poly returned a complex polynom instead to real polynom. 76/16876/3
Adeline CARNIS [Wed, 22 Jul 2015 13:09:44 +0000 (15:09 +0200)]
Change-Id: I90b8b775266d033c7718bc453b1c05284a13817c

scilab/modules/polynomials/sci_gateway/cpp/sci_poly.cpp

index d08e3c2..1f113ed 100644 (file)
@@ -134,7 +134,6 @@ types::Function::ReturnValue sci_poly(types::typed_list &in, int _iRetCount, typ
         int iRanks = iSize;
         pPolyOut = new types::Polynom(wstrName, 2, piDimsArray, &iRanks);
         double* pdblCoefReal = pPolyOut->get(0)->get();
-
         if (pDblIn->isComplex())
         {
             double dblEps = (double)C2F(dlamch)("p", 1L);
@@ -142,11 +141,16 @@ types::Function::ReturnValue sci_poly(types::typed_list &in, int _iRetCount, typ
             double* pdblInImg   = pDblIn->getImg();
             double* pdblCoefImg = pPolyOut->get(0)->getImg();
             C2F(wprxc)(&iRanks, pdblInReal, pdblInImg, pdblCoefReal, pdblCoefImg);
-            // if imaginary part is null, set polynom real
-            if (C2F(dasum)(&iSize, pdblCoefImg, &iOne) <= dblEps)
+            bool bSetCplx = false;
+            for (int k = 0; k < iRanks; k++)
             {
-                pPolyOut->setComplex(false);
+                if ((pdblCoefReal[k] + pdblCoefImg[k]) != pdblCoefReal[k])
+                {
+                    bSetCplx = true;
+                    break;
+                }
             }
+            pPolyOut->setComplex(bSetCplx);
         }
         else
         {