2013-07-17 19:24:07 +02:00
|
|
|
from tools import py_deserialize
|
|
|
|
import descriptors
|
|
|
|
|
|
|
|
cdef class TailGf:
|
|
|
|
cdef tail _c
|
|
|
|
def __init__(self, **d):
|
|
|
|
"""
|
2013-09-11 18:23:38 +02:00
|
|
|
TailGf ( shape )
|
|
|
|
TailGf ( data, mask, order_min )
|
2013-07-17 19:24:07 +02:00
|
|
|
"""
|
2014-05-22 14:51:26 +02:00
|
|
|
# default values
|
2013-09-11 18:23:38 +02:00
|
|
|
omin = -1
|
|
|
|
omax = 8
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
a = d.pop('data',None)
|
|
|
|
if a==None :
|
2013-09-11 18:23:38 +02:00
|
|
|
(N1, N2) = d.pop('shape')
|
|
|
|
a = numpy.zeros((omax-omin+1,N1,N2), numpy.complex)
|
2013-07-17 19:24:07 +02:00
|
|
|
m = d.pop('mask',None)
|
|
|
|
if m==None :
|
|
|
|
m = numpy.zeros(a.shape[1:3], int)
|
2013-09-11 18:23:38 +02:00
|
|
|
m.fill(omax)
|
|
|
|
o = d.pop('order_min',None)
|
|
|
|
if o==None: o = omin
|
|
|
|
|
2013-07-17 19:24:07 +02:00
|
|
|
assert len(d) == 0, "Unknown parameters in TailGf constructions %s"%d.keys()
|
2013-09-11 18:23:38 +02:00
|
|
|
|
|
|
|
self._c = tail(array_view[dcomplex,THREE](a), array_view[long,TWO](m), o)
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
property N1 :
|
|
|
|
def __get__(self): return self.shape[0]
|
|
|
|
|
|
|
|
property N2 :
|
|
|
|
def __get__(self): return self.shape[1]
|
|
|
|
|
|
|
|
def _make_slice(self, sl1, sl2):
|
2013-09-11 18:23:38 +02:00
|
|
|
return self.__class__(data = self.data[:,sl1,sl2], mask = self.mask[sl1,sl2])
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
def __repr__ (self) :
|
2013-09-11 18:23:38 +02:00
|
|
|
omin = self.order_min
|
|
|
|
while ((omin <= self.order_max) and (numpy.max(numpy.abs(self.data[omin-self.order_min,:,:])) < 1e-8)):
|
|
|
|
omin = omin+1
|
|
|
|
if omin == self.order_max+1:
|
|
|
|
return "%s"%numpy.zeros(self.shape)
|
|
|
|
else:
|
|
|
|
return string.join([ "%s"%self[r]+ (" /" if r>0 else "") + " Om^%s"%(abs(r)) for r in range(omin, self.order_max+1) ] , " + ")
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
def __call__(self, x) :
|
|
|
|
val = 0.0
|
|
|
|
for n in range(self.order_min, self.order_max+1):
|
|
|
|
val += self[n] * x**(-n)
|
|
|
|
return val
|
|
|
|
|
|
|
|
#---- other operations ----
|
|
|
|
def transpose (self) :
|
|
|
|
"""Transpose the array : new view as in numpy"""
|
2013-09-11 18:23:38 +02:00
|
|
|
return TailGf(data=self.data.transpose(), mask=self.mask.transpose())
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
def conjugate(self) :
|
|
|
|
"""Transpose the array : new view as in numpy"""
|
2013-09-11 18:23:38 +02:00
|
|
|
return TailGf(data=self.data.conjugate(), mask=self.mask)
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|