MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / norm

Function norm

src/api/c/norm.cpp:105–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104template<typename T>
105double norm(const af_array a, const af_norm_type type, const double p,
106 const double q) {
107 using BT = typename af::dtype_traits<T>::base_type;
108
109 const Array<BT> A = detail::abs<BT, T>(getArray<T>(a));
110
111 switch (type) {
112 case AF_NORM_EUCLID: return vectorNorm(A, 2);
113 case AF_NORM_VECTOR_1: return vectorNorm(A, 1);
114 case AF_NORM_VECTOR_INF: return vectorNorm(A, af::Inf);
115 case AF_NORM_VECTOR_P: return vectorNorm(A, p);
116 case AF_NORM_MATRIX_1: return matrixNorm(A, 1);
117 case AF_NORM_MATRIX_INF: return matrixNorm(A, af::Inf);
118 case AF_NORM_MATRIX_2: return matrixNorm(A, 2);
119 case AF_NORM_MATRIX_L_PQ: return LPQNorm(A, p, q);
120 default:
121 AF_ERROR("This type of norm is not supported in ArrayFire\n",
122 AF_ERR_NOT_SUPPORTED);
123 }
124}
125
126af_err af_norm(double *out, const af_array in, const af_norm_type type,
127 const double p, const double q) {

Callers 3

TESTFunction · 0.50
TESTFunction · 0.50
TEST_PFunction · 0.50

Calls 3

vectorNormFunction · 0.85
matrixNormFunction · 0.85
LPQNormFunction · 0.85

Tested by

no test coverage detected