MCPcopy Create free account
hub / github.com/numpy/numpy / svd_wrapper

Function svd_wrapper

numpy/linalg/umath_linalg.cpp:2889–2979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2887
2888template<typename typ>
2889static inline void
2890svd_wrapper(char JOBZ,
2891 char **args,
2892 npy_intp const *dimensions,
2893 npy_intp const *steps)
2894{
2895using basetyp = basetype_t<typ>;
2896 ptrdiff_t outer_steps[4];
2897 int error_occurred = get_fp_invalid_and_clear();
2898 size_t iter;
2899 size_t outer_dim = *dimensions++;
2900 size_t op_count = (JOBZ=='N')?2:4;
2901 GESDD_PARAMS_t<typ> params;
2902
2903 for (iter = 0; iter < op_count; ++iter) {
2904 outer_steps[iter] = (ptrdiff_t) steps[iter];
2905 }
2906 steps += op_count;
2907
2908 if (init_gesdd(&params,
2909 JOBZ,
2910 (fortran_int)dimensions[0],
2911 (fortran_int)dimensions[1],
2912dispatch_scalar<typ>())) {
2913 LINEARIZE_DATA_t a_in, u_out, s_out, v_out;
2914 fortran_int min_m_n = params.M < params.N ? params.M : params.N;
2915
2916 init_linearize_data(&a_in, params.N, params.M, steps[1], steps[0]);
2917 if ('N' == params.JOBZ) {
2918 /* only the singular values are wanted */
2919 init_linearize_data(&s_out, 1, min_m_n, 0, steps[2]);
2920 } else {
2921 fortran_int u_columns, v_rows;
2922 if ('S' == params.JOBZ) {
2923 u_columns = min_m_n;
2924 v_rows = min_m_n;
2925 } else { /* JOBZ == 'A' */
2926 u_columns = params.M;
2927 v_rows = params.N;
2928 }
2929 init_linearize_data(&u_out,
2930 u_columns, params.M,
2931 steps[3], steps[2]);
2932 init_linearize_data(&s_out,
2933 1, min_m_n,
2934 0, steps[4]);
2935 init_linearize_data(&v_out,
2936 params.N, v_rows,
2937 steps[6], steps[5]);
2938 }
2939
2940 for (iter = 0; iter < outer_dim; ++iter) {
2941 int not_ok;
2942 /* copy the matrix in */
2943 linearize_matrix((typ*)params.A, (typ*)args[0], &a_in);
2944 not_ok = call_gesdd(&params);
2945 if (!not_ok) {
2946 if ('N' == params.JOBZ) {

Callers

nothing calls this directly

Calls 11

get_fp_invalid_and_clearFunction · 0.85
init_gesddFunction · 0.85
init_linearize_dataFunction · 0.85
linearize_matrixFunction · 0.85
call_gesddFunction · 0.85
delinearize_matrixFunction · 0.85
identity_matrixFunction · 0.85
nan_matrixFunction · 0.85
update_pointersFunction · 0.85
release_gesddFunction · 0.85
set_fp_invalid_or_clearFunction · 0.85

Tested by

no test coverage detected