Commit e94b3f41 authored by Ultima's avatar Ultima
Browse files

Migration of point_space to d2o completed.

Reworked init of d2o.
Implemented a distributor cache.
parent a43a3b04
...@@ -29,7 +29,8 @@ from nifty_cmaps import ncmap ...@@ -29,7 +29,8 @@ from nifty_cmaps import ncmap
from nifty_core import space,\ from nifty_core import space,\
point_space,\ point_space,\
nested_space,\ nested_space,\
field field
from nifty_mpi_data import distributed_data_object from nifty_mpi_data import distributed_data_object
from nifty_power import * from nifty_power import *
from nifty_random import random from nifty_random import random
......
...@@ -36,7 +36,7 @@ from nifty import * # version 0.8.0 ...@@ -36,7 +36,7 @@ from nifty import * # version 0.8.0
about.warnings.off() about.warnings.off()
# some signal space; e.g., a two-dimensional regular grid # some signal space; e.g., a two-dimensional regular grid
x_space = rg_space([128, 128]) # define signal space x_space = rg_space([1280, 1280], datamodel = 'd2o') # define signal space
#x_space = rg_space(512) #x_space = rg_space(512)
#x_space = hp_space(32) #x_space = hp_space(32)
#x_space = gl_space(96) #x_space = gl_space(96)
...@@ -56,6 +56,7 @@ d_space = R.target # get data spac ...@@ -56,6 +56,7 @@ d_space = R.target # get data spac
N = diagonal_operator(d_space, diag=s.var(), bare=True) # define noise covariance N = diagonal_operator(d_space, diag=s.var(), bare=True) # define noise covariance
n = N.get_random_field(domain=d_space) # generate noise n = N.get_random_field(domain=d_space) # generate noise
d = R(s) + n # compute data d = R(s) + n # compute data
j = R.adjoint_times(N.inverse_times(d)) # define information source j = R.adjoint_times(N.inverse_times(d)) # define information source
......
...@@ -128,7 +128,7 @@ class lm_space(point_space): ...@@ -128,7 +128,7 @@ class lm_space(point_space):
vol : numpy.ndarray vol : numpy.ndarray
Pixel volume of the :py:class:`lm_space`, which is always 1. Pixel volume of the :py:class:`lm_space`, which is always 1.
""" """
def __init__(self,lmax,mmax=None,datatype=None): def __init__(self, lmax, mmax=None, datatype=None):
""" """
Sets the attributes for an lm_space class instance. Sets the attributes for an lm_space class instance.
...@@ -186,7 +186,10 @@ class lm_space(point_space): ...@@ -186,7 +186,10 @@ class lm_space(point_space):
self.paradict['lmax'] = x[0] self.paradict['lmax'] = x[0]
self.paradict['mmax'] = x[1] self.paradict['mmax'] = x[1]
def copy(self):
return lm_space(lmax = self.paradict['lmax'],
mmax = self.paradict['mmax'],
datatype = self.datatype)
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...@@ -213,12 +216,12 @@ class lm_space(point_space): ...@@ -213,12 +216,12 @@ class lm_space(point_space):
""" """
return self.paradict['mmax'] return self.paradict['mmax']
def shape(self): def get_shape(self):
mmax = self.paradict['mmax'] mmax = self.paradict['mmax']
lmax = self.paradict['lmax'] lmax = self.paradict['lmax']
return np.array([(mmax+1)*(lmax+1)-((lmax+1)*lmax)//2], dtype=int) return np.array([(mmax+1)*(lmax+1)-((lmax+1)*lmax)//2], dtype=int)
def dim(self,split=False): def get_dim(self, split=False):
""" """
Computes the dimension of the space, i.e.\ the number of spherical Computes the dimension of the space, i.e.\ the number of spherical
harmonics components that are stored. harmonics components that are stored.
...@@ -242,15 +245,15 @@ class lm_space(point_space): ...@@ -242,15 +245,15 @@ class lm_space(point_space):
""" """
## dim = (mmax+1)*(lmax-mmax/2+1) ## dim = (mmax+1)*(lmax-mmax/2+1)
if(split): if(split):
return self.shape() return self.get_shape()
#return np.array([(self.para[0]+1)*(self.para[1]+1)-(self.para[1]+1)*self.para[1]//2],dtype=np.int) #return np.array([(self.para[0]+1)*(self.para[1]+1)-(self.para[1]+1)*self.para[1]//2],dtype=np.int)
else: else:
return np.prod(self.shape()) return np.prod(self.get_shape())
#return (self.para[0]+1)*(self.para[1]+1)-(self.para[1]+1)*self.para[1]//2 #return (self.para[0]+1)*(self.para[1]+1)-(self.para[1]+1)*self.para[1]//2
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def dof(self): def get_dof(self):
""" """
Computes the number of degrees of freedom of the space, taking into Computes the number of degrees of freedom of the space, taking into
account symmetry constraints and complex-valuedness. account symmetry constraints and complex-valuedness.
...@@ -325,7 +328,7 @@ class lm_space(point_space): ...@@ -325,7 +328,7 @@ class lm_space(point_space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def _getlm(self): ## > compute all (l,m) def _getlm(self): ## > compute all (l,m)
index = np.arange(self.dim(split=False)) index = np.arange(self.get_dim(split=False))
n = 2*self.para[0]+1 n = 2*self.para[0]+1
m = np.ceil((n-np.sqrt(n**2-8*(index-self.para[0])))/2).astype(np.int) m = np.ceil((n-np.sqrt(n**2-8*(index-self.para[0])))/2).astype(np.int)
l = index-self.para[0]*m+m*(m-1)//2 l = index-self.para[0]*m+m*(m-1)//2
...@@ -397,7 +400,7 @@ class lm_space(point_space): ...@@ -397,7 +400,7 @@ class lm_space(point_space):
else: else:
if(np.size(x)==1): if(np.size(x)==1):
if(extend): if(extend):
x = self.datatype(x)*np.ones(self.dim(split=True),dtype=self.datatype,order='C') x = self.datatype(x)*np.ones(self.get_dim(split=True),dtype=self.datatype,order='C')
else: else:
if(np.isscalar(x)): if(np.isscalar(x)):
x = np.array([x],dtype=self.datatype) x = np.array([x],dtype=self.datatype)
...@@ -459,13 +462,13 @@ class lm_space(point_space): ...@@ -459,13 +462,13 @@ class lm_space(point_space):
arg = random.parse_arguments(self,**kwargs) arg = random.parse_arguments(self,**kwargs)
if(arg is None): if(arg is None):
return np.zeros(self.dim(split=True),dtype=self.datatype,order='C') return np.zeros(self.get_dim(split=True),dtype=self.datatype,order='C')
elif(arg[0]=="pm1"): elif(arg[0]=="pm1"):
x = random.pm1(datatype=self.datatype,shape=self.dim(split=True)) x = random.pm1(datatype=self.datatype,shape=self.get_dim(split=True))
elif(arg[0]=="gau"): elif(arg[0]=="gau"):
x = random.gau(datatype=self.datatype,shape=self.dim(split=True),mean=None,dev=arg[2],var=arg[3]) x = random.gau(datatype=self.datatype,shape=self.get_dim(split=True),mean=None,dev=arg[2],var=arg[3])
elif(arg[0]=="syn"): elif(arg[0]=="syn"):
lmax = self.para[0] ## lmax lmax = self.para[0] ## lmax
...@@ -483,7 +486,7 @@ class lm_space(point_space): ...@@ -483,7 +486,7 @@ class lm_space(point_space):
return x return x
elif(arg[0]=="uni"): elif(arg[0]=="uni"):
x = random.uni(datatype=self.datatype,shape=self.dim(split=True),vmin=arg[1],vmax=arg[2]) x = random.uni(datatype=self.datatype,shape=self.get_dim(split=True),vmin=arg[1],vmax=arg[2])
else: else:
raise KeyError(about._errors.cstring("ERROR: unsupported random key '"+str(arg[0])+"'.")) raise KeyError(about._errors.cstring("ERROR: unsupported random key '"+str(arg[0])+"'."))
...@@ -612,9 +615,9 @@ class lm_space(point_space): ...@@ -612,9 +615,9 @@ class lm_space(point_space):
each determine another component with negative :math:`m`. each determine another component with negative :math:`m`.
""" """
if(total): if(total):
return self.dof() return self.get_dof()
else: else:
mol = np.ones(self.dim(split=True),dtype=self.vol.dtype,order='C') mol = np.ones(self.get_dim(split=True),dtype=self.vol.dtype,order='C')
mol[self.para[0]+1:] = 2 ## redundant in (l,m) and (l,-m) mol[self.para[0]+1:] = 2 ## redundant in (l,m) and (l,-m)
return mol return mol
...@@ -1060,6 +1063,10 @@ class gl_space(point_space): ...@@ -1060,6 +1063,10 @@ class gl_space(point_space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def copy(self):
return gl_space(nlat = self.paradict['nlat'],
nlon = self.paradict['nlon'],
datatype = self.datatype)
def nlat(self): def nlat(self):
""" """
Returns the number of latitudinal bins. Returns the number of latitudinal bins.
...@@ -1082,10 +1089,10 @@ class gl_space(point_space): ...@@ -1082,10 +1089,10 @@ class gl_space(point_space):
""" """
return self.paradict['nlon'] return self.paradict['nlon']
def shape(self): def get_shape(self):
return np.array([(self.paradict['nlat']*self.paradict['nlon'])], dtype=np.int) return np.array([(self.paradict['nlat']*self.paradict['nlon'])], dtype=np.int)
def dim(self,split=False): def get_dim(self,split=False):
""" """
Computes the dimension of the space, i.e.\ the number of pixels. Computes the dimension of the space, i.e.\ the number of pixels.
...@@ -1102,15 +1109,15 @@ class gl_space(point_space): ...@@ -1102,15 +1109,15 @@ class gl_space(point_space):
""" """
## dim = nlat*nlon ## dim = nlat*nlon
if(split): if(split):
return self.shape() return self.get_shape()
#return np.array([self.para[0]*self.para[1]],dtype=np.int) #return np.array([self.para[0]*self.para[1]],dtype=np.int)
else: else:
return np.prod(self.shape()) return np.prod(self.get_shape())
#return self.para[0]*self.para[1] #return self.para[0]*self.para[1]
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def dof(self): def get_dof(self):
""" """
Computes the number of degrees of freedom of the space. Computes the number of degrees of freedom of the space.
...@@ -1236,13 +1243,13 @@ class gl_space(point_space): ...@@ -1236,13 +1243,13 @@ class gl_space(point_space):
arg = random.parse_arguments(self,**kwargs) arg = random.parse_arguments(self,**kwargs)
if(arg is None): if(arg is None):
x = np.zeros(self.dim(split=True),dtype=self.datatype,order='C') x = np.zeros(self.get_dim(split=True),dtype=self.datatype,order='C')
elif(arg[0]=="pm1"): elif(arg[0]=="pm1"):
x = random.pm1(datatype=self.datatype,shape=self.dim(split=True)) x = random.pm1(datatype=self.datatype,shape=self.get_dim(split=True))
elif(arg[0]=="gau"): elif(arg[0]=="gau"):
x = random.gau(datatype=self.datatype,shape=self.dim(split=True),mean=None,dev=arg[2],var=arg[3]) x = random.gau(datatype=self.datatype,shape=self.get_dim(split=True),mean=None,dev=arg[2],var=arg[3])
elif(arg[0]=="syn"): elif(arg[0]=="syn"):
lmax = self.para[0]-1 ## nlat-1 lmax = self.para[0]-1 ## nlat-1
...@@ -1255,7 +1262,7 @@ class gl_space(point_space): ...@@ -1255,7 +1262,7 @@ class gl_space(point_space):
x = self.calc_weight(x,power=0.5) x = self.calc_weight(x,power=0.5)
elif(arg[0]=="uni"): elif(arg[0]=="uni"):
x = random.uni(datatype=self.datatype,shape=self.dim(split=True),vmin=arg[1],vmax=arg[2]) x = random.uni(datatype=self.datatype,shape=self.get_dim(split=True),vmin=arg[1],vmax=arg[2])
else: else:
raise KeyError(about._errors.cstring("ERROR: unsupported random key '"+str(arg[0])+"'.")) raise KeyError(about._errors.cstring("ERROR: unsupported random key '"+str(arg[0])+"'."))
...@@ -1345,7 +1352,7 @@ class gl_space(point_space): ...@@ -1345,7 +1352,7 @@ class gl_space(point_space):
if(total): if(total):
return self.datatype(4*pi) return self.datatype(4*pi)
else: else:
mol = np.ones(self.dim(split=True),dtype=self.datatype,order='C') mol = np.ones(self.get_dim(split=True),dtype=self.datatype,order='C')
return self.calc_weight(mol,power=1) return self.calc_weight(mol,power=1)
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...@@ -1689,7 +1696,7 @@ class hp_space(point_space): ...@@ -1689,7 +1696,7 @@ class hp_space(point_space):
""" """
niter = 0 ## default number of iterations used for transformations niter = 0 ## default number of iterations used for transformations
def __init__(self,nside): def __init__(self, nside):
""" """
Sets the attributes for a hp_space class instance. Sets the attributes for a hp_space class instance.
...@@ -1734,6 +1741,9 @@ class hp_space(point_space): ...@@ -1734,6 +1741,9 @@ class hp_space(point_space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def copy(self):
return hp_space(nside = self.paradict['nside'])
def nside(self): def nside(self):
""" """
Returns the resolution parameter. Returns the resolution parameter.
...@@ -1745,10 +1755,10 @@ class hp_space(point_space): ...@@ -1745,10 +1755,10 @@ class hp_space(point_space):
""" """
return self.paradict['nside'] return self.paradict['nside']
def shape(self): def get_shape(self):
return np.array([12*self.paradict['nside']**2], dtype=np.int) return np.array([12*self.paradict['nside']**2], dtype=np.int)
def dim(self,split=False): def get_dim(self,split=False):
""" """
Computes the dimension of the space, i.e.\ the number of pixels. Computes the dimension of the space, i.e.\ the number of pixels.
...@@ -1765,15 +1775,15 @@ class hp_space(point_space): ...@@ -1765,15 +1775,15 @@ class hp_space(point_space):
""" """
## dim = 12*nside**2 ## dim = 12*nside**2
if(split): if(split):
return self.shape() return self.get_shape()
#return np.array([12*self.para[0]**2],dtype=np.int) #return np.array([12*self.para[0]**2],dtype=np.int)
else: else:
return np.prod(self.shape()) return np.prod(self.get_shape())
#return 12*self.para[0]**2 #return 12*self.para[0]**2
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def dof(self): def get_dof(self):
""" """
Computes the number of degrees of freedom of the space. Computes the number of degrees of freedom of the space.
...@@ -1899,13 +1909,13 @@ class hp_space(point_space): ...@@ -1899,13 +1909,13 @@ class hp_space(point_space):
arg = random.parse_arguments(self,**kwargs) arg = random.parse_arguments(self,**kwargs)
if(arg is None): if(arg is None):
x = np.zeros(self.dim(split=True),dtype=self.datatype,order='C') x = np.zeros(self.get_dim(split=True),dtype=self.datatype,order='C')
elif(arg[0]=="pm1"): elif(arg[0]=="pm1"):
x = random.pm1(datatype=self.datatype,shape=self.dim(split=True)) x = random.pm1(datatype=self.datatype,shape=self.get_dim(split=True))
elif(arg[0]=="gau"): elif(arg[0]=="gau"):
x = random.gau(datatype=self.datatype,shape=self.dim(split=True),mean=None,dev=arg[2],var=arg[3]) x = random.gau(datatype=self.datatype,shape=self.get_dim(split=True),mean=None,dev=arg[2],var=arg[3])
elif(arg[0]=="syn"): elif(arg[0]=="syn"):
lmax = 3*self.para[0]-1 ## 3*nside-1 lmax = 3*self.para[0]-1 ## 3*nside-1
...@@ -1915,7 +1925,7 @@ class hp_space(point_space): ...@@ -1915,7 +1925,7 @@ class hp_space(point_space):
x = self.calc_weight(x,power=0.5) x = self.calc_weight(x,power=0.5)
elif(arg[0]=="uni"): elif(arg[0]=="uni"):
x = random.uni(datatype=self.datatype,shape=self.dim(split=True),vmin=arg[1],vmax=arg[2]) x = random.uni(datatype=self.datatype,shape=self.get_dim(split=True),vmin=arg[1],vmax=arg[2])
else: else:
raise KeyError(about._errors.cstring("ERROR: unsupported random key '"+str(arg[0])+"'.")) raise KeyError(about._errors.cstring("ERROR: unsupported random key '"+str(arg[0])+"'."))
...@@ -2001,7 +2011,7 @@ class hp_space(point_space): ...@@ -2001,7 +2011,7 @@ class hp_space(point_space):
if(total): if(total):
return self.datatype(4*pi) return self.datatype(4*pi)
else: else:
mol = np.ones(self.dim(split=True),dtype=self.datatype,order='C') mol = np.ones(self.get_dim(split=True),dtype=self.datatype,order='C')
return self.calc_weight(mol,power=1) return self.calc_weight(mol,power=1)
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......
This diff is collapsed.
This diff is collapsed.
...@@ -236,7 +236,7 @@ class random(object): ...@@ -236,7 +236,7 @@ class random(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@staticmethod @staticmethod
def pm1(datatype=np.int,shape=1): def pm1(datatype=np.int, shape=1):
""" """
Generates random field values according to an uniform distribution Generates random field values according to an uniform distribution
over {+1,-1} or {+1,+i,-1,-i}, respectively. over {+1,-1} or {+1,+i,-1,-i}, respectively.
...@@ -266,7 +266,7 @@ class random(object): ...@@ -266,7 +266,7 @@ class random(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@staticmethod @staticmethod
def gau(datatype=np.float64,shape=1,mean=None,dev=None,var=None): def gau(datatype=np.float64, shape=1, mean=None, dev=None, var=None):
""" """
Generates random field values according to a normal distribution. Generates random field values according to a normal distribution.
......
...@@ -489,6 +489,10 @@ def direct_dot(x, y): ...@@ -489,6 +489,10 @@ def direct_dot(x, y):
x = x.get_val() x = x.get_val()
except(AttributeError): except(AttributeError):
pass pass
try:
y = y.get_val()
except(AttributeError):
pass
## try to make a direct vdot ## try to make a direct vdot
try: try:
return x.vdot(y) return x.vdot(y)
......
...@@ -209,7 +209,7 @@ class operator(object): ...@@ -209,7 +209,7 @@ class operator(object):
nrow : int nrow : int
number of rows (equal to the dimension of the codomain) number of rows (equal to the dimension of the codomain)
""" """
return self.target.dim(split=False) return self.target.get_dim(split=False)
def ncol(self): def ncol(self):
""" """
...@@ -220,7 +220,7 @@ class operator(object): ...@@ -220,7 +220,7 @@ class operator(object):
ncol : int ncol : int
number of columns (equal to the dimension of the domain) number of columns (equal to the dimension of the domain)
""" """
return self.domain.dim(split=False) return self.domain.get_dim(split=False)
def dim(self, axis=None): def dim(self, axis=None):
""" """
...@@ -1455,9 +1455,9 @@ class diagonal_operator(operator): ...@@ -1455,9 +1455,9 @@ class diagonal_operator(operator):
""" """
if(domain is None)or(domain==self.domain): if(domain is None)or(domain==self.domain):
if(self.uni): ## identity if(self.uni): ## identity
return (self.domain.datatype(self.domain.dof())).real return (self.domain.datatype(self.domain.get_dof())).real
elif(self.domain.dim(split=False)<self.domain.dof()): ## hidden degrees of freedom elif(self.domain.get_dim(split=False)<self.domain.get_dof()): ## hidden degrees of freedom
return self.domain.calc_dot(np.ones(self.domain.dim(split=True),dtype=self.domain.datatype,order='C'),self.val) ## discrete inner product return self.domain.calc_dot(np.ones(self.domain.get_dim(split=True),dtype=self.domain.datatype,order='C'),self.val) ## discrete inner product
else: else:
return np.sum(self.val,axis=None,dtype=None,out=None) return np.sum(self.val,axis=None,dtype=None,out=None)
else: else:
...@@ -1465,9 +1465,9 @@ class diagonal_operator(operator): ...@@ -1465,9 +1465,9 @@ class diagonal_operator(operator):
if(not isinstance(domain,space)): if(not isinstance(domain,space)):
raise TypeError(about._errors.cstring("ERROR: invalid input.")) raise TypeError(about._errors.cstring("ERROR: invalid input."))
## check degrees of freedom ## check degrees of freedom
if(self.domain.dof()>domain.dof()): if(self.domain.get_dof()>domain.get_dof()):
about.infos.cprint("INFO: variant numbers of degrees of freedom ( "+str(self.domain.dof())+" / "+str(domain.dof())+" ).") about.infos.cprint("INFO: variant numbers of degrees of freedom ( "+str(self.domain.get_dof())+" / "+str(domain.get_dof())+" ).")
return (domain.datatype(domain.dof())).real return (domain.datatype(domain.get_dof())).real
else: else:
return super(diagonal_operator,self).tr(domain=domain,**kwargs) ## probing return super(diagonal_operator,self).tr(domain=domain,**kwargs) ## probing
...@@ -1529,9 +1529,9 @@ class diagonal_operator(operator): ...@@ -1529,9 +1529,9 @@ class diagonal_operator(operator):
if(domain is None)or(domain==self.target): if(domain is None)or(domain==self.target):
if(self.uni): ## identity if(self.uni): ## identity
return np.real(self.domain.datatype(self.domain.dof())) return np.real(self.domain.datatype(self.domain.get_dof()))
elif(self.domain.dim(split=False)<self.domain.dof()): ## hidden degrees of freedom elif(self.domain.get_dim(split=False)<self.domain.get_dof()): ## hidden degrees of freedom
return self.domain.calc_dot(np.ones(self.domain.dim(split=True),dtype=self.domain.datatype,order='C'),1/self.val) ## discrete inner product return self.domain.calc_dot(np.ones(self.domain.get_dim(split=True),dtype=self.domain.datatype,order='C'),1/self.val) ## discrete inner product
else: else:
return np.sum(1./self.val,axis=None,dtype=None,out=None) return np.sum(1./self.val,axis=None,dtype=None,out=None)
else: else:
...@@ -1539,9 +1539,9 @@ class diagonal_operator(operator): ...@@ -1539,9 +1539,9 @@ class diagonal_operator(operator):
if(not isinstance(domain,space)): if(not isinstance(domain,space)):
raise TypeError(about._errors.cstring("ERROR: invalid input.")) raise TypeError(about._errors.cstring("ERROR: invalid input."))
## check degrees of freedom ## check degrees of freedom
if(self.domain.dof()>domain.dof()): if(self.domain.get_dof()>domain.get_dof()):
about.infos.cprint("INFO: variant numbers of degrees of freedom ( "+str(self.domain.dof())+" / "+str(domain.dof())+" ).") about.infos.cprint("INFO: variant numbers of degrees of freedom ( "+str(self.domain.get_dof())+" / "+str(domain.get_dof())+" ).")
return np.real(domain.datatype(domain.dof())) return np.real(domain.datatype(domain.get_dof()))
else: else:
return super(diagonal_operator,self).inverse_tr(domain=domain,**kwargs) ## probing return super(diagonal_operator,self).inverse_tr(domain=domain,**kwargs) ## probing
""" """
...@@ -1776,8 +1776,8 @@ class diagonal_operator(operator): ...@@ -1776,8 +1776,8 @@ class diagonal_operator(operator):
return 1. return 1.
else: else:
return self.domain.unary_operation(self.val, op='prod') return self.domain.unary_operation(self.val, op='prod')
#elif(self.domain.dim(split=False)<self.domain.dof()): ## hidden degrees of freedom #elif(self.domain.get_dim(split=False)<self.domain.get_dof()): ## hidden degrees of freedom
# return np.exp(self.domain.calc_dot(np.ones(self.domain.dim(split=True),dtype=self.domain.datatype,order='C'),np.log(self.val))) # return np.exp(self.domain.calc_dot(np.ones(self.domain.get_dim(split=True),dtype=self.domain.datatype,order='C'),np.log(self.val)))
#else: #else:
# return np.prod(self.val,axis=None,dtype=None,out=None) # return np.prod(self.val,axis=None,dtype=None,out=None)
...@@ -1813,8 +1813,8 @@ class diagonal_operator(operator): ...@@ -1813,8 +1813,8 @@ class diagonal_operator(operator):
""" """
if self.uni == True: ## identity if self.uni == True: ## identity
return 0 return 0
#elif(self.domain.dim(split=False)<self.domain.dof()): ## hidden degrees of freedom #elif(self.domain.get_dim(split=False)<self.domain.get_dof()): ## hidden degrees of freedom
# return self.domain.calc_dot(np.ones(self.domain.dim(split=True),dtype=self.domain.datatype,order='C'),np.log(self.val)) # return self.domain.calc_dot(np.ones(self.domain.get_dim(split=True),dtype=self.domain.datatype,order='C'),np.log(self.val))
else: else:
return self.domain.unary_operation( return self.domain.unary_operation(
nifty_simple_math.log(self.val), op='sum')