c-api vs. ctypes
Vieleicht interessant zu diesem Thema:
http://conference.scipy.org/proceedings ... l_text.pdf
http://conference.scipy.org/proceedings ... l_text.pdf
Hier einmal eine Lösung mit f2py:
File test.f95File testpy.pyAusgabeMfG
HWK
File test.f95
Code: Alles auswählen
subroutine test(arrayin, arrayout, m, n)
implicit none
REAL, dimension(m, n), intent(in) :: arrayin
REAL, dimension(m, n), intent(out) :: arrayout
integer, intent(in) :: m, n
arrayout = arrayin + 3
end subroutine test
Code: Alles auswählen
import numpy
import test
a = numpy.arange(9).reshape(3, 3)
b = test.test(a)
print a
print b
Code: Alles auswählen
>C:\Programme\Python26\pythonw -u "testpy.py"
[[0 1 2]
[3 4 5]
[6 7 8]]
[[ 3. 4. 5.]
[ 6. 7. 8.]
[ 9. 10. 11.]]
>Exit code: 0
HWK
-
- User
- Beiträge: 13
- Registriert: Dienstag 2. Februar 2010, 13:11
@openMP: ich konnte noch keine Performancesteigerungen feststellen, auch wenn beide Cores jetzt ausgelastet sind...muss den Code wahrsch. noch optimieren!
wenn ich den Code beim compilieren optimiere (-O2) rennt es schneller als auf meinem Dual Core!
wenn ich den Code beim compilieren optimiere (-O2) rennt es schneller als auf meinem Dual Core!