private List < List < Double > > deepCopy ( final List < List < Double > > original ) { final List < List < Double > > result = new ArrayList <> ( original . size ( ) ) ; for ( final List < Double > originalRow : original ) { final List < Double > row = new ArrayList <> ( originalRow . size ( ) ) ; for ( final double element : originalRow ) { row . add ( element ) ; } result . add ( row ) ; } return result ; }
Create a deep copy to make the matrix immutable .