Hello,
I'm a new scipy user, and I'm trying to speed up some array code with
weave. I'm running xp with gcc from cgywin, and scipy.weave.tes t()
returns an OK status.
I'm trying to speed up the code below. I've found a couple of examples
of weave on the web, and I think it should be straight forward, but I
keep getting the following error when calling weave.blitz(exp r). It's
complaining about the variable being assigned, I've tried listing it in
the blitz call with no luck.
Any help is appreciated.
PS I've also posted to scipy.org
Thank you,
Frank
***ERROR***
Traceback (most recent call last):
File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeW eave.py",
line 436, in -toplevel-
prof.runcall(ma in)
File "C:\Python24\Li b\hotshot\__ini t__.py", line 76, in runcall
return self._prof.runc all(func, args, kw)
File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeW eave.py",
line 383, in main
findw(w,wprior, phiprior,uprior ,vprior)
File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeW eave.py",
line 136, in findw
weave.blitz(exp r)
File "C:\Python24\Li b\site-packages\scipy\ weave\blitz_too ls.py", line
35, in blitz
if check_size and not
size_check.chec k_expr(expr,loc al_dict,global_ dict):
File "C:\Python24\Li b\site-packages\scipy\ weave\size_chec k.py", line
51, in check_expr
exec(expr,value s)
File "<string>", line 1
wnext[1:grows-1,1:gcols-1] =( alpha * w[1:grows-1,1:gcols-1] + ax *
(w[1:grows-1,0:gcols-2] + w[1:grows-1,2:gcols]) +
^
SyntaxError: invalid syntax
***CODE***
def findw(wnext,wpr ior,phiprior,up rior,vprior):
#format here is x[i,j] where i's are rows, j's columns, use flipud()
to get the
#print out consistent with the spacial up-down directions
#assign local names that are more
#inline with the class notation
w = wprior
phi = phiprior
u = uprior
v = vprior
#three of the BC are known so just set them
#symetry plane
wnext[0,0:gcols] = 0.0
#upper wall
wnext[gN,0:gcols] = 2.0/gdy**2 * (phi[gN,0:gcols] -
phi[gN-1,0:gcols])
#inlet, off the walls
wnext[1:grows-1,0] = 0.0
upos = where(u>0)
vpos = where(v>0)
Sx = ones_like(u)
Sx[upos] = 0.0
xSx = 1.0 - Sx
Sy = ones_like(v)
Sy[vpos] = 0.0
ySy = 1.0 - Sy
uw = u*w
vw = v*w
ax = gnu*gdt/gdx**2
ay = gnu*gdt/gdy**2
dtdx = gdt/gdx
dtdy = gdt/gdy
alpha = (1.0 - 2.0*ax - 2.0*ay)
#interior nodes
expr = """ \
wnext[1:grows-1,1:gcols-1] =( alpha * w[1:grows-1,1:gcols-1] + ax *
(w[1:grows-1,0:gcols-2] + w[1:grows-1,2:gcols]) +
ay * (w[0:grows-2,1:gcols-1] +
w[2:grows,1:gcols-1]) -
dtdx * (xSx[1:grows-1,1:gcols-1] *
(uw[1:grows-1,1:gcols-1] - uw[1:grows-1,0:gcols-2]) -
Sx[1:grows-1,1:gcols-1] *
(uw[1:grows-1,2:gcols] - uw[1:grows-1,1:gcols-1])) -
dtdy * (ySy[1:grows-1,1:gcols-1] *
(vw[1:grows-1,1:gcols-1] - vw[1:grows-1,0:gcols-2]) -
Sy[1:grows-1,1:gcols-1] *
(vw[1:grows-1,2:gcols] - vw[1:grows-1,1:gcols-1])) )
"""
#weave.inline(e xpr,['wnext','w','Sx ','xSx','Sy','y Sy','uw','vw',' ax','ay','dtdx' ,'dtdy','alpha' ,'grows','gcols '])
#weave.inline(e xpr,['wnext'],compiler='gcc' ,verbose=2)
#weave.blitz(ex pr,['wnext','w','Sx ','xSx','Sy','y Sy','uw','vw',' ax','ay','dtdx' ,'dtdy','alpha' ,'grows','gcols '])
#weave.blitz(ex pr,size_check=1 )
#weave.inline(e xpr,['wnext'])
weave.blitz(exp r)
## for j in range(1,gasizej-1):
## for i in range(1,gasizei-1):
##
## wnext[i,j] =( w[i,j] + gnu*gdt/gdx**2 * (w[i,j-1] -
2.0*w[i,j] + w[i,j+1]) +
## gnu*gdt/gdy**2 * (w[i-1,j] - 2.0*w[i,j] +
w[i+1,j]) -
## (1.0 - Sx[i,j]) * gdt/gdx * (uw[i,j] -
uw[i,j-1]) -
## Sx[i,j] * gdt/gdx * (uw[i,j+1] - uw[i,j]) -
## (1.0 - Sy[i,j]) * gdt/gdy * (vw[i,j] -
vw[i-1,j]) -
## Sy[i,j] * gdt/gdy * (vw[i+1,j] - vw[i,j]) )
## print "***wnext** **"
## print "i: ", i, "j: ", j, "wnext[i,j]: ", wnext[i,j]
#final BC at outlet, off walls
wnext[1:grows-1,gM] = wnext[1:grows-1,gM-1] 0 1546 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacek Generowicz |
last post by:
Does anyone happen to have up-to-date summary instructions for
installing weave.inline ?
I don't want weave.blitz, I don't want Numeric, and I don't want
Scipy. According to the documentation, this is perfectly possible, but
the documentation is clearly out of date, and after working around 3
documentation bugs and still not managing to install it, I'm rapidly
running out of enthusiasm ... so if anyone has done this recently, I'd...
|
by: Michael Foord |
last post by:
Has anyone had success using weave with gcc for windows (standard
windows distribution python)?
I have my distutils setup to use gcc (via mingw32) - which it does
fine. I've compiled and installed various modules with it. Weave
itself installs fine, picking up the settings from distutils.
However it has it's own version of distutils 'scipy_distutils' that it
uses to compile the C it is given - which complains that it can't find...
|
by: JustSomeGuy |
last post by:
I have a routine that evaluates a polynomial equation that have 3 variables
x,y,z of orders 1,2,3 the coefficients of the polynomial are in an array.
This routine is quite slow and I'd like to optimize it.
Any suggestions?
simply put pts is a vector of
typdef struct
double x;
double y;
double z;
|
by: Rex_chaos |
last post by:
Hi all,
I am looking for a high-performance container(matrix and vector) for
numerical computation. Someone recommended the boost::multi_array. After
having looked at the documentation, I know several more candidates from it. They
are : MTL, blitz++, boost::ublas. I have no idea which one is the best.
The documentation of these packages are trying to convince me that they
are free from drawback :)) I need someone to tell me the experience...
|
by: Steven T. Hatton |
last post by:
I bought Josuttis's book on the repeated recommendations of people in this
newsgroup.
http://www.josuttis.com/libbook/
One of the first things I looked up was the std::valarray<>. And what I
read is that he questions the worth of the valarray.
http://www.cs.bsu.edu/homepages/peb/cplusplus/headers/valarray.htm
| |
by: zhuang |
last post by:
Hi,
I'm having some problems getting weave to work correctly. For now,
I'm just testing how to
access Numeric arrays under weave. My test code is:
from Numeric import *
import weave
a = zeros((5,5,5,5,5),typecode=Int16)
|
by: Guch Wu |
last post by:
Array<unsigned char,2> A(10,10);
unsigned char* rawdata;
rawdata = new (unsinged char);
Can I extract data in A to rawdata without using for loop?
|
by: dss |
last post by:
I'm trying to compile some code that I downloaded. The code uses
Blitz++ and tvmet to manipulate arrays. I have never worked with either
of these, and I am having trouble getting both of these to work. When I
compile the code, I get a compiler error in the tvmet files. Instead of
trying to figure out what is going on with tvmet, I decided to do
everything with blitz. Which is also not working out. I am hoping that
someone can provide...
|
by: Soren |
last post by:
Hi,
I have a strange and very annoying problem when using weave in scipy..
when I run the code below.. the first time it needs to compile.. it
says <compilingand then python.exe crashes! and no result is shown..
the second time i run it, it does not compile but gives the completely
wrong answer.. prints a matrix of all zeros except for point 1,1 in
the matrix which seems to have some random high number like
-5.39403959e+08. .... !!??
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |