/// <summary> /// If the matrices stored in this object have already been calculated, they will be reused even if the original /// free-free stiffness matrix has changed. To avoid that, this method must be called. /// </summary> public void Clear() { inverseKii = null; inverseKiiDiagonal = null; inverseKrr = null; Kbb = null; Kbi = null; Kcc = null; Krc = null; Krr = null; KccStar = null; //linearSystem.Matrix = null; // DO NOT DO THAT!!! The analyzer manages that. }
/// <summary> /// inv(G^T * Q * G) /// </summary> public void InvertCoarseProblemMatrix() { CalculateMatrixG(); //Matrix GQG = matrixG.ThisTransposeTimesOtherTimesThis(matrixQ); Matrix GQG = matrixG.MultiplyRight(matrixQ.Multiply(matrixG), true); var writer = new LinearAlgebra.Output.FullMatrixWriter(); //writer.WriteToFile(GQG, @"C:\Users\Serafeim\Desktop\output.txt"); factorGQG = GQG.FactorCholesky(true); }
private static void TestSystemSolution(LinearAlgebraProviderChoice providers) { TestSettings.RunMultiproviderTest(providers, delegate() { // positive definite var A = Matrix.CreateFromArray(SymmPosDef10by10.Matrix); var b = Vector.CreateFromArray(SymmPosDef10by10.Rhs); var xExpected = Vector.CreateFromArray(SymmPosDef10by10.Lhs); CholeskyFull factorization = A.FactorCholesky(true); Vector xComputed = factorization.SolveLinearSystem(b); comparer.AssertEqual(xExpected, xComputed); }); }
private static void TestFactorization(LinearAlgebraProviderChoice providers) { TestSettings.RunMultiproviderTest(providers, delegate() { // positive definite var A1 = Matrix.CreateFromArray(SymmPosDef10by10.Matrix); var expectedU1 = Matrix.CreateFromArray(SymmPosDef10by10.FactorU); CholeskyFull factorization1 = A1.FactorCholesky(true); Matrix computedU1 = factorization1.GetFactorU(); comparer.AssertEqual(expectedU1, computedU1); // singular var A2 = Matrix.CreateFromArray(SquareSingular10by10.Matrix); Assert.Throws <IndefiniteMatrixException>(() => A2.FactorCholesky(true)); }); }