Started working on examples

This commit is contained in:
Simon Giraudot 2015-08-21 11:57:46 +02:00
parent 075c29c3fa
commit 99eb0e1041
6 changed files with 94 additions and 4 deletions

View File

@ -2,6 +2,6 @@
PROJECT_NAME = "CGAL ${CGAL_CREATED_VERSION_NUM} - CGAL and Solvers"
INPUT = ${CMAKE_SOURCE_DIR}/Solver_interface/doc/Solver_interface/
EXAMPLE_PATH =
EXAMPLE_PATH = ${CMAKE_SOURCE_DIR}/Solver_interface/examples/Solver_interface/

View File

@ -28,11 +28,13 @@
- `SparseLinearAlgebraTraits_d`
- `SparseLinearAlgebraTraitsWithFactor_d`
- `SvdTraits`
- `VCMTraits`
## Classes ##
- `CGAL::Eigen_solver_traits`
- `CGAL::Eigen_svd`
- `CGAL::Eigen_vcm_traits`
- `CGAL::Eigen_matrix`
- `CGAL::Eigen_vector`
- `CGAL::Eigen_sparse_matrix`

View File

@ -17,7 +17,7 @@ equivalent models for other solvers, for example those found in the
\section SectionSolverEigen Eigen
\section SectionSolverEigenSparse Eigen Sparse Solvers
An interface to all sparse solvers from the \ref thirdpartyEigen
library is provided through the class
@ -44,7 +44,25 @@ typedef CGAL::Eigen_solver_traits< Eigen::ConjugateGradient<EigenMatrix> > Itera
//direct symmetric solver
typedef CGAL::Eigen_solver_traits< Eigen::SimplicialCholesky<EigenMatrix> > Direct_symmetric_solver;
\endcode
\endcode
\section SectionSolverEigenSVD Eigen Singular Value Decomposition
The class `Eigen_svd` provides an algorithm to solve in the least
square sense a linear system with a singular value decomposition using
\ref thirdpartyEigen. The field type is `double`.
Here is a simple example that shows how to handle matrices, vectors
and this solver:
\cgalExample{Solver_interface/eigen_singular_value_decomposition.cpp}
\section SectionSolverEigenVCM Variance Covariance Matrix
The class `Eigen_vcm_traits<T>` provides an interface to the
selfadjoint solver of the \ref thirdpartyEigen library.

View File

@ -1,3 +1,3 @@
/*!
\example Solver_interface/eigen_singular_value_decomposition.cpp
*/

View File

@ -0,0 +1,34 @@
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
project( examples_ )
cmake_minimum_required(VERSION 2.8.10)
find_package(CGAL QUIET COMPONENTS Core )
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
include( CGAL_CreateSingleSourceCGALProgram )
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
if (NOT EIGEN3_FOUND)
message(STATUS "This program requires the Eigen library, and will not be compiled.")
else()
include( ${EIGEN3_USE_FILE} )
endif()
include_directories (BEFORE "../include")
create_single_source_cgal_program( "eigen_singular_value_decomposition.cpp" )
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -0,0 +1,36 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Eigen_matrix.h>
#include <CGAL/Eigen_vector.h>
#include <CGAL/Eigen_svd.h>
typedef CGAL::Eigen_svd::FT FT;
typedef CGAL::Eigen_svd::Vector Eigen_vector;
typedef CGAL::Eigen_svd::Matrix Eigen_matrix;
int main(void)
{
std::size_t degree = 3;
Eigen_vector B (degree);
Eigen_matrix M (degree, degree);
// Fill B and M with random numbers
for (std::size_t i = 0; i < degree; ++ i)
{
B.set (i, rand());
for (std::size_t j = 0; j < degree; ++ j)
M.set (i, j, rand());
}
// Solve MX=B
std::cout << CGAL::Eigen_svd::solve(M, B) << std::endl;
// Print result
std::cout << "Solution of SVD = [ ";
for (std::size_t i = 0; i < degree; ++ i)
std::cout << B.vector()[i] << " ";
std::cout << "]" << std::endl;
return 0;
}