libflame revision_anchor
Functions
FLASH_QR_UT_inc_create_hier_matrices.c File Reference

(r)

Functions

FLA_Error FLASH_QR_UT_inc_create_hier_matrices (FLA_Obj A_flat, dim_t depth, dim_t *b_flash, dim_t b_alg, FLA_Obj *A, FLA_Obj *TW)
dim_t FLASH_QR_UT_inc_determine_alg_blocksize (FLA_Obj A)

Function Documentation

FLA_Error FLASH_QR_UT_inc_create_hier_matrices ( FLA_Obj  A_flat,
dim_t  depth,
dim_t b_flash,
dim_t  b_alg,
FLA_Obj A,
FLA_Obj TW 
)

References FLA_Abort(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLA_Print_message(), FLASH_Obj_create_ext(), FLASH_Obj_create_hier_copy_of_flat(), and FLASH_QR_UT_inc_determine_alg_blocksize().

{
    FLA_Datatype datatype;
    dim_t        m, n;
    
    // *** The current QR_UT_inc algorithm implemented assumes that
    // the matrix has a hierarchical depth of 1. We check for that here
    // because we anticipate that we'll use a more general algorithm in the
    // future, and we don't want to forget to remove the constraint. ***
    if ( depth != 1 )
    {
       FLA_Print_message( "FLASH_QR_UT_inc() currently only supports matrices of depth 1",
                          __FILE__, __LINE__ );
       FLA_Abort();
    }

    // Create hierarchical copy of matrix A_flat.
    FLASH_Obj_create_hier_copy_of_flat( A_flat, depth, b_flash, A );

    // Query the datatype of matrix A_flat.
    datatype = FLA_Obj_datatype( A_flat );
    
    // If the user passed in zero for b_alg, then we need to set the
    // algorithmic (inner) blocksize to a reasonable default value.
    if ( b_alg == 0 )
    {
        b_alg = FLASH_QR_UT_inc_determine_alg_blocksize( *A );
    }

    // Query the element (not scalar) dimensions of the new hierarchical
    // matrix. This is done so we can create T with full blocks for the
    // bottom and right "edge cases" of A.
    m = FLA_Obj_length( *A );
    n = FLA_Obj_width ( *A );

    // Create hierarchical matrices T and W. T is lower triangular where
    // each block is b_alg-by-b_flash and W is strictly upper triangular
    // where each block is b_alg-by-b_flash. So we can create them
    // simultaneously as part of the same hierarchical matrix.
    FLASH_Obj_create_ext( datatype, m * b_alg, n * b_flash[0], 
                          depth, &b_alg, b_flash, 
                          TW );
       
    return FLA_SUCCESS;
}
dim_t FLASH_QR_UT_inc_determine_alg_blocksize ( FLA_Obj  A)

References FLA_Obj_length().

Referenced by FLASH_QR_UT_inc_create_hier_matrices().

{
    dim_t b_alg;
    dim_t b_flash;

    // Acquire the storage blocksize.
    b_flash = FLA_Obj_length( *FLASH_OBJ_PTR_AT( A ) );

    // Scale the storage blocksize by a pre-defined scalar to arrive at a
    // reasonable algorithmic blocksize, but make sure it's at least 1.
    b_alg = ( dim_t ) max( ( double ) b_flash * FLA_QR_INNER_TO_OUTER_B_RATIO, 1 );

    return b_alg;
}