libflame  revision_anchor
Functions
FLA_Hess_UT_blk_var5.c File Reference

(r)

Functions

FLA_Error FLA_Hess_UT_blk_var5 (FLA_Obj A, FLA_Obj T)
 

Function Documentation

◆ FLA_Hess_UT_blk_var5()

FLA_Error FLA_Hess_UT_blk_var5 ( FLA_Obj  A,
FLA_Obj  T 
)
14 {
15  FLA_Obj ATL, ATR, A00, A01, A02,
16  ABL, ABR, A10, A11, A12,
17  A20, A21, A22;
18  FLA_Obj UT, U0,
19  UB, U1,
20  U2;
21  FLA_Obj ZT, Z0,
22  ZB, Z1,
23  Z2;
24  FLA_Obj TL, TR, T0, T1, W12;
25 
26  FLA_Obj U, Z;
27  FLA_Obj UB_l;
28  FLA_Obj ZB_l;
29  FLA_Obj WT_l;
30  FLA_Obj T1_tl;
31  FLA_Obj none, none2, none3;
32  FLA_Datatype datatype_A;
33  dim_t m_A;
34  dim_t b_alg, b, bb;
35 
36  b_alg = FLA_Obj_length( T );
37 
38  datatype_A = FLA_Obj_datatype( A );
39  m_A = FLA_Obj_length( A );
40 
41  FLA_Obj_create( datatype_A, m_A, b_alg, 0, 0, &U );
42  FLA_Obj_create( datatype_A, m_A, b_alg, 0, 0, &Z );
43 
44  FLA_Part_2x2( A, &ATL, &ATR,
45  &ABL, &ABR, 0, 0, FLA_TL );
46  FLA_Part_2x1( U, &UT,
47  &UB, 0, FLA_TOP );
48  FLA_Part_2x1( Z, &ZT,
49  &ZB, 0, FLA_TOP );
50  FLA_Part_1x2( T, &TL, &TR, 0, FLA_LEFT );
51 
52  while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) )
53  {
54  b = min( FLA_Obj_length( ABR ), b_alg );
55 
56  FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
57  /* ************* */ /* ******************** */
58  &A10, /**/ &A11, &A12,
59  ABL, /**/ ABR, &A20, /**/ &A21, &A22,
60  b, b, FLA_BR );
61  FLA_Repart_2x1_to_3x1( UT, &U0,
62  /* ** */ /* ** */
63  &U1,
64  UB, &U2, b, FLA_BOTTOM );
65  FLA_Repart_2x1_to_3x1( ZT, &Z0,
66  /* ** */ /* ** */
67  &Z1,
68  ZB, &Z2, b, FLA_BOTTOM );
69  FLA_Repart_1x2_to_1x3( TL, /**/ TR, &T0, /**/ &T1, &W12,
70  b, FLA_RIGHT );
71 
72  /*------------------------------------------------------------*/
73 
74  FLA_Part_2x2( T1, &T1_tl, &none,
75  &none2, &none3, b, b, FLA_TL );
76 
77  bb = min( FLA_Obj_length( ABR ) - 1, b_alg );
78 
79  FLA_Part_1x2( UB, &UB_l, &none, bb, FLA_LEFT );
80  FLA_Part_1x2( ZB, &ZB_l, &none, bb, FLA_LEFT );
81 
82  // [ ABR, UB, ZB, T1 ] = FLA_Hess_UT_step_unb_var5( ABR, UB, ZB, T1, b );
83  //FLA_Hess_UT_step_unb_var5( ABR, UB, ZB, T1_tl );
84  FLA_Hess_UT_step_opt_var5( ABR, UB, ZB, T1_tl );
85 
86  // ATR = ATR - ATR * UB * inv( triu ( T1 ) ) * UB' );
87  if ( FLA_Obj_length( ATR ) > 0 )
88  {
89  // NOTE: We use ZT as temporary workspace.
90  FLA_Part_1x2( ZT, &WT_l, &none, bb, FLA_LEFT );
91  FLA_Part_2x2( T1, &T1_tl, &none,
92  &none2, &none3, bb, bb, FLA_TL );
93 
94  // WT_l = ATR * UB_l * inv( triu( T1 ) ).
95  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
96  FLA_ONE, ATR, UB_l, FLA_ZERO, WT_l );
97  FLA_Trsm_external( FLA_RIGHT, FLA_UPPER_TRIANGULAR,
98  FLA_NO_TRANSPOSE, FLA_NONUNIT_DIAG, FLA_ONE, T1_tl, WT_l );
99 
100  // ATR = ATR - WT_l * UB_l'
101  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
102  FLA_MINUS_ONE, WT_l, UB_l, FLA_ONE, ATR );
103  }
104 
105  // / A12 \ = Q11' * / / A12 \ - / Z1 \ * inv( triu( T1 ) ) * U2' \
106  // \ A22 / \ \ A22 / \ Z2 / /
107  //
108  // where Q11 corresponds to the block Householder transformation
109  // associated with UB and T1.
110  if ( FLA_Obj_width( A12 ) > 0 )
111  {
112  FLA_Obj ABR2, ABR2_b;
113  FLA_Obj UB_b;
114 
115  // NOTE: Since A12.n > 0, we are guaranteed to not be at an edge case,
116  // namely the case where bb = b - 1 = ABR.m - 1, thus we are free to use
117  // the "full" matrix partitions in this scope block (ie: ZB instead of
118  // ZB_l).
119 
120  // W12 = U2'
121  // W12 = inv( triu( T1 ) ) * W12;
122  FLA_Copyt_external( FLA_CONJ_TRANSPOSE, U2, W12 );
123  FLA_Trsm_external( FLA_LEFT, FLA_UPPER_TRIANGULAR, FLA_NO_TRANSPOSE,
124  FLA_NONUNIT_DIAG, FLA_ONE, T1_tl, W12 );
125 
126  FLA_Merge_2x1( A12,
127  A22, &ABR2 );
128 
129  // / A12 \ = / A12 \ - / Z1 \ * W12
130  // \ A22 / \ A22 / \ Z2 /
131  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
132  FLA_MINUS_ONE, ZB, W12, FLA_ONE, ABR2 );
133 
134  // Omit the top row of UB so it has [implicit] unit diagonal, allowing us
135  // to use FLA_Apply_Q_UT() to apply the block Householder transformation
136  // corresponding to UB and T1. This trick is valid since the top row of
137  // ABR2 would normally be unchanged by the transformation (ie: multiplied
138  // by identity).
139  FLA_Part_2x1( UB, &none,
140  &UB_b, 1, FLA_TOP );
141  FLA_Part_2x1( ABR2, &none,
142  &ABR2_b, 1, FLA_TOP );
143 
144  // Apply Q11' to A12 and A22 from the left:
145  //
146  // / A12 \ = / I - / U1 \ * inv( triu( T1 ) ) * / U1 \' \' / A12 \
147  // \ A22 / \ \ U2 / \ U2 / / \ A22 /
148  //
149  FLA_Apply_Q_UT( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
150  UB_b, T1_tl, W12, ABR2_b );
151  }
152 
153  /*------------------------------------------------------------*/
154 
155  FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
156  A10, A11, /**/ A12,
157  /* ************** */ /* ****************** */
158  &ABL, /**/ &ABR, A20, A21, /**/ A22,
159  FLA_TL );
160  FLA_Cont_with_3x1_to_2x1( &UT, U0,
161  U1,
162  /* ** */ /* ** */
163  &UB, U2, FLA_TOP );
164  FLA_Cont_with_3x1_to_2x1( &ZT, Z0,
165  Z1,
166  /* ** */ /* ** */
167  &ZB, Z2, FLA_TOP );
168  FLA_Cont_with_1x3_to_1x2( &TL, /**/ &TR, T0, T1, /**/ W12,
169  FLA_LEFT );
170  }
171 
172  FLA_Obj_free( &U );
173  FLA_Obj_free( &Z );
174 
175  return FLA_SUCCESS;
176 }
FLA_Error FLA_Hess_UT_step_opt_var5(FLA_Obj A, FLA_Obj U, FLA_Obj Z, FLA_Obj T)
Definition: FLA_Hess_UT_opt_var5.c:29
FLA_Error FLA_Copyt_external(FLA_Trans trans, FLA_Obj A, FLA_Obj B)
Definition: FLA_Copyt_external.c:13
FLA_Error FLA_Gemm_external(FLA_Trans transa, FLA_Trans transb, FLA_Obj alpha, FLA_Obj A, FLA_Obj B, FLA_Obj beta, FLA_Obj C)
Definition: FLA_Gemm_external.c:13
FLA_Error FLA_Trsm_external(FLA_Side side, FLA_Uplo uplo, FLA_Trans trans, FLA_Diag diag, FLA_Obj alpha, FLA_Obj A, FLA_Obj B)
Definition: FLA_Trsm_external.c:13
FLA_Obj FLA_MINUS_ONE
Definition: FLA_Init.c:22
FLA_Obj FLA_ZERO
Definition: FLA_Init.c:20
FLA_Obj FLA_ONE
Definition: FLA_Init.c:18
FLA_Error FLA_Apply_Q_UT(FLA_Side side, FLA_Trans trans, FLA_Direct direct, FLA_Store storev, FLA_Obj A, FLA_Obj T, FLA_Obj W, FLA_Obj B)
Definition: FLA_Apply_Q_UT.c:16
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_Obj_create(FLA_Datatype datatype, dim_t m, dim_t n, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition: FLA_Obj.c:55
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
FLA_Error FLA_Merge_2x1(FLA_Obj AT, FLA_Obj AB, FLA_Obj *A)
Definition: FLA_View.c:541
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
int FLA_Datatype
Definition: FLA_type_defs.h:49
unsigned long dim_t
Definition: FLA_type_defs.h:71
Definition: FLA_type_defs.h:159

References FLA_Apply_Q_UT(), FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Cont_with_3x3_to_2x2(), FLA_Copyt_external(), FLA_Gemm_external(), FLA_Hess_UT_step_opt_var5(), FLA_Merge_2x1(), FLA_MINUS_ONE, FLA_Obj_create(), FLA_Obj_datatype(), FLA_Obj_free(), FLA_Obj_length(), 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_Trsm_external(), and FLA_ZERO.

Referenced by FLA_Hess_UT_internal().