| 71 | } |
| 72 | |
| 73 | af_err af_svd(af_array *u, af_array *s, af_array *vt, const af_array in) { |
| 74 | try { |
| 75 | const ArrayInfo &info = getInfo(in); |
| 76 | dim4 dims = info.dims(); |
| 77 | |
| 78 | ARG_ASSERT(3, (dims.ndims() >= 0 && dims.ndims() <= 2)); |
| 79 | af_dtype type = info.getType(); |
| 80 | |
| 81 | if (dims.ndims() == 0) { |
| 82 | AF_CHECK(af_create_handle(u, 0, nullptr, type)); |
| 83 | AF_CHECK(af_create_handle(s, 0, nullptr, type)); |
| 84 | AF_CHECK(af_create_handle(vt, 0, nullptr, type)); |
| 85 | return AF_SUCCESS; |
| 86 | } |
| 87 | |
| 88 | switch (type) { |
| 89 | case f64: svd<double>(s, u, vt, in); break; |
| 90 | case f32: svd<float>(s, u, vt, in); break; |
| 91 | case c64: svd<cdouble>(s, u, vt, in); break; |
| 92 | case c32: svd<cfloat>(s, u, vt, in); break; |
| 93 | default: TYPE_ERROR(1, type); |
| 94 | } |
| 95 | } |
| 96 | CATCHALL; |
| 97 | return AF_SUCCESS; |
| 98 | } |
| 99 | |
| 100 | af_err af_svd_inplace(af_array *u, af_array *s, af_array *vt, af_array in) { |
| 101 | try { |
no test coverage detected