<< mps_sub mpscilab mps_trace >>

mpscilab >> mpscilab > mps_sum

mps_sum

Sum of matrix elements

Calling Sequence

mps_sum( rop, op [, orientation] )
rop = mps_sum( op [, orientation] )

Overloaded usage:

rop = sum( op [, orientation] )

Arguments

rop

multi-precision matrix

orientation

single character string

algorithm

single character string

Description

Compute the sum of the elements of matrix op according to orientation parameter using the specified algorithm. The result is return in rop which must be of the right size for the specified computation.

mps_sum( rop, op [, orientation] )

Computes the sum of all of the elements of op along the specified orientation and returns the result in rop. The orientation is specified as a single character either '*', 'r' and 'c' respectively for row, column and whole matrix.

rop = mps_sum( op [, orientation] )

Creates a multi-precision matrix of the correct size and with the same precision as op containing the result.

rop = sum( rop, op [, orientation] )

Overloaded usage.

Examples

// Sum of all the elements of a matrix.
A = [1 2; 3 4]
mpsA = mps_init2(A,100)
rop = mps_init(1,1,100)
rop = mps_sum(A)

// Column-wise sum of the elements of a matrix.
A = [1 2; 3 4]
mpsA = mps_init2(A,100)
rop = mps_init(1,2,100)
mps_sum(rop,A,'c')

// Sum of all the elements of a matrix using the quick algorithm.
A = [1 2; 3 4]
mpsA = mps_init2(A,100)
rop = mps_init(1,1,100)
mps_sum(rop,A,'*','q')

// Sum of all the elements of a matrix using the overloaded sum() function.
A = [1 2; 3 4]
mpsA = mps_init2(A,100)
rop = sum(A)

See Also

<< mps_sub mpscilab mps_trace >>