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

either the new or the original code can now be selected via define.

parent 2e422bf3
Loading
Loading
Loading
Loading
+29 −56
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
   the United Nations Convention on Contracts on the International Sales of Goods.

*******************************************************************************************************/
#define	MYCHANGES
//#define	MYCHANGES
#include <stdint.h>
#include "options.h"
#include "prot_fx.h"
@@ -85,8 +85,7 @@ static void biDiagonalReductionRight_64(
    Word32 *g, /* Q31 */
    Word16 *g_e
);

#endif
#else
static void biDiagonalReductionLeft_fx(
    Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */
    Word32 singularValues[MAX_OUTPUT_CHANNELS],    /* exp(singularValues_e) */
@@ -114,6 +113,7 @@ static void biDiagonalReductionRight_fx(
    Word16 *sig_x_e,
    Word32 *g /* Q31 */
);            // Q31
#endif

static void singularVectorsAccumulationLeft_fx(
    Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) as Input, Q31 as output */
@@ -855,22 +855,12 @@ static void HouseholderReduction_fx(
    Word16 nCh;
	push_wmops("HouseholderReduction_fx");
#ifdef	MYCHANGES
    Word32 singularValues_fx2[MAX_OUTPUT_CHANNELS];          /* exp(singularValues_fx_e) */
    Word16 singularValues_fx2_e[MAX_OUTPUT_CHANNELS];
    Word32 secDiag_fx2[MAX_OUTPUT_CHANNELS];                 /* exp(secDiag_fx_e) */
    Word16 secDiag_fx2_e[MAX_OUTPUT_CHANNELS];

	Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
    Word32 g_fx = 0;
    Word16 g_e = 0;
    move32();
    move16();
    Word32 sig_x_fx = 0;
    Word16 sig_x_fx_e = 0;
    move32();
    move16();
    Word32 eps_x_fx2=*eps_x_fx;        /* exp(eps_x_fx_e) */
    Word16 eps_x_fx2_e=*eps_x_fx_e;

#else

@@ -884,7 +874,6 @@ static void HouseholderReduction_fx(

    Word16 iCh, jCh;
    Word16 singularVectors_Left_fx_e[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
	printf("\n");
#ifdef	 MYCHANGES
	push_wmops("HouseholderReduction_fx 64");
    FOR( jCh = 0; jCh < nChannelsL; jCh++ )
@@ -900,15 +889,15 @@ static void HouseholderReduction_fx(
	    bitwindow=1;
	    biDiagonalReductionLeft_64(
			    singularVectors_Left_64,bitwindow,
			    singularValues_fx2,singularValues_fx2_e,
			    singularValues_fx,singularValues_fx_e,
			    nChannelsL,
			    nChannelsC,
			    nCh
			    );
	    singularValues_fx2_e[nCh]=add(singularVectors_Left_e,singularValues_fx2_e[nCh]);
	    secDiag_fx2[nCh]=g_fx;
	    singularValues_fx_e[nCh]=add(singularVectors_Left_e,singularValues_fx_e[nCh]);
	    secDiag_fx[nCh]=g_fx;
	    move32();
	    secDiag_fx2_e[nCh]=add(singularVectors_Left_e,g_e);
	    secDiag_fx_e[nCh]=add(singularVectors_Left_e,g_e);
	    bitwindow=2;
	    biDiagonalReductionRight_64(
			    singularVectors_Left_64,bitwindow,
@@ -921,21 +910,31 @@ static void HouseholderReduction_fx(
		{
        		Word16 L_temp_e;
		        Word32 L_temp;
			printf("\nSINGLUAR \x1b[1;36m %08X<%2d  %08X<%2d --> ",singularValues_fx2[nCh],singularValues_fx2_e[nCh], secDiag_fx2[nCh], secDiag_fx2_e[nCh]);
			fflush(stdout);
			L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx2[nCh] ), singularValues_fx2_e[nCh], L_abs( secDiag_fx2[nCh] ), secDiag_fx2_e[nCh], &L_temp_e ); /* exp(L_temp_e) */
			printf("%08X<%2d\x1b[0m\n",L_temp, L_temp_e);
			IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, eps_x_fx2, eps_x_fx2_e ), 1 ) )
			L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), singularValues_fx_e[nCh], L_abs( secDiag_fx[nCh] ), secDiag_fx_e[nCh], &L_temp_e ); /* exp(L_temp_e) */
			IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, *eps_x_fx, *eps_x_fx_e ), 1 ) )
			{
				eps_x_fx2 = L_temp; /* exp(L_temp_e) */
				*eps_x_fx = L_temp; /* exp(L_temp_e) */
				move32();
				eps_x_fx2_e = L_temp_e;
				*eps_x_fx_e = L_temp_e;
				move32();
			}
		}
    }	
    {
        int i,j;
        for (j=0;j<nChannelsC;j++)
        {
            for (i=0;i<nChannelsL;i++)
            {
                Word16 n;
                n=W_norm(singularVectors_Left_64[j][i]);
                singularVectors_Left_fx[j][i]=W_extract_h(W_shl(singularVectors_Left_64[j][i],n));
                singularVectors_Left_fx_e[j][i]=sub(add(32,singularVectors_Left_e),n);
	    }
        }
    }
	pop_wmops();
#endif
#else
	push_wmops("HouseholderReduction_fx 32");
    FOR( jCh = 0; jCh < nChannelsL; jCh++ )
    {
@@ -954,11 +953,6 @@ static void HouseholderReduction_fx(

        Word16 L_temp_e;
        Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), singularValues_fx_e[nCh], L_abs( secDiag_fx[nCh] ), secDiag_fx_e[nCh], &L_temp_e ); /* exp(L_temp_e) */
       		{
			printf("\nSINGLUAR  %08X<%2d  %08X<%2d --> ",singularValues_fx[nCh],singularValues_fx_e[nCh], secDiag_fx[nCh], secDiag_fx_e[nCh]);
			fflush(stdout);
			printf("%08X<%2d\n",L_temp, L_temp_e);
		}
	IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, *eps_x_fx, *eps_x_fx_e ), 1 ) )
        {
            *eps_x_fx = L_temp; /* exp(L_temp_e) */
@@ -967,30 +961,10 @@ static void HouseholderReduction_fx(
            move32();
        }
    }


    pop_wmops();
    {
	    int i,j;
	    for (j=0;j<nChannelsC;j++)
	    {
		    secDiag_fx[j]=secDiag_fx2[j];
		    secDiag_fx_e[j]=secDiag_fx2_e[j];
		    singularValues_fx[j]=singularValues_fx2[j];
		    singularValues_fx_e[j]=singularValues_fx2_e[j];
#endif

		    for (i=0;i<nChannelsL;i++)
		    {
			    Word16 n;
			    n=W_norm(singularVectors_Left_64[j][i]);
			    singularVectors_Left_fx[j][i]=W_extract_h(W_shl(singularVectors_Left_64[j][i],n));
			    singularVectors_Left_fx_e[j][i]=sub(add(32,singularVectors_Left_e),n);
		    }
	    }

	    *eps_x_fx = eps_x_fx2;
	    *eps_x_fx_e = eps_x_fx2_e;
    }

    /* SingularVecotr Accumulation */
    singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_fx_e, secDiag_fx_e, nChannelsC );
@@ -1127,11 +1101,9 @@ static void biDiagonalReductionRight_64(
    Word16 norm_x_e;
    Word64 norm_64;
    Word16 idx;
    Word16 bitwindow0;



    bitwindow0=bitwindow;

    ( *g ) =0;
    ( *g_e ) = 0;
@@ -1222,7 +1194,7 @@ static void biDiagonalReductionRight_64(
        }
    }
}
#endif
#else
static void biDiagonalReductionLeft_fx(
    Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */
    Word32 singularValues[MAX_OUTPUT_CHANNELS],    /* exp(singularValues_e) */
@@ -1475,6 +1447,7 @@ static void biDiagonalReductionRight_fx(

    return;
}
#endif

/*-------------------------------------------------------------------------
 * singularVectorsAccumulationLeft()