| 168 | } |
| 169 | |
| 170 | af_err af_pinverse(af_array *out, const af_array in, const double tol, |
| 171 | const af_mat_prop options) { |
| 172 | try { |
| 173 | const ArrayInfo &i_info = getInfo(in); |
| 174 | |
| 175 | af_dtype type = i_info.getType(); |
| 176 | |
| 177 | if (options != AF_MAT_NONE) { |
| 178 | AF_ERROR("Using this property is not yet supported in inverse", |
| 179 | AF_ERR_NOT_SUPPORTED); |
| 180 | } |
| 181 | |
| 182 | ARG_ASSERT(1, i_info.isFloating()); // Only floating and complex types |
| 183 | ARG_ASSERT(2, tol >= 0.); // Ensure tolerance is not negative |
| 184 | |
| 185 | af_array output; |
| 186 | |
| 187 | if (i_info.ndims() == 0) { return af_retain_array(out, in); } |
| 188 | |
| 189 | switch (type) { |
| 190 | case f32: output = pinverse<float>(in, tol); break; |
| 191 | case f64: output = pinverse<double>(in, tol); break; |
| 192 | case c32: output = pinverse<cfloat>(in, tol); break; |
| 193 | case c64: output = pinverse<cdouble>(in, tol); break; |
| 194 | default: TYPE_ERROR(1, type); |
| 195 | } |
| 196 | swap(*out, output); |
| 197 | } |
| 198 | CATCHALL; |
| 199 | |
| 200 | return AF_SUCCESS; |
| 201 | } |
no test coverage detected