Skip to content
Snippets Groups Projects
Commit 3e419294 authored by Tom Fischer's avatar Tom Fischer Committed by Dmitri Naumov
Browse files

[MaL/LA/Eigen] cppcheck: Fix 'arg. names diff.' warnings.

parent 319bcc7f
No related branches found
No related tags found
No related merge requests found
...@@ -16,21 +16,21 @@ ...@@ -16,21 +16,21 @@
namespace MathLib 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<EigenMatrix::IndexType> &vec_knownX_id,
const std::vector<double> &vec_knownX_x, double /*penalty_scaling*/) const std::vector<double> &vec_knownX_x, double /*penalty_scaling*/)
{ {
using SpMat = EigenMatrix::RawMatrixType; using SpMat = EigenMatrix::RawMatrixType;
static_assert(SpMat::IsRowMajor, "matrix is assumed to be row major!"); static_assert(SpMat::IsRowMajor, "matrix is assumed to be row major!");
auto &A = A_.getRawMatrix(); auto &A_eigen = A.getRawMatrix();
auto &b = b_.getRawVector(); auto &b_eigen = b.getRawVector();
// A(k, j) = 0. // A_eigen(k, j) = 0.
// set row to zero // set row to zero
for (auto row_id : vec_knownX_id) 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)) if (it.col() != decltype(it.col())(row_id))
{ {
it.valueRef() = 0.0; it.valueRef() = 0.0;
...@@ -38,14 +38,14 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, ...@@ -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++) for (std::size_t ix=0; ix<vec_knownX_id.size(); ix++)
{ {
SpMat::Index const row_id = vec_knownX_id[ix]; SpMat::Index const row_id = vec_knownX_id[ix];
auto const x = vec_knownX_x[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 // set column to zero, subtract from rhs
for (SpMat::InnerIterator it(AT, row_id); it; ++it) for (SpMat::InnerIterator it(AT, row_id); it; ++it)
{ {
...@@ -54,20 +54,20 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, ...@@ -54,20 +54,20 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/,
continue; continue;
} }
b[it.col()] -= it.value()*x; b_eigen[it.col()] -= it.value()*x;
it.valueRef() = 0.0; it.valueRef() = 0.0;
} }
auto& c = AT.coeffRef(row_id, row_id); auto& c = AT.coeffRef(row_id, row_id);
if (c != 0.0) { if (c != 0.0) {
b[row_id] = x * c; b_eigen[row_id] = x * c;
} else { } else {
b[row_id] = x; b_eigen[row_id] = x;
c = 1.0; c = 1.0;
} }
} }
A = AT.transpose(); A_eigen = AT.transpose();
} }
} // namespace MathLib } // namespace MathLib
...@@ -24,14 +24,15 @@ class EigenVector; ...@@ -24,14 +24,15 @@ class EigenVector;
* *
* @param A Coefficient matrix * @param A Coefficient matrix
* @param b RHS vector * @param b RHS vector
* @param _vec_knownX_id a vector of known solution entry IDs * @param vec_knownX_id a vector of known solution entry IDs
* @param _vec_knownX_x a vector of known solutions * @param vec_knownX_x a vector of known solutions
* @param penalty_scaling value for scaling some matrix and right hand side * @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*/, void applyKnownSolution(EigenMatrix &A, EigenVector &b, EigenVector &/*x*/,
const std::vector<EigenMatrix::IndexType> &_vec_knownX_id, const std::vector<EigenMatrix::IndexType> &vec_knownX_id,
const std::vector<double> &_vec_knownX_x, double penalty_scaling = 1e+10); const std::vector<double> &vec_knownX_x, double penalty_scaling = 1e+10);
inline inline
void applyKnownSolution(Eigen::MatrixXd const &A, Eigen::VectorXd &b, Eigen::VectorXd &/*x*/, void applyKnownSolution(Eigen::MatrixXd const &A, Eigen::VectorXd &b, Eigen::VectorXd &/*x*/,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment