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
3acd94ae
There was an error fetching the commit references. Please try again later.
Commit
3acd94ae
authored
5 years ago
by
Lukas Cejka
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added checking for negative number of elements, in case of int overflow. Debugging prints included.
parent
0b132c07
No related branches found
No related tags found
1 merge request
!45
Matrices revision
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Matrices/Sparse_impl.h
+16
-0
16 additions, 0 deletions
src/TNL/Matrices/Sparse_impl.h
with
16 additions
and
0 deletions
src/TNL/Matrices/Sparse_impl.h
+
16
−
0
View file @
3acd94ae
...
...
@@ -109,6 +109,20 @@ template< typename Real,
typename
Index
>
void
Sparse
<
Real
,
Device
,
Index
>::
allocateMatrixElements
(
const
IndexType
&
numberOfMatrixElements
)
{
std
::
cout
<<
" Allocating matrix elements..."
<<
std
::
endl
;
// CHECKING: if the number of matrix elements is larger than the highest number the IndexType can go to?
// INT OVERFLOW
// CORRECT? ELL stores certain matrices in such a way, which could cause the number of matrix elements
// to be greater than the maximum value IndexType can store, thus causing int overflow when
// creating the arrays "values" and "indexes".
// PROBLEM: int can overflow in such a way that it is still positive, thus rendering this assert useless.
// HOW FIX? Do we have to create special conditions for every format in its allocation method? We can't
// tell from within this method, if numberOfMatrixElements is an overflown value or not.
TNL_ASSERT_GE
(
numberOfMatrixElements
,
0
,
"Number of matrix elements must be non-negative."
);
std
::
cout
<<
" numberOfMatrixElements = "
<<
numberOfMatrixElements
<<
std
::
endl
;
this
->
values
.
setSize
(
numberOfMatrixElements
);
this
->
columnIndexes
.
setSize
(
numberOfMatrixElements
);
...
...
@@ -118,6 +132,8 @@ void Sparse< Real, Device, Index >::allocateMatrixElements( const IndexType& num
*/
if
(
numberOfMatrixElements
>
0
)
this
->
columnIndexes
.
setValue
(
this
->
columns
);
std
::
cout
<<
"->END OF allocateMatrixElements!!!"
<<
std
::
endl
;
}
template
<
typename
Real
,
...
...
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