MCPcopy Create free account
hub / github.com/PX4/eigen / lpNorm

Function lpNorm

test/array_for_matrix.cpp:150–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

test_array_for_matrixFunction · 0.85

Calls 9

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

Tested by 1

test_array_for_matrixFunction · 0.68