Debian Codegraph @

src/lapack/dec/q/lqut/vars/flamec/FLA_LQ_UT_blk_var2.c

raw
1 /*
2
3 Copyright (C) 2014, The University of Texas at Austin
4
5 This file is part of libflame and is available under the 3-Clause
6 BSD license, which can be found in the LICENSE file at the top-level
7 directory, or at http://opensource.org/licenses/BSD-3-Clause
8
9 */
10
11 #include "FLAME.h"
12
13 FLA_Error FLA_LQ_UT_blk_var2( FLA_Obj A, FLA_Obj T, fla_lqut_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 TTL, TTR, T00, T01, T02,
20 TBL, TBR, T10, T11, W12,
21 T20, T21, T22;
22
23 FLA_Obj AR1,
24 AR2;
25
26 dim_t b;
27
28 FLA_Part_2x2( A, &ATL, &ATR,
29 &ABL, &ABR, 0, 0, FLA_TL );
30
31 FLA_Part_2x2( T, &TTL, &TTR,
32 &TBL, &TBR, 0, 0, FLA_TL );
33
34 while ( FLA_Obj_min_dim( ABR ) > 0 ){
35
36 b = FLA_Determine_blocksize( ABR, FLA_BR, FLA_Cntl_blocksize( cntl ) );
37
38 FLA_Repart_2x2_to_3x3( ATL, /**/ ATR, &A00, /**/ &A01, &A02,
39 /* ************* */ /* ******************** */
40 &A10, /**/ &A11, &A12,
41 ABL, /**/ ABR, &A20, /**/ &A21, &A22,
42 b, b, FLA_BR );
43
44 FLA_Repart_2x2_to_3x3( TTL, /**/ TTR, &T00, /**/ &T01, &T02,
45 /* ************* */ /* ******************** */
46 &T10, /**/ &T11, &W12,
47 TBL, /**/ TBR, &T20, /**/ &T21, &T22,
48 b, b, FLA_BR );
49
50 /*------------------------------------------------------------*/
51
52 FLA_Merge_1x2( A11, A12, &AR1 );
53
54 // Perform an LQ factorization via the UT transform on AR1:
55 //
56 // ( A11 A12 ) -> L11 QR1
57 //
58 // where:
59 // - QR1 is formed from UR1 (which is stored row-wise above the
60 // diagonal of AR1) and T11 (which is stored to the upper triangle
61 // of T11).
62 // - L11 is stored to the lower triangle of AR1.
63
64 FLA_LQ_UT_internal( AR1, T11,
65 FLA_Cntl_sub_lqut( cntl ) );
66
67
68 if ( FLA_Obj_length( A21 ) > 0 )
69 {
70 FLA_Merge_1x2( A21, A22, &AR2 );
71
72 // Apply the Householder transforms associated with UR1 and T11 to
73 // AR2:
74 //
75 // ( A21 A22 ) := ( A21 A22 ) Q1
76 //
77 // where QR1 is formed from UR1 and T11.
78
79 FLA_Apply_Q_UT_internal( FLA_RIGHT, FLA_NO_TRANSPOSE, FLA_FORWARD, FLA_ROWWISE,
80 AR1, T11, W12, AR2,
81 FLA_Cntl_sub_apqut( cntl ) );
82 }
83
84
85 // Update T
86 //
87 // T01 = conj(A01) * U11^T + conj(A02) * U12^T;
88 //
89 // Recall: U11 = triuu( A11 );
90 // U12 = A12;
91
92 FLA_Copyt_external( FLA_CONJ_NO_TRANSPOSE, A01, T01 );
93 FLA_Trmm_external( FLA_RIGHT, FLA_UPPER_TRIANGULAR,
94 FLA_TRANSPOSE, FLA_UNIT_DIAG,
95 FLA_ONE, A11, T01 );
96 FLA_Gemm_external( FLA_CONJ_NO_TRANSPOSE, FLA_TRANSPOSE,
97 FLA_ONE, A02, A12, FLA_ONE, T01 );
98
99 /*------------------------------------------------------------*/
100
101 FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR, A00, A01, /**/ A02,
102 A10, A11, /**/ A12,
103 /* ************** */ /* ****************** */
104 &ABL, /**/ &ABR, A20, A21, /**/ A22,
105 FLA_TL );
106
107 FLA_Cont_with_3x3_to_2x2( &TTL, /**/ &TTR, T00, T01, /**/ T02,
108 T10, T11, /**/ W12,
109 /* ************** */ /* ****************** */
110 &TBL, /**/ &TBR, T20, T21, /**/ T22,
111 FLA_TL );
112 }
113
114 return FLA_SUCCESS;
115 }
116