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;
}
/**
}
else
{
- // System.out.println("Iteration " + iter);
+ // jalview.bin.Console.outPrintln("Iteration " + iter);
}
g = (d[l] - d[l - 1]) / (2.0 * e[l - 1]);
}
else
{
- // System.out.println("Iteration " + iter);
+ // jalview.bin.Console.outPrintln("Iteration " + iter);
}
g = (d[l] - d[l - 1]) / (2.0 * e[l - 1]);
}
}
}
+
+ @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;
+ }
}