| 98 | } |
| 99 | |
| 100 | af_err af_svd_inplace(af_array *u, af_array *s, af_array *vt, af_array in) { |
| 101 | try { |
| 102 | const ArrayInfo &info = getInfo(in); |
| 103 | dim4 dims = info.dims(); |
| 104 | |
| 105 | ARG_ASSERT(3, (dims.ndims() >= 0 && dims.ndims() <= 2)); |
| 106 | af_dtype type = info.getType(); |
| 107 | |
| 108 | if (dims.ndims() == 0) { |
| 109 | AF_CHECK(af_create_handle(u, 0, nullptr, type)); |
| 110 | AF_CHECK(af_create_handle(s, 0, nullptr, type)); |
| 111 | AF_CHECK(af_create_handle(vt, 0, nullptr, type)); |
| 112 | return AF_SUCCESS; |
| 113 | } |
| 114 | |
| 115 | DIM_ASSERT(3, dims[0] >= dims[1]); |
| 116 | |
| 117 | switch (type) { |
| 118 | case f64: svdInPlace<double>(s, u, vt, in); break; |
| 119 | case f32: svdInPlace<float>(s, u, vt, in); break; |
| 120 | case c64: svdInPlace<cdouble>(s, u, vt, in); break; |
| 121 | case c32: svdInPlace<cfloat>(s, u, vt, in); break; |
| 122 | default: TYPE_ERROR(1, type); |
| 123 | } |
| 124 | } |
| 125 | CATCHALL; |
| 126 | return AF_SUCCESS; |
| 127 | } |
no test coverage detected