libflame  revision_anchor
Functions
FLA_Fill_with_linear_dist.c File Reference

(r)

Functions

FLA_Error FLA_Fill_with_linear_dist (FLA_Obj shift, FLA_Obj delta, FLA_Obj x)
 

Function Documentation

◆ FLA_Fill_with_linear_dist()

FLA_Error FLA_Fill_with_linear_dist ( FLA_Obj  shift,
FLA_Obj  delta,
FLA_Obj  x 
)
14 {
15  FLA_Obj lT, l0,
16  lB, lambda1,
17  l2;
18  FLA_Obj l, k, delta2;
19  FLA_Datatype dt_real;
20  dim_t n_x;
21 
22 
23  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
24  FLA_Fill_with_linear_dist_check( shift, delta, x );
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, &delta2 );
40  FLA_Copy( delta, delta2 );
41 
42  // Initialize k to shift + delta2.
43  FLA_Set( shift, k );
44  FLA_Mult_add( FLA_ONE, delta2, k );
45 
46  FLA_Part_2x1( l, &lT,
47  &lB, 0, FLA_TOP );
48 
49  while ( FLA_Obj_length( lB ) > 0 )
50  {
51  FLA_Repart_2x1_to_3x1( lT, &l0,
52  /* ** */ /* ******* */
53  &lambda1,
54  lB, &l2, 1, FLA_BOTTOM );
55 
56  /*------------------------------------------------------------*/
57 
58  // lambda1 = k;
59  FLA_Copy( k, lambda1 );
60 
61  // k = k + delta2;
62  FLA_Mult_add( FLA_ONE, delta2, k );
63 
64  /*------------------------------------------------------------*/
65 
66  FLA_Cont_with_3x1_to_2x1( &lT, l0,
67  lambda1,
68  /* ** */ /* ******* */
69  &lB, l2, FLA_TOP );
70  }
71 
72  // Normalize by last element.
73  //FLA_Part_2x1( l, &lT,
74  // &lB, 1, FLA_BOTTOM );
75  //FLA_Inv_scal( lB, l );
76 
77  // Overwrite x with the distribution we created in l.
78  // If x is complex, then this is where the conversion between
79  // datatypes happens.
80  FLA_Copy( l, x );
81 
82  FLA_Obj_free( &l );
83  FLA_Obj_free( &k );
84  FLA_Obj_free( &delta2 );
85 
86  return FLA_SUCCESS;
87 }
FLA_Error FLA_Fill_with_linear_dist_check(FLA_Obj shift, FLA_Obj delta, FLA_Obj x)
Definition: FLA_Fill_with_linear_dist_check.c:13
FLA_Error FLA_Copy(FLA_Obj A, FLA_Obj B)
Definition: FLA_Copy.c:15
FLA_Obj FLA_ONE
Definition: FLA_Init.c:18
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
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
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_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
FLA_Datatype FLA_Obj_datatype_proj_to_real(FLA_Obj A)
Definition: FLA_Query.c:23
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588
dim_t FLA_Obj_vector_dim(FLA_Obj obj)
Definition: FLA_Query.c:137
int FLA_Datatype
Definition: FLA_type_defs.h:49
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Mult_add(FLA_Obj alpha, FLA_Obj beta, FLA_Obj gamma)
Definition: FLA_Mult_add.c:13
FLA_Error FLA_Set(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Set.c:13
Definition: FLA_type_defs.h:159

References FLA_Check_error_level(), FLA_Cont_with_3x1_to_2x1(), FLA_Copy(), FLA_Fill_with_linear_dist_check(), 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().

Referenced by FLA_Fill_with_cluster_dist().