mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
* add cmake files to find (optional) supported libraries
* add unit tests for sparse cholesky
This commit is contained in:
parent
f44316e5f8
commit
fa27cd1ed0
@ -16,9 +16,16 @@
|
||||
|
||||
#ifdef EIGEN_TAUCS_SUPPORT
|
||||
|
||||
// taucs.h declares a lot of mess
|
||||
#define isnan
|
||||
#define finite
|
||||
#define isinf
|
||||
extern "C" {
|
||||
#include "taucs.h"
|
||||
}
|
||||
#undef isnan
|
||||
#undef finite
|
||||
#undef isinf
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
|
@ -195,11 +195,12 @@ template<typename MatrixType>
|
||||
template<typename Derived>
|
||||
void SparseLLT<MatrixType,Cholmod>::solveInPlace(MatrixBase<Derived> &b) const
|
||||
{
|
||||
if (m_status & MatrixLIsDirty)
|
||||
matrixL();
|
||||
|
||||
const int size = m_matrix.rows();
|
||||
ei_assert(size==b.rows());
|
||||
|
||||
if (m_status & MatrixLIsDirty)
|
||||
matrixL();
|
||||
Base::solveInPlace(b);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,6 @@ void SparseLLT<MatrixType,Backend>::compute(const MatrixType& a)
|
||||
for (int j = 0; j < size; ++j)
|
||||
{
|
||||
Scalar x = ei_real(a.coeff(j,j));
|
||||
int endSize = size-j-1;
|
||||
|
||||
// TODO better estimate of the density !
|
||||
tempVector.init(density>0.001? IsDense : IsSparse);
|
||||
@ -191,7 +190,8 @@ bool SparseLLT<MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const
|
||||
ei_assert(size==b.rows());
|
||||
|
||||
m_matrix.solveTriangularInPlace(b);
|
||||
m_matrix.adjoint().solveTriangularInPlace(b);
|
||||
// FIXME should be .adjoint() but it fails to compile...
|
||||
m_matrix.transpose().solveTriangularInPlace(b);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ void SparseLLT<MatrixType,Taucs>::compute(const MatrixType& a)
|
||||
else
|
||||
{
|
||||
// use the faster Multifrontal routine
|
||||
m_taucsSupernodalFactor = taucs_ccs_factor_llt_ll(&taucsMatA);
|
||||
m_taucsSupernodalFactor = taucs_ccs_factor_llt_mf(&taucsMatA);
|
||||
}
|
||||
m_status = (m_status & ~IncompleteFactorization) | CompleteFactorization | MatrixLIsDirty;
|
||||
}
|
||||
@ -177,16 +177,19 @@ template<typename MatrixType>
|
||||
template<typename Derived>
|
||||
void SparseLLT<MatrixType,Taucs>::solveInPlace(MatrixBase<Derived> &b) const
|
||||
{
|
||||
const int size = m_matrix.rows();
|
||||
ei_assert(size==b.rows());
|
||||
|
||||
if (m_status & MatrixLIsDirty)
|
||||
{
|
||||
// ei_assert(!(m_status & SupernodalFactorIsDirty));
|
||||
// taucs_supernodal_solve_llt(m_taucsSupernodalFactor,double* b);
|
||||
//matrixL();
|
||||
// TODO use taucs's supernodal solver, in particular check types, storage order, etc.
|
||||
// VectorXb x(b.rows());
|
||||
// for (int j=0; j<b.cols(); ++j)
|
||||
// {
|
||||
// taucs_supernodal_solve_llt(m_taucsSupernodalFactor,x.data(),&b.col(j).coeffRef(0));
|
||||
// b.col(j) = x;
|
||||
// }
|
||||
matrixL();
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
{
|
||||
Base::solveInPlace(b);
|
||||
}
|
||||
|
76
cmake/FindCholmod.cmake
Normal file
76
cmake/FindCholmod.cmake
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
if (CHOLMOD_INCLUDES AND CHOLMOD_LIBRARIES)
|
||||
set(CHOLMOD_FIND_QUIETLY TRUE)
|
||||
endif (CHOLMOD_INCLUDES AND CHOLMOD_LIBRARIES)
|
||||
|
||||
find_path(CHOLMOD_INCLUDES
|
||||
NAMES
|
||||
cholmod.h
|
||||
PATHS
|
||||
$ENV{CHOLMODDIR}
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
PATH_SUFFIXES
|
||||
suitesparse
|
||||
)
|
||||
|
||||
find_library(CHOLMOD_LIBRARIES cholmod PATHS $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
|
||||
|
||||
if(CHOLMOD_LIBRARIES)
|
||||
|
||||
get_filename_component(CHOLMOD_LIBDIR ${CHOLMOD_LIBRARIES} PATH)
|
||||
|
||||
message("found CHOLMOD_LIBRARIES " ${CHOLMOD_LIBRARIES} " in " ${CHOLMOD_LIBDIR})
|
||||
|
||||
find_library(AMD_LIBRARY amd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
|
||||
if (AMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${AMD_LIBRARY})
|
||||
message ("AMD_LIBRARY found")
|
||||
else (AMD_LIBRARY)
|
||||
message ("AMD_LIBRARY not found")
|
||||
set(CHOLMOD_LIBRARIES FALSE)
|
||||
endif (AMD_LIBRARY)
|
||||
|
||||
endif(CHOLMOD_LIBRARIES)
|
||||
|
||||
if(CHOLMOD_LIBRARIES)
|
||||
message("CHOLMOD_LIBRARIES still here")
|
||||
|
||||
find_library(COLAMD_LIBRARY colamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
|
||||
if (COLAMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${COLAMD_LIBRARY})
|
||||
else (COLAMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES FALSE)
|
||||
endif (COLAMD_LIBRARY)
|
||||
|
||||
endif(CHOLMOD_LIBRARIES)
|
||||
|
||||
if(CHOLMOD_LIBRARIES)
|
||||
message("CHOLMOD_LIBRARIES still here")
|
||||
find_library(CAMD_LIBRARY camd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
|
||||
if (CAMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CAMD_LIBRARY})
|
||||
else (CAMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES FALSE)
|
||||
endif (CAMD_LIBRARY)
|
||||
|
||||
endif(CHOLMOD_LIBRARIES)
|
||||
|
||||
if(CHOLMOD_LIBRARIES)
|
||||
message("CHOLMOD_LIBRARIES still here (last)")
|
||||
find_library(CCOLAMD_LIBRARY colamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
|
||||
if (CCOLAMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CCOLAMD_LIBRARY})
|
||||
else (CCOLAMD_LIBRARY)
|
||||
set(CHOLMOD_LIBRARIES FALSE)
|
||||
endif (CCOLAMD_LIBRARY)
|
||||
|
||||
endif(CHOLMOD_LIBRARIES)
|
||||
|
||||
# if(CHOLMOD_LIBRARIES)
|
||||
# endif(CHOLMOD_LIBRARIES)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CHOLMOD DEFAULT_MSG
|
||||
CHOLMOD_INCLUDES CHOLMOD_LIBRARIES)
|
||||
|
||||
mark_as_advanced(CHOLMOD_INCLUDES CHOLMOD_LIBRARIES AMD_LIBRARY COLAMD_LIBRARY)
|
20
cmake/FindSuperLU.cmake
Normal file
20
cmake/FindSuperLU.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
if (SUPERLU_INCLUDES AND SUPERLU_LIBRARIES)
|
||||
set(SUPERLU_FIND_QUIETLY TRUE)
|
||||
endif (SUPERLU_INCLUDES AND SUPERLU_LIBRARIES)
|
||||
|
||||
find_path(SUPERLU_INCLUDES
|
||||
NAMES
|
||||
superlu/supermatrix.h
|
||||
PATHS
|
||||
$ENV{SUPERLUDIR}
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
)
|
||||
|
||||
find_library(SUPERLU_LIBRARIES superlu PATHS $ENV{SUPERLUDIR} ${LIB_INSTALL_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SUPERLU DEFAULT_MSG
|
||||
SUPERLU_INCLUDES SUPERLU_LIBRARIES)
|
||||
|
||||
mark_as_advanced(SUPERLU_INCLUDES SUPERLU_LIBRARIES)
|
20
cmake/FindTaucs.cmake
Normal file
20
cmake/FindTaucs.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
if (TAUCS_INCLUDES AND TAUCS_LIBRARIES)
|
||||
set(TAUCS_FIND_QUIETLY TRUE)
|
||||
endif (TAUCS_INCLUDES AND TAUCS_LIBRARIES)
|
||||
|
||||
find_path(TAUCS_INCLUDES
|
||||
NAMES
|
||||
taucs.h
|
||||
PATHS
|
||||
$ENV{TAUCSDIR}
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
)
|
||||
|
||||
find_library(TAUCS_LIBRARIES taucs PATHS $ENV{TAUCSDIR} ${LIB_INSTALL_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(TAUCS DEFAULT_MSG
|
||||
TAUCS_INCLUDES TAUCS_LIBRARIES)
|
||||
|
||||
mark_as_advanced(TAUCS_INCLUDES TAUCS_LIBRARIES)
|
46
cmake/FindUmfpack.cmake
Normal file
46
cmake/FindUmfpack.cmake
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
if (UMFPACK_INCLUDES AND UMFPACK_LIBRARIES)
|
||||
set(UMFPACK_FIND_QUIETLY TRUE)
|
||||
endif (UMFPACK_INCLUDES AND UMFPACK_LIBRARIES)
|
||||
|
||||
find_path(UMFPACK_INCLUDES
|
||||
NAMES
|
||||
umfpack.h
|
||||
PATHS
|
||||
$ENV{UMFPACKDIR}
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
PATH_SUFFIXES
|
||||
suitesparse
|
||||
)
|
||||
|
||||
find_library(UMFPACK_LIBRARIES umfpack PATHS $ENV{UMFPACKDIR} ${LIB_INSTALL_DIR})
|
||||
|
||||
if(UMFPACK_LIBRARIES)
|
||||
|
||||
get_filename_component(UMFPACK_LIBDIR ${UMFPACK_LIBRARIES} PATH)
|
||||
|
||||
find_library(AMD_LIBRARY amd PATHS ${UMFPACK_LIBDIR} $ENV{UMFPACKDIR} ${LIB_INSTALL_DIR})
|
||||
if (AMD_LIBRARY)
|
||||
set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARIES} ${AMD_LIBRARY})
|
||||
else (AMD_LIBRARY)
|
||||
set(UMFPACK_LIBRARIES FALSE)
|
||||
endif (AMD_LIBRARY)
|
||||
|
||||
endif(UMFPACK_LIBRARIES)
|
||||
|
||||
if(UMFPACK_LIBRARIES)
|
||||
|
||||
find_library(COLAMD_LIBRARY colamd PATHS ${UMFPACK_LIBDIR} $ENV{UMFPACKDIR} ${LIB_INSTALL_DIR})
|
||||
if (COLAMD_LIBRARY)
|
||||
set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARIES} ${COLAMD_LIBRARY})
|
||||
else (COLAMD_LIBRARY)
|
||||
set(UMFPACK_LIBRARIES FALSE)
|
||||
endif (COLAMD_LIBRARY)
|
||||
|
||||
endif(UMFPACK_LIBRARIES)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(UMFPACK DEFAULT_MSG
|
||||
UMFPACK_INCLUDES UMFPACK_LIBRARIES)
|
||||
|
||||
mark_as_advanced(UMFPACK_INCLUDES UMFPACK_LIBRARIES AMD_LIBRARY COLAMD_LIBRARY)
|
@ -1,31 +1,59 @@
|
||||
IF(BUILD_TESTS)
|
||||
if(BUILD_TESTS)
|
||||
|
||||
set(EXTERNAL_LIBS "")
|
||||
|
||||
find_package(GSL)
|
||||
if(GSL_FOUND)
|
||||
add_definitions("-DHAS_GSL")
|
||||
set(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${GSL_LIBRARIES})
|
||||
endif(GSL_FOUND)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g2")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g2")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-inline-functions")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g2")
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||
SET(EI_OFLAG "-O2")
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(EI_OFLAG "")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
find_package(Taucs)
|
||||
if(TAUCS_FOUND)
|
||||
add_definitions("-DEIGEN_TAUCS_SUPPORT")
|
||||
include_directories(${TAUCS_INCLUDES})
|
||||
set(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${TAUCS_LIBRARIES})
|
||||
endif(TAUCS_FOUND)
|
||||
|
||||
OPTION(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions" OFF)
|
||||
find_package(Cholmod)
|
||||
if(CHOLMOD_FOUND)
|
||||
message("add EIGEN_CHOLMOD_SUPPORT " ${CHOLMOD_LIBRARIES})
|
||||
add_definitions("-DEIGEN_CHOLMOD_SUPPORT")
|
||||
include_directories(${CHOLMOD_INCLUDES})
|
||||
set(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${CHOLMOD_LIBRARIES})
|
||||
endif(CHOLMOD_FOUND)
|
||||
|
||||
# similar to SET_TARGET_PROPERTIES but append the property instead of overwriting it
|
||||
MACRO(EI_ADD_TARGET_PROPERTY target prop value)
|
||||
# find_package(Umfpack)
|
||||
# if(UMFPACK_FOUND)
|
||||
# add_definitions("-DEIGEN_UMFPACK_SUPPORT")
|
||||
# endif(UMFPACK_FOUND)
|
||||
#
|
||||
# find_package(SuperLU)
|
||||
# if(SUPERLU_FOUND)
|
||||
# add_definitions("-DEIGEN_SUPERLU_SUPPORT")
|
||||
# endif(SUPERLU_FOUND)
|
||||
|
||||
GET_TARGET_PROPERTY(previous ${target} ${prop})
|
||||
SET_TARGET_PROPERTIES(${target} PROPERTIES ${prop} "${previous} ${value}")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g2")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-inline-functions")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g2")
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||
set(EI_OFLAG "-O2")
|
||||
else(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(EI_OFLAG "")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
ENDMACRO(EI_ADD_TARGET_PROPERTY)
|
||||
option(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions" OFF)
|
||||
|
||||
# similar to set_target_properties but append the property instead of overwriting it
|
||||
macro(ei_add_target_property target prop value)
|
||||
|
||||
get_target_property(previous ${target} ${prop})
|
||||
set_target_properties(${target} PROPERTIES ${prop} "${previous} ${value}")
|
||||
|
||||
endmacro(ei_add_target_property)
|
||||
|
||||
# Macro to add a test
|
||||
#
|
||||
@ -42,86 +70,84 @@ ENDMACRO(EI_ADD_TARGET_PROPERTY)
|
||||
# "ctest -V" or "ctest -V -R <testname>"
|
||||
# On other platform use ctest as usual
|
||||
#
|
||||
MACRO(EI_ADD_TEST testname)
|
||||
macro(ei_add_test testname)
|
||||
|
||||
SET(targetname test_${testname})
|
||||
set(targetname test_${testname})
|
||||
|
||||
SET(filename ${testname}.cpp)
|
||||
ADD_EXECUTABLE(${targetname} ${filename})
|
||||
set(filename ${testname}.cpp)
|
||||
add_executable(${targetname} ${filename})
|
||||
|
||||
IF(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
if(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
SET_TARGET_PROPERTIES(${targetname} PROPERTIES COMPILE_FLAGS "-fexceptions")
|
||||
OPTION(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF)
|
||||
IF(EIGEN_DEBUG_ASSERTS)
|
||||
SET_TARGET_PROPERTIES(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_DEBUG_ASSERTS=1")
|
||||
ENDIF(EIGEN_DEBUG_ASSERTS)
|
||||
set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-fexceptions")
|
||||
option(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF)
|
||||
if(EIGEN_DEBUG_ASSERTS)
|
||||
set_target_properties(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_DEBUG_ASSERTS=1")
|
||||
endif(EIGEN_DEBUG_ASSERTS)
|
||||
|
||||
ELSE(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
else(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
SET_TARGET_PROPERTIES(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_NO_ASSERTION_CHECKING=1")
|
||||
set_target_properties(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_NO_ASSERTION_CHECKING=1")
|
||||
|
||||
ENDIF(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
endif(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
IF(${ARGC} GREATER 1)
|
||||
EI_ADD_TARGET_PROPERTY(${targetname} COMPILE_FLAGS "${ARGV1}")
|
||||
ENDIF(${ARGC} GREATER 1)
|
||||
if(${ARGC} GREATER 1)
|
||||
ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV1}")
|
||||
endif(${ARGC} GREATER 1)
|
||||
|
||||
EI_ADD_TARGET_PROPERTY(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
||||
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
||||
|
||||
IF(TEST_LIB)
|
||||
if(TEST_LIB)
|
||||
target_link_libraries(${targetname} Eigen2)
|
||||
ENDIF(TEST_LIB)
|
||||
endif(TEST_LIB)
|
||||
|
||||
if(GSL_FOUND)
|
||||
target_link_libraries(${targetname} ${GSL_LIBRARIES})
|
||||
endif(GSL_FOUND)
|
||||
target_link_libraries(${targetname} ${EXTERNAL_LIBS})
|
||||
|
||||
IF(WIN32)
|
||||
ADD_TEST(${testname} "${targetname}")
|
||||
ELSE(WIN32)
|
||||
ADD_TEST(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
|
||||
ENDIF(WIN32)
|
||||
if(WIN32)
|
||||
add_test(${testname} "${targetname}")
|
||||
else(WIN32)
|
||||
add_test(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
|
||||
endif(WIN32)
|
||||
|
||||
ENDMACRO(EI_ADD_TEST)
|
||||
endmacro(ei_add_test)
|
||||
|
||||
|
||||
ENABLE_TESTING()
|
||||
enable_testing()
|
||||
|
||||
IF(TEST_LIB)
|
||||
ADD_DEFINITIONS("-DEIGEN_EXTERN_INSTANTIATIONS=1")
|
||||
ENDIF(TEST_LIB)
|
||||
if(TEST_LIB)
|
||||
add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
|
||||
endif(TEST_LIB)
|
||||
|
||||
EI_ADD_TEST(meta)
|
||||
EI_ADD_TEST(sizeof)
|
||||
EI_ADD_TEST(dynalloc)
|
||||
EI_ADD_TEST(nomalloc)
|
||||
EI_ADD_TEST(packetmath)
|
||||
EI_ADD_TEST(basicstuff)
|
||||
EI_ADD_TEST(linearstructure)
|
||||
EI_ADD_TEST(cwiseop)
|
||||
EI_ADD_TEST(sum)
|
||||
EI_ADD_TEST(product_small)
|
||||
EI_ADD_TEST(product_large ${EI_OFLAG})
|
||||
EI_ADD_TEST(adjoint)
|
||||
EI_ADD_TEST(submatrices)
|
||||
EI_ADD_TEST(miscmatrices)
|
||||
EI_ADD_TEST(commainitializer)
|
||||
EI_ADD_TEST(smallvectors)
|
||||
EI_ADD_TEST(map)
|
||||
EI_ADD_TEST(array)
|
||||
EI_ADD_TEST(triangular)
|
||||
EI_ADD_TEST(cholesky)
|
||||
EI_ADD_TEST(lu ${EI_OFLAG})
|
||||
EI_ADD_TEST(determinant)
|
||||
EI_ADD_TEST(inverse)
|
||||
EI_ADD_TEST(qr)
|
||||
EI_ADD_TEST(eigensolver)
|
||||
EI_ADD_TEST(svd)
|
||||
EI_ADD_TEST(geometry)
|
||||
EI_ADD_TEST(hyperplane)
|
||||
EI_ADD_TEST(parametrizedline)
|
||||
EI_ADD_TEST(regression)
|
||||
EI_ADD_TEST(sparse ${EI_OFLAG})
|
||||
ei_add_test(meta)
|
||||
ei_add_test(sizeof)
|
||||
ei_add_test(dynalloc)
|
||||
ei_add_test(nomalloc)
|
||||
ei_add_test(packetmath)
|
||||
ei_add_test(basicstuff)
|
||||
ei_add_test(linearstructure)
|
||||
ei_add_test(cwiseop)
|
||||
ei_add_test(sum)
|
||||
ei_add_test(product_small)
|
||||
ei_add_test(product_large ${EI_OFLAG})
|
||||
ei_add_test(adjoint)
|
||||
ei_add_test(submatrices)
|
||||
ei_add_test(miscmatrices)
|
||||
ei_add_test(commainitializer)
|
||||
ei_add_test(smallvectors)
|
||||
ei_add_test(map)
|
||||
ei_add_test(array)
|
||||
ei_add_test(triangular)
|
||||
ei_add_test(cholesky)
|
||||
ei_add_test(lu ${EI_OFLAG})
|
||||
ei_add_test(determinant)
|
||||
ei_add_test(inverse)
|
||||
ei_add_test(qr)
|
||||
ei_add_test(eigensolver)
|
||||
ei_add_test(svd)
|
||||
ei_add_test(geometry)
|
||||
ei_add_test(hyperplane)
|
||||
ei_add_test(parametrizedline)
|
||||
ei_add_test(regression)
|
||||
ei_add_test(sparse )
|
||||
|
||||
ENDIF(BUILD_TESTS)
|
||||
endif(BUILD_TESTS)
|
||||
|
@ -23,6 +23,8 @@
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "main.h"
|
||||
#include <Eigen/Cholesky>
|
||||
#include <Eigen/LU>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
enum {
|
||||
@ -46,8 +48,7 @@ initSparse(double density,
|
||||
{
|
||||
Scalar v = (ei_random<Scalar>(0,1) < density) ? ei_random<Scalar>() : 0;
|
||||
if ((flags&ForceNonZeroDiag) && (i==j))
|
||||
while (ei_abs(v)<1e-2)
|
||||
v = ei_random<Scalar>();
|
||||
v = ei_random<Scalar>(Scalar(5.),Scalar(20.));
|
||||
if ((flags & MakeLowerTriangular) && j>i)
|
||||
v = 0;
|
||||
else if ((flags & MakeUpperTriangular) && j<i)
|
||||
@ -98,7 +99,7 @@ template<typename Scalar> void sparse(int rows, int cols)
|
||||
refMat.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5);
|
||||
|
||||
VERIFY_IS_APPROX(m, refMat);
|
||||
|
||||
#if 0
|
||||
// test InnerIterators and Block expressions
|
||||
for(int j=0; j<cols; j++)
|
||||
{
|
||||
@ -216,9 +217,43 @@ template<typename Scalar> void sparse(int rows, int cols)
|
||||
|
||||
// TODO test row major
|
||||
}
|
||||
#endif
|
||||
|
||||
// test LLT
|
||||
{
|
||||
SparseMatrix<Scalar> m2(rows, cols);
|
||||
DenseMatrix refMat2(rows, cols);
|
||||
|
||||
DenseVector b = DenseVector::Random(cols);
|
||||
DenseVector refX(cols), x(cols);
|
||||
|
||||
initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, &zeroCoords, &nonzeroCoords);
|
||||
refMat2 += refMat2.adjoint();
|
||||
refMat2.diagonal() *= 0.5;
|
||||
|
||||
refMat2.llt().solve(b, &refX);
|
||||
// std::cerr << refMat2 << "\n\n" << refMat2.llt().matrixL() << "\n\n";
|
||||
// std::cerr << m2 << "\n\n";
|
||||
typedef SparseMatrix<Scalar,Lower|SelfAdjoint> SparseSelfAdjointMatrix;
|
||||
x = b;
|
||||
SparseLLT<SparseSelfAdjointMatrix> (m2).solveInPlace(x);
|
||||
VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: default");
|
||||
#ifdef EIGEN_CHOLMOD_SUPPORT
|
||||
x = b;
|
||||
SparseLLT<SparseSelfAdjointMatrix,Cholmod>(m2).solveInPlace(x);
|
||||
VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: cholmod");
|
||||
#endif
|
||||
#ifdef EIGEN_TAUCS_SUPPORT
|
||||
x = b;
|
||||
SparseLLT<SparseSelfAdjointMatrix,Taucs>(m2,IncompleteFactorization).solveInPlace(x);
|
||||
VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: taucs (IncompleteFactorization)");
|
||||
x = b;
|
||||
SparseLLT<SparseSelfAdjointMatrix,Taucs>(m2,SupernodalMultifrontal).solveInPlace(x);
|
||||
VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: taucs (SupernodalMultifrontal)");
|
||||
x = b;
|
||||
SparseLLT<SparseSelfAdjointMatrix,Taucs>(m2,SupernodalLeftLooking).solveInPlace(x);
|
||||
VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: taucs (SupernodalLeftLooking)");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user