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
369ae3ce
There was an error fetching the commit references. Please try again later.
Commit
369ae3ce
authored
5 years ago
by
Tomáš Oberhuber
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixing MatrixReader.
parent
0b14ec64
No related branches found
No related tags found
1 merge request
!48
Segments
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TNL/Matrices/MatrixReader.h
+1
-1
1 addition, 1 deletion
src/TNL/Matrices/MatrixReader.h
src/TNL/Matrices/MatrixReader_impl.h
+5
-3
5 additions, 3 deletions
src/TNL/Matrices/MatrixReader_impl.h
with
6 additions
and
4 deletions
src/TNL/Matrices/MatrixReader.h
+
1
−
1
View file @
369ae3ce
...
@@ -58,7 +58,7 @@ class MatrixReader
...
@@ -58,7 +58,7 @@ class MatrixReader
IndexType
&
lineNumber
);
IndexType
&
lineNumber
);
protected:
protected:
static
void
checkMtxHeader
(
const
String
&
header
,
static
bool
checkMtxHeader
(
const
String
&
header
,
bool
&
symmetric
);
bool
&
symmetric
);
static
void
readMtxHeader
(
std
::
istream
&
file
,
static
void
readMtxHeader
(
std
::
istream
&
file
,
...
...
This diff is collapsed.
Click to expand it.
src/TNL/Matrices/MatrixReader_impl.h
+
5
−
3
View file @
369ae3ce
...
@@ -156,12 +156,12 @@ bool MatrixReader< Matrix >::findLineByElement( std::istream& file,
...
@@ -156,12 +156,12 @@ bool MatrixReader< Matrix >::findLineByElement( std::istream& file,
}
}
template
<
typename
Matrix
>
template
<
typename
Matrix
>
void
MatrixReader
<
Matrix
>::
checkMtxHeader
(
const
String
&
header
,
bool
MatrixReader
<
Matrix
>::
checkMtxHeader
(
const
String
&
header
,
bool
&
symmetric
)
bool
&
symmetric
)
{
{
std
::
vector
<
String
>
parsedLine
=
header
.
split
(
' '
,
String
::
SplitSkip
::
SkipEmpty
);
std
::
vector
<
String
>
parsedLine
=
header
.
split
(
' '
,
String
::
SplitSkip
::
SkipEmpty
);
if
(
(
int
)
parsedLine
.
size
()
<
5
||
parsedLine
[
0
]
!=
"%%MatrixMarket"
)
if
(
(
int
)
parsedLine
.
size
()
<
5
||
parsedLine
[
0
]
!=
"%%MatrixMarket"
)
throw
std
::
runtime_error
(
"Wrong MTX file header. We expect line like this: %%MatrixMarket matrix coordinate real general"
)
;
return
false
;
if
(
parsedLine
[
1
]
!=
"matrix"
)
if
(
parsedLine
[
1
]
!=
"matrix"
)
throw
std
::
runtime_error
(
std
::
string
(
"Keyword 'matrix' is expected in the header line: "
)
+
header
.
getString
()
);
throw
std
::
runtime_error
(
std
::
string
(
"Keyword 'matrix' is expected in the header line: "
)
+
header
.
getString
()
);
if
(
parsedLine
[
2
]
!=
"coordinates"
&&
if
(
parsedLine
[
2
]
!=
"coordinates"
&&
...
@@ -176,6 +176,7 @@ void MatrixReader< Matrix >::checkMtxHeader( const String& header,
...
@@ -176,6 +176,7 @@ void MatrixReader< Matrix >::checkMtxHeader( const String& header,
else
else
throw
std
::
runtime_error
(
std
::
string
(
"Only 'general' matrices are supported, not "
)
+
parsedLine
[
4
].
getString
()
);
throw
std
::
runtime_error
(
std
::
string
(
"Only 'general' matrices are supported, not "
)
+
parsedLine
[
4
].
getString
()
);
}
}
return
true
;
}
}
template
<
typename
Matrix
>
template
<
typename
Matrix
>
...
@@ -195,7 +196,7 @@ void MatrixReader< Matrix >::readMtxHeader( std::istream& file,
...
@@ -195,7 +196,7 @@ void MatrixReader< Matrix >::readMtxHeader( std::istream& file,
std
::
getline
(
file
,
line
);
std
::
getline
(
file
,
line
);
if
(
!
headerParsed
)
if
(
!
headerParsed
)
{
{
checkMtxHeader
(
line
,
symmetric
);
headerParsed
=
checkMtxHeader
(
line
,
symmetric
);
if
(
verbose
&&
symmetric
)
if
(
verbose
&&
symmetric
)
std
::
cout
<<
"The matrix is SYMMETRIC ... "
;
std
::
cout
<<
"The matrix is SYMMETRIC ... "
;
continue
;
continue
;
...
@@ -215,6 +216,7 @@ void MatrixReader< Matrix >::readMtxHeader( std::istream& file,
...
@@ -215,6 +216,7 @@ void MatrixReader< Matrix >::readMtxHeader( std::istream& file,
if
(
rows
<=
0
||
columns
<=
0
)
if
(
rows
<=
0
||
columns
<=
0
)
throw
std
::
runtime_error
(
"Row or column index is negative."
);
throw
std
::
runtime_error
(
"Row or column index is negative."
);
break
;
}
}
}
}
...
...
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