[Numpy-discussion] f2py: variable number of arguments of variable lengths

Fabrice Silva silva at lma.cnrs-mrs.fr
Wed Feb 17 16:55:48 EST 2010


Le mercredi 17 février 2010 à 15:43 -0600, Robert Kern a écrit :
> On Wed, Feb 17, 2010 at 15:29, Fabrice Silva <silva at lma.cnrs-mrs.fr> wrote:
> > I previously coded a fortran function that needs a variable number of
> > scalar arguments. This number is not known at compile time, but at call
> > time. So I used to pass them within a vector, passing also the length of
> > this vector
> >
> >              subroutine systeme(inc,t,nm,Dinc,sn)
> >        C
> >        C      evaluate the derivative of vector x at time t
> >        C      with complex modes (sn). Used for the calculation
> >        C      of auto-oscillations in resonator-valve coupled system.
> >        C
> >              integer nm,np,ny,ind
> >              double precision inc(1:2*nm+2), Dinc(1:2*nm+2)
> >              complex*16 sn(1:nm)
> >
> >        Cf2py double precision, intent(in) :: t
> >        Cf2py integer, intent(in), optional :: nm
> >        Cf2py double precision, intent(in), dimension(2*nm+2) :: inc
> >        Cf2py double precision, intent(out), dimension(2*nm+2) :: Dinc
> >        Cf2py complex, intent(in), dimension(nm) :: sn
> >
> >
> > I do now want to pass, not nm float values, but nm arrays of variables
> > lengths. I expect to pass the following objects :
> > - nm: number of arrays
> > - L : a 1d-array (dimension nm) containing the lengths of each array
> > - np: the sum of lengths
> > - X : a 1d-array (dimension np) containing the concatenated arrays.
> 
> Yeah, that's pretty much what you would have to do.

What about the next step: a variable number of arguments that are
2d-arrays with different shapes ?

-- 
Fabrice Silva
LMA UPR CNRS 7051




More information about the NumPy-Discussion mailing list