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
49faa182
Commit
49faa182
authored
14 years ago
by
Jesper Andersson
Browse files
Options
Downloads
Patches
Plain Diff
Added copy-constructor and assignment operator to SpMat
parent
cb9e0a76
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
SpMat.h
+9
-1
9 additions, 1 deletion
SpMat.h
with
9 additions
and
1 deletion
SpMat.h
+
9
−
1
View file @
49faa182
...
...
@@ -94,6 +94,7 @@ public:
SpMat
(
unsigned
int
m
,
unsigned
int
n
,
const
unsigned
int
*
irp
,
const
unsigned
int
*
jcp
,
const
double
*
sp
);
SpMat
(
const
NEWMAT
::
GeneralMatrix
&
M
);
SpMat
(
const
std
::
string
&
fname
);
SpMat
(
const
SpMat
<
T
>&
s
)
:
_m
(
s
.
_m
),
_n
(
s
.
_n
),
_nz
(
s
.
_nz
),
_ri
(
s
.
_ri
),
_val
(
s
.
_val
),
_pw
(
s
.
_pw
),
_ei
(
*
this
,
true
)
{}
~
SpMat
()
{}
unsigned
int
Nrows
()
const
{
return
(
_m
);}
...
...
@@ -121,6 +122,12 @@ public:
void
SetColumn
(
unsigned
int
c
,
const
NEWMAT
::
ColumnVector
&
col
,
double
eps
=
0.0
);
// Set a whole column (obliterating what was there before)
void
AddTo
(
unsigned
int
r
,
unsigned
int
c
,
const
T
&
v
)
{
here
(
r
,
c
)
+=
v
;}
// Add value to a single (possibly existing) value
SpMat
<
T
>&
operator
=
(
const
SpMat
&
M
)
{
if
(
this
==
&
M
)
return
(
*
this
);
_m
=
M
.
_m
;
_n
=
M
.
_n
;
_nz
=
M
.
_nz
;
_ri
=
M
.
_ri
;
_val
=
M
.
_val
;
_pw
=
M
.
_pw
;
_ei
=
M
.
_ei
;
return
(
*
this
);
}
SpMat
<
T
>&
operator
+=
(
const
SpMat
&
M
)
{
if
(
same_sparsity
(
M
))
return
(
add_same_sparsity_mat_to_me
(
M
,
1
));
...
...
@@ -182,10 +189,11 @@ public:
if
(
_j
==
_mat
.
_n
)
_oob
=
true
;
}
~
Iterator
()
{}
Iterator
&
operator
=
(
const
Iterator
&
I
)
{
_i
=
I
.
_i
;
_j
=
I
.
_j
;
_oob
=
I
.
_oob
;
return
(
*
this
);
}
// _mat deliberately not assigned
bool
operator
==
(
const
Iterator
&
other
)
{
return
(
&
_mat
==&
other
.
_mat
&&
((
_oob
&&
other
.
_oob
)
||
(
_i
==
other
.
_i
&&
_j
==
other
.
_j
)));
}
bool
operator
!=
(
const
Iterator
&
other
)
{
return
(
!
(
*
this
==
other
));
}
T
&
operator
*
()
{
return
((
_mat
.
_val
[
_j
])[
_i
]);
}
Iterator
&
operator
++
()
Iterator
&
operator
++
()
// Prefix operator
{
if
(
++
_i
<
_mat
.
_ri
[
_j
].
size
())
return
(
*
this
);
else
{
...
...
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