public static double elementSumSq ( DMatrixD1 m ) { // minimize round off error double maxAbs = CommonOps_DDRM . elementMaxAbs ( m ) ; if ( maxAbs == 0 ) return 0 ; double total = 0 ; int N = m . getNumElements ( ) ; for ( int i = 0 ; i < N ; i ++ ) { double d = m . data [ i ] / maxAbs ; total += d * d ; } return maxAbs * total * maxAbs ; }
Sums up the square of each element in the matrix . This is equivalent to the Frobenius norm squared .