Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
c749c8a9
There was an error fetching the commit references. Please try again later.
Commit
c749c8a9
authored
4 years ago
by
Jakub Klinkovský
Committed by
Tomáš Oberhuber
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added operator<< and setValue for SparseMatrixRowView
parent
de51fb4d
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TNL/Matrices/SparseMatrixRowView.h
+17
-2
17 additions, 2 deletions
src/TNL/Matrices/SparseMatrixRowView.h
src/TNL/Matrices/SparseMatrixRowView.hpp
+30
-2
30 additions, 2 deletions
src/TNL/Matrices/SparseMatrixRowView.hpp
with
47 additions
and
4 deletions
src/TNL/Matrices/SparseMatrixRowView.h
+
17
−
2
View file @
c749c8a9
...
...
@@ -10,8 +10,12 @@
#pragma once
#include
<ostream>
#include
<TNL/Cuda/CudaCallable.h>
namespace
TNL
{
namespace
Matrices
{
namespace
Matrices
{
template
<
typename
SegmentView
,
typename
ValuesView
,
...
...
@@ -52,6 +56,10 @@ class SparseMatrixRowView
__cuda_callable__
RealType
&
getValue
(
const
IndexType
localIdx
);
__cuda_callable__
void
setValue
(
const
IndexType
localIdx
,
const
RealType
&
value
);
__cuda_callable__
void
setElement
(
const
IndexType
localIdx
,
const
IndexType
column
,
...
...
@@ -64,7 +72,14 @@ class SparseMatrixRowView
ColumnsIndexesViewType
columnIndexes
;
};
}
// namespace Matrices
template
<
typename
SegmentView
,
typename
ValuesView
,
typename
ColumnsIndexesView
,
bool
isBinary_
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
SparseMatrixRowView
<
SegmentView
,
ValuesView
,
ColumnsIndexesView
,
isBinary_
>&
row
);
}
// namespace Matrices
}
// namespace TNL
#include
<TNL/Matrices/SparseMatrixRowView.hpp>
This diff is collapsed.
Click to expand it.
src/TNL/Matrices/SparseMatrixRowView.hpp
+
30
−
2
View file @
c749c8a9
...
...
@@ -11,9 +11,10 @@
#pragma once
#include
<TNL/Matrices/SparseMatrixRowView.h>
#include
<TNL/Assert.h>
namespace
TNL
{
namespace
Matrices
{
namespace
Matrices
{
template
<
typename
SegmentView
,
typename
ValuesView
,
...
...
@@ -89,6 +90,22 @@ getValue( const IndexType localIdx ) -> RealType&
return
values
[
segmentView
.
getGlobalIndex
(
localIdx
)
];
}
template
<
typename
SegmentView
,
typename
ValuesView
,
typename
ColumnsIndexesView
,
bool
isBinary_
>
__cuda_callable__
void
SparseMatrixRowView
<
SegmentView
,
ValuesView
,
ColumnsIndexesView
,
isBinary_
>::
setValue
(
const
IndexType
localIdx
,
const
RealType
&
value
)
{
TNL_ASSERT_LT
(
localIdx
,
this
->
getSize
(),
"Local index exceeds matrix row capacity."
);
if
(
!
isBinary
()
)
{
const
IndexType
globalIdx
=
segmentView
.
getGlobalIndex
(
localIdx
);
values
[
globalIdx
]
=
value
;
}
}
template
<
typename
SegmentView
,
typename
ValuesView
,
typename
ColumnsIndexesView
,
...
...
@@ -106,6 +123,17 @@ setElement( const IndexType localIdx,
values
[
globalIdx
]
=
value
;
}
template
<
typename
SegmentView
,
typename
ValuesView
,
typename
ColumnsIndexesView
,
bool
isBinary_
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
SparseMatrixRowView
<
SegmentView
,
ValuesView
,
ColumnsIndexesView
,
isBinary_
>&
row
)
{
using
NonConstIndex
=
std
::
remove_const_t
<
typename
SparseMatrixRowView
<
SegmentView
,
ValuesView
,
ColumnsIndexesView
,
isBinary_
>::
IndexType
>
;
for
(
NonConstIndex
i
=
0
;
i
<
row
.
getSize
();
i
++
)
str
<<
" [ "
<<
row
.
getColumnIndex
(
i
)
<<
" ] = "
<<
row
.
getValue
(
i
)
<<
", "
;
return
str
;
}
}
// namespace Matrices
}
// namespace Matrices
}
// namespace TNL
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