Commit 21134e48 authored by Manuel Jander's avatar Manuel Jander
Browse files

Remove unnecessary set16_fx() and add logging code for later reference for...

Remove unnecessary set16_fx() and add logging code for later reference for objective precision asessment.
parent 8b1739b3
Loading
Loading
Loading
Loading
Loading
+95 −5
Original line number Diff line number Diff line
@@ -297,6 +297,42 @@ void svdMat2mat_fx(
    return;
}

#ifdef MORE_DEBUG2
static void matrixFx2Fl2(
    float r[][MAX_OUTPUT_CHANNELS],
    const Word32 a[][MAX_OUTPUT_CHANNELS],
    const Word16 a_e[][MAX_OUTPUT_CHANNELS],
    const int adim1,
    const int adim2 )
{
    for ( int i1 = 0; i1 < adim1; i1++ )
    {
        for ( int i2 = 0; i2 < adim2; i2++ )
        {
            r[i1][i2] = (float) a[i1][i2] * powf( 2.f, a_e[i1][i2] - 31 );
        }
    }
}

static void matrixPrint2(
    const float a[][MAX_OUTPUT_CHANNELS],
    const int dim1,
    const int dim2,
    const char *name )
{
    printf( "Matrix %s[%d][%d] = \n", name, dim1, dim2 );
    for ( int i1 = 0; i1 < dim1; i1++ )
    {
        printf( " { " );
        for ( int i2 = 0; i2 < dim2; i2++ )
        {
            printf( "%.10e, ", a[i1][i2] );
        }
        printf( " },\n" );
    }
}
#endif

#ifndef DEBUG_SVD_TEST
// #define DEBUG_SVD_PRECISION
#endif
@@ -417,7 +453,7 @@ static void matrixPrint(
    {
        for ( int i2 = 0; i2 < dim2; i2++ )
        {
            printf( "%f, ", a[i1][i2] );
            printf( "%.10e, ", a[i1][i2] );
        }
        printf( "\n" );
    }
@@ -479,7 +515,7 @@ static void svd_accuracy_test_fx(
        singularValuesFx2_e[x] = InputMatrixFx_e;
    matrixFx2Fl( InputMatrix, InputMatrixFx, singularValuesFx2_e, nChannelsL, nChannelsC );
    dimSingular = min( nChannelsL, nChannelsC );
    matrixFx2Fl( singularValues, singularValuesFx, singularValuesFx_e, 1, nChannelsC );
    matrixFx2Fl( &singularValues, (Word32(*)[MAX_MATRIX])singularValuesFx, singularValuesFx_e, 1, nChannelsC );
    for ( int x = 0; x < MAX_MATRIX; x++ )
        singularValuesFx2_e[x] = 0;
    matrixFx2Fl( singularVectors_Left, singularVectors_LeftFx, singularValuesFx2_e, nChannelsL, nChannelsC );
@@ -579,9 +615,25 @@ Word16 svd_fx(
    Word16 temp_fx_e;
    push_wmops( "svd_fx" );

#if 1
#ifdef MORE_DEBUG2
{
    float input[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
    Word16 exp_matrix[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];

    for (int ii=0; ii<MAX_OUTPUT_CHANNELS; ii++)
        for (int iii=0; iii<MAX_OUTPUT_CHANNELS; iii++)
            exp_matrix[ii][iii] = InputMatrix_e;

    matrixFx2Fl2(input, InputMatrix, exp_matrix, nChannelsL, nChannelsC);
    matrixPrint2(input, nChannelsL, nChannelsC, "  input  ");
}
#endif

#ifndef FIX_1010_OPT_SINGLE_RESCALE
    set32_fx( secDiag_fx, 0, MAX_OUTPUT_CHANNELS );
    set16_fx( secDiag_fx_e, 0, MAX_OUTPUT_CHANNELS );

    set16_fx( singularValues_fx_e, 0, MAX_OUTPUT_CHANNELS );
#endif

    /* Collecting Values */
@@ -594,8 +646,6 @@ Word16 svd_fx(
        }
    }

    set16_fx( singularValues_fx_e, 0, MAX_OUTPUT_CHANNELS );

    /* Householder reduction */
#ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE
    HouseholderReduction_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, InputMatrix_e, singularValues_fx_e, &secDiag_fx_e, nChannelsL, nChannelsC, &eps_x_fx, &eps_x_fx_e );
@@ -1273,6 +1323,18 @@ static void HouseholderReduction_fx(
        }
    }

#ifdef MORE_DEBUG2
{
    float singularVectors_Left[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
    float secDiag[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];

    matrixFx2Fl2(singularVectors_Left, singularVectors_Left_fx, singularVectors_Left_fx_e, nChannelsL, nChannelsC);
    matrixFx2Fl2(secDiag, (Word32(*)[MAX_OUTPUT_CHANNELS])secDiag_fx, (Word16(*)[MAX_OUTPUT_CHANNELS])secDiag_fx_e, 1, nChannelsC);
    matrixPrint2(singularVectors_Left, nChannelsL, nChannelsC, "left");
    matrixPrint2(secDiag, 1, nChannelsC, "secDiag");
}
#endif

    /* SingularVecotr Accumulation */
#ifndef FIX_1010_OPT_SINGLE_RESCALE
    singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_e, *secDiag_fx_e, nChannelsC );
@@ -1283,9 +1345,37 @@ static void HouseholderReduction_fx(
#else
    singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_fx_e, secDiag_fx_e, nChannelsC );
#endif

#ifdef MORE_DEBUG2
{
    float singularVectors_Right[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
    Word16 singularVectors_Left_fx_e[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];

    for (int ii=0; ii<MAX_OUTPUT_CHANNELS; ii++)
        for (int iii=0; iii<MAX_OUTPUT_CHANNELS; iii++)
            singularVectors_Left_fx_e[ii][iii] = 0;

    matrixFx2Fl2(singularVectors_Right, singularVectors_Right_fx, singularVectors_Left_fx_e, nChannelsC, nChannelsC);
    matrixPrint2(singularVectors_Right, nChannelsC, nChannelsC, "right2");
}
#endif

    singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_fx_e, singularValues_fx_e, nChannelsL, nChannelsC );
#endif

#ifdef MORE_DEBUG2
{
    float singularVectors_Left[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
    Word16 singularVectors_Left_fx_e[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS];

    for (int ii=0; ii<MAX_OUTPUT_CHANNELS; ii++)
        for (int iii=0; iii<MAX_OUTPUT_CHANNELS; iii++)
            singularVectors_Left_fx_e[ii][iii] = 0;

    matrixFx2Fl2(singularVectors_Left, singularVectors_Left_fx, singularVectors_Left_fx_e, nChannelsL, nChannelsC);
    matrixPrint2(singularVectors_Left, nChannelsL, nChannelsC, "left2");
}
#endif
    return;
}