Reputation: 17470
e.g. matrix:
a b c
d e f
g h i
->
column vector
a+b+c
d+e+f
g+h+i
I can think of ugly solutions with sum, and maybe less ugly solutions with multiplying by a row vector, but is there a nice way?
Upvotes: 1
Views: 623
Reputation: 17576
A matrix is represented as a wrapper around a collection of lists, where each list is a row. So mapping over the arguments of matrix
is mapping over the rows. You can do something like this: map(lambda([r], [lsum(x, x, r)]), A)
where A
is your matrix.
Upvotes: 3