diff --git a/.gitignore b/.gitignore index 21ca0c7eb..b56fdea15 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build/ release/ _build/ _release/ -*~ \ No newline at end of file +*~ +Xcode/ diff --git a/CMakeLists.txt b/CMakeLists.txt index fbfbe1521..4264d84c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,17 @@ # -# Copyright 2014 CNRS +# Copyright (c) 2015 LAAS-CNRS +# +# This file is part of eigenpy. +# eigenpy is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# eigenpy is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. You should +# have received a copy of the GNU Lesser General Public License along +# with eigenpy. If not, see . # CMAKE_MINIMUM_REQUIRED(VERSION 2.6) @@ -23,6 +35,15 @@ IF(APPLE) SET(CMAKE_MACOSX_RPATH TRUE) ENDIF(APPLE) +# ---------------------------------------------------- +# --- OPTIONS --------------------------------------- +# ---------------------------------------------------- +OPTION (EIGEN_NUMPY_ALIGNED "Directly aligned data between Numpy and Eigen" OFF) + +IF(EIGEN_NUMPY_ALIGNED) + ADD_DEFINITIONS(-DEIGENPY_ALIGNED) +ENDIF(EIGEN_NUMPY_ALIGNED) + # ---------------------------------------------------- # --- DEPENDANCIES ----------------------------------- # ---------------------------------------------------- @@ -102,6 +123,9 @@ ADD_LIBRARY(geometry SHARED unittest/geometry.cpp) TARGET_LINK_LIBRARIES(geometry ${Boost_LIBRARIES} ${PROJECT_NAME}) SET_TARGET_PROPERTIES(geometry PROPERTIES PREFIX "") +IF(EIGEN_NUMPY_ALIGNED) + PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED") +ENDIF(EIGEN_NUMPY_ALIGNED) PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}") PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}") PKG_CONFIG_APPEND_LIBS("boost_python") diff --git a/src/details.cpp b/src/details.cpp index d77c6c0c7..c77a0be89 100644 --- a/src/details.cpp +++ b/src/details.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015 LAAS-CNRS + * + * This file is part of eigenpy. + * eigenpy is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * eigenpy is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. You should + * have received a copy of the GNU Lesser General Public License along + * with eigenpy. If not, see . + */ + #include "eigenpy/details.hpp" namespace eigenpy diff --git a/src/details.hpp b/src/details.hpp index ce9ba1bc4..8989f3037 100644 --- a/src/details.hpp +++ b/src/details.hpp @@ -108,7 +108,7 @@ namespace eigenpy { static MatType & construct(void*storage,int /*r*/,int c) { - return * new(storage) MatType(c); + return * new(storage) MatType(R,c); } }; @@ -117,7 +117,7 @@ namespace eigenpy { static MatType & construct(void*storage,int r,int /*c*/) { - return * new(storage) MatType(r); + return * new(storage) MatType(r,C); } }; @@ -168,7 +168,6 @@ namespace eigenpy static void construct(PyObject* pyObj, bp::converter::rvalue_from_python_stage1_data* memory) { - typedef typename MatType::Scalar T; using namespace Eigen; PyArrayObject * pyArray = reinterpret_cast(pyObj); @@ -191,20 +190,26 @@ namespace eigenpy void enableEigenPySpecific() { import_array(); - - #ifdef EIGEN_DONT_VECTORIZE + +#ifdef EIGEN_DONT_VECTORIZE + boost::python::to_python_converter >(); + eigenpy::EigenToPy >(); eigenpy::EigenFromPy(); - #else - typedef typename eigenpy::UnalignedEquivalent::type MatTypeDontAlign; +#else boost::python::to_python_converter >(); + eigenpy::EigenFromPy(); + + typedef typename eigenpy::UnalignedEquivalent::type MatTypeDontAlign; +#ifndef EIGENPY_ALIGNED boost::python::to_python_converter >(); eigenpy::EigenFromPy(); #endif +#endif + } diff --git a/src/eigenpy.cpp b/src/eigenpy.cpp index 088c2b3fd..d0b685eb1 100644 --- a/src/eigenpy.cpp +++ b/src/eigenpy.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015 LAAS-CNRS + * + * This file is part of eigenpy. + * eigenpy is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * eigenpy is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. You should + * have received a copy of the GNU Lesser General Public License along + * with eigenpy. If not, see . + */ + #include "eigenpy/eigenpy.hpp" namespace eigenpy diff --git a/src/exception.cpp b/src/exception.cpp index 3c20f3a38..b8ac24cad 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2015 LAAS-CNRS + * + * This file is part of eigenpy. + * eigenpy is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * eigenpy is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. You should + * have received a copy of the GNU Lesser General Public License along + * with eigenpy. If not, see . + */ + #include diff --git a/src/fwd.hpp b/src/fwd.hpp index b137f1df8..37aa6a203 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -27,11 +27,15 @@ namespace eigenpy { typedef Eigen::MatrixBase MatType; typedef Eigen::Matrix type; + D::RowsAtCompileTime, + D::ColsAtCompileTime, +#ifndef EIGENPY_ALIGNED + D::Options | Eigen::DontAlign, +#else + D::Options, +#endif + D::MaxRowsAtCompileTime, + D::MaxColsAtCompileTime> type; }; } // namespace eigenpy diff --git a/src/quaternion.hpp b/src/quaternion.hpp index 279bdeac1..f93c30e41 100644 --- a/src/quaternion.hpp +++ b/src/quaternion.hpp @@ -39,7 +39,11 @@ namespace eigenpy template<> struct UnalignedEquivalent { - typedef Eigen::Quaternion type; +#ifndef EIGENPY_ALIGNED + typedef Eigen::Quaternion type; +#else + typedef Eigen::Quaterniond type; +#endif }; namespace bp = boost::python; @@ -51,10 +55,15 @@ namespace eigenpy typedef Eigen::QuaternionBase QuaternionBase; typedef typename eigenpy::UnalignedEquivalent::type QuaternionUnaligned; - typedef typename QuaternionUnaligned::Scalar Scalar; - typedef Eigen::Matrix Vector3; + typedef typename QuaternionBase::Scalar Scalar; typedef typename QuaternionUnaligned::Coefficients Coefficients; +#ifndef EIGENPY_ALIGNED + typedef Eigen::Matrix Vector3; typedef Eigen::Matrix Matrix3; +#else + typedef Eigen::Matrix Vector3; + typedef Eigen::Matrix Matrix3; +#endif typedef Eigen::AngleAxis AngleAxisUnaligned; @@ -169,8 +178,10 @@ namespace eigenpy bp::init<>()) .def(QuaternionVisitor()) ; - + +#ifndef EIGENPY_ALIGNED bp::to_python_converter< Quaternion,QuaternionVisitor >(); +#endif } }; diff --git a/unittest/geometry.cpp b/unittest/geometry.cpp index 0490eb596..8782d1b4c 100644 --- a/unittest/geometry.cpp +++ b/unittest/geometry.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2015 LAAS-CNRS + * + * This file is part of eigenpy. + * eigenpy is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * eigenpy is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. You should + * have received a copy of the GNU Lesser General Public License along + * with eigenpy. If not, see . + */ #include "eigenpy/eigenpy.hpp" #include "eigenpy/geometry.hpp"