mirror of https://github.com/CGAL/cgal
Remove Lapack support from Jet_fitting, PSP, Ridges and Solver_interface
This commit is contained in:
parent
86faeb7fa5
commit
911bea4021
|
|
@ -11,18 +11,10 @@ find_package(CGAL QUIET)
|
||||||
|
|
||||||
if ( CGAL_FOUND )
|
if ( CGAL_FOUND )
|
||||||
|
|
||||||
# use either Eigen or BLAS/LAPACK
|
# use Eigen
|
||||||
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
||||||
if (NOT EIGEN3_FOUND)
|
if (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)
|
# Link with Boost.ProgramOptions (optional)
|
||||||
find_package(Boost QUIET COMPONENTS program_options)
|
find_package(Boost QUIET COMPONENTS program_options)
|
||||||
if(Boost_PROGRAM_OPTIONS_FOUND)
|
if(Boost_PROGRAM_OPTIONS_FOUND)
|
||||||
|
|
@ -38,11 +30,9 @@ if ( CGAL_FOUND )
|
||||||
create_single_source_cgal_program( "Mesh_estimation.cpp" )
|
create_single_source_cgal_program( "Mesh_estimation.cpp" )
|
||||||
create_single_source_cgal_program( "Single_estimation.cpp" )
|
create_single_source_cgal_program( "Single_estimation.cpp" )
|
||||||
|
|
||||||
else(EIGEN3_FOUND OR LAPACK_FOUND)
|
else()
|
||||||
|
message(STATUS "NOTICE: This program requires Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
message(STATUS "NOTICE: This program requires either Eigen 3.1 (or greater) or LAPACK, and will not be compiled.")
|
endif()
|
||||||
|
|
||||||
endif(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
To compile, you need support for lapack
|
To compile, you need support for Eigen
|
||||||
|
|
||||||
Program Single_estimation
|
Program Single_estimation
|
||||||
---------------------
|
---------------------
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#ifdef CGAL_EIGEN3_ENABLED
|
#ifdef CGAL_EIGEN3_ENABLED
|
||||||
#include <CGAL/Eigen_svd.h>
|
#include <CGAL/Eigen_svd.h>
|
||||||
#else
|
|
||||||
#ifdef CGAL_LAPACK_ENABLED
|
|
||||||
#include <CGAL/Lapack_svd.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
@ -51,11 +47,7 @@ unsigned int fact(unsigned int n){
|
||||||
#ifdef CGAL_EIGEN3_ENABLED
|
#ifdef CGAL_EIGEN3_ENABLED
|
||||||
template < class DataKernel, class LocalKernel = Simple_cartesian<double>, class SvdTraits = Eigen_svd >
|
template < class DataKernel, class LocalKernel = Simple_cartesian<double>, class SvdTraits = Eigen_svd >
|
||||||
#else
|
#else
|
||||||
#ifdef CGAL_LAPACK_ENABLED
|
|
||||||
template < class DataKernel, class LocalKernel = Simple_cartesian<double>, class SvdTraits = Lapack_svd>
|
|
||||||
#else
|
|
||||||
template < class DataKernel, class LocalKernel, class SvdTraits >
|
template < class DataKernel, class LocalKernel, class SvdTraits >
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
class Monge_via_jet_fitting {
|
class Monge_via_jet_fitting {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -11,27 +11,14 @@ find_package(CGAL QUIET)
|
||||||
|
|
||||||
if ( CGAL_FOUND )
|
if ( CGAL_FOUND )
|
||||||
|
|
||||||
# use either Eigen or BLAS/LAPACK
|
# use Eigen
|
||||||
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
||||||
if (NOT EIGEN3_FOUND)
|
if (EIGEN3_FOUND)
|
||||||
find_package(LAPACK)
|
|
||||||
if(LAPACK_FOUND)
|
|
||||||
include( ${LAPACK_USE_FILE} )
|
|
||||||
endif(LAPACK_FOUND)
|
|
||||||
else()
|
|
||||||
include( ${EIGEN3_USE_FILE} )
|
include( ${EIGEN3_USE_FILE} )
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
|
|
||||||
create_single_source_cgal_program( "blind_1pt.cpp" )
|
create_single_source_cgal_program( "blind_1pt.cpp" )
|
||||||
|
else()
|
||||||
else(EIGEN3_FOUND OR LAPACK_FOUND)
|
message(STATUS "NOTICE: This program requires Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
|
endif()
|
||||||
message(STATUS "NOTICE: This program requires either Eigen 3.1 (or greater) or LAPACK, and will not be compiled.")
|
|
||||||
|
|
||||||
endif(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ if ( CGAL_FOUND )
|
||||||
find_package( TBB REQUIRED )
|
find_package( TBB REQUIRED )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Executables that do *not* require EIGEN or LAPACK
|
# Executables that do *not* require EIGEN
|
||||||
create_single_source_cgal_program( "average_spacing_example.cpp" )
|
create_single_source_cgal_program( "average_spacing_example.cpp" )
|
||||||
create_single_source_cgal_program( "bilateral_smooth_point_set_example.cpp" )
|
create_single_source_cgal_program( "bilateral_smooth_point_set_example.cpp" )
|
||||||
create_single_source_cgal_program( "grid_simplification_example.cpp" )
|
create_single_source_cgal_program( "grid_simplification_example.cpp" )
|
||||||
|
|
@ -70,27 +70,18 @@ if ( CGAL_FOUND )
|
||||||
message(STATUS "NOTICE : the LAS reader test requires LASlib and will not be compiled.")
|
message(STATUS "NOTICE : the LAS reader test requires LASlib and will not be compiled.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Use Eigen or BLAS and LAPACK (optional)
|
# Use Eigen
|
||||||
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
||||||
if (NOT EIGEN3_FOUND)
|
if (EIGEN3_FOUND)
|
||||||
find_package(LAPACK)
|
|
||||||
if(LAPACK_FOUND)
|
|
||||||
include( ${LAPACK_USE_FILE} )
|
|
||||||
endif(LAPACK_FOUND)
|
|
||||||
else()
|
|
||||||
include( ${EIGEN3_USE_FILE} )
|
include( ${EIGEN3_USE_FILE} )
|
||||||
endif()
|
# Executables that require Eigen
|
||||||
|
|
||||||
if(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
# Executables that require Eigen or BLAS and LAPACK
|
|
||||||
create_single_source_cgal_program( "jet_smoothing_example.cpp" )
|
create_single_source_cgal_program( "jet_smoothing_example.cpp" )
|
||||||
create_single_source_cgal_program( "normal_estimation.cpp" )
|
create_single_source_cgal_program( "normal_estimation.cpp" )
|
||||||
create_single_source_cgal_program( "edges_example.cpp" )
|
create_single_source_cgal_program( "edges_example.cpp" )
|
||||||
else(EIGEN3_FOUND OR LAPACK_FOUND)
|
else()
|
||||||
|
|
||||||
message(STATUS "NOTICE: Some of the executables in this directory need either Eigen 3.1 (or greater) or LAPACK, and will not be compiled.")
|
message(STATUS "NOTICE: Some of the executables in this directory need Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
|
endif()
|
||||||
endif(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
|
|
||||||
foreach(target
|
foreach(target
|
||||||
scale_estimation_example
|
scale_estimation_example
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ if ( CGAL_FOUND )
|
||||||
|
|
||||||
find_package( TBB QUIET )
|
find_package( TBB QUIET )
|
||||||
|
|
||||||
# Executables that do *not* require LAPACK
|
# Executables that do *not* require Eigen
|
||||||
create_single_source_cgal_program( "read_test.cpp" )
|
create_single_source_cgal_program( "read_test.cpp" )
|
||||||
create_single_source_cgal_program( "read_test_with_different_pmaps.cpp" )
|
create_single_source_cgal_program( "read_test_with_different_pmaps.cpp" )
|
||||||
create_single_source_cgal_program( "analysis_test.cpp" )
|
create_single_source_cgal_program( "analysis_test.cpp" )
|
||||||
|
|
@ -38,31 +38,20 @@ if ( CGAL_FOUND )
|
||||||
create_single_source_cgal_program( "edge_aware_upsample_test.cpp" )
|
create_single_source_cgal_program( "edge_aware_upsample_test.cpp" )
|
||||||
create_single_source_cgal_program( "structuring_test.cpp" )
|
create_single_source_cgal_program( "structuring_test.cpp" )
|
||||||
|
|
||||||
# Use Eigen or BLAS and LAPACK (optional)
|
# Use Eigen
|
||||||
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
||||||
if (NOT EIGEN3_FOUND)
|
if (EIGEN3_FOUND)
|
||||||
find_package(LAPACK)
|
|
||||||
if(LAPACK_FOUND)
|
|
||||||
include( ${LAPACK_USE_FILE} )
|
|
||||||
endif(LAPACK_FOUND)
|
|
||||||
else()
|
|
||||||
include( ${EIGEN3_USE_FILE} )
|
include( ${EIGEN3_USE_FILE} )
|
||||||
endif()
|
# Executables that require Eigen
|
||||||
|
|
||||||
|
|
||||||
if(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
# Executables that require Eigen or BLAS and LAPACK
|
|
||||||
create_single_source_cgal_program( "normal_estimation_test.cpp" )
|
create_single_source_cgal_program( "normal_estimation_test.cpp" )
|
||||||
create_single_source_cgal_program( "hierarchy_simplification_test.cpp" )
|
create_single_source_cgal_program( "hierarchy_simplification_test.cpp" )
|
||||||
create_single_source_cgal_program( "smoothing_test.cpp" )
|
create_single_source_cgal_program( "smoothing_test.cpp" )
|
||||||
create_single_source_cgal_program( "vcm_plane_test.cpp" )
|
create_single_source_cgal_program( "vcm_plane_test.cpp" )
|
||||||
create_single_source_cgal_program( "vcm_all_test.cpp" )
|
create_single_source_cgal_program( "vcm_all_test.cpp" )
|
||||||
create_single_source_cgal_program( "jet_pointer_as_property_map.cpp" )
|
create_single_source_cgal_program( "jet_pointer_as_property_map.cpp" )
|
||||||
else(EIGEN3_FOUND OR LAPACK_FOUND)
|
else()
|
||||||
|
message(STATUS "NOTICE: This program requires Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
message(STATUS "NOTICE: This program requires either Eigen 3.1 (or greater) or LAPACK, and will not be compiled.")
|
endif()
|
||||||
|
|
||||||
endif(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
|
|
||||||
foreach(target
|
foreach(target
|
||||||
analysis_test
|
analysis_test
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,11 @@ find_package(CGAL QUIET )
|
||||||
|
|
||||||
if ( CGAL_FOUND )
|
if ( CGAL_FOUND )
|
||||||
|
|
||||||
# use either Eigen or BLAS/LAPACK
|
# use either Eigen
|
||||||
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
||||||
if (NOT EIGEN3_FOUND)
|
if (EIGEN3_FOUND)
|
||||||
find_package(LAPACK)
|
|
||||||
if(LAPACK_FOUND)
|
|
||||||
include( ${LAPACK_USE_FILE} )
|
|
||||||
endif(LAPACK_FOUND)
|
|
||||||
else()
|
|
||||||
include( ${EIGEN3_USE_FILE} )
|
include( ${EIGEN3_USE_FILE} )
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
# Link with Boost.ProgramOptions (optional)
|
# Link with Boost.ProgramOptions (optional)
|
||||||
find_package(Boost QUIET COMPONENTS program_options)
|
find_package(Boost QUIET COMPONENTS program_options)
|
||||||
if(Boost_PROGRAM_OPTIONS_FOUND)
|
if(Boost_PROGRAM_OPTIONS_FOUND)
|
||||||
|
|
@ -37,11 +29,11 @@ if ( CGAL_FOUND )
|
||||||
create_single_source_cgal_program( Ridges_Umbilics_SM.cpp)
|
create_single_source_cgal_program( Ridges_Umbilics_SM.cpp)
|
||||||
create_single_source_cgal_program( Ridges_Umbilics_LCC.cpp)
|
create_single_source_cgal_program( Ridges_Umbilics_LCC.cpp)
|
||||||
|
|
||||||
else(EIGEN3_FOUND OR LAPACK_FOUND)
|
else()
|
||||||
|
|
||||||
message(STATUS "NOTICE: This program requires either Eigen 3.1 (or greater) or LAPACK, and will not be compiled.")
|
message(STATUS "NOTICE: This program requires Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
|
|
||||||
endif(EIGEN3_FOUND OR LAPACK_FOUND)
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,27 +11,17 @@ find_package(CGAL QUIET)
|
||||||
|
|
||||||
if ( CGAL_FOUND )
|
if ( CGAL_FOUND )
|
||||||
|
|
||||||
# use either Eigen or BLAS/LAPACK
|
# use either Eigen
|
||||||
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater)
|
||||||
if (NOT EIGEN3_FOUND)
|
if (EIGEN3_FOUND)
|
||||||
find_package(LAPACK)
|
|
||||||
if(LAPACK_FOUND)
|
|
||||||
include( ${LAPACK_USE_FILE} )
|
|
||||||
endif(LAPACK_FOUND)
|
|
||||||
else()
|
|
||||||
include( ${EIGEN3_USE_FILE} )
|
include( ${EIGEN3_USE_FILE} )
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(EIGEN3_FOUND OR LAPACK_FOUND)
|
|
||||||
|
|
||||||
create_single_source_cgal_program( "ridge_test.cpp" )
|
create_single_source_cgal_program( "ridge_test.cpp" )
|
||||||
|
|
||||||
else(EIGEN3_FOUND OR LAPACK_FOUND)
|
else()
|
||||||
|
|
||||||
message(STATUS "NOTICE: This program requires either Eigen 3.1 (or greater) or LAPACK, and will not be compiled.")
|
message(STATUS "NOTICE: This program requires Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
|
|
||||||
endif(EIGEN3_FOUND OR LAPACK_FOUND)
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
to solve in the least square sense a linear system with a singular value decomposition
|
to solve in the least square sense a linear system with a singular value decomposition
|
||||||
|
|
||||||
\cgalHasModel `CGAL::Eigen_svd`
|
\cgalHasModel `CGAL::Eigen_svd`
|
||||||
\cgalHasModel `CGAL::Lapack_svd`
|
|
||||||
*/
|
*/
|
||||||
class SvdTraits
|
class SvdTraits
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,4 @@
|
||||||
- `CGAL::Eigen_sparse_matrix`
|
- `CGAL::Eigen_sparse_matrix`
|
||||||
- `CGAL::Eigen_sparse_symmetric_matrix`
|
- `CGAL::Eigen_sparse_symmetric_matrix`
|
||||||
- `CGAL::Eigen_svd`
|
- `CGAL::Eigen_svd`
|
||||||
- `CGAL::Lapack_vector`
|
|
||||||
- `CGAL::Lapack_matrix`
|
|
||||||
- `CGAL::Lapack_svd`
|
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,206 +0,0 @@
|
||||||
// Copyright (c) 2007 INRIA Sophia-Antipolis (France), INRIA Lorraine LORIA.
|
|
||||||
// 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; either version 3 of the License,
|
|
||||||
// or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// 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$
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
|
||||||
//
|
|
||||||
// Author(s) : Marc Pouget and Frédéric Cazals
|
|
||||||
|
|
||||||
#ifndef CGAL_LAPACK_H
|
|
||||||
#define CGAL_LAPACK_H
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <CGAL/auto_link/LAPACK.h>
|
|
||||||
#include <CGAL/assertions.h>
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
// taken from acml.h
|
|
||||||
void dgelss(int m, int n, int nrhs,
|
|
||||||
double *a, int lda, double *b, int ldb, double *sing,
|
|
||||||
double rcond, int *irank, int *info);
|
|
||||||
|
|
||||||
void dgelss_(int *m, int *n, int *nrhs,
|
|
||||||
double *a, int *lda, double *b, int *ldb, double *
|
|
||||||
s, double *rcond, int *rank, double *work, int *lwork,
|
|
||||||
int *info);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
namespace LAPACK {
|
|
||||||
|
|
||||||
inline
|
|
||||||
void dgelss(int *m, int *n, int *nrhs,
|
|
||||||
double *a, int *lda, double *b, int *ldb, double *s,
|
|
||||||
double *rcond, int *rank, double *work, int *lwork, int *info)
|
|
||||||
{
|
|
||||||
#ifdef CGAL_USE_F2C
|
|
||||||
::dgelss_(m, n, nrhs, a, lda, b, ldb, s, rcond, rank, work, lwork, info);
|
|
||||||
#else
|
|
||||||
::dgelss(*m, *n, *nrhs, a, *lda, b, *ldb, s, *rcond, rank, info);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace LAPACK
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
/// \ingroup PkgSolverInterfaceRef
|
|
||||||
///
|
|
||||||
/// A matrix class to be used in the class `Lapack_svd`.
|
|
||||||
///
|
|
||||||
/// \cgalModels `SvdTraits::Matrix`
|
|
||||||
class Lapack_vector
|
|
||||||
{
|
|
||||||
typedef double FT;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
FT* m_vector;
|
|
||||||
size_t nb_elts;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Initializes all the elements of the vector to zero.
|
|
||||||
Lapack_vector(size_t n)
|
|
||||||
{
|
|
||||||
m_vector = (FT*) std::calloc(n, sizeof(FT));
|
|
||||||
nb_elts = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
~Lapack_vector() { free(m_vector); }
|
|
||||||
|
|
||||||
/// Return the size of the vector.
|
|
||||||
size_t size() { return nb_elts; }
|
|
||||||
|
|
||||||
/// Return the vector as an array.
|
|
||||||
const FT* vector() const { return m_vector;}
|
|
||||||
|
|
||||||
/// Return the vector as an array.
|
|
||||||
FT* vector() { return m_vector; }
|
|
||||||
|
|
||||||
/// Return the `i`th entry, `i` from `0` to `size()-1`.
|
|
||||||
FT operator()(size_t i) {return m_vector[i];}
|
|
||||||
|
|
||||||
/// Set the `i`'th entry to `value`.
|
|
||||||
void set(size_t i, const FT value) { m_vector[i] = value; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Copy constructor and operator =() are not implemented.
|
|
||||||
Lapack_vector(const Lapack_vector& toCopy);
|
|
||||||
Lapack_vector& operator =(const Lapack_vector& toCopy);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// \ingroup PkgSolverInterfaceRef
|
|
||||||
///
|
|
||||||
/// In CLAPACK, matrices are one-dimensional arrays and elements are
|
|
||||||
/// column-major ordered. This class is a wrapper defining set and get
|
|
||||||
/// in the usual way with line and column indices.
|
|
||||||
///
|
|
||||||
/// \cgalModels `SvdTraits::Matrix`
|
|
||||||
class Lapack_matrix
|
|
||||||
{
|
|
||||||
typedef double FT;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
FT* m_matrix;
|
|
||||||
size_t nb_rows;
|
|
||||||
size_t nb_columns;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Initializes all the elements of the matrix to zero.
|
|
||||||
Lapack_matrix(size_t n1, size_t n2)
|
|
||||||
{
|
|
||||||
m_matrix = (FT*) std::calloc (n1*n2, sizeof(FT));
|
|
||||||
nb_rows = n1;
|
|
||||||
nb_columns = n2;
|
|
||||||
}
|
|
||||||
|
|
||||||
~Lapack_matrix() { free(m_matrix); }
|
|
||||||
|
|
||||||
/// Return the number of rows of the matrix.
|
|
||||||
size_t number_of_rows() { return nb_rows; }
|
|
||||||
/// Return the number of columns of the matrix.
|
|
||||||
size_t number_of_columns() { return nb_columns; }
|
|
||||||
|
|
||||||
/// Return the matrix as an array.
|
|
||||||
const FT* matrix() const { return m_matrix; }
|
|
||||||
/// Return the matrix as an array.
|
|
||||||
FT* matrix() { return m_matrix; }
|
|
||||||
|
|
||||||
/// Return the entry at row `i` and column `j`, `i` from `0` to `number_of_rows - 1`,
|
|
||||||
/// `j` from `0` to `number_of_columns - 1`.
|
|
||||||
FT operator()(size_t i, size_t j) { return m_matrix[j*nb_rows+i]; }
|
|
||||||
|
|
||||||
/// Set the entry at row `i` and column `j` to `value`.
|
|
||||||
void set(size_t i, size_t j, const FT value) { m_matrix[j*nb_rows+i] = value; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Copy constructor and operator =() are not implemented.
|
|
||||||
Lapack_matrix(const Lapack_matrix& toCopy);
|
|
||||||
Lapack_matrix& operator =(const Lapack_matrix& toCopy);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// \ingroup PkgSolverInterfaceRef
|
|
||||||
///
|
|
||||||
/// This class is a wrapper to the singular value decomposition algorithm of LAPACK.
|
|
||||||
///
|
|
||||||
/// \cgalModels `SvdTraits`
|
|
||||||
class Lapack_svd
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef double FT;
|
|
||||||
typedef Lapack_vector Vector;
|
|
||||||
typedef Lapack_matrix Matrix;
|
|
||||||
|
|
||||||
/// Solves the system \f$ MX=B\f$ (in the least square sense if \f$ M\f$ is not
|
|
||||||
/// square) using a singular value decomposition. The solution is stored in \f$ B\f$.
|
|
||||||
/// \return the condition number of \f$ M\f$
|
|
||||||
static FT solve(Matrix& M, Vector& B);
|
|
||||||
};
|
|
||||||
|
|
||||||
inline
|
|
||||||
Lapack_svd::FT Lapack_svd::solve(Matrix& M, Vector& B)
|
|
||||||
{
|
|
||||||
int m = static_cast<int>(M.number_of_rows()),
|
|
||||||
n = static_cast<int>(M.number_of_columns()),
|
|
||||||
nrhs = 1,
|
|
||||||
lda = m,
|
|
||||||
ldb = m,
|
|
||||||
rank,
|
|
||||||
lwork = 5*m,
|
|
||||||
info;
|
|
||||||
|
|
||||||
// c style
|
|
||||||
FT* sing_values = (FT*) std::malloc(n*sizeof(FT));
|
|
||||||
FT* work = (FT*) std::malloc(lwork*sizeof(FT));
|
|
||||||
|
|
||||||
FT rcond = -1;
|
|
||||||
|
|
||||||
LAPACK::dgelss(&m, &n, &nrhs, M.matrix(), &lda, B.vector(), &ldb, sing_values,
|
|
||||||
&rcond, &rank, work, &lwork, &info);
|
|
||||||
CGAL_assertion(info==0);
|
|
||||||
|
|
||||||
FT cond_nb = sing_values[0]/sing_values[n-1];
|
|
||||||
|
|
||||||
// clean up
|
|
||||||
free(sing_values);
|
|
||||||
free(work);
|
|
||||||
|
|
||||||
return cond_nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
#endif // CGAL_LAPACK_H
|
|
||||||
Loading…
Reference in New Issue