public static void convert(FMatrix input , DMatrix output ) { if( input.getNumRows() != output.getNumRows() ) throw new IllegalArgumentException("Number of rows do not match"); if( input.getNumCols() != output.getNumCols() ) throw new IllegalArgumentException("Number of columns do not match"); for( int i = 0; i < input.getNumRows(); i++ ) { for( int j = 0; j < input.getNumCols(); j++ ) { output.unsafe_set(i,j, input.unsafe_get(i,j)); } } }
/** * Generic, but slow, conversion function. * * @param input Input matrix. * @param output Output matrix. */ public static void convert(DMatrix input , DMatrix output ) { if( output instanceof ReshapeMatrix ) { ((ReshapeMatrix)output).reshape(input.getNumRows(),input.getNumCols()); } else { if (input.getNumRows() != output.getNumRows()) throw new IllegalArgumentException("Number of rows do not match"); if (input.getNumCols() != output.getNumCols()) throw new IllegalArgumentException("Number of columns do not match"); } for( int i = 0; i < input.getNumRows(); i++ ) { for( int j = 0; j < input.getNumCols(); j++ ) { output.unsafe_set(i,j,input.unsafe_get(i,j)); } } }