matboolean.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------------*/
00002 /* INRIA 2006 */
00003 /*-----------------------------------------------------------------------------------*/
00004 #ifdef _MSC_VER
00005 #include <Windows.h>
00006 #endif
00007 
00008 #include "machine.h"
00009 #include "stack-c.h"
00010 #include "core_math.h"
00011 #include "matboolean.h"
00012 /*-----------------------------------------------------------------------------------*/
00013 #define ISTK ((integer *)&C2F(stack))
00014 /*-----------------------------------------------------------------------------------*/
00015 int C2F(matlog)(void)
00016 {
00017     static integer ou = 57;
00018     static integer non = 61;
00019 
00020     static integer j=0;
00021     static double e1, e2;
00022     extern  int C2F(error)();
00023     static integer i1, i2, l1, l2, m2, n2, m1, n1, op, lw, il1, il2, mn2, it1, it2, mn1, top0;
00024 
00025     top0 = C2F(vstk).top;
00026     op = C2F(com).fin;
00027     lw = C2F(vstk).lstk[C2F(vstk).top] + 1;
00028 
00029     if (C2F(com).rhs == 2)
00030     {
00031                 il2 = C2F(vstk).lstk[C2F(vstk).top - 1] + C2F(vstk).lstk[C2F(vstk).top - 1] - 1;
00032                 if (ISTK[il2 - 1] < 0) 
00033                 {
00034                 il2 = ISTK[il2] + ISTK[il2] - 1;
00035                 }
00036                 m2 = ISTK[il2];
00037                 n2 = ISTK[il2 + 1];
00038                 it2 = ISTK[il2 + 2];
00039                 l2 = (il2 + 4) / 2 + 1;
00040                 mn2 = m2 * n2;
00041                 --C2F(vstk).top;
00042     }
00043 
00044     il1 = C2F(vstk).lstk[C2F(vstk).top - 1] + C2F(vstk).lstk[C2F(vstk).top - 1] - 1;
00045     if (ISTK[il1 - 1] < 0) 
00046         {
00047                 il1 = ISTK[il1] + ISTK[il1] - 1;
00048     }
00049     m1 = ISTK[il1];
00050     n1 = ISTK[il1 + 1];
00051     it1 = ISTK[il1 + 2];
00052 
00053     l1 = (il1 + 4) / 2 + 1;
00054     mn1 = m1 * n1;
00055     if (C2F(com).fin == non) 
00056         {
00057                 if (mn1 == 0) 
00058                 {
00059                         ISTK[il1 - 1] = 1;
00060                         ISTK[il1] = 0;
00061                         ISTK[il1 + 1] = 0;
00062                         ISTK[il1 + 2] = 0;
00063 
00064                         C2F(vstk).lstk[C2F(vstk).top] = (il1 + 4) / 2 + 1;
00065                         return 0;
00066                 }
00067                 else
00068                 {
00069                         ISTK[il1 - 1] = 4;
00070                         for (j = 0; j <= mn1 - 1; ++j) 
00071                         {
00072                                 e1 = C2F(stack).Stk[l1 + j - 1];
00073                                 if (e1 == 0.) 
00074                                 {
00075                                 ISTK[il1 + 3 + j - 1] = 1;
00076                                 }
00077                                 else
00078                                 {
00079                                 ISTK[il1 + 3 + j - 1] = 0;
00080                                 }
00081                         }
00082                         C2F(vstk).lstk[C2F(vstk).top] = (il1 + 3 + mn1) / 2 + 1;
00083                 }
00084         }
00085         else
00086         {
00087                 if (mn1 == 0 || mn2 == 0) 
00088                 {
00089                         ISTK[il1 - 1] = 1;
00090                         ISTK[il1] = 0;
00091                         ISTK[il1 + 1] = 0;
00092                         ISTK[il1 + 2] = 0;
00093 
00094                         C2F(vstk).lstk[C2F(vstk).top] = (il1 + 4) / 2 + 1;
00095                         return 0;
00096                 }
00097                 if (mn1 == 1) 
00098                 {
00099                         i1 = 0;
00100                         mn1 = mn2;
00101                 }
00102                 else 
00103                 {
00104                         i1 = 1;
00105                 }
00106                 if (mn2 == 1) 
00107                 {
00108                         i2 = 0;
00109                         mn2 = mn1;
00110                 }
00111                 else 
00112                 {
00113                     i2 = 1;
00114                 }
00115                 if (mn1 != mn2) 
00116                 {
00117                         static integer code_error = 60;
00118                         C2F(error)(&code_error);
00119                         return 0;
00120                 }
00121                 if (C2F(com).fin == ou) 
00122                 {
00123                 for (j = 0; j <= mn1 - 1; ++j) 
00124                         {
00125                                 e1 = C2F(stack).Stk[l1 + j * i1 - 1];
00126                                 e2 = C2F(stack).Stk[l2 + j * i2 - 1];
00127                                 if (e1 != 0. || e2 != 0.) 
00128                                 {
00129                                 ISTK[il1 + 3 + j - 1] = 1;
00130                                 }
00131                                 else 
00132                                 {
00133                                 ISTK[il1 + 3 + j - 1] = 0;
00134                                 }
00135                         }
00136                 }
00137                 else
00138                 {
00139                         for (j = 0; j <= mn1 - 1; ++j) 
00140                         {
00141                                 e1 = C2F(stack).Stk[l1 + j * i1 - 1];
00142                                 e2 = C2F(stack).Stk[l2 + j * i2 - 1];
00143                                 if (e1 != 0. && e2 != 0.) 
00144                                 {
00145                                         ISTK[il1 + 3 + j - 1] = 1;
00146                                 }
00147                                 else
00148                                 {
00149                                 ISTK[il1 + 3 + j - 1] = 0;
00150                                 }
00151                         }
00152                 }
00153                 ISTK[il1 - 1] = 4;
00154                 ISTK[il1] = Max(m1,m2);
00155                 ISTK[il1 + 1] = Max(n1,n2);
00156 
00157                 C2F(vstk).lstk[C2F(vstk).top] = (il1 + 3 + mn1) / 2 + 1;
00158                 return 0;
00159         }
00160 return 0;
00161 }
00162 #undef ISTK
00163 /*-----------------------------------------------------------------------------------*/
00164 
00165 

Generated on Sun Mar 4 15:03:44 2007 for Scilab [trunk] by  doxygen 1.5.1