From: Patrik J. <co...@fa...> - 2012-07-12 17:56:21
|
Hi John, Won't just blitz::all and blitz::any (as in "blitz::all(v == w)") work? Also, the appearance of _bz_VecExpr seems to indicate that you are using the very old blitz 0.9. I'd encourage you to upgrade. cheers, /Patrik On Tue, Jul 10, 2012 at 5:26 PM, John Dickson <joh...@gm...> wrote: > It seems natural to use blitz::product and blitz::sum as "and" and "or", > respectively, on TinyVectors of type bool. (That is, blitz::product(v) > returns 1 if all entries in v are true and 0 otherwise, and similarly with > and.) This is particularly useful when comparing two vectors in an if > statement, as in > > if (blitz::product(v == w)) { ... } > > However, with g++ -- and at least some versions of MSVC -- the above > expression (where v and w are TinyVector<int,3>) results in the compiler > error message: > > "... error: no matching function for call to > product(blitz::_bz_VecExpr<blitz::_bz_VecExrOp<blitz::TinyVector<IterConst<int, > 3, 1>, blitz::TinyVectorIterConst<int, 3, 1>, blitz::_bz_Equal<int,int> > >" > > The above is readily fixed by enclosing v == w in a static_cast, as in: > > if (blitz::product(static_cast<blitz::TinyVector<bool,3> >(v == w))) { ... } > > but this is clumsy when comparisons are made frequently. Note that similar > problems occur with any function that accepts a TinyVector as an argument > when passed a TinyVector expression. > > Thus my question is: is there any way to avoid the static_cast when passing > an expression to either the blitz built-in functions like product and sum or > to other functions that accept a TinyVector as an argument? > > Thank you, > John > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Blitz-support mailing list > Bli...@li... > https://lists.sourceforge.net/lists/listinfo/blitz-support > |