例如在如下一段代码中:

        Matrix m = new Matrix(2,3); 
        for(int i=0; i<m.getRowDimension(); i++) {
            for(int j=0; j<m.getColumnDimension(); j++) {
                m.set(i, j, Math.random());
                System.out.print(m.get(i, j) + " ");
            }
            System.out.println();
        }
        
        Matrix t = m.copy();
        Matrix t1 = null;
            t1 = t.transpose();
        t.set(0, 0, 1000000);
        System.out.println(t.get(0, 0) + "  " + m.get(0, 0) + " " + t1+ " " + t + " " + m);
        //输出结果为:1000000.0  0.7540635606803358 Jama.Matrix@486c8255 Jama.Matrix@4be0bf98 Jama.Matrix@1042bb13

上述实验说明:matrix 的copy(), transpose()方法分别申请了额外的空间。另外如果想对矩阵做转置变换的话,要额外申请一块空间。因为原来的空间已经确定,矩阵的行列维度也确定了,因此不能再随意改变。

 

相关文章:

  • 2021-07-21
  • 2021-06-21
  • 2021-12-20
  • 2021-07-13
  • 2021-05-25
  • 2021-09-22
  • 2022-12-23
猜你喜欢
  • 2021-07-06
  • 2021-06-25
  • 2021-07-31
  • 2021-09-14
  • 2021-12-14
  • 2021-08-10
  • 2021-10-02
相关资源
相似解决方案