Blitz logo

Blitz Support :

From: Julian Cummings (cummings_at_[hidden])
Date: 2003-04-03 15:18:32


I think you probably have to save the intermediate 1d vectors in your
expression
into temporaries before computing your diadic product. So you should
try this:

using namespace tensor;

Array<float,2> A(3,4);
Array<float,1> B(4), B2(3), C(5), C2(4);
Range J(0,2), I(0,3);

B2 = B(J+1) - B(J);
C2 = C(I+1) - C(I);
A = B2(i) * C2(j);

This syntax may not be as satisfying and simple as what you would like,
but I don't
think you can improve on this within the constraints of the Blitz Array
design. The
problem with your original attempt is that you cannot index an Array
expression
in Blitz, so you have to store intermediate expressions as Arrays before
indexing them.

Regards, Julian C.

Zsolt Regaly wrote:

>Content-Type: text/plain;
> charset="iso-8859-1"
>From: Zsolt Regaly <rezso_at_general> (by way of Zsolt Regaly <rezso_at_general>) (by way of Zsolt Regaly <rezso_at_general>) (by way of Zsolt Regaly <rezso_at_general>)
>Subject: [Blitz-support] Creating 2d array from 1d vectors
>Date: Tue, 25 Mar 2003 16:15:40 +0100
>User-Agent: KMail/1.4.3
>To: blitz-support_at_[hidden]
>MIME-Version: 1.0
>Content-Transfer-Encoding: quoted-printable
>Message-Id: <200303251615.40956.rezso_at_general>
>
>Hi
>
>Any one knows a method to create 2d array from the diadic product of two =
>1d
>vectors?
>
>I'd like to do this:
>
>using namespace tensor;
>
>Array<float, 2> A(4,5);
>Array<float, 1> B(4), C(5);
>
>A =3D B(i)*C(j);
>
>which is working good.
>But if I try this:
>
>using namespace tensor;
>
>Array<float, 2> A(3,4);
>Array<float, 1> B(4), C(5);
>Range J(0, 2), I(0, 3)
>
>A =3D (B(J+1)-B(J))(i)*(C(I+1)-V(I))(j);
>
>I got compillation error!
>_______________________________________________
>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