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
33e3f0af
Commit
33e3f0af
authored
21 years ago
by
Mark Woolrich
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
3e1a676d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
miscmaths.cc
+90
-0
90 additions, 0 deletions
miscmaths.cc
miscmaths.h
+3
-1
3 additions, 1 deletion
miscmaths.h
with
93 additions
and
1 deletion
miscmaths.cc
+
90
−
0
View file @
33e3f0af
...
@@ -1761,7 +1761,97 @@ int conjgrad(ColumnVector& x, const Matrix& A, const ColumnVector& b, int maxit)
...
@@ -1761,7 +1761,97 @@ int conjgrad(ColumnVector& x, const Matrix& A, const ColumnVector& b, int maxit)
return
conjgrad
(
x
,
A
,
b
,
maxit
,
1e-10
);
return
conjgrad
(
x
,
A
,
b
,
maxit
,
1e-10
);
}
}
float
csevl
(
const
float
x
,
const
ColumnVector
&
cs
,
const
int
n
)
{
float
b0
=
0
;
float
b1
=
0
;
float
b2
=
0
;
const
float
twox
=
2
*
x
;
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
b2
=
b1
;
b1
=
b0
;
b0
=
twox
*
b1
-
b2
+
cs
(
n
+
1
-
i
);
}
return
0.5
*
(
b0
-
b2
);
}
float
digamma
(
const
float
x
)
{
int
ntapsi
(
16
);
int
ntpsi
(
23
);
ColumnVector
psics
(
ntpsi
);
ColumnVector
apsics
(
ntapsi
);
psics
<<
-
.038057080835217922E0
<<
.49141539302938713E0
<<
-
.056815747821244730E0
<<
.008357821225914313E0
<<
-
.001333232857994342E0
<<
.000220313287069308E0
<<
-
.000037040238178456E0
<<
.000006283793654854E0
<<
-
.000001071263908506E0
<<
.000000183128394654E0
<<
-
.000000031353509361E0
<<
.000000005372808776E0
<<
-
.000000000921168141E0
<<
.000000000157981265E0
<<
-
.000000000027098646E0
<<
.000000000004648722E0
<<
-
.000000000000797527E0
<<
.000000000000136827E0
<<
-
.000000000000023475E0
<<
.000000000000004027E0
<<
-
.000000000000000691E0
<<
.000000000000000118E0
<<
-
.000000000000000020E0
;
apsics
<<-
.0204749044678185E0
<<
-
.0101801271534859E0
<<
.0000559718725387E0
<<
-
.0000012917176570E0
<<
.0000000572858606E0
<<
-
.0000000038213539E0
<<
.0000000003397434E0
<<
-
.0000000000374838E0
<<
.0000000000048990E0
<<
-
.0000000000007344E0
<<
.0000000000001233E0
<<
-
.0000000000000228E0
<<
.0000000000000045E0
<<
-
.0000000000000009E0
<<
.0000000000000002E0
<<
-
.0000000000000000E0
;
float
y
=
fabs
(
x
);
float
psi
;
if
(
y
<
2.0
)
{
// do we need to deal with the following case?
// c psi(x) for -2. .lt. x .lt. 2.
int
n
=
int
(
floor
(
x
));
y
=
x
-
n
;
n
=
n
-
1
;
psi
=
csevl
(
2
*
y
-
1
,
psics
,
ntpsi
);
if
(
n
==-
1
)
{
psi
=
psi
-
1.0
/
x
;
}
}
else
{
const
float
aux
=
csevl
(
8
/
(
Sqr
(
y
))
-
1
,
apsics
,
ntapsi
);
psi
=
log
(
x
)
-
0.5
/
x
+
aux
;
}
return
psi
;
}
vector
<
float
>
ColumnVector2vector
(
const
ColumnVector
&
col
)
vector
<
float
>
ColumnVector2vector
(
const
ColumnVector
&
col
)
...
...
This diff is collapsed.
Click to expand it.
miscmaths.h
+
3
−
1
View file @
33e3f0af
...
@@ -214,7 +214,9 @@ namespace MISCMATHS {
...
@@ -214,7 +214,9 @@ namespace MISCMATHS {
// (stops when error < reltol * initial error)
// (stops when error < reltol * initial error)
int
conjgrad
(
ColumnVector
&
x
,
const
Matrix
&
A
,
const
ColumnVector
&
b
,
int
conjgrad
(
ColumnVector
&
x
,
const
Matrix
&
A
,
const
ColumnVector
&
b
,
int
maxit
,
float
reltol
);
int
maxit
,
float
reltol
);
float
csevl
(
const
float
x
,
const
ColumnVector
&
cs
,
const
int
n
);
float
digamma
(
const
float
x
);
vector
<
float
>
ColumnVector2vector
(
const
ColumnVector
&
col
);
vector
<
float
>
ColumnVector2vector
(
const
ColumnVector
&
col
);
...
...
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