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
16b4091d
There was an error fetching the commit references. Please try again later.
Commit
16b4091d
authored
5 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Improved asserts in dense matrix
parent
a82afc32
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Matrices/Dense_impl.h
+25
-16
25 additions, 16 deletions
src/TNL/Matrices/Dense_impl.h
with
25 additions
and
16 deletions
src/TNL/Matrices/Dense_impl.h
+
25
−
16
View file @
16b4091d
...
@@ -158,9 +158,11 @@ __cuda_callable__
...
@@ -158,9 +158,11 @@ __cuda_callable__
Real
&
Dense
<
Real
,
Device
,
Index
>::
operator
()(
const
IndexType
row
,
Real
&
Dense
<
Real
,
Device
,
Index
>::
operator
()(
const
IndexType
row
,
const
IndexType
column
)
const
IndexType
column
)
{
{
TNL_ASSERT
(
row
>=
0
&&
row
<
this
->
getRows
()
&&
TNL_ASSERT_GE
(
row
,
0
,
"Row index must be non-negative."
);
column
>=
0
&&
column
<
this
->
getColumns
(),
TNL_ASSERT_LT
(
row
,
this
->
getRows
(),
"Row index is out of bounds."
);
printf
(
" row = %d, column = %d, this->getRows = %d, this->getColumns() = %d
\n
"
,
row
,
column
,
this
->
getRows
(),
this
->
getColumns
()
)
);
TNL_ASSERT_GE
(
column
,
0
,
"Column index must be non-negative."
);
TNL_ASSERT_LT
(
column
,
this
->
getColumns
(),
"Column index is out of bounds."
);
return
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
);
return
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
);
}
}
...
@@ -171,9 +173,11 @@ __cuda_callable__
...
@@ -171,9 +173,11 @@ __cuda_callable__
const
Real
&
Dense
<
Real
,
Device
,
Index
>::
operator
()(
const
IndexType
row
,
const
Real
&
Dense
<
Real
,
Device
,
Index
>::
operator
()(
const
IndexType
row
,
const
IndexType
column
)
const
const
IndexType
column
)
const
{
{
TNL_ASSERT
(
row
>=
0
&&
row
<
this
->
getRows
()
&&
TNL_ASSERT_GE
(
row
,
0
,
"Row index must be non-negative."
);
column
>=
0
&&
column
<
this
->
getColumns
(),
TNL_ASSERT_LT
(
row
,
this
->
getRows
(),
"Row index is out of bounds."
);
printf
(
" row = %d, column = %d, this->getRows = %d, this->getColumns() = %d
\n
"
,
row
,
column
,
this
->
getRows
(),
this
->
getColumns
()
)
);
TNL_ASSERT_GE
(
column
,
0
,
"Column index must be non-negative."
);
TNL_ASSERT_LT
(
column
,
this
->
getColumns
(),
"Column index is out of bounds."
);
return
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
);
return
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
);
}
}
...
@@ -186,10 +190,11 @@ bool Dense< Real, Device, Index >::setElementFast( const IndexType row,
...
@@ -186,10 +190,11 @@ bool Dense< Real, Device, Index >::setElementFast( const IndexType row,
const
IndexType
column
,
const
IndexType
column
,
const
RealType
&
value
)
const
RealType
&
value
)
{
{
TNL_ASSERT
(
row
>=
0
&&
row
<
this
->
getRows
()
&&
TNL_ASSERT_GE
(
row
,
0
,
"Row index must be non-negative."
);
column
>=
0
&&
column
<
this
->
getColumns
(),
TNL_ASSERT_LT
(
row
,
this
->
getRows
(),
"Row index is out of bounds."
);
std
::
cerr
<<
" row = "
<<
row
<<
" column = "
<<
column
<<
" this->getRows() = "
<<
this
->
getRows
()
TNL_ASSERT_GE
(
column
,
0
,
"Column index must be non-negative."
);
<<
" this->getColumns() = "
<<
this
->
getColumns
()
);
TNL_ASSERT_LT
(
column
,
this
->
getColumns
(),
"Column index is out of bounds."
);
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
)
=
value
;
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
)
=
value
;
return
true
;
return
true
;
}
}
...
@@ -215,9 +220,11 @@ bool Dense< Real, Device, Index >::addElementFast( const IndexType row,
...
@@ -215,9 +220,11 @@ bool Dense< Real, Device, Index >::addElementFast( const IndexType row,
const
RealType
&
value
,
const
RealType
&
value
,
const
RealType
&
thisElementMultiplicator
)
const
RealType
&
thisElementMultiplicator
)
{
{
TNL_ASSERT
(
row
>=
0
&&
row
<
this
->
getRows
()
&&
TNL_ASSERT_GE
(
row
,
0
,
"Row index must be non-negative."
);
column
>=
0
&&
column
<
this
->
getColumns
(),
TNL_ASSERT_LT
(
row
,
this
->
getRows
(),
"Row index is out of bounds."
);
printf
(
" row = %d, column = %d, this->getRows = %d, this->getColumns() = %d
\n
"
,
row
,
column
,
this
->
getRows
(),
this
->
getColumns
()
)
);
TNL_ASSERT_GE
(
column
,
0
,
"Column index must be non-negative."
);
TNL_ASSERT_LT
(
column
,
this
->
getColumns
(),
"Column index is out of bounds."
);
const
IndexType
elementIndex
=
this
->
getElementIndex
(
row
,
column
);
const
IndexType
elementIndex
=
this
->
getElementIndex
(
row
,
column
);
if
(
thisElementMultiplicator
==
1.0
)
if
(
thisElementMultiplicator
==
1.0
)
this
->
values
.
operator
[](
elementIndex
)
+=
value
;
this
->
values
.
operator
[](
elementIndex
)
+=
value
;
...
@@ -324,9 +331,11 @@ __cuda_callable__
...
@@ -324,9 +331,11 @@ __cuda_callable__
const
Real
&
Dense
<
Real
,
Device
,
Index
>::
getElementFast
(
const
IndexType
row
,
const
Real
&
Dense
<
Real
,
Device
,
Index
>::
getElementFast
(
const
IndexType
row
,
const
IndexType
column
)
const
const
IndexType
column
)
const
{
{
TNL_ASSERT
(
row
>=
0
&&
row
<
this
->
getRows
()
&&
TNL_ASSERT_GE
(
row
,
0
,
"Row index must be non-negative."
);
column
>=
0
&&
column
<
this
->
getColumns
(),
TNL_ASSERT_LT
(
row
,
this
->
getRows
(),
"Row index is out of bounds."
);
printf
(
" row = %d, column = %d, this->getRows = %d, this->getColumns() = %d
\n
"
,
row
,
column
,
this
->
getRows
(),
this
->
getColumns
()
)
);
TNL_ASSERT_GE
(
column
,
0
,
"Column index must be non-negative."
);
TNL_ASSERT_LT
(
column
,
this
->
getColumns
(),
"Column index is out of bounds."
);
return
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
);
return
this
->
values
.
operator
[](
this
->
getElementIndex
(
row
,
column
)
);
}
}
...
...
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