Skip to main content
3-Newcomer
December 31, 2018
Question

how do I sum all elements of an array?

  • December 31, 2018
  • 5 replies
  • 17783 views

I need to sum all elements of an array.  Is there a function that does this?

5 replies

21-Topaz II
January 2, 2019

Hi,

Yes there is a function.  It is on the ribbon at Maths | Operators And Symbols | Operators | Calculus.

 

Capture.JPG

Cheers Terry

21-Topaz II
January 3, 2019

Hi,

This for an "array" rather than just a "vector"

Capture.JPG

25-Diamond I
January 3, 2019

The summation symbol Terry pointed you to only works with column and row vectors (matrices with either just one column or just one row).

In case you are looking for the sum of all elements of an arbitrary matrix, here are two shorter routines which do the job:

B1.png

And here is a way to sum up recursively all scalars even in multiple nested matrices (for whatever that may be worth).

B2.png

Worksheet in format P5 attached

19-Tanzanite
January 3, 2019

You could also do the following for matrices (though not nested matrices):

 

summation.PNG

Alan

23-Emerald IV
January 3, 2019

Or, to be independent of ORIGIN and of the size of the array/Matrix:

LM_20190103_ArraySum.png

Success!
Luc

Prime 3.1 file attached

25-Diamond I
January 4, 2019

OK, here sure are many ways to skin a cat.

 

Even though DJV doesn't show any interest, here are two more ways to achieve the desired result.

B1.png

 

Personally I still would prefer my first one, "SumAll1". It also seems to be the fastest, followed by the recursive "SumAll3".

B2.png

Worksheet in Format P5 attached.