> Consider the following C code:
>
> float a[100], b[100], c[100], d[100];
> do (i=0; i<100; ++i)
> a[i] = (b[i] < 0) ? c[i] : d[i];
>
> The obvious Blitz++ equivalent
>
> Array<float,1> a(100), b(100), c(100), d(100);
> a = (b < 0) ? c : d;
>
> won't work because the C++ standard doesn't allow overloading the ?:
> operator
> (BTW, can anyone explain me why?).
>
> Is there an elegant and efficient way to formulate 'arithmetic if'
> constructs for Blitz++ arrays?
Not elegantly, no :-)
But the following will do the trick:
Array<float,1> a(100), b(100), c(100), d(100);
a = where(b < 0, c, d);
For this you will need the blitz-19980623 snapshot:
ftp://oonumerics.org/pub/blitz/snapshots/blitz-19980623.tar.gz
Cheers,
Todd
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo@oonumerics.org, with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 04:30:05 EST