Matrix::ConditionNr Property

__declspec(property(get = GetConditionNr)) double ConditionNr;

Stores the condition number reciprocial value after the call to LUSolve.

Read: double GetConditionNr() const;
Remarks:

The property is set by the method. It contains the calling matrix condition number reciprocial value after the call to Matrix::LUSolve method and if Matrix::ConditionNumber property was not cnNone. If the ConditionNr (inverse of condition number) is a very small number (thus the condition number is very large), then the calling matrix is ill-conditioned and the error in the solution will also be large. The condition number is used for analyzing the errors in the solution of a system of linear equations.

In practice, most computations are performed with rounding errors. Besides, you often need to solve a system Ax = b where the data (the elements of A and b) are not known exactly. Therefore, it's important to understand how the data errors and rounding errors can affect the solution X. If X is the exact solution of Ax = b, and X + dx is the exact solution of a perturbed problem (A + dA)X = (b + db), then

∥δx∥∥x∥≤κ(A)(∥δA∥∥A∥+∥δb∥∥b∥), whereκ(A)=∥A∥⋅∥A−1∥\frac{\|\delta x \|}{\|x\|} \leq \kappa (A) \left(\frac{\|\delta A\|}{\|A\|} + \frac{\|\delta b\|}{\|b\|}\right) \quad \text{, where} \quad \kappa (A) = \|A\|\cdot \|A^{-1}\|

In other words, relative errors in A or b may be amplified in the solution vector X by a factor k(A) = ||A|| ||A -1 || called the condition number of A. The norm used to calculate the condition number is set by the Matrix::ConditionNumber property. Rounding errors have the same effect as relative perturbations c(n)e in the original data. Here e is the machine precision, and c(n) is a modest function of the matrix order n. The corresponding solution error is ||dx||/||x|| <= c(n)k(A)e. (The value of c(n) is seldom greater than 10n), Thus, if your matrix A is ill-conditioned (that is, its condition number k(A) is very large), then the error in the solution X is also large; you may even encounter a complete loss of precision. This loss can be greatly reduced by enabling the Matrix::RefineSolution property.

Examples
#include "MtxExpr.h"
#include "MtxVec.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector X, B;
    Matrix A;

    B.SetIt(false, DewArray<double>{0, 2});
    A.SetIt(2, 2, false, DewArray<double>{1, 2, 3, 4}); // 2x2, not complex matrix
    A.RefineSolution = true;
    A.ConditionNumber = TConditionNumber::cnNormInf;
    A.LUSolve(B, X);
}
See Also: Matrix::LUSolve, Matrix::ConditionNumber, Matrix::RefineSolution
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler