# Calcul de la matrice de gain et de l'analyse
# --------------------------------------------
if Y.size <= Xb.size:
- _A = R + Hm * B * Ha
+ _A = R + numpy.dot(Hm, B * Ha)
_u = numpy.linalg.solve( _A , d )
Xa = Xb + B * Ha * _u
else:
- _A = BI + Ha * RI * Hm
- _u = numpy.linalg.solve( _A , Ha * RI * d )
+ _A = BI + numpy.dot(Ha, RI * Hm)
+ _u = numpy.linalg.solve( _A , numpy.dot(Ha, RI * d) )
Xa = Xb + _u
self.StoredVariables["Analysis"].store( Xa.A1 )
#
# Calcul de la covariance d'analyse
# ---------------------------------
if self._toStore("APosterioriCovariance") or \
- self._toStore("SimulationQuantiles"):
- if (Y.size <= Xb.size): K = B * Ha * (R + Hm * B * Ha).I
- elif (Y.size > Xb.size): K = (BI + Ha * RI * Hm).I * Ha * RI
+ self._toStore("SimulationQuantiles"):
+ if (Y.size <= Xb.size): K = B * Ha * (R + numpy.dot(Hm, B * Ha)).I
+ elif (Y.size > Xb.size): K = (BI + numpy.dot(Ha, RI * Hm)).I * Ha * RI
A = B - K * Hm * B
if min(A.shape) != max(A.shape):
raise ValueError("The %s a posteriori covariance matrix A is of shape %s, despites it has to be a squared matrix. There is an error in the observation operator, please check it."%(self._name,str(A.shape)))
# Calcul de la matrice de gain et de l'analyse
# --------------------------------------------
if Y.size <= Xb.size:
- _A = R + Hm * B * Ha
+ _A = R + numpy.dot(Hm, B * Ha)
_u = numpy.linalg.solve( _A , d )
Xa = Xb + B * Ha * _u
else:
- _A = BI + Ha * RI * Hm
- _u = numpy.linalg.solve( _A , Ha * RI * d )
+ _A = BI + numpy.dot(Ha, RI * Hm)
+ _u = numpy.linalg.solve( _A , numpy.dot(Ha, RI * d) )
Xa = Xb + _u
self.StoredVariables["Analysis"].store( Xa.A1 )
#
# ---------------------------------
if self._toStore("APosterioriCovariance") or \
self._toStore("SimulationQuantiles"):
- if (Y.size <= Xb.size): K = B * Ha * (R + Hm * B * Ha).I
- elif (Y.size > Xb.size): K = (BI + Ha * RI * Hm).I * Ha * RI
+ if (Y.size <= Xb.size): K = B * Ha * (R + numpy.dot(Hm, B * Ha)).I
+ elif (Y.size > Xb.size): K = (BI + numpy.dot(Ha, RI * Hm)).I * Ha * RI
A = B - K * Hm * B
if min(A.shape) != max(A.shape):
raise ValueError("The %s a posteriori covariance matrix A is of shape %s, despites it has to be a squared matrix. There is an error in the observation operator, please check it."%(self._name,str(A.shape)))
self.__NbCallsAsMatrix += 1 # Decompte local
Operator.NbCallsAsMatrix += 1 # Decompte global
- def __addOneMethodCall(self):
+ def __addOneMethodCall(self, nb = 1):
"Comptabilise un appel"
- self.__NbCallsAsMethod += 1 # Decompte local
- Operator.NbCallsAsMethod += 1 # Decompte global
+ self.__NbCallsAsMethod += nb # Decompte local
+ Operator.NbCallsAsMethod += nb # Decompte global
def __addOneCacheCall(self):
"Comptabilise un appel"
def __init__(self,
name = "GenericFullOperator",
asMatrix = None,
- asOneFunction = None, # Fonction
- asThreeFunctions = None, # Fonctions dictionary
- asScript = None, # Fonction(s) script
+ asOneFunction = None, # 1 Fonction
+ asThreeFunctions = None, # 3 Fonctions in a dictionary
+ asScript = None, # 1 or 3 Fonction(s) by script
asDict = None, # Parameters
appliedInX = None,
avoidRC = True,
"x.__rmul__(y) <==> y*x"
if self.ismatrix() and isinstance(other, (int, numpy.matrix, float)):
return other * self.__C
+ elif self.ismatrix() and isinstance(other, (list, numpy.ndarray, tuple)):
+ if numpy.ravel(other).size == self.shape[1]: # Vecteur
+ return numpy.asmatrix(numpy.ravel(other)) * self.__C
+ elif numpy.asmatrix(other).shape[0] == self.shape[1]: # Matrice
+ return numpy.asmatrix(other) * self.__C
+ else:
+ raise ValueError("operands could not be broadcast together with shapes %s %s in %s matrix"%(numpy.asmatrix(other).shape,self.shape,self.__name))
elif self.isvector() and isinstance(other,numpy.matrix):
if numpy.ravel(other).size == self.shape[0]: # Vecteur
return numpy.asmatrix(numpy.ravel(other) * self.__C)
for k in __keys:
__v = __local[k]
if __v is None: continue
- if k == "Checked" and not __v: continue
- if k == "Stored" and not __v: continue
- if k == "ColMajor" and not __v: continue
- if k == "AvoidRC" and __v: continue
- if k == "noDetails": continue
+ if k == "Checked" and not __v: continue
+ if k == "Stored" and not __v: continue
+ if k == "ColMajor" and not __v: continue
if k == "InputAsMF" and not __v: continue
+ if k == "AvoidRC" and __v: continue
+ if k == "noDetails": continue
if isinstance(__v,Persistence.Persistence): __v = __v.values()
if callable(__v): __text = self._missing%__v.__name__+__text
if isinstance(__v,dict):