libflame  revision_anchor
Functions
FLA_Apply_Q_UT_rnbc_blk_var1.c File Reference

(r)

Functions

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

Function Documentation

◆ FLA_Apply_Q_UT_rnbc_blk_var1()

FLA_Error FLA_Apply_Q_UT_rnbc_blk_var1 ( FLA_Obj  A,
FLA_Obj  T,
FLA_Obj  W,
FLA_Obj  B,
fla_apqut_t cntl 
)
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 BL, BR, B0, B1, B2;
104 
105  dim_t b_alg, b;
106  dim_t m_BR, n_BR;
107 
108  // Query the algorithmic blocksize by inspecting the length of T.
109  b_alg = FLA_Obj_length( T );
110 
111  // If m > n, then we have to initialize our partitionings carefully so
112  // that we begin in the proper location in A and B (since we traverse
113  // matrix A from BR to TL).
114  if ( FLA_Obj_length( A ) > FLA_Obj_width( A ) )
115  {
116  m_BR = FLA_Obj_length( A ) - FLA_Obj_width( A );
117  n_BR = 0;
118  }
119  else if ( FLA_Obj_length( A ) < FLA_Obj_width( A ) )
120  {
121  m_BR = 0;
122  n_BR = FLA_Obj_width( A ) - FLA_Obj_length( A );
123  }
124  else
125  {
126  m_BR = 0;
127  n_BR = 0;
128  }
129 
130  FLA_Part_2x2( A, &ATL, &ATR,
131  &ABL, &ABR, m_BR, n_BR, FLA_BR );
132 
133  // A and T are dependent; we determine T matrix w.r.t. A
134  FLA_Part_1x2( T, &TL, &TR, FLA_Obj_min_dim( A ), FLA_LEFT );
135 
136  FLA_Part_1x2( B, &BL, &BR, m_BR, FLA_RIGHT );
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_1x2_to_1x3( BL, /**/ BR, &B0, &B1, /**/ &B2,
158  b, FLA_LEFT );
159 
160  /*------------------------------------------------------------*/
161 
162  FLA_Part_2x1( T1, &T1T,
163  &T2B, b, FLA_TOP );
164 
165  FLA_Part_2x2( W, &WTL, &WTR,
166  &WBL, &WBR, b, FLA_Obj_length( B1 ), FLA_TL );
167 
168  // WTL = B1^T;
169 
170  FLA_Copyt_internal( FLA_TRANSPOSE, B1, WTL,
171  FLA_Cntl_sub_copyt( cntl ) );
172 
173  // U11 = trilu( A11 );
174  // U21 = A21;
175  // Let WTL^T be conformal to B1.
176  //
177  // WTL^T = ( B1 * U11 + B2 * U21 ) * inv( triu(T1T)' );
178  // WTL = inv( conj(triu(T1T)) ) * ( U11^T * B1^T + U21^T * B2^T );
179 
180  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
181  FLA_TRANSPOSE, FLA_UNIT_DIAG,
182  FLA_ONE, A11, WTL,
183  FLA_Cntl_sub_trmm1( cntl ) );
184 
185  FLA_Gemm_internal( FLA_TRANSPOSE, FLA_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_CONJ_NO_TRANSPOSE, FLA_NONUNIT_DIAG,
191  FLA_ONE, T1T, WTL,
192  FLA_Cntl_sub_trsm( cntl ) );
193 
194  // B2 = B2 - WTL^T * U21';
195  // B1 = B1 - WTL^T * U11';
196  // = B1 - ( conj(U11) * WTL )^T;
197 
198  FLA_Gemm_internal( FLA_TRANSPOSE, FLA_CONJ_TRANSPOSE,
199  FLA_MINUS_ONE, WTL, A21, FLA_ONE, B2,
200  FLA_Cntl_sub_gemm2( cntl ) );
201 
202  FLA_Trmm_internal( FLA_LEFT, FLA_LOWER_TRIANGULAR,
203  FLA_CONJ_NO_TRANSPOSE, FLA_UNIT_DIAG,
204  FLA_MINUS_ONE, A11, WTL,
205  FLA_Cntl_sub_trmm2( cntl ) );
206 
207  FLA_Axpyt_internal( FLA_TRANSPOSE, FLA_ONE, WTL, B1,
208  FLA_Cntl_sub_axpyt( cntl ) );
209 
210  /*------------------------------------------------------------*/
211 
212  FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, /**/ A01, A02,
213  /* ************** */ /* ****************** */
214  A10, /**/ A11, A12,
215  &ABL, /**/ &ABR, A20, /**/ A21, A22,
216  FLA_BR );
217 
218  FLA_Cont_with_1x3_to_1x2( &TL, /**/ &TR, T0, /**/ T1, T2,
219  FLA_RIGHT );
220 
221  FLA_Cont_with_1x3_to_1x2( &BL, /**/ &BR, B0, /**/ B1, B2,
222  FLA_RIGHT );
223  }
224 
225  return FLA_SUCCESS;
226 }
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_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_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_2x2_to_3x3(), FLA_Trmm_internal(), and FLA_Trsm_internal().

Referenced by FLA_Apply_Q_UT_rnbc().