libflame revision_anchor
Functions
FLA_Sort.c File Reference

(r)

Functions

int fla_scomp_f (const void *a, const void *b)
 
int fla_scomp_b (const void *a, const void *b)
 
int fla_dcomp_f (const void *a, const void *b)
 
int fla_dcomp_b (const void *a, const void *b)
 
FLA_Error FLA_Sort (FLA_Direct direct, FLA_Obj x)
 
FLA_Error FLA_Sort_f_ops (int m_x, float *x, int inc_x)
 
FLA_Error FLA_Sort_b_ops (int m_x, float *x, int inc_x)
 
FLA_Error FLA_Sort_f_opd (int m_x, double *x, int inc_x)
 
FLA_Error FLA_Sort_b_opd (int m_x, double *x, int inc_x)
 

Function Documentation

◆ fla_dcomp_b()

int fla_dcomp_b ( const void a,
const void b 
)
176{
177 double* da = ( double* ) a;
178 double* db = ( double* ) b;
179 int r_val;
180
181 if ( *da < *db ) r_val = 1;
182 else if ( *da > *db ) r_val = -1;
183 else r_val = 0;
184
185 return r_val;
186}
int i
Definition bl1_axmyv2.c:145

References i.

Referenced by FLA_Sort_b_opd().

◆ fla_dcomp_f()

int fla_dcomp_f ( const void a,
const void b 
)
163{
164 double* da = ( double* ) a;
165 double* db = ( double* ) b;
166 int r_val;
167
168 if ( *da < *db ) r_val = -1;
169 else if ( *da > *db ) r_val = 1;
170 else r_val = 0;
171
172 return r_val;
173}

References i.

Referenced by FLA_Sort_f_opd().

◆ fla_scomp_b()

int fla_scomp_b ( const void a,
const void b 
)
150{
151 float* da = ( float* ) a;
152 float* db = ( float* ) b;
153 int r_val;
154
155 if ( *da < *db ) r_val = 1;
156 else if ( *da > *db ) r_val = -1;
157 else r_val = 0;
158
159 return r_val;
160}

References i.

Referenced by FLA_Sort_b_ops().

◆ fla_scomp_f()

int fla_scomp_f ( const void a,
const void b 
)
137{
138 float* da = ( float* ) a;
139 float* db = ( float* ) b;
140 int r_val;
141
142 if ( *da < *db ) r_val = -1;
143 else if ( *da > *db ) r_val = 1;
144 else r_val = 0;
145
146 return r_val;
147}

References i.

Referenced by FLA_Sort_f_ops().

◆ FLA_Sort()

FLA_Error FLA_Sort ( FLA_Direct  direct,
FLA_Obj  x 
)
19{
20 FLA_Datatype datatype;
22 dim_t m_x;
24
27
28 datatype = FLA_Obj_datatype( x );
29
32
33 // If the vector does not have unit stride, copy it to a temporary vector
34 // that does have unit stride.
35 if ( inc_x != 1 )
36 {
39 }
40 else
41 {
42 x_use = x;
43 }
44
45 switch ( datatype )
46 {
47 case FLA_FLOAT:
48 {
49 float* x_p = ( float* ) FLA_FLOAT_PTR( x_use );
50
51 if ( direct == FLA_FORWARD )
53 x_p, inc_x );
54 else // if ( direct == FLA_BACKWARD )
56 x_p, inc_x );
57
58 break;
59 }
60
61 case FLA_DOUBLE:
62 {
63 double* x_p = ( double* ) FLA_DOUBLE_PTR( x_use );
64
65 if ( direct == FLA_FORWARD )
67 x_p, inc_x );
68 else // if ( direct == FLA_BACKWARD )
70 x_p, inc_x );
71
72 break;
73 }
74
75 }
76
77 if ( inc_x != 1 )
78 {
79 FLA_Copy( x_use, x );
81 }
82
83 return FLA_SUCCESS;
84}
FLA_Error FLA_Sort_f_opd(int m_x, double *x, int inc_x)
Definition FLA_Sort.c:110
FLA_Error FLA_Sort_b_opd(int m_x, double *x, int inc_x)
Definition FLA_Sort.c:121
FLA_Error FLA_Sort_f_ops(int m_x, float *x, int inc_x)
Definition FLA_Sort.c:88
FLA_Error FLA_Sort_b_ops(int m_x, float *x, int inc_x)
Definition FLA_Sort.c:99
FLA_Error FLA_Sort_check(FLA_Direct direct, FLA_Obj x)
Definition FLA_Sort_check.c:13
FLA_Error FLA_Copy(FLA_Obj A, FLA_Obj B)
Definition FLA_Copy.c:15
FLA_Error FLA_Obj_create_copy_of(FLA_Trans trans, FLA_Obj old, FLA_Obj *obj)
Definition FLA_Obj.c:345
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_inc(FLA_Obj obj)
Definition FLA_Query.c:145
dim_t FLA_Obj_vector_dim(FLA_Obj obj)
Definition FLA_Query.c:137
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_Check_error_level(), FLA_Copy(), FLA_Obj_create_copy_of(), FLA_Obj_datatype(), FLA_Obj_free(), FLA_Obj_vector_dim(), FLA_Obj_vector_inc(), FLA_Sort_b_opd(), FLA_Sort_b_ops(), FLA_Sort_check(), FLA_Sort_f_opd(), FLA_Sort_f_ops(), and i.

Referenced by FLA_Fill_with_cluster_dist(), and FLA_Sort_bsvd_ext().

◆ FLA_Sort_b_opd()

FLA_Error FLA_Sort_b_opd ( int  m_x,
double x,
int  inc_x 
)
123{
124 qsort( x,
125 m_x,
126 sizeof( double ),
127 fla_dcomp_b );
128
129 return FLA_SUCCESS;
130}
int fla_dcomp_b(const void *a, const void *b)
Definition FLA_Sort.c:175

References fla_dcomp_b(), and i.

Referenced by FLA_Sort().

◆ FLA_Sort_b_ops()

FLA_Error FLA_Sort_b_ops ( int  m_x,
float x,
int  inc_x 
)
101{
102 qsort( x,
103 m_x,
104 sizeof( float ),
105 fla_scomp_b );
106
107 return FLA_SUCCESS;
108}
int fla_scomp_b(const void *a, const void *b)
Definition FLA_Sort.c:149

References fla_scomp_b(), and i.

Referenced by FLA_Sort().

◆ FLA_Sort_f_opd()

FLA_Error FLA_Sort_f_opd ( int  m_x,
double x,
int  inc_x 
)
112{
113 qsort( x,
114 m_x,
115 sizeof( double ),
116 fla_dcomp_f );
117
118 return FLA_SUCCESS;
119}
int fla_dcomp_f(const void *a, const void *b)
Definition FLA_Sort.c:162

References fla_dcomp_f(), and i.

Referenced by FLA_Sort().

◆ FLA_Sort_f_ops()

FLA_Error FLA_Sort_f_ops ( int  m_x,
float x,
int  inc_x 
)
90{
91 qsort( x,
92 m_x,
93 sizeof( float ),
95
96 return FLA_SUCCESS;
97}
int fla_scomp_f(const void *a, const void *b)
Definition FLA_Sort.c:136

References fla_scomp_f(), and i.

Referenced by FLA_Sort().