2.2.3.9.70 matrixbase::SumDiagonals
Contents
Description
Sum the diagonals of this matrix placing the result in a vector.
Syntax
int SumDiagonals( vectorbase & vbSum, int nBegin = 0, const int* pnEnd = NULL )
Parameters
- vbSum
- [output] vector containing the summed rows
- nBegin
- [input] specifying the begin diagonal, default 0 is the main diagonal, > 0 is above the main diagonal, and < 0 is below the main diagonal.
- pnEnd
- [input] specifying the end diagonal
Return
Returns 0 on success or -1 on failure.
Examples
EX1
void matrixbase_SumDiagonals_ex1() { int rc, ii,jj; matrix<double> mat = { {-1, 0, 3, 99}, { 0, 2, 6, 0}, { 1, 4, 9, 0} }; mat[0][3]=NANUM; vector vSum; int nEnd = -1; int nRet = mat.SumDiagonals(vSum, -2, &nEnd); }
Remark
Sum the diagonals of this matrix placing the result in a vector. The underlying base type of the vector must not be less than the underlying base type of the matrix.
See Also
Header to Include
origin.h