Skip to content

Commit d6d2e8a

Browse files
author
camilo
committed
SA Fixes
1 parent a579d62 commit d6d2e8a

File tree

8 files changed

+24
-31
lines changed

8 files changed

+24
-31
lines changed
File renamed without changes.

check/qlibs_cpp_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <iostream>
22
#include <qlibs.h>
33
#include <cmath>
4-
#include <include/mat.hpp>
4+
//#include <include/mat.hpp>
55

66
using namespace std;
77
using namespace qlibs;
@@ -417,7 +417,7 @@ void test_ffmath(void)
417417
std::cout << ffmath::copysign( ffmath::getNan(), -2.0f ) << std::endl;
418418
std::cout << ffmath::copysign( ffmath::getInf(), -2.0f ) << std::endl;
419419
}
420-
420+
/*
421421
void test_mat( void )
422422
{
423423
cout<<"MAT TEST"<<endl;
@@ -449,7 +449,7 @@ void test_mat( void )
449449
(x*ix).display();
450450
451451
}
452-
452+
*/
453453
void test_interp1( void )
454454
{
455455
real_t tx[] = { 1.0f, 2.0f, 3.0f, 4.0f };
@@ -594,7 +594,7 @@ int main()
594594
test_fp16();
595595
test_tdl();
596596

597-
test_mat();
597+
//test_mat();
598598
test_interp1();
599599
test_fis();
600600
test_fis2();

check/sa_check.ewp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,9 +2228,6 @@
22282228
<file>
22292229
<name>$PROJ_DIR$\..\src\include\ltisys.hpp</name>
22302230
</file>
2231-
<file>
2232-
<name>$PROJ_DIR$\..\src\include\mat.hpp</name>
2233-
</file>
22342231
<file>
22352232
<name>$PROJ_DIR$\..\src\include\numa.hpp</name>
22362233
</file>

check/sa_check.ewt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,9 +2958,6 @@
29582958
<file>
29592959
<name>$PROJ_DIR$\..\src\include\ltisys.hpp</name>
29602960
</file>
2961-
<file>
2962-
<name>$PROJ_DIR$\..\src\include\mat.hpp</name>
2963-
</file>
29642961
<file>
29652962
<name>$PROJ_DIR$\..\src\include\numa.hpp</name>
29662963
</file>

src/include/ltisys.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,12 @@ namespace qlibs {
247247
return delay( xInput );
248248
}
249249

250-
constexpr size_t getNumberOfDelays() const noexcept {
250+
/**
251+
* @brief Returns the number of delay steps configured for this instance.
252+
*
253+
* @return The number of delays (equal to the template parameter).
254+
*/
255+
size_t getNumberOfDelays() const noexcept {
251256
return numberOfDelays;
252257
}
253258
};

src/include/tdl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ namespace qlibs {
3737
real_t *rd{ nullptr };
3838
real_t *wr{ nullptr };
3939
size_t itemCount{ 0U };
40-
const real_t undefined{ 0.0_re/0.0_re }; // skipcq: CXX-W2010
4140

4241
void insertNewest( const real_t sample ) noexcept;
4342
void removeOldest( void ) noexcept;
@@ -131,7 +130,7 @@ namespace qlibs {
131130
* @param[in] index The requested delay index
132131
* @return The requested value from the TDL
133132
*/
134-
const real_t& operator[]( int index ) noexcept;
133+
real_t operator[]( int index ) noexcept;
135134

136135
/**
137136
* @brief Insert a new sample to the TDL removing the oldest sample

src/ltisys.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ bool smithPredictor::updatePrediction( const real_t ut,
284284
const real_t yt_hat = modelDelay->delay( yt_hat_d );
285285
const real_t ep_hat = yt - yt_hat;
286286

287-
yp_hat = yt_hat_d + ( filter ? filter->excite( ep_hat ) : ep_hat );
287+
yp_hat = yt_hat_d + ( ( nullptr != filter ) ? filter->excite( ep_hat ) : ep_hat );
288288
return true;
289289
}
290290
/*============================================================================*/

src/tdl.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ real_t tdl::getRecent( void ) const noexcept
5353
/*============================================================================*/
5454
real_t tdl::getAtIndex( const size_t i ) const noexcept
5555
{
56+
size_t j = i;
57+
58+
if ( j >= itemCount ) {
59+
j = itemCount - 1U;
60+
}
5661
/*cstat -MISRAC++2008-5-0-3*/
57-
return ( ( wr >= rd ) && ( ( head + i ) >= wr ) ) ? rd[ itemCount - i ]
58-
: *( rd - i );
62+
return ( ( wr >= rd ) && ( ( head + j ) >= wr ) ) ? rd[ itemCount - j ]
63+
: *( rd - j );
5964
/*cstat +MISRAC++2008-5-0-3*/
6065
}
6166
/*============================================================================*/
@@ -65,23 +70,13 @@ void tdl::insertSample( const real_t sample ) noexcept
6570
insertNewest( sample );
6671
}
6772
/*============================================================================*/
68-
const real_t& tdl::operator[]( int index ) noexcept
73+
real_t tdl::operator[]( int index ) noexcept
6974
{
70-
const size_t i = static_cast<size_t>( index );
71-
/*cstat -MISRAC++2008-6-6-5*/
72-
if ( ( index >= 0 ) && ( i < itemCount ) ) {
73-
/*cstat -MISRAC++2008-5-0-3*/
74-
return ( ( wr >= rd ) && ( ( head + i ) >= wr ) ) ? rd[ itemCount - i ]
75-
: *( rd - i );
76-
/*cstat +MISRAC++2008-5-0-3*/
77-
}
78-
else if ( -1 == index ) {
79-
return ( ( rd + 1U ) >= tail ) ? head[ 0 ] : rd[ 1 ];
75+
if ( index < 0 ) {
76+
index = -index;
8077
}
81-
else {
82-
return undefined;
83-
}
84-
/*cstat +MISRAC++2008-6-6-5*/
78+
79+
return getAtIndex( static_cast<size_t>( index ) );
8580
}
8681
/*============================================================================*/
8782
/*! @endcond */

0 commit comments

Comments
 (0)