diff options
author | JanHenrik <janhenrik@janhenrik.org> | 2020-04-01 00:40:03 +0200 |
---|---|---|
committer | JanHenrik <janhenrik@janhenrik.org> | 2020-04-01 00:40:03 +0200 |
commit | f7de54fc6fa6b40dfa2dfbe4c2a8ee933affa126 (patch) | |
tree | 78465e38a01011dc9f17eb73416011310532017f /cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions | |
parent | 3ec13d81e70e52246545c720abe756ccf09fb231 (diff) | |
download | minikbd-f7de54fc6fa6b40dfa2dfbe4c2a8ee933affa126.tar.gz minikbd-f7de54fc6fa6b40dfa2dfbe4c2a8ee933affa126.tar.bz2 minikbd-f7de54fc6fa6b40dfa2dfbe4c2a8ee933affa126.zip |
added files
Diffstat (limited to 'cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions')
-rw-r--r-- | cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/mat_helper.c | 193 | ||||
-rw-r--r-- | cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/ref_helper.c | 103 |
2 files changed, 296 insertions, 0 deletions
diff --git a/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/mat_helper.c b/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/mat_helper.c new file mode 100644 index 0000000..0174ccf --- /dev/null +++ b/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/mat_helper.c @@ -0,0 +1,193 @@ +#include "ref.h"
+
+float32_t ref_detrm(float32_t *pSrc, float32_t *temp, uint32_t size)
+{
+ float32_t s = 1, det = 0;
+ int i, j, m, n, c;
+
+ if ( size == 1 )
+ {
+ return ( pSrc[ 0 ] );
+ }
+ else
+ {
+ det = 0;
+
+ for ( c = 0;c < size;c++ )
+ {
+ m = 0;
+ n = 0;
+
+ for ( i = 0;i < size;i++ )
+ {
+ for ( j = 0;j < size;j++ )
+ {
+ temp[ i*size + j ] = 0;
+
+ if ( i != 0 && j != c )
+ {
+ temp[ m*(size-1) + n ] = pSrc[ i*size + j ];
+
+ if ( n < ( size - 2 ) )
+ {
+ n++;
+ }
+ else
+ {
+ n = 0;
+ m++;
+ }
+ }
+ }
+ }
+
+ det += s * ( pSrc[ c ] * ref_detrm( temp, temp + size*size, size - 1 ) );
+ s = -s;
+ }
+ }
+
+ return ( det );
+}
+
+
+void ref_cofact(float32_t *pSrc, float32_t *pDst, float32_t *temp, uint32_t size)
+{
+ int p, q, m, n, i, j;
+
+ if (size == 1)
+ {
+ pDst[0] = 1;
+ return;
+ }
+
+ for ( q = 0;q < size;q++ )
+ {
+ for ( p = 0;p < size;p++ )
+ {
+ m = 0;
+ n = 0;
+
+ for ( i = 0;i < size;i++ )
+ {
+ for ( j = 0;j < size;j++ )
+ {
+ temp[ i*size + j ] = 0;
+
+ if ( i != q && j != p )
+ {
+ temp[ m*(size-1) + n ] = pSrc[ i*size + j ];
+
+ if ( n < ( size - 2 ) )
+ {
+ n++;
+ }
+ else
+ {
+ n = 0;
+ m++;
+ }
+ }
+ }
+ }
+
+ pDst[ q*size + p ] = ref_pow( -1, q + p ) * ref_detrm( temp, temp + (size-1)*(size-1), size - 1 );
+ }
+ }
+}
+
+
+
+float64_t ref_detrm64(float64_t *pSrc, float64_t *temp, uint32_t size)
+{
+ float64_t s = 1, det = 0;
+ int i, j, m, n, c;
+
+ if ( size == 1 )
+ {
+ return ( pSrc[ 0 ] );
+ }
+ else
+ {
+ det = 0;
+
+ for ( c = 0;c < size;c++ )
+ {
+ m = 0;
+ n = 0;
+
+ for ( i = 0;i < size;i++ )
+ {
+ for ( j = 0;j < size;j++ )
+ {
+ temp[ i*size + j ] = 0;
+
+ if ( i != 0 && j != c )
+ {
+ temp[ m*(size-1) + n ] = pSrc[ i*size + j ];
+
+ if ( n < ( size - 2 ) )
+ {
+ n++;
+ }
+ else
+ {
+ n = 0;
+ m++;
+ }
+ }
+ }
+ }
+
+ det += s * ( pSrc[ c ] * ref_detrm64( temp, temp + size*size, size - 1 ) );
+ s = -s;
+ }
+ }
+
+ return ( det );
+}
+
+
+void ref_cofact64(float64_t *pSrc, float64_t *pDst, float64_t *temp, uint32_t size)
+{
+ int p, q, m, n, i, j;
+
+ if (size == 1)
+ {
+ pDst[0] = 1;
+ return;
+ }
+
+ for ( q = 0;q < size;q++ )
+ {
+ for ( p = 0;p < size;p++ )
+ {
+ m = 0;
+ n = 0;
+
+ for ( i = 0;i < size;i++ )
+ {
+ for ( j = 0;j < size;j++ )
+ {
+ temp[ i*size + j ] = 0;
+
+ if ( i != q && j != p )
+ {
+ temp[ m*(size-1) + n ] = pSrc[ i*size + j ];
+
+ if ( n < ( size - 2 ) )
+ {
+ n++;
+ }
+ else
+ {
+ n = 0;
+ m++;
+ }
+ }
+ }
+ }
+
+ pDst[ q*size + p ] = ref_pow( -1, q + p ) * ref_detrm64( temp, temp + (size-1)*(size-1), size - 1 );
+ }
+ }
+}
diff --git a/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/ref_helper.c b/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/ref_helper.c new file mode 100644 index 0000000..57ecf1b --- /dev/null +++ b/cdc-dials/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/RefLibs/src/HelperFunctions/ref_helper.c @@ -0,0 +1,103 @@ +#include "ref.h"
+
+float32_t scratchArray[8192*2];
+
+arm_cfft_instance_f32 ref_cfft_sR_f32_len8192 = { 8192, 0, 0, 0 };
+
+q31_t ref_sat_n(q31_t num, uint32_t bits)
+{
+ int32_t posMax, negMin;
+ uint32_t i;
+
+ posMax = 1;
+ for (i = 0; i < (bits - 1); i++)
+ {
+ posMax = posMax * 2;
+ }
+
+ if (num > 0)
+ {
+ posMax = (posMax - 1);
+
+ if (num > posMax)
+ {
+ num = posMax;
+ }
+ }
+ else
+ {
+ negMin = -posMax;
+
+ if (num < negMin)
+ {
+ num = negMin;
+ }
+ }
+ return (num);
+}
+
+q31_t ref_sat_q31(q63_t num)
+{
+ if (num > (q63_t)INT_MAX)
+ {
+ return INT_MAX;
+ }
+ else if (num < (q63_t)0xffffffff80000000ll)
+ {
+ return INT_MIN;
+ }
+ else
+ {
+ return (q31_t)num;
+ }
+}
+
+q15_t ref_sat_q15(q31_t num)
+{
+ if (num > (q31_t)SHRT_MAX)
+ {
+ return SHRT_MAX;
+ }
+ else if (num < (q31_t)0xffff8000)
+ {
+ return SHRT_MIN;
+ }
+ else
+ {
+ return (q15_t)num;
+ }
+}
+
+q7_t ref_sat_q7(q15_t num)
+{
+ if (num > (q15_t)SCHAR_MAX)
+ {
+ return SCHAR_MAX;
+ }
+ else if (num < (q15_t)0xff80)
+ {
+ return SCHAR_MIN;
+ }
+ else
+ {
+ return (q7_t)num;
+ }
+}
+
+float32_t ref_pow(float32_t a, uint32_t b)
+{
+ uint32_t i;
+ float32_t r = a;
+
+ for(i=1;i<b;i++)
+ {
+ r *= a;
+ }
+
+ if ( b == 0)
+ {
+ return 1;
+ }
+
+ return r;
+}
|