Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
8cc3297c
Commit
8cc3297c
authored
Jan 14, 2019
by
Purves, Murray
Browse files
Adding support for base values going high to low in radixmath::interpolateToNewBaseValues
parent
ac74e198
Changes
2
Hide whitespace changes
Inline
Side-by-side
radixmath/interpolate.cc
View file @
8cc3297c
...
...
@@ -164,20 +164,38 @@ std::vector<T> interpolateToOtherBaseValues(
}
radix_line
(
" Initial interpolation complete"
);
// Work out if the base array goes low to high or high to low
bool
lowToHigh
=
true
;
if
(
baseValues
.
front
()
<
baseValues
.
back
())
{
radix_line
(
" Base values go low to high"
);
}
else
{
lowToHigh
=
false
;
radix_line
(
" Base values go high to low"
);
}
// Iterate over the new base vector to calculate values at these positions
radix_line
(
" Interpolating to new base values"
);
for
(
size_t
i
=
0
;
i
<
newBaseValues
.
size
();
++
i
)
{
// Fill in values with a new base lower than the lowest original
if
(
newBaseValues
[
i
]
<
baseValues
.
front
())
if
((
lowToHigh
&&
newBaseValues
[
i
]
<
baseValues
.
front
())
||
(
!
lowToHigh
&&
newBaseValues
[
i
]
<
baseValues
.
back
()))
{
radix_line
(
" Base value below range: filling with lowest"
);
radix_line
(
" Base value "
<<
newBaseValues
[
i
]
<<
" below range "
<<
baseValues
.
front
()
<<
"-"
<<
baseValues
.
back
()
<<
": filling with lowest"
);
finalInterpolatedValues
[
i
]
=
initialInterpolatedValues
.
front
();
}
// Fill in values with a new base higher than the highest original
else
if
(
newBaseValues
[
i
]
>
baseValues
.
back
())
else
if
((
lowToHigh
&&
newBaseValues
[
i
]
>
baseValues
.
back
())
||
(
!
lowToHigh
&&
newBaseValues
[
i
]
>
baseValues
.
front
()))
{
radix_line
(
" Base value above range: filling with highest"
);
radix_line
(
" Base value "
<<
newBaseValues
[
i
]
<<
" above range "
<<
baseValues
.
front
()
<<
"-"
<<
baseValues
.
back
()
<<
": filling with highest"
);
finalInterpolatedValues
[
i
]
=
initialInterpolatedValues
.
back
();
}
// Fill in central values
...
...
radixmath/interpolate.hh
View file @
8cc3297c
...
...
@@ -12,7 +12,7 @@
namespace
radix
{
template
<
typename
T
>
extern
std
::
vector
<
T
>
RADIX_PUBLIC
interpolateValues
(
std
::
vector
<
T
>
RADIX_PUBLIC
interpolateValues
(
const
std
::
vector
<
T
>
&
baseValues
,
const
std
::
vector
<
T
>
&
valuesToInterpolate
,
const
bool
circular
=
false
,
const
T
missingValue
=
-
9999.
f
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment