Blitz logo

Blitz Support :

From: Othmar Frey (ofrey_at_[hidden])
Date: 2004-07-16 10:05:35


Hi.

I am rather new to blitz++.

I would like to evaluate a one dimensional array
at indices that are given in a - let's say - 2-dimensional
array of indices.

What I would love to have working is something like:
(something I am really fond of that it works in Matlab)
-------------------------------------------------------
    ...

    Array<float,1> dataVector(100);
    Array<float,2> dataMatrix1(20,20);
    Array<float,2> dataMatrix2(20,20);
    Array<int,2> arrayOfIndices(20,20);

    ...
    // fill dataVector and dataMatrix1 with some data
    // and set the indices in arrayOfIndices according to my needs
    ...

    dataMatrix2 = dataMatrix1 + dataVector(arrayOfIndices);

    ...
---------------------------------------------------------

    I've learned from the example pick.cpp at

    http://www.oonumerics.org/blitz/examples/blitz/pick.cpp

    that there's a possibility to pick
    values from a vector according to a given index vector by using
    VectorPick.
    But then, all the nice elementwise operators don't work as the do for
    arrays.

    Is there straightforward solution to this problem, which I missed?
    (Maybe one that is even mentioned in the documentation?)

    Many thanks for your help.

    Cheers

    Othmar

-- 
-----------------------------------------------------------------------
Othmar Frey                             Remote Sensing Laboratories RSL
ofrey_at_[hidden]                      University of Zurich
http://www.geo.unizh.ch/~ofrey          Winterthurerstrasse 190	
phone +41 44 635 51 64                  CH-8057 Zurich
fax   +41 44 635 68 46                  Switzerland
-----------------------------------------------------------------------