Skip to content

Commit 9546f1d

Browse files
author
camilo
committed
added interp1 class. bump to 1.0.8
1 parent 297ceda commit 9546f1d

File tree

13 files changed

+802
-16
lines changed

13 files changed

+802
-16
lines changed

check/main.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,24 @@
33
using namespace qlibs;
44

55
int main() {
6+
7+
mat<2,2> x(
8+
1.0f, 2.0f,
9+
3.0f, 4.0f
10+
);
11+
mat<2,1> y(
12+
1.0f,
13+
3.0f
14+
);
15+
mat<2,1> z(
16+
2.0f,
17+
2.0f
18+
);
19+
20+
mat<2,1> result = 4.5 - z - 2.0f*x*y - 3;
21+
x*=x;
22+
result.display();
23+
x.display();
24+
625
return 0;
726
}

check/qlibs_cpp_test.cpp

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ void test_fp16( void );
1111
void test_crc( void );
1212
void test_ltisys( void );
1313
void test_ffmath( void );
14-
14+
void test_mat( void );
15+
void test_interp1( void );
1516

1617
void test_fis3( void )
1718
{
@@ -304,6 +305,108 @@ void test_ffmath(void)
304305
cout << ffmath::getInf() << endl;
305306
}
306307

308+
void test_mat( void )
309+
{
310+
cout<<"MAT TEST"<<endl;
311+
mat<2,2> x(
312+
1.0f, 2.0f,
313+
3.0f, 4.0f
314+
);
315+
mat<2,1> y(
316+
1.0f,
317+
3.0f
318+
);
319+
mat<2,1> z(
320+
2.0f,
321+
2.0f
322+
);
323+
324+
mat<2,1> result = 4.5 - z - 2.0f*x*y - 3;
325+
mat<4,4> I( MAT_IDENTITY );
326+
x*=x;
327+
result.display();
328+
x.display();
329+
cout<< x(2) << endl;
330+
auto j = !y;
331+
j.display();
332+
I.display();
333+
auto ix = x.inv();
334+
x.display();
335+
ix.display();
336+
(x*ix).display();
337+
338+
}
339+
340+
void test_interp1( void )
341+
{
342+
real_t tx[] = { 1.0f, 2.0f, 3.0f, 4.0f };
343+
real_t ty[] = { 5.0f, 9.0f, 12.0f, 15.0f };
344+
interp1 interpolation( tx, ty );
345+
346+
cout << "linear" << endl;
347+
interpolation.setMethod( INTERP1_LINEAR );
348+
cout << interpolation.get( 2.5 ) << endl;
349+
cout << interpolation.get( 3.1 ) << endl;
350+
cout << interpolation.get( 0.5 ) << endl;
351+
cout << interpolation.get( 5.0 ) << endl;
352+
353+
cout << "sine" << endl;
354+
interpolation.setMethod( INTERP1_SINE );
355+
cout << interpolation.get( 2.5 ) << endl;
356+
cout << interpolation.get( 3.1 ) << endl;
357+
cout << interpolation.get( 0.5 ) << endl;
358+
cout << interpolation.get( 5.0 ) << endl;
359+
360+
cout << "cubic" << endl;
361+
interpolation.setMethod( INTERP1_CUBIC );
362+
cout << interpolation.get( 2.5 ) << endl;
363+
cout << interpolation.get( 3.1 ) << endl;
364+
cout << interpolation.get( 0.5 ) << endl;
365+
cout << interpolation.get( 5.0 ) << endl;
366+
367+
cout << "hermite" << endl;
368+
interpolation.setMethod( INTERP1_HERMITE );
369+
cout << interpolation.get( 2.5 ) << endl;
370+
cout << interpolation.get( 3.1 ) << endl;
371+
cout << interpolation.get( 0.5 ) << endl;
372+
cout << interpolation.get( 5.0 ) << endl;
373+
374+
cout << "nearest" << endl;
375+
interpolation.setMethod( INTERP1_NEAREST);
376+
cout << interpolation.get( 2.5 ) << endl;
377+
cout << interpolation.get( 3.1 ) << endl;
378+
cout << interpolation.get( 0.5 ) << endl;
379+
cout << interpolation.get( 5.0 ) << endl;
380+
381+
cout << "next" << endl;
382+
interpolation.setMethod( INTERP1_NEXT);
383+
cout << interpolation.get( 2.5 ) << endl;
384+
cout << interpolation.get( 3.1 ) << endl;
385+
cout << interpolation.get( 0.5 ) << endl;
386+
cout << interpolation.get( 5.0 ) << endl;
387+
388+
cout << "previous" << endl;
389+
interpolation.setMethod( INTERP1_PREVIOUS);
390+
cout << interpolation.get( 2.5 ) << endl;
391+
cout << interpolation.get( 3.1 ) << endl;
392+
cout << interpolation.get( 0.5 ) << endl;
393+
cout << interpolation.get( 5.0 ) << endl;
394+
395+
cout << "spline" << endl;
396+
interpolation.setMethod( INTERP1_SPLINE);
397+
cout << interpolation.get( 2.5 ) << endl;
398+
cout << interpolation.get( 3.1 ) << endl;
399+
cout << interpolation.get( 0.5 ) << endl;
400+
cout << interpolation.get( 5.0 ) << endl;
401+
402+
cout << "cspline" << endl;
403+
interpolation.setMethod( INTERP1_CONSTRAINED_SPLINE);
404+
cout << interpolation.get( 2.5 ) << endl;
405+
cout << interpolation.get( 3.1 ) << endl;
406+
cout << interpolation.get( 0.5 ) << endl;
407+
cout << interpolation.get( 5.0 ) << endl;
408+
}
409+
307410
int main()
308411
{
309412
test_crc();
@@ -314,5 +417,7 @@ int main()
314417
test_fis2();
315418
test_fis3();
316419
test_ffmath();
420+
test_mat();
421+
test_interp1();
317422
return 0;
318423
}

check/sa_check.ewp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,9 +2164,15 @@
21642164
<file>
21652165
<name>$PROJ_DIR$\..\src\include\generic.hpp</name>
21662166
</file>
2167+
<file>
2168+
<name>$PROJ_DIR$\..\src\include\interp1.hpp</name>
2169+
</file>
21672170
<file>
21682171
<name>$PROJ_DIR$\..\src\include\ltisys.hpp</name>
21692172
</file>
2173+
<file>
2174+
<name>$PROJ_DIR$\..\src\include\mat.hpp</name>
2175+
</file>
21702176
<file>
21712177
<name>$PROJ_DIR$\..\src\include\mathex.hpp</name>
21722178
</file>
@@ -2210,6 +2216,9 @@
22102216
<file>
22112217
<name>$PROJ_DIR$\..\src\generic.cpp</name>
22122218
</file>
2219+
<file>
2220+
<name>$PROJ_DIR$\..\src\interp1.cpp</name>
2221+
</file>
22132222
<file>
22142223
<name>$PROJ_DIR$\..\src\ltisys.cpp</name>
22152224
</file>

check/sa_check.ewt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,9 +2868,15 @@
28682868
<file>
28692869
<name>$PROJ_DIR$\..\src\include\generic.hpp</name>
28702870
</file>
2871+
<file>
2872+
<name>$PROJ_DIR$\..\src\include\interp1.hpp</name>
2873+
</file>
28712874
<file>
28722875
<name>$PROJ_DIR$\..\src\include\ltisys.hpp</name>
28732876
</file>
2877+
<file>
2878+
<name>$PROJ_DIR$\..\src\include\mat.hpp</name>
2879+
</file>
28742880
<file>
28752881
<name>$PROJ_DIR$\..\src\include\mathex.hpp</name>
28762882
</file>
@@ -2914,6 +2920,9 @@
29142920
<file>
29152921
<name>$PROJ_DIR$\..\src\generic.cpp</name>
29162922
</file>
2923+
<file>
2924+
<name>$PROJ_DIR$\..\src\interp1.cpp</name>
2925+
</file>
29172926
<file>
29182927
<name>$PROJ_DIR$\..\src\ltisys.cpp</name>
29192928
</file>

keywords.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# Datatypes(KEYWORD1)
77
#######################################
88

9+
interp1 KEYWORD1
10+
interp1Method KEYWORD1
911
real_t KEYWORD1
1012
bitfield KEYWORD1
1113
crc KEYWORD1
@@ -65,6 +67,7 @@ tdl KEYWORD1
6567
# Methods and Functions(KEYWORD2)
6668
#######################################
6769

70+
setMethod KEYWORD2
6871
bitfield_size KEYWORD2
6972
setup KEYWORD2
7073
clearAll KEYWORD2
@@ -224,7 +227,15 @@ insertSample KEYWORD2
224227

225228
#######################################
226229
# Constants(LITERAL1)
227-
230+
INTERP1_NEXT LITERAL1
231+
INTERP1_PREVIOUS LITERAL1
232+
INTERP1_NEAREST LITERAL1
233+
INTERP1_LINEAR LITERAL1
234+
INTERP1_SINE LITERAL1
235+
INTERP1_CUBIC LITERAL1
236+
INTERP1_HERMITE LITERAL1
237+
INTERP1_SPLINE LITERAL1
238+
INTERP1_CONSTRAINED_SPLINE LITERAL1
228239
CRC8 LITERAL1
229240
CRC16 LITERAL1
230241
CRC32 LITERAL1

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"maintainer": true
1717
}
1818
],
19-
"version": "1.0.7",
19+
"version": "1.0.8",
2020
"license": "MIT",
2121
"frameworks": "arduino",
2222
"platforms": "*"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=qlibs
2-
version=1.0.7
2+
version=1.0.8
33
license=MIT
44
author=J. Camilo Gomez C. <[email protected]>
55
maintainer=J. Camilo Gomez C. <[email protected]>

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ target_sources( ${PROJECT_NAME} INTERFACE
2121
"${CMAKE_CURRENT_LIST_DIR}/bitfield.cpp"
2222
"${CMAKE_CURRENT_LIST_DIR}/generic.cpp"
2323
"${CMAKE_CURRENT_LIST_DIR}/ffmath.cpp"
24+
"${CMAKE_CURRENT_LIST_DIR}/interp1.cpp"
2425
)
2526

2627
target_compile_options( ${PROJECT_NAME} INTERFACE

src/fis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ bool fis::instance::setupOutput( const fis::tag t,
145145
/*cstat -CERT-STR34-C*/
146146
xOutput[ t ].min = Min;
147147
xOutput[ t ].max = Max;
148+
/*cstat -CERT-FLP36-C*/
148149
xOutput[ t ].res = ( xOutput[ t ].max - xOutput[ t ].min )/static_cast<real_t>( nPoints );
149-
/*cstat +CERT-STR34-C*/
150+
/*cstat +CERT-STR34-C +CERT-FLP36-C*/
150151
retVal = true;
151152
}
152153

0 commit comments

Comments
 (0)