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
9e18ae28
Commit
9e18ae28
authored
10 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[MeL] Add setMatrixSparsity.
parent
aee18325
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/Lis/LisMatrix.h
+31
-0
31 additions, 0 deletions
MathLib/LinAlg/Lis/LisMatrix.h
MathLib/LinAlg/SetMatrixSparsity.h
+41
-0
41 additions, 0 deletions
MathLib/LinAlg/SetMatrixSparsity.h
with
72 additions
and
0 deletions
MathLib/LinAlg/Lis/LisMatrix.h
+
31
−
0
View file @
9e18ae28
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#include
<vector>
#include
<vector>
#include
"MathLib/LinAlg/RowColumnIndices.h"
#include
"MathLib/LinAlg/RowColumnIndices.h"
#include
"MathLib/LinAlg/Lis/LisCheck.h"
#include
"MathLib/LinAlg/SetMatrixSparsity.h"
#include
"lis.h"
#include
"lis.h"
...
@@ -27,7 +29,12 @@
...
@@ -27,7 +29,12 @@
namespace
MathLib
namespace
MathLib
{
{
// Forward declarations.
class
LisVector
;
class
LisVector
;
class
LisMatrix
;
template
<
typename
SPARSITY_PATTERN
>
struct
SetMatrixSparsity
<
LisMatrix
,
SPARSITY_PATTERN
>
;
/**
/**
* \brief LisMatrix is a wrapper class for matrix types of the
* \brief LisMatrix is a wrapper class for matrix types of the
...
@@ -126,6 +133,9 @@ private:
...
@@ -126,6 +133,9 @@ private:
// friend function
// friend function
friend
bool
finalizeMatrixAssembly
(
LisMatrix
&
mat
);
friend
bool
finalizeMatrixAssembly
(
LisMatrix
&
mat
);
template
<
typename
MATRIX
,
typename
SPARSITY_PATTERN
>
friend
struct
SetMatrixSparsity
;
};
};
template
<
class
T_DENSE_MATRIX
>
template
<
class
T_DENSE_MATRIX
>
...
@@ -147,6 +157,27 @@ LisMatrix::add(std::vector<std::size_t> const& row_pos, std::vector<std::size_t>
...
@@ -147,6 +157,27 @@ LisMatrix::add(std::vector<std::size_t> const& row_pos, std::vector<std::size_t>
/// finish assembly to make this matrix be ready for use
/// finish assembly to make this matrix be ready for use
bool
finalizeMatrixAssembly
(
LisMatrix
&
mat
);
bool
finalizeMatrixAssembly
(
LisMatrix
&
mat
);
/// Sets the sparsity pattern of the underlying LisMatrix.
template
<
typename
SPARSITY_PATTERN
>
struct
SetMatrixSparsity
<
LisMatrix
,
SPARSITY_PATTERN
>
{
void
operator
()(
LisMatrix
&
matrix
,
SPARSITY_PATTERN
const
&
sparsity_pattern
)
{
std
::
size_t
n_rows
=
matrix
.
getNRows
();
std
::
vector
<
int
>
row_sizes
;
row_sizes
.
reserve
(
n_rows
);
// LIS needs 1 more entry, otherewise it starts reallocating arrays.
for
(
std
::
size_t
i
=
0
;
i
<
n_rows
;
i
++
)
row_sizes
.
push_back
(
sparsity_pattern
.
getNodeDegree
(
i
)
+
1
);
int
ierr
=
lis_matrix_malloc
(
matrix
.
_AA
,
0
,
row_sizes
.
data
());
checkLisError
(
ierr
);
}
};
}
// MathLib
}
// MathLib
#endif //LISMATRIX_H_
#endif //LISMATRIX_H_
...
...
This diff is collapsed.
Click to expand it.
MathLib/LinAlg/SetMatrixSparsity.h
0 → 100644
+
41
−
0
View file @
9e18ae28
/**
* \copyright
* Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#ifndef MATHLIB_SETMATRIXSPARSITY_H_
#define MATHLIB_SETMATRIXSPARSITY_H_
namespace
MathLib
{
/// Default implementation of SetMatrixSparsity class called by
/// setMatrixSparsity.
/// This is a workaround for partial function specialization.
template
<
typename
MATRIX
,
typename
SPARSITY_PATTERN
>
struct
SetMatrixSparsity
{
void
operator
()(
MATRIX
&
,
SPARSITY_PATTERN
const
&
)
{
}
};
/// Sets the sparsity pattern of the underlying matrix.
/// To allow partial specialization a SetMatrixSparsity template is
/// instantiated, to which the matrix and the sparsity_pattern are passed.
template
<
typename
MATRIX
,
typename
SPARSITY_PATTERN
>
void
setMatrixSparsity
(
MATRIX
&
matrix
,
SPARSITY_PATTERN
const
&
sparsity_pattern
)
{
SetMatrixSparsity
<
MATRIX
,
SPARSITY_PATTERN
>
set_sparsity
;
set_sparsity
(
matrix
,
sparsity_pattern
);
}
}
// MathLib
#ifdef USE_LIS
#include
"Lis/LisMatrix.h"
#endif // USE_LIS
#endif // MATHLIB_SETMATRIXSPARSITY_H_
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