multiplyByConstant方法和矩阵

时间:2016-03-06 10:17:30

标签: matrix

public class Matrix{
    public double myArray[][];
    public Matrix(double a[][]){
        this.myArray=a;
    }


    public Matrix(int b,Vector...vectors) {

    double myArray[][] = new double[vectors.length][];
    int row = vectors.length;

    int column = vectors.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].getYourArray()[j];
            }
            else
            {
                myArray[j][i] = vectors[i].getYourArray()[j]; 
        }
    }
}
}
   public Matrix(int a){
       double [][] t=new double[a][a];
       Matrix z=new Matrix(t);
       for(int i=0;i<a;i++){
           for(int j=0;j<a;j++){
               if(i==j) z.myArray[i][j]=1;
               else z.myArray[i][j]=0;

           }
       }
       this.myArray=z.myArray;
   }

   public Matrix multiplyByConstant(double m){ // here


       }

   }

multiplyByConstatnt:乘以常数:将double作为乘法因子,并将矩阵的每个元素与该因子相乘并返回一个新矩阵。

我还有矢量和测试类,但我不知道如何将此方法与矩阵

一起使用

0 个答案:

没有答案