Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miscmaths
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
Container Registry
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
miscmaths
Commits
636e6182
Commit
636e6182
authored
7 years ago
by
Jesper Andersson
Browse files
Options
Downloads
Patches
Plain Diff
Added an IsSorted() method for debugging purposes
parent
454b6664
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SpMat.h
+23
-0
23 additions, 0 deletions
SpMat.h
with
23 additions
and
0 deletions
SpMat.h
+
23
−
0
View file @
636e6182
...
...
@@ -110,6 +110,7 @@ public:
void
Print
()
const
{
Print
(
8
);}
void
WarningsOn
()
{
_pw
=
true
;}
void
WarningsOff
()
{
_pw
=
false
;}
bool
IsSorted
()
const
{
return
(
is_sorted
());
}
// Returns true if all _ri arrays are sorted. For debugging.
T
Peek
(
unsigned
int
r
,
unsigned
int
c
)
const
;
...
...
@@ -220,6 +221,7 @@ private:
bool
same_sparsity
(
const
SpMat
<
T
>&
M
)
const
;
SpMat
<
T
>&
add_same_sparsity_mat_to_me
(
const
SpMat
<
T
>&
M
,
double
s
);
SpMat
<
T
>&
add_diff_sparsity_mat_to_me
(
const
SpMat
<
T
>&
M
,
double
s
);
bool
is_sorted
()
const
;
};
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
...
...
@@ -1222,6 +1224,27 @@ SpMat<T>& SpMat<T>::add_diff_sparsity_mat_to_me(const SpMat<T>& M, double s)
return
(
*
this
);
}
/////////////////////////////////////////////////////////////////////
//
// Returns true if all _ri arrays are sorted in ascending order
//
/////////////////////////////////////////////////////////////////////
template
<
class
T
>
bool
SpMat
<
T
>::
is_sorted
()
const
{
for
(
unsigned
int
ci
=
0
;
ci
<
_ri
.
size
();
ci
++
)
{
if
(
_ri
[
ci
].
size
()
>
1
)
{
unsigned
int
cri
=
_ri
[
ci
][
0
];
for
(
unsigned
int
ii
=
1
;
ii
<
_ri
[
ci
].
size
();
ii
++
)
{
if
(
_ri
[
ci
][
ii
]
<
cri
)
return
(
false
);
else
cri
=
_ri
[
ci
][
ii
];
}
}
}
return
(
true
);
}
/*
template<class T>
SpMat<T>& SpMat<T>::add_diff_sparsity_mat_to_me(const SpMat<T>& M, double s)
...
...
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