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
8d920be8
Commit
8d920be8
authored
16 years ago
by
Jesper Andersson
Browse files
Options
Downloads
Patches
Plain Diff
First version pretty much finished and tested
parent
1ddffee6
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
splinterpolator.h
+35
-27
35 additions, 27 deletions
splinterpolator.h
with
35 additions
and
27 deletions
splinterpolator.h
+
35
−
27
View file @
8d920be8
...
...
@@ -56,12 +56,14 @@ public:
std
::
vector
<
ExtrapolationType
>
ett
(
dim
.
size
(),
et
);
common_construction
(
data
,
dim
,
order
,
prec
,
ett
,
copy_low_order
);
}
// Copy construction. May be removed in future
Splinterpolator
(
const
Splinterpolator
<
T
>&
src
)
:
_valid
(
false
),
_own_coef
(
false
),
_coef
(
0
),
_cptr
(
0
),
_ndim
(
0
)
{
assign
(
src
);
}
// Destructor
virtual
~
Splinterpolator
()
{
if
(
_own_coef
)
delete
[]
_coef
;
}
~
Splinterpolator
()
{
if
(
_own_coef
)
delete
[]
_coef
;
}
// Assignment. May be removed in future
Splinterpolator
&
operator
=
(
const
Splinterpolator
&
s
);
Splinterpolator
&
operator
=
(
const
Splinterpolator
&
s
rc
)
{
if
(
_own_coef
)
delete
[]
_coef
;
assign
(
src
);
return
(
*
this
);
}
// Set new data in Splinterpolator.
void
Set
(
const
T
*
data
,
const
std
::
vector
<
unsigned
int
>&
dim
,
const
std
::
vector
<
ExtrapolationType
>&
et
,
unsigned
int
order
=
3
,
bool
copy_low_order
=
true
,
double
prec
=
1e-8
)
...
...
@@ -69,7 +71,7 @@ public:
if
(
_own_coef
)
delete
[]
_coef
;
common_construction
(
data
,
dim
,
order
,
prec
,
et
,
copy_low_order
);
}
virtual
void
Set
(
const
T
*
data
,
const
std
::
vector
<
unsigned
int
>&
dim
,
ExtrapolationType
et
,
unsigned
int
order
=
3
,
bool
copy_low_order
=
true
,
double
prec
=
1e-8
)
void
Set
(
const
T
*
data
,
const
std
::
vector
<
unsigned
int
>&
dim
,
ExtrapolationType
et
,
unsigned
int
order
=
3
,
bool
copy_low_order
=
true
,
double
prec
=
1e-8
)
{
std
::
vector
<
ExtrapolationType
>
vet
(
dim
.
size
(),
Zeros
);
Set
(
data
,
dim
,
vet
,
order
,
copy_low_order
,
prec
);
...
...
@@ -105,6 +107,7 @@ public:
// Remaining functions are mainly for debugging/diagnostics.
//
unsigned
int
NDim
()
const
{
return
(
_ndim
);
}
unsigned
int
Order
()
const
{
return
(
_order
);
}
const
std
::
vector
<
unsigned
int
>&
Size
()
const
{
return
(
_dim
);
}
unsigned
int
Size
(
unsigned
int
dim
)
const
{
if
(
dim
>
4
)
return
(
0
);
else
return
(
_dim
[
dim
]);}
T
Coef
(
unsigned
int
x
,
unsigned
int
y
=
0
,
unsigned
int
z
=
0
)
const
...
...
@@ -177,6 +180,7 @@ private:
// Private helper-functions
//
void
common_construction
(
const
T
*
data
,
const
std
::
vector
<
unsigned
int
>&
dim
,
unsigned
int
order
,
double
prec
,
const
std
::
vector
<
ExtrapolationType
>&
et
,
bool
copy
);
void
assign
(
const
Splinterpolator
<
T
>&
src
);
bool
calc_coef
(
const
T
*
data
,
bool
copy
);
void
deconv_along
(
unsigned
int
dim
);
T
coef
(
int
*
indx
)
const
;
...
...
@@ -203,7 +207,7 @@ private:
//
// Disallowed member functions
//
Splinterpolator
(
const
Splinterpolator
&
s
);
// Don't allow copy-construction
//
Splinterpolator(const Splinterpolator& s); // Don't allow copy-construction
// Splinterpolator& operator=(const Splinterpolator& s); // Don't allow assignment
};
...
...
@@ -213,29 +217,6 @@ private:
//
/////////////////////////////////////////////////////////////////////
template
<
class
T
>
Splinterpolator
<
T
>&
Splinterpolator
<
T
>::
operator
=
(
const
Splinterpolator
<
T
>&
src
)
{
if
(
_own_coef
)
delete
[]
_coef
;
_valid
=
src
.
_valid
;
_own_coef
=
src
.
_own_coef
;
_cptr
=
src
.
_cptr
;
_order
=
src
.
_order
;
_ndim
=
src
.
_ndim
;
_prec
=
src
.
_prec
;
_dim
=
src
.
_dim
;
_et
=
src
.
_et
;
if
(
_own_coef
)
{
// If we need to do a deep copy
unsigned
int
ts
=
1
;
for
(
unsigned
int
i
=
0
;
i
<
_ndim
;
i
++
)
ts
*=
_dim
[
i
];
_coef
=
new
T
[
ts
];
memcpy
(
_coef
,
src
.
_coef
,
ts
*
sizeof
(
T
));
}
return
(
*
this
);
}
/////////////////////////////////////////////////////////////////////
//
// Returns interpolated value at location coord.
...
...
@@ -1000,6 +981,33 @@ void Splinterpolator<T>::common_construction(const T *data, const std::vector<un
_valid
=
true
;
}
/////////////////////////////////////////////////////////////////////
//
// Takes care of the "common" tasks when copy-constructing
// and when assigning.
//
/////////////////////////////////////////////////////////////////////
template
<
class
T
>
void
Splinterpolator
<
T
>::
assign
(
const
Splinterpolator
<
T
>&
src
)
{
_valid
=
src
.
_valid
;
_own_coef
=
src
.
_own_coef
;
_cptr
=
src
.
_cptr
;
_order
=
src
.
_order
;
_ndim
=
src
.
_ndim
;
_prec
=
src
.
_prec
;
_dim
=
src
.
_dim
;
_et
=
src
.
_et
;
if
(
_own_coef
)
{
// If we need to do a deep copy
unsigned
int
ts
=
1
;
for
(
unsigned
int
i
=
0
;
i
<
_ndim
;
i
++
)
ts
*=
_dim
[
i
];
_coef
=
new
T
[
ts
];
memcpy
(
_coef
,
src
.
_coef
,
ts
*
sizeof
(
T
));
}
}
/////////////////////////////////////////////////////////////////////
//
// Performs deconvolution, converting signal to spline coefficients.
...
...
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