Working around this, i decided to rewrite some functions so that they 
can accept the original values from a PDL and process in the integer 
array and finally, i'll write the integer arrays into the output piddle; 
so the problem will be solved.

This code (n=$SIZE(n) and $TD is defined as TD(m,n)):

void randomassignment(int ntot, int T, PDL_Short * TD,int n, int *z, int 
**wp, int **dp, int *ztot) //
{
int i,j, t, sum=0;
for(j=0;j<n;j++) {
for(i=sum;i-sum<$TD(m => 2,n => j);i++) {
t = (int)(T*drand());
z[i+sum] = t;
wp[($TD(m => 1,n => j))][t]++;
dp[($TD(m => 0,n => j))][t]++;
ztot[t]++;
}
sum+=$TD(m => 2,n => j);
}
}


gives the following errors

    Cust.xs: In function ‘randomassignment’:
    Cust.xs:85: error: ‘m’ undeclared (first use in this function)
    Cust.xs:85: error: (Each undeclared identifier is reported only once
    Cust.xs:85: error: for each function it appears in.)
    Cust.xs:85: error: expected expression before ‘>’ token
    Cust.xs:88: error: expected expression before ‘>’ token
    Cust.xs:89: error: expected expression before ‘>’ token
    Cust.xs:92: error: expected expression before ‘>’ token

    and so on

what is the proper way to get data from a piddle in a function??

Thanks in advance.
Addy

Christian Soeller wrote:
> 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


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to