]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Adding multi-functions input capabilities (6)
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Tue, 1 Jan 2019 17:39:31 +0000 (18:39 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Tue, 1 Jan 2019 17:39:31 +0000 (18:39 +0100)
src/daComposant/daAlgorithms/Blue.py
src/daComposant/daAlgorithms/ExtendedBlue.py
src/daComposant/daCore/BasicObjects.py
src/daComposant/daCore/Interfaces.py

index b1ea9b9a0c1e287d11866e1c3ddfb05273dda865..93fa4e917e97f61beadfb6ea2f4c0225f7d25680 100644 (file)
@@ -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)))
index f609c092956bba427ec26a9d948dc8d9e58d6466..e80c39cb03a981b42fa8fd1961c9af19a6a914f2 100644 (file)
@@ -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)))
index 1f26d6e52f4d63ee986e8ccea3f0aa6931f28b38..4b596f23ac37086af8487941c2449c718aa16598 100644 (file)
@@ -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, # 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)
index 8e0deb05cafce352b3724afa0c7fe53fb8065ec0..faa1c2fa65c7eed2399a4b90cc66a750749863e5 100644 (file)
@@ -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):