libflame  revision_anchor
Functions
FLA_Hess_UT_blk_var4.c File Reference

(r)

Functions

FLA_Error FLA_Hess_UT_blk_var4 (FLA_Obj A, FLA_Obj T)
 

Function Documentation

◆ FLA_Hess_UT_blk_var4()

FLA_Error FLA_Hess_UT_blk_var4 ( FLA_Obj  A,
FLA_Obj  T 
)

References FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Cont_with_3x3_to_2x2(), FLA_Copy_external(), FLA_Gemm_external(), FLA_Hess_UT_step_opt_var4(), FLA_MINUS_ONE, FLA_Obj_create(), FLA_Obj_datatype(), FLA_Obj_free(), FLA_Obj_length(), 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_Set(), FLA_Triangularize(), FLA_Trsm_external(), and FLA_ZERO.

Referenced by FLA_Hess_UT_internal().

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 YT, Y0,
22  YB, Y1,
23  Y2;
24  FLA_Obj ZT, Z0,
25  ZB, Z1,
26  Z2;
27  FLA_Obj TL, TR, T0, T1, T2;
28 
29  FLA_Obj U, Y, Z;
30  FLA_Obj ABR_l;
31  FLA_Obj UB_l, U2_l;
32  FLA_Obj YB_l, Y2_l;
33  FLA_Obj ZB_l, Z2_l;
34  FLA_Obj WT_l;
35  FLA_Obj T1_tl;
36  FLA_Obj none, none2, none3;
37  FLA_Obj UB_tl,
38  UB_bl;
39  FLA_Datatype datatype_A;
40  dim_t m_A;
41  dim_t b_alg, b, bb;
42 
43  b_alg = FLA_Obj_length( T );
44 
45  datatype_A = FLA_Obj_datatype( A );
46  m_A = FLA_Obj_length( A );
47 
48  FLA_Obj_create( datatype_A, m_A, b_alg, 0, 0, &U );
49  FLA_Obj_create( datatype_A, m_A, b_alg, 0, 0, &Y );
50  FLA_Obj_create( datatype_A, m_A, b_alg, 0, 0, &Z );
51 
52  FLA_Part_2x2( A, &ATL, &ATR,
53  &ABL, &ABR, 0, 0, FLA_TL );
54  FLA_Part_2x1( U, &UT,
55  &UB, 0, FLA_TOP );
56  FLA_Part_2x1( Y, &YT,
57  &YB, 0, FLA_TOP );
58  FLA_Part_2x1( Z, &ZT,
59  &ZB, 0, FLA_TOP );
60  FLA_Part_1x2( T, &TL, &TR, 0, FLA_LEFT );
61 
62  while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) )
63  {
64  b = min( FLA_Obj_length( ABR ), b_alg );
65 
66  FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
67  /* ************* */ /* ******************** */
68  &A10, /**/ &A11, &A12,
69  ABL, /**/ ABR, &A20, /**/ &A21, &A22,
70  b, b, FLA_BR );
71  FLA_Repart_2x1_to_3x1( UT, &U0,
72  /* ** */ /* ** */
73  &U1,
74  UB, &U2, b, FLA_BOTTOM );
75  FLA_Repart_2x1_to_3x1( YT, &Y0,
76  /* ** */ /* ** */
77  &Y1,
78  YB, &Y2, b, FLA_BOTTOM );
79  FLA_Repart_2x1_to_3x1( ZT, &Z0,
80  /* ** */ /* ** */
81  &Z1,
82  ZB, &Z2, b, FLA_BOTTOM );
83  FLA_Repart_1x2_to_1x3( TL, /**/ TR, &T0, /**/ &T1, &T2,
84  b, FLA_RIGHT );
85 
86  /*------------------------------------------------------------*/
87 
88  FLA_Part_2x2( T1, &T1_tl, &none,
89  &none2, &none3, b, b, FLA_TL );
90 
91  bb = min( FLA_Obj_length( ABR ) - 1, b_alg );
92 
93  FLA_Part_1x2( ABR, &ABR_l, &none, bb, FLA_LEFT );
94  FLA_Part_1x2( UB, &UB_l, &none, bb, FLA_LEFT );
95  FLA_Part_1x2( YB, &YB_l, &none, bb, FLA_LEFT );
96  FLA_Part_1x2( ZB, &ZB_l, &none, bb, FLA_LEFT );
97 
98  FLA_Part_2x1( UB_l, &none,
99  &U2_l, b, FLA_TOP );
100  FLA_Part_2x1( YB_l, &none,
101  &Y2_l, b, FLA_TOP );
102  FLA_Part_2x1( ZB_l, &none,
103  &Z2_l, b, FLA_TOP );
104 
105  // [ ABR, YB, ZB, T1 ] = FLA_Hess_UT_step_unb_var4( ABR, YB, ZB, T1, b );
106  //FLA_Hess_UT_step_unb_var4( ABR, YB, ZB, T1_tl );
107  //FLA_Hess_UT_step_ofu_var4( ABR, YB, ZB, T1_tl );
108  FLA_Hess_UT_step_opt_var4( ABR, YB, ZB, T1_tl );
109 
110  // Build UB from ABR, with explicit unit subdiagonal and zeros.
111  FLA_Copy_external( ABR_l, UB_l );
112  FLA_Part_2x1( UB_l, &UB_tl,
113  &UB_bl, 1, FLA_TOP );
114  FLA_Triangularize( FLA_LOWER_TRIANGULAR, FLA_UNIT_DIAG, UB_bl );
115  FLA_Set( FLA_ZERO, UB_tl );
116 
117  // ATR = ATR - ATR * UB * inv( triu( T ) ) * UB' );
118  if ( FLA_Obj_length( ATR ) > 0 )
119  {
120  // NOTE: We use ZT as temporary workspace.
121  FLA_Part_1x2( ZT, &WT_l, &none, bb, FLA_LEFT );
122  FLA_Part_2x2( T1, &T1_tl, &none,
123  &none2, &none3, bb, bb, FLA_TL );
124 
125  // WT_l = ATR * UB_l * inv( triu( T ) ).
126  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
127  FLA_ONE, ATR, UB_l, FLA_ZERO, WT_l );
128  FLA_Trsm_external( FLA_RIGHT, FLA_UPPER_TRIANGULAR,
129  FLA_NO_TRANSPOSE, FLA_NONUNIT_DIAG, FLA_ONE, T1_tl, WT_l );
130 
131  // ATR = ATR - WT_l * UB_l'
132  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
133  FLA_MINUS_ONE, WT_l, UB_l, FLA_ONE, ATR );
134  }
135 
136  // A22 = A22 - U2 * Y2' - Z2 * U2';
137  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
138  FLA_MINUS_ONE, U2_l, Y2_l, FLA_ONE, A22 );
139  FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
140  FLA_MINUS_ONE, Z2_l, U2_l, FLA_ONE, A22 );
141 
142  /*------------------------------------------------------------*/
143 
144  FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
145  A10, A11, /**/ A12,
146  /* ************** */ /* ****************** */
147  &ABL, /**/ &ABR, A20, A21, /**/ A22,
148  FLA_TL );
149  FLA_Cont_with_3x1_to_2x1( &UT, U0,
150  U1,
151  /* ** */ /* ** */
152  &UB, U2, FLA_TOP );
153  FLA_Cont_with_3x1_to_2x1( &YT, Y0,
154  Y1,
155  /* ** */ /* ** */
156  &YB, Y2, FLA_TOP );
157  FLA_Cont_with_3x1_to_2x1( &ZT, Z0,
158  Z1,
159  /* ** */ /* ** */
160  &ZB, Z2, FLA_TOP );
161  FLA_Cont_with_1x3_to_1x2( &TL, /**/ &TR, T0, T1, /**/ T2,
162  FLA_LEFT );
163  }
164 
165  FLA_Obj_free( &U );
166  FLA_Obj_free( &Y );
167  FLA_Obj_free( &Z );
168 
169  return FLA_SUCCESS;
170 }
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_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
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588
FLA_Error FLA_Hess_UT_step_opt_var4(FLA_Obj A, FLA_Obj Y, FLA_Obj Z, FLA_Obj T)
Definition: FLA_Hess_UT_opt_var4.c:29
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_Copy_external(FLA_Obj A, FLA_Obj B)
Definition: FLA_Copy_external.c:13
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
Definition: FLA_type_defs.h:158
FLA_Error FLA_Set(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Set.c:13
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_Triangularize(FLA_Uplo uplo, FLA_Diag diag, FLA_Obj A)
Definition: FLA_Triangularize.c:13
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
int FLA_Datatype
Definition: FLA_type_defs.h:49
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_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
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
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_Obj FLA_ZERO
Definition: FLA_Init.c:20