| 33 | } |
| 34 | |
| 35 | af_err af_cholesky(af_array *out, int *info, const af_array in, |
| 36 | const bool is_upper) { |
| 37 | try { |
| 38 | const ArrayInfo &i_info = getInfo(in); |
| 39 | |
| 40 | if (i_info.ndims() > 2) { |
| 41 | AF_ERROR("cholesky can not be used in batch mode", AF_ERR_BATCH); |
| 42 | } |
| 43 | |
| 44 | af_dtype type = i_info.getType(); |
| 45 | |
| 46 | if (i_info.ndims() == 0) { |
| 47 | return af_create_handle(out, 0, nullptr, type); |
| 48 | } |
| 49 | DIM_ASSERT( |
| 50 | 1, i_info.dims()[0] == i_info.dims()[1]); // Only square matrices |
| 51 | ARG_ASSERT(2, i_info.isFloating()); // Only floating and complex types |
| 52 | |
| 53 | af_array output; |
| 54 | switch (type) { |
| 55 | case f32: output = cholesky<float>(info, in, is_upper); break; |
| 56 | case f64: output = cholesky<double>(info, in, is_upper); break; |
| 57 | case c32: output = cholesky<cfloat>(info, in, is_upper); break; |
| 58 | case c64: output = cholesky<cdouble>(info, in, is_upper); break; |
| 59 | default: TYPE_ERROR(1, type); |
| 60 | } |
| 61 | std::swap(*out, output); |
| 62 | } |
| 63 | CATCHALL; |
| 64 | |
| 65 | return AF_SUCCESS; |
| 66 | } |
| 67 | |
| 68 | af_err af_cholesky_inplace(int *info, af_array in, const bool is_upper) { |
| 69 | try { |
no test coverage detected