| 44 | |
| 45 | template<typename T> |
| 46 | double matrixNorm(const Array<T> &A, double p) { |
| 47 | using RT = normReductionResult<T>; |
| 48 | if (p == 1) { |
| 49 | Array<RT> colSum = reduce<af_add_t, T, normReductionResult<T>>(A, 0); |
| 50 | return getScalar<RT>(reduce_all<af_max_t, RT, RT>(colSum)); |
| 51 | } |
| 52 | if (p == af::Inf) { |
| 53 | Array<RT> rowSum = reduce<af_add_t, T, RT>(A, 1); |
| 54 | return getScalar<RT>(reduce_all<af_max_t, RT, RT>(rowSum)); |
| 55 | } |
| 56 | |
| 57 | AF_ERROR("This type of norm is not supported in ArrayFire\n", |
| 58 | AF_ERR_NOT_SUPPORTED); |
| 59 | } |
| 60 | |
| 61 | template<typename T> |
| 62 | double vectorNorm(const Array<T> &A, double p) { |