* Bug 16118 fixed: now %s <> 1+%s returns %t 14/21014/3
St├ęphane MOTTELET [Wed, 19 Jun 2019 12:58:33 +0000 (14:58 +0200)]
http://bugzilla.scilab.org/show_bug.cgi?id=16118

Change-Id: Id58c6e33513584572a6642a97b03f381eab4b4f5

scilab/CHANGES.md
scilab/modules/ast/src/cpp/operations/types_comparison_eq.cpp
scilab/modules/ast/src/cpp/operations/types_comparison_ne.cpp
scilab/modules/ast/tests/nonreg_tests/bug_16118.tst [new file with mode: 0644]

index 6f55800..bee5907 100644 (file)
@@ -184,6 +184,7 @@ Bug Fixes
 * [#16085](http://bugzilla.scilab.org/show_bug.cgi?id=16085): insertion in an empty struct was broken.
 * [#16087](http://bugzilla.scilab.org/show_bug.cgi?id=16087): Insertion of struct() in a non-empty struct crashed Scilab.
 * [#16111](http://bugzilla.scilab.org/show_bug.cgi?id=16111): `isglobal` was not supporting non-scalar array of strings as input.
+* [#16118](http://bugzilla.scilab.org/show_bug.cgi?id=16118): `%s <> (1+%s)` returned %F.
 * [#16144](http://bugzilla.scilab.org/show_bug.cgi?id=16144): Addition of sparse matrices gave incorrect results.
 * [#16174](http://bugzilla.scilab.org/show_bug.cgi?id=16174): `libraryinfo` yielded 0x0 matrix of strings for libs without macro
 * [#16208](http://bugzilla.scilab.org/show_bug.cgi?id=16208): Using 3D string matrix with old C-api gateways may crash Scilab.
index 1d0eb51..62397b7 100644 (file)
@@ -2950,10 +2950,6 @@ template<>
 InternalType* compequal_M_M<Polynom, Polynom, Bool>(Polynom* _pL, Polynom* _pR)
 {
     Bool* pbOut = NULL;
-    bool bPoise = true;
-
-    SinglePoly** pSPL = _pL->get();
-    SinglePoly** pSPR = _pR->get();
 
     if (_pL->getVariableName() != _pR->getVariableName())
     {
@@ -2964,182 +2960,18 @@ InternalType* compequal_M_M<Polynom, Polynom, Bool>(Polynom* _pL, Polynom* _pR)
     {
         pbOut = new Bool(_pL->getDims(), _pL->getDimsArray());
         int iSize = pbOut->getSize();
-
-        if (_pL->isComplex())
+        for (int i = 0; i < iSize; i++)
         {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[0]->get(j), pSPR[0]->getImg(j), pSPL[i]->get(j), pSPL[i]->getImg(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[0]->get(j), (double)0, pSPL[i]->get(j), pSPL[i]->getImg(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-        }
-        else
-        {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[0]->get(j), pSPR[0]->getImg(j), pSPL[i]->get(j), (double)0, &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[0]->get(j), pSPL[i]->get(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
+            pbOut->set(i, *(_pL->get(i)) == *( _pR->get(0)));
         }
     }
     else if (_pL->isScalar())
     {
         pbOut = new Bool(_pR->getDims(), _pR->getDimsArray());
         int iSize = pbOut->getSize();
-
-        if (pSPR[0]->getSize() != 1)
+        for (int i = 0; i < iSize; i++)
         {
-            if (_pL->isComplex())
-            {
-                if (_pR->isComplex())
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = false;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                            {
-                                compequal(pSPL[0]->get(j), pSPL[0]->getImg(j), pSPR[i]->get(j), pSPR[i]->getImg(j), &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-                else
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = false;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                            {
-                                compequal(pSPL[0]->get(j), pSPL[0]->getImg(j), pSPR[i]->get(j), (double)0, &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-            }
-            else
-            {
-
-                if (_pR->isComplex())
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = false;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                            {
-                                compequal(pSPL[0]->get(j), (double)0, pSPR[i]->get(j), pSPR[i]->get(j), &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-                else
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = false;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                            {
-                                compequal(pSPL[0]->get(j), pSPR[i]->get(j), &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-
-            }
+            pbOut->set(i, *(_pL->get(0)) == *(_pR->get(i)));
         }
     }
     else
@@ -3160,88 +2992,9 @@ InternalType* compequal_M_M<Polynom, Polynom, Bool>(Polynom* _pL, Polynom* _pR)
 
         pbOut = new Bool(_pL->getDims(), _pL->getDimsArray());
         int iSize = pbOut->getSize();
-
-        if (_pL->isComplex())
-        {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[i]->get(j), pSPR[i]->getImg(j), pSPL[i]->get(j), pSPL[i]->getImg(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPL[i]->get(j), pSPL[i]->getImg(j), pSPR[i]->get(j), (double)0, &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-        }
-        else
+        for (int i = 0; i < iSize; i++)
         {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[i]->get(j), pSPR[i]->getImg(j), pSPL[i]->get(j), (double)0, &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = false;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compequal(pSPR[i]->get(j), pSPL[i]->get(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
+            pbOut->set(i, *(_pL->get(i)) == *(_pR->get(i)));
         }
     }
 
index 38e5b70..97ee9ce 100644 (file)
@@ -2956,10 +2956,6 @@ template<>
 InternalType* compnoequal_M_M<Polynom, Polynom, Bool>(Polynom* _pL, Polynom* _pR)
 {
     Bool* pbOut = NULL;
-    bool bPoise = true;
-
-    SinglePoly** pSPL = _pL->get();
-    SinglePoly** pSPR = _pR->get();
 
     if (_pL->getVariableName() != _pR->getVariableName())
     {
@@ -2970,182 +2966,18 @@ InternalType* compnoequal_M_M<Polynom, Polynom, Bool>(Polynom* _pL, Polynom* _pR
     {
         pbOut = new Bool(_pL->getDims(), _pL->getDimsArray());
         int iSize = pbOut->getSize();
-
-        if (_pL->isComplex())
+        for (int i = 0; i < iSize; i++)
         {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[0]->get(j), pSPR[0]->getImg(j), pSPL[i]->get(j), pSPL[i]->getImg(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[0]->get(j), (double)0, pSPL[i]->get(j), pSPL[i]->getImg(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-        }
-        else
-        {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[0]->get(j), pSPR[0]->getImg(j), pSPL[i]->get(j), (double)0, &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[0]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[0]->get(j), pSPL[i]->get(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
+            pbOut->set(i, *(_pL->get(i)) != *( _pR->get(0)));
         }
     }
     else if (_pL->isScalar())
     {
         pbOut = new Bool(_pR->getDims(), _pR->getDimsArray());
         int iSize = pbOut->getSize();
-
-        if (pSPR[0]->getSize() != 1)
+        for (int i = 0; i < iSize; i++)
         {
-            if (_pL->isComplex())
-            {
-                if (_pR->isComplex())
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = true;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                            {
-                                compnoequal(pSPL[0]->get(j), pSPL[0]->getImg(j), pSPR[i]->get(j), pSPR[i]->getImg(j), &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-                else
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = true;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                            {
-                                compnoequal(pSPL[0]->get(j), pSPL[0]->getImg(j), pSPR[i]->get(j), (double)0, &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-            }
-            else
-            {
-
-                if (_pR->isComplex())
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = true;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPL[0]->getSize() && (bPoise == true); j++)
-                            {
-                                compnoequal(pSPL[0]->get(j), (double)0, pSPR[i]->get(j), pSPR[i]->get(j), &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-                else
-                {
-                    for (int i = 0; i < iSize; i++)
-                    {
-                        if (pSPL[0]->getSize() != pSPR[i]->getSize())
-                        {
-                            bPoise = true;
-                        }
-                        else
-                        {
-                            bPoise = true;
-                            for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                            {
-                                compnoequal(pSPL[0]->get(j), pSPR[i]->get(j), &bPoise);
-                            }
-                        }
-                        pbOut->set(i, bPoise);
-                    }
-                }
-
-            }
+            pbOut->set(i, *(_pL->get(0)) != *(_pR->get(i)));
         }
     }
     else
@@ -3166,88 +2998,9 @@ InternalType* compnoequal_M_M<Polynom, Polynom, Bool>(Polynom* _pL, Polynom* _pR
 
         pbOut = new Bool(_pL->getDims(), _pL->getDimsArray());
         int iSize = pbOut->getSize();
-
-        if (_pL->isComplex())
-        {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[i]->get(j), pSPR[i]->getImg(j), pSPL[i]->get(j), pSPL[i]->getImg(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPL[i]->get(j), pSPL[i]->getImg(j), pSPR[i]->get(j), (double)0, &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-        }
-        else
+        for (int i = 0; i < iSize; i++)
         {
-            if (_pR->isComplex())
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[i]->get(j), pSPR[i]->getImg(j), pSPL[i]->get(j), (double)0, &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < iSize; i++)
-                {
-                    if (pSPL[i]->getSize() != pSPR[i]->getSize())
-                    {
-                        bPoise = true;
-                    }
-                    else
-                    {
-                        bPoise = true;
-                        for (int j = 0; j < pSPR[i]->getSize() && (bPoise == true); j++)
-                        {
-                            compnoequal(pSPR[i]->get(j), pSPL[i]->get(j), &bPoise);
-                        }
-                    }
-                    pbOut->set(i, bPoise);
-                }
-            }
+            pbOut->set(i, *(_pL->get(i)) != *(_pR->get(i)));
         }
     }
 
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_16118.tst b/scilab/modules/ast/tests/nonreg_tests/bug_16118.tst
new file mode 100644 (file)
index 0000000..e74cb64
--- /dev/null
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - St├ęphane MOTTELET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 16118 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16118
+//
+// <-- Short Description -->
+// polynomials: %z <> (1+%z) returns %F (same with ~=) (6.0.0 regression)
+
+assert_checkequal(%s <> 1+%s, %t)
+assert_checkequal(%s <> [1+%s, %s], [%t, %f])
+assert_checkequal(1+%s <> %s, %t)
+assert_checkequal([1+%s, %s] <> %s, [%t, %f])
+
+assert_checkequal([%s, 1+%s] <> [1+%s, %s], [%t, %t])
+assert_checkequal([1+%s, 1+%s] <> [1+%s, %s], [%f, %t])
+assert_checkequal([1+%s, %s] <> [1+%s, %s], [%f, %f])
+