diff --git a/.gitattributes b/.gitattributes index 15b2ddec874..f4212a09791 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1819,6 +1819,7 @@ Jet_fitting_3/doc_tex/Jet_fitting_3/david-dirmaxkmin-white-back.jpg -text svneol Jet_fitting_3/doc_tex/Jet_fitting_3/jet_fitting_basis.gif -text svneol=unset#image/gif Jet_fitting_3/doc_tex/Jet_fitting_3/jet_fitting_basis.pdf -text svneol=unset#application/pdf Jet_fitting_3/doc_tex/Jet_fitting_3/ppal_curv_poly2x2+y2.jpg -text svneol=unset#image/jpeg +Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Eigen_svd.tex -text Jet_fitting_3/doc_tex/Jet_fitting_3_ref/template_dependence.jpg -text svneol=unset#image/jpeg Jet_fitting_3/doc_tex/Jet_fitting_3_ref/template_dependence.pdf -text svneol=unset#application/pdf Jet_fitting_3/examples/Jet_fitting_3/data/ellipe0.003.off -text svneol=unset#application/octet-stream @@ -3461,6 +3462,7 @@ Snap_rounding_2/test/Snap_rounding_2/cgal_test_base -text Snap_rounding_2/test/Snap_rounding_2/cgal_test_with_cmake eol=lf Solver_interface/include/CGAL/Eigen_matrix.h -text Solver_interface/include/CGAL/Eigen_solver_traits.h -text +Solver_interface/include/CGAL/Eigen_svd.h -text Solver_interface/include/CGAL/Eigen_vector.h -text Spatial_searching/TODO.txt -text Spatial_searching/benchmark/Spatial_searching/Compare_ANN_STANN_CGAL.cpp -text diff --git a/Installation/cmake/modules/CGAL_UseLAPACK.cmake b/Installation/cmake/modules/CGAL_UseLAPACK.cmake index 51c8bca807f..024ef03a32c 100644 --- a/Installation/cmake/modules/CGAL_UseLAPACK.cmake +++ b/Installation/cmake/modules/CGAL_UseLAPACK.cmake @@ -33,6 +33,8 @@ if ( LAPACK_FOUND AND NOT CGAL_LAPACK_SETUP ) # Setup is done set ( CGAL_LAPACK_SETUP TRUE ) + + add_definitions(-DCGAL_LAPACK_ENABLED) endif() diff --git a/Installation/cmake/modules/CGAL_UseTAUCS.cmake b/Installation/cmake/modules/CGAL_UseTAUCS.cmake index ed44c7b0bce..2bea35c7c3a 100644 --- a/Installation/cmake/modules/CGAL_UseTAUCS.cmake +++ b/Installation/cmake/modules/CGAL_UseTAUCS.cmake @@ -24,5 +24,7 @@ if ( TAUCS_FOUND AND NOT CGAL_TAUCS_SETUP ) # Setup is done set ( CGAL_TAUCS_SETUP TRUE ) + add_definitions(-DCGAL_TAUCS_ENABLED) + endif() diff --git a/Installation/doc_tex/Installation/installation.tex b/Installation/doc_tex/Installation/installation.tex index 0c4ce3a26d6..d6edb77a317 100644 --- a/Installation/doc_tex/Installation/installation.tex +++ b/Installation/doc_tex/Installation/installation.tex @@ -249,11 +249,11 @@ version provided in the download section. \subsection{Eigen \label{thirdparty:Eigen}} -{\sc Eigen} is a matrix manipulation library. \ccc{Eigen} supports all - matrix sizes, various matrix decomposition methods and sparse linear solvers. In \cgal, {\sc Eigen} is used as +\eigen is a matrix manipulation library. \eigen supports all + matrix sizes, various matrix decomposition methods and sparse linear solvers. In \cgal, \eigen is used as an alternative to \taucs\ which also provides sparse linear solvers. -The {\sc Eigen} web site is \ccAnchor{http://eigen.tuxfamily.org}{\path|http://eigen.tuxfamily.org|}. +The \eigen web site is \eigenpage. \subsection{Blas \label{thirdparty:Blas}} @@ -1142,7 +1142,7 @@ usage of TAUCS-METIS will be disabled. \index{cgal!general-config-cmake-vars-dep-eigen}\index{cgal configuration cmake variables - dependencies - eigen} \subsubsection{Eigen library} -{\sc Eigen} is a header-only template library. +\eigen is a header-only template library. Only the {\em directory} containing the header files is needed. {\ccTexHtml{\small}{} diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3/Jet_fitting_3_user.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3/Jet_fitting_3_user.tex index ddb28f415d8..d4a167b6ec6 100644 --- a/Jet_fitting_3/doc_tex/Jet_fitting_3/Jet_fitting_3_user.tex +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3/Jet_fitting_3_user.tex @@ -19,9 +19,9 @@ This package allows the estimation of local differential quantities of a surface from a point sample, given either as a mesh or as point cloud. -Note that this package needs the third party libraries -\ccThirdPartyLapack\ and \ccThirdPartyBlas\ to be installed to compile -the example code. +Note that this package either needs the third party library +\ccThirdPartyEigen, or \ccThirdPartyLapack\ and \ccThirdPartyBlas\ +to be installed to compile the example code. %%%%%%%%%%%%%%%%%%%%%%% \section{Introduction\label{sec:intro}} @@ -258,14 +258,13 @@ the coordinate system of the PCA (in which the fitting is performed). This concept provides the types for the input sample points, together with $3d$ vectors and a number type. It is used as template for the -classe \ccc{Monge_via_jet_fitting, SvdTraits = lapack_svd>} . Typically, one can use +class \ccc{Monge_via_jet_fitting} . Typically, one can use \ccc{CGAL::Cartesian}. \subsubsection{Template parameter \texttt{LocalKernel}} %%%%%%%%%%% This is a parameter of the class -\ccc{Monge_via_jet_fitting, SvdTraits = lapack_svd>}. +\ccc{Monge_via_jet_fitting}. This concept defines the vector and number types used for local computations and to store the PCA basis data. @@ -281,7 +280,7 @@ one can use This concept provides the number, vector and matrix types for algebra operations required by the fitting method in -\ccc{Monge_via_jet_fitting, SvdTraits = lapack_svd>} +\ccc{Monge_via_jet_fitting} . The main method is a linear solver using a singular value decomposition. \subsubsection{Compatibility requirements} diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3/PkgDescription.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3/PkgDescription.tex index b73cb366842..cb42a58622e 100644 --- a/Jet_fitting_3/doc_tex/Jet_fitting_3/PkgDescription.tex +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3/PkgDescription.tex @@ -10,7 +10,7 @@ curvature lines, etc. This package allows the estimation of local differential quantities of a surface from a point sample.} -\ccPkgDependsOn{Solvers as \ccThirdPartyLapack\ and \ccThirdPartyBlas.} +\ccPkgDependsOn{either \ccThirdPartyEigen, or \ccThirdPartyLapack\ and \ccThirdPartyBlas for solvers.} \ccPkgIntroducedInCGAL{3.3} \ccPkgLicense{\ccLicenseQPL} %\ccPkgDemo{Operations on Polyhedra}{polyhedron_3.zip} diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Eigen_svd.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Eigen_svd.tex new file mode 100644 index 00000000000..a386fa99b86 --- /dev/null +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Eigen_svd.tex @@ -0,0 +1,20 @@ +\begin{ccRefClass}{Eigen_svd} + +\ccDefinition + +The class \ccRefName\ provides an algorithm to solve in the least +square sense a linear system with a singular value decomposition using +\ccc{Eigen}. The field type is \ccc{double}. + +\ccInclude{CGAL/Eigen_svd.h} + +\ccIsModel +\ccc{SvdTraits} + +\end{ccRefClass} + +% +------------------------------------------------------------------------+ +%%RefPage: end of main body, begin of footer +% EOF +% +------------------------------------------------------------------------+ + diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Monge_via_jet_fitting.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Monge_via_jet_fitting.tex index 3448814d4bb..ec8875189f1 100644 --- a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Monge_via_jet_fitting.tex +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Monge_via_jet_fitting.tex @@ -30,7 +30,8 @@ the particular information returned depending on the degrees specified for the polynomial fitting and for the Monge form. The default for the template \ccc{LocalKernel} is -\ccc{Cartesian} and the default for \ccc{SvdTraits} is \ccc{Lapack_svd}. +\ccc{Cartesian} and the default for \ccc{SvdTraits} is \ccc{Eigen_svd} if \ccc{CGAL_EIGEN3_ENABLED} +is defined and \ccc{Lapack_svd} otherwise. \ccInclude{CGAL/Monge_via_jet_fitting.h} @@ -160,6 +161,7 @@ algebra algorithm required by the fitting method. \ccSeeAlso +\ccc{Eigen_svd}, \ccc{Lapack_svd}, \ccc{Monge_form} diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/SvdTraits.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/SvdTraits.tex index 0d84396c123..c02f4f7d097 100644 --- a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/SvdTraits.tex +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/SvdTraits.tex @@ -81,6 +81,7 @@ number of $M$. The solution is stored in $B$.} \ccHasModels % +------------------------------------------------------------------ +\ccc{Eigen_svd}, \ccc{Lapack_svd}. \ccSeeAlso diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/intro.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/intro.tex index 4819d8df007..a14281edf9d 100644 --- a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/intro.tex +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/intro.tex @@ -45,6 +45,7 @@ Surfaces via Polynomial Fitting\label{ref_chap:Jet_fitting_3}} \subsection*{Classes} \ccRefIdfierPage{CGAL::Monge_via_jet_fitting< DataKernel, LocalKernel, SvdTraits>::Monge_form}\\ \ccRefIdfierPage{CGAL::Monge_via_jet_fitting}\\ +\ccRefIdfierPage{CGAL::Eigen_svd}\\ \ccRefIdfierPage{CGAL::Lapack_svd}\\ \subsection*{Global Functions} diff --git a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/main.tex b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/main.tex index 3416acd7e44..e027cd0e3cd 100644 --- a/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/main.tex +++ b/Jet_fitting_3/doc_tex/Jet_fitting_3_ref/main.tex @@ -8,6 +8,7 @@ \input{Jet_fitting_3_ref/intro.tex} \input{Jet_fitting_3_ref/DataKernel.tex} +\input{Jet_fitting_3_ref/Eigen_svd.tex} \input{Jet_fitting_3_ref/Lapack_svd.tex} \input{Jet_fitting_3_ref/LocalKernel.tex} \input{Jet_fitting_3_ref/Monge_form.tex} diff --git a/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt b/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt index 5a71d6197fb..d4fcbf8e4ac 100644 --- a/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt +++ b/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt @@ -21,12 +21,18 @@ if ( CGAL_FOUND ) include( CGAL_CreateSingleSourceCGALProgram ) - # Link with BLAS and LAPACK (required) - find_package(LAPACK) - if(LAPACK_FOUND) - - include( ${LAPACK_USE_FILE} ) - + # use either Eigen or BLAS/LAPACK + find_package(Eigen3) + if (NOT EIGEN3_FOUND) + find_package(LAPACK) + if(LAPACK_FOUND) + include( ${LAPACK_USE_FILE} ) + endif(LAPACK_FOUND) + else() + include( ${EIGEN3_USE_FILE} ) + endif() + + if(EIGEN3_FOUND OR LAPACK_FOUND) # Link with Boost.ProgramOptions (optional) find_package(Boost QUIET COMPONENTS program_options) if(Boost_PROGRAM_OPTIONS_FOUND) @@ -44,11 +50,11 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "Mesh_estimation.cpp" ) create_single_source_cgal_program( "Single_estimation.cpp" ) - else(LAPACK_FOUND) + else(EIGEN3_FOUND OR LAPACK_FOUND) - message(STATUS "NOTICE: This program requires LAPACK, and will not be compiled.") + message(STATUS "NOTICE: This program requires either Eigen 3 (or greater) or LAPACK, and will not be compiled.") - endif(LAPACK_FOUND) + endif(EIGEN3_FOUND OR LAPACK_FOUND) else() diff --git a/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h b/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h index f38781799f7..eb130142fde 100644 --- a/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h +++ b/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h @@ -23,10 +23,15 @@ #include #include #include -#include #include #include +#ifdef CGAL_EIGEN3_ENABLED +#include +#else +#include +#endif + namespace CGAL { inline @@ -37,7 +42,11 @@ unsigned int fact(unsigned int n){ } ////////////////////// CLASS Monge_via_jet_fitting //////////////////////// +#ifdef CGAL_EIGEN3_ENABLED +template < class DataKernel, class LocalKernel = Cartesian, class SvdTraits = Eigen_svd > +#else template < class DataKernel, class LocalKernel = Cartesian, class SvdTraits = Lapack_svd> +#endif class Monge_via_jet_fitting { public: //////////////////////begin nested CLASS Monge_form /////////////////// diff --git a/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt b/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt index cebf1ac2d19..8d35f979a2a 100644 --- a/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt +++ b/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt @@ -21,22 +21,29 @@ if ( CGAL_FOUND ) include( CGAL_CreateSingleSourceCGALProgram ) - # Link with BLAS and LAPACK (required) - find_package(LAPACK) + # use either Eigen or BLAS/LAPACK + find_package(Eigen3) + if (NOT EIGEN3_FOUND) + find_package(LAPACK) + if(LAPACK_FOUND) + include( ${LAPACK_USE_FILE} ) + endif(LAPACK_FOUND) + else() + include( ${EIGEN3_USE_FILE} ) + endif() + - if(LAPACK_FOUND) + if(EIGEN3_FOUND OR LAPACK_FOUND) - include( ${LAPACK_USE_FILE} ) - - include_directories (BEFORE ../../include) + include_directories (BEFORE ../../include) create_single_source_cgal_program( "blind_1pt.cpp" ) - else(LAPACK_FOUND) + else(EIGEN3_FOUND OR LAPACK_FOUND) - message(STATUS "NOTICE: This program requires LAPACK, and will not be compiled.") + message(STATUS "NOTICE: This program requires either Eigen 3 (or greater) or LAPACK, and will not be compiled.") - endif(LAPACK_FOUND) + endif(EIGEN3_FOUND OR LAPACK_FOUND) else() diff --git a/Manual/doc_tex/Manual/cgal_manual.sty b/Manual/doc_tex/Manual/cgal_manual.sty index 8a77d8acfa0..9e73970630e 100644 --- a/Manual/doc_tex/Manual/cgal_manual.sty +++ b/Manual/doc_tex/Manual/cgal_manual.sty @@ -253,6 +253,7 @@ \newcommand{\ccThirdPartyBlas}{\ccThirdParty{Blas}} \newcommand{\ccThirdPartyAtlas}{\ccThirdParty{Atlas}} \newcommand{\ccThirdPartyRS}{\ccThirdParty{RS}} +\newcommand{\ccThirdPartyEigen}{\ccThirdParty{Eigen}} % --------- plain names of thirdparty stuff ------- @@ -273,6 +274,7 @@ \newcommand{\atlas}{\textsc{atlas}} \newcommand{\lapack}{\textsc{lapack}} \newcommand{\exacus}{\textsc{Exacus}} +\newcommand{\eigen}{\textsc{Eigen}} % macros for WWW pages @@ -301,7 +303,7 @@ \newcommand{\cpackpage}{\path'http://www.cmake.org/cmake/help/cpack2.6docs.html'} \newcommand{\nsispage}{\path'http://nsis.sourceforge.net/Main\_Page'} \newcommand{\fhs}{\path'http://www.pathname.com/fhs/pub/fhs-2.3.html'} - +\newcommand{\eigenpage}{\path'http://eigen.tuxfamily.org'} % Implement the two columns layout for the HTML converted part % ------------------------------------------------------------ diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 096921576a0..ba83a3a4031 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -59,11 +59,26 @@ if(QT4_FOUND) find_package(QGLViewer ) endif(QT4_FOUND) -# Find LAPACK (optional), for curvatures estimation -find_package(LAPACK) -# Find TAUCS (optionnal), for parametrization -find_package(TAUCS) + +# Eigen is now used by default +find_package(Eigen3) +if (NOT EIGEN3_FOUND) + # Find LAPACK (optional), for curvatures estimation + find_package(LAPACK) + if(LAPACK_FOUND) + include( ${LAPACK_USE_FILE} ) + endif(LAPACK_FOUND) + + # Find TAUCS (optionnal), for parametrization + find_package(TAUCS) + if(TAUCS_FOUND) + include( ${TAUCS_USE_FILE} ) + endif(TAUCS_FOUND) +else() + include( ${EIGEN3_USE_FILE} ) +endif() + if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) @@ -71,21 +86,15 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) include_directories ( ${QGLVIEWER_INCLUDE_DIR} ) - # Link with BLAS, LAPACK and TAUCS (optional) - if(TAUCS_FOUND) - include( ${TAUCS_USE_FILE} ) - add_definitions(-DCGAL_TAUCS_ENABLED) - else(TAUCS_FOUND) - message(STATUS "NOTICE: TAUCS is not found. parametrization will not be available.") - endif(TAUCS_FOUND) + # Parameterization needs Eigen3 or TAUCS + if(NOT EIGEN3_FOUND AND NOT TAUCS_FOUND) + message(STATUS "NOTICE: Eigen 3 and TAUCS is not found. parametrization will not be available.") + endif(NOT EIGEN3_FOUND AND NOT TAUCS_FOUND) - # Link with BLAS and LAPACK only (optional) - if(LAPACK_FOUND) - include( ${LAPACK_USE_FILE} ) - add_definitions(-DCGAL_LAPACK_ENABLED) - else(LAPACK_FOUND) - message(STATUS "NOTICE: LAPACK is not found. curvatures estimation will not be available.") - endif(LAPACK_FOUND) + # Curvature estimation needs Eigen3 or LAPACK + if(NOT EIGEN3_FOUND AND NOT LAPACK_FOUND) + message(STATUS "NOTICE: Eigen 3 and LAPACK is not found. curvatures estimation will not be available.") + endif(NOT EIGEN3_FOUND AND NOT LAPACK_FOUND) qt4_wrap_ui( MainWindowUI_files MainWindow.ui ) qt4_wrap_ui( Show_point_dialogUI_FILES Show_point_dialog.ui ) @@ -158,11 +167,11 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) Scene_edit_polyhedron_item.cpp Scene_edit_polyhedron_item.moc) target_link_libraries(scene_edit_polyhedron_item scene_polyhedron_item demo_framework) - if(TAUCS_FOUND) + if(EIGEN3_FOUND OR TAUCS_FOUND) add_library(scene_textured_polyhedron_item SHARED Scene_textured_polyhedron_item.cpp texture.cpp Scene_textured_polyhedron_item.moc) target_link_libraries(scene_textured_polyhedron_item demo_framework) - endif(TAUCS_FOUND) + endif(EIGEN3_FOUND OR TAUCS_FOUND) add_library(scene_polygon_soup_item SHARED Scene_polygon_soup_item.cpp Scene_polygon_soup_item.moc) @@ -194,7 +203,7 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) # Viewer_moc.cpp ${MainWindowUI_files} ${RESOURCE_FILES} ) add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 ) - if(TAUCS_FOUND) + if(EIGEN3_FOUND OR TAUCS_FOUND) # add_executable( Polyhedron_3 Scene_tex_rendering.cpp Scene_tex_polyhedron_operations.cpp ) endif() # else(POLYHEDRON_DEMO_ENABLE_FORWARD_DECL) @@ -297,10 +306,10 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) polyhedron_demo_plugin(pca_plugin Polyhedron_demo_pca_plugin) target_link_libraries(pca_plugin scene_polyhedron_item scene_basic_objects) - if(TAUCS_FOUND) + if(EIGEN3_FOUND OR TAUCS_FOUND) polyhedron_demo_plugin(parameterization_plugin Polyhedron_demo_parameterization_plugin) target_link_libraries(parameterization_plugin scene_polyhedron_item scene_textured_polyhedron_item ) - endif(TAUCS_FOUND) + endif(EIGEN3_FOUND OR TAUCS_FOUND) polyhedron_demo_plugin(self_intersection_plugin Polyhedron_demo_self_intersection_plugin) target_link_libraries(self_intersection_plugin scene_polyhedron_item) diff --git a/Ridges_3/doc_tex/Ridges_3/PkgDescription.tex b/Ridges_3/doc_tex/Ridges_3/PkgDescription.tex index fb4e4b577c8..0ed105d8731 100644 --- a/Ridges_3/doc_tex/Ridges_3/PkgDescription.tex +++ b/Ridges_3/doc_tex/Ridges_3/PkgDescription.tex @@ -10,8 +10,7 @@ mesh. Such curvature related features are curves: ridges or crests, and points: umbilics.} - \ccPkgDependsOn{Solvers as \ccThirdPartyLapack\ and - \ccThirdPartyBlas.} + \ccPkgDependsOn{either \ccThirdPartyEigen, or \ccThirdPartyLapack\ and \ccThirdPartyBlas for solvers.} \ccPkgIntroducedInCGAL{3.3} \ccPkgLicense{\ccLicenseQPL} \ccPkgIllustration{Ridges_3/RidgesMechPartDetail.png}{Ridges_3/mecanic-sub1_crestTweight1Tsharp7-jpg.png} diff --git a/Ridges_3/doc_tex/Ridges_3/Ridges_3_user.tex b/Ridges_3/doc_tex/Ridges_3/Ridges_3_user.tex index 619c97e2e2d..12ce3131106 100644 --- a/Ridges_3/doc_tex/Ridges_3/Ridges_3_user.tex +++ b/Ridges_3/doc_tex/Ridges_3/Ridges_3_user.tex @@ -37,8 +37,8 @@ algorithms; such quantities may be computed by the package {\em Estimation of Local Differential Properties of Sampled Surfaces via Polynomial Fitting}. -Note that this package needs the third party libraries -\ccThirdPartyLapack\ and \ccThirdPartyBlas\ for linear algebra operations. +Note that this package needs either the third party library \ccThirdPartyEigen, +or the third party libraries \ccThirdPartyLapack\ and \ccThirdPartyBlas\ for linear algebra operations. \subsection{Overview} %%%%%%%%%%%%%%%%%%%%%% diff --git a/Ridges_3/examples/Ridges_3/CMakeLists.txt b/Ridges_3/examples/Ridges_3/CMakeLists.txt index b8026d7a308..8c492786e6a 100644 --- a/Ridges_3/examples/Ridges_3/CMakeLists.txt +++ b/Ridges_3/examples/Ridges_3/CMakeLists.txt @@ -17,12 +17,19 @@ if ( CGAL_FOUND ) include( ${CGAL_USE_FILE} ) include( CGAL_CreateSingleSourceCGALProgram ) - # Link with BLAS and LAPACK (required) - find_package(LAPACK) - if(LAPACK_FOUND) - - include( ${LAPACK_USE_FILE} ) - + # use either Eigen or BLAS/LAPACK + find_package(Eigen3) + if (NOT EIGEN3_FOUND) + find_package(LAPACK) + if(LAPACK_FOUND) + include( ${LAPACK_USE_FILE} ) + endif(LAPACK_FOUND) + else() + include( ${EIGEN3_USE_FILE} ) + endif() + + + if(EIGEN3_FOUND OR LAPACK_FOUND) # Link with Boost.ProgramOptions (optional) find_package(Boost QUIET COMPONENTS program_options) if(Boost_PROGRAM_OPTIONS_FOUND) @@ -41,11 +48,11 @@ if ( CGAL_FOUND ) add_to_cached_list( CGAL_EXECUTABLE_TARGETS Compute_Ridges_Umbilics ) target_link_libraries(Compute_Ridges_Umbilics ${CGAL_LIBRARIES}) - else(LAPACK_FOUND) + else(EIGEN3_FOUND OR LAPACK_FOUND) - message(STATUS "NOTICE: This program requires LAPACK, and will not be compiled.") + message(STATUS "NOTICE: This program requires either Eigen 3 (or greater) or LAPACK, and will not be compiled.") - endif(LAPACK_FOUND) + endif(EIGEN3_FOUND OR LAPACK_FOUND) else() diff --git a/Ridges_3/test/Ridges_3/CMakeLists.txt b/Ridges_3/test/Ridges_3/CMakeLists.txt index 5d03880318d..49c5747cb4b 100644 --- a/Ridges_3/test/Ridges_3/CMakeLists.txt +++ b/Ridges_3/test/Ridges_3/CMakeLists.txt @@ -21,20 +21,27 @@ if ( CGAL_FOUND ) include( CGAL_CreateSingleSourceCGALProgram ) - # Link with BLAS and LAPACK (required) - find_package(LAPACK) - - if(LAPACK_FOUND) - - include( ${LAPACK_USE_FILE} ) + # use either Eigen or BLAS/LAPACK + find_package(Eigen3) + if (NOT EIGEN3_FOUND) + find_package(LAPACK) + if(LAPACK_FOUND) + include( ${LAPACK_USE_FILE} ) + endif(LAPACK_FOUND) + else() + include( ${EIGEN3_USE_FILE} ) + endif() + + + if(EIGEN3_FOUND OR LAPACK_FOUND) create_single_source_cgal_program( "ridge_test.cpp" ) - else(LAPACK_FOUND) + else(EIGEN3_FOUND OR LAPACK_FOUND) - message(STATUS "NOTICE: This program requires LAPACK, and will not be compiled.") + message(STATUS "NOTICE: This program requires either Eigen 3 (or greater) or LAPACK, and will not be compiled.") - endif(LAPACK_FOUND) + endif(EIGEN3_FOUND OR LAPACK_FOUND) else() diff --git a/Solver_interface/include/CGAL/Eigen_matrix.h b/Solver_interface/include/CGAL/Eigen_matrix.h index 2dfae188110..05f5eec45ac 100644 --- a/Solver_interface/include/CGAL/Eigen_matrix.h +++ b/Solver_interface/include/CGAL/Eigen_matrix.h @@ -27,7 +27,7 @@ namespace CGAL { -/// The class Eigen_matrix +/// The class Eigen_sparse_matrix /// is a C++ wrapper around Eigen' matrix type SparseMatrix<>. /// /// This kind of matrix can be either symmetric or not. Symmetric @@ -39,7 +39,7 @@ namespace CGAL { /// @param T Number type. template -struct Eigen_matrix +struct Eigen_sparse_matrix { // Public types public: @@ -51,7 +51,7 @@ public: public: /// Create a square matrix initialized with zeros. - Eigen_matrix(int dim, ///< Matrix dimension. + Eigen_sparse_matrix(int dim, ///< Matrix dimension. bool is_symmetric = false) ///< Symmetric/hermitian? : m_dynamic(dim,dim), m_matrix(dim,dim) { @@ -63,7 +63,7 @@ public: /// Create a rectangular matrix initialized with zeros. /// /// @commentheading Precondition: rows == columns if is_symmetric is true. - Eigen_matrix(int rows, ///< Number of rows. + Eigen_sparse_matrix(int rows, ///< Number of rows. int columns, ///< Number of columns. bool is_symmetric = false) ///< Symmetric/hermitian? : m_dynamic(rows,columns), m_matrix(rows,columns) @@ -78,7 +78,7 @@ public: } /// Delete this object and the wrapped TAUCS matrix. - ~Eigen_matrix() + ~Eigen_sparse_matrix() { } @@ -91,7 +91,7 @@ public: /// Write access to a matrix coefficient: a_ij <- val. /// /// Optimizations: - /// - For symmetric matrices, Eigen_matrix stores only the lower triangle + /// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle /// set_coef() does nothing if (i, j) belongs to the upper triangle. /// - Caller can optimize this call by setting 'new_coef' to true /// if the coefficient does not already exist in the matrix. @@ -126,9 +126,9 @@ public: private: - /// Eigen_matrix cannot be copied (yet) - Eigen_matrix(const Eigen_matrix& rhs); - Eigen_matrix& operator=(const Eigen_matrix& rhs); + /// Eigen_sparse_matrix cannot be copied (yet) + Eigen_sparse_matrix(const Eigen_sparse_matrix& rhs); + Eigen_sparse_matrix& operator=(const Eigen_sparse_matrix& rhs); // Fields private: @@ -140,11 +140,11 @@ private: // Symmetric/hermitian? bool m_is_symmetric; -}; // Taucs_matrix +}; // Eigen_sparse_matrix -/// The class Eigen_symmetric_matrix is a C++ wrapper +/// The class Eigen_sparse_symmetric_matrix is a C++ wrapper /// around a Eigen sparse matrix (type Eigen::SparseMatrix). /// /// Symmetric matrices store only the lower triangle. @@ -155,33 +155,48 @@ private: /// @param T Number type. template -struct Eigen_symmetric_matrix - : public Eigen_matrix +struct Eigen_sparse_symmetric_matrix + : public Eigen_sparse_matrix { // Public types -public: - typedef T NT; // Public operations -public: - /// Create a square *symmetric* matrix initialized with zeros. - Eigen_symmetric_matrix(int dim) ///< Matrix dimension. - : Eigen_matrix(dim, true /* symmetric */) + /// Create a square *symmetric* matrix initialized with zeros. + Eigen_sparse_symmetric_matrix(int dim) ///< Matrix dimension. + : Eigen_sparse_matrix(dim, true /* symmetric */) { } /// Create a square *symmetric* matrix initialized with zeros. /// /// @commentheading Precondition: rows == columns. - Eigen_symmetric_matrix(int rows, ///< Number of rows. + Eigen_sparse_symmetric_matrix(int rows, ///< Number of rows. int columns) ///< Number of columns. - : Eigen_matrix(rows, columns, true /* symmetric */) + : Eigen_sparse_matrix(rows, columns, true /* symmetric */) { } }; +template +struct Eigen_matrix : public ::Eigen::Matrix +{ + typedef ::Eigen::Matrix EigenType; + Eigen_matrix( std::size_t n1, std::size_t n2):EigenType(n1,n2){} + std::size_t number_of_rows () const {return this->rows();} + std::size_t number_of_columns () const {return this->cols();} + FT operator()( std::size_t i , std::size_t j ) const {return this->operator()(i,j);} + void set( std::size_t i, std::size_t j,FT value){ + this->coeffRef(i,j)=value; + } + + const EigenType& eigen_object() const{ + return static_cast(*this); + } + +}; + } //namespace CGAL #endif // CGAL_EIGEN_MATRIX_H \ No newline at end of file diff --git a/Solver_interface/include/CGAL/Eigen_solver_traits.h b/Solver_interface/include/CGAL/Eigen_solver_traits.h index 50e002cdd37..68d294ca13c 100644 --- a/Solver_interface/include/CGAL/Eigen_solver_traits.h +++ b/Solver_interface/include/CGAL/Eigen_solver_traits.h @@ -31,6 +31,23 @@ namespace CGAL { +namespace internal { + template + struct Get_eigen_matrix{ + typedef Eigen_sparse_matrix type; + }; + + template + struct Get_eigen_matrix< ::Eigen::ConjugateGradient,FT>{ + typedef Eigen_sparse_symmetric_matrix type; + }; + + template + struct Get_eigen_matrix< ::Eigen::SimplicialCholesky,FT>{ + typedef Eigen_sparse_symmetric_matrix type; + }; +} //internal + /// The class Eigen_solver_traits /// is a generic traits class for solving asymmetric or symmetric positive definite (SPD) /// sparse linear systems using one of the Eigen solvers. @@ -39,16 +56,16 @@ namespace CGAL { /// /// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d concept. -template::EigenType> > +template::EigenType> > class Eigen_solver_traits { typedef typename EigenSolverT::Scalar Scalar; // Public types public: - - typedef Eigen_matrix Matrix; - typedef Eigen_vector Vector; - typedef Scalar NT; + typedef Scalar NT; + typedef typename internal::Get_eigen_matrix::type Matrix; + typedef Eigen_vector Vector; + // Public operations public: diff --git a/Solver_interface/include/CGAL/Eigen_svd.h b/Solver_interface/include/CGAL/Eigen_svd.h new file mode 100644 index 00000000000..49102091d0f --- /dev/null +++ b/Solver_interface/include/CGAL/Eigen_svd.h @@ -0,0 +1,46 @@ +// Copyright (c) 2011 INRIA Bordeaux Sud-Ouest (France), All rights reserved. +// +// This file is part of CGAL (www.cgal.org); 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; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Gael Guennebaud + +#ifndef CGAL_EIGEN_SVD_H +#define CGAL_EIGEN_SVD_H + +#include +#include +#include + + + +namespace CGAL { + +class Eigen_svd{ +public: + typedef double FT; + typedef Eigen_vector Vector; + typedef Eigen_matrix Matrix; + //solve MX=B using SVD and return the condition number of M + //The solution is stored in B + static FT solve(const Matrix& M, Vector& B){ + Eigen::JacobiSVD jacobiSvd(M.eigen_object(),::Eigen::ComputeThinU | ::Eigen::ComputeThinV); + B.eigen_object()=jacobiSvd.solve(Vector::EigenType(B.eigen_object())); + return jacobiSvd.singularValues().array().abs().maxCoeff()/ + jacobiSvd.singularValues().array().abs().minCoeff(); + } +}; + +}//namespace CGAL +#endif // CGAL_EIGEN_SVD_H diff --git a/Solver_interface/include/CGAL/Eigen_vector.h b/Solver_interface/include/CGAL/Eigen_vector.h index 158ff4b32a2..7cc0d699094 100644 --- a/Solver_interface/include/CGAL/Eigen_vector.h +++ b/Solver_interface/include/CGAL/Eigen_vector.h @@ -73,6 +73,13 @@ public: EigenType& eigen_object() { return *this; } + + void set(int i,NT value) { + this->operator[](i)=value; + } + + NT* vector() {return this->data();} + }; } //namespace CGAL diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp index 78dbc8a8195..de2f2740ab0 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp @@ -114,12 +114,12 @@ Polyhedron* poisson_reconstruct(const Point_set& points, #ifdef CGAL_EIGEN3_ENABLED if(solver_name=="Eigen - built-in simplicial LDLt") { - CGAL::Eigen_solver_traits::EigenType> > solver; + CGAL::Eigen_solver_traits::EigenType> > solver; ok = function.compute_implicit_function(solver); } if(solver_name=="Eigen - built-in CG") { - CGAL::Eigen_solver_traits::EigenType> > solver; + CGAL::Eigen_solver_traits::EigenType> > solver; solver.solver().setTolerance(1e-6); solver.solver().setMaxIterations(1000); ok = function.compute_implicit_function(solver);