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 #ifdef FLA_ENABLE_NON_CRITICAL_CODE
14 
FLA_Chol_l_unb_var1(FLA_Obj A)15 FLA_Error FLA_Chol_l_unb_var1( FLA_Obj A )
16 {
17   FLA_Obj ATL,   ATR,      A00,  a01,     A02,
18           ABL,   ABR,      a10t, alpha11, a12t,
19                            A20,  a21,     A22;
20 
21   int r_val = FLA_SUCCESS;
22 
23   FLA_Part_2x2( A,    &ATL, &ATR,
24                       &ABL, &ABR,     0, 0, FLA_TL );
25 
26   while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) ){
27 
28     FLA_Repart_2x2_to_3x3( ATL, /**/ ATR,       &A00,  /**/ &a01,     &A02,
29                         /* ************* */   /* ************************** */
30                                                 &a10t, /**/ &alpha11, &a12t,
31                            ABL, /**/ ABR,       &A20,  /**/ &a21,     &A22,
32                            1, 1, FLA_BR );
33 
34     /*------------------------------------------------------------*/
35 
36     // a10t = a10t * inv( tril( A00 )' )
37     // a10t' = inv( conj( tril( A00 ) ) ) * a10t'
38     FLA_Trsv_external( FLA_LOWER_TRIANGULAR, FLA_CONJ_NO_TRANSPOSE, FLA_NONUNIT_DIAG, A00, a10t );
39 
40     // alpha11 = alpha11 - a10t * a10t'
41     FLA_Dotcs_external( FLA_CONJUGATE, FLA_MINUS_ONE, a10t, a10t, FLA_ONE, alpha11 );
42 
43     // alpha11 = sqrt( alpha11 )
44     r_val = FLA_Sqrt( alpha11 );
45 
46     if ( r_val != FLA_SUCCESS )
47       return ( FLA_Obj_length( A00 ) );
48 
49     /*------------------------------------------------------------*/
50 
51     FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR,       A00,  a01,     /**/ A02,
52                                                      a10t, alpha11, /**/ a12t,
53                             /* ************** */  /* ************************ */
54                               &ABL, /**/ &ABR,       A20,  a21,     /**/ A22,
55                               FLA_TL );
56   }
57 
58   return r_val;
59 }
60 
61 #endif
62