I seem to remember that there was a PP switch to force the variable to
be made 'physical' (or whatever the term was as opposed to 'virtual').
It amounts to using the $PP() macro to make sure the contiguous memory
block is available for the external routine to work on. Grepping the
PDL source resulted in a few hits in some gsl_ interfaces.
So even if you are working on a slice a physical memory block is
allocated and the changes will be flown back to the parent. Comes at a
memory cost obviously...
Christian
On 18/11/2009, at 4:15 AM, Craig DeForest wrote:
> 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
--
Christian Soeller PhD Dept. of Physiology +64 9 3737599 x82770
University of Auckland Auckland, New Zealand fax +64 9 3737499
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl