libflame  revision_anchor
Functions
FLA_Fill_with_random_dist.c File Reference

(r)

Functions

FLA_Error FLA_Fill_with_random_dist (FLA_Obj shift, FLA_Obj max, FLA_Obj x)
 

Function Documentation

◆ FLA_Fill_with_random_dist()

FLA_Error FLA_Fill_with_random_dist ( FLA_Obj  shift,
FLA_Obj  max,
FLA_Obj  x 
)

References FLA_Axpy(), FLA_Check_error_level(), FLA_Copy(), FLA_Fill_with_random_dist_check(), FLA_Obj_create(), FLA_Obj_datatype_proj_to_real(), FLA_Obj_free(), FLA_Obj_vector_dim(), FLA_ONE, FLA_ONE_HALF, FLA_Random_matrix(), FLA_Scal(), and FLA_Set().

Referenced by FLA_Fill_with_cluster_dist().

14 {
15  FLA_Obj r, y;
16  FLA_Datatype dt_real;
17  dim_t n_x;
18 
19  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
20  FLA_Fill_with_random_dist_check( shift, max, x );
21 
22  dt_real = FLA_Obj_datatype_proj_to_real( x );
23  n_x = FLA_Obj_vector_dim( x );
24 
25  FLA_Obj_create( dt_real, n_x, 1, 0, 0, &r );
26  FLA_Obj_create( dt_real, n_x, 1, 0, 0, &y );
27 
28  FLA_Random_matrix( r );
29 
30  FLA_Set( FLA_ONE, y );
31  FLA_Axpy( FLA_ONE, r, y );
32  FLA_Scal( FLA_ONE_HALF, y );
33  FLA_Scal( max, y );
34 
35  FLA_Set( shift, r );
36  FLA_Axpy( FLA_ONE, y, r );
37 
38  // Overwrite x with the distribution we created in l.
39  // If x is complex, then this is where the conversion between
40  // datatypes happens.
41  FLA_Copy( r, x );
42 
43  FLA_Obj_free( &r );
44  FLA_Obj_free( &y );
45 
46  return FLA_SUCCESS;
47 }
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
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_Fill_with_random_dist_check(FLA_Obj shift, FLA_Obj max, FLA_Obj x)
Definition: FLA_Fill_with_random_dist_check.c:13
FLA_Obj FLA_ONE_HALF
Definition: FLA_Init.c:19
FLA_Obj FLA_ONE
Definition: FLA_Init.c:18
FLA_Error FLA_Random_matrix(FLA_Obj A)
Definition: FLA_Random_matrix.c:13
Definition: FLA_type_defs.h:158
FLA_Error FLA_Set(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Set.c:13
FLA_Error FLA_Scal(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Scal.c:15
FLA_Datatype FLA_Obj_datatype_proj_to_real(FLA_Obj A)
Definition: FLA_Query.c:23
FLA_Error FLA_Axpy(FLA_Obj alpha, FLA_Obj A, FLA_Obj B)
Definition: FLA_Axpy.c:15
dim_t FLA_Obj_vector_dim(FLA_Obj obj)
Definition: FLA_Query.c:137
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49