Boost logo

Ublas :

Subject: [ublas] [bindings] How do I call the new gees? Why is it different from the old one?
From: Paul Leopardi (paul.leopardi_at_[hidden])
Date: 2010-04-19 10:46:01


Hi all,
I'm now trying to use the current bindings and finding it much harder to use
than the V1 bindings. In particular, how should I be calling the new gees in
the following piece of code (from glucat/matrix_imp.h)?

#if defined(_GLUCAT_USE_BINDINGS_V1)
#include <boost/numeric/bindings/lapack/workspace.hpp>
#include <boost/numeric/bindings/lapack/gees.hpp>
#include <boost/numeric/bindings/traits/ublas_matrix.hpp>
#endif
#if defined(_GLUCAT_USE_BINDINGS)
#include <boost/numeric/bindings/lapack/workspace.hpp>
#include <boost/numeric/bindings/lapack/driver/gees.hpp>
#endif

[snip...]

  /// Eigenvalues of a matrix
  template< typename Matrix_T >
  ublas::vector< std::complex<double> >
  eigenvalues(const Matrix_T& val)
  {
    typedef std::complex<double> complex_t;
    typedef typename ublas::vector< complex_t > complex_vector_t;
    typedef typename Matrix_T::size_type matrix_index_t;

    const matrix_index_t dim = val.size1();
    complex_vector_t lambda = complex_vector_t(dim);

#if defined(_GLUCAT_USE_BINDINGS_V1) || defined(_GLUCAT_USE_BINDINGS)
    namespace lapack = boost::numeric::bindings::lapack;
    typedef typename ublas::matrix<double, ublas::column_major>
                     lapack_matrix_t;

    lapack_matrix_t T = to_lapack(val);
    lapack_matrix_t V = T;
#endif
#if defined(_GLUCAT_USE_BINDINGS_V1)
    lapack::gees (T, lambda, V, lapack::optimal_workspace() );
#elif defined(_GLUCAT_USE_BINDINGS)
    lapack::gees ('N', 'N', (logical_t*)0, T, fortran_int_t(0), lambda, V );
#else
    lambda.clear();
#endif
    return lambda;
  }

(where to_lapack() is my own conversion routine).

Compiling this, I get the following somewhat cryptic error message:

g++ -DHAVE_CONFIG_H -I. -I.. -I/home/leopardi/src/boost-numeric-
bindings/boost-numeric-bindings-2010-04-19 -I/home/leopardi/src/boost-
numeric-bindings/boost-numeric-bindings-2010-04-19 -Wall -ansi -march=k8 -
O3 --param max-inline-insns-single=5400 --param large-function-insns=5400 -
funroll-loops -fvariable-expansion-in-unroller -fno-math-errno -fno-trapping-
math -g -DNDEBUG -D_GLUCAT_USE_TR1_UNORDERED_MAP -D_GLUCAT_USE_DENSE_MATRICES
-D_GLUCAT_USE_QD -D_GLUCAT_USE_EIGENVALUES -D_GLUCAT_USE_BINDINGS -
D_GLUCAT_USE_TR1_RANDOM -fno-check-new -fexceptions -MT peg11.o -MD -MP -MF
.deps/peg11.Tpo -c -o peg11.o peg11.cpp
In file included from ../glucat/glucat_imp.h:62,
                 from ../test/driver.h:36,
                 from peg11.cpp:35:
../glucat/matrix_imp.h: In function
‘boost::numeric::ublas::vector<std::complex<double>,
boost::numeric::ublas::unbounded_array<std::complex<double>,
std::allocator<std::complex<double> > > > glucat::matrix::eigenvalues(const
Matrix_T&) [with Matrix_T = boost::numeric::ublas::matrix<float,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<float, std::allocator<float> > >]’:
../glucat/matrix_multi_imp.h:1118: instantiated from ‘glucat::eig_case_t
glucat::matrix_multi<Scalar_T, LO, HI>::eig_test(Scalar_T&) const [with
Scalar_T = float, int LO = -0x00000000000000020, int HI = 32]’
../glucat/matrix_multi_imp.h:1347: instantiated from ‘const
glucat::matrix_multi<Scalar_T, LO, HI> glucat::sqrt(const
glucat::matrix_multi<Scalar_T, LO, HI>&, const glucat::matrix_multi<Scalar_T,
LO, HI>&, bool) [with Scalar_T = float, int LO = -0x00000000000000020, int HI
= 32]’
../glucat/clifford_algebra_imp.h:545: instantiated from ‘const
Multivector<Scalar_T, LO, HI> glucat::sqrt(const Multivector<Scalar_T, LO,
HI>&) [with Multivector = glucat::matrix_multi, Scalar_T = float, int LO =
-0x00000000000000020, int HI = 32]’
../test11/peg11.h:110: instantiated from ‘void peg11::transcendtest(const
Multivector_T&, bool) [with Multivector_T = peg11::do_test11() [with
Multivector_T = glucat::matrix_multi<float, -0x00000000000000020, 32>]::m_]’
../test11/peg11.h:177: instantiated from ‘void peg11::do_test11() [with
Multivector_T = glucat::matrix_multi<float, -0x00000000000000020, 32>]’
peg11.cpp:46: instantiated from here
../glucat/matrix_imp.h:444: error: no matching function for call to
‘gees(char, char, logical_t*, glucat::matrix::eigenvalues(const Matrix_T&)
[with Matrix_T = boost::numeric::ublas::matrix<float,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<float, std::allocator<float> >
>]::lapack_matrix_t&, int, glucat::matrix::eigenvalues(const Matrix_T&) [with
Matrix_T = boost::numeric::ublas::matrix<float,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<float, std::allocator<float> >
>]::complex_vector_t&, glucat::matrix::eigenvalues(const Matrix_T&) [with
Matrix_T = boost::numeric::ublas::matrix<float,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<float, std::allocator<float> >
>]::lapack_matrix_t&)

What is the cause of the error message? Is my translation from the old gees
call to the new gees call correct? I used the code and comments in
<boost/numeric/bindings/lapack/driver/gees.hpp> and
http://www.netlib.org/lapack/patch-3.0/src/dgees.f to guess what values to use
for the parameters. In particular, I was expecting the call to match

gees( const char jobvs, const char sort, logical_t* select, MatrixA& a,
        fortran_int_t& sdim, VectorW& w, MatrixVS& vs )

from <boost/numeric/bindings/lapack/driver/gees.hpp>.

My g++ version is:

gcc version 4.4.1 [gcc-4_4-branch revision 150839] (SUSE Linux)

Best, Paul