3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-27 06:43:40 +01:00
dft_tools/test/pytriqs/arrays/expr.pyx
Olivier Parcollet f2c7d449cc First commit : triqs libs version 1.0 alpha1
for earlier commits, see TRIQS0.x repository.
2013-07-17 19:24:07 +02:00

40 lines
1006 B
Cython

#!python
#cython: embedsignature=True
from cython.operator cimport dereference as deref, preincrement as inc #dereference and increment operators
#cimport cython
import numpy
import string
import warnings
from arrays cimport *
def f(A) :
# Solution 1
cdef array_view[long,TWO] a = array_view[long,TWO](A)
# ....
a.call ( _i(), _j()) << ( _i() + 3*_j() + 2 )
# can not do this ... unless with preprocessing the cython files...
# indeed _i is placeholder[ONE], not lazy_expr, I need to erase its type for
# cython compiler...
#a.call ( _i, _j) << ( _i + 3*_j + 2 )
#....
return A
#Solution 2
cdef placeholder[ONE] i_
cdef placeholder[TWO] j_
array_view[long,TWO] (A).call ( ph(i_), ph(j_)) << ph(i_) + ph(j_)
#Solution 3 ?
array_view[long,TWO] (A).call ( ph0(), ph1()) << ph0() + ph1()
#array_view[long,TWO] (A).call ( _i(), _j()) << 3*_i() + _j()*2
#array_view[long,TWO] (A)( ph(i_), ph(j_)) << ph(i_) + ph(j_)
return A