我正在尝试按照这些说明构建MATRIX类;
构造函数:编写三个构造函数
将矢量列表作为逗号分隔的参数列表,并将这些矢量从第一个到最后一个转换为矩阵(Vector是下面将要解释的另一个类),并从这些矢量构造矩阵,或者将它们创建为由另一个参数确定的矩阵的列或行。 (如果0将它们视为原始向量,如果1将这些向量视为矩阵的列)
取一个整数并生成由该整数确定的维度的单位矩阵。
在矩阵对象上调用以下方法,并根据需要采用另一个矩阵或任何其他相关参数。
这是我的矩阵类;
package p1;
public class Matrix{
public double myArray[][];
public Matrix(int b,double...vectors) {
this.myArray=vectors;
double myArray[][] = new double[vectors.length][];
int row = vectors.length;
int column = vectors[0].length;
for (int i = 0; i < row; i++) {
myArray[i] = new double[column];
}
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
if(b==0)
{
myArray[i][j] = vectors[i][j]; // ERROR HERE
}
else
{
myArray[j][i] = vectors[i][j]; // ERROR HERE
}
}
}
}
public Matrix(int d){
double myArray[][]=new double[d][d];
}
}
我在代码中显示了错误。我无法在一个2D数组中集成两个向量,使其等于矩阵。