MCPcopy Create free account
hub / github.com/Derious/cuMPC / lpNorm

Function lpNorm

dependence/eigen-3.4.0/test/array_for_matrix.cpp:155–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155template<typename VectorType> void lpNorm(const VectorType& v)
156{
157 using std::sqrt;
158 typedef typename VectorType::RealScalar RealScalar;
159 VectorType u = VectorType::Random(v.size());
160
161 if(v.size()==0)
162 {
163 VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), RealScalar(0));
164 VERIFY_IS_APPROX(u.template lpNorm<1>(), RealScalar(0));
165 VERIFY_IS_APPROX(u.template lpNorm<2>(), RealScalar(0));
166 VERIFY_IS_APPROX(u.template lpNorm<5>(), RealScalar(0));
167 }
168 else
169 {
170 VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), u.cwiseAbs().maxCoeff());
171 }
172
173 VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwiseAbs().sum());
174 VERIFY_IS_APPROX(u.template lpNorm<2>(), sqrt(u.array().abs().square().sum()));
175 VERIFY_IS_APPROX(numext::pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.array().abs().pow(5).sum());
176}
177
178template<typename MatrixType> void cwise_min_max(const MatrixType& m)
179{

Callers 1

EIGEN_DECLARE_TESTFunction · 0.85

Calls 9

squareMethod · 0.80
absMethod · 0.80
sqrtFunction · 0.70
powFunction · 0.50
sizeMethod · 0.45
maxCoeffMethod · 0.45
sumMethod · 0.45
arrayMethod · 0.45
powMethod · 0.45

Tested by

no test coverage detected