| 66 | } |
| 67 | |
| 68 | af_err af_cholesky_inplace(int *info, af_array in, const bool is_upper) { |
| 69 | try { |
| 70 | const ArrayInfo &i_info = getInfo(in); |
| 71 | |
| 72 | if (i_info.ndims() > 2) { |
| 73 | AF_ERROR("cholesky can not be used in batch mode", AF_ERR_BATCH); |
| 74 | } |
| 75 | |
| 76 | af_dtype type = i_info.getType(); |
| 77 | if (i_info.ndims() == 0) { return AF_SUCCESS; } |
| 78 | ARG_ASSERT(1, i_info.isFloating()); // Only floating and complex types |
| 79 | DIM_ASSERT( |
| 80 | 1, i_info.dims()[0] == i_info.dims()[1]); // Only square matrices |
| 81 | |
| 82 | int out; |
| 83 | |
| 84 | switch (type) { |
| 85 | case f32: out = cholesky_inplace<float>(in, is_upper); break; |
| 86 | case f64: out = cholesky_inplace<double>(in, is_upper); break; |
| 87 | case c32: out = cholesky_inplace<cfloat>(in, is_upper); break; |
| 88 | case c64: out = cholesky_inplace<cdouble>(in, is_upper); break; |
| 89 | default: TYPE_ERROR(1, type); |
| 90 | } |
| 91 | std::swap(*info, out); |
| 92 | } |
| 93 | CATCHALL; |
| 94 | |
| 95 | return AF_SUCCESS; |
| 96 | } |
no test coverage detected