* bug 9810 fixed - MATINV wrong simulation values errors has been improved. 86/4786/2
Clément DAVID [Tue, 30 Aug 2011 11:59:55 +0000 (13:59 +0200)]
Change-Id: Ie6cdec640918336e3ced9888caf1b199c99d0ec1

scilab/CHANGES_5.4.X
scilab/modules/scicos_blocks/src/c/mat_inv.c
scilab/modules/xcos/tests/nonreg_tests/bug_9810.dia.ref [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_9810.sce [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_9810.tst [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_9810.xcos [new file with mode: 0644]

index b1cd05d..64d403e 100644 (file)
@@ -75,6 +75,8 @@ Xcos:
 
 * bug 9590 fixed - xcos examples were not embeded in binary version on Windows.
 
+* bug 9810 fixed - MATINV wrong simulation values errors has been improved.
+
 
 File input/output:
 ==================
index 6b77b59..f79c7b0 100644 (file)
 *
 * See the file ./license.txt
 */
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #include <stdio.h>
-#include "machine.h" /* C2F */
+
+#include "machine.h"            /* C2F */
 #include "MALLOC.h"
+#include "localization.h"
+
 #include "scicos.h"
 #include "scicos_block4.h"
 #include "scicos_malloc.h"
 #include "scicos_free.h"
 #include "dynlib_scicos_blocks.h"
-/*--------------------------------------------------------------------------*/ 
-extern int C2F(dgetrf)();
-extern int C2F(dgetri)();
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
+extern int C2F(dgetrf) ();
+extern int C2F(dgetri) ();
+
+/*--------------------------------------------------------------------------*/
 typedef struct
-{         
-       int *ipiv;
-       double *dwork;
-} mat_inv_struct ;
-/*--------------------------------------------------------------------------*/ 
-SCICOS_BLOCKS_IMPEXP void mat_inv(scicos_block *block,int flag)
 {
- double *u = NULL;
- double *y = NULL;
- int nu = 0;
- int info = 0;
- int i = 0;
- mat_inv_struct *ptr = NULL;
- nu =GetInPortRows(block,1);
- u=GetRealInPortPtrs(block,1);
- y=GetRealOutPortPtrs(block,1);
+    int *ipiv;
+    double *dwork;
+} mat_inv_struct;
+
+/*--------------------------------------------------------------------------*/
+SCICOS_BLOCKS_IMPEXP void mat_inv(scicos_block * block, int flag)
+{
+    double *u = NULL;
+    double *y = NULL;
+    int nu = 0;
+    int info = 0;
+    int i = 0;
+    mat_inv_struct *ptr = NULL;
+
+    nu = GetInPortRows(block, 1);
+    u = GetRealInPortPtrs(block, 1);
+    y = GetRealOutPortPtrs(block, 1);
 
-             /*init : initialization*/
-if (flag==4)
-   {if((*(block->work)=(mat_inv_struct*) scicos_malloc(sizeof(mat_inv_struct)))==NULL)
-       {set_block_error(-16);
-        return;}
-    ptr=*(block->work);
-    if((ptr->ipiv=(int*) scicos_malloc(sizeof(int)*nu))==NULL)
-       {set_block_error(-16);
-        scicos_free(ptr);
-        return;}
-    if((ptr->dwork=(double*) scicos_malloc(sizeof(double)*nu))==NULL)
-       {set_block_error(-16);
-        scicos_free(ptr->ipiv);
-        scicos_free(ptr);
-        return;}
-   }
+    /*init : initialization */
+    if (flag == 4)
+    {
+        if ((*(block->work) = (mat_inv_struct *) scicos_malloc(sizeof(mat_inv_struct))) == NULL)
+        {
+            set_block_error(-16);
+            return;
+        }
+        ptr = *(block->work);
+        if ((ptr->ipiv = (int *)scicos_malloc(sizeof(int) * nu)) == NULL)
+        {
+            set_block_error(-16);
+            scicos_free(ptr);
+            return;
+        }
+        if ((ptr->dwork = (double *)scicos_malloc(sizeof(double) * nu)) == NULL)
+        {
+            set_block_error(-16);
+            scicos_free(ptr->ipiv);
+            scicos_free(ptr);
+            return;
+        }
+    }
 
-       /* Terminaison */
-else if (flag==5)
-   {ptr=*(block->work);
-    if ((ptr->dwork)!=NULL){
-       scicos_free(ptr->ipiv);
-       scicos_free(ptr->dwork);
-       scicos_free(ptr);
-       return;}
-   }
+    /* Terminaison */
+    else if (flag == 5)
+    {
+        ptr = *(block->work);
+        if ((ptr->dwork) != NULL)
+        {
+            scicos_free(ptr->ipiv);
+            scicos_free(ptr->dwork);
+            scicos_free(ptr);
+            return;
+        }
+    }
 
-else
-   {
-    ptr=*(block->work);
-    for (i=0;i<(nu*nu);i++)   { y[i]=u[i];}
-    C2F(dgetrf)(&nu,&nu,&y[0],&nu,ptr->ipiv,&info);
-    if (info !=0)
-       {if (flag!=6)
-       {set_block_error(-7);
-        return;}}
-    C2F (dgetri)(&nu,y,&nu,ptr->ipiv,ptr->dwork,&nu,&info);
-    
-   }
+    else
+    {
+        ptr = *(block->work);
+        for (i = 0; i < (nu * nu); i++)
+        {
+            y[i] = u[i];
+        }
+        C2F(dgetrf) (&nu, &nu, &y[0], &nu, ptr->ipiv, &info);
+        if (info != 0)
+        {
+            if (flag != 6)
+            {
+                Coserror(_("The LU factorization has been completed, but the factor U is exactly singular : U(%d,%d) is exactly zero."), info, info);
+                return;
+            }
+        }
+        C2F(dgetri) (&nu, y, &nu, ptr->ipiv, ptr->dwork, &nu, &info);
+
+    }
 }
-/*--------------------------------------------------------------------------*/ 
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_9810.dia.ref b/scilab/modules/xcos/tests/nonreg_tests/bug_9810.dia.ref
new file mode 100644 (file)
index 0000000..b02a6c3
--- /dev/null
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH XCOS -->
+//
+// <-- Non-regression test for bug 9810 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9810
+//
+// <-- Short Description -->
+// Matrix inversion error message update
+exec(SCI + "/modules/xcos/tests/nonreg_tests/bug_9810.sce");
+status = importXcosDiagram(SCI + "/modules/xcos/tests/nonreg_tests/bug_9810.xcos");
+if ~status then bugmes();quit;end
+// compile and simulate
+xcos_simulate(scs_m, 4);
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_9810.sce b/scilab/modules/xcos/tests/nonreg_tests/bug_9810.sce
new file mode 100644 (file)
index 0000000..b9695dd
--- /dev/null
@@ -0,0 +1,60 @@
+//Declaration des matrices                                             \r
+A1     =       -24.00  ;//     A1              \r
+A2     =       -45.00  ;//     A2              \r
+A3     =       47.00   ;//     A3              \r
+A4     =       -36.00  ;//     A4              \r
+A5     =       36.00   ;//     A5              \r
+A6     =       48.00   ;//     A6              \r
+A7     =       -18.00  ;//     A7      Somme   8.00\r
+B1     =       -42.00  ;//     B1              \r
+B2     =       3.00    ;//     B2              \r
+B3     =       -36.00  ;//     B3              \r
+B4     =       -38.00  ;//     B4              \r
+B5     =       49.00   ;//     B5              \r
+B6     =       -16.00  ;//     B6              \r
+B7     =       -21.00  ;//     B7      Somme   -101.00\r
+C1     =       -40.00  ;//     C1              \r
+C2     =       -9.00   ;//     C2              \r
+C3     =       31.00   ;//     C3              \r
+C4     =       15.00   ;//     C4              \r
+C5     =       19.00   ;//     C5              \r
+C6     =       45.00   ;//     C6              \r
+C7     =       -9.00   ;//     C7      Somme   52.00\r
+D1     =       30.00   ;//     D1              \r
+D2     =       -5.00   ;//     D2              \r
+D3     =       13.00   ;//     D3              \r
+D4     =       38.00   ;//     D4              \r
+D5     =       23.00   ;//     D5              \r
+D6     =       5.00    ;//     D6              \r
+D7     =       30.00   ;//     D7      Somme   134.00\r
+E1     =       -6.00   ;//     E1              \r
+E2     =       1.00    ;//     E2              \r
+E3     =       -49.00  ;//     E3              \r
+E4     =       -11.00  ;//     E4              \r
+E5     =       1.00    ;//     E5              \r
+E6     =       25.00   ;//     E6              \r
+E7     =       39.00   ;//     E7      Somme   0.00\r
+F1     =       -49.00  ;//     F1              \r
+F2     =       1.00    ;//     F2              \r
+F3     =       -48.00  ;//     F3              \r
+F4     =       -5.00   ;//     F4              \r
+F5     =       -46.00  ;//     F5              \r
+F6     =       18.00   ;//     F6              \r
+F7     =       22.00   ;//     F7      Somme   -107.00\r
+G1     =       40.00   ;//     G1              \r
+G2     =       -25.00  ;//     G2              \r
+G3     =       -40.00  ;//     G3              \r
+G4     =       -35.00  ;//     G4              \r
+G5     =       -16.00  ;//     G5              \r
+G6     =       -7.00   ;//     G6                                                                                                      \r
+G7     =       30.00   ;//     G7      Somme   -53.00                                                                                  \r
+\r
+Col1   =       [       A1      ;       B1      ;       C1      ;       D1      ;       E1      ;       F1      ;       G1      ]       ;//Collonne 1\r
+Col2   =       [       A2      ;       B2      ;       C2      ;       D2      ;       E2      ;       F2      ;       G2      ]       ;//Collonne 2\r
+Col3   =       [       A3      ;       B3      ;       C3      ;       D3      ;       E3      ;       F3      ;       G3      ]       ;//Collonne 3\r
+Col4   =       [       A4      ;       B4      ;       C4      ;       D4      ;       E4      ;       F4      ;       G4      ]       ;//Collonne 4\r
+Col5   =       [       A5      ;       B5      ;       C5      ;       D5      ;       E5      ;       F5      ;       G5      ]       ;//Collonne 5\r
+Col6   =       [       A6      ;       B6      ;       C6      ;       D6      ;       E6      ;       F6      ;       G6      ]       ;//Collonne 6\r
+Col7   =       [       A7      ;       B7      ;       C7      ;       D7      ;       E7      ;       F7      ;       G7      ]       ;//Collonne 7\r
+\r
+M      =       [       Col1    ,       Col2    ,       Col3    ,       Col4    ,       Col5    ,       Col6    ,       Col7    ]       ;//Matrice\r
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_9810.tst b/scilab/modules/xcos/tests/nonreg_tests/bug_9810.tst
new file mode 100644 (file)
index 0000000..0432ed0
--- /dev/null
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH XCOS -->
+//
+// <-- Non-regression test for bug 9810 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9810
+//
+// <-- Short Description -->
+// Matrix inversion error message update
+
+exec(SCI + "/modules/xcos/tests/nonreg_tests/bug_9810.sce");
+status = importXcosDiagram(SCI + "/modules/xcos/tests/nonreg_tests/bug_9810.xcos");
+if ~status then pause, end
+
+// compile and simulate
+xcos_simulate(scs_m, 4);
+
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_9810.xcos b/scilab/modules/xcos/tests/nonreg_tests/bug_9810.xcos
new file mode 100644 (file)
index 0000000..2b456b3
Binary files /dev/null and b/scilab/modules/xcos/tests/nonreg_tests/bug_9810.xcos differ