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
Chaofan Chen
ogs
Commits
09936a4f
Commit
09936a4f
authored
9 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
include comments from TF
parent
74d73777
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MathLib/LinAlg/Eigen/EigenLinearSolver.cpp
+0
-1
0 additions, 1 deletion
MathLib/LinAlg/Eigen/EigenLinearSolver.cpp
MathLib/LinAlg/Eigen/EigenMatrix.h
+29
-12
29 additions, 12 deletions
MathLib/LinAlg/Eigen/EigenMatrix.h
MathLib/LinAlg/Eigen/EigenOption.h
+1
-1
1 addition, 1 deletion
MathLib/LinAlg/Eigen/EigenOption.h
with
30 additions
and
14 deletions
MathLib/LinAlg/Eigen/EigenLinearSolver.cpp
+
0
−
1
View file @
09936a4f
...
...
@@ -11,7 +11,6 @@
#include
<boost/property_tree/ptree.hpp>
#include
<logog/include/logog.hpp>
#include
<unsupported/Eigen/IterativeSolvers>
#include
"EigenVector.h"
#include
"EigenMatrix.h"
...
...
This diff is collapsed.
Click to expand it.
MathLib/LinAlg/Eigen/EigenMatrix.h
+
29
−
12
View file @
09936a4f
...
...
@@ -26,6 +26,8 @@ namespace MathLib
/**
* Global matrix based on Eigen sparse matrix
*
* The matrix will be dynamically allocated during construction.
*/
class
EigenMatrix
{
...
...
@@ -52,20 +54,22 @@ public:
/// return an end index of the active data range
virtual
std
::
size_t
getRangeEnd
()
const
{
return
getNRows
();
}
///
R
eset data entries to zero.
///
r
eset data entries to zero.
virtual
void
setZero
()
{
_mat
.
setZero
();
}
/// set entry
/// set a value to the given entry. If the entry doesn't exist, this class
/// dynamically allocates it.
int
setValue
(
std
::
size_t
row
,
std
::
size_t
col
,
double
val
)
{
_mat
.
coeffRef
(
row
,
col
)
=
val
;
return
0
;
}
/// add value
/// add a value to the given entry. If the entry doesn't exist, the value is
/// inserted.
int
add
(
std
::
size_t
row
,
std
::
size_t
col
,
double
val
)
{
assert
(
row
<
getNRows
()
&&
col
<
getNCols
());
...
...
@@ -74,7 +78,7 @@ public:
}
/// Add sub-matrix at positions \c row_pos and same column positions as the
/// given row positions.
/// given row positions.
If the entry doesn't exist, the value is inserted.
template
<
class
T_DENSE_MATRIX
>
void
add
(
std
::
vector
<
std
::
size_t
>
const
&
row_pos
,
const
T_DENSE_MATRIX
&
sub_matrix
,
...
...
@@ -83,7 +87,8 @@ public:
this
->
add
(
row_pos
,
row_pos
,
sub_matrix
,
fkt
);
}
/// Add sub-matrix at positions given by \c indices.
/// Add sub-matrix at positions given by \c indices. If the entry doesn't exist,
/// this class inserts the value.
template
<
class
T_DENSE_MATRIX
>
void
add
(
RowColumnIndices
<
std
::
size_t
>
const
&
indices
,
const
T_DENSE_MATRIX
&
sub_matrix
,
...
...
@@ -92,27 +97,39 @@ public:
this
->
add
(
indices
.
rows
,
indices
.
columns
,
sub_matrix
,
fkt
);
}
///
/**
* Add sub-matrix at positions \c row_pos and \c col_pos. If the entries doesn't
* exist in the matrix, the values are inserted.
* @param row_pos a vector of row position indices. The vector size should
* equal to the number of rows in the given sub-matrix.
* @param col_pos a vector of column position indices. The vector size should
* equal to the number of columns in the given sub-matrix.
* @param sub_matrix a sub-matrix to be added
* @param fkt a scaling factor applied to all entries in the sub-matrix
*/
template
<
class
T_DENSE_MATRIX
>
void
add
(
std
::
vector
<
std
::
size_t
>
const
&
row_pos
,
std
::
vector
<
std
::
size_t
>
const
&
col_pos
,
const
T_DENSE_MATRIX
&
sub_matrix
,
double
fkt
=
1.0
);
/// get value
double
get
(
std
::
size_t
row
,
std
::
size_t
col
)
/// get value
. This function returns zero if the element doesn't exist.
double
get
(
std
::
size_t
row
,
std
::
size_t
col
)
const
{
assert
(
row
<
getNRows
()
&&
col
<
getNCols
());
return
_mat
.
coeff
(
row
,
col
);
}
/// get value
/// get value
. This function returns zero if the element doesn't exist.
double
operator
()
(
std
::
size_t
row
,
std
::
size_t
col
)
const
{
return
_mat
.
coeff
(
row
,
col
);
return
get
(
row
,
col
);
}
/// get a maximum value in diagonal entries
virtual
double
getMaxDiagCoeff
()
{
return
1
;}
virtual
double
getMaxDiagCoeff
()
const
{
return
_mat
.
diagonal
().
maxCoeff
();
}
/// y = mat * x
virtual
void
multiply
(
const
EigenVector
&
x
,
EigenVector
&
y
)
const
...
...
@@ -120,7 +137,7 @@ public:
y
.
getRawVector
()
=
_mat
*
x
.
getRawVector
();
}
/// return
if
th
is
matrix is al
ready assembled or not
/// return
always true, i.e.
th
e
matrix is al
ways ready for use
bool
isAssembled
()
const
{
return
true
;
}
#ifndef NDEBUG
...
...
This diff is collapsed.
Click to expand it.
MathLib/LinAlg/Eigen/EigenOption.h
+
1
−
1
View file @
09936a4f
...
...
@@ -41,7 +41,7 @@ struct EigenOption
/// Preconditioner type
PreconType
precon_type
;
/// Maximum iteration count
long
max_iterations
;
std
::
size_t
max_iterations
;
/// Error tolerance
double
error_tolerance
;
...
...
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