Using N4DJ in java nd4j-native-platform version 0.9.1
I am trying to create a subset of an array by only selecting certain rows. I do this using the getRows method.
This works fine for matrices, however when my matrix comprises of a single row vector I get an incorrect result, see below example showing how calling method getRow(int i) works fine compared to getRows(int...rows):
final INDArray singleRowArray = Nd4j.create(new double[]{1,2,3,4},new int[]{1,4});
System.out.println(singleRowArray); //Output: [1.00, 2.00, 3.00, 4.00]
final INDArray getSingleRowArray = singleRowArray.getRow(0);
System.out.println(getSingleRowArray); //Output: [1.00, 2.00, 3.00, 4.00] as expected
final INDArray getSingleRowArrayFromGetRowsSingle = singleRowArray.getRows(0);
System.out.println(getSingleRowArrayFromGetRowsSingle); //Output: [1.00, 0.00, 0.00, 0.00] expected the same as above
Current work around is to check whether the matrix is in fact a single vector and calling the getRow instead of the getRows method.
Is this a known issue for N4DJ or am I misunderstanding something?
Note that a similar issue is encountered for column vectors.