| 70 | } |
| 71 | |
| 72 | af_err af_det(double *real_val, double *imag_val, const af_array in) { |
| 73 | try { |
| 74 | const ArrayInfo &i_info = getInfo(in); |
| 75 | |
| 76 | if (i_info.ndims() > 2) { |
| 77 | AF_ERROR("solve can not be used in batch mode", AF_ERR_BATCH); |
| 78 | } |
| 79 | |
| 80 | af_dtype type = i_info.getType(); |
| 81 | |
| 82 | if (i_info.dims()[0]) { |
| 83 | DIM_ASSERT(1, i_info.dims()[0] == |
| 84 | i_info.dims()[1]); // Only square matrices |
| 85 | } |
| 86 | ARG_ASSERT(1, i_info.isFloating()); // Only floating and complex types |
| 87 | |
| 88 | *real_val = 0; |
| 89 | *imag_val = 0; |
| 90 | |
| 91 | cfloat cfval; |
| 92 | cdouble cdval; |
| 93 | |
| 94 | switch (type) { |
| 95 | case f32: *real_val = det<float>(in); break; |
| 96 | case f64: *real_val = det<double>(in); break; |
| 97 | case c32: |
| 98 | cfval = det<cfloat>(in); |
| 99 | *real_val = real(cfval); |
| 100 | *imag_val = imag(cfval); |
| 101 | break; |
| 102 | case c64: |
| 103 | cdval = det<cdouble>(in); |
| 104 | *real_val = real(cdval); |
| 105 | *imag_val = imag(cdval); |
| 106 | break; |
| 107 | default: TYPE_ERROR(1, type); |
| 108 | } |
| 109 | } |
| 110 | CATCHALL; |
| 111 | |
| 112 | return AF_SUCCESS; |
| 113 | } |