libflame revision_anchor
Functions
FLA_Apply_Q_UT_lnbc.h File Reference

(r)

Go to the source code of this file.

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)
 
FLA_Error FLA_Apply_Q_UT_lnbc_blk_var2 (FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B, fla_apqut_t *cntl)
 
FLA_Error FLA_Apply_Q_UT_lnbc_blk_var3 (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 
)
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
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.
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
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
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
158 FLA_ONE, A11, WTL,
159 FLA_Cntl_sub_trmm1( cntl ) );
160
163 FLA_Cntl_sub_gemm1( cntl ) );
164
167 FLA_ONE, T1T, WTL,
168 FLA_Cntl_sub_trsm( cntl ) );
169
170 // B2 = B2 - U21 * WTL;
171 // B1 = B1 - U11 * WTL;
172
175 FLA_Cntl_sub_gemm2( cntl ) );
176
180 FLA_Cntl_sub_trmm2( cntl ) );
181
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
197 B1,
198 /* ** */ /* ** */
199 &BB, B2, FLA_TOP );
200 }
201
202 return FLA_SUCCESS;
203}
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_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
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
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
FLA_Obj FLA_MINUS_ONE
Definition FLA_Init.c:22
FLA_Obj FLA_ONE
Definition FLA_Init.c:18
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_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_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_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_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
dim_t FLA_Obj_width(FLA_Obj obj)
Definition FLA_Query.c:123
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
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
dim_t FLA_Obj_length(FLA_Obj obj)
Definition FLA_Query.c:116
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_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
dim_t FLA_Obj_min_dim(FLA_Obj obj)
Definition FLA_Query.c:153
unsigned long dim_t
Definition FLA_type_defs.h:71
int i
Definition bl1_axmyv2.c:145
Definition FLA_type_defs.h:159

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(), FLA_Trsm_internal(), and i.

Referenced by FLA_Apply_Q_UT_lnbc().

◆ FLA_Apply_Q_UT_lnbc_blk_var2()

FLA_Error FLA_Apply_Q_UT_lnbc_blk_var2 ( FLA_Obj  A,
FLA_Obj  T,
FLA_Obj  W,
FLA_Obj  B,
fla_apqut_t cntl 
)
14{
15 FLA_Obj BL, BR, B0, B1, B2;
16
17 FLA_Obj WL, WR, W0, W1, W2;
18
19 dim_t b;
20
21 FLA_Part_1x2( B, &BL, &BR, 0, FLA_LEFT );
22
23 FLA_Part_1x2( W, &WL, &WR, 0, FLA_LEFT );
24
25 while ( FLA_Obj_width( BL ) < FLA_Obj_width( B ) ){
26
28
29 FLA_Repart_1x2_to_1x3( BL, /**/ BR, &B0, /**/ &B1, &B2,
30 b, FLA_RIGHT );
31
32 FLA_Repart_1x2_to_1x3( WL, /**/ WR, &W0, /**/ &W1, &W2,
33 b, FLA_RIGHT );
34
35 /*------------------------------------------------------------*/
36
37 // B1 = Q * B1;
39 A, T, W1, B1,
40 FLA_Cntl_sub_apqut( cntl ) );
41
42 /*------------------------------------------------------------*/
43
44 FLA_Cont_with_1x3_to_1x2( &BL, /**/ &BR, B0, B1, /**/ B2,
45 FLA_LEFT );
46
47 FLA_Cont_with_1x3_to_1x2( &WL, /**/ &WR, W0, W1, /**/ W2,
48 FLA_LEFT );
49 }
50
51 return FLA_SUCCESS;
52}
FLA_Error FLA_Apply_Q_UT_internal(FLA_Side side, FLA_Trans trans, FLA_Direct direct, FLA_Store storev, FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B, fla_apqut_t *cntl)
Definition FLA_Apply_Q_UT_internal.c:17
dim_t FLA_Determine_blocksize(FLA_Obj A_unproc, FLA_Quadrant to_dir, fla_blocksize_t *cntl_blocksizes)
Definition FLA_Blocksize.c:234

References FLA_Apply_Q_UT_internal(), FLA_Cont_with_1x3_to_1x2(), FLA_Determine_blocksize(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Repart_1x2_to_1x3(), and i.

Referenced by FLA_Apply_Q_UT_lnbc().

◆ FLA_Apply_Q_UT_lnbc_blk_var3()

FLA_Error FLA_Apply_Q_UT_lnbc_blk_var3 ( FLA_Obj  A,
FLA_Obj  T,
FLA_Obj  W,
FLA_Obj  B,
fla_apqut_t cntl 
)
14{
15 FLA_Obj ATL, ATR, A00, A01, A02,
16 ABL, ABR, A10, A11, A12,
17 A20, A21, A22;
18
20 TWBL, TWBR, TW10, T11, W12,
21 TW20, TW21, TW22;
22
24 WBL, WBR;
25
26 FLA_Obj BT, B0,
27 BB, B1,
28 B2;
29
30 dim_t b;
31
32 FLA_Part_2x2( A, &ATL, &ATR,
33 &ABL, &ABR, 0, 0, FLA_TL );
34
36 &TWBL, &TWBR, 0, 0, FLA_TL );
37
38 FLA_Part_2x1( B, &BT,
39 &BB, 0, FLA_TOP );
40
41 while ( FLA_Obj_min_dim( ABR ) > 0 ){
42
44
45 FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
46 /* ************* */ /* ******************** */
47 &A10, /**/ &A11, &A12,
48 ABL, /**/ ABR, &A20, /**/ &A21, &A22,
49 b, b, FLA_BR );
50
51 FLA_Repart_2x2_to_3x3( TWTL, /**/ TWTR, &TW00, /**/ &TW01, &TW02,
52 /* *************** */ /* *********************** */
53 &TW10, /**/ &T11, &W12,
54 TWBL, /**/ TWBR, &TW20, /**/ &TW21, &TW22,
55 b, b, FLA_BR );
56
58 /* ** */ /* ** */
59 &B1,
60 BB, &B2, b, FLA_BOTTOM );
61
62 /*------------------------------------------------------------*/
63
64 FLA_Part_2x2( W, &WTL, &WTR,
65 &WBL, &WBR, b, FLA_Obj_width( B1 ), FLA_TL );
66
67 // WTL = B1;
68
70 FLA_Cntl_sub_copyt( cntl ) );
71
72 // U11 = trilu( A11 );
73 // U21 = A21;
74 //
75 // WTL = inv( triu(T11) )' * ( U11' * B1 + U21' * B2 );
76
79 FLA_ONE, A11, WTL,
80 FLA_Cntl_sub_trmm1( cntl ) );
81
84 FLA_Cntl_sub_gemm1( cntl ) );
85
88 FLA_ONE, T11, WTL,
89 FLA_Cntl_sub_trsm( cntl ) );
90
91 // B2 = B2 - U21 * WTL;
92 // B1 = B1 - U11 * WTL;
93
96 FLA_Cntl_sub_gemm2( cntl ) );
97
101 FLA_Cntl_sub_trmm2( cntl ) );
102
104 FLA_Cntl_sub_axpyt( cntl ) );
105
106 /*------------------------------------------------------------*/
107
108 FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
109 A10, A11, /**/ A12,
110 /* ************** */ /* ****************** */
111 &ABL, /**/ &ABR, A20, A21, /**/ A22,
112 FLA_TL );
113
115 TW10, T11, /**/ W12,
116 /* **************** */ /* ********************* */
117 &TWBL, /**/ &TWBR, TW20, TW21, /**/ TW22,
118 FLA_TL );
119
121 B1,
122 /* ** */ /* ** */
123 &BB, B2, FLA_TOP );
124 }
125
126 return FLA_SUCCESS;
127}

References FLA_Axpyt_internal(), FLA_Cont_with_3x1_to_2x1(), FLA_Cont_with_3x3_to_2x2(), FLA_Copyt_internal(), FLA_Determine_blocksize(), FLA_Gemm_internal(), FLA_MINUS_ONE, FLA_Obj_min_dim(), FLA_Obj_width(), FLA_ONE, FLA_Part_2x1(), FLA_Part_2x2(), FLA_Repart_2x1_to_3x1(), FLA_Repart_2x2_to_3x3(), FLA_Trmm_internal(), FLA_Trsm_internal(), and i.

Referenced by FLA_Apply_Q_UT_lnbc().