| 58 | } |
| 59 | |
| 60 | af_err af_rank(uint* out, const af_array in, const double tol) { |
| 61 | try { |
| 62 | const ArrayInfo& i_info = getInfo(in); |
| 63 | |
| 64 | if (i_info.ndims() > 2) { |
| 65 | AF_ERROR("solve can not be used in batch mode", AF_ERR_BATCH); |
| 66 | } |
| 67 | |
| 68 | af_dtype type = i_info.getType(); |
| 69 | |
| 70 | ARG_ASSERT(1, i_info.isFloating()); // Only floating and complex types |
| 71 | ARG_ASSERT(0, out != nullptr); |
| 72 | |
| 73 | uint output = 0; |
| 74 | if (i_info.ndims() != 0) { |
| 75 | switch (type) { |
| 76 | case f32: output = rank<float>(in, tol); break; |
| 77 | case f64: output = rank<double>(in, tol); break; |
| 78 | case c32: output = rank<cfloat>(in, tol); break; |
| 79 | case c64: output = rank<cdouble>(in, tol); break; |
| 80 | default: TYPE_ERROR(1, type); |
| 81 | } |
| 82 | } |
| 83 | std::swap(*out, output); |
| 84 | } |
| 85 | CATCHALL; |
| 86 | |
| 87 | return AF_SUCCESS; |
| 88 | } |