// will probably not work since the matrix will not always be positive definite //[SkippableFact] private static void TestRowAdditionReverse() { Skip.IfNot(TestSettings.TestSuiteSparse, TestSettings.MessageWhenSkippingSuiteSparse); Matrix original = Matrix.CreateFromArray(SparsePosDef10by10.Matrix); Vector rhs = Vector.CreateFromArray(SparsePosDef10by10.Rhs); // Start the matrix as diagonal var matrixExpected = Matrix.CreateIdentity(original.NumColumns); var dok = DokSymmetric.CreateIdentity(SparsePosDef10by10.Order); var factor = CholeskySuiteSparse.Factorize(dok.BuildSymmetricCscMatrix(true), false); for (int i = 0; i < matrixExpected.NumRows; ++i) { // Update matrix Vector newRowVector = original.GetRow(i); matrixExpected.SetSubrow(i, newRowVector); matrixExpected.SetSubcolumn(i, newRowVector); //Console.WriteLine($"\nOnly dofs [0, {i}]"); factor.AddRow(i, SparseVector.CreateFromDense(newRowVector)); // Solve new linear system Vector solutionExpected = matrixExpected.FactorCholesky(true).SolveLinearSystem(rhs); Vector solutionComputed = factor.SolveLinearSystem(rhs); comparer.AssertEqual(solutionExpected, solutionComputed); } }