From: Jean-Philippe ARGAUD Date: Tue, 1 Jan 2019 17:39:31 +0000 (+0100) Subject: Adding multi-functions input capabilities (6) X-Git-Tag: V9_3_0.1-prealpha1~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7bf69a5322576eda00a4d90fa54d1d60a65d0ea6;p=modules%2Fadao.git Adding multi-functions input capabilities (6) --- diff --git a/src/daComposant/daAlgorithms/Blue.py b/src/daComposant/daAlgorithms/Blue.py index b1ea9b9..93fa4e9 100644 --- a/src/daComposant/daAlgorithms/Blue.py +++ b/src/daComposant/daAlgorithms/Blue.py @@ -124,12 +124,12 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # 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 ) # @@ -158,9 +158,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # 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))) diff --git a/src/daComposant/daAlgorithms/ExtendedBlue.py b/src/daComposant/daAlgorithms/ExtendedBlue.py index f609c09..e80c39c 100644 --- a/src/daComposant/daAlgorithms/ExtendedBlue.py +++ b/src/daComposant/daAlgorithms/ExtendedBlue.py @@ -125,12 +125,12 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # 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 ) # @@ -160,8 +160,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # --------------------------------- 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))) diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 1f26d6e..4b596f2 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -337,10 +337,10 @@ class Operator(object): 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" @@ -356,9 +356,9 @@ class FullOperator(object): 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, @@ -1700,6 +1700,13 @@ class Covariance(object): "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) diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index 8e0deb0..faa1c2f 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -118,12 +118,12 @@ class _TUIViewer(GenericCaseViewer): 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):