Blitz logo

Blitz Support :

From: daniel.egloff_at_[hidden]
Date: 2005-05-31 05:16:37


Dear Blitz List

how can I make the following loop dimension independent, e.g. the
dimension 4 should be variable, but compile time fixed.

blitz::Array<double,4> array; // zero based

    for (int i = array.lbound(blitz::firstDim); i <=
array.ubound(blitz::firstDim); i++)
    {
        for (int j = array.lbound(blitz::secondDim); j <=
array.ubound(blitz::secondDim); j++)
        {
            for (int k = array.lbound(blitz::thirdDim); k <=
array.ubound(blitz::thirdDim); k++)
            {
                   blitz::Array<double,4> slice =
array(i,j,k,blitz::Range::all());
         // apply some function f on the slice which does some
operation on all element of slice as a whole
                  // e.g. inplace sort of all the elements slice(0),
... slice(slice.extent(firstDim))
        sort(slice);
            }
        }
    }

a related question: how can I make the following loop dimension
independent:

blitz::Array<double,3> array;

    for (int i = array.lbound(blitz::firstDim); i <=
array.ubound(blitz::firstDim); i++)
    {
        for (int j = array.lbound(blitz::secondDim); j <=
array.ubound(blitz::secondDim); j++)
        {
            for (int k = array.lbound(blitz::thirdDim); k <=
array.ubound(blitz::thirdDim); k++)
            {
                  // apply a function to every array element,
depending on its indices
        f(i,j,k, array(i,j,k));
            }
        }
    }

I think the second problem is related to functors. Whats about the
first?
Any help greatly appreciated.

Regards,
Daniel Egloff
Zürcher Kantonalbank, VFEF
Josefstrasse 222, 8005 Zürich
Tel. +41 (0) 44 292 45 33, Fax +41 (0) 44 292 45 93
Briefadresse: Postfach, 8010 Zürich, http://www.zkb.ch
___________________________________________________________________

Disclaimer:

Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger
bestimmt.

Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird,
bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden
und anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige
Kopien zu vernichten bzw. zu loeschen. Der Gebrauch der Information
ist verboten.

This message is intended only for the named recipient and may contain
confidential or privileged information.

If you have received it in error, please advise the sender by return
e-mail and delete this message and any attachments. Any unauthorised
use or dissemination of this information is strictly prohibited.