Source

#include "symmatrix.ppp"intTSymMatrix::getindex(constint&i,constint&j,boolraiseExceptions)const{if(i==j){if((i>=dim)||(i<0))raiseError("index out of range");return(i*(i+3))>>1;}if(i>j){if((i>=dim)||(j<0))raiseError("index out of range");if((matrixType==Upper)||(matrixType==UpperFilled))if(raiseExceptions)raiseError("index out of range for upper triangular matrix");elsereturn-1;return((i*(i+1))>>1)+j;}if((j>=dim)||(i<0))raiseError("index out of range");if((matrixType==Lower)||(matrixType==LowerFilled))if(raiseExceptions)raiseError("index out of range for lower triangular matrix");elsereturn-1;return((j*(j+1))>>1)+i;}