libflame  12600
Functions
FLASH_Random_spd_matrix.c File Reference

(r12600)

Functions

FLA_Error FLASH_Random_spd_matrix (FLA_Uplo uplo, FLA_Obj H)

Function Documentation

References FLA_Check_error_level(), FLA_Check_valid_uplo(), FLA_Obj_has_zero_dim(), FLA_Random_spd_matrix(), FLASH_Obj_create_flat_copy_of_hier(), FLASH_Obj_free(), and FLASH_Obj_hierarchify().

{
    FLA_Obj   F;
    FLA_Error e_val;

    if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    {
        e_val = FLA_Check_valid_uplo( uplo );
        FLA_Check_error_code( e_val );
    }

    // Exit early if one dimension is zero.
    if ( FLA_Obj_has_zero_dim( H ) ) return FLA_SUCCESS;

    // Create a temporary flat copy of the hierarchical object.
    FLASH_Obj_create_flat_copy_of_hier( H, &F );

    // Randomize the flat matrix object to be SPD.
    FLA_Random_spd_matrix( uplo, F );

    // Copy the flat object's contents back to the hierarchical object.
    FLASH_Obj_hierarchify( F, H );

    // Free the temporary flat object.
    FLASH_Obj_free( &F );

    return FLA_SUCCESS;
}