From the following code:
/** Array for internal storage of elements.
@serial internal array storage.
*/
private double[][] A;
/** Row and column dimensions.
@serial row dimension.
@serial column dimension.
*/
private int m, n;
public Matrix times (Matrix B) {
if (B.m != n) {
throw new IllegalArgumentException("Matrix inner dimensions must agree.");
}
Matrix X = new Matrix(m,B.n);
double[][] C = X.getArray();
double[] Bcolj = new double[n];
for (int j = 0; j < B.n; j++) {
for (int k = 0; k < n; k++) {
Bcolj[k] = B.A[k][j];
}
for (int i = 0; i < m; i++) {
double[] Arowi = A[i];
double s = 0;
for (int k = 0; k < n; k++) {
s += Arowi[k]*Bcolj[k];
}
C[i][j] = s;
}
}
return X;
}
double[] Arowi = A[i];
What is this line doing?
A is a two dimensional Matrix, why is A[i] allowed? and what exactly is it doing?
Is that the same thing as A[i][0]
?
This notation is confusing.
Also could someone translate that line to .NET, how would you do that with a double[,] Matrix
?
I know there is a Matrix.GetLength() which gives you a specified length of a dimension. But comparison to that line of Java code, how would that be translated?
EDIT I believe I fixed it by just replacing that line and passing in my matrix to copy the first row into a new one dimensional matrix and returning it
public double[] ConvertFirstRowOfMultiArrayToOneArray(double[,] p)
{
double[] array = new double[p.Length];
for (int i = 0; i < p.GetLength(0); i++)
{
array[i] = p[0, i];
}
return array;
}