// Calculates the matrix element for the kinetic energy public double kineticEnergyElement(matrix A, matrix B) { QRdecomposition qr = new QRdecomposition(A + B); matrix inverse = qr.inverse(); matrix tmp = A * inverse * B * problem.getLambda(); return(3.0 / 2.0 * tmp.trace() * overlapElement(A, B)); }
public void Test_inverse() { matrix A = new matrix("1,2,3;0,1,4;5,6,0"); QRdecomposition qr = new QRdecomposition(A); matrix inv = qr.inverse(); matrix inverse = new matrix("-24,18,5;20,-15,-4;-5,4,1"); /* Assert.IsTrue(inv.equals(inverse)); */ // It is true.... Assert.IsTrue(Misc.sortOfEqual(inv, inverse, 8)); }