void
unread,May 2, 2012, 5:31:38 PM5/2/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jblas-users
Hello,
I am confusing why the following simple code makes strange results and
even an error. See the following codes and outputs.
[Code]
float[][] X_data = new float[][]{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10},
{11, 12, 13, 14, 15}};
FloatMatrix X = new FloatMatrix(X_data);
int[] rows = new int[]{0, 1, 2};
int[] cols = new int[]{0, 1, 2, 3, 4};
System.out.println("matrix test");
System.out.println("------------------------------------------");
System.out.println(X.get(rows, cols));
System.out.println("------------------------------------------");
System.out.println(X.get(0, cols));
System.out.println(X.get(1, cols));
System.out.println(X.get(2, cols));
System.out.println("------------------------------------------");
System.out.println(X.get(rows, 4));
System.out.println(X.get(rows, 3));
System.out.println(X.get(rows, 2));
System.out.println(X.get(rows, 1));
System.out.println(X.get(rows, 0));
[Output]
matrix test
------------------------------------------
[1.0, 2.0, 3.0, 4.0, 5.0; 6.0, 7.0, 8.0, 9.0, 10.0; 11.0, 12.0, 13.0,
14.0, 15.0]
------------------------------------------
[1.0, 2.0, 3.0, 4.0, 5.0]
[6.0, 7.0, 8.0, 9.0, 10.0]
[11.0, 12.0, 13.0, 14.0, 15.0]
------------------------------------------
[5.0, 0.0, 0.0, 0.0; 10.0, 0.0, 0.0, 0.0; 15.0, 0.0, 0.0, 0.0]
[4.0, 0.0, 0.0; 9.0, 0.0, 0.0; 14.0, 0.0, 0.0]
[3.0, 0.0; 8.0, 0.0; 13.0, 0.0]
[2.0; 7.0; 12.0]
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at org.jblas.FloatMatrix.put(FloatMatrix.java:1220)
at org.jblas.FloatMatrix.get(FloatMatrix.java:623)
at learningEngine.NodeData.main(NodeData.java:72)
-void