#ifndef CGAL_LA_EIGEN_H #define CGAL_LA_EIGEN_H #ifndef CGAL_USE_EIGEN #error Requires Eigen #endif #include #include #include #include #include #include namespace CGAL { template struct LA_eigen { typedef NT_ NT; // Dim_ real dimension // Max_dim_ upper bound on the dimension template struct Vector { typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> type; typedef Construct_eigen Constructor; //typedef NT const* const_iterator; //FIXME: use Matrix_base instead in the iterator? typedef Iterator_from_indices const_iterator; templatestatic const_iterator vector_begin(Vec_ const&a){ return const_iterator(a,0); } templatestatic const_iterator vector_end(Vec_ const&a){ return const_iterator(a,a.size()); } }; template struct Matrix { //TODO: don't pass on the values of Max_* for an expensive NT typedef Eigen::Matrix::value,Eigen_dimension::value,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,Eigen_dimension::value> type; // typedef ... Constructor // typedef ... Accessor }; private: template class Canonicalize_vector { typedef typename Dimension_eigen::type S1; typedef typename Dimension_eigen::type S2; public: typedef typename Vector::type type; }; public: templatestatic NT dot_product(Vec_ const&a,Vec_ const&b){ return a.dot(b); } template static NT determinant(Mat_ const&m,bool=false){ return m.determinant(); } template static typename Same_uncertainty_nt::type sign_of_determinant(Mat_ const&m,bool=false) { return CGAL::sign(m.determinant()); } template static typename Canonicalize_vector::type homogeneous_add(Vec1 const&a,Vec2 const&b){ //TODO: use compile-time size when available int d=a.size(); typename Canonicalize_vector::type v(d); v << b[d-1]*a.topRows(d-1)+a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; return v; } template static typename Canonicalize_vector::type homogeneous_sub(Vec1 const&a,Vec2 const&b){ int d=a.size(); typename Canonicalize_vector::type v(d); v << b[d-1]*a.topRows(d-1)-a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; return v; } template static std::pair homogeneous_dot_product(Vec1 const&a,Vec2 const&b){ int d=a.size(); return make_pair(a.topRows(d-1).dot(b.topRows(d-1)), a[d-1]*b[d-1]); } }; } #endif