Menu

[r2807]: / trunk / course / examples / weave_cplx.py  Maximize  Restore  History

Download this file

23 lines (20 with data), 549 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
###########################################################################
from Numeric import *
from weave import *
def complex_test():
a = zeros((4,4),Complex)
a[0,0] = 1+2j
a[1,1] = 2+3.5j
print 'Before\n',a
code = \
"""
std::complex<double> i(0, 1);
std::cout << a(1,1) << std::endl;
a(2,2) = 3.0+4.5*i;
//a(2,2).imag = 4.5;
"""
inline(code,['a'],type_converters = converters.blitz)
print 'After\n',a
complex_test()
###########################################################################
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.