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 
FLA_QR2_UT_unb_var1(FLA_Obj U,FLA_Obj D,FLA_Obj T)13 FLA_Error FLA_QR2_UT_unb_var1( FLA_Obj U,
14                                FLA_Obj D, FLA_Obj T )
15 {
16   FLA_Obj UTL,   UTR,      U00,  u01,       U02,
17           UBL,   UBR,      u10t, upsilon11, u12t,
18                            U20,  u21,       U22;
19 
20   FLA_Obj DL,    DR,       D0,  d1,  D2;
21 
22   FLA_Obj TTL,   TTR,      T00,  t01,   T02,
23           TBL,   TBR,      t10t, tau11, t12t,
24                            T20,  t21,   T22;
25 
26 
27   FLA_Part_2x2( U,    &UTL, &UTR,
28                       &UBL, &UBR,     0, 0, FLA_TL );
29 
30   FLA_Part_1x2( D,    &DL,  &DR,      0, FLA_LEFT );
31 
32   FLA_Part_2x2( T,    &TTL, &TTR,
33                       &TBL, &TBR,     0, 0, FLA_TL );
34 
35   while ( FLA_Obj_min_dim( UBR ) > 0 ){
36 
37     FLA_Repart_2x2_to_3x3( UTL, /**/ UTR,       &U00,  /**/ &u01,       &U02,
38                         /* ************* */   /* ************************** */
39                                                 &u10t, /**/ &upsilon11, &u12t,
40                            UBL, /**/ UBR,       &U20,  /**/ &u21,       &U22,
41                            1, 1, FLA_BR );
42 
43     FLA_Repart_1x2_to_1x3( DL,  /**/ DR,        &D0, /**/ &d1, &D2,
44                            1, FLA_RIGHT );
45 
46     FLA_Repart_2x2_to_3x3( TTL, /**/ TTR,       &T00,  /**/ &t01,   &T02,
47                         /* ************* */   /* ************************ */
48                                                 &t10t, /**/ &tau11, &t12t,
49                            TBL, /**/ TBR,       &T20,  /**/ &t21,   &T22,
50                            1, 1, FLA_BR );
51 
52     /*------------------------------------------------------------*/
53 
54     // Compute tau11 and u2 from upsilon11 and d1 such that tau11 and u2
55     // determine a Householder transform H such that applying H from the
56     // left to the column vector consisting of upsilon11 and d1 annihilates
57     // the entries in d1 (and updates upsilon11).
58     FLA_Househ2_UT( FLA_LEFT,
59                     upsilon11,
60                     d1, tau11 );
61 
62     // / u12t \ =  H / u12t \
63     // \  D2  /      \  D2  /
64     //
65     // where H is formed from tau11 and d1.
66     FLA_Apply_H2_UT( FLA_LEFT, tau11, d1, u12t,
67                                           D2 );
68 
69     // t01 = D0' * d1;
70     FLA_Gemv_external( FLA_CONJ_TRANSPOSE, FLA_ONE, D0, d1, FLA_ZERO, t01 );
71 
72     /*------------------------------------------------------------*/
73 
74     FLA_Cont_with_3x3_to_2x2( &UTL, /**/ &UTR,       U00,  u01,       /**/ U02,
75                                                      u10t, upsilon11, /**/ u12t,
76                             /* ************** */  /* ************************ */
77                               &UBL, /**/ &UBR,       U20,  u21,       /**/ U22,
78                               FLA_TL );
79 
80     FLA_Cont_with_1x3_to_1x2( &DL,  /**/ &DR,        D0, d1, /**/ D2,
81                               FLA_LEFT );
82 
83     FLA_Cont_with_3x3_to_2x2( &TTL, /**/ &TTR,       T00,  t01,   /**/ T02,
84                                                      t10t, tau11, /**/ t12t,
85                             /* ************** */  /* ********************** */
86                               &TBL, /**/ &TBR,       T20,  t21,   /**/ T22,
87                               FLA_TL );
88   }
89 
90   return FLA_SUCCESS;
91 }
92 
93