summaryrefslogtreecommitdiff
path: root/stereographic.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'stereographic.hpp')
-rw-r--r--stereographic.hpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/stereographic.hpp b/stereographic.hpp
index 2dfa735..58c6b31 100644
--- a/stereographic.hpp
+++ b/stereographic.hpp
@@ -10,13 +10,13 @@ Vector<Scalar> stereographicToEuclidean(const Vector<Scalar>& ζ) {
Vector<Scalar> z(N);
Scalar a = ζ.transpose() * ζ;
- Scalar b = 2 * sqrt(N) / (1.0 + a);
+ Scalar b = 2 * sqrt((Real)N) / ((Real)1 + a);
for (unsigned i = 0; i < N - 1; i++) {
z(i) = ζ(i);
}
- z(N - 1) = (a - 1.0) / 2.0;
+ z(N - 1) = (a - (Real)1) / (Real)2;
return b * z;
}
@@ -30,7 +30,7 @@ Vector<Scalar> euclideanToStereographic(const Vector<Scalar>& z) {
ζ(i) = z(i);
}
- return ζ / (sqrt(N) - z(N - 1));
+ return ζ / (sqrt((Real)N) - z(N - 1));
}
template <class Scalar>
@@ -38,14 +38,14 @@ Matrix<Scalar> stereographicJacobian(const Vector<Scalar>& ζ) {
unsigned N = ζ.size();
Matrix<Scalar> J(N, N + 1);
- Scalar b = 1.0 + (Scalar)(ζ.transpose() * ζ);
+ Scalar b = (Real)1 + (Scalar)(ζ.transpose() * ζ);
for (unsigned i = 0; i < N; i++) {
for (unsigned j = 0; j < N; j++) {
J(i, j) = - ζ(i) * ζ(j);
if (i == j) {
- J(i, j) += 0.5 * b;
+ J(i, j) += b / (Real)2;
}
}