本文整理汇总了C++中Factor::factorize方法的典型用法代码示例。如果您正苦于以下问题:C++ Factor::factorize方法的具体用法?C++ Factor::factorize怎么用?C++ Factor::factorize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factor
的用法示例。
在下文中一共展示了Factor::factorize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestCaseFunctionOperatorObj
int TestCaseFunctionOperatorObj(){
SparseMatrix A{3,3, true};
A(0, 0) = 1;
A(0, 1) = 1;
A(0, 2) = 1;
A(1, 2) = 5;
A(2, 2) = -1;
A.build();
DenseMatrix b{3};
b(0) = 6;
b(1) = -4;
b(2) = 27;
// Ax = b
Factor factor = A.analyze();
bool res = factor.factorize(A);
TINYTEST_ASSERT(res);
DenseMatrix x = solve(factor, b);
double expected[] = {2.78571f,4.57143f,-1.35714f};
assertEqual(expected, x.getData(), 3);
// update values
A.zero();
A(0, 0) = 2;
A(0, 1) = 9;
A(0, 2) = 7;
A(1, 2) = 8;
A(2, 2) = -3;
factor.factorize(A);
x = solve(factor, b);
double expected2[] = {1.0935,1.76937,-1.73019};
assertEqual(expected2, x.getData(), 3);
return 1;
}
示例2: SolveSparseDenseFactorTestObj
int SolveSparseDenseFactorTestObj()
{
SparseMatrix A{3,3, true};
A(0, 0) = 1;
A(0, 1) = 1;
A(0, 2) = 1;
A(1, 2) = 5;
A(2, 2) = -1;
A.build();
DenseMatrix b{3};
b(0) = 6;
b(1) = -4;
b(2) = 27;
Factor F;
F = A.analyze();
bool res = F.factorize(A);
DenseMatrix x = solve(F, b);
double expected[] = {2.78571f,4.57143f,-1.35714f};
assertEqual(expected, x.getData(), 3);
// update values
A.zero();
A(0, 0) = 2;
A(0, 1) = 9;
A(0, 2) = 7;
A(1, 2) = 8;
A(2, 2) = -3;
F.factorize(A);
x = solve(F, b);
double expected2[] = {1.0935,1.76937,-1.73019};
assertEqual(expected2, x.getData(), 3);
return 1;
}
示例3: SingularTestObj
int SingularTestObj(){
SparseMatrix A{3,3, true};
A(2, 2) = 1;
A.build();
DenseMatrix b{3};
b(0) = 0;
b(1) = 1;
b(2) = 0;
Factor factor = A.analyze();
bool res = factor.factorize(A);
TINYTEST_ASSERT(!res);
DenseMatrix x = solve(factor, b);
return 1;
}