libflame  revision_anchor
Functions
FLASH_Obj_create_diag_panel.c File Reference

(r)

Functions

FLA_Error FLASH_Obj_create_diag_panel (FLA_Obj A, FLA_Obj *U)
 

Function Documentation

◆ FLASH_Obj_create_diag_panel()

FLA_Error FLASH_Obj_create_diag_panel ( FLA_Obj  A,
FLA_Obj U 
)
14 {
15  FLA_Datatype datatype;
16  dim_t b_flash;
17  dim_t b_flash_last;
18  dim_t n_blocks_min_dim;
19  dim_t m_U, n_U;
20 
21  // Acquire the datatype of the matrix to be factored.
22  datatype = FLA_Obj_datatype( A );
23 
24  // Acquire the storage blocksize of the top-left element.
25  b_flash = FLASH_Obj_scalar_length_tl( A );
26 
27  // Get the number of storage blocks in the minimum dimension of A.
28  n_blocks_min_dim = FLA_Obj_min_dim( A );
29 
30  // Compute the scalar length and width of U.
31  m_U = b_flash;
32  n_U = n_blocks_min_dim * b_flash;
33 
34  // Create U with storage blocksize of b_flash.
35  FLASH_Obj_create( datatype, m_U, n_U, 1, &b_flash, U );
36 
37  // The last, bottom-right-most diagonal block of A might be smaller
38  // than the other diagonal blocks. Compute the size of this block.
39  b_flash_last = FLASH_Obj_scalar_min_dim( A ) % b_flash;
40 
41  // If the remainder is zero, then A does not need its last block
42  // shrunk and thus it is ready as-is. However, if b_flash_last is
43  // non-zero, then we must manually adjust the size of the last block of
44  // U. Note that we are not freeing and re-allocating memory, just
45  // changing the size of the view into the last block.
46 
47  if ( b_flash_last > 0 )
48  {
49  FLA_Obj UL, UR;
50  FLA_Obj URTL, URTR,
51  URBL, URBR;
52  FLA_Obj* UR_p;
53 
54  // Repartition U so we can access the last block object.
55  FLA_Part_1x2( *U, &UL, &UR, 1, FLA_RIGHT );
56 
57  // Dereference the 1x1 object reference to get a pointer to
58  // the actual block object in U.
59  UR_p = FLASH_OBJ_PTR_AT( UR );
60 
61  // Repartition the last block object so that URTL is the
62  // correct size.
63  FLA_Part_2x2( *UR_p, &URTL, &URTR,
64  &URBL, &URBR, b_flash_last,
65  b_flash_last, FLA_TL );
66 
67  // Overwrite the original object pointed to by UR_p with the
68  // corrected object URTL.
69  *UR_p = URTL;
70  }
71 
72  return FLA_SUCCESS;
73 }
dim_t FLASH_Obj_scalar_length_tl(FLA_Obj H)
Definition: FLASH_View.c:723
FLA_Error FLASH_Obj_create(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_mn, FLA_Obj *H)
Definition: FLASH_Obj.c:143
dim_t FLASH_Obj_scalar_min_dim(FLA_Obj H)
Definition: FLASH_View.c:675
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_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:110
dim_t FLA_Obj_min_dim(FLA_Obj obj)
Definition: FLA_Query.c:153
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
int FLA_Datatype
Definition: FLA_type_defs.h:49
unsigned long dim_t
Definition: FLA_type_defs.h:71
Definition: FLA_type_defs.h:159

References FLA_Obj_datatype(), FLA_Obj_min_dim(), FLA_Part_1x2(), FLA_Part_2x2(), FLASH_Obj_create(), FLASH_Obj_scalar_length_tl(), and FLASH_Obj_scalar_min_dim().

Referenced by FLASH_LU_incpiv_opt1(), and FLASH_QR_UT_inc_opt1().