libflame  revision_anchor
Functions
FLA_Bsvd_find_submatrix.c File Reference

(r)

Functions

FLA_Error FLA_Bsvd_find_submatrix_ops (int mn_A, int ij_begin, float *buff_d, int inc_d, float *buff_e, int inc_e, int *ijTL, int *ijBR)
FLA_Error FLA_Bsvd_find_submatrix_opd (int mn_A, int ij_begin, double *buff_d, int inc_d, double *buff_e, int inc_e, int *ijTL, int *ijBR)

Function Documentation

FLA_Error FLA_Bsvd_find_submatrix_opd ( int  mn_A,
int  ij_begin,
double *  buff_d,
int  inc_d,
double *  buff_e,
int  inc_e,
int *  ijTL,
int *  ijBR 
)

References bli_d0().

Referenced by FLA_Bsvd_v_opd_var1(), FLA_Bsvd_v_opd_var2(), FLA_Bsvd_v_opz_var1(), and FLA_Bsvd_v_opz_var2().

{
    double rzero = bli_d0();
    int    ij_tl;
    int    ij_br;

    // Search for the first non-zero superdiagonal element starting at
    // the index specified by ij_begin.
    for ( ij_tl = ij_begin; ij_tl < mn_A - 1; ++ij_tl )
    {
        double* e1 = buff_e + (ij_tl  )*inc_e;

        // If we find a non-zero element, record it and break out of this
        // loop.
        if ( *e1 != rzero )
        {
#ifdef PRINTF
printf( "FLA_Bsvd_find_submatrix_opd: found non-zero superdiagonal element\n" );
printf( "                             e[%3d] = %22.19e\n", ij_tl, *e1 );
#endif
            *ijTL = ij_tl;
            break;
        }
    }

    // If ij_tl was incremented all the way up to mn_A - 1, then we didn't
    // find any non-zeros.
    if ( ij_tl == mn_A - 1 )
    {
#ifdef PRINTF
printf( "FLA_Bsvd_find_submatrix_opd: no submatrices found.\n" );
#endif
        return FLA_FAILURE;
    }

    // If we've gotten this far, then a non-zero superdiagonal element was
    // found. Now we must walk the remaining portion of the superdiagonal
    // to find the first zero element, or if one is not found, we simply
    // use the last element of the superdiagonal.
    for ( ij_br = ij_tl; ij_br < mn_A - 1; ++ij_br )
    {
        double* e1 = buff_e + (ij_br  )*inc_e;

        // If we find a zero element, record it and break out of this
        // loop.
        if ( *e1 == rzero )
        {
#ifdef PRINTF
printf( "FLA_Bsvd_find_submatrix_opd: found zero superdiagonal element\n" );
printf( "                             e[%3d] = %22.19e\n", ij_br, *e1 );
#endif
            break;
        }
    }

    // If a zero element was found, then ij_br should hold the index of
    // that element. If a zero element was not found, then ij_br should
    // hold mn_A - 1. Either way, we save the value and return success.
    *ijBR = ij_br;

    return FLA_SUCCESS;
}
FLA_Error FLA_Bsvd_find_submatrix_ops ( int  mn_A,
int  ij_begin,
float *  buff_d,
int  inc_d,
float *  buff_e,
int  inc_e,
int *  ijTL,
int *  ijBR 
)
{
    FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );

    return FLA_SUCCESS;
}