[f2py] arguments issue

Chris Fonnesbeck fonnesbeck at gmail.com
Wed Mar 9 16:47:54 EET 2005


I have an f2py module for generating multivariate normal random
variates, but am having problems with the argument list. The arguments
are: 1. a list of expected values (input), 2. a covariance matrix
(input) 3. the dimension of the multivariate quantity (hidden), 4. the
output random variables (output) and 5. a function for generating
standard normal variates (input). It compiles fine, but when I try
running it, I get the following error:

>>> genmn([0,0], [[1,0],[0,1]], normal)
create_cb_arglist: Failed to build argument list (siz) with enough
arguments (tot-opt) required by user-supplied function
(siz,tot,opt=0,3,1).
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
flib.error: failed in processing argument list for call-back snorm.

The arguments look fine to me, so I'm not sure what is happening. Here
is the f2py code:

      SUBROUTINE genmn(mu,sigma,x,p,snorm)

cf2py real dimension(p),intent(in) :: mu
cf2py real dimension(p,p),intent(in) :: sigma
cf2py real dimension(p),intent(out) :: x
cf2py integer intent(hide),depend(mu) :: p=len(mu)

C     .. Array Arguments ..
      REAL mu(p),sigma(p,p),csigma(p,p),x(p)
C     ..
C     .. Local Scalars ..
      REAL ae
      INTEGER i,j,p
C     ..
C     .. External Functions ..
      REAL snorm
      EXTERNAL snorm
C
C     Cholesky decomposition of covariance matrix
C
      CALL chol(p,simga,csigma)
   
      DO 10,i = 1,p
          ae = 0.0
          DO 20,j = 1,i
              ae = ae + csigma(i,j)*snorm()
   20     CONTINUE
          x(i) = ae + mu(i)
   10 CONTINUE
      RETURN
C
      END


Any help most appreciated,
Chris



More information about the f2py-users mailing list