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_Apply_CAQ_UT_inc_apply_panels(dim_t nb_part,FLA_Obj A,FLA_Obj TW,FLA_Obj W,FLA_Obj B)13 FLA_Error FLA_Apply_CAQ_UT_inc_apply_panels( dim_t nb_part, FLA_Obj A, FLA_Obj TW, FLA_Obj W, FLA_Obj B )
14 {
15   FLA_Obj AT,              A0,
16           AB,              A1,
17                            A2;
18 
19   FLA_Obj TWT,             TW0,
20           TWB,             TW1,
21                            TW2;
22 
23   FLA_Obj WT,              W0,
24           WB,              W1,
25                            W2;
26 
27   FLA_Obj BT,              B0,
28           BB,              B1,
29                            B2;
30 
31   dim_t b;
32 
33   FLA_Part_2x1( A,    &AT,
34                       &AB,            0, FLA_TOP );
35 
36   FLA_Part_2x1( TW,   &TWT,
37                       &TWB,           0, FLA_TOP );
38 
39   FLA_Part_2x1( W,    &WT,
40                       &WB,            0, FLA_TOP );
41 
42   FLA_Part_2x1( B,    &BT,
43                       &BB,            0, FLA_TOP );
44 
45   while ( FLA_Obj_length( AB ) > 0 ){
46 
47     b = min( nb_part, FLA_Obj_length( AB ) );
48 
49     FLA_Repart_2x1_to_3x1( AT,                &A0,
50                         /* ** */            /* ** */
51                                               &A1,
52                            AB,                &A2,        b, FLA_BOTTOM );
53 
54     FLA_Repart_2x1_to_3x1( TWT,               &TW0,
55                         /* ** */            /* ** */
56                                               &TW1,
57                            TWB,               &TW2,       b, FLA_BOTTOM );
58 
59     // NOTE: we use a blocksize of 1 for W since it has exactly nb_part
60     // rows (where each row is a row panels of b_alg x b_flash blocks).
61     FLA_Repart_2x1_to_3x1( WT,                &W0,
62                         /* ** */            /* ** */
63                                               &W1,
64                            WB,                &W2,        1, FLA_BOTTOM );
65 
66     FLA_Repart_2x1_to_3x1( BT,                &B0,
67                         /* ** */            /* ** */
68                                               &B1,
69                            BB,                &B2,        b, FLA_BOTTOM );
70 
71     /*------------------------------------------------------------*/
72 
73     // Apply incremental Q's associated with each block A1 to the
74     // corresponding block of right-hand side B1.
75     FLASH_Apply_Q_UT_inc( FLA_LEFT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_COLUMNWISE,
76                           A1, TW1, W1, B1 );
77 
78     /*------------------------------------------------------------*/
79 
80     FLA_Cont_with_3x1_to_2x1( &AT,               A0,
81                                                  A1,
82                             /* ** */          /* ** */
83                               &AB,               A2,      FLA_TOP );
84 
85     FLA_Cont_with_3x1_to_2x1( &TWT,              TW0,
86                                                  TW1,
87                             /* ** */          /* ** */
88                               &TWB,              TW2,     FLA_TOP );
89 
90     FLA_Cont_with_3x1_to_2x1( &WT,                W0,
91                                                   W1,
92                             /* ** */           /* ** */
93                               &WB,                W2,     FLA_TOP );
94 
95     FLA_Cont_with_3x1_to_2x1( &BT,                B0,
96                                                   B1,
97                             /* ** */           /* ** */
98                               &BB,                B2,     FLA_TOP );
99   }
100 
101   return FLA_SUCCESS;
102 }
103 
104