We don't know what an Array2DRowRealMatrix or ArrayRealVector is; b.t.w. those two loops of mine don't care what the dimensions of that matrix are, i.e. they simply 'walk' over any two dimensional matrix and set each element to a (pseudo) random value.

kind regards,

Jos

12-23-2009, 03:56 PM

rootpi

Quote:

Originally Posted by JosAH

We don't know what an Array2DRowRealMatrix or ArrayRealVector is; b.t.w. those two loops of mine don't care what the dimensions of that matrix are, i.e. they simply 'walk' over any two dimensional matrix and set each element to a (pseudo) random value.

kind regards,

Jos

OK, thanks! I think I got it, the Array2DRowRealMatrix and the ArrayRealVector are the codes I have to write in order to do the LUDecomposition, it's the code of the library from Apache Common Mahts. Now I've got a problem, when I try to print an element of my matrix it gives an exception. What should I do??
And where is the mistake in using this code?:

OK, thanks! I think I got it, the Array2DRowRealMatrix and the ArrayRealVector are the codes I have to write in order to do the LUDecomposition, it's the code of the library from Apache Common Mahts. Now I've got a problem, when I try to print an element of my matrix it gives an exception. What should I do??
And where is the mistake in using this code?:

Please mention the exact error message; my guess is that this was an ArrayIndexOutOfBoundsException. Look at your code: say n == 3, you allocate a 3x3 matrix and you want to set element [3][3] to a random value but a matrix with three rows has rows 0, 1 and 2; 3 is an out of bound value. Use my nested loops instead for the filling of a matrix; even better, turn it into a separate method, e.g. fillMatrix(double[][] matrix).