libflame  revision_anchor
Functions
FLA_Apply_Q_UT_lnbc_blk_var1.c File Reference

(r)

Functions

FLA_Error FLA_Apply_Q_UT_lnbc_blk_var1 (FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B, fla_apqut_t *cntl)
 

Function Documentation

◆ FLA_Apply_Q_UT_lnbc_blk_var1()

FLA_Error FLA_Apply_Q_UT_lnbc_blk_var1 ( FLA_Obj  A,
FLA_Obj  T,
FLA_Obj  W,
FLA_Obj  B,
fla_apqut_t cntl 
)

References FLA_Axpyt_internal(), FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Cont_with_3x3_to_2x2(), FLA_Copyt_internal(), FLA_Gemm_internal(), FLA_MINUS_ONE, FLA_Obj_length(), FLA_Obj_min_dim(), FLA_Obj_width(), FLA_ONE, FLA_Part_1x2(), FLA_Part_2x1(), FLA_Part_2x2(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLA_Repart_2x2_to_3x3(), FLA_Trmm_internal(), and FLA_Trsm_internal().

Referenced by FLA_Apply_Q_UT_lnbc().

14 {
15 /*
16  Apply a unitary matrix Q to a matrix B from the left,
17 
18  B := Q B
19 
20  where Q is the backward product of Householder transformations:
21 
22  Q = H(k-1) ... H(1) H(0)
23 
24  where H(i) corresponds to the Householder vector stored below the diagonal
25  in the ith column of A. Thus, the operation becomes:
26 
27  B := Q B
28  = H(k-1) ... H(1) H(0) B
29  = H(k-1)' ... H(1)' H(0)' B
30  = ( H(0) H(1) ... H(k-1) )' B
31 
32  From this, we can see that we must move through A from top-left to bottom-
33  right, since the Householder vector for H(0) was stored in the first column
34  of A. We intend to apply blocks of reflectors at a time, where a block
35  reflector H of b consecutive Householder transforms may be expressed as:
36 
37  H = ( H(i) H(i+1) ... H(i+b-1) )'
38  = ( I - U inv(T) U' )'
39 
40  where:
41  - U is the strictly lower trapezoidal (with implicit unit diagonal) matrix
42  of Householder vectors, stored below the diagonal of A in columns i
43  through i+b-1, corresponding to H(i) through H(i+b-1).
44  - T is the upper triangular block Householder matrix corresponding to
45  Householder vectors i through i+b-1.
46 
47  Consider applying H to B as an intermediate step towards applying all of Q:
48 
49  B := H B
50  = ( I - U inv(T) U' )' B
51  = ( I - U inv(T)' U' ) B
52  = B - U inv(T)' U' B
53 
54  We must move from top-left to bottom-right. So, we partition:
55 
56  U -> / U11 \ B -> / B1 \ T -> ( T1 T2 )
57  \ U21 / \ B2 /
58 
59  where:
60  - U11 is stored in the strictly lower triangle of A11 with implicit unit
61  diagonal.
62  - U21 is stored in A21.
63  - T1 is an upper triangular block of row-panel matrix T.
64 
65  Substituting repartitioned U, B, and T, we have:
66 
67  / B1 \ := / B1 \ - / U11 \ inv(T1)' / U11 \' / B1 \
68  \ B2 / \ B2 / \ U21 / \ U21 / \ B2 /
69  = / B1 \ - / U11 \ inv(T1)' ( U11' U21' ) / B1 \
70  \ B2 / \ U21 / \ B2 /
71  = / B1 \ - / U11 \ inv(T1)' ( U11' B1 + U21' B2 )
72  \ B2 / \ U21 /
73 
74  Thus, B1 is updated as:
75 
76  B1 := B1 - U11 inv(T1)' ( U11' B1 + U21' B2 )
77 
78  And B2 is updated as:
79 
80  B2 := B2 - U21 inv(T1)' ( U11' B1 + U21' B2 )
81 
82  Note that:
83 
84  inv(T1)' ( U11' B1 + U21' B2 )
85 
86  is common to both updates, and thus may be computed and stored in
87  workspace, and then re-used.
88 
89  -FGVZ
90 */
91  FLA_Obj ATL, ATR, A00, A01, A02,
92  ABL, ABR, A10, A11, A12,
93  A20, A21, A22;
94 
95  FLA_Obj TL, TR, T0, T1, T2;
96 
97  FLA_Obj T1T,
98  T2B;
99 
100  FLA_Obj WTL, WTR,
101  WBL, WBR;
102 
103  FLA_Obj BT, B0,
104  BB, B1,
105  B2;
106 
107  dim_t b_alg, b;
108 
109  // Query the algorithmic blocksize by inspecting the length of T.
110  b_alg = FLA_Obj_length( T );
111 
112  FLA_Part_2x2( A, &ATL, &ATR,
113  &ABL, &ABR, 0, 0, FLA_TL );
114 
115  FLA_Part_1x2( T, &TL, &TR, 0, FLA_LEFT );
116 
117  FLA_Part_2x1( B, &BT,
118  &BB, 0, FLA_TOP );
119 
120  while ( FLA_Obj_min_dim( ABR ) > 0 ){
121 
122  b = min( b_alg, FLA_Obj_min_dim( ABR ) );
123 
124  FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
125  /* ************* */ /* ******************** */
126  &A10, /**/ &A11, &A12,
127  ABL, /**/ ABR, &A20, /**/ &A21, &A22,
128  b, b, FLA_BR );
129 
130  FLA_Repart_1x2_to_1x3( TL, /**/ TR, &T0, /**/ &T1, &T2,
131  b, FLA_RIGHT );
132 
133  FLA_Repart_2x1_to_3x1( BT, &B0,
134  /* ** */ /* ** */
135  &B1,
136  BB, &B2, b, FLA_BOTTOM );
137 
138  /*------------------------------------------------------------*/
139 
140  FLA_Part_2x1( T1, &T1T,
141  &T2B, b, FLA_TOP );
142 
143  FLA_Part_2x2( W, &WTL, &WTR,
144  &WBL, &WBR, b, FLA_Obj_width( B1 ), FLA_TL );
145 
146  // WTL = B1;
147 
148  FLA_Copyt_internal( FLA_NO_TRANSPOSE, B1, WTL,
149  FLA_Cntl_sub_copyt( cntl ) );
150 
151  // U11 = trilu( A11 );
152  // U21 = A21;
153  //
154  // WTL = inv( triu(T1T) )' * ( U11' * B1 + U21' * B2 );
155 
156  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
157  FLA_CONJ_TRANSPOSE, FLA_UNIT_DIAG,
158  FLA_ONE, A11, WTL,
159  FLA_Cntl_sub_trmm1( cntl ) );
160 
161  FLA_Gemm_internal( FLA_CONJ_TRANSPOSE, FLA_NO_TRANSPOSE,
162  FLA_ONE, A21, B2, FLA_ONE, WTL,
163  FLA_Cntl_sub_gemm1( cntl ) );
164 
165  FLA_Trsm_internal( FLA_LEFT, FLA_UPPER_TRIANGULAR,
166  FLA_CONJ_TRANSPOSE, FLA_NONUNIT_DIAG,
167  FLA_ONE, T1T, WTL,
168  FLA_Cntl_sub_trsm( cntl ) );
169 
170  // B2 = B2 - U21 * WTL;
171  // B1 = B1 - U11 * WTL;
172 
173  FLA_Gemm_internal( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
174  FLA_MINUS_ONE, A21, WTL, FLA_ONE, B2,
175  FLA_Cntl_sub_gemm2( cntl ) );
176 
177  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
178  FLA_NO_TRANSPOSE, FLA_UNIT_DIAG,
179  FLA_MINUS_ONE, A11, WTL,
180  FLA_Cntl_sub_trmm2( cntl ) );
181 
182  FLA_Axpyt_internal( FLA_NO_TRANSPOSE, FLA_ONE, WTL, B1,
183  FLA_Cntl_sub_axpyt( cntl ) );
184 
185  /*------------------------------------------------------------*/
186 
187  FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
188  A10, A11, /**/ A12,
189  /* ************** */ /* ****************** */
190  &ABL, /**/ &ABR, A20, A21, /**/ A22,
191  FLA_TL );
192 
193  FLA_Cont_with_1x3_to_1x2( &TL, /**/ &TR, T0, T1, /**/ T2,
194  FLA_LEFT );
195 
196  FLA_Cont_with_3x1_to_2x1( &BT, B0,
197  B1,
198  /* ** */ /* ** */
199  &BB, B2, FLA_TOP );
200  }
201 
202  return FLA_SUCCESS;
203 }
FLA_Error FLA_Repart_2x1_to_3x1(FLA_Obj AT, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj AB, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:226
FLA_Error FLA_Repart_1x2_to_1x3(FLA_Obj AL, FLA_Obj AR, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:267
FLA_Error FLA_Copyt_internal(FLA_Trans trans, FLA_Obj A, FLA_Obj B, fla_copyt_t *cntl)
Definition: FLA_Copyt_internal.c:16
FLA_Error FLA_Gemm_internal(FLA_Trans transa, FLA_Trans transb, FLA_Obj alpha, FLA_Obj A, FLA_Obj B, FLA_Obj beta, FLA_Obj C, fla_gemm_t *cntl)
Definition: FLA_Gemm_internal.c:16
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Axpyt_internal(FLA_Trans trans, FLA_Obj alpha, FLA_Obj A, FLA_Obj B, fla_axpyt_t *cntl)
Definition: FLA_Axpyt_internal.c:16
FLA_Obj FLA_MINUS_ONE
Definition: FLA_Init.c:22
FLA_Error FLA_Repart_2x2_to_3x3(FLA_Obj ATL, FLA_Obj ATR, FLA_Obj *A00, FLA_Obj *A01, FLA_Obj *A02, FLA_Obj *A10, FLA_Obj *A11, FLA_Obj *A12, FLA_Obj ABL, FLA_Obj ABR, FLA_Obj *A20, FLA_Obj *A21, FLA_Obj *A22, dim_t mb, dim_t nb, FLA_Quadrant quadrant)
Definition: FLA_View.c:142
FLA_Error FLA_Cont_with_3x1_to_2x1(FLA_Obj *AT, FLA_Obj A0, FLA_Obj A1, FLA_Obj *AB, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:428
FLA_Error FLA_Part_2x2(FLA_Obj A, FLA_Obj *A11, FLA_Obj *A12, FLA_Obj *A21, FLA_Obj *A22, dim_t mb, dim_t nb, FLA_Quadrant quadrant)
Definition: FLA_View.c:17
FLA_Obj FLA_ONE
Definition: FLA_Init.c:18
FLA_Error FLA_Trmm_internal(FLA_Side side, FLA_Uplo uplo, FLA_Trans transa, FLA_Diag diag, FLA_Obj alpha, FLA_Obj A, FLA_Obj B, fla_trmm_t *cntl)
Definition: FLA_Trmm_internal.c:16
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLA_Cont_with_1x3_to_1x2(FLA_Obj *AL, FLA_Obj *AR, FLA_Obj A0, FLA_Obj A1, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:475
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
FLA_Error FLA_Cont_with_3x3_to_2x2(FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj A00, FLA_Obj A01, FLA_Obj A02, FLA_Obj A10, FLA_Obj A11, FLA_Obj A12, FLA_Obj *ABL, FLA_Obj *ABR, FLA_Obj A20, FLA_Obj A21, FLA_Obj A22, FLA_Quadrant quadrant)
Definition: FLA_View.c:304
FLA_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:110
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
dim_t FLA_Obj_min_dim(FLA_Obj obj)
Definition: FLA_Query.c:153
FLA_Error FLA_Trsm_internal(FLA_Side side, FLA_Uplo uplo, FLA_Trans transa, FLA_Diag diag, FLA_Obj alpha, FLA_Obj A, FLA_Obj B, fla_trsm_t *cntl)
Definition: FLA_Trsm_internal.c:16