Commit 93c38c5d authored by thomas dettbarn's avatar thomas dettbarn
Browse files

Brought the code to the same level as the svd_optimization_branch.

parent 6ea437ed
Loading
Loading
Loading
Loading
+34 −33
Original line number Diff line number Diff line
@@ -69,11 +69,11 @@ static void HouseholderReduction_fx(
static void biDiagonalReductionLeft_64(
    Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS],
    Word16 bitwindow,
    Word32 singularValues[MAX_OUTPUT_CHANNELS],    /* exp(singularValues_e) */
    Word16 singularValues_e[MAX_OUTPUT_CHANNELS],
    const Word16 nChannelsL,  /* Q0 */
    const Word16 nChannelsC,  /* Q0 */
    const Word16 currChannel /* Q0 */
    const Word16 currChannel, /* Q0 */
    Word32 *g, /* Q31 */
    Word16 *g_e
);

static void biDiagonalReductionRight_64(
@@ -877,8 +877,12 @@ static void HouseholderReduction_fx(
#ifdef	MYCHANGES

    Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
    Word32 g_fx = 0;
    Word16 g_e = 0;
    Word32 g_left_fx = 0;
    Word16 g_left_e = 0;
    move32();
    move16();
    Word32 g_right_fx = 0;
    Word16 g_right_e = 0;
    move32();
    move16();

@@ -895,7 +899,6 @@ static void HouseholderReduction_fx(
    Word16 iCh, jCh;
    Word16 singularVectors_Left_fx_e[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
#ifdef	 MYCHANGES
	push_wmops("HouseholderReduction_fx 64");
    FOR( jCh = 0; jCh < nChannelsL; jCh++ )
    {
        FOR( iCh = 0; iCh < nChannelsC; iCh++ )
@@ -909,23 +912,26 @@ static void HouseholderReduction_fx(
	    bitwindow=1;
	    biDiagonalReductionLeft_64(
			    singularVectors_Left_64,bitwindow,
			    singularValues_fx,singularValues_fx_e,
			    nChannelsL,
			    nChannelsC,
			    nCh
			    nCh,
                            &g_left_fx,
                            &g_left_e
			    );
	    singularValues_fx_e[nCh]=add(singularVectors_Left_e,singularValues_fx_e[nCh]);
	    secDiag_fx[nCh]=g_fx;
	    singularValues_fx[nCh]=g_left_fx;
            move32();
	    secDiag_fx_e[nCh]=add(singularVectors_Left_e,g_e);
	    singularValues_fx_e[nCh]=add(singularVectors_Left_e,g_left_e);
	    secDiag_fx[nCh]=g_right_fx; /* from the previous channel */
	    move32();
	    secDiag_fx_e[nCh]=add(singularVectors_Left_e,g_right_e);
	    bitwindow=2;
	    biDiagonalReductionRight_64(
			    singularVectors_Left_64,bitwindow,
			    nChannelsL,
			    nChannelsC,
			    nCh,
			    &g_fx,
			    &g_e	
			    &g_right_fx,
			    &g_right_e	
			    );
		{
        		Word16 L_temp_e;
@@ -953,7 +959,6 @@ static void HouseholderReduction_fx(
	    }
        }
    }
	pop_wmops();
#else

    FOR( jCh = 0; jCh < nChannelsL; jCh++ )
@@ -1002,22 +1007,22 @@ static void HouseholderReduction_fx(
static void biDiagonalReductionLeft_64(
    Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS],
    Word16 bitwindow,
    Word32 singularValues[MAX_OUTPUT_CHANNELS],    /* exp(singularValues_e) */
    Word16 singularValues_e[MAX_OUTPUT_CHANNELS],
    const Word16 nChannelsL,  /* Q0 */
    const Word16 nChannelsC,  /* Q0 */
    const Word16 currChannel /* Q0 */
    const Word16 currChannel, /* Q0 */
    Word32 *g,
    Word16 *g_e
)
{



    Word16 iCh, jCh;
    Word32 norm_x, g;
    Word16 norm_x_e, g_e;
    Word32 norm_x;
    Word16 norm_x_e;
    Word64 norm_64;
    g=0;
    g_e=0;
    ( *g )=0;
    ( *g_e) =0;
    move32();
    move16();
    norm_x=0;
@@ -1047,16 +1052,16 @@ static void biDiagonalReductionLeft_64(
        Word32 r, invVal;
        Word16 r_e, invVal_e;

        g_e = norm_x_e;
        ( *g_e ) = norm_x_e;
        move16();
        g = Sqrt32( norm_x, &g_e);
        ( *g ) = Sqrt32( norm_x, g_e);
        IF ( GE_64( singularVectors_Left_64[currChannel][currChannel], 0 ) )
        {
           g = L_negate( g );
           ( *g ) = L_negate( *g );
        }
        factor2 = W_extract_l( W_shr( singularVectors_Left_64[currChannel][currChannel], bitwindow) );
        tmp_e=sub( g_e, bitwindow) ;
        tmpmul=W_mult0_32_32( g, factor2);
        tmp_e=sub( ( *g_e ), bitwindow) ;
        tmpmul=W_mult0_32_32( ( *g ), factor2);
        tmpmul=W_shl(tmpmul, tmp_e);
        r_64=W_sub(tmpmul, norm_64);
        r_e=W_norm(r_64 );
@@ -1068,8 +1073,8 @@ static void biDiagonalReductionLeft_64(
        invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, r, &invVal_e);


        tmp_e = add(31, sub(bitwindow, g_e ) );
        singularVectors_Left_64[currChannel][currChannel] = W_sub( singularVectors_Left_64[currChannel][currChannel], W_shr( W_deposit32_h( g), tmp_e) ); // here, the exponent goes up.
        tmp_e = add(31, sub(bitwindow, *g_e ) );
        singularVectors_Left_64[currChannel][currChannel] = W_sub( singularVectors_Left_64[currChannel][currChannel], W_shr( W_deposit32_h( *g ), tmp_e) ); // here, the exponent goes up.

        bitwindow=add(bitwindow, 1); // so does the bit window
        FOR ( iCh = add( currChannel, 1 ); iCh < nChannelsC; iCh++)
@@ -1098,10 +1103,6 @@ static void biDiagonalReductionLeft_64(
            }
        }
    }
    singularValues[currChannel] = g;
    singularValues_e[currChannel] = g_e;
    move32();
    move16();
}

/*-------------------------------------------------------------------------