Commit ae31c412 authored by thomas dettbarn's avatar thomas dettbarn
Browse files

added a new define NONBE_SVD_OPTIMIZATION to encapsulate changes in ivas_svd_dec.c

parent fb373c80
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -143,9 +143,11 @@

/* ################### Start FIXES switches ########################### */


/* #################### End FIXES switches ############################ */

/* ################### Start NONBE switches ########################### */
#define	NONBE_SVD_OPTIMIZATION
/* #################### End NONBE switches ############################ */

/* clang-format on */

+27 −34
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
   the United Nations Convention on Contracts on the International Sales of Goods.

*******************************************************************************************************/
#define	MYCHANGES

#include <stdint.h>
#include "options.h"
@@ -59,13 +58,14 @@
 *-----------------------------------------------------------------------*/

static float GivensRotation( const float x, const float z );
#ifdef MYCHANGES
static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float sig_x, float g );
#ifdef NONBE_SVD_OPTIMIZATION
static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float g );
static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *g );
#else
static void biDiagonalReductionLeft( float singularVectors[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g );
static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g );
#endif

static void biDiagonalReductionRight( float singularVectors[][MAX_OUTPUT_CHANNELS], float secDiag[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC, const int16_t currChannel, float *sig_x, float *g );

static void singularVectorsAccumulationLeft( float singularVectors_Left[][MAX_OUTPUT_CHANNELS], float singularValues[MAX_OUTPUT_CHANNELS], const int16_t nChannelsL, const int16_t nChannelsC );

@@ -492,17 +492,23 @@ static void HouseholderReduction(
    float *eps_x )
{
    int16_t nCh;
    float g = 0.0f, sig_x = 0.0f;
    float g = 0.0f;
#ifdef	NONBE_SVD_OPTIMIZATION

#else
    float sig_x = 0.0f;
#endif

    /* Bidiagonal Reduction for every channel */
    for ( nCh = 0; nCh < nChannelsC; nCh++ ) /* nChannelsC */
    {
#ifdef	MYCHANGES
        biDiagonalReductionLeft( singularVectors_Left, singularValues, secDiag, nChannelsL, nChannelsC, nCh, sig_x, g );
#ifdef	NONBE_SVD_OPTIMIZATION
        biDiagonalReductionLeft( singularVectors_Left, singularValues, secDiag, nChannelsL, nChannelsC, nCh, g );
        biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &g );
#else
        biDiagonalReductionLeft( singularVectors_Left, singularValues, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g );
#endif
        biDiagonalReductionRight( singularVectors_Left, secDiag, nChannelsL, nChannelsC, nCh, &sig_x, &g );
#endif
        *eps_x = max( *eps_x, ( fabsf( singularValues[nCh] ) + fabsf( secDiag[nCh] ) ) );
    }

@@ -520,7 +526,7 @@ static void HouseholderReduction(
 *
 *-------------------------------------------------------------------------*/

#ifdef	MYCHANGES
#ifdef	NONBE_SVD_OPTIMIZATION
static void biDiagonalReductionLeft(
    float singularVectors[][MAX_OUTPUT_CHANNELS],
    float singularValues[MAX_OUTPUT_CHANNELS],
@@ -528,25 +534,17 @@ static void biDiagonalReductionLeft(
    const int16_t nChannelsL,
    const int16_t nChannelsC,
    const int16_t currChannel,
    float sig_x,
    float g )
{
    int16_t iCh, jCh;
    float norm_x, f, r;

    secDiag[currChannel] = ( sig_x ) * ( g );
    secDiag[currChannel] = g;

    /* Setting values to 0 */
    sig_x = 0.0f;
    g = 0.0f;

    if ( currChannel < nChannelsL ) /* i <= m */
    {
        for ( jCh = currChannel; jCh < nChannelsL; jCh++ ) /* nChannelsL */
        {
            sig_x += fabsf( singularVectors[jCh][currChannel] );
        }
        if ( ( sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
    {
        norm_x = 0.0f;

@@ -555,6 +553,8 @@ static void biDiagonalReductionLeft(
        {
            norm_x += ( singularVectors[jCh][currChannel] * singularVectors[jCh][currChannel] );
        }
        if ( ( norm_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
            g = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = g * singularVectors[currChannel][currChannel] - norm_x;
            singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - g );
@@ -662,40 +662,34 @@ static void biDiagonalReductionLeft(
 *
 *
 *-------------------------------------------------------------------------*/
#ifdef	MYCHANGES
#ifdef	NONBE_SVD_OPTIMIZATION
static void biDiagonalReductionRight(
    float singularVectors[][MAX_OUTPUT_CHANNELS],
    float secDiag[MAX_OUTPUT_CHANNELS],
    const int16_t nChannelsL,
    const int16_t nChannelsC,
    const int16_t currChannel,
    float *sig_x,
    float *g )
{
    int16_t iCh, jCh, idx;
    float norm_x, r;

    /* Setting values to 0 */
    ( *sig_x ) = 0.0f;
    ( *g ) = 0.0f;

    if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */
    {
        idx = currChannel + 1;

        for ( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */
        {
            ( *sig_x ) += fabsf( singularVectors[currChannel][jCh] );
        }

        if ( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
        norm_x = 0.0f;

        for ( jCh = idx; jCh < nChannelsC; jCh++ ) /*nChannelsC */
        {
            norm_x += ( singularVectors[currChannel][jCh] * singularVectors[currChannel][jCh] );
        }

        if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
            ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = ( *g ) * singularVectors[currChannel][idx] - norm_x;
            singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) );
@@ -718,7 +712,6 @@ static void biDiagonalReductionRight(
                    singularVectors[iCh][jCh] += ( norm_x * secDiag[jCh] );
                }
            }
            ( *g ) = ( *g ) / maxWithSign( *sig_x );
        }
    }