Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
cad262a1
Commit
cad262a1
authored
Aug 12, 2020
by
Nils Rummler
Browse files
renamed a getter fnc in PiecewisePolynomial and minor tidy up.
parent
53b9f3d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/ITABase/Math/PiecewisePolynomial.h
View file @
cad262a1
...
...
@@ -49,6 +49,8 @@ namespace ITABase
inline
int
NumCoefficients
()
const
{
return
Order
()
+
1
;
};
//! Returns the break points defining the intervals for the polynomials
inline
const
std
::
vector
<
float
>&
BreakPoints
()
const
{
return
vdBreakPoints
;
};
//! Returns the Coefficients of that Polynom. Sorted according to ascending intervals [a0, b0, c0, d0, a1, b1, c1, d1]
inline
const
std
::
vector
<
float
>&
Coefficients
()
const
{
return
vdCoefficients
;
};
//! Evaluate the piecewise polynomial at a given x value.
float
Value
(
const
float
&
xValue
)
const
;
...
...
@@ -58,8 +60,6 @@ namespace ITABase
int
IntervalIndex
(
const
float
xValue
)
const
;
//! Return a piecewise polynomial containing the derivations of the polynomials of this one
CPiecewisePolynomial
Derivation
()
const
;
//! Debug only?!
std
::
vector
<
float
>::
const_iterator
getCoefficients
()
const
{
return
vdCoefficients
.
begin
();
}
private:
//! Returns the iterator to the first coefficient of the interval with given index
...
...
tests/SplineTest.cpp
View file @
cad262a1
...
...
@@ -62,7 +62,7 @@ int main(int iNumInArgs, char* pcInArgs[])
std::vector<float> vdResult2 = { float(77.0000), float(7.9485), float(18.7512), float(50.0000), float(70.7647), float(36.3051), float(28.0000)
*/
//Test 2, Speedtest
/*
std
::
vector
<
float
>
vdSupportingPoints
{
-
10
,
-
9
,
-
8
,
-
7
,
-
6
,
-
5
,
-
4
,
-
3
,
-
2
,
-
1
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
};
std
::
vector
<
float
>
vdDataPoints2
{
77
,
80
,
19
,
49
,
45
,
65
,
71
,
76
,
28
,
68
,
66
,
17
,
12
,
50
,
96
,
35
,
59
,
23
,
76
,
26
,
51
};
std
::
vector
<
float
>
vdX
=
{
-
10
,
float
(
1.5
),
float
(
-
7.898
),
float
(
3.3
),
float
(
3.3
),
float
(
9.9
),
float
(
-
2.5
),
float
(
8.9
),
float
(
0.01
),
float
(
-
4.3
)
};
...
...
@@ -86,8 +86,8 @@ int main(int iNumInArgs, char* pcInArgs[])
myWatch
.
stop
();
}
std
::
cout
<<
myWatch
<<
std
::
endl
;
*/
/*
//Test 3, export Coefficients to .txt to plot them in Matlab
std::vector<float> vdSupportingPoints{ -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
std::vector<float> vdDataPoints{ 77, 80, 19, 49, 45, 65, 71, 76, 28, 68, 66, 17,12, 50, 96, 35, 59, 23, 76, 26, 51 };
...
...
@@ -124,7 +124,7 @@ int main(int iNumInArgs, char* pcInArgs[])
//should trhow exception
myPoly2.Value(2);
*/
return
0
;
...
...
tests/
s
plineTest.m
→
tests/
S
plineTest.m
View file @
cad262a1
File moved
tests/spline_compare.m
deleted
100644 → 0
View file @
53b9f3d6
%% Create Matlab and ITA::BASE splines
X
=
[
-
10
:
1
:
10
];
Y
=
[
77
80
19
49
45
65
71
76
28
68
66
17
12
50
96
35
59
23
76
26
51
];
%randi(100,1,21)
Coeffs
=
[
-
24.4868088000000
0
27.4868088000000
77
;
...
%Copy & Paste from the resulting ITA::BASE Spline
58.4340477000000
-
73.4604263000000
-
45.9736176000000
80
;
...
-
54.2493782000000
101.841713000000
-
17.5923386000000
19
;
...
33.5634651000000
-
60.9064217000000
23.3429565000000
49
;
...
-
22.0044861000000
39.7839775000000
2.22050858000000
45
;
...
16.4544754000000
-
26.2294807000000
15.7750053000000
65
;
...
-
30.7892181747901
23.0766833120257
12.6794720000000
71
;
...
54.7927242498993
-
69.2909712123447
-
33.5017530375546
76
;
...
-
47.3816788248071
95.0872015373532
-
7.70552271254611
28
;
...
4.73399104932904
-
47.0578349370681
40.3238438877390
68
;
...
23.4457146274910
-
32.8558617890810
-
39.5898528384100
66
;
...
-
7.51684955929288
37.4812820933919
-
34.9644325340990
17
;
...
5.62168360968059
14.9307334155133
17.4475829748062
12
;
...
-
49.9698848794294
31.7957842445550
64.1741006348744
50
;
...
79.2578559080372
-
118.113870393733
-
22.1439855143039
96
;
...
-
75.0615387527194
119.659697330378
-
20.5981585776589
35
;
...
77.5513382000000
-
106.515846000000
-
7.03549194000000
59
;
...
-
85.7249985000000
126.138168000000
12.5868301000000
23
;
...
73.3486862000000
-
131.036835000000
7.68815231000000
76
;
...
-
29.6697369000000
89.0092087000000
-
34.3394737000000
26
];
myPoly
=
mkpp
(
X
,
Coeffs
);
%% Plot
xx
=
[
-
10
:
0.1
:
10
];
plot
(
X
,
Y
,
'o'
,
xx
,
spline
(
X
,
Y
,
xx
));
hold
on
grid
on
title
'Splines: Matlab vs. ITA'
plot
(
xx
,
ppval
(
myPoly
,
xx
));
plot
(
xx
,
spline
(
X
,
Y
,
xx
)
-
ppval
(
myPoly
,
xx
));
legend
(
'Data'
,
'Matlab'
,
'ITA'
,
'Diff'
);
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment