libflame  revision_anchor
Functions
FLA_Sort_svd.c File Reference

(r)

Functions

FLA_Error FLA_Sort_svd (FLA_Direct direct, FLA_Obj s, FLA_Obj U, FLA_Obj V)
 
FLA_Error FLA_Sort_svd_f_ops (int m_U, int n_V, float *s, int inc_s, float *U, int rs_U, int cs_U, float *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_b_ops (int m_U, int n_V, float *s, int inc_s, float *U, int rs_U, int cs_U, float *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_f_opd (int m_U, int n_V, double *s, int inc_s, double *U, int rs_U, int cs_U, double *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_b_opd (int m_U, int n_V, double *s, int inc_s, double *U, int rs_U, int cs_U, double *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_f_opc (int m_U, int n_V, float *s, int inc_s, scomplex *U, int rs_U, int cs_U, scomplex *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_b_opc (int m_U, int n_V, float *s, int inc_s, scomplex *U, int rs_U, int cs_U, scomplex *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_f_opz (int m_U, int n_V, double *s, int inc_s, dcomplex *U, int rs_U, int cs_U, dcomplex *V, int rs_V, int cs_V)
 
FLA_Error FLA_Sort_svd_b_opz (int m_U, int n_V, double *s, int inc_s, dcomplex *U, int rs_U, int cs_U, dcomplex *V, int rs_V, int cs_V)
 

Function Documentation

◆ FLA_Sort_svd()

FLA_Error FLA_Sort_svd ( FLA_Direct  direct,
FLA_Obj  s,
FLA_Obj  U,
FLA_Obj  V 
)
14 {
15  FLA_Datatype datatype;
16  dim_t m_U, n_V;
17  dim_t rs_U, cs_U;
18  dim_t rs_V, cs_V;
19  dim_t inc_s;
20 
21  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
22  FLA_Sort_svd_check( direct, s, U, V );
23 
24  datatype = FLA_Obj_datatype( U );
25 
26  m_U = FLA_Obj_length( U );
27  n_V = FLA_Obj_length( V );
28 
29  rs_U = FLA_Obj_row_stride( U );
30  cs_U = FLA_Obj_col_stride( U );
31 
32  rs_V = FLA_Obj_row_stride( V );
33  cs_V = FLA_Obj_col_stride( V );
34 
35  inc_s = FLA_Obj_vector_inc( s );
36 
37  switch ( datatype )
38  {
39  case FLA_FLOAT:
40  {
41  float* s_p = ( float* ) FLA_FLOAT_PTR( s );
42  float* U_p = ( float* ) FLA_FLOAT_PTR( U );
43  float* V_p = ( float* ) FLA_FLOAT_PTR( V );
44 
45  if ( direct == FLA_FORWARD )
46  FLA_Sort_svd_f_ops( m_U,
47  n_V,
48  s_p, inc_s,
49  U_p, rs_U, cs_U,
50  V_p, rs_V, cs_V );
51  else // if ( direct == FLA_BACKWARD )
52  FLA_Sort_svd_b_ops( m_U,
53  n_V,
54  s_p, inc_s,
55  U_p, rs_U, cs_U,
56  V_p, rs_V, cs_V );
57 
58  break;
59  }
60 
61  case FLA_DOUBLE:
62  {
63  double* s_p = ( double* ) FLA_DOUBLE_PTR( s );
64  double* U_p = ( double* ) FLA_DOUBLE_PTR( U );
65  double* V_p = ( double* ) FLA_DOUBLE_PTR( V );
66 
67  if ( direct == FLA_FORWARD )
68  FLA_Sort_svd_f_opd( m_U,
69  n_V,
70  s_p, inc_s,
71  U_p, rs_U, cs_U,
72  V_p, rs_V, cs_V );
73  else // if ( direct == FLA_BACKWARD )
74  FLA_Sort_svd_b_opd( m_U,
75  n_V,
76  s_p, inc_s,
77  U_p, rs_U, cs_U,
78  V_p, rs_V, cs_V );
79 
80  break;
81  }
82 
83  case FLA_COMPLEX:
84  {
85  float* s_p = ( float* ) FLA_FLOAT_PTR( s );
86  scomplex* U_p = ( scomplex* ) FLA_COMPLEX_PTR( U );
87  scomplex* V_p = ( scomplex* ) FLA_COMPLEX_PTR( V );
88 
89  if ( direct == FLA_FORWARD )
90  FLA_Sort_svd_f_opc( m_U,
91  n_V,
92  s_p, inc_s,
93  U_p, rs_U, cs_U,
94  V_p, rs_V, cs_V );
95  else // if ( direct == FLA_BACKWARD )
96  FLA_Sort_svd_b_opc( m_U,
97  n_V,
98  s_p, inc_s,
99  U_p, rs_U, cs_U,
100  V_p, rs_V, cs_V );
101 
102  break;
103  }
104 
105  case FLA_DOUBLE_COMPLEX:
106  {
107  double* s_p = ( double* ) FLA_DOUBLE_PTR( s );
108  dcomplex* U_p = ( dcomplex* ) FLA_DOUBLE_COMPLEX_PTR( U );
109  dcomplex* V_p = ( dcomplex* ) FLA_DOUBLE_COMPLEX_PTR( V );
110 
111  if ( direct == FLA_FORWARD )
112  FLA_Sort_svd_f_opz( m_U,
113  n_V,
114  s_p, inc_s,
115  U_p, rs_U, cs_U,
116  V_p, rs_V, cs_V );
117  else // if ( direct == FLA_BACKWARD )
118  FLA_Sort_svd_b_opz( m_U,
119  n_V,
120  s_p, inc_s,
121  U_p, rs_U, cs_U,
122  V_p, rs_V, cs_V );
123 
124  break;
125  }
126 
127  }
128 
129  return FLA_SUCCESS;
130 }
FLA_Error FLA_Sort_svd_b_ops(int m_U, int n_V, float *s, int inc_s, float *U, int rs_U, int cs_U, float *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:143
FLA_Error FLA_Sort_svd_f_opc(int m_U, int n_V, float *s, int inc_s, scomplex *U, int rs_U, int cs_U, scomplex *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:236
FLA_Error FLA_Sort_svd_f_opd(int m_U, int n_V, double *s, int inc_s, double *U, int rs_U, int cs_U, double *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:152
FLA_Error FLA_Sort_svd_b_opz(int m_U, int n_V, double *s, int inc_s, dcomplex *U, int rs_U, int cs_U, dcomplex *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:296
FLA_Error FLA_Sort_svd_f_ops(int m_U, int n_V, float *s, int inc_s, float *U, int rs_U, int cs_U, float *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:134
FLA_Error FLA_Sort_svd_b_opd(int m_U, int n_V, double *s, int inc_s, double *U, int rs_U, int cs_U, double *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:194
FLA_Error FLA_Sort_svd_b_opc(int m_U, int n_V, float *s, int inc_s, scomplex *U, int rs_U, int cs_U, scomplex *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:245
FLA_Error FLA_Sort_svd_f_opz(int m_U, int n_V, double *s, int inc_s, dcomplex *U, int rs_U, int cs_U, dcomplex *V, int rs_V, int cs_V)
Definition: FLA_Sort_svd.c:254
FLA_Error FLA_Sort_svd_check(FLA_Direct direct, FLA_Obj s, FLA_Obj U, FLA_Obj V)
Definition: FLA_Sort_svd_check.c:13
dim_t FLA_Obj_row_stride(FLA_Obj obj)
Definition: FLA_Query.c:167
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
dim_t FLA_Obj_col_stride(FLA_Obj obj)
Definition: FLA_Query.c:174
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
dim_t FLA_Obj_vector_inc(FLA_Obj obj)
Definition: FLA_Query.c:145
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: blis_type_defs.h:138
Definition: blis_type_defs.h:133

References FLA_Check_error_level(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_vector_inc(), FLA_Sort_svd_b_opc(), FLA_Sort_svd_b_opd(), FLA_Sort_svd_b_ops(), FLA_Sort_svd_b_opz(), FLA_Sort_svd_check(), FLA_Sort_svd_f_opc(), FLA_Sort_svd_f_opd(), FLA_Sort_svd_f_ops(), and FLA_Sort_svd_f_opz().

Referenced by FLA_Svd_uv_unb_var1(), and FLA_Svd_uv_unb_var2().

◆ FLA_Sort_svd_b_opc()

FLA_Error FLA_Sort_svd_b_opc ( int  m_U,
int  n_V,
float *  s,
int  inc_s,
scomplex U,
int  rs_U,
int  cs_U,
scomplex V,
int  rs_V,
int  cs_V 
)
250 {
251  return FLA_SUCCESS;
252 }

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_b_opd()

FLA_Error FLA_Sort_svd_b_opd ( int  m_U,
int  n_V,
double *  s,
int  inc_s,
double *  U,
int  rs_U,
int  cs_U,
double *  V,
int  rs_V,
int  cs_V 
)
199 {
200  int min_m_n = min( m_U, n_V );
201  int i, ii, j, k;
202  double p;
203 
204  for ( ii = 1; ii < min_m_n; ++ii )
205  {
206  i = ii - 1;
207  k = i;
208 
209  p = s[ i*inc_s ];
210 
211  for ( j = ii; j < min_m_n; ++j )
212  {
213  if ( s[ j*inc_s ] > p )
214  {
215  k = j;
216  p = s[ j*inc_s ];
217  }
218  }
219 
220  if ( k != i )
221  {
222  s[ k*inc_s ] = s[ i ];
223  s[ i ] = p;
224  bl1_dswapv( m_U,
225  U + i*cs_U, rs_U,
226  U + k*cs_U, rs_U );
227  bl1_dswapv( n_V,
228  V + i*cs_V, rs_V,
229  V + k*cs_V, rs_V );
230  }
231  }
232 
233  return FLA_SUCCESS;
234 }
int i
Definition: bl1_axmyv2.c:145
void bl1_dswapv(int n, double *x, int incx, double *y, int incy)
Definition: bl1_swapv.c:23

References bl1_dswapv(), and i.

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_b_ops()

FLA_Error FLA_Sort_svd_b_ops ( int  m_U,
int  n_V,
float *  s,
int  inc_s,
float *  U,
int  rs_U,
int  cs_U,
float *  V,
int  rs_V,
int  cs_V 
)
148 {
149  return FLA_SUCCESS;
150 }

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_b_opz()

FLA_Error FLA_Sort_svd_b_opz ( int  m_U,
int  n_V,
double *  s,
int  inc_s,
dcomplex U,
int  rs_U,
int  cs_U,
dcomplex V,
int  rs_V,
int  cs_V 
)
301 {
302  int min_m_n = min( m_U, n_V );
303  int i, ii, j, k;
304  double p;
305 
306  for ( ii = 1; ii < min_m_n; ++ii )
307  {
308  i = ii - 1;
309  k = i;
310 
311  p = s[ i*inc_s ];
312 
313  for ( j = ii; j < min_m_n; ++j )
314  {
315  if ( s[ j*inc_s ] > p )
316  {
317  k = j;
318  p = s[ j*inc_s ];
319  }
320  }
321 
322  if ( k != i )
323  {
324  s[ k*inc_s ] = s[ i ];
325  s[ i ] = p;
326  bl1_zswapv( m_U,
327  U + i*cs_U, rs_U,
328  U + k*cs_U, rs_U );
329  bl1_zswapv( n_V,
330  V + i*cs_V, rs_V,
331  V + k*cs_V, rs_V );
332  }
333  }
334 
335  return FLA_SUCCESS;
336 }
void bl1_zswapv(int n, dcomplex *x, int incx, dcomplex *y, int incy)
Definition: bl1_swapv.c:43

References bl1_zswapv(), and i.

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_f_opc()

FLA_Error FLA_Sort_svd_f_opc ( int  m_U,
int  n_V,
float *  s,
int  inc_s,
scomplex U,
int  rs_U,
int  cs_U,
scomplex V,
int  rs_V,
int  cs_V 
)
241 {
242  return FLA_SUCCESS;
243 }

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_f_opd()

FLA_Error FLA_Sort_svd_f_opd ( int  m_U,
int  n_V,
double *  s,
int  inc_s,
double *  U,
int  rs_U,
int  cs_U,
double *  V,
int  rs_V,
int  cs_V 
)
157 {
158  int min_m_n = min( m_U, n_V );
159  int i, ii, j, k;
160  double p;
161 
162  for ( ii = 1; ii < min_m_n; ++ii )
163  {
164  i = ii - 1;
165  k = i;
166 
167  p = s[ i*inc_s ];
168 
169  for ( j = ii; j < min_m_n; ++j )
170  {
171  if ( s[ j*inc_s ] < p )
172  {
173  k = j;
174  p = s[ j*inc_s ];
175  }
176  }
177 
178  if ( k != i )
179  {
180  s[ k*inc_s ] = s[ i ];
181  s[ i ] = p;
182  bl1_dswapv( m_U,
183  U + i*cs_U, rs_U,
184  U + k*cs_U, rs_U );
185  bl1_dswapv( n_V,
186  V + i*cs_V, rs_V,
187  V + k*cs_V, rs_V );
188  }
189  }
190 
191  return FLA_SUCCESS;
192 }

References bl1_dswapv(), and i.

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_f_ops()

FLA_Error FLA_Sort_svd_f_ops ( int  m_U,
int  n_V,
float *  s,
int  inc_s,
float *  U,
int  rs_U,
int  cs_U,
float *  V,
int  rs_V,
int  cs_V 
)
139 {
140  return FLA_SUCCESS;
141 }

Referenced by FLA_Sort_svd().

◆ FLA_Sort_svd_f_opz()

FLA_Error FLA_Sort_svd_f_opz ( int  m_U,
int  n_V,
double *  s,
int  inc_s,
dcomplex U,
int  rs_U,
int  cs_U,
dcomplex V,
int  rs_V,
int  cs_V 
)
259 {
260  int min_m_n = min( m_U, n_V );
261  int i, ii, j, k;
262  double p;
263 
264  for ( ii = 1; ii < min_m_n; ++ii )
265  {
266  i = ii - 1;
267  k = i;
268 
269  p = s[ i*inc_s ];
270 
271  for ( j = ii; j < min_m_n; ++j )
272  {
273  if ( s[ j*inc_s ] < p )
274  {
275  k = j;
276  p = s[ j*inc_s ];
277  }
278  }
279 
280  if ( k != i )
281  {
282  s[ k*inc_s ] = s[ i ];
283  s[ i ] = p;
284  bl1_zswapv( m_U,
285  U + i*cs_U, rs_U,
286  U + k*cs_U, rs_U );
287  bl1_zswapv( n_V,
288  V + i*cs_V, rs_V,
289  V + k*cs_V, rs_V );
290  }
291  }
292 
293  return FLA_SUCCESS;
294 }

References bl1_zswapv(), and i.

Referenced by FLA_Sort_svd().