Ah. I get it. You want to know the location in memory of the row.
The problem is that there is not necessarily any such thing -- there
is a level of indirection between the PDL dimensions and the memory
addresses. Given a vector into the data, the offset from the ->data
pointer in the PDL struct is the sum of the dimensions *times* the
corresponding element of the ->dimincs field, which is an array of
longs. That's why transposition and dim list shenanigans go so fast
-- they only move around elements of dimincs, rather than shuffling
the data themselves.
If you want to index elements directly you need to calculate the index
explicitly by scaling and summing for each individual element.
On Nov 17, 2009, at 8:12 AM, Craig DeForest wrote:
> You can get access to the loop variables for the "active dims" in
> your PP subroutine -- those are the dims that you declare in the
> signature at the top of the function. Inside a loop(<var>) %{ %}
> construct, the name of the dim is available as a local C variable,
> as in:
>
> /* xvals-like threadlooop */
> loop(n) %{
> $var() = n;
> %}
>
> Does that help?
>
>
>
>
> On Nov 17, 2009, at 12:57 AM, adithya wrote:
>
>> Hi All,
>>
>> How can i get address for a row (column in PDL's case) from PDL::PP??
>>
>> For Example, the following C code
>> int a[10][10];
>> getdata(a);
>> int *row=a[5];
>> row should contain the address of the 5th row.
>>
>> This brings up two questions:
>>
>> In PDL::PP module, can this be done???
>> Can Slices be used inside PP code??
>>
>> Also, is there a way for OtherPars to be made Global Variables (like
>> OtherPars => 'global static int T;')??
>>
>> Thanks in advance.
>>
>> Addy
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl