From 27eebb9b222d25520d07b0e247641674b50e322a Mon Sep 17 00:00:00 2001 From: Michael Kaess Date: Wed, 7 Jul 2010 22:26:46 +0000 Subject: [PATCH] compiling under linux with lapack; removed unnecessary install from Makefile in spqr with Kai --- Makefile.am | 4 ---- configure.ac | 2 ++ cpp/Makefile.am | 11 +++++++++-- cpp/Matrix.cpp | 7 ++++++- cpp/Matrix.h | 2 ++ cpp/testMatrix.cpp | 2 ++ spqr_mini/Makefile.am | 9 ++++++++- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index d2d27e479..b496ab80e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,10 +20,6 @@ install-exec-hook: cp -f ldl/ldl.h $(prefix)/include/ldl/ && \ cp -f ldl/UFconfig.h $(prefix)/include/ldl/ && \ cp -f ldl/libldl.a $(prefix)/lib/ - install -d $(prefix)/include/spqr_mini && \ - cp -f spqr_mini/*.h $(prefix)/include/spqr_mini/ && \ - cp -f spqr_mini/*.hpp $(prefix)/include/spqr_mini/ && \ - [ -f spqr_mini/libspqr_mini.a ] && cp -f spqr_mini/libspqr_mini.a $(prefix)/lib/ || echo "Skipping spqr" dist-hook: mkdir $(distdir)/CppUnitLite diff --git a/configure.ac b/configure.ac index a71e09e61..2cab1163f 100644 --- a/configure.ac +++ b/configure.ac @@ -65,6 +65,8 @@ AC_ARG_ENABLE([lapack], esac],[lapack=false]) AM_CONDITIONAL([USE_LAPACK_MACOS], [test x$lapack = xtrue && test x$ISMAC = xtrue]) +AM_CONDITIONAL([USE_LAPACK_LINUX], [test x$lapack = xtrue && test x$ISMAC = xfalse]) +AM_CONDITIONAL([USE_LAPACK], test x$lapack = xtrue) AM_CONDITIONAL([USE_VECLIB_MACOS], [(test x$lapack = xtrue || test x$blas = xtrue) && test x$ISMAC = xtrue]) #enabgle SparseQR for linear solving diff --git a/cpp/Makefile.am b/cpp/Makefile.am index f1c07d6ad..2ebec0fe7 100644 --- a/cpp/Makefile.am +++ b/cpp/Makefile.am @@ -329,7 +329,14 @@ if USE_BLAS_MACOS AM_CXXFLAGS += -DGT_USE_CBLAS endif -if USE_LAPACK_MACOS +if USE_LAPACK_LINUX +AM_CXXFLAGS += -I/usr/include +AM_LDFLAGS += -llapack +libgtsam_la_LDFLAGS += -llapack +endif + +if USE_LAPACK +AM_LDFLAGS += -L../spqr_mini -lspqr_mini libgtsam_la_LDFLAGS += -L../spqr_mini -lspqr_mini AM_CXXFLAGS += -DGT_USE_LAPACK endif @@ -349,4 +356,4 @@ CXXLINK = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ # rule to run an executable %.run: % libgtsam.la ./$^ - + diff --git a/cpp/Matrix.cpp b/cpp/Matrix.cpp index 6375a925b..5f6870af8 100644 --- a/cpp/Matrix.cpp +++ b/cpp/Matrix.cpp @@ -19,7 +19,11 @@ #endif #ifdef GT_USE_LAPACK + #ifdef YA_BLAS #include + #else +#include + #endif #endif #include @@ -672,6 +676,7 @@ void householder(Matrix &A, size_t k) { /** in-place householder */ /* ************************************************************************* */ #ifdef GT_USE_LAPACK +#ifdef YA_BLAS void householder(Matrix &A) { int m = A.size1(); int n = A.size2(); @@ -691,7 +696,6 @@ void householder(Matrix &A) { lwork = (int)work_optimal_size; double work[lwork]; dgeqrf_(&m, &n, a, &m, tau, work, &lwork, &info); - int k0 = 0; int j0; memset(A.data().begin(), 0, m*n*sizeof(double)); @@ -703,6 +707,7 @@ void householder(Matrix &A) { } } #endif +#endif /* ************************************************************************* */ Vector backSubstituteUpper(const Matrix& U, const Vector& b, bool unit) { diff --git a/cpp/Matrix.h b/cpp/Matrix.h index d64cbee45..4ecbe3124 100644 --- a/cpp/Matrix.h +++ b/cpp/Matrix.h @@ -261,8 +261,10 @@ void householder(Matrix& A, size_t k); * @return nothing: in place !!! */ #ifdef GT_USE_LAPACK +#ifdef YA_BLAS void householder(Matrix &A); #endif +#endif /** * backSubstitute U*x=b diff --git a/cpp/testMatrix.cpp b/cpp/testMatrix.cpp index 5c09bdaf4..b8dfea6f8 100644 --- a/cpp/testMatrix.cpp +++ b/cpp/testMatrix.cpp @@ -642,6 +642,7 @@ TEST( matrix, houseHolder ) // unit tests for housholder transformation /* ************************************************************************* */ #ifdef GT_USE_LAPACK +#ifdef YA_BLAS TEST( matrix, houseHolder2 ) { double data[] = { -5, 0, 5, 0, 0, 0, -1, @@ -660,6 +661,7 @@ TEST( matrix, houseHolder2 ) CHECK(assert_equal(expected1, A1, 1e-3)); } #endif +#endif /* ************************************************************************* */ // unit test for qr factorization (and hence householder) diff --git a/spqr_mini/Makefile.am b/spqr_mini/Makefile.am index 5f8496394..8645f9a64 100644 --- a/spqr_mini/Makefile.am +++ b/spqr_mini/Makefile.am @@ -2,7 +2,7 @@ includedir = ${prefix}/include/spqr_mini libdir = ${exec_prefix}/lib -if USE_LAPACK_MACOS +if USE_LAPACK sources = cholmod_error.c cholmod_common.c cholmod_memory.c spqr_front.cpp spqr_larftb.cpp headers = UFconfig.h cholmod_common.h cholmod_internal.h cholmod_blas.h cholmod_core.h headers += SuiteSparseQR_definitions.h SuiteSparseQR_subset.hpp spqr_subset.hpp spqr_larftb.h spqr_front.h @@ -24,6 +24,13 @@ AM_LDFLAGS = -lcblas -latlas libspqr_mini_la_LDFLAGS = -framework vecLib -lcblas -latlas endif +if USE_LAPACK_LINUX +AM_CXXFLAGS += -DDLONG -DGT_USE_LAPACK -I/usr/include +libspqr_mini_la_CPPFLAGS = -DDLONG -DGT_USE_LAPACK +AM_LDFLAGS = -llapack +libspqr_mini_la_LDFLAGS = -llapack +endif + endif