public DenseMatrix(double[][] matrix){
  this.matrix=new double[matrix.length][matrix[0].length];
  for (int i=0; i < this.matrix.length; i++)   if (matrix[i].length != this.matrix[i].length)   throw new RuntimeException("Given matrix was not of consistent size (rows have diffrent lengths)");
 else   System.arraycopy(matrix[i],0,this.matrix[i],0,this.matrix[i].length);
}

public DenseMatrix ( double [ ] [ ] matrix ) { this . matrix = new double [ matrix . length ] [ matrix [ 0 ] . length ] ; for ( int i = 0 ; i < this . matrix . length ; i ++ ) if ( matrix [ i ] . length != this . matrix [ i ] . length ) throw new RuntimeException ( "Given matrix was not of consistent size (rows have diffrent lengths)" ) ; else System . arraycopy ( matrix [ i ] , 0 , this . matrix [ i ] , 0 , this . matrix [ i ] . length ) ; }
creates a new matrix that is a clone of the given matrix . an error will be throw if the rows of the given matrix are not all the same size
