[SciPy-User] [SciPy-user] lambda functions within matrix

archeryguru2000 archeryguru2000@gmail....
Thu Apr 29 09:04:25 CDT 2010

Hello all,
I'm trying to create a matrix that will allow me to specify which cells will
contain certain values.  I have a line of code that I just cannot straighten
out.  In SymPy I can use the following:

>>>sympy.Matrix(N,N,lambda i,j: i==j & j<int(M/2+1))

where N and M are integers.  This creates a zero-matrix with ones in the
upper left diagonal but the ones do not continue to the lower left.  However
in SciPy, I assumed I would've used the following:

>>>scipy.fromfunction(lambda i,j: i==j & j<int(M/2+1), (N,N))

but this gives an error that seems to pertain to my lambda function?
unsupported operand type(s) for &: 'float' and 'float'

Any suggestions?
View this message in context: http://old.nabble.com/lambda-functions-within-matrix-tp28393844p28393844.html
Sent from the Scipy-User mailing list archive at Nabble.com.

More information about the SciPy-User mailing list