On 27 Nov., 12:22, Jens-Peer Kuska <ku... at informatik.uni-leipzig.de>
wrote:
> Hi,
>
> and write a pure Mathematica function, that check the arguments
> and send it to the C-Function is not a option, i.e.,
>
> Sample[lst_] /; And@@ (NumericQ /@ Flatten[lst]):=
> rawCSample[Length /@ lst,Flatten[lst]]
>
> But I'm not sure what you mean with "depth" .. because
> in Mathematica a "lists of lists (array) of Real values"
> has always the Depth[] == 2
>
> If you just need the pattern of a List of list with reals
> {{__Real}..} should do that
>
> Regards
> Jens
>
> Chris wrote:
> > Dear all,
>
> > We're having quite a similiar problem to a post that was made last
> > june:
> >http://forums.wolfram.com/mathgroup/archive/2006/Jun/msg00398.html
>
> > We want to send a multidimensional array from Mathematica to a
> > C-Programm (over Mathlink) that uses this data as input. At the moment
> > we're
> > struggling with the "Pattern:"-command in the template file.
>
> > Since we're passing lists of lists (array) of Real values to our
> > programm but don't know the depth of this list in advance (the actual
> > user enters the depth), this forms
> > our problem. How is it possible to write such a 'Pattern:...' ?
> > Any insights on that one?
>
> > Our .tm-file for only 2 'inner lists' looks as follows:
> > ********************
> > // tm-file
> > :Begin:
> > :Function: Sample
> > // how can we make this more dynamic? We want to be able to determine
> > the number of inner lists ourselves, maybe with an additional
> > parameter?
> > :Pattern: Sample[list:{one:{___Real},two:{___Real}}]
> > :Arguments: {list}
> > :ArgumentTypes: {Manual}
> > :ReturnType: Manual
> > :End:
> > ********************
>
> > This acutally works but doesn't let us leave with much of flexibility.
> > Does anyone have a solution to this one?
> > Any help is greatly appreciated!
>
> > Regards,
> > Chris
Hey Jens,
Thanks a lot, I could use a part of your suggestion as a solution to
my problem. And I got also lucky with the other part and solved the
problem at hand there as well! =) Since we now Flatten[] our list and
put in another variable, we are able to extract all the necessary
information we need to rebuild the nested list as we need it in our
external program.
But you where right, I've misused the term depth. I actually used it
to describe the number of inner lists.
Regards, Chris