libflame  revision_anchor
Functions
FLA_Fill_with_inverse_dist.c File Reference

(r)

Functions

FLA_Error FLA_Fill_with_inverse_dist (FLA_Obj alpha, FLA_Obj x)
 

Function Documentation

◆ FLA_Fill_with_inverse_dist()

FLA_Error FLA_Fill_with_inverse_dist ( FLA_Obj  alpha,
FLA_Obj  x 
)

References alpha2, FLA_Check_error_level(), FLA_Cont_with_3x1_to_2x1(), FLA_Copy(), FLA_Fill_with_inverse_dist_check(), FLA_Inv_scal(), FLA_Invert(), FLA_Mult_add(), FLA_Obj_create(), FLA_Obj_datatype_proj_to_real(), FLA_Obj_free(), FLA_Obj_length(), FLA_Obj_vector_dim(), FLA_ONE, FLA_Part_2x1(), FLA_Repart_2x1_to_3x1(), and FLA_Set().

14 {
15  FLA_Obj lT, l0,
16  lB, lambda1,
17  l2;
18  FLA_Obj l, k, alpha2;
19  FLA_Datatype dt_real;
20  dim_t n_x;
21 
22 
23  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
25 
26  dt_real = FLA_Obj_datatype_proj_to_real( x );
27  n_x = FLA_Obj_vector_dim( x );
28 
29  // Create a local counter to increment as we create the distribution.
30  FLA_Obj_create( dt_real, 1, 1, 0, 0, &k );
31 
32  // Create a local vector l. We will work with this vector, which is
33  // the same length as x, so that we can use vertical partitioning.
34  FLA_Obj_create( dt_real, n_x, 1, 0, 0, &l );
35 
36  // Create a local real scalar alpha2 of the same precision as
37  // alpha. Then copy alpha to alpha2, which will convert the
38  // complex value to real, if necessary (ie: if alpha is complex).
39  FLA_Obj_create( dt_real, 1, 1, 0, 0, &alpha2 );
40  FLA_Copy( alpha, alpha2 );
41 
42  // Initialize k to 1.
43  FLA_Set( FLA_ONE, k );
44 
45  FLA_Part_2x1( l, &lT,
46  &lB, 0, FLA_TOP );
47 
48  while ( FLA_Obj_length( lB ) > 0 )
49  {
50  FLA_Repart_2x1_to_3x1( lT, &l0,
51  /* ** */ /* ******* */
52  &lambda1,
53  lB, &l2, 1, FLA_BOTTOM );
54 
55  /*------------------------------------------------------------*/
56 
57  // lambda1 = alpha2 / k;
58  FLA_Copy( k, lambda1 );
59  FLA_Inv_scal( alpha2, lambda1 );
60  FLA_Invert( FLA_NO_CONJUGATE, lambda1 );
61 
62  // k = k + 1;
64 
65  /*------------------------------------------------------------*/
66 
67  FLA_Cont_with_3x1_to_2x1( &lT, l0,
68  lambda1,
69  /* ** */ /* ******* */
70  &lB, l2, FLA_TOP );
71  }
72 
73  // Overwrite x with the distribution we created in l.
74  // If x is complex, then this is where the conversion between
75  // datatypes happens.
76  FLA_Copy( l, x );
77 
78  FLA_Obj_free( &l );
79  FLA_Obj_free( &k );
80  FLA_Obj_free( &alpha2 );
81 
82  return FLA_SUCCESS;
83 }
FLA_Error FLA_Obj_create(FLA_Datatype datatype, dim_t m, dim_t n, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition: FLA_Obj.c:55
FLA_Error FLA_Repart_2x1_to_3x1(FLA_Obj AT, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj AB, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:226
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588
FLA_Error FLA_Copy(FLA_Obj A, FLA_Obj B)
Definition: FLA_Copy.c:15
FLA_Error FLA_Cont_with_3x1_to_2x1(FLA_Obj *AT, FLA_Obj A0, FLA_Obj A1, FLA_Obj *AB, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:428
double *restrict alpha2
Definition: bl1_dotv2axpyv2b.c:186
FLA_Obj FLA_ONE
Definition: FLA_Init.c:18
Definition: FLA_type_defs.h:158
FLA_Error FLA_Set(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Set.c:13
FLA_Error FLA_Invert(FLA_Conj conj, FLA_Obj x)
Definition: FLA_Invert.c:13
FLA_Datatype FLA_Obj_datatype_proj_to_real(FLA_Obj A)
Definition: FLA_Query.c:23
FLA_Error FLA_Inv_scal(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Inv_scal.c:13
FLA_Error FLA_Fill_with_inverse_dist_check(FLA_Obj alpha, FLA_Obj x)
Definition: FLA_Fill_with_inverse_dist_check.c:13
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
dim_t FLA_Obj_vector_dim(FLA_Obj obj)
Definition: FLA_Query.c:137
FLA_Error FLA_Mult_add(FLA_Obj alpha, FLA_Obj beta, FLA_Obj gamma)
Definition: FLA_Mult_add.c:13
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116