feat(linear-static-3d-euler-beam): step 20 - mkl-pardiso-solver-review-fix
This commit is contained in:
@@ -110,10 +110,11 @@ public:
|
||||
"PARDISO factorization requires a square matrix.");
|
||||
}
|
||||
if (matrix.rows() == 0U) {
|
||||
return solverFailure(
|
||||
"solver-empty-matrix",
|
||||
"matrix-shape",
|
||||
"PARDISO factorization requires at least one equation.");
|
||||
// A fully constrained model has no free equations. Preserve the
|
||||
// observable factorize/solve lifecycle without creating backend
|
||||
// state or calling PARDISO with its invalid n=0 input.
|
||||
factorized_ = true;
|
||||
return Status::ok();
|
||||
}
|
||||
if (!convertsToMklInt(matrix.rows()) ||
|
||||
!convertsToMklInt(matrix.values().size())) {
|
||||
@@ -183,6 +184,9 @@ public:
|
||||
"PARDISO RHS values must be finite.");
|
||||
}
|
||||
}
|
||||
if (size == 0U) {
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
std::vector<double> rhsCopy(rhs.data(), rhs.data() + rhs.size());
|
||||
Vector candidate{size};
|
||||
@@ -211,6 +215,11 @@ private:
|
||||
const auto& publicColumns = matrix.columnIndices();
|
||||
const auto& publicValues = matrix.values();
|
||||
|
||||
double matrixScale = 0.0;
|
||||
for (const double value : publicValues) {
|
||||
matrixScale = (std::max)(matrixScale, std::abs(value));
|
||||
}
|
||||
|
||||
for (std::size_t row = 0U; row < matrix.rows(); ++row) {
|
||||
for (std::size_t position = publicOffsets[row];
|
||||
position < publicOffsets[row + 1U];
|
||||
@@ -233,8 +242,13 @@ private:
|
||||
std::distance(publicColumns.begin(), reverse));
|
||||
const double left = publicValues[position];
|
||||
const double right = publicValues[reversePosition];
|
||||
const double scale = (std::max)({1.0, std::abs(left), std::abs(right)});
|
||||
if (std::abs(left - right) > 1.0e-12 * scale) {
|
||||
const double difference = std::abs(left - right);
|
||||
// The approved symmetry test is normalized by the matrix's
|
||||
// actual nonzero scale, without an absolute unit-size floor.
|
||||
const bool isSymmetric = matrixScale == 0.0 ?
|
||||
difference == 0.0 :
|
||||
difference <= 1.0e-12 * matrixScale;
|
||||
if (!isSymmetric) {
|
||||
return solverFailure(
|
||||
"solver-matrix-not-symmetric",
|
||||
std::to_string(row) + ":" + std::to_string(column),
|
||||
|
||||
Reference in New Issue
Block a user