substraction of identity to complex matrix corrected. 33/11433/1
Cedric Delamarre [Thu, 2 May 2013 09:01:17 +0000 (11:01 +0200)]
a=6*ones(3,3)+4*%i;
a-6*eye()
6*eye()-a

Change-Id: Ie0b935d0105cbf6fd09ec53140cc45b34685442d

scilab/modules/operations/src/cpp/types_substraction.cpp

index 1044b00..31879cf 100644 (file)
@@ -394,9 +394,21 @@ int SubstractDoubleToDouble(Double* _pDouble1, Double* _pDouble2, Double** _pDou
 
         //return opposite
         double* pDbl = (*_pDoubleOut)->get();
-        for (int i = 0 ; i < _pDouble2->getSize() ; i++)
+        if ((*_pDoubleOut)->isComplex())
         {
-            pDbl[i] = -pDbl[i];
+            double* pDblImg = (*_pDoubleOut)->getImg();
+            for (int i = 0 ; i < _pDouble2->getSize() ; i++)
+            {
+                pDbl[i] = -pDbl[i];
+                pDblImg[i] = -pDblImg[i];
+            }
+        }
+        else
+        {
+            for (int i = 0 ; i < _pDouble2->getSize() ; i++)
+            {
+                pDbl[i] = -pDbl[i];
+            }
         }
         return 0;
     }