1

I am porting some MatLab code to MathDotNet / C#

What is the function to return each element in a vector multiplied together?

In MatLab i can do prod(v)

What is the equivalent of this in MathDotNet?

Joe Booth
  • 501
  • 1
  • 4
  • 13

1 Answers1

2

Doesn't look like it exists, but you can use LINQ to accomplish it.

int total = vector.Enumerate().Aggregate((product, next) => product * next);
Clay Ver Valen
  • 1,033
  • 6
  • 10
  • hmm - is there a recommended approach for extending MathDotNet - i.e. LINKQ vs MathDotNet's internal iterators? – Joe Booth Dec 04 '15 at 05:30