Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
3e419294
Commit
3e419294
authored
4 years ago
by
Tom Fischer
Committed by
Dmitri Naumov
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[MaL/LA/Eigen] cppcheck: Fix 'arg. names diff.' warnings.
parent
319bcc7f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MathLib/LinAlg/Eigen/EigenTools.cpp
+11
-11
11 additions, 11 deletions
MathLib/LinAlg/Eigen/EigenTools.cpp
MathLib/LinAlg/Eigen/EigenTools.h
+6
-5
6 additions, 5 deletions
MathLib/LinAlg/Eigen/EigenTools.h
with
17 additions
and
16 deletions
MathLib/LinAlg/Eigen/EigenTools.cpp
+
11
−
11
View file @
3e419294
...
@@ -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
This diff is collapsed.
Click to expand it.
MathLib/LinAlg/Eigen/EigenTools.h
+
6
−
5
View file @
3e419294
...
@@ -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*/
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment