sesodesa
sesodesa

Reputation: 1603

Calculate the sum of the elements of an elementwise product of two matrices in Maxima

What's in the title and I've tried thus far:

sum(lambda([i,j], M[i,j] * Ma[i,j]))

This expression gives me the Wrong number of arguments error. Doesn't sum() operate on lists, or am I missing something like an expression in the sum function call?

Upvotes: 1

Views: 343

Answers (1)

sesodesa
sesodesa

Reputation: 1603

Turns out the answer was rather simple:

lsum(i,i, list_matrix_entries(M3 * Ma))

This essentially translates to (\sum_{i\in{set of the elements of M*Ma}} i) in LaTeX.

Upvotes: 1

Related Questions