code: public static double elementSum( DMatrixD1 mat ) {
          double total = 0;
  
          int size = mat.getNumElements();
  
          for( int i = 0; i < size; i++ ) {
              total += mat.get(i);
          }
  
          return total;
      }
docs: <p>
  Computes the sum of all the elements in the matrix:<br>
  <br>
  sum(i=1:m , j=1:n ; a<sub>ij</sub>)
  <p>
  
  @param mat An m by n matrix. Not modified.
  @return The sum of the elements.