public static long get1D ( DMatrixRMaj A , int n ) { long before = System . currentTimeMillis ( ) ; double total = 0 ; for ( int iter = 0 ; iter < n ; iter ++ ) { int index = 0 ; for ( int i = 0 ; i < A . numRows ; i ++ ) { int end = index + A . numCols ; while ( index != end ) { total += A . get ( index ++ ) ; } } } long after = System . currentTimeMillis ( ) ; // print to ensure that ensure that an overly smart compiler does not optimize out // the whole function and to show that both produce the same results. System . out . println ( total ) ; return after - before ; }
Get by index is used here .