libflame  revision_anchor
Functions
FLA_Apply_Q_UT_lnfc.h File Reference

(r)

Go to the source code of this file.

Functions

FLA_Error FLA_Apply_Q_UT_lnfc_blk_var1 (FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B, fla_apqut_t *cntl)
 
FLA_Error FLA_Apply_Q_UT_lnfc_blk_var2 (FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B, fla_apqut_t *cntl)
 
FLA_Error FLA_Apply_Q_UT_lnfc_blk_var3 (FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B, fla_apqut_t *cntl)
 

Function Documentation

◆ FLA_Apply_Q_UT_lnfc_blk_var1()

FLA_Error FLA_Apply_Q_UT_lnfc_blk_var1 ( FLA_Obj  A,
FLA_Obj  T,
FLA_Obj  W,
FLA_Obj  B,
fla_apqut_t cntl 
)
87 {
88  FLA_Obj ATL, ATR, A00, A01, A02,
89  ABL, ABR, A10, A11, A12,
90  A20, A21, A22;
91 
92  FLA_Obj TL, TR, T0, T1, T2;
93 
94  FLA_Obj T1T,
95  T2B;
96 
97  FLA_Obj WTL, WTR,
98  WBL, WBR;
99 
100  FLA_Obj BT, B0,
101  BB, B1,
102  B2;
103 
104  dim_t b_alg, b;
105  dim_t m_BR, n_BR;
106 
107  // Query the algorithmic blocksize by inspecting the length of T.
108  b_alg = FLA_Obj_length( T );
109 
110  // If m > n, then we have to initialize our partitionings carefully so
111  // that we begin in the proper location in A and B (since we traverse
112  // matrix A from BR to TL).
113  if ( FLA_Obj_length( A ) > FLA_Obj_width( A ) )
114  {
115  m_BR = FLA_Obj_length( A ) - FLA_Obj_width( A );
116  n_BR = 0;
117  }
118  else if ( FLA_Obj_length( A ) < FLA_Obj_width( A ) )
119  {
120  m_BR = 0;
121  n_BR = FLA_Obj_width( A ) - FLA_Obj_length( A );
122  }
123  else
124  {
125  m_BR = 0;
126  n_BR = 0;
127  }
128 
129  FLA_Part_2x2( A, &ATL, &ATR,
130  &ABL, &ABR, m_BR, n_BR, FLA_BR );
131 
132  // A and T are dependent; we determine T matrix w.r.t. A
133  FLA_Part_1x2( T, &TL, &TR, FLA_Obj_min_dim( A ), FLA_LEFT );
134 
135  FLA_Part_2x1( B, &BT,
136  &BB, m_BR, FLA_BOTTOM );
137 
138  while ( FLA_Obj_min_dim( ATL ) > 0 ){
139 
140  b = min( b_alg, FLA_Obj_min_dim( ATL ) );
141 
142  // Since T was filled from left to right, and since we need to access them
143  // in reverse order, we need to handle the case where the last block is
144  // smaller than the other b x b blocks.
145  if ( FLA_Obj_width( TR ) == 0 && FLA_Obj_width( T ) % b_alg > 0 )
146  b = FLA_Obj_width( T ) % b_alg;
147 
148  FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, &A01, /**/ &A02,
149  &A10, &A11, /**/ &A12,
150  /* ************* */ /* ******************** */
151  ABL, /**/ ABR, &A20, &A21, /**/ &A22,
152  b, b, FLA_TL );
153 
154  FLA_Repart_1x2_to_1x3( TL, /**/ TR, &T0, &T1, /**/ &T2,
155  b, FLA_LEFT );
156 
157  FLA_Repart_2x1_to_3x1( BT, &B0,
158  &B1,
159  /* ** */ /* ** */
160  BB, &B2, b, FLA_TOP );
161 
162  /*------------------------------------------------------------*/
163 
164  FLA_Part_2x1( T1, &T1T,
165  &T2B, b, FLA_TOP );
166 
167  FLA_Part_2x2( W, &WTL, &WTR,
168  &WBL, &WBR, b, FLA_Obj_width( B1 ), FLA_TL );
169 
170  // WTL = B1;
171 
172  FLA_Copyt_internal( FLA_NO_TRANSPOSE, B1, WTL,
173  FLA_Cntl_sub_copyt( cntl ) );
174 
175  // U11 = trilu( A11 );
176  // U21 = A21;
177  //
178  // WTL = inv( triu(T1T) ) * ( U11' * B1 + U21' * B2 );
179 
180  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
181  FLA_CONJ_TRANSPOSE, FLA_UNIT_DIAG,
182  FLA_ONE, A11, WTL,
183  FLA_Cntl_sub_trmm1( cntl ) );
184 
185  FLA_Gemm_internal( FLA_CONJ_TRANSPOSE, FLA_NO_TRANSPOSE,
186  FLA_ONE, A21, B2, FLA_ONE, WTL,
187  FLA_Cntl_sub_gemm1( cntl ) );
188 
189  FLA_Trsm_internal( FLA_LEFT, FLA_UPPER_TRIANGULAR,
190  FLA_NO_TRANSPOSE, FLA_NONUNIT_DIAG,
191  FLA_ONE, T1T, WTL,
192  FLA_Cntl_sub_trsm( cntl ) );
193 
194  // B2 = B2 - U21 * WTL;
195  // B1 = B1 - U11 * WTL;
196 
197  FLA_Gemm_internal( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
198  FLA_MINUS_ONE, A21, WTL, FLA_ONE, B2,
199  FLA_Cntl_sub_gemm2( cntl ) );
200 
201  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
202  FLA_NO_TRANSPOSE, FLA_UNIT_DIAG,
203  FLA_MINUS_ONE, A11, WTL,
204  FLA_Cntl_sub_trmm2( cntl ) );
205 
206  FLA_Axpyt_internal( FLA_NO_TRANSPOSE, FLA_ONE, WTL, B1,
207  FLA_Cntl_sub_axpyt( cntl ) );
208 
209  /*------------------------------------------------------------*/
210 
211  FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, /**/ A01, A02,
212  /* ************** */ /* ****************** */
213  A10, /**/ A11, A12,
214  &ABL, /**/ &ABR, A20, /**/ A21, A22,
215  FLA_BR );
216 
217  FLA_Cont_with_1x3_to_1x2( &TL, /**/ &TR, T0, /**/ T1, T2,
218  FLA_RIGHT );
219 
220  FLA_Cont_with_3x1_to_2x1( &BT, B0,
221  /* ** */ /* ** */
222  B1,
223  &BB, B2, FLA_BOTTOM );
224  }
225 
226  return FLA_SUCCESS;
227 }
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
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(), and FLA_Trsm_internal().

Referenced by FLA_Apply_Q_UT_lnfc().

◆ FLA_Apply_Q_UT_lnfc_blk_var2()

FLA_Error FLA_Apply_Q_UT_lnfc_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 
27  b = FLA_Determine_blocksize( BR, FLA_RIGHT, FLA_Cntl_blocksize( cntl ) );
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;
38  FLA_Apply_Q_UT_internal( FLA_LEFT, FLA_NO_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
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(), and FLA_Repart_1x2_to_1x3().

Referenced by FLA_Apply_Q_UT_lnfc().

◆ FLA_Apply_Q_UT_lnfc_blk_var3()

FLA_Error FLA_Apply_Q_UT_lnfc_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 
19  FLA_Obj TWTL, TWTR, TW00, TW01, TW02,
20  TWBL, TWBR, TW10, T11, W12,
21  TW20, TW21, TW22;
22 
23  FLA_Obj WTL, WTR,
24  WBL, WBR;
25 
26  FLA_Obj BT, B0,
27  BB, B1,
28  B2;
29 
30  dim_t b, m_BR, n_BR;
31 
32  // If m < n, then we have to initialize our partitionings carefully so
33  // that we begin in the proper location in A and B (since we traverse
34  // matrix A from BR to TL).
35  if ( FLA_Obj_length( A ) < FLA_Obj_width( A ) )
36  {
37  m_BR = 0;
38  n_BR = FLA_Obj_width( A ) - FLA_Obj_length( A );
39  }
40  else
41  {
42  m_BR = 0;
43  n_BR = 0;
44  }
45 
46  FLA_Part_2x2( A, &ATL, &ATR,
47  &ABL, &ABR, m_BR, n_BR, FLA_BR );
48 
49  FLA_Part_2x2( TW, &TWTL, &TWTR,
50  &TWBL, &TWBR, 0, 0, FLA_BR );
51 
52  FLA_Part_2x1( B, &BT,
53  &BB, n_BR, FLA_BOTTOM );
54 
55  while ( FLA_Obj_min_dim( ATL ) > 0 ){
56 
57  b = FLA_Determine_blocksize( ATL, FLA_TL, FLA_Cntl_blocksize( cntl ) );
58 
59  // Since T was filled from TL to BR, and since we need to access them in
60  // reverse order, we need to handle the case where the bottom-right-most
61  // block is smaller than the other b x b blocks.
62  if ( FLA_Obj_width( TWBR ) == 0 &&
63  FLA_Obj_width( TW ) % b > 0 )
64  b = FLA_Obj_width( TW ) % b;
65 
66  FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, &A01, /**/ &A02,
67  &A10, &A11, /**/ &A12,
68  /* ************* */ /* ******************** */
69  ABL, /**/ ABR, &A20, &A21, /**/ &A22,
70  b, b, FLA_TL );
71 
72  FLA_Repart_2x2_to_3x3( TWTL, /**/ TWTR, &TW00, &TW01, /**/ &TW02,
73  &TW10, &T11, /**/ &W12,
74  /* *************** */ /* *********************** */
75  TWBL, /**/ TWBR, &TW20, &TW21, /**/ &TW22,
76  b, b, FLA_TL );
77 
78  FLA_Repart_2x1_to_3x1( BT, &B0,
79  &B1,
80  /* ** */ /* ** */
81  BB, &B2, b, FLA_TOP );
82 
83  /*------------------------------------------------------------*/
84 
85  FLA_Part_2x2( W, &WTL, &WTR,
86  &WBL, &WBR, b, FLA_Obj_width( B1 ), FLA_TL );
87 
88  // WTL = B1;
89 
90  FLA_Copyt_internal( FLA_NO_TRANSPOSE, B1, WTL,
91  FLA_Cntl_sub_copyt( cntl ) );
92 
93  // U11 = trilu( A11 );
94  // U21 = A21;
95  //
96  // WTL = inv( triu(T11) ) * ( U11' * B1 + U21' * B2 );
97 
98  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
99  FLA_CONJ_TRANSPOSE, FLA_UNIT_DIAG,
100  FLA_ONE, A11, WTL,
101  FLA_Cntl_sub_trmm1( cntl ) );
102 
103  FLA_Gemm_internal( FLA_CONJ_TRANSPOSE, FLA_NO_TRANSPOSE,
104  FLA_ONE, A21, B2, FLA_ONE, WTL,
105  FLA_Cntl_sub_gemm1( cntl ) );
106 
107  FLA_Trsm_internal( FLA_LEFT, FLA_UPPER_TRIANGULAR,
108  FLA_NO_TRANSPOSE, FLA_NONUNIT_DIAG,
109  FLA_ONE, T11, WTL,
110  FLA_Cntl_sub_trsm( cntl ) );
111 
112  // B2 = B2 - U21 * WTL;
113  // B1 = B1 - U11 * WTL;
114 
115  FLA_Gemm_internal( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
116  FLA_MINUS_ONE, A21, WTL, FLA_ONE, B2,
117  FLA_Cntl_sub_gemm2( cntl ) );
118 
119  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
120  FLA_NO_TRANSPOSE, FLA_UNIT_DIAG,
121  FLA_MINUS_ONE, A11, WTL,
122  FLA_Cntl_sub_trmm2( cntl ) );
123 
124  FLA_Axpyt_internal( FLA_NO_TRANSPOSE, FLA_ONE, WTL, B1,
125  FLA_Cntl_sub_axpyt( cntl ) );
126 
127  /*------------------------------------------------------------*/
128 
129  FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, /**/ A01, A02,
130  /* ************** */ /* ****************** */
131  A10, /**/ A11, A12,
132  &ABL, /**/ &ABR, A20, /**/ A21, A22,
133  FLA_BR );
134 
135  FLA_Cont_with_3x3_to_2x2( &TWTL, /**/ &TWTR, TW00, /**/ TW01, TW02,
136  /* **************** */ /* ********************* */
137  TW10, /**/ T11, W12,
138  &TWBL, /**/ &TWBR, TW20, /**/ TW21, TW22,
139  FLA_BR );
140 
141  FLA_Cont_with_3x1_to_2x1( &BT, B0,
142  /* ** */ /* ** */
143  B1,
144  &BB, B2, FLA_BOTTOM );
145  }
146 
147  return FLA_SUCCESS;
148 }

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

Referenced by FLA_Apply_Q_UT_lnfc().