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
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
Yuhao Liu
ogs
Commits
75353937
Commit
75353937
authored
9 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[MaL] added: unified setting of vector values
parent
6a2bd7ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MathLib/LinAlg/UnifiedMatrixSetters.cpp
+19
-0
19 additions, 0 deletions
MathLib/LinAlg/UnifiedMatrixSetters.cpp
MathLib/LinAlg/UnifiedMatrixSetters.h
+10
-0
10 additions, 0 deletions
MathLib/LinAlg/UnifiedMatrixSetters.h
with
29 additions
and
0 deletions
MathLib/LinAlg/UnifiedMatrixSetters.cpp
+
19
−
0
View file @
75353937
...
@@ -67,6 +67,12 @@ void setVector(Eigen::VectorXd& v, std::initializer_list<double> values)
...
@@ -67,6 +67,12 @@ void setVector(Eigen::VectorXd& v, std::initializer_list<double> values)
for
(
std
::
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
v
[
i
]
=
*
(
it
++
);
for
(
std
::
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
v
[
i
]
=
*
(
it
++
);
}
}
void
setVector
(
Eigen
::
VectorXd
&
v
,
MatrixVectorTraits
<
Eigen
::
VectorXd
>::
Index
const
index
,
double
const
value
)
{
v
[
index
]
=
value
;
}
}
// namespace MathLib
}
// namespace MathLib
#endif // OGS_USE_EIGEN
#endif // OGS_USE_EIGEN
...
@@ -97,6 +103,12 @@ void setVector(PETScVector& v,
...
@@ -97,6 +103,12 @@ void setVector(PETScVector& v,
v
.
set
(
idcs
,
vals
);
v
.
set
(
idcs
,
vals
);
}
}
void
setVector
(
PETScVector
&
v
,
MatrixVectorTraits
<
PETScVector
>::
Index
const
index
,
double
const
value
)
{
v
.
set
(
index
,
value
);
// TODO handle negative indices
}
void
setMatrix
(
PETScMatrix
&
m
,
void
setMatrix
(
PETScMatrix
&
m
,
std
::
initializer_list
<
double
>
values
)
std
::
initializer_list
<
double
>
values
)
{
{
...
@@ -173,6 +185,13 @@ void setVector(EigenVector& v,
...
@@ -173,6 +185,13 @@ void setVector(EigenVector& v,
setVector
(
v
.
getRawVector
(),
values
);
setVector
(
v
.
getRawVector
(),
values
);
}
}
void
setVector
(
EigenVector
&
v
,
MatrixVectorTraits
<
EigenVector
>::
Index
const
index
,
double
const
value
)
{
v
.
getRawVector
()[
index
]
=
value
;
}
void
setMatrix
(
EigenMatrix
&
m
,
void
setMatrix
(
EigenMatrix
&
m
,
std
::
initializer_list
<
double
>
values
)
std
::
initializer_list
<
double
>
values
)
{
{
...
...
This diff is collapsed.
Click to expand it.
MathLib/LinAlg/UnifiedMatrixSetters.h
+
10
−
0
View file @
75353937
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#define MATHLIB_UNIFIED_MATRIX_SETTERS_H
#define MATHLIB_UNIFIED_MATRIX_SETTERS_H
#include
<initializer_list>
#include
<initializer_list>
#include
"MatrixVectorTraits.h"
#ifdef OGS_USE_EIGEN
#ifdef OGS_USE_EIGEN
...
@@ -35,6 +36,9 @@ double norm(Eigen::VectorXd const& x);
...
@@ -35,6 +36,9 @@ double norm(Eigen::VectorXd const& x);
void
setVector
(
Eigen
::
VectorXd
&
v
,
std
::
initializer_list
<
double
>
values
);
void
setVector
(
Eigen
::
VectorXd
&
v
,
std
::
initializer_list
<
double
>
values
);
void
setVector
(
Eigen
::
VectorXd
&
v
,
MatrixVectorTraits
<
Eigen
::
VectorXd
>::
Index
const
index
,
double
const
value
);
}
// namespace MathLib
}
// namespace MathLib
#endif // OGS_USE_EIGEN
#endif // OGS_USE_EIGEN
...
@@ -55,6 +59,9 @@ double norm(PETScVector const& x);
...
@@ -55,6 +59,9 @@ double norm(PETScVector const& x);
void
setVector
(
PETScVector
&
v
,
void
setVector
(
PETScVector
&
v
,
std
::
initializer_list
<
double
>
values
);
std
::
initializer_list
<
double
>
values
);
void
setVector
(
PETScVector
&
v
,
MatrixVectorTraits
<
PETScVector
>::
Index
const
index
,
double
const
value
);
void
setMatrix
(
PETScMatrix
&
m
,
Eigen
::
MatrixXd
const
&
tmp
);
void
setMatrix
(
PETScMatrix
&
m
,
Eigen
::
MatrixXd
const
&
tmp
);
void
addToMatrix
(
PETScMatrix
&
m
,
void
addToMatrix
(
PETScMatrix
&
m
,
...
@@ -79,6 +86,9 @@ class EigenMatrix;
...
@@ -79,6 +86,9 @@ class EigenMatrix;
void
setVector
(
EigenVector
&
v
,
void
setVector
(
EigenVector
&
v
,
std
::
initializer_list
<
double
>
values
);
std
::
initializer_list
<
double
>
values
);
void
setVector
(
EigenVector
&
v
,
MatrixVectorTraits
<
EigenVector
>::
Index
const
index
,
double
const
value
);
void
setMatrix
(
EigenMatrix
&
m
,
void
setMatrix
(
EigenMatrix
&
m
,
std
::
initializer_list
<
double
>
values
);
std
::
initializer_list
<
double
>
values
);
...
...
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