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
ce6c4673
Commit
ce6c4673
authored
15 years ago
by
Mark Jenkinson
Browse files
Options
Downloads
Patches
Plain Diff
Removed all calls by copy (!! - yes COPY!) and replaced by calls by reference
parent
b2bab736
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kernel.cc
+17
-30
17 additions, 30 deletions
kernel.cc
kernel.h
+5
-5
5 additions, 5 deletions
kernel.h
with
22 additions
and
35 deletions
kernel.cc
+
17
−
30
View file @
ce6c4673
...
...
@@ -30,14 +30,12 @@ namespace MISCMATHS {
return
kernel
(
n
)
*
(
1.0
-
dn
)
+
kernel
(
n
+
1
)
*
dn
;
}
inline
bool
in_bounds
(
ColumnVector
data
,
int
index
)
inline
bool
in_bounds
(
const
ColumnVector
&
data
,
int
index
)
{
return
(
(
index
>=
1
)
&&
(
index
<=
data
.
Nrows
()));
}
inline
bool
in_bounds
(
ColumnVector
data
,
float
index
)
inline
bool
in_bounds
(
const
ColumnVector
&
data
,
float
index
)
{
return
(
((
int
)
floor
(
index
)
>=
1
)
&&
((
int
)
ceil
(
index
)
<=
data
.
Nrows
()));
}
// Support Functions
float
sincfn
(
float
x
)
{
if
(
fabs
(
x
)
<
1e-7
)
{
return
1.0
-
fabs
(
x
);
}
...
...
@@ -125,7 +123,7 @@ namespace MISCMATHS {
}
// dummy fn for now
float
extrapolate_1d
(
const
ColumnVector
data
,
const
int
index
)
float
extrapolate_1d
(
const
ColumnVector
&
data
,
const
int
index
)
{
float
extrapval
;
...
...
@@ -142,7 +140,7 @@ namespace MISCMATHS {
}
// basic trilinear call
float
interpolate_1d
(
ColumnVector
data
,
const
float
index
)
float
interpolate_1d
(
const
ColumnVector
&
data
,
const
float
index
)
{
float
interpval
;
int
low_bound
=
(
int
)
floor
(
index
);
...
...
@@ -159,7 +157,7 @@ namespace MISCMATHS {
//////// Spline Support /////////
float
hermiteinterpolation_1d
(
ColumnVector
data
,
int
p1
,
int
p4
,
float
t
)
float
hermiteinterpolation_1d
(
const
ColumnVector
&
data
,
int
p1
,
int
p4
,
float
t
)
{
// Q(t) = (2t^3 - 3t^2 + 1)P_1 + (-2t^3 + 3t^2)P_4 + (t^3 - 2t^2 + t)R_1 + (t^3 - t^2)R_4
// inputs: points P_1, P_4; tangents R_1, R_4; interpolation index t;
...
...
@@ -193,24 +191,26 @@ namespace MISCMATHS {
//////// Kernel Interpolation Call /////////
float
kernelinterpolation_1d
(
ColumnVector
data
,
float
index
,
ColumnVector
userkernel
,
int
width
)
float
kernelinterpolation_1d
(
const
ColumnVector
&
data
,
float
index
,
const
ColumnVector
&
userkernel
,
int
width
)
{
int
widthx
=
(
width
-
1
)
/
2
;
// kernel half-width (i.e. range is +/- w)
int
wx
=
widthx
;
ColumnVector
kernelx
=
userkernel
;
float
*
storex
=
new
float
[
2
*
wx
+
1
];
int
ix0
;
ix0
=
(
int
)
floor
(
index
);
static
int
wx
=
0
;
static
float
*
storex
=
0
;
if
(
(
wx
!=
widthx
)
||
(
storex
==
0
)
)
{
wx
=
widthx
;
storex
=
new
float
[
2
*
wx
+
1
];
for
(
int
d
=-
wx
;
d
<=
wx
;
d
++
)
{
storex
[
d
+
wx
]
=
kernelval
((
index
-
ix0
+
d
),
wx
,
userkernel
);
}
}
float
convsum
=
0.0
,
interpval
=
0.0
,
kersum
=
0.0
;
for
(
int
d
=-
wx
;
d
<=
wx
;
d
++
)
{
storex
[
d
+
wx
]
=
kernelval
((
index
-
ix0
+
d
),
wx
,
kernelx
);
}
int
xj
;
for
(
int
x1
=
ix0
-
wx
;
x1
<=
ix0
+
wx
;
x1
++
)
{
if
(
in_bounds
(
data
,
x1
))
{
...
...
@@ -223,8 +223,6 @@ namespace MISCMATHS {
}
}
delete
(
storex
);
if
(
(
fabs
(
kersum
)
>
1e-9
)
)
{
interpval
=
convsum
/
kersum
;
}
else
{
...
...
@@ -238,7 +236,7 @@ namespace MISCMATHS {
////// Kernel wrappers //////
float
kernelinterpolation_1d
(
ColumnVector
data
,
float
index
)
float
kernelinterpolation_1d
(
const
ColumnVector
&
data
,
float
index
)
{
ColumnVector
userkernel
=
sinckernel1D
(
"hanning"
,
7
,
1201
);
return
kernelinterpolation_1d
(
data
,
index
,
userkernel
,
7
);
...
...
@@ -251,14 +249,3 @@ namespace MISCMATHS {
}
}
This diff is collapsed.
Click to expand it.
kernel.h
+
5
−
5
View file @
ce6c4673
...
...
@@ -167,12 +167,12 @@ namespace MISCMATHS {
kernel
sinckernel
(
const
string
&
sincwindowtype
,
int
w
,
int
nstore
);
kernel
sinckernel
(
const
string
&
sincwindowtype
,
int
wx
,
int
wy
,
int
wz
,
int
nstore
);
float
extrapolate_1d
(
const
ColumnVector
data
,
const
int
index
);
float
interpolate_1d
(
ColumnVector
data
,
const
float
index
);
float
kernelinterpolation_1d
(
ColumnVector
data
,
float
index
,
ColumnVector
userkernel
,
int
width
);
float
kernelinterpolation_1d
(
ColumnVector
data
,
float
index
);
float
extrapolate_1d
(
const
ColumnVector
&
data
,
const
int
index
);
float
interpolate_1d
(
const
ColumnVector
&
data
,
const
float
index
);
float
kernelinterpolation_1d
(
const
ColumnVector
&
data
,
float
index
,
const
ColumnVector
&
userkernel
,
int
width
);
float
kernelinterpolation_1d
(
const
ColumnVector
&
data
,
float
index
);
float
kernelinterpolation_1d
(
RowVector
data
,
float
index
);
float
hermiteinterpolation_1d
(
ColumnVector
data
,
int
p1
,
int
p4
,
float
t
);
float
hermiteinterpolation_1d
(
const
ColumnVector
&
data
,
int
p1
,
int
p4
,
float
t
);
}
#endif
...
...
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