import jalview.util.MessageManager;
import java.io.PrintStream;
+import java.util.Arrays;
/**
* A class to model rectangular matrices of double values and operations on them
System.arraycopy(value[i], 0, newmat[i], 0, value[i].length);
}
- return new Matrix(newmat);
+ Matrix m = new Matrix(newmat);
+ if (this.d != null)
+ {
+ m.d = Arrays.copyOf(this.d, this.d.length);
+ }
+ if (this.e != null)
+ {
+ m.e = Arrays.copyOf(this.e, this.e.length);
+ }
+
+ return m;
}
/**
}
}
Matrix m1 = new Matrix(in);
+
Matrix m2 = (Matrix) m1.copy();
assertNotSame(m1, m2);
assertTrue(matrixEquals(m1, m2));
+ assertNull(m2.d);
+ assertNull(m2.e);
+
+ /*
+ * now add d and e vectors and recopy
+ */
+ m1.d = Arrays.copyOf(in[2], in[2].length);
+ m1.e = Arrays.copyOf(in[4], in[4].length);
+ m2 = (Matrix) m1.copy();
+ assertNotSame(m2.d, m1.d);
+ assertNotSame(m2.e, m1.e);
+ assertEquals(m2.d, m1.d);
+ assertEquals(m2.e, m1.e);
}
/**