|
Boost : |
From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2002-04-04 03:08:05
Hi Kresimir,
you wrote:
> Peter Schmitteckert (boost) wrote:
>
> > It seems that
> > double numerics::detail::conj(double const& x)
> > is missing somewhere.
> [...]> $ g++-3.0 -I ../.. -DUSE_GCC u.C -o u
> > /tmp/cc95hlYg.o: In function
> > `numerics::scalar_conj<double>::operator()(double const&) const':
> >
/tmp/cc95hlYg.o(.gnu.linkonce.t._ZNK8numerics11scalar_conjIdEclERKd+0xd):
> > undefined reference to `numerics::detail::conj(double const&)'
> > collect2: ld returned 1 exit status
>
> Some time ago I stumbled upon the same problem (although
> it wasn't `conj()', but some other function declared/defined
> in `ublas/math.h').
>
> Relevant lines from `ublas/config.h':
>
> #ifdef USE_GCC
> // ...
> #ifdef NDEBUG
> // ...
> #else
> // ...
> #define NUMERICS_USE_INSTANT
> // ...
> #endif
> #endif
>
> That is, if you do not define NDEBUG, then
> NUMERICS_USE_INSTANT is defined. And this
> means that some (all?) functions from `ublas/math.h'
> (eg. `conj()') will not be inlined. Instead, you
> should compile and link `ublas/instant.cpp':
>
> g++-3.0 -I ../.. -DUSE_GCC u.C your_ublas_path/instant.cpp -o u
>
> The alternative is to define NDEBUG:
>
> g++-3.0 -I ../.. -DNDEBUG -DUSE_GCC u.C
>
> BTW, without NDEBUG you will not get true expression
> templates because
>
> #define NUMERICS_USE_ET
>
> is in #ifdef NDEBUG block.
The functions in math.h define a generic interface for scalar functions like
real()/imag()/conj() over the types float, double and std::complex<>.
The implementation currently uses non template functions for the basic types
and template functions for std::complex<>. If the non template functions are
not inlined, declaration and definition need to be separated AFAIK.
I think, it should be possible to extend numerics::type_traits<>, so that
real() could be written for example
template<class T>
typename type_traits<T>::real_type real (const T &t) {
return type_traits<T>::real (t);
}
and hope, that most compilers will accept this ;-) If this works, it should
be possible to eliminate instant.cpp.
Best regards
Joerg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk