Repository: stack-of-tasks/eigenpy (language: python)

Issue:
Quaternion leads to segfault with -march=native
I have compiled eigenpy with clang-10 (Release mode) and the following flags: `-march=native -mfpmath=sse`. Then, the following code leads to a segfault:
```python
import eigenpy
eigenpy.Quaternion.Identity()
```


Quaternion leads to segfault with -march=native
I have compiled eigenpy with clang-10 (Release mode) and the following flags: `-march=native -mfpmath=sse`. Then, the following code leads to a segfault:
```python
import eigenpy
eigenpy.Quaternion.Identity()
```




Discussion / hints:
I can't reproduce.

Here are the steps I followed, on a 18.04 machine:
```bash
git clone --recursive https://github.com/stack-of-tasks/eigenpy.git
cd eigenpy
mkdir build
cd build
export CXX=/usr/bin/clang++-10
export CXX_FLAGS="-march=native -mfpmath=sse"
export CC=/usr/bin/clang-10
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ..
make -sj16
make test // OK
python3 -c "import eigenpy; print(eigenpy.Quaternion.Identity())"
```

As expected, I get
```
(x,y,z,w) = 0 0 0 1
```
ok, my `CXX_FLAGS`was wrong.

I can reproduce with
```diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 689dc3d..7164e71 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,7 @@ INCLUDE(cmake/ide.cmake)
 INCLUDE(cmake/apple.cmake)
 
 STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse")
 
 # If needed, fix CMake policy for APPLE systems
 APPLY_DEFAULT_APPLE_CONFIGURATION()
 ```

Only the geometry test segfaults.
> Only the geometry test segfaults.

Yes, that's correct! I also observed that `test_geometry.py` failed.

Btw, I have also similar issues with `Pinocchio.Quaternion`, but I am not sure if it is also rooted to this one.
Again, please provide the version of Eigen, Boost, Python and Eigenpy you are using. Otherwise, it will be hard to provide sound help.
Did you try the C++ equivalent action before opening this issue?
> Again, please provide the version of Eigen, Boost, Python and Eigenpy you are using. Otherwise, it will be hard to provide sound help.

This is my setup:
  - Eigen: 3.3.7
  - Boost: 1.65.1
  - Eigenpy: devel branch
  - Ubuntu 18.04

> Did you try the C++ equivalent action before opening this issue?

No, I didn't
> > Did you try the C++ equivalent action before opening this issue?
> 
> No, I didn't

Please first try this aspect and come back latter with this useful feedback.
No issue on my side. 
This seems to be a conflict between different install of eigenpy.
I will close this issue as it does not seem related to eigenpy.

For future issues, you should provide a docker image replicating the issue for quick test and debugging.
>  This seems to be a conflict between different install of eigenpy.

Are you sure?

This issue was reproduced by @nim65s.

I think it is too early for making that conclusion.
Please start from a clean installation (e.g. Docker image) and we can discuss after that if the problem still occurs.
I have no anymore the issue after cleaning up `ipython`. I realized that it was leading to segfault with `ipython` only (it was working well with `python`).

This is not exactly the @nim65s condition, but it could be a similar problem.


Could you do: which python/ which ipython?

> Could you do: which python/ which ipython?

No, I couldn't for ipython. But I believe it should be `/usr/bin/ipython`. Now I removed that one, I reinstalled the version using `pip install --user`.

For python, everything remains the same. So `which python` prints `/usr/bin/python`.


What is the recommended approach (pip or apt install version)? 
The thing is that I don't think the issue is really ipython, but rather the fact that they were not based on the same version of Python.
My previous comment was not correct. It still leads to segfault is your write the code using ipython console.

I have created a docker image, and I still find the same issue. You can pull the docker as `docker pull cmastalli/eigenpy-native:latest`, and the code of the Dockerfile is:
```bash
#Eigenpy image
FROM ubuntu:18.04 
MAINTAINER carlos.mastalli@gmail.com

#Set working directory
WORKDIR /home/devel

RUN apt-get update 
RUN apt-get install -y build-essential cmake python git libboost-dev python-dev python-numpy
RUN apt-get install -y libeigen3-dev
RUN apt-get install -y libboost-python-dev
RUN git clone https://github.com/stack-of-tasks/eigenpy.git eigenpy \
&& cd eigenpy \
&& git submodule update --init \
&& mkdir build \
&& cd build \
&& cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=native" \
&& make -j2 \
&& make install
ENV LD_LIBRARY_PATH="/usr/local/lib"
RUN python -c "import eigenpy; print(eigenpy.Quaternion.Identity())"
```

Unfortunately, we need to re-open this issue.



solver either by #232 or #233.

I will close this issue. Thanks again @jcarpent for putting effort in providing a solution (I was getting desperate with this issue) 
Sorry, I need to reopen this issue as there are other problems. I will share a code that shows you which cases work and doesn't.
```python
import pinocchio
import numpy as np

t = np.array([1, 2, 3])
q0 = pinocchio.Quaternion.Identity()
q1 = pinocchio.Quaternion.Identity()
q1.x = 1.
q2 = pinocchio.Quaternion(1, 0, 0, 0)
q3 = pinocchio.Quaternion(np.array([1, 0, 0, 0]))


M0 = pinocchio.SE3(q0, t) # works!
M1 = pinocchio.SE3(q1, t) # works!

M2 = pinocchio.SE3(q2, t) # doesn't works!
M3 = pinocchio.SE3(q3, t) # doesn't works!
```

So, it seems we need to have sort of `static` constructors, right? In any case, I am not sure how this could be fixed.
What is q2?
Did you recompile Pinocchio Python bindings with the same vectorization flags?
Could you update your docker image?
> What is q2?
> Did you recompile Pinocchio Python bindings with the same vectorization flags?
> Could you update your docker image?

I have corrected my previous comment, now you can see what is q2.

Yes, I used the same vectorization flags.
I will try to update the docker today. I will let you know when it is done.
Solved by #235.
> Solved by #235.

I tested the merged PR; and unfortunately, I still find the issue from my side (in this case I used `-march=native -mfpmath=sse`.
How do you test it? 
Please provide a docker image. I’m already spending too much time.
>  Could you update your docker image?

I have updated my docker with Pinocchio installation.
You can also see that cases without Pinocchio also leads to segfault.
I made [this dockerfile](https://github.com/nim65s/gepetto-utils/blob/master/docker/eigenpy/devel.Dockerfile):

```dockerfile
FROM ubuntu:focal

RUN apt-get update -y \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    build-essential \
    cmake \
    git \
    libboost-all-dev \
    libeigen3-dev \
    python3-numpy \
 && rm -rf /var/lib/apt/lists/*

RUN git clone --recursive -b devel https://github.com/stack-of-tasks/eigenpy.git

WORKDIR eigenpy/build

RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=native" -DPYTHON_EXECUTABLE=/usr/bin/python3 ..

RUN make
```

I think this is a minimal and standard way to reproduce this issue.

It can be used directly with `docker run --rm -it gepetto/utils:eigenpy-devel`, but the transfer between different computers of binaries compiled with `-march=native` is usually a bad idea.

This docker image is up-to-date with devel (on 3a7acfcc02b77d66b6c0dbe3410fb7e6dbb6b1fb, ie. with #235 merged).

Running `make test` inside it shows a segfault on the `py-geometry` unit test. 
The C++ corresponding `geometry`unit-test is OK.

I was able to trigger the segfault both with GCC 9.3.10 and Clang 10, on a i5-6600 and on a i9-9900. But maybe, on other CPU families, the behavior will change, because of the `-march=native`.

Hi guys,

Sorry for bothered you again on this topic, but this issue still happens in my side, and #236 is not solving it.

@nim65s can you still reproduce the issue?

@jcarpent why is this issue closed? (we need to re-open this issue)
Too many think to handle. I prefer to close it as it is me which entirely dealing with this kind of issue. 
I understand you are lacking of time.
But, it is useful to keep it open:
  1. to acknowledge the issue 
  2. to let others finding a solution.

Furthermore, if you have an idea how to resolve this issue, then please share it here.
I could try to solve it,
If @jcarpent don't intend to work on it, I suggest to keep it close and tag it `WONTFIX`, which explicitely state that this might not be solved yet.
In principle, if it's a known issue that could lead to a segmentation fault, I'd leave the issue open and add something along the lines of `help wanted`.

**However, I can no longer reproduce this issue with the latest devel branch using the above modified Dockerfile on Ubuntu 20.04.** I've also run EigenPy with `-march=native` in deployment and it's been fine.

Dockerfile modified from Carlos' above (this works fine on my machine):
```docker
FROM ubuntu:20.04 
ARG DEBIAN_FRONTEND=noninteractive
#Set working directory
WORKDIR /home/devel

RUN apt-get update -qq && \
    apt-get install -y build-essential cmake python3 git libboost-dev python3-dev python3-numpy libeigen3-dev libboost-python-dev && \
    rm -rf /var/lib/apt/lists/*
RUN git clone --branch devel --recursive https://github.com/stack-of-tasks/eigenpy.git eigenpy \
&& cd eigenpy \
&& mkdir build \
&& cd build \
&& cmake ../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-march=native" \
&& make -j \
&& make install
ENV LD_LIBRARY_PATH="/usr/local/lib"
ENV PYTHONPATH="/usr/local/lib/python3/dist-packages"
RUN python3 -c "import eigenpy; print(eigenpy.Quaternion.Identity())"
```
Good news if it is working now. Thanks @wxmerkt to check.
It is crashing with this Python code:
```python
import eigenpy; import numpy as np; print(eigenpy.Quaternion(np.eye(3)))
```

and you might need to run it several times to detect the segfault.

@wxmerkt  -- can you confirm if this works or not for you? 
I can't reproduce.

Here are the steps I followed, on a 18.04 machine:
```bash
git clone --recursive https://github.com/stack-of-tasks/eigenpy.git
cd eigenpy
mkdir build
cd build
export CXX=/usr/bin/clang++-10
export CXX_FLAGS="-march=native -mfpmath=sse"
export CC=/usr/bin/clang-10
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ..
make -sj16
make test // OK
python3 -c "import eigenpy; print(eigenpy.Quaternion.Identity())"
```

As expected, I get
```
(x,y,z,w) = 0 0 0 1
```
ok, my `CXX_FLAGS`was wrong.

I can reproduce with
```diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 689dc3d..7164e71 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,7 @@ INCLUDE(cmake/ide.cmake)
 INCLUDE(cmake/apple.cmake)
 
 STRING(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse")
 
 # If needed, fix CMake policy for APPLE systems
 APPLY_DEFAULT_APPLE_CONFIGURATION()
 ```

Only the geometry test segfaults.
> Only the geometry test segfaults.

Yes, that's correct! I also observed that `test_geometry.py` failed.

Btw, I have also similar issues with `Pinocchio.Quaternion`, but I am not sure if it is also rooted to this one.
Again, please provide the version of Eigen, Boost, Python and Eigenpy you are using. Otherwise, it will be hard to provide sound help.
Did you try the C++ equivalent action before opening this issue?
> Again, please provide the version of Eigen, Boost, Python and Eigenpy you are using. Otherwise, it will be hard to provide sound help.

This is my setup:
  - Eigen: 3.3.7
  - Boost: 1.65.1
  - Eigenpy: devel branch
  - Ubuntu 18.04

> Did you try the C++ equivalent action before opening this issue?

No, I didn't
> > Did you try the C++ equivalent action before opening this issue?
> 
> No, I didn't

Please first try this aspect and come back latter with this useful feedback.
No issue on my side. 
This seems to be a conflict between different install of eigenpy.
I will close this issue as it does not seem related to eigenpy.

For future issues, you should provide a docker image replicating the issue for quick test and debugging.
>  This seems to be a conflict between different install of eigenpy.

Are you sure?

This issue was reproduced by @nim65s.

I think it is too early for making that conclusion.
Please start from a clean installation (e.g. Docker image) and we can discuss after that if the problem still occurs.
I have no anymore the issue after cleaning up `ipython`. I realized that it was leading to segfault with `ipython` only (it was working well with `python`).

This is not exactly the @nim65s condition, but it could be a similar problem.


Could you do: which python/ which ipython?

> Could you do: which python/ which ipython?

No, I couldn't for ipython. But I believe it should be `/usr/bin/ipython`. Now I removed that one, I reinstalled the version using `pip install --user`.

For python, everything remains the same. So `which python` prints `/usr/bin/python`.


What is the recommended approach (pip or apt install version)? 
The thing is that I don't think the issue is really ipython, but rather the fact that they were not based on the same version of Python.
My previous comment was not correct. It still leads to segfault is your write the code using ipython console.

I have created a docker image, and I still find the same issue. You can pull the docker as `docker pull cmastalli/eigenpy-native:latest`, and the code of the Dockerfile is:
```bash
#Eigenpy image
FROM ubuntu:18.04 
MAINTAINER carlos.mastalli@gmail.com

#Set working directory
WORKDIR /home/devel

RUN apt-get update 
RUN apt-get install -y build-essential cmake python git libboost-dev python-dev python-numpy
RUN apt-get install -y libeigen3-dev
RUN apt-get install -y libboost-python-dev
RUN git clone https://github.com/stack-of-tasks/eigenpy.git eigenpy \
&& cd eigenpy \
&& git submodule update --init \
&& mkdir build \
&& cd build \
&& cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=native" \
&& make -j2 \
&& make install
ENV LD_LIBRARY_PATH="/usr/local/lib"
RUN python -c "import eigenpy; print(eigenpy.Quaternion.Identity())"
```

Unfortunately, we need to re-open this issue.



solver either by #232 or #233.

I will close this issue. Thanks again @jcarpent for putting effort in providing a solution (I was getting desperate with this issue) 
Sorry, I need to reopen this issue as there are other problems. I will share a code that shows you which cases work and doesn't.
```python
import pinocchio
import numpy as np

t = np.array([1, 2, 3])
q0 = pinocchio.Quaternion.Identity()
q1 = pinocchio.Quaternion.Identity()
q1.x = 1.
q2 = pinocchio.Quaternion(1, 0, 0, 0)
q3 = pinocchio.Quaternion(np.array([1, 0, 0, 0]))


M0 = pinocchio.SE3(q0, t) # works!
M1 = pinocchio.SE3(q1, t) # works!

M2 = pinocchio.SE3(q2, t) # doesn't works!
M3 = pinocchio.SE3(q3, t) # doesn't works!
```

So, it seems we need to have sort of `static` constructors, right? In any case, I am not sure how this could be fixed.
What is q2?
Did you recompile Pinocchio Python bindings with the same vectorization flags?
Could you update your docker image?
> What is q2?
> Did you recompile Pinocchio Python bindings with the same vectorization flags?
> Could you update your docker image?

I have corrected my previous comment, now you can see what is q2.

Yes, I used the same vectorization flags.
I will try to update the docker today. I will let you know when it is done.
Solved by #235.
> Solved by #235.

I tested the merged PR; and unfortunately, I still find the issue from my side (in this case I used `-march=native -mfpmath=sse`.
How do you test it? 
Please provide a docker image. I’m already spending too much time.
>  Could you update your docker image?

I have updated my docker with Pinocchio installation.
You can also see that cases without Pinocchio also leads to segfault.
I made [this dockerfile](https://github.com/nim65s/gepetto-utils/blob/master/docker/eigenpy/devel.Dockerfile):

```dockerfile
FROM ubuntu:focal

RUN apt-get update -y \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    build-essential \
    cmake \
    git \
    libboost-all-dev \
    libeigen3-dev \
    python3-numpy \
 && rm -rf /var/lib/apt/lists/*

RUN git clone --recursive -b devel https://github.com/stack-of-tasks/eigenpy.git

WORKDIR eigenpy/build

RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=native" -DPYTHON_EXECUTABLE=/usr/bin/python3 ..

RUN make
```

I think this is a minimal and standard way to reproduce this issue.

It can be used directly with `docker run --rm -it gepetto/utils:eigenpy-devel`, but the transfer between different computers of binaries compiled with `-march=native` is usually a bad idea.

This docker image is up-to-date with devel (on 3a7acfcc02b77d66b6c0dbe3410fb7e6dbb6b1fb, ie. with #235 merged).

Running `make test` inside it shows a segfault on the `py-geometry` unit test. 
The C++ corresponding `geometry`unit-test is OK.

I was able to trigger the segfault both with GCC 9.3.10 and Clang 10, on a i5-6600 and on a i9-9900. But maybe, on other CPU families, the behavior will change, because of the `-march=native`.

Hi guys,

Sorry for bothered you again on this topic, but this issue still happens in my side, and #236 is not solving it.

@nim65s can you still reproduce the issue?

@jcarpent why is this issue closed? (we need to re-open this issue)
Too many think to handle. I prefer to close it as it is me which entirely dealing with this kind of issue. 
I understand you are lacking of time.
But, it is useful to keep it open:
  1. to acknowledge the issue 
  2. to let others finding a solution.

Furthermore, if you have an idea how to resolve this issue, then please share it here.
I could try to solve it,
If @jcarpent don't intend to work on it, I suggest to keep it close and tag it `WONTFIX`, which explicitely state that this might not be solved yet.
In principle, if it's a known issue that could lead to a segmentation fault, I'd leave the issue open and add something along the lines of `help wanted`.

**However, I can no longer reproduce this issue with the latest devel branch using the above modified Dockerfile on Ubuntu 20.04.** I've also run EigenPy with `-march=native` in deployment and it's been fine.

Dockerfile modified from Carlos' above (this works fine on my machine):
```docker
FROM ubuntu:20.04 
ARG DEBIAN_FRONTEND=noninteractive
#Set working directory
WORKDIR /home/devel

RUN apt-get update -qq && \
    apt-get install -y build-essential cmake python3 git libboost-dev python3-dev python3-numpy libeigen3-dev libboost-python-dev && \
    rm -rf /var/lib/apt/lists/*
RUN git clone --branch devel --recursive https://github.com/stack-of-tasks/eigenpy.git eigenpy \
&& cd eigenpy \
&& mkdir build \
&& cd build \
&& cmake ../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-march=native" \
&& make -j \
&& make install
ENV LD_LIBRARY_PATH="/usr/local/lib"
ENV PYTHONPATH="/usr/local/lib/python3/dist-packages"
RUN python3 -c "import eigenpy; print(eigenpy.Quaternion.Identity())"
```
Good news if it is working now. Thanks @wxmerkt to check.
It is crashing with this Python code:
```python
import eigenpy; import numpy as np; print(eigenpy.Quaternion(np.eye(3)))
```

and you might need to run it several times to detect the segfault.

@wxmerkt  -- can you confirm if this works or not for you? 

Fix patch:
diff --git a/include/eigenpy/quaternion.hpp b/include/eigenpy/quaternion.hpp
index 7e00edfa3..a9158541f 100644
--- a/include/eigenpy/quaternion.hpp
+++ b/include/eigenpy/quaternion.hpp
@@ -110,12 +110,16 @@ namespace eigenpy
     void visit(PyClass& cl) const 
     {
       cl
-      .def(bp::init<Matrix3>((bp::arg("self"),bp::arg("R")),
-                             "Initialize from rotation matrix.\n"
-                             "\tR : a rotation matrix 3x3.")[bp::return_value_policy<bp::return_by_value>()])
-      .def(bp::init<AngleAxis>((bp::arg("self"),bp::arg("aa")),
-                               "Initialize from an angle axis.\n"
-                               "\taa: angle axis object."))
+      .def("__init__",bp::make_constructor(&QuaternionVisitor::FromRotationMatrix,
+                                           bp::default_call_policies(),
+                                           (bp::arg("R"))),
+                                           "Initialize from rotation matrix.\n"
+                                           "\tR : a rotation matrix 3x3.")
+      .def("__init__",bp::make_constructor(&QuaternionVisitor::FromAngleAxis,
+                                           bp::default_call_policies(),
+                                           (bp::arg("aa"))),
+                                           "Initialize from an angle axis.\n"
+                                           "\taa: angle axis object.")
       .def(bp::init<Quaternion>((bp::arg("self"),bp::arg("quat")),
                                 "Copy constructor.\n"
                                 "\tquat: a quaternion.")[bp::return_value_policy<bp::return_by_value>()])
@@ -130,11 +134,12 @@ namespace eigenpy
            "\tvec4 : a 4D vector representing quaternion coefficients in the order xyzw.")
       .def("__init__",bp::make_constructor(&QuaternionVisitor::DefaultConstructor),
            "Default constructor")
-      .def(bp::init<Scalar,Scalar,Scalar,Scalar>
-           ((bp::arg("self"),bp::arg("w"),bp::arg("x"),bp::arg("y"),bp::arg("z")),
+      .def("__init__",bp::make_constructor(&QuaternionVisitor::FromCoefficients,
+                                           bp::default_call_policies(),
+                                           (bp::arg("w"),bp::arg("x"),bp::arg("y"),bp::arg("z"))),
             "Initialize from coefficients.\n\n"
             "... note:: The order of coefficients is *w*, *x*, *y*, *z*. "
-            "The [] operator numbers them differently, 0...4 for *x* *y* *z* *w*!"))
+            "The [] operator numbers them differently, 0...4 for *x* *y* *z* *w*!")
       
       .add_property("x",
                     &QuaternionVisitor::getCoeff<0>,
@@ -244,16 +249,16 @@ namespace eigenpy
       ;
     }
   private:
-    
+
     template<int i>
     static void setCoeff(Quaternion & self, Scalar value) { self.coeffs()[i] = value; }
-    
+
     template<int i>
     static Scalar getCoeff(Quaternion & self) { return self.coeffs()[i]; }
-    
+
     static Quaternion & setFromTwoVectors(Quaternion & self, const Vector3 & a, const Vector3 & b)
     { return self.setFromTwoVectors(a,b); }
-    
+
     template<typename OtherQuat>
     static Quaternion & assign(Quaternion & self, const OtherQuat & quat)
     { return self = quat; }
@@ -263,24 +268,42 @@ namespace eigenpy
       Quaternion* q(new Quaternion); q->setIdentity();
       return q;
     }
-    
-    static Quaternion* FromTwoVectors(const Vector3& u, const Vector3& v)
+
+    static Quaternion* FromCoefficients(Scalar w, Scalar x, Scalar y, Scalar z)
+    {
+      Quaternion* q(new Quaternion(w, x, y, z));
+      return q;
+    }
+
+    static Quaternion* FromAngleAxis(const AngleAxis& aa)
+    {
+      Quaternion* q(new Quaternion(aa));
+      return q;
+    }
+
+    static Quaternion* FromTwoVectors(const Eigen::Ref<Vector3> u, const Eigen::Ref<Vector3> v)
     {
       Quaternion* q(new Quaternion); q->setFromTwoVectors(u,v);
       return q;
     }
-    
+
     static Quaternion* DefaultConstructor()
     {
       return new Quaternion;
     }
-    
+
     static Quaternion* FromOneVector(const Eigen::Ref<Vector4> v)
     {
       Quaternion* q(new Quaternion(v[3],v[0],v[1],v[2]));
       return q;
     }
-  
+
+    static Quaternion* FromRotationMatrix(const Eigen::Ref<Matrix3> R)
+    {
+      Quaternion* q(new Quaternion(R));
+      return q;
+    }
+
     static bool __eq__(const Quaternion & u, const Quaternion & v)
     {
       return u.coeffs() == v.coeffs();


Test patch:
diff --git a/unittest/matrix.cpp b/unittest/matrix.cpp
index 2982ee81f..f165bd5b5 100644
--- a/unittest/matrix.cpp
+++ b/unittest/matrix.cpp
@@ -101,7 +101,7 @@ generateRowMajorMatrix(const Eigen::DenseIndex rows,
   typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> RowMajorMatrix;
   RowMajorMatrix A(rows, cols);
   typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1> Vector;
-  Eigen::Map<Vector>(A.data(),A.size()) = Vector::LinSpaced(A.size(),1,A.size());
+  Eigen::Map<Vector>(A.data(),A.size()) = Vector::LinSpaced(A.size(), 1, static_cast<Scalar>(A.size()));
   std::cout << "Matrix values:\n" << A << std::endl;
   return A;
 }
@@ -112,7 +112,7 @@ generateRowMajorVector(const Eigen::DenseIndex size)
 {
   typedef Eigen::Matrix<Scalar,1,Eigen::Dynamic,Eigen::RowMajor> RowMajorVector;
   RowMajorVector A(size);
-  A.setLinSpaced(size,1,size);
+  A.setLinSpaced(size, 1, static_cast<Scalar>(size));
   std::cout << "Vector values: " << A.transpose() << std::endl;
   return A;
 }
@@ -125,7 +125,7 @@ generateColMajorMatrix(const Eigen::DenseIndex rows,
   typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> ColMajorMatrix;
   ColMajorMatrix A(rows, cols);
   typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1> Vector;
-  Eigen::Map<Vector>(A.data(),A.size()) = Vector::LinSpaced(A.size(),1,A.size());
+  Eigen::Map<Vector>(A.data(),A.size()) = Vector::LinSpaced(A.size(), 1, static_cast<Scalar>(A.size()));
   std::cout << "Matrix values:\n" << A << std::endl;
   return A;
 }
@@ -136,7 +136,7 @@ generateColMajorVector(const Eigen::DenseIndex size)
 {
   typedef Eigen::Matrix<Scalar,1,Eigen::Dynamic> ColMajorVector;
   ColMajorVector A(size);
-  A.setLinSpaced(size,1,size);
+  A.setLinSpaced(size, 1, static_cast<Scalar>(size));
   std::cout << "Vector values: " << A.transpose() << std::endl;
   return A;
 }
diff --git a/unittest/python/test_geometry.py b/unittest/python/test_geometry.py
index 86332f242..2caa9fc9d 100644
--- a/unittest/python/test_geometry.py
+++ b/unittest/python/test_geometry.py
@@ -13,15 +13,21 @@ def isapprox(a,b,epsilon=1e-6):
         return abs(a-b)<epsilon
 
 # --- Quaternion ---------------------------------------------------------------
+# Coefficient initialisation
+verbose and print("[Quaternion] Coefficient initialisation")
 q = Quaternion(1,2,3,4)
 q.normalize()
 assert(isapprox(np.linalg.norm(q.coeffs()),q.norm()))
 assert(isapprox(np.linalg.norm(q.coeffs()),1))
 
+# Coefficient-vector initialisation
+verbose and print("[Quaternion] Coefficient-vector initialisation")
 v = np.array([0.5,-0.5,0.5,0.5])
 qv = Quaternion(v)
 assert(isapprox(qv.coeffs(), v))
 
+# Angle axis initialisation
+verbose and print("[Quaternion] AngleAxis initialisation")
 r = AngleAxis(q)
 q2 = Quaternion(r)
 assert(q==q)
@@ -34,6 +40,8 @@ def isapprox(a,b,epsilon=1e-6):
 assert(isapprox(Rq.dot(Rq.T),np.eye(3)))
 assert(isapprox(Rr,Rq))
 
+# Rotation matrix initialisation
+verbose and print("[Quaternion] Rotation Matrix initialisation")
 qR = Quaternion(Rr)
 assert(q.isApprox(qR))
 assert(isapprox(q.coeffs(),qR.coeffs()))
@@ -43,7 +51,7 @@ def isapprox(a,b,epsilon=1e-6):
    qR[5]
    print("Error, this message should not appear.")
 except RuntimeError as e:
-  if verbose: print("As expected, catched exception: ",e)
+  if verbose: print("As expected, caught exception: ", e)
 
 # --- Angle Vector ------------------------------------------------
 r = AngleAxis(.1,np.array([1,0,0],np.double))