Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

New Post: add several vectors

$
0
0
Assuming all of the "vectors" are the same length (if they aren't, then the result will be the same length as the shortest):
List<double[]> lstVectors = ...;
double[] vectorSum = lstVectors.Aggregate((a,b) => a.Zip(b, (aa, bb) => aa + bb).ToArray());
Not the most efficient, but it ought to do the job.

(For some reason the "plus" in the expression above is getting converted to the XML entity notation? But not in the editor Preview...)

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>