Loading ...
Sorry, an error occurred while loading the content.

Re: [ublas-dev] promote_traits

Expand Messages
  • Alexis
    Ok, found the answer myself :) It s because the boost::mpl library defines by default a maximum size of 10 for a meta-vector. In order to overcome this
    Message 1 of 2 , Feb 1, 2004
    View Source
    • 0 Attachment
      Ok, found the answer myself :)
      It's because the boost::mpl library defines by default a maximum size
      of 10 for a meta-vector. In order to overcome this limitation, you just
      need to change the file boost/mpl/limits/vector.hpp, which contains a
      single #define. Change the value to 20, 30, 40 or 50.
      Finally, add #define BOOST_MPL_NO_PREPROCESSED_HEADERS before you
      include any ublas headers.

      On Thursday, Jan 29, 2004, at 00:03 Europe/London, alexismajordomo
      wrote:

      > Hello guys,
      >
      > I was playing with the promote_traits meta-function of uBlas.
      > Congratulations, nice
      > job and well written. However, I had some problems when I tried to use
      > them with
      > 'char' and 'short' built-in data types (see below). The behaviour of
      > the test program I
      > wrote is not correct. Those types are not promoted by the
      > meta-function, the reason
      > being that they are not defined in the meta-function, more precisely
      > in the
      > mpl::vector object containing the list of built-in types. I thought
      > that'd be easy, that
      > simply adding would do. However, it seems that the size of the
      > meta-vector is limited
      > to 10, and adding char, uchar, short and ushort added up to 11.
      > However, it seems that the header included is a precompiled one (I
      > dont know exactly
      > the mechanisms that led to that header being included rather than the
      > generic one).
      > So I think there might be a possibility of forcing the generic header
      > to be used, and a
      > mpl::vector of the right size to be generated. Do you know how to do
      > such a thing?
      >
      > OR, if you have any other solutions on how to solve this issue, I'd be
      > more than happy
      > if you could indicate it to me. You did such a great job with writting
      > this lib, that'd be
      > a shame if it suffered of tiny details such as promote_traits not
      > supporting char and
      > short.
      >
      > All the best
      >
      > Alexis
      >
      >
      > ==========CUT HERE =============
      >
      > // clearly, char is not promoted neither to int, nor to float
      > // as the typedefed ci and cf shows (their size is 1)
      > // and the 1st is not integral and the 2nd not floating point.
      > // furthermore, they are not char as well, weird, huh?
      >
      > #include <iostream>
      > #include "boost/numeric/ublas/vector.hpp"
      > #include "boost/numeric/ublas/matrix.hpp"
      > #include "boost/numeric/ublas/matrix_expression.hpp"
      > #include "boost/numeric/ublas/io.hpp"
      > #include "boost/numeric/ublas/traits.hpp"
      > #include "boost/type_traits.hpp"
      >
      > int main()
      > {
      > typedef char t1;
      > typedef int t2;
      > typedef float t3;
      > typedef double t4;
      >
      > namespace ublas = boost::numeric::ublas;
      >
      > typedef ublas::promote_traits<t1, t2>::promote_type ci;
      > typedef ublas::promote_traits<t2, t3>::promote_type tif;
      > typedef ublas::promote_traits<t3, t4>::promote_type fd;
      > typedef ublas::promote_traits<t1, t3>::promote_type cf;
      >
      > ci v1; tif v2; fd v3; cf v4;
      > std::cout << sizeof(v1) << std::endl
      > << sizeof(v2) << std::endl
      > << sizeof(v3) << std::endl
      > << sizeof(v4) << std::endl
      > // << v1 << " "
      > // << v2 << " "
      > // << v3 << " "
      > // << v4 << " "
      > << std::endl;
      >
      > std::cout << std::boolalpha << "integral" << std::endl
      > << boost::is_integral<ci>::value << std::endl
      > << boost::is_integral<tif>::value << std::endl
      > << boost::is_integral<fd>::value << std::endl
      > << boost::is_integral<cf>::value << std::endl;
      >
      > std::cout << std::boolalpha << "float" << std::endl
      > << boost::is_float<ci>::value << std::endl
      > << boost::is_float<tif>::value << std::endl
      > << boost::is_float<fd>::value << std::endl
      > << boost::is_float<cf>::value << std::endl;
      >
      > std::cout << std::boolalpha << "alignment" << std::endl
      > << boost::alignment_of<ci>::value << std::endl
      > << boost::alignment_of<tif>::value << std::endl
      > << boost::alignment_of<fd>::value << std::endl
      > << boost::alignment_of<cf>::value << std::endl;
      >
      > std::cout << std::boolalpha << "is same" << std::endl
      > << boost::is_same<ci, char>::value << std::endl
      > << boost::is_same<tif, float>::value << std::endl
      > << boost::is_same<fd, double>::value << std::endl
      > << boost::is_same<cf, char>::value << std::endl;
      >
      > return 0;
      > }
      >
      >
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      > ---------------------~-->
      > Upgrade to 128-bit SSL Security!
      > http://us.click.yahoo.com/qZ0LdD/yjVHAA/TtwFAA/EbFolB/TM
      > ---------------------------------------------------------------------
      > ~->
      >
      > Yahoo! Groups Links
      >
      > To visit your group on the web, go to:
      > http://groups.yahoo.com/group/ublas-dev/
      >
      > To unsubscribe from this group, send an email to:
      > ublas-dev-unsubscribe@yahoogroups.com
      >
      > Your use of Yahoo! Groups is subject to:
      > http://docs.yahoo.com/info/terms/
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.