Sum of matrix
msum(A, n): calculate sum on a matrix or a multidimensional matrix,n is the dimensionalitylayeron which the summarization is performed.
For example a 5-by-4 matrix [[1,0,2,3],[0,71,5,6],[0,0,6,5],[35,53,2,3],[35,8,4,2]] can be summed on rows or columns by setting n
A |
|
1 |
[[1,0,2,3],[0,71,5,6],[0,0,6,5],[35,53,2,3],[35,8,4,2]] |
2 |
=msum(A1,1) |
3 |
=msum(A1,2) |
4 |
=msum@a(A1) |
A1 Input the 5-by-4 matrix, with 5 vector members
A2 n=1, calculate sum on the matrix’s first dimension layer, counterpoint addition of the vector members.That is, calculate sum on members of each column.
A3 n=2, calculate sum on the matrix’s seconddimension layer, add the elements within each vector. That is, calculate sum on members of each row.
A4 @a means sum over all the elements of A1
Another example, in a 3-dimensional matrix, you can also sum in different dimensionlayer by setting n
A |
|
1 |
[[[111,112,113],[121,122,123],[131,132,133]],[[211,212,213],[221,222,223],[231,232,233]]] |
2 |
=msum(A1, 1) |
3 |
=msum(A1, 2) |
4 |
=msum(A1, 3) |
5 |
=msum@a(A1) |
A1 Inputa 3-dimensional matrix with 2 members, both 3-by-3 matrices
A2 n=1, the sum is summarized on the first dimension layer. That is, the counterpoint addition of two member matrices
A3 n=2, the sum is summarized on the second dimension layer. That is, the counterpoint addition of three vectors in each member matrix
A4 n=3, the sum is summarized on the third dimension layer. That is, sum the members of each vector.
A5 @a means sum over all the elements of A1.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL