mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-22 00:43:18 +08:00
Replace pow with sqrt
This commit is contained in:
committed by
Lorenz Meier
parent
22bf63cb71
commit
03ffd696a6
+3
-3
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
Type norm() const {
|
||||
const Vector &a(*this);
|
||||
return Type(sqrt(a.dot(a)));
|
||||
return Type(::sqrt(a.dot(a)));
|
||||
}
|
||||
|
||||
Type norm_squared() const {
|
||||
@@ -98,11 +98,11 @@ public:
|
||||
return unit();
|
||||
}
|
||||
|
||||
Vector pow(Type v) const {
|
||||
Vector sqrt() const {
|
||||
const Vector &a(*this);
|
||||
Vector r;
|
||||
for (size_t i = 0; i<M; i++) {
|
||||
r(i) = Type(::pow(a(i), v));
|
||||
r(i) = Type(::sqrt(a(i)));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,10 +30,10 @@ int main()
|
||||
v2.normalize();
|
||||
TEST(isEqualF(v2.norm(), 1.f));
|
||||
|
||||
// power
|
||||
// sqrt
|
||||
float data1_sq[] = {1,4,9,16,25};
|
||||
Vector<float, 5> v4(data1_sq);
|
||||
TEST(isEqual(v1, v4.pow(0.5)));
|
||||
TEST(isEqual(v1, v4.sqrt()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user