diff --git a/.gitignore b/.gitignore index 21ca0c7eba141c37cae3811f70eacff3fad3ac06..b56fdea15bad3463d0e3d78fea90f6ae749a09bf 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 fbfbe15217d253aa1c5ef4e00d2289b5d24024e1..4264d84c4f6d7be737a3dd4ef4ce2a7dc16c5ce0 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 <http://www.gnu.org/licenses/>. # 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 d77c6c0c7287d6b0a8768726d7e6ddedeb239ffa..c77a0be89a4f903c1d53ec96b7446dacac78fe75 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 <http://www.gnu.org/licenses/>. + */ + #include "eigenpy/details.hpp" namespace eigenpy diff --git a/src/details.hpp b/src/details.hpp index ce9ba1bc4cc0190f16809465cb4bdd8b7dd19ab7..8989f30370c2d361e081e12a668f4552319ce4dd 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<PyArrayObject*>(pyObj); @@ -191,20 +190,26 @@ namespace eigenpy void enableEigenPySpecific() { import_array(); - - #ifdef EIGEN_DONT_VECTORIZE + +#ifdef EIGEN_DONT_VECTORIZE + boost::python::to_python_converter<MatType, - eigenpy::EigenToPy<MatType,MatType> >(); + eigenpy::EigenToPy<MatType,MatType> >(); eigenpy::EigenFromPy<MatType,MatType>(); - #else - typedef typename eigenpy::UnalignedEquivalent<MatType>::type MatTypeDontAlign; +#else boost::python::to_python_converter<MatType, eigenpy::EigenToPy<MatType,MatType> >(); + eigenpy::EigenFromPy<MatType,MatType>(); + + typedef typename eigenpy::UnalignedEquivalent<MatType>::type MatTypeDontAlign; +#ifndef EIGENPY_ALIGNED boost::python::to_python_converter<MatTypeDontAlign, eigenpy::EigenToPy<MatTypeDontAlign,MatTypeDontAlign> >(); eigenpy::EigenFromPy<MatTypeDontAlign,MatTypeDontAlign>(); #endif +#endif + } diff --git a/src/eigenpy.cpp b/src/eigenpy.cpp index 088c2b3fd299bf449a8b9c626e58cce5c2a82561..d0b685eb1490be7e423521f7a40dba068279f701 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 <http://www.gnu.org/licenses/>. + */ + #include "eigenpy/eigenpy.hpp" namespace eigenpy diff --git a/src/exception.cpp b/src/exception.cpp index 3c20f3a38dc8631317ceaa46750b9261cd970e12..b8ac24cad2b7e9063becd5d7ae31255b3172124e 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 <http://www.gnu.org/licenses/>. + */ + #include <eigenpy/exception.hpp> diff --git a/src/fwd.hpp b/src/fwd.hpp index b137f1df8236182a7873e7e346ecdab361277a6d..37aa6a2033dc705e6207e0086a0f138a41d6a91f 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -27,11 +27,15 @@ namespace eigenpy { typedef Eigen::MatrixBase<D> MatType; typedef Eigen::Matrix<typename D::Scalar, - D::RowsAtCompileTime, - D::ColsAtCompileTime, - D::Options | Eigen::DontAlign, - D::MaxRowsAtCompileTime, - D::MaxColsAtCompileTime> 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 279bdeac1e9298204e11d49ff3539e257557b615..f93c30e41257c8000d23478918cb1a27a7fdacc6 100644 --- a/src/quaternion.hpp +++ b/src/quaternion.hpp @@ -39,7 +39,11 @@ namespace eigenpy template<> struct UnalignedEquivalent<Eigen::Quaterniond> { - typedef Eigen::Quaternion<double,Eigen::DontAlign> type; +#ifndef EIGENPY_ALIGNED + typedef Eigen::Quaternion<Eigen::Quaterniond::Scalar,Eigen::DontAlign> type; +#else + typedef Eigen::Quaterniond type; +#endif }; namespace bp = boost::python; @@ -51,10 +55,15 @@ namespace eigenpy typedef Eigen::QuaternionBase<Quaternion> QuaternionBase; typedef typename eigenpy::UnalignedEquivalent<Quaternion>::type QuaternionUnaligned; - typedef typename QuaternionUnaligned::Scalar Scalar; - typedef Eigen::Matrix<Scalar,3,1,Eigen::DontAlign> Vector3; + typedef typename QuaternionBase::Scalar Scalar; typedef typename QuaternionUnaligned::Coefficients Coefficients; +#ifndef EIGENPY_ALIGNED + typedef Eigen::Matrix<Scalar,3,1,Eigen::DontAlign> Vector3; typedef Eigen::Matrix<Scalar,3,3,Eigen::DontAlign> Matrix3; +#else + typedef Eigen::Matrix<Scalar,3,1,0> Vector3; + typedef Eigen::Matrix<Scalar,3,3,0> Matrix3; +#endif typedef Eigen::AngleAxis<Scalar> AngleAxisUnaligned; @@ -169,8 +178,10 @@ namespace eigenpy bp::init<>()) .def(QuaternionVisitor<Quaternion>()) ; - + +#ifndef EIGENPY_ALIGNED bp::to_python_converter< Quaternion,QuaternionVisitor<Quaternion> >(); +#endif } }; diff --git a/unittest/geometry.cpp b/unittest/geometry.cpp index 0490eb5969144c75fc0ed35c053e05071ba40813..8782d1b4c2f6f2c2a6eb36fc1d330133721b06b6 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 <http://www.gnu.org/licenses/>. + */ #include "eigenpy/eigenpy.hpp" #include "eigenpy/geometry.hpp"