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
710f6375
Commit
710f6375
authored
17 years ago
by
Mark Jenkinson
Browse files
Options
Downloads
Patches
Plain Diff
Added option to initialise solution
parent
d3274330
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
+45
-2
45 additions, 2 deletions
SpMat.h
with
45 additions
and
2 deletions
SpMat.h
+
45
−
2
View file @
710f6375
...
...
@@ -137,7 +137,20 @@ public:
double
tol
=
1e-4
,
unsigned
int
miter
=
200
,
boost
::
shared_ptr
<
Preconditioner
<
T
>
>
C
=
boost
::
shared_ptr
<
Preconditioner
<
T
>
>
())
const
;
NEWMAT
::
ReturnMatrix
SolveForx
(
const
NEWMAT
::
ColumnVector
&
b
,
MatrixType
type
,
double
tol
,
unsigned
int
miter
,
const
NEWMAT
::
ColumnVector
&
x_init
)
const
;
NEWMAT
::
ReturnMatrix
SolveForx
(
const
NEWMAT
::
ColumnVector
&
b
,
MatrixType
type
,
double
tol
,
unsigned
int
miter
,
boost
::
shared_ptr
<
Preconditioner
<
T
>
>
C
,
const
NEWMAT
::
ColumnVector
&
x_init
)
const
;
private
:
unsigned
int
_m
;
unsigned
int
_n
;
...
...
@@ -368,18 +381,48 @@ NEWMAT::ReturnMatrix SpMat<T>::AsNEWMAT() const
//
/////////////////////////////////////////////////////////////////////
template
<
class
T
>
NEWMAT
::
ReturnMatrix
SpMat
<
T
>::
SolveForx
(
const
NEWMAT
::
ColumnVector
&
b
,
MatrixType
type
,
double
tol
,
unsigned
int
miter
,
const
NEWMAT
::
ColumnVector
&
x_init
)
const
{
return
this
->
SolveForx
(
b
,
type
,
tol
,
miter
,
boost
::
shared_ptr
<
Preconditioner
<
T
>
>
(),
x_init
);
}
template
<
class
T
>
NEWMAT
::
ReturnMatrix
SpMat
<
T
>::
SolveForx
(
const
NEWMAT
::
ColumnVector
&
b
,
MatrixType
type
,
double
tol
,
unsigned
int
miter
,
boost
::
shared_ptr
<
Preconditioner
<
T
>
>
C
)
const
{
NEWMAT
::
ColumnVector
x_init
;
return
this
->
SolveForx
(
b
,
type
,
tol
,
miter
,
C
,
x_init
);
}
template
<
class
T
>
NEWMAT
::
ReturnMatrix
SpMat
<
T
>::
SolveForx
(
const
NEWMAT
::
ColumnVector
&
b
,
MatrixType
type
,
double
tol
,
unsigned
int
miter
,
boost
::
shared_ptr
<
Preconditioner
<
T
>
>
C
,
const
NEWMAT
::
ColumnVector
&
x_init
)
const
{
if
(
_m
!=
_n
)
throw
SpMatException
(
"SolveForx: Matrix must be square"
);
if
(
int
(
_m
)
!=
b
.
Nrows
())
throw
SpMatException
(
"SolveForx: Mismatch between matrix and vector"
);
NEWMAT
::
ColumnVector
x
(
_n
);
x
=
0.0
;
if
(
x
.
Nrows
()
==
x_init
.
Nrows
())
{
x
=
x_init
;
}
else
{
if
(
x_init
.
Nrows
()
>
0
)
{
throw
SpMatException
(
"SolveForx: initialisation vector has incorrect size"
);
}
else
{
x
=
0.0
;
}
}
int
status
=
0
;
int
liter
=
int
(
miter
);
double
ltol
=
tol
;
...
...
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