public ColumnMajorMatrixIterator columnMajorIterator ( ) { return new ColumnMajorMatrixIterator ( rows , columns ) { private long limit = ( long ) rows * columns ; private int i = - 1 ; @ Override public int rowIndex ( ) { return i - columnIndex ( ) * rows ; } @ Override public int columnIndex ( ) { return i / rows ; } @ Override public double get ( ) { return Matrix . this . get ( rowIndex ( ) , columnIndex ( ) ) ; } @ Override public void set ( double value ) { Matrix . this . set ( rowIndex ( ) , columnIndex ( ) , value ) ; } @ Override public boolean hasNext ( ) { return i + 1 < limit ; } @ Override public Double next ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } i ++ ; return get ( ) ; } } ; }
Returns a column - major matrix iterator .