Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
ac04676b
Commit
ac04676b
authored
5 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add numberOfValues() and check that IndexType is valid
parent
0a158b16
No related branches found
No related tags found
1 merge request
!26
Feature/linear systems
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/algebra/SparseMatrixDescriptor.hpp
+20
-1
20 additions, 1 deletion
src/algebra/SparseMatrixDescriptor.hpp
with
20 additions
and
1 deletion
src/algebra/SparseMatrixDescriptor.hpp
+
20
−
1
View file @
ac04676b
...
...
@@ -2,11 +2,16 @@
#define SPARSE_MATRIX_DESCRIPTOR_HPP
#include
<Array.hpp>
#include
<map>
#include
<type_traits>
template
<
typename
DataType
=
double
,
typename
IndexType
=
size_t
>
class
SparseMatrixDescriptor
{
static_assert
(
std
::
is_integral_v
<
IndexType
>
,
"Index type must be an integral type"
);
static_assert
(
std
::
is_unsigned_v
<
IndexType
>
,
"Index type must be unsigned"
);
public:
using
data_type
=
DataType
;
using
index_type
=
IndexType
;
...
...
@@ -17,6 +22,12 @@ class SparseMatrixDescriptor
std
::
map
<
IndexType
,
DataType
>
m_id_value_map
;
public:
IndexType
numberOfValues
()
const
noexcept
{
return
m_id_value_map
.
size
();
}
const
DataType
&
operator
[](
const
IndexType
&
j
)
const
{
auto
i_value
=
m_id_value_map
.
find
(
j
);
...
...
@@ -52,6 +63,13 @@ class SparseMatrixDescriptor
Array
<
SparseRowDescriptor
>
m_row_array
;
public
:
PUGS_INLINE
size_t
numberOfRows
()
const
noexcept
{
return
m_row_array
.
size
();
}
SparseRowDescriptor
&
row
(
const
IndexType
i
)
{
...
...
@@ -73,7 +91,8 @@ class SparseMatrixDescriptor
const
DataType
&
operator
()(
const
IndexType
&
i
,
const
IndexType
&
j
)
const
{
return
m_row_array
[
i
][
j
];
const
auto
&
r
=
m_row_array
[
i
];
// split to ensure const-ness of call
return
r
[
j
];
}
friend
std
::
ostream
&
...
...
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