getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-users] Getfem python interface questions


From: LUK ShunTim
Subject: [Getfem-users] Getfem python interface questions
Date: Fri, 16 Nov 2007 13:28:46 +0800
User-agent: Mozilla-Thunderbird 2.0.0.6 (X11/20071008)

Hello,

I'm learning to use the python interface by trying to translate the M-files in the tests/matlab directory into their python counterparts.

I start with tutorial1.m and things seem to go well until this line

R=gf_mesh_fem_get(mf, 'eval', {'(x-.5).^2 + (y-.5).^2 + x/5 - y/3'});

Here's the python equivalent I used:
R=mf.eval('(x[0] - 0.5)**2 + (x[1] - 0.5)**2 + x[0]/5.0 - x[1]/3.0')

I got this error traceback

</error>
([], array([], type=Int32))
Traceback (most recent call last):
  File "tutorial1.py", line 50, in ?
    R=mf.eval('(x[0] - 0.5)**2 + (x[1] - 0.5)**2 + x[0]/5.0 - x[1]/3.0')
File "/usr/lib/python2.4/site-packages/getfem/getfem.py", line 865, in eval
    x=P[:,0]; r=numarray.array(eval(expression))
IndexError: Index out of range
</error>

I think I don't know how to use the eval() function correctly.

Another question: is my understanding of the equivalence of types in the matlab-interface document correct?

Matlab          Python

ivec            numarray rank-1 integer array (of default precision)
vec             numarray rank-1 float array (of default precision)
imat            numarray rank-2 integer array (of default precision)
mat             numarray rank-2 float array (of default precision)

On my debian/sid amd64, the default precision for array elements are Int64 and Float64, respectively.

If anyone is interested, after I get them working, I'm happy to share them. But don't hold your breadth, :-) I just started my learning and I can only do it intermittently. I'm sure I have to seek your help again.

Thanks in advance,
ST
--





reply via email to

[Prev in Thread] Current Thread [Next in Thread]