Skip to content

Commit

Permalink
added interp1 class. bump to 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
camilo committed Jan 15, 2024
1 parent 297ceda commit 9546f1d
Show file tree
Hide file tree
Showing 13 changed files with 802 additions and 16 deletions.
19 changes: 19 additions & 0 deletions check/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,24 @@
using namespace qlibs;

int main() {

mat<2,2> x(
1.0f, 2.0f,
3.0f, 4.0f
);
mat<2,1> y(
1.0f,
3.0f
);
mat<2,1> z(
2.0f,
2.0f
);

mat<2,1> result = 4.5 - z - 2.0f*x*y - 3;
x*=x;
result.display();
x.display();

return 0;
}
107 changes: 106 additions & 1 deletion check/qlibs_cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ void test_fp16( void );
void test_crc( void );
void test_ltisys( void );
void test_ffmath( void );

void test_mat( void );
void test_interp1( void );

void test_fis3( void )
{
Expand Down Expand Up @@ -304,6 +305,108 @@ void test_ffmath(void)
cout << ffmath::getInf() << endl;
}

void test_mat( void )
{
cout<<"MAT TEST"<<endl;
mat<2,2> x(
1.0f, 2.0f,
3.0f, 4.0f
);
mat<2,1> y(
1.0f,
3.0f
);
mat<2,1> z(
2.0f,
2.0f
);

mat<2,1> result = 4.5 - z - 2.0f*x*y - 3;
mat<4,4> I( MAT_IDENTITY );
x*=x;
result.display();
x.display();
cout<< x(2) << endl;
auto j = !y;
j.display();
I.display();
auto ix = x.inv();
x.display();
ix.display();
(x*ix).display();

}

void test_interp1( void )
{
real_t tx[] = { 1.0f, 2.0f, 3.0f, 4.0f };
real_t ty[] = { 5.0f, 9.0f, 12.0f, 15.0f };
interp1 interpolation( tx, ty );

cout << "linear" << endl;
interpolation.setMethod( INTERP1_LINEAR );
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "sine" << endl;
interpolation.setMethod( INTERP1_SINE );
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "cubic" << endl;
interpolation.setMethod( INTERP1_CUBIC );
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "hermite" << endl;
interpolation.setMethod( INTERP1_HERMITE );
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "nearest" << endl;
interpolation.setMethod( INTERP1_NEAREST);
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "next" << endl;
interpolation.setMethod( INTERP1_NEXT);
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "previous" << endl;
interpolation.setMethod( INTERP1_PREVIOUS);
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "spline" << endl;
interpolation.setMethod( INTERP1_SPLINE);
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;

cout << "cspline" << endl;
interpolation.setMethod( INTERP1_CONSTRAINED_SPLINE);
cout << interpolation.get( 2.5 ) << endl;
cout << interpolation.get( 3.1 ) << endl;
cout << interpolation.get( 0.5 ) << endl;
cout << interpolation.get( 5.0 ) << endl;
}

int main()
{
test_crc();
Expand All @@ -314,5 +417,7 @@ int main()
test_fis2();
test_fis3();
test_ffmath();
test_mat();
test_interp1();
return 0;
}
9 changes: 9 additions & 0 deletions check/sa_check.ewp
Original file line number Diff line number Diff line change
Expand Up @@ -2164,9 +2164,15 @@
<file>
<name>$PROJ_DIR$\..\src\include\generic.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\interp1.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\ltisys.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\mat.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\mathex.hpp</name>
</file>
Expand Down Expand Up @@ -2210,6 +2216,9 @@
<file>
<name>$PROJ_DIR$\..\src\generic.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\interp1.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\ltisys.cpp</name>
</file>
Expand Down
9 changes: 9 additions & 0 deletions check/sa_check.ewt
Original file line number Diff line number Diff line change
Expand Up @@ -2868,9 +2868,15 @@
<file>
<name>$PROJ_DIR$\..\src\include\generic.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\interp1.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\ltisys.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\mat.hpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\include\mathex.hpp</name>
</file>
Expand Down Expand Up @@ -2914,6 +2920,9 @@
<file>
<name>$PROJ_DIR$\..\src\generic.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\interp1.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\ltisys.cpp</name>
</file>
Expand Down
13 changes: 12 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Datatypes(KEYWORD1)
#######################################

interp1 KEYWORD1
interp1Method KEYWORD1
real_t KEYWORD1
bitfield KEYWORD1
crc KEYWORD1
Expand Down Expand Up @@ -65,6 +67,7 @@ tdl KEYWORD1
# Methods and Functions(KEYWORD2)
#######################################

setMethod KEYWORD2
bitfield_size KEYWORD2
setup KEYWORD2
clearAll KEYWORD2
Expand Down Expand Up @@ -224,7 +227,15 @@ insertSample KEYWORD2

#######################################
# Constants(LITERAL1)

INTERP1_NEXT LITERAL1
INTERP1_PREVIOUS LITERAL1
INTERP1_NEAREST LITERAL1
INTERP1_LINEAR LITERAL1
INTERP1_SINE LITERAL1
INTERP1_CUBIC LITERAL1
INTERP1_HERMITE LITERAL1
INTERP1_SPLINE LITERAL1
INTERP1_CONSTRAINED_SPLINE LITERAL1
CRC8 LITERAL1
CRC16 LITERAL1
CRC32 LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"maintainer": true
}
],
"version": "1.0.7",
"version": "1.0.8",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=qlibs
version=1.0.7
version=1.0.8
license=MIT
author=J. Camilo Gomez C. <[email protected]>
maintainer=J. Camilo Gomez C. <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ target_sources( ${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/bitfield.cpp"
"${CMAKE_CURRENT_LIST_DIR}/generic.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ffmath.cpp"
"${CMAKE_CURRENT_LIST_DIR}/interp1.cpp"
)

target_compile_options( ${PROJECT_NAME} INTERFACE
Expand Down
3 changes: 2 additions & 1 deletion src/fis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ bool fis::instance::setupOutput( const fis::tag t,
/*cstat -CERT-STR34-C*/
xOutput[ t ].min = Min;
xOutput[ t ].max = Max;
/*cstat -CERT-FLP36-C*/
xOutput[ t ].res = ( xOutput[ t ].max - xOutput[ t ].min )/static_cast<real_t>( nPoints );
/*cstat +CERT-STR34-C*/
/*cstat +CERT-STR34-C +CERT-FLP36-C*/
retVal = true;
}

Expand Down
Loading

0 comments on commit 9546f1d

Please sign in to comment.