- Matrix origmat = new Matrix(in, n, n);
-
- // System.out.println(" --- Original matrix ---- ");
- // / origmat.print(System.out);
- // System.out.println();
- // System.out.println(" --- transpose matrix ---- ");
- Matrix trans = origmat.transpose();
-
- // trans.print(System.out);
- // System.out.println();
- // System.out.println(" --- OrigT * Orig ---- ");
- Matrix symm = trans.postMultiply(origmat);
-
- // symm.print(System.out);
- // System.out.println();
- // Copy the symmetric matrix for later
- // Matrix origsymm = symm.copy();
-
- // This produces the tridiagonal transformation matrix
- // long tstart = System.currentTimeMillis();
- symm.tred();
-
- // long tend = System.currentTimeMillis();
-
- // System.out.println("Time take for tred = " + (tend-tstart) + "ms");
- // System.out.println(" ---Tridiag transform matrix ---");
- // symm.print(System.out);
- // System.out.println();
- // System.out.println(" --- D vector ---");
- // symm.printD(System.out);
- // System.out.println();
- // System.out.println(" --- E vector ---");
- // symm.printE(System.out);
- // System.out.println();
- // Now produce the diagonalization matrix
- // tstart = System.currentTimeMillis();
- symm.tqli();
- // tend = System.currentTimeMillis();
-
- // System.out.println("Time take for tqli = " + (tend-tstart) + " ms");
- // System.out.println(" --- New diagonalization matrix ---");
- // symm.print(System.out);
- // System.out.println();
- // System.out.println(" --- D vector ---");
- // symm.printD(System.out);
- // System.out.println();
- // System.out.println(" --- E vector ---");
- // symm.printE(System.out);
- // System.out.println();
- // System.out.println(" --- First eigenvector --- ");
- // double[] eigenv = symm.getColumn(0);
- // for (int i=0; i < eigenv.length;i++) {
- // Format.print(System.out,"%15.4f",eigenv[i]);
- // }
- // System.out.println();
- // double[] neigenv = origsymm.vectorPostMultiply(eigenv);
- // for (int i=0; i < neigenv.length;i++) {
- // Format.print(System.out,"%15.4f",neigenv[i]/symm.d[0]);
- // }
- // System.out.println();
+ /**
+ * Multiplies every entry in the matrix by the given value.
+ *
+ * @param
+ */
+ @Override
+ public void multiply(double by)
+ {
+ for (double[] row : value)
+ {
+ if (row != null)
+ {
+ for (int i = 0; i < row.length; i++)
+ {
+ row[i] *= by;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void setD(double[] v)
+ {
+ d = v;
+ }
+
+ @Override
+ public void setE(double[] v)
+ {
+ e = v;
+ }
+
+ public double getTotal()
+ {
+ double d = 0d;
+ for (int i = 0; i < this.height(); i++)
+ {
+ for (int j = 0; j < this.width(); j++)
+ {
+ d += value[i][j];
+ }
+ }
+ return d;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(MatrixI m2, double delta)
+ {
+ if (m2 == null || this.height() != m2.height()
+ || this.width() != m2.width())
+ {
+ return false;
+ }
+ for (int i = 0; i < this.height(); i++)
+ {
+ for (int j = 0; j < this.width(); j++)
+ {
+ double diff = this.getValue(i, j) - m2.getValue(i, j);
+ if (Math.abs(diff) > delta)
+ {
+ return false;
+ }
+ }
+ }
+ return true;