| 1 |
/* |
| 2 |
|
| 3 |
Copyright (C) 2014, The University of Texas at Austin |
| 4 |
|
| 5 |
This file is part of libflame and is available under the 3-Clause |
| 6 |
BSD license, which can be found in the LICENSE file at the top-level |
| 7 |
directory, or at http://opensource.org/licenses/BSD-3-Clause |
| 8 |
|
| 9 |
*/ |
| 10 |
|
| 11 |
#include "FLAME.h" |
| 12 |
|
| 13 |
FLA_Error FLA_LQ_UT_blk_var3( FLA_Obj A, FLA_Obj TW, fla_lqut_t* cntl ) |
| 14 |
{ |
| 15 |
FLA_Obj ATL, ATR, A00, A01, A02, |
| 16 |
ABL, ABR, A10, A11, A12, |
| 17 |
A20, A21, A22; |
| 18 |
|
| 19 |
FLA_Obj TWTL, TWTR, TW00, TW01, TW02, |
| 20 |
TWBL, TWBR, TW10, T11, W12, |
| 21 |
TW20, TW21, TW22; |
| 22 |
|
| 23 |
FLA_Obj AR1, |
| 24 |
AR2; |
| 25 |
|
| 26 |
dim_t b; |
| 27 |
|
| 28 |
FLA_Part_2x2( A, &ATL, &ATR, |
| 29 |
&ABL, &ABR, 0, 0, FLA_TL ); |
| 30 |
|
| 31 |
FLA_Part_2x2( TW, &TWTL, &TWTR, |
| 32 |
&TWBL, &TWBR, 0, 0, FLA_TL ); |
| 33 |
|
| 34 |
while ( FLA_Obj_min_dim( ABR ) > 0 ){ |
| 35 |
|
| 36 |
b = FLA_Determine_blocksize( ABR, FLA_BR, FLA_Cntl_blocksize( cntl ) ); |
| 37 |
|
| 38 |
FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02, |
| 39 |
/* ************* */ /* ******************** */ |
| 40 |
&A10, /**/ &A11, &A12, |
| 41 |
ABL, /**/ ABR, &A20, /**/ &A21, &A22, |
| 42 |
b, b, FLA_BR ); |
| 43 |
|
| 44 |
FLA_Repart_2x2_to_3x3( TWTL, /**/ TWTR, &TW00, /**/ &TW01, &TW02, |
| 45 |
/* ************* */ /* ******************** */ |
| 46 |
&TW10, /**/ &T11, &W12, |
| 47 |
TWBL, /**/ TWBR, &TW20, /**/ &TW21, &TW22, |
| 48 |
b, b, FLA_BR ); |
| 49 |
|
| 50 |
/*------------------------------------------------------------*/ |
| 51 |
|
| 52 |
FLA_Merge_1x2( A11, A12, &AR1 ); |
| 53 |
|
| 54 |
// Perform an LQ factorization via the UT transform on AR1: |
| 55 |
// |
| 56 |
// ( A11 A12 ) -> L11 QR1 |
| 57 |
// |
| 58 |
// where: |
| 59 |
// - QR1 is formed from UR1 (which is stored row-wise above the |
| 60 |
// diagonal of AR1) and T11 (which is stored to the upper triangle |
| 61 |
// of T11). |
| 62 |
// - L11 is stored to the lower triangle of AR1. |
| 63 |
|
| 64 |
FLA_LQ_UT_internal( AR1, T11, |
| 65 |
FLA_Cntl_sub_lqut( cntl ) ); |
| 66 |
|
| 67 |
|
| 68 |
if ( FLA_Obj_length( A21 ) > 0 ) |
| 69 |
{ |
| 70 |
FLA_Merge_1x2( A21, A22, &AR2 ); |
| 71 |
|
| 72 |
// Apply the Householder transforms associated with UR1 and T11 to |
| 73 |
// AR2: |
| 74 |
// |
| 75 |
// ( A21 A22 ) := ( A21 A22 ) Q1 |
| 76 |
// |
| 77 |
// where QR1 is formed from UR1 and T11. |
| 78 |
|
| 79 |
FLA_Apply_Q_UT_internal( FLA_RIGHT, FLA_NO_TRANSPOSE, FLA_FORWARD, FLA_ROWWISE, |
| 80 |
AR1, T11, W12, AR2, |
| 81 |
FLA_Cntl_sub_apqut( cntl ) ); |
| 82 |
} |
| 83 |
|
| 84 |
/*------------------------------------------------------------*/ |
| 85 |
|
| 86 |
FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02, |
| 87 |
A10, A11, /**/ A12, |
| 88 |
/* ************** */ /* ****************** */ |
| 89 |
&ABL, /**/ &ABR, A20, A21, /**/ A22, |
| 90 |
FLA_TL ); |
| 91 |
|
| 92 |
FLA_Cont_with_3x3_to_2x2( &TWTL, /**/ &TWTR, TW00, TW01, /**/ TW02, |
| 93 |
TW10, T11, /**/ W12, |
| 94 |
/* ************** */ /* ****************** */ |
| 95 |
&TWBL, /**/ &TWBR, TW20, TW21, /**/ TW22, |
| 96 |
FLA_TL ); |
| 97 |
} |
| 98 |
|
| 99 |
return FLA_SUCCESS; |
| 100 |
} |
| 101 |
|