|
libflame
revision_anchor
|
Go to the source code of this file.
Functions | |
| FLA_Error | FLASH_QR_UT_inc (FLA_Obj A, FLA_Obj TW) |
| FLA_Error | FLASH_QR_UT_inc_noopt (FLA_Obj A, FLA_Obj TW) |
| FLA_Error | FLASH_QR_UT_inc_opt1 (FLA_Obj A, FLA_Obj TW) |
| FLA_Error | FLA_QR_UT_inc_blk_var1 (FLA_Obj A, FLA_Obj TW, fla_qrutinc_t *cntl) |
| FLA_Error | FLA_QR_UT_inc_blk_var2 (FLA_Obj A, FLA_Obj TW, FLA_Obj U, fla_qrutinc_t *cntl) |
| 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) |
| FLA_Error | FLASH_QR_UT_inc_solve (FLA_Obj A, FLA_Obj TW, FLA_Obj B, FLA_Obj X) |
| FLA_Error FLA_QR_UT_inc_blk_var1 | ( | FLA_Obj | A, |
| FLA_Obj | TW, | ||
| fla_qrutinc_t * | cntl | ||
| ) |
References FLA_Apply_Q2_UT_internal(), FLA_Apply_Q_UT_internal(), FLA_Cont_with_3x3_to_2x2(), FLA_Determine_blocksize(), FLA_Obj_min_dim(), FLA_Obj_width(), FLA_Part_2x2(), FLA_QR2_UT_internal(), FLA_QR_UT_internal(), and FLA_Repart_2x2_to_3x3().
Referenced by FLASH_QR_UT_inc_noopt().
{
FLA_Obj ATL, ATR, A00, A01, A02,
ABL, ABR, A10, A11, A12,
A20, A21, A22;
FLA_Obj TTL, WTR, T00, W01, W02,
TBL, TBR, T10, T11, W12,
T20, T21, T22;
dim_t b;
FLA_Part_2x2( A, &ATL, &ATR,
&ABL, &ABR, 0, 0, FLA_TL );
FLA_Part_2x2( TW, &TTL, &WTR,
&TBL, &TBR, 0, 0, FLA_TL );
while ( FLA_Obj_min_dim( ABR ) > 0 ){
b = FLA_Determine_blocksize( ABR, FLA_BR, FLA_Cntl_blocksize( cntl ) );
FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
/* ************* */ /* ******************** */
&A10, /**/ &A11, &A12,
ABL, /**/ ABR, &A20, /**/ &A21, &A22,
b, b, FLA_BR );
FLA_Repart_2x2_to_3x3( TTL, /**/ WTR, &T00, /**/ &W01, &W02,
/* ************* */ /* ******************** */
&T10, /**/ &T11, &W12,
TBL, /**/ TBR, &T20, /**/ &T21, &T22,
b, b, FLA_BR );
/*------------------------------------------------------------*/
/*
Perform a QR factorization (via UT transform) on A11:
[ A11, T11 ] = QR_UT( A11, T11 );
where T11 refers to a single storage block that refers to an
b_alg-by-b row-panel of upper triangular block Householder
transforms. Here, b is the storage blocksize while b_alg is
the algorithmic blocksize used by the QR factorization.
Typically b_alg << b.
*/
FLA_QR_UT_internal( A11, T11,
FLA_Cntl_sub_qrut( cntl ) );
if ( FLA_Obj_width( A12 ) > 0 )
{
/*
Apply Q^H to A12 from the left:
A12 = Q^H * A12
where Q is formed from A11 and T11. Note that W12 refers
to a row-panel of blocks where each block refers to an
b_alg-by-b row-panel of workspace.
*/
FLA_Apply_Q_UT_internal( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
A11, T11, W12, A12,
FLA_Cntl_sub_apqut( cntl ) );
}
/*
Update QR factorization of A11 with each block of A21, storing
block Householder transforms into corresponding blocks of T21.
[ A11, ...
A21, T21 ] = QR2_UT( A11, ...
A21, T21 );
*/
FLA_QR2_UT_internal( A11,
A21, T21,
FLA_Cntl_sub_qr2ut( cntl ) );
if ( FLA_Obj_width( A12 ) > 0 )
{
/*
Apply Q^H to A12 and A22 from the left:
/ A12 \ = Q^H * / A12 \
\ A22 / \ A22 /
where Q is formed from A21 and T21.
*/
FLA_Apply_Q2_UT_internal( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
A21, T21, W12, A12,
A22,
FLA_Cntl_sub_apq2ut( cntl ) );
}
/*------------------------------------------------------------*/
FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
A10, A11, /**/ A12,
/* ************** */ /* ****************** */
&ABL, /**/ &ABR, A20, A21, /**/ A22,
FLA_TL );
FLA_Cont_with_3x3_to_2x2( &TTL, /**/ &WTR, T00, W01, /**/ W02,
T10, T11, /**/ W12,
/* ************** */ /* ****************** */
&TBL, /**/ &TBR, T20, T21, /**/ T22,
FLA_TL );
}
return FLA_SUCCESS;
}
| FLA_Error FLA_QR_UT_inc_blk_var2 | ( | FLA_Obj | A, |
| FLA_Obj | TW, | ||
| FLA_Obj | U, | ||
| fla_qrutinc_t * | cntl | ||
| ) |
References FLA_Apply_Q2_UT_internal(), FLA_Apply_Q_UT_internal(), FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x3_to_2x2(), FLA_Determine_blocksize(), FLA_Obj_min_dim(), FLA_Part_1x2(), FLA_Part_2x2(), FLA_QR2_UT_internal(), FLA_QR_UT_copy_internal(), FLA_Repart_1x2_to_1x3(), and FLA_Repart_2x2_to_3x3().
Referenced by FLASH_QR_UT_inc_opt1().
{
FLA_Obj ATL, ATR, A00, A01, A02,
ABL, ABR, A10, A11, A12,
A20, A21, A22;
FLA_Obj TTL, WTR, T00, W01, W02,
TBL, TBR, T10, T11, W12,
T20, T21, T22;
FLA_Obj UL, UR, U0, U11, U2;
dim_t b;
FLA_Part_2x2( A, &ATL, &ATR,
&ABL, &ABR, 0, 0, FLA_TL );
FLA_Part_2x2( TW, &TTL, &WTR,
&TBL, &TBR, 0, 0, FLA_TL );
FLA_Part_1x2( U, &UL, &UR, 0, FLA_LEFT );
while ( FLA_Obj_min_dim( ABR ) > 0 ){
b = FLA_Determine_blocksize( ABR, FLA_BR, FLA_Cntl_blocksize( cntl ) );
FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
/* ************* */ /* ******************** */
&A10, /**/ &A11, &A12,
ABL, /**/ ABR, &A20, /**/ &A21, &A22,
b, b, FLA_BR );
FLA_Repart_2x2_to_3x3( TTL, /**/ WTR, &T00, /**/ &W01, &W02,
/* ************* */ /* ******************** */
&T10, /**/ &T11, &W12,
TBL, /**/ TBR, &T20, /**/ &T21, &T22,
b, b, FLA_BR );
FLA_Repart_1x2_to_1x3( UL, /**/ UR, &U0, /**/ &U11, &U2,
b, FLA_RIGHT );
/*------------------------------------------------------------*/
/*
Use U11 to hold a copy of A11 to avoid a false
write-after-read dependency so that FLA_QR2_UT() may proceed
while FLA_Apply_Q_UT() executes.
*/
/*
Perform a QR factorization (via UT transform) on A11:
[ A11, T11 ] = QR_UT( A11, T11 );
where T11 refers to a single storage block that refers to an
b_alg-by-b row-panel of upper triangular block Householder
transforms. Here, b is the storage blocksize while b_alg is
the algorithmic blocksize used by the QR factorization.
Typically b_alg << b.
After the factorization is complete, A11 is copied into U11.
*/
FLA_QR_UT_copy_internal( A11, T11, U11,
FLA_Cntl_sub_qrut( cntl ) );
/*
Apply Q^H to A12 from the left:
A12 = Q^H * A12
where Q is formed from A11 and T11. Note that W12 refers
to a row-panel of blocks where each block refers to an
b_alg-by-b row-panel of workspace.
*/
FLA_Apply_Q_UT_internal( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
U11, T11, W12, A12,
FLA_Cntl_sub_apqut( cntl ) );
/*
Update QR factorization of A11 with each block of A21, storing
block Householder transforms into corresponding blocks of T21.
[ A11, ...
A21, T21 ] = QR2_UT( A11, ...
A21, T21 );
*/
FLA_QR2_UT_internal( A11,
A21, T21,
FLA_Cntl_sub_qr2ut( cntl ) );
/*
Apply Q^H to A12 and A22 from the left:
/ A12 \ = Q^H * / A12 \
\ A22 / \ A22 /
where Q is formed from A21 and T21.
*/
FLA_Apply_Q2_UT_internal( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
A21, T21, W12, A12,
A22,
FLA_Cntl_sub_apq2ut( cntl ) );
/*------------------------------------------------------------*/
FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
A10, A11, /**/ A12,
/* ************** */ /* ****************** */
&ABL, /**/ &ABR, A20, A21, /**/ A22,
FLA_TL );
FLA_Cont_with_3x3_to_2x2( &TTL, /**/ &WTR, T00, W01, /**/ W02,
T10, T11, /**/ W12,
/* ************** */ /* ****************** */
&TBL, /**/ &TBR, T20, T21, /**/ T22,
FLA_TL );
FLA_Cont_with_1x3_to_1x2( &UL, /**/ &UR, U0, U11, /**/ U2,
FLA_LEFT );
}
return FLA_SUCCESS;
}
| FLA_Error FLASH_QR_UT_inc | ( | FLA_Obj | A, |
| FLA_Obj | TW | ||
| ) |
References FLASH_QR_UT_inc_noopt(), FLASH_QR_UT_inc_opt1(), and FLASH_Queue_stack_depth().
{
FLA_Error r_val;
if ( FLASH_Queue_stack_depth() == 0 )
r_val = FLASH_QR_UT_inc_opt1( A, TW );
else
r_val = FLASH_QR_UT_inc_noopt( A, TW );
return r_val;
}
| 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_Cont_with_3x1_to_2x1(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Part_2x2(), FLA_Print_message(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_create_ext(), FLASH_Obj_create_hier_copy_of_flat(), FLASH_Obj_scalar_width(), FLASH_QR_UT_inc_determine_alg_blocksize(), FLA_Obj_view::m, FLA_Obj_view::m_inner, FLA_Obj_view::n, and FLA_Obj_view::n_inner.
{
FLA_Datatype datatype;
dim_t m, n;
dim_t n_last;
// *** 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 );
// If the bottom-right-most block along the diagonal is a partial block,
// adjust the view of the corresponding T block.
n_last = FLASH_Obj_scalar_width( *A ) % *b_flash;
if ( n_last > 0 )
{
FLA_Obj TWTL, TWTR,
TWBL, TWBR;
FLA_Obj TWL, TWR;
FLA_Obj TWT, TW0,
TWB, TW1,
TW2;
FLA_Obj* TW1p;
FLA_Part_2x2( *TW, &TWTL, &TWTR,
&TWBL, &TWBR, n-1, n-1, FLA_TL );
FLA_Part_2x1( TWBR, &TWT,
&TWB, 0, FLA_TOP );
while ( FLA_Obj_length( TWB ) > 0 )
{
FLA_Repart_2x1_to_3x1( TWT, &TW0,
/* *** */ /* *** */
&TW1,
TWB, &TW2, 1, FLA_BOTTOM );
// -----------------------------------------------------------
TW1p = FLASH_OBJ_PTR_AT( TW1 );
FLA_Part_1x2( *TW1p, &TWL, &TWR, n_last, FLA_LEFT );
*TW1p = TWL;
TW1p->m_inner = TW1p->m;
TW1p->n_inner = TW1p->n;
// -----------------------------------------------------------
FLA_Cont_with_3x1_to_2x1( &TWT, TW0,
TW1,
/* *** */ /* *** */
&TWB, TW2, FLA_TOP );
}
}
return FLA_SUCCESS;
}
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;
}
| FLA_Error FLASH_QR_UT_inc_noopt | ( | FLA_Obj | A, |
| FLA_Obj | TW | ||
| ) |
References FLA_Check_error_level(), FLA_QR_UT_inc_blk_var1(), FLA_QR_UT_inc_check(), FLASH_Queue_begin(), and FLASH_Queue_end().
Referenced by FLASH_QR_UT_inc().
{
FLA_Error r_val;
// Check parameters.
if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
FLA_QR_UT_inc_check( A, TW );
// Begin a parallel region.
FLASH_Queue_begin();
// Invoke FLA_QR_UT_inc_blk_var1() with the standard control tree.
r_val = FLA_QR_UT_inc_blk_var1( A, TW, flash_qrutinc_cntl );
// End the parallel region.
FLASH_Queue_end();
return r_val;
}
| FLA_Error FLASH_QR_UT_inc_opt1 | ( | FLA_Obj | A, |
| FLA_Obj | TW | ||
| ) |
References FLA_Check_error_level(), FLA_QR_UT_inc_blk_var2(), FLA_QR_UT_inc_check(), FLASH_Obj_create_diag_panel(), FLASH_Obj_free(), FLASH_Queue_begin(), and FLASH_Queue_end().
Referenced by FLASH_QR_UT_inc().
{
FLA_Error r_val;
FLA_Obj U;
// Check parameters.
if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
FLA_QR_UT_inc_check( A, TW );
// Create a temporary matrix to hold copies of all of the blocks along the
// diagonal of A.
FLASH_Obj_create_diag_panel( A, &U );
// Begin a parallel region.
FLASH_Queue_begin();
// Invoke FLA_QR_UT_inc_blk_var2() with the standard control tree.
r_val = FLA_QR_UT_inc_blk_var2( A, TW, U, flash_qrutinc_cntl );
// End the parallel region.
FLASH_Queue_end();
// Free the temporary matrix.
FLASH_Obj_free( &U );
return r_val;
}
References FLA_Check_error_level(), FLA_ONE, FLA_QR_UT_inc_solve_check(), FLASH_Apply_Q_UT_inc(), FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_Copy(), FLASH_Obj_create_copy_of(), FLASH_Obj_free(), FLASH_Obj_scalar_width(), FLASH_Part_create_2x1(), FLASH_Part_free_2x1(), and FLASH_Trsm().
{
FLA_Obj W, Y;
FLA_Obj AT, AB;
FLA_Obj YT, YB;
// Check parameters.
if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
FLA_QR_UT_inc_solve_check( A, TW, B, X );
FLASH_Apply_Q_UT_inc_create_workspace( TW, B, &W );
FLASH_Obj_create_copy_of( FLA_NO_TRANSPOSE, B, &Y );
FLASH_Apply_Q_UT_inc( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
A, TW, W, Y );
// Create a temporary hierarchical view of only the top n-by-n part of A in
// case m > n so that AT captures the upper triangular factor R. We do the
// same for Y to ensure conformality.
FLASH_Part_create_2x1( A, &AT,
&AB, FLASH_Obj_scalar_width( A ), FLA_TOP );
FLASH_Part_create_2x1( Y, &YT,
&YB, FLASH_Obj_scalar_width( A ), FLA_TOP );
FLASH_Trsm( FLA_LEFT, FLA_UPPER_TRIANGULAR, FLA_NO_TRANSPOSE, FLA_NONUNIT_DIAG,
FLA_ONE, AT, YT );
FLASH_Copy( YT, X );
// Free the temporary hierarchical views.
FLASH_Part_free_2x1( &AT,
&AB );
FLASH_Part_free_2x1( &YT,
&YB );
FLASH_Obj_free( &Y );
FLASH_Obj_free( &W );
return FLA_SUCCESS;
}
1.7.6.1