diff --git a/MathLib/LinAlg/Eigen/EigenTools.cpp b/MathLib/LinAlg/Eigen/EigenTools.cpp index 00ac54a76630dafe06af00273f1a6362eb87112d..97f5b0f9d6d94bf5231e7b0ae03487de814e995b 100644 --- a/MathLib/LinAlg/Eigen/EigenTools.cpp +++ b/MathLib/LinAlg/Eigen/EigenTools.cpp @@ -16,21 +16,21 @@ namespace MathLib { -void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, +void applyKnownSolution(EigenMatrix &A, EigenVector &b, EigenVector &/*x*/, const std::vector<EigenMatrix::IndexType> &vec_knownX_id, const std::vector<double> &vec_knownX_x, double /*penalty_scaling*/) { using SpMat = EigenMatrix::RawMatrixType; static_assert(SpMat::IsRowMajor, "matrix is assumed to be row major!"); - auto &A = A_.getRawMatrix(); - auto &b = b_.getRawVector(); + auto &A_eigen = A.getRawMatrix(); + auto &b_eigen = b.getRawVector(); - // A(k, j) = 0. + // A_eigen(k, j) = 0. // set row to zero for (auto row_id : vec_knownX_id) { - for (SpMat::InnerIterator it(A,row_id); it; ++it) { + for (SpMat::InnerIterator it(A_eigen,row_id); it; ++it) { if (it.col() != decltype(it.col())(row_id)) { it.valueRef() = 0.0; @@ -38,14 +38,14 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, } } - SpMat AT = A.transpose(); + SpMat AT = A_eigen.transpose(); for (std::size_t ix=0; ix<vec_knownX_id.size(); ix++) { SpMat::Index const row_id = vec_knownX_id[ix]; auto const x = vec_knownX_x[ix]; - // b_i -= A(i,k)*val, i!=k + // b_i -= A_eigen(i,k)*val, i!=k // set column to zero, subtract from rhs for (SpMat::InnerIterator it(AT, row_id); it; ++it) { @@ -54,20 +54,20 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, continue; } - b[it.col()] -= it.value()*x; + b_eigen[it.col()] -= it.value()*x; it.valueRef() = 0.0; } auto& c = AT.coeffRef(row_id, row_id); if (c != 0.0) { - b[row_id] = x * c; + b_eigen[row_id] = x * c; } else { - b[row_id] = x; + b_eigen[row_id] = x; c = 1.0; } } - A = AT.transpose(); + A_eigen = AT.transpose(); } } // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenTools.h b/MathLib/LinAlg/Eigen/EigenTools.h index 50622552827fcc61cd2d0883f08c9191d99ff1b7..fc6d5acff2e8b1f977cbb088466b96052b76cbf7 100644 --- a/MathLib/LinAlg/Eigen/EigenTools.h +++ b/MathLib/LinAlg/Eigen/EigenTools.h @@ -24,14 +24,15 @@ class EigenVector; * * @param A Coefficient matrix * @param b RHS vector - * @param _vec_knownX_id a vector of known solution entry IDs - * @param _vec_knownX_x a vector of known solutions + * @param vec_knownX_id a vector of known solution entry IDs + * @param vec_knownX_x a vector of known solutions * @param penalty_scaling value for scaling some matrix and right hand side - * entries to enforce some conditions + * entries to enforce some conditions, value ignored in the current + * implementation */ void applyKnownSolution(EigenMatrix &A, EigenVector &b, EigenVector &/*x*/, - const std::vector<EigenMatrix::IndexType> &_vec_knownX_id, - const std::vector<double> &_vec_knownX_x, double penalty_scaling = 1e+10); + const std::vector<EigenMatrix::IndexType> &vec_knownX_id, + const std::vector<double> &vec_knownX_x, double penalty_scaling = 1e+10); inline void applyKnownSolution(Eigen::MatrixXd const &A, Eigen::VectorXd &b, Eigen::VectorXd &/*x*/,