![]() |
Blitz Support : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2005-03-01 15:02:36
Hello Inge,
Yes, that line does not compile. The blitz::tensor objects are meant to
be used primarily as Array-like objects that return the index of the
current Array element being evaluated. As a special case, you can index
an Array with a blitz::tensor object, as you did in your first
expression. But typically the blitz::tensor object is used directly in
an Array expression, like this:
b = blitz::tensor::i + 1;
If you need to shift an Array indexing object, you can do this with a
blitz::Range object. So for example,
b = a(blitz::Range(0,1) + 1);
I hope this clears things up for you.
Regards, Julian C.
On Tue, 2005-03-01 at 17:33 +0100, Inge.Viken_at_[hidden] wrote:
>
>
>
>
> Hi all,
>
> I would have thought that the following code should have
> compiled (I'm using Visual Studio.Net 2003, Blitz++ 0.8):
>
>
> #include <iostream>
> #include "blitz/array.h"
> int main(int argc, char *argv[])
> {
> blitz::Array<double, 1> a(3), b(2);
> a = 1, 2, 3;
>
> // Compiles OK:
> b = a(blitz::tensor::i);
>
> // Compiles OK:
> b = a(blitz::Range(1, 2));
>
> // Should do the same as the above line,
> // shouldn't it?
> // Does not compile:
> b = a(blitz::tensor::i + 1);
>
> std::cout << a;
> std::cout << b;
>
> exit(0);
> }
>
>
> The compilation error message is included at the bottom of this mail.
> Presumably it means that 'blitz::tensor::i + 1' will
> evaluate to a BzBinaryExprResult<...>::T_result,
> for which there is no Array::operator() (based on
> interpreting the message and quickly checking the Blitz++ implementation).
>
> Am i doing something wrong, or is the above code simply not supported?
>
> Best regards
> Inge Viken (novice Blitz++ user)
>
> ******************* Error message **************************
>
> c:\usr\tmp\emsea\bugdemo\bugdemo.cpp(18) : error C2664:
> 'blitz::Array<P_numtype,N_rank>::T_array
> blitz::Array<P_numtype,N_rank>::operator ()(blitz::Range) const' : cannot
> convert parameter 1 from 'blitz::BzBinaryExprResult<OP,O1,O2>::T_result' to
> 'blitz::Range'
> with
> [
> P_numtype=double,
> N_rank=1
> ]
> and
> [
> OP=blitz::Add,
> O1=blitz::IndexPlaceholder<0>,
> O2=int
> ]
> No constructor could take the source type, or constructor overload
> resolution was ambiguous
>
>
> _____________________________
> Neither the confidentiality nor the integrity of this message can be
> guaranteed following transmission on the Internet. The addressee should
> consider this risk and take full responsibility for use of this message.
> This e-mail has been swept by Norman antivirus software.
>
>
>
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
-- Dr. Julian C. Cummings E-mail: cummings_at_[hidden] California Institute of Technology Phone: 626-395-2543 1200 E. California Blvd., Mail Code 158-79 Fax: 626-584-5917 Pasadena, CA 91125 Office: 125 Powell-Booth