Skip to content

Conversation

@mgovers
Copy link
Member

@mgovers mgovers commented Dec 2, 2025

This is an experiment. Do not merge yet!

Rather than using some form of condition numbers to detect unsolvable matrix decompositions, we now detect them on-the-fly

  • Dense solver
  • Sparse solver

NOTE: some ill-conditioned cases now actually fail even though they did not do so before!!! It is dependent on the calculation method and whether the calculation is symmetric or asymmetric whether the system raises errors or not.

@mgovers mgovers self-assigned this Dec 2, 2025
@mgovers mgovers added improvement Improvement on internal implementation do-not-merge This should not be merged labels Dec 2, 2025
Signed-off-by: Martijn Govers <[email protected]>
Signed-off-by: Martijn Govers <[email protected]>
Comment on lines +151 to +152
.binaryExpr(
(matrix.col(pivot).tail(size - pivot - 1) * matrix.row(pivot).tail(size - pivot - 1)),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: also add the contribution from the accumulated_error.col(pivot).tail(size - pivot - 1) * matrix.row(pivot).tail(size - pivot - 1)) and (matrix.col(pivot).tail(size - pivot - 1) * accumulated_error.row(pivot).tail(size - pivot - 1)

// check stability
Scalar const piv_size = cabs(matrix(pivot, pivot));
double const piv_error = accumulated_error(pivot, pivot);
if (cabs(matrix(pivot, pivot)) <= std::max(accumulated_error.row(pivot).tail(size - pivot).maxCoeff(),
Copy link
Member Author

@mgovers mgovers Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually a very weak criterion. by the time your accumulated error even becomes close to your pivot element size, the rest of your calculation may already become garbage. E.g., if you want a precision of 1E-5, odds are that your calculation will not be as precise anymore when your matrix element precision is something like 1E-1. This criterion probably should be stricter:

Suggested change
if (cabs(matrix(pivot, pivot)) <= std::max(accumulated_error.row(pivot).tail(size - pivot).maxCoeff(),
if (cabs(matrix(pivot, pivot)) <= threshold * std::max(accumulated_error.row(pivot).tail(size - pivot).maxCoeff(),

Signed-off-by: Martijn Govers <[email protected]>
Signed-off-by: Martijn Govers <[email protected]>

Apply suggestion from @mgovers

Signed-off-by: Martijn Govers <[email protected]>
@mgovers mgovers force-pushed the feature/on-the-fly-sparse-matrix branch from 888321e to 912af80 Compare December 3, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge This should not be merged improvement Improvement on internal implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants