File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -86,20 +86,19 @@ public static Matrix constructWithCopy(final double A[][])
8686 {
8787 final int m = A .length ;
8888 final int n = A [0 ].length ;
89- final Matrix X = new Matrix (m , n );
90- final double [][] C = X .getArray ();
91- for (int i = 0 ; i < m ; i ++)
89+ final double C [][] = new double [m ][];
90+ for (int i = 0 ; i < C .length ; i ++)
9291 {
93- if (A [i ].length != n )
94- {
95- throw new IllegalArgumentException ("All rows must have the same length." ); //$NON-NLS-1$
96- }
97- for ( int j = 0 ; j < n ; j ++)
98- {
99- C [i ][ j ] = A [i ][ j ] ;
100- }
92+ if (A [i ].length != n )
93+ {
94+ throw new IllegalArgumentException ("All rows must have the same length." ); //$NON-NLS-1$
95+ }
96+ else
97+ {
98+ C [i ] = Arrays . copyOf ( A [i ], n ) ;
99+ }
101100 }
102- return X ;
101+ return new Matrix ( m , n , C ) ;
103102 }
104103
105104 /**
@@ -705,10 +704,10 @@ public double[][] getArray()
705704 */
706705 public double [][] getArrayCopy ()
707706 {
708- final double C [][] = new double [this .A . length ][];
707+ final double C [][] = new double [this .m ][];
709708 for (int i = 0 ; i < C .length ; i ++)
710709 {
711- C [i ] = Arrays .copyOf (this .A [i ], this .A [ i ]. length );
710+ C [i ] = Arrays .copyOf (this .A [i ], this .n );
712711 }
713712 return C ;
714713 }
You can’t perform that action at this time.
0 commit comments