reforge "&" operator 32/15132/4
Antoine ELIAS [Mon, 1 Sep 2014 07:55:40 +0000 (09:55 +0200)]
Change-Id: I8faed5faea05bf3da7ca75401c8813124e97a814

13 files changed:
scilab/modules/ast/Makefile.am
scilab/modules/ast/Makefile.in
scilab/modules/ast/ast.vcxproj
scilab/modules/ast/ast.vcxproj.filters
scilab/modules/ast/includes/operations/types_and.hxx [new file with mode: 0644]
scilab/modules/ast/includes/operations/types_or.hxx [moved from scilab/modules/ast/includes/operations/types_or_and.hxx with 61% similarity]
scilab/modules/ast/includes/operations/types_subtraction.hxx
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/operations/operations.cpp
scilab/modules/ast/src/cpp/operations/types_and.cpp [new file with mode: 0644]
scilab/modules/ast/src/cpp/operations/types_or.cpp [moved from scilab/modules/ast/src/cpp/operations/types_or_and.cpp with 52% similarity]
scilab/modules/ast/tests/unit_tests/and.dia.ref [new file with mode: 0644]
scilab/modules/ast/tests/unit_tests/and.tst [new file with mode: 0644]

index 3c97469..16bfd65 100644 (file)
@@ -32,7 +32,8 @@ libsciast_la_SOURCES = \
     src/cpp/operations/types_multiplication.cpp \
     src/cpp/operations/types_dotmultiplication.cpp \
     src/cpp/operations/types_comparison_lt_le_gt_ge.cpp \
-    src/cpp/operations/types_or_and.cpp \
+    src/cpp/operations/types_or.cpp \
+    src/cpp/operations/types_and.cpp \
     src/cpp/operations/types_comparison_ne.cpp \
     src/cpp/operations/types_power.cpp \
     src/cpp/operations/types_divide.cpp \
@@ -166,7 +167,8 @@ includes/operations/matrix_right_division.h \
 includes/operations/types_comparison_ne.hxx \
 includes/operations/types_multiplication.hxx \
 includes/operations/types_ldivide.hxx \
-includes/operations/types_or_and.hxx \
+includes/operations/types_and.hxx \
+includes/operations/types_or.hxx \
 includes/operations/matrix_left_division.h \
 includes/operations/types_power.hxx \
 includes/operations/matrix_finite.h \
index 6d1c268..040ff1a 100644 (file)
@@ -175,7 +175,8 @@ am__libsciast_la_SOURCES_DIST = src/cpp/ast/runvisitor.cpp \
        src/cpp/operations/types_multiplication.cpp \
        src/cpp/operations/types_dotmultiplication.cpp \
        src/cpp/operations/types_comparison_lt_le_gt_ge.cpp \
-       src/cpp/operations/types_or_and.cpp \
+       src/cpp/operations/types_or.cpp \
+       src/cpp/operations/types_and.cpp \
        src/cpp/operations/types_comparison_ne.cpp \
        src/cpp/operations/types_power.cpp \
        src/cpp/operations/types_divide.cpp \
@@ -246,7 +247,8 @@ am_libsciast_la_OBJECTS = src/cpp/ast/libsciast_la-runvisitor.lo \
        src/cpp/operations/libsciast_la-types_multiplication.lo \
        src/cpp/operations/libsciast_la-types_dotmultiplication.lo \
        src/cpp/operations/libsciast_la-types_comparison_lt_le_gt_ge.lo \
-       src/cpp/operations/libsciast_la-types_or_and.lo \
+       src/cpp/operations/libsciast_la-types_or.lo \
+       src/cpp/operations/libsciast_la-types_and.lo \
        src/cpp/operations/libsciast_la-types_comparison_ne.lo \
        src/cpp/operations/libsciast_la-types_power.lo \
        src/cpp/operations/libsciast_la-types_divide.lo \
@@ -703,7 +705,8 @@ libsciast_la_SOURCES = src/cpp/ast/runvisitor.cpp \
        src/cpp/operations/types_multiplication.cpp \
        src/cpp/operations/types_dotmultiplication.cpp \
        src/cpp/operations/types_comparison_lt_le_gt_ge.cpp \
-       src/cpp/operations/types_or_and.cpp \
+       src/cpp/operations/types_or.cpp \
+       src/cpp/operations/types_and.cpp \
        src/cpp/operations/types_comparison_ne.cpp \
        src/cpp/operations/types_power.cpp \
        src/cpp/operations/types_divide.cpp \
@@ -809,7 +812,8 @@ includes/operations/matrix_right_division.h \
 includes/operations/types_comparison_ne.hxx \
 includes/operations/types_multiplication.hxx \
 includes/operations/types_ldivide.hxx \
-includes/operations/types_or_and.hxx \
+includes/operations/types_and.hxx \
+includes/operations/types_or.hxx \
 includes/operations/matrix_left_division.h \
 includes/operations/types_power.hxx \
 includes/operations/matrix_finite.h \
@@ -1179,7 +1183,10 @@ src/cpp/operations/libsciast_la-types_dotmultiplication.lo:  \
 src/cpp/operations/libsciast_la-types_comparison_lt_le_gt_ge.lo:  \
        src/cpp/operations/$(am__dirstamp) \
        src/cpp/operations/$(DEPDIR)/$(am__dirstamp)
-src/cpp/operations/libsciast_la-types_or_and.lo:  \
+src/cpp/operations/libsciast_la-types_or.lo:  \
+       src/cpp/operations/$(am__dirstamp) \
+       src/cpp/operations/$(DEPDIR)/$(am__dirstamp)
+src/cpp/operations/libsciast_la-types_and.lo:  \
        src/cpp/operations/$(am__dirstamp) \
        src/cpp/operations/$(DEPDIR)/$(am__dirstamp)
 src/cpp/operations/libsciast_la-types_comparison_ne.lo:  \
@@ -1444,6 +1451,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-interface_addition.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-operations.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_addition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_and.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_comparison_eq.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_comparison_lt_le_gt_ge.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_comparison_ne.Plo@am__quote@
@@ -1454,7 +1462,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_ldivide.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_multiplication.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_opposite.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_or_and.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_or.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_power.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/operations/$(DEPDIR)/libsciast_la-types_subtraction.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/parse/$(DEPDIR)/libsciast_la-parser.Plo@am__quote@
@@ -1757,12 +1765,19 @@ src/cpp/operations/libsciast_la-types_comparison_lt_le_gt_ge.lo: src/cpp/operati
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/operations/libsciast_la-types_comparison_lt_le_gt_ge.lo `test -f 'src/cpp/operations/types_comparison_lt_le_gt_ge.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_comparison_lt_le_gt_ge.cpp
 
-src/cpp/operations/libsciast_la-types_or_and.lo: src/cpp/operations/types_or_and.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/operations/libsciast_la-types_or_and.lo -MD -MP -MF src/cpp/operations/$(DEPDIR)/libsciast_la-types_or_and.Tpo -c -o src/cpp/operations/libsciast_la-types_or_and.lo `test -f 'src/cpp/operations/types_or_and.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_or_and.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/operations/$(DEPDIR)/libsciast_la-types_or_and.Tpo src/cpp/operations/$(DEPDIR)/libsciast_la-types_or_and.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/operations/types_or_and.cpp' object='src/cpp/operations/libsciast_la-types_or_and.lo' libtool=yes @AMDEPBACKSLASH@
+src/cpp/operations/libsciast_la-types_or.lo: src/cpp/operations/types_or.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/operations/libsciast_la-types_or.lo -MD -MP -MF src/cpp/operations/$(DEPDIR)/libsciast_la-types_or.Tpo -c -o src/cpp/operations/libsciast_la-types_or.lo `test -f 'src/cpp/operations/types_or.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_or.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/operations/$(DEPDIR)/libsciast_la-types_or.Tpo src/cpp/operations/$(DEPDIR)/libsciast_la-types_or.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/operations/types_or.cpp' object='src/cpp/operations/libsciast_la-types_or.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/operations/libsciast_la-types_or.lo `test -f 'src/cpp/operations/types_or.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_or.cpp
+
+src/cpp/operations/libsciast_la-types_and.lo: src/cpp/operations/types_and.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/operations/libsciast_la-types_and.lo -MD -MP -MF src/cpp/operations/$(DEPDIR)/libsciast_la-types_and.Tpo -c -o src/cpp/operations/libsciast_la-types_and.lo `test -f 'src/cpp/operations/types_and.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_and.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/operations/$(DEPDIR)/libsciast_la-types_and.Tpo src/cpp/operations/$(DEPDIR)/libsciast_la-types_and.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/operations/types_and.cpp' object='src/cpp/operations/libsciast_la-types_and.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/operations/libsciast_la-types_or_and.lo `test -f 'src/cpp/operations/types_or_and.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_or_and.cpp
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/operations/libsciast_la-types_and.lo `test -f 'src/cpp/operations/types_and.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_and.cpp
 
 src/cpp/operations/libsciast_la-types_comparison_ne.lo: src/cpp/operations/types_comparison_ne.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/operations/libsciast_la-types_comparison_ne.lo -MD -MP -MF src/cpp/operations/$(DEPDIR)/libsciast_la-types_comparison_ne.Tpo -c -o src/cpp/operations/libsciast_la-types_comparison_ne.lo `test -f 'src/cpp/operations/types_comparison_ne.cpp' || echo '$(srcdir)/'`src/cpp/operations/types_comparison_ne.cpp
index 838ed74..c425e61 100644 (file)
@@ -340,10 +340,11 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClInclude Include="includes\operations\types_ldivide.hxx" />
     <ClInclude Include="includes\operations\types_multiplication.hxx" />
     <ClInclude Include="includes\operations\types_opposite.hxx" />
-    <ClInclude Include="includes\operations\types_or_and.hxx" />
+    <ClInclude Include="includes\operations\types_or.hxx" />
     <ClInclude Include="includes\operations\types_power.hxx" />
     <ClInclude Include="includes\operations\types_subtraction.hxx" />
     <ClInclude Include="includes\operations\types_transposition.hxx" />
+    <ClInclude Include="includes\operations\types_and.hxx" />
     <ClInclude Include="includes\parse\isatty.hxx" />
     <ClInclude Include="includes\parse\parse.hxx" />
     <ClInclude Include="includes\parse\parser.hxx" />
@@ -429,6 +430,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClCompile Include="src\cpp\operations\interface_addition.cpp" />
     <ClCompile Include="src\cpp\operations\operations.cpp" />
     <ClCompile Include="src\cpp\operations\types_addition.cpp" />
+    <ClCompile Include="src\cpp\operations\types_and.cpp" />
     <ClCompile Include="src\cpp\operations\types_comparison_eq.cpp" />
     <ClCompile Include="src\cpp\operations\types_comparison_lt_le_gt_ge.cpp" />
     <ClCompile Include="src\cpp\operations\types_comparison_ne.cpp" />
@@ -439,7 +441,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClCompile Include="src\cpp\operations\types_ldivide.cpp" />
     <ClCompile Include="src\cpp\operations\types_multiplication.cpp" />
     <ClCompile Include="src\cpp\operations\types_opposite.cpp" />
-    <ClCompile Include="src\cpp\operations\types_or_and.cpp" />
+    <ClCompile Include="src\cpp\operations\types_or.cpp" />
     <ClCompile Include="src\cpp\operations\types_power.cpp" />
     <ClCompile Include="src\cpp\operations\types_subtraction.cpp" />
     <ClCompile Include="src\cpp\parse\parser.cpp" />
index 9f03afe..6a5e5df 100644 (file)
     <ClInclude Include="includes\operations\types_multiplication.hxx">
       <Filter>Header Files\operations</Filter>
     </ClInclude>
-    <ClInclude Include="includes\operations\types_or_and.hxx">
-      <Filter>Header Files\operations</Filter>
-    </ClInclude>
     <ClInclude Include="includes\operations\types_power.hxx">
       <Filter>Header Files\operations</Filter>
     </ClInclude>
     <ClInclude Include="includes\operations\types_dotmultiplication.hxx">
       <Filter>Header Files\operations</Filter>
     </ClInclude>
+    <ClInclude Include="includes\operations\types_and.hxx">
+      <Filter>Header Files\operations</Filter>
+    </ClInclude>
+    <ClInclude Include="includes\operations\types_or.hxx">
+      <Filter>Header Files\operations</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\ast\debugvisitor.cpp">
     <ClCompile Include="src\cpp\operations\types_multiplication.cpp">
       <Filter>Source Files\operations</Filter>
     </ClCompile>
-    <ClCompile Include="src\cpp\operations\types_or_and.cpp">
-      <Filter>Source Files\operations</Filter>
-    </ClCompile>
     <ClCompile Include="src\cpp\operations\types_power.cpp">
       <Filter>Source Files\operations</Filter>
     </ClCompile>
     <ClCompile Include="src\cpp\operations\types_dotmultiplication.cpp">
       <Filter>Source Files\operations</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\operations\types_and.cpp">
+      <Filter>Source Files\operations</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\operations\types_or.cpp">
+      <Filter>Source Files\operations</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/scilab/modules/ast/includes/operations/types_and.hxx b/scilab/modules/ast/includes/operations/types_and.hxx
new file mode 100644 (file)
index 0000000..f27b417
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __TYPES_AND_H__
+#define __TYPES_AND_H__
+
+#include "generic_operations.hxx"
+#include "double.hxx"
+#include "polynom.hxx"
+#include "bool.hxx"
+#include "sparse.hxx"
+
+void fillAndFunction();
+
+//define arrays on operation functions
+typedef types::InternalType*(*and_function)(types::InternalType*, types::InternalType*);
+
+#define DECLARE_AND_PROTO(x) \
+    template<class T, class U, class O> \
+    inline types::InternalType* x(T *_pL, U *_pR)
+
+DECLARE_AND_PROTO(and_M_M);
+DECLARE_AND_PROTO(and_M_S);
+DECLARE_AND_PROTO(and_M_E);
+
+DECLARE_AND_PROTO(and_S_M);
+DECLARE_AND_PROTO(and_S_S);
+DECLARE_AND_PROTO(and_S_E);
+
+//[]
+DECLARE_AND_PROTO(and_E_M);
+
+//eye
+DECLARE_AND_PROTO(and_I_M);
+DECLARE_AND_PROTO(and_I_S);
+
+DECLARE_AND_PROTO(and_int_M_M);
+DECLARE_AND_PROTO(and_int_M_S);
+DECLARE_AND_PROTO(and_int_S_M);
+DECLARE_AND_PROTO(and_int_S_S);
+
+//boolean sparse specialisation
+template<> inline types::InternalType* and_M_M<types::SparseBool, types::SparseBool, types::SparseBool>(types::SparseBool* _pL, types::SparseBool* _pR);
+template<> inline types::InternalType* and_M_M<types::SparseBool, types::Bool, types::SparseBool>(types::SparseBool* _pL, types::Bool* _pR);
+template<> inline types::InternalType* and_M_M<types::Bool, types::SparseBool, types::SparseBool>(types::Bool* _pL, types::SparseBool* _pR);
+
+//x & x
+template<typename T, typename U, typename O> inline static void bit_and(T* l, long long size, U* r, O* o)
+{
+    for (int i = 0; i < size ; ++i)
+    {
+        o[i] = (((O)l[i] != (O)0) && ((O)r[i] != (O)0)) ? (O)1 : (O)0;
+    }
+}
+
+//x1 & x
+template<typename T, typename U, typename O> inline static void bit_and(T l, long long size, U* r, O* o)
+{
+    for (int i = 0; i < size ; ++i)
+    {
+        o[i] = (((O)l != (O)0) && ((O)r[i] != (O)0)) ? (O)1 : (O)0;
+    }
+}
+
+//x & x1
+template<typename T, typename U, typename O> inline static void bit_and(T* l, long long size, U r, O* o)
+{
+    for (int i = 0; i < size ; ++i)
+    {
+        o[i] = (((O)l[i] != (O)0) && ((O)r != (O)0)) ? (O)1 : (O)0;
+    }
+}
+
+//x1 & x1
+template<typename T, typename U, typename O> inline static void bit_and(T l, U r, O* o)
+{
+    *o = (((O)l != (O)0) && ((O)r != (O)0)) ? (O)1 : (O)0;
+}
+
+
+//int, real & operation,
+//x & x
+template<typename T, typename U, typename O> inline static void int_and(T* l, long long size, U* r, O* o)
+{
+    for (int i = 0; i < size ; ++i)
+    {
+        o[i] = (O)l[i] & (O)r[i];
+    }
+}
+
+//x1 & x
+template<typename T, typename U, typename O> inline static void int_and(T l, long long size, U* r, O* o)
+{
+    for (int i = 0; i < size ; ++i)
+    {
+        o[i] = (O)l & (O)r[i];
+    }
+}
+
+//x & x1
+template<typename T, typename U, typename O> inline static void int_and(T* l, long long size, U r, O* o)
+{
+    for (int i = 0; i < size ; ++i)
+    {
+        o[i] = (O)l[i] & (O)r;
+    }
+}
+
+//x1 & x1
+template<typename T, typename U, typename O> inline static void int_and(T l, U r, O* o)
+{
+    *o = (O)l & (O)r;
+}
+
+// &&
+int IntAndInt(types::InternalType* _pL, types::Bool** _pOut);
+int BoolAndBool(types::Bool* _pL, types::Bool** _pOut);
+int SparseBoolAndSparseBool(types::InternalType* _pL, types::Bool** _pOut);
+
+#undef DECLARE_AND_PROTO
+#endif /* !__TYPES_AND_H__ */
+
+
  *
  */
 
-#ifndef __TYPES_BITWISEOP_H__
-#define __TYPES_BITWISEOP_H__
+#ifndef __TYPES_OR_H__
+#define __TYPES_OR_H__
 
 #include "generic_operations.hxx"
 #include "types.hxx"
 #include "bool.hxx"
-//#include "sparse.hxx"
-
-// &&
-int IntAndInt(types::InternalType* _pL, types::Bool** _pOut);
-int BoolAndBool(types::Bool* _pL, types::Bool** _pOut);
-int SparseBoolAndSparseBool(types::InternalType* _pL, types::Bool** _pOut);
-
-// &
-int IntLogicalAndInt(types::InternalType* _pL, types::InternalType*  _pR, types::InternalType** _pOut);
-int BoolLogicalAndBool(types::Bool* _pL, types::Bool*  _pR, types::Bool** _pOut);
-int SparseBoolLogicalAndSparseBool(types::InternalType* _pL, types::InternalType*  _pR, types::InternalType** _pOut);
 
 // ||
 int IntOrInt(types::InternalType* _pL, types::Bool** _pOut);
@@ -38,4 +27,4 @@ int IntLogicalOrInt(types::InternalType* _pL, types::InternalType*  _pR, types::
 int BoolLogicalOrBool(types::Bool* _pL, types::Bool*  _pR, types::Bool** _pOut);
 int SparseBoolLogicalOrSparseBool(types::InternalType* _pL, types::InternalType*  _pR, types::InternalType** _pOut);
 
-#endif /* __TYPES_BITWISEOP_H__ */
+#endif /* __TYPES_OR_H__ */
index c499628..88c8ad0 100644 (file)
@@ -19,7 +19,6 @@
 #include "polynom.hxx"
 #include "sparse.hxx"
 
-// FIXME : remove using namespace
 void fillSubtractFunction();
 
 //define arrays on operation functions
index 2f0f076..8182e31 100644 (file)
@@ -24,7 +24,8 @@
 
 #include "context.hxx"
 #include "generic_operations.hxx"
-#include "types_or_and.hxx"
+#include "types_or.hxx"
+#include "types_and.hxx"
 #include "localization.hxx"
 
 #include "macrofile.hxx"
index b14b1de..ceed995 100644 (file)
@@ -6,6 +6,7 @@
 #include "types_subtraction.hxx"
 #include "types_opposite.hxx"
 #include "types_dotmultiplication.hxx"
+#include "types_and.hxx"
 
 void initOperationArray()
 {
@@ -13,4 +14,5 @@ void initOperationArray()
     fillOppositeFunction();
     fillSubtractFunction();
     fillDotMulFunction();
+    fillAndFunction();
 }
diff --git a/scilab/modules/ast/src/cpp/operations/types_and.cpp b/scilab/modules/ast/src/cpp/operations/types_and.cpp
new file mode 100644 (file)
index 0000000..6d6c2ec
--- /dev/null
@@ -0,0 +1,718 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+extern "C"
+{
+#include "os_swprintf.h"
+}
+
+#include "types_and.hxx"
+#include "double.hxx"
+#include "int.hxx"
+#include "bool.hxx"
+#include "sparse.hxx"
+
+using namespace types;
+
+//define arrays on operation functions
+static and_function pAndfunction[types::InternalType::IdLast][types::InternalType::IdLast] = {NULL};
+
+void fillAndFunction()
+{
+#define scilab_fill_and(id1, id2, func, typeIn1, typeIn2, typeOut) \
+    pAndfunction[types::InternalType::Id ## id1][types::InternalType::Id ## id2] = (and_function)&and_##func<typeIn1, typeIn2, typeOut>
+
+    //Double
+    scilab_fill_and(Double, Double, M_M, Double, Double, Bool);
+    scilab_fill_and(Double, Bool, M_M, Double, Bool, Bool);
+
+    scilab_fill_and(Double, ScalarDouble, M_S, Double, Double, Bool);
+    scilab_fill_and(Double, ScalarBool, M_S, Double, Bool, Bool);
+
+    scilab_fill_and(Double, Empty, M_E, Double, Double, Double);
+    scilab_fill_and(Double, Identity, M_S, Double, Double, Bool);
+
+    scilab_fill_and(ScalarDouble, Double, S_M, Double, Double, Bool);
+    scilab_fill_and(ScalarDouble, Bool, S_M, Double, Bool, Bool);
+
+    scilab_fill_and(ScalarDouble, ScalarDouble, S_S, Double, Double, Bool);
+    scilab_fill_and(ScalarDouble, ScalarBool, S_S, Double, Bool, Bool);
+
+    scilab_fill_and(ScalarDouble, Empty, M_E, Double, Double, Double);
+    scilab_fill_and(ScalarDouble, Identity, S_S, Double, Double, Bool);
+
+    //Bool
+    scilab_fill_and(Bool, Double, M_M, Bool, Double, Bool);
+    scilab_fill_and(Bool, Bool, M_M, Bool, Bool, Bool);
+
+    scilab_fill_and(Bool, ScalarDouble, M_S, Bool, Double, Bool);
+    scilab_fill_and(Bool, ScalarBool, M_S, Bool, Bool, Bool);
+
+    scilab_fill_and(Bool, Empty, M_E, Bool, Double, Double);
+    scilab_fill_and(Bool, Identity, M_S, Bool, Double, Bool);
+
+    scilab_fill_and(ScalarBool, Double, S_M, Bool, Double, Bool);
+    scilab_fill_and(ScalarBool, Bool, S_M, Bool, Bool, Bool);
+
+    scilab_fill_and(ScalarBool, ScalarDouble, S_S, Bool, Double, Bool);
+    scilab_fill_and(ScalarBool, ScalarBool, S_S, Bool, Bool, Bool);
+
+    scilab_fill_and(ScalarBool, Empty, M_E, Bool, Double, Double);
+    scilab_fill_and(ScalarBool, Identity, S_S, Bool, Double, Bool);
+
+    // []
+    scilab_fill_and(Empty, Double, E_M, Double, Double, Double);
+    scilab_fill_and(Empty, Bool, E_M, Double, Bool, Double);
+    scilab_fill_and(Empty, ScalarDouble, E_M, Double, Double, Double);
+    scilab_fill_and(Empty, ScalarBool, E_M, Double, Bool, Double);
+    scilab_fill_and(Empty, Empty, E_M, Double, Double, Double);
+    scilab_fill_and(Empty, Identity, E_M, Double, Double, Double);
+
+    // Identity
+    scilab_fill_and(Identity, Double, I_M, Double, Double, Bool);
+    scilab_fill_and(Identity, Bool, I_M, Double, Bool, Bool);
+
+    scilab_fill_and(Identity, ScalarDouble, I_S, Double, Double, Bool);
+    scilab_fill_and(Identity, ScalarBool, I_S, Double, Bool, Bool);
+
+    scilab_fill_and(Identity, Empty, M_E, Double, Double, Bool);
+    scilab_fill_and(Identity, Identity, I_S, Double, Double, Bool);
+
+
+    //int8
+    scilab_fill_and(Int8, Int8, int_M_M, Int8, Int8, Int8);
+    scilab_fill_and(Int8, UInt8, int_M_M, Int8, UInt8, UInt8);
+    scilab_fill_and(Int8, Int16, int_M_M, Int8, Int16, Int16);
+    scilab_fill_and(Int8, UInt16, int_M_M, Int8, UInt16, UInt16);
+    scilab_fill_and(Int8, Int32, int_M_M, Int8, Int32, Int32);
+    scilab_fill_and(Int8, UInt32, int_M_M, Int8, UInt32, UInt32);
+    scilab_fill_and(Int8, Int64, int_M_M, Int8, Int64, Int64);
+    scilab_fill_and(Int8, UInt64, int_M_M, Int8, UInt64, UInt64);
+
+    scilab_fill_and(Int8, ScalarInt8, int_M_S, Int8, Int8, Int8);
+    scilab_fill_and(Int8, ScalarUInt8, int_M_S, Int8, UInt8, UInt8);
+    scilab_fill_and(Int8, ScalarInt16, int_M_S, Int8, Int16, Int16);
+    scilab_fill_and(Int8, ScalarUInt16, int_M_S, Int8, UInt16, UInt16);
+    scilab_fill_and(Int8, ScalarInt32, int_M_S, Int8, Int32, Int32);
+    scilab_fill_and(Int8, ScalarUInt32, int_M_S, Int8, UInt32, UInt32);
+    scilab_fill_and(Int8, ScalarInt64, int_M_S, Int8, Int64, Int64);
+    scilab_fill_and(Int8, ScalarUInt64, int_M_S, Int8, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt8, Int8, int_S_M, Int8, Int8, Int8);
+    scilab_fill_and(ScalarInt8, UInt8, int_S_M, Int8, UInt8, UInt8);
+    scilab_fill_and(ScalarInt8, Int16, int_S_M, Int8, Int16, Int16);
+    scilab_fill_and(ScalarInt8, UInt16, int_S_M, Int8, UInt16, UInt16);
+    scilab_fill_and(ScalarInt8, Int32, int_S_M, Int8, Int32, Int32);
+    scilab_fill_and(ScalarInt8, UInt32, int_S_M, Int8, UInt32, UInt32);
+    scilab_fill_and(ScalarInt8, Int64, int_S_M, Int8, Int64, Int64);
+    scilab_fill_and(ScalarInt8, UInt64, int_S_M, Int8, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt8, ScalarInt8, int_S_S, Int8, Int8, Int8);
+    scilab_fill_and(ScalarInt8, ScalarUInt8, int_S_S, Int8, UInt8, UInt8);
+    scilab_fill_and(ScalarInt8, ScalarInt16, int_S_S, Int8, Int16, Int16);
+    scilab_fill_and(ScalarInt8, ScalarUInt16, int_S_S, Int8, UInt16, UInt16);
+    scilab_fill_and(ScalarInt8, ScalarInt32, int_S_S, Int8, Int32, Int32);
+    scilab_fill_and(ScalarInt8, ScalarUInt32, int_S_S, Int8, UInt32, UInt32);
+    scilab_fill_and(ScalarInt8, ScalarInt64, int_S_S, Int8, Int64, Int64);
+    scilab_fill_and(ScalarInt8, ScalarUInt64, int_S_S, Int8, UInt64, UInt64);
+
+    //uint8
+    scilab_fill_and(UInt8, Int8, int_M_M, UInt8, Int8, UInt8);
+    scilab_fill_and(UInt8, UInt8, int_M_M, UInt8, UInt8, UInt8);
+    scilab_fill_and(UInt8, Int16, int_M_M, UInt8, Int16, UInt16);
+    scilab_fill_and(UInt8, UInt16, int_M_M, UInt8, UInt16, UInt16);
+    scilab_fill_and(UInt8, Int32, int_M_M, UInt8, Int32, UInt32);
+    scilab_fill_and(UInt8, UInt32, int_M_M, UInt8, UInt32, UInt32);
+    scilab_fill_and(UInt8, Int64, int_M_M, UInt8, Int64, UInt64);
+    scilab_fill_and(UInt8, UInt64, int_M_M, UInt8, UInt64, UInt64);
+
+    scilab_fill_and(UInt8, ScalarInt8, int_M_S, UInt8, Int8, UInt8);
+    scilab_fill_and(UInt8, ScalarUInt8, int_M_S, UInt8, UInt8, UInt8);
+    scilab_fill_and(UInt8, ScalarInt16, int_M_S, UInt8, Int16, UInt16);
+    scilab_fill_and(UInt8, ScalarUInt16, int_M_S, UInt8, UInt16, UInt16);
+    scilab_fill_and(UInt8, ScalarInt32, int_M_S, UInt8, Int32, UInt32);
+    scilab_fill_and(UInt8, ScalarUInt32, int_M_S, UInt8, UInt32, UInt32);
+    scilab_fill_and(UInt8, ScalarInt64, int_M_S, UInt8, Int64, UInt64);
+    scilab_fill_and(UInt8, ScalarUInt64, int_M_S, UInt8, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt8, Int8, int_S_M, UInt8, Int8, UInt8);
+    scilab_fill_and(ScalarUInt8, UInt8, int_S_M, UInt8, UInt8, UInt8);
+    scilab_fill_and(ScalarUInt8, Int16, int_S_M, UInt8, Int16, UInt16);
+    scilab_fill_and(ScalarUInt8, UInt16, int_S_M, UInt8, UInt16, UInt16);
+    scilab_fill_and(ScalarUInt8, Int32, int_S_M, UInt8, Int32, UInt32);
+    scilab_fill_and(ScalarUInt8, UInt32, int_S_M, UInt8, UInt32, UInt32);
+    scilab_fill_and(ScalarUInt8, Int64, int_S_M, UInt8, Int64, UInt64);
+    scilab_fill_and(ScalarUInt8, UInt64, int_S_M, UInt8, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt8, ScalarInt8, int_S_S, UInt8, Int8, UInt8);
+    scilab_fill_and(ScalarUInt8, ScalarUInt8, int_S_S, UInt8, UInt8, UInt8);
+    scilab_fill_and(ScalarUInt8, ScalarInt16, int_S_S, UInt8, Int16, UInt16);
+    scilab_fill_and(ScalarUInt8, ScalarUInt16, int_S_S, UInt8, UInt16, UInt16);
+    scilab_fill_and(ScalarUInt8, ScalarInt32, int_S_S, UInt8, Int32, UInt32);
+    scilab_fill_and(ScalarUInt8, ScalarUInt32, int_S_S, UInt8, UInt32, UInt32);
+    scilab_fill_and(ScalarUInt8, ScalarInt64, int_S_S, UInt8, Int64, UInt64);
+    scilab_fill_and(ScalarUInt8, ScalarUInt64, int_S_S, UInt8, UInt64, UInt64);
+
+    //int16
+    scilab_fill_and(Int16, Int8, int_M_M, Int16, Int8, Int16);
+    scilab_fill_and(Int16, UInt8, int_M_M, Int16, UInt8, UInt16);
+    scilab_fill_and(Int16, Int16, int_M_M, Int16, Int16, Int16);
+    scilab_fill_and(Int16, UInt16, int_M_M, Int16, UInt16, UInt16);
+    scilab_fill_and(Int16, Int32, int_M_M, Int16, Int32, Int32);
+    scilab_fill_and(Int16, UInt32, int_M_M, Int16, UInt32, UInt32);
+    scilab_fill_and(Int16, Int64, int_M_M, Int16, Int64, Int64);
+    scilab_fill_and(Int16, UInt64, int_M_M, Int16, UInt64, UInt64);
+
+    scilab_fill_and(Int16, ScalarInt8, int_M_S, Int16, Int8, Int16);
+    scilab_fill_and(Int16, ScalarUInt8, int_M_S, Int16, UInt8, UInt16);
+    scilab_fill_and(Int16, ScalarInt16, int_M_S, Int16, Int16, Int16);
+    scilab_fill_and(Int16, ScalarUInt16, int_M_S, Int16, UInt16, UInt16);
+    scilab_fill_and(Int16, ScalarInt32, int_M_S, Int16, Int32, Int32);
+    scilab_fill_and(Int16, ScalarUInt32, int_M_S, Int16, UInt32, UInt32);
+    scilab_fill_and(Int16, ScalarInt64, int_M_S, Int16, Int64, Int64);
+    scilab_fill_and(Int16, ScalarUInt64, int_M_S, Int16, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt16, Int8, int_S_M, Int16, Int8, Int16);
+    scilab_fill_and(ScalarInt16, UInt8, int_S_M, Int16, UInt8, UInt16);
+    scilab_fill_and(ScalarInt16, Int16, int_S_M, Int16, Int16, Int16);
+    scilab_fill_and(ScalarInt16, UInt16, int_S_M, Int16, UInt16, UInt16);
+    scilab_fill_and(ScalarInt16, Int32, int_S_M, Int16, Int32, Int32);
+    scilab_fill_and(ScalarInt16, UInt32, int_S_M, Int16, UInt32, UInt32);
+    scilab_fill_and(ScalarInt16, Int64, int_S_M, Int16, Int64, Int64);
+    scilab_fill_and(ScalarInt16, UInt64, int_S_M, Int16, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt16, ScalarInt8, int_S_S, Int16, Int8, Int16);
+    scilab_fill_and(ScalarInt16, ScalarUInt8, int_S_S, Int16, UInt8, UInt16);
+    scilab_fill_and(ScalarInt16, ScalarInt16, int_S_S, Int16, Int16, Int16);
+    scilab_fill_and(ScalarInt16, ScalarUInt16, int_S_S, Int16, UInt16, UInt16);
+    scilab_fill_and(ScalarInt16, ScalarInt32, int_S_S, Int16, Int32, Int32);
+    scilab_fill_and(ScalarInt16, ScalarUInt32, int_S_S, Int16, UInt32, UInt32);
+    scilab_fill_and(ScalarInt16, ScalarInt64, int_S_S, Int16, Int64, Int64);
+    scilab_fill_and(ScalarInt16, ScalarUInt64, int_S_S, Int16, UInt64, UInt64);
+
+    //uint16
+    scilab_fill_and(UInt16, Int8, int_M_M, UInt16, Int8, UInt16);
+    scilab_fill_and(UInt16, UInt8, int_M_M, UInt16, UInt8, UInt16);
+    scilab_fill_and(UInt16, Int16, int_M_M, UInt16, Int16, UInt16);
+    scilab_fill_and(UInt16, UInt16, int_M_M, UInt16, UInt16, UInt16);
+    scilab_fill_and(UInt16, Int32, int_M_M, UInt16, Int32, UInt32);
+    scilab_fill_and(UInt16, UInt32, int_M_M, UInt16, UInt32, UInt32);
+    scilab_fill_and(UInt16, Int64, int_M_M, UInt16, Int64, UInt64);
+    scilab_fill_and(UInt16, UInt64, int_M_M, UInt16, UInt64, UInt64);
+
+    scilab_fill_and(UInt16, ScalarInt8, int_M_S, UInt16, Int8, UInt16);
+    scilab_fill_and(UInt16, ScalarUInt8, int_M_S, UInt16, UInt8, UInt16);
+    scilab_fill_and(UInt16, ScalarInt16, int_M_S, UInt16, Int16, UInt16);
+    scilab_fill_and(UInt16, ScalarUInt16, int_M_S, UInt16, UInt16, UInt16);
+    scilab_fill_and(UInt16, ScalarInt32, int_M_S, UInt16, Int32, UInt32);
+    scilab_fill_and(UInt16, ScalarUInt32, int_M_S, UInt16, UInt32, UInt32);
+    scilab_fill_and(UInt16, ScalarInt64, int_M_S, UInt16, Int64, UInt64);
+    scilab_fill_and(UInt16, ScalarUInt64, int_M_S, UInt16, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt16, Int8, int_S_M, UInt16, Int8, UInt16);
+    scilab_fill_and(ScalarUInt16, UInt8, int_S_M, UInt16, UInt8, UInt16);
+    scilab_fill_and(ScalarUInt16, Int16, int_S_M, UInt16, Int16, UInt16);
+    scilab_fill_and(ScalarUInt16, UInt16, int_S_M, UInt16, UInt16, UInt16);
+    scilab_fill_and(ScalarUInt16, Int32, int_S_M, UInt16, Int32, UInt32);
+    scilab_fill_and(ScalarUInt16, UInt32, int_S_M, UInt16, UInt32, UInt32);
+    scilab_fill_and(ScalarUInt16, Int64, int_S_M, UInt16, Int64, UInt64);
+    scilab_fill_and(ScalarUInt16, UInt64, int_S_M, UInt16, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt16, ScalarInt8, int_S_S, UInt16, Int8, UInt16);
+    scilab_fill_and(ScalarUInt16, ScalarUInt8, int_S_S, UInt16, UInt8, UInt16);
+    scilab_fill_and(ScalarUInt16, ScalarInt16, int_S_S, UInt16, Int16, UInt16);
+    scilab_fill_and(ScalarUInt16, ScalarUInt16, int_S_S, UInt16, UInt16, UInt16);
+    scilab_fill_and(ScalarUInt16, ScalarInt32, int_S_S, UInt16, Int32, UInt32);
+    scilab_fill_and(ScalarUInt16, ScalarUInt32, int_S_S, UInt16, UInt32, UInt32);
+    scilab_fill_and(ScalarUInt16, ScalarInt64, int_S_S, UInt16, Int64, UInt64);
+    scilab_fill_and(ScalarUInt16, ScalarUInt64, int_S_S, UInt16, UInt64, UInt64);
+
+    //int32
+    scilab_fill_and(Int32, Int8, int_M_M, Int32, Int8, Int32);
+    scilab_fill_and(Int32, UInt8, int_M_M, Int32, UInt8, UInt32);
+    scilab_fill_and(Int32, Int16, int_M_M, Int32, Int16, Int32);
+    scilab_fill_and(Int32, UInt16, int_M_M, Int32, UInt16, UInt32);
+    scilab_fill_and(Int32, Int32, int_M_M, Int32, Int32, Int32);
+    scilab_fill_and(Int32, UInt32, int_M_M, Int32, UInt32, UInt32);
+    scilab_fill_and(Int32, Int64, int_M_M, Int32, Int64, Int64);
+    scilab_fill_and(Int32, UInt64, int_M_M, Int32, UInt64, UInt64);
+
+    scilab_fill_and(Int32, ScalarInt8, int_M_S, Int32, Int8, Int32);
+    scilab_fill_and(Int32, ScalarUInt8, int_M_S, Int32, UInt8, UInt32);
+    scilab_fill_and(Int32, ScalarInt16, int_M_S, Int32, Int16, Int32);
+    scilab_fill_and(Int32, ScalarUInt16, int_M_S, Int32, UInt16, UInt32);
+    scilab_fill_and(Int32, ScalarInt32, int_M_S, Int32, Int32, Int32);
+    scilab_fill_and(Int32, ScalarUInt32, int_M_S, Int32, UInt32, UInt32);
+    scilab_fill_and(Int32, ScalarInt64, int_M_S, Int32, Int64, Int64);
+    scilab_fill_and(Int32, ScalarUInt64, int_M_S, Int32, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt32, Int8, int_S_M, Int32, Int8, Int32);
+    scilab_fill_and(ScalarInt32, UInt8, int_S_M, Int32, UInt8, UInt32);
+    scilab_fill_and(ScalarInt32, Int16, int_S_M, Int32, Int16, Int32);
+    scilab_fill_and(ScalarInt32, UInt16, int_S_M, Int32, UInt16, UInt32);
+    scilab_fill_and(ScalarInt32, Int32, int_S_M, Int32, Int32, Int32);
+    scilab_fill_and(ScalarInt32, UInt32, int_S_M, Int32, UInt32, UInt32);
+    scilab_fill_and(ScalarInt32, Int64, int_S_M, Int32, Int64, Int64);
+    scilab_fill_and(ScalarInt32, UInt64, int_S_M, Int32, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt32, ScalarInt8, int_S_S, Int32, Int8, Int32);
+    scilab_fill_and(ScalarInt32, ScalarUInt8, int_S_S, Int32, UInt8, UInt32);
+    scilab_fill_and(ScalarInt32, ScalarInt16, int_S_S, Int32, Int16, Int32);
+    scilab_fill_and(ScalarInt32, ScalarUInt16, int_S_S, Int32, UInt16, UInt32);
+    scilab_fill_and(ScalarInt32, ScalarInt32, int_S_S, Int32, Int32, Int32);
+    scilab_fill_and(ScalarInt32, ScalarUInt32, int_S_S, Int32, UInt32, UInt32);
+    scilab_fill_and(ScalarInt32, ScalarInt64, int_S_S, Int32, Int64, Int64);
+    scilab_fill_and(ScalarInt32, ScalarUInt64, int_S_S, Int32, UInt64, UInt64);
+
+    //uint32
+    scilab_fill_and(UInt32, Int8, int_M_M, UInt32, Int8, UInt32);
+    scilab_fill_and(UInt32, UInt8, int_M_M, UInt32, UInt8, UInt32);
+    scilab_fill_and(UInt32, Int16, int_M_M, UInt32, Int16, UInt32);
+    scilab_fill_and(UInt32, UInt16, int_M_M, UInt32, UInt16, UInt32);
+    scilab_fill_and(UInt32, Int32, int_M_M, UInt32, Int32, UInt32);
+    scilab_fill_and(UInt32, UInt32, int_M_M, UInt32, UInt32, UInt32);
+    scilab_fill_and(UInt32, Int64, int_M_M, UInt32, Int64, UInt64);
+    scilab_fill_and(UInt32, UInt64, int_M_M, UInt32, UInt64, UInt64);
+
+    scilab_fill_and(UInt32, ScalarInt8, int_M_S, UInt32, Int8, UInt32);
+    scilab_fill_and(UInt32, ScalarUInt8, int_M_S, UInt32, UInt8, UInt32);
+    scilab_fill_and(UInt32, ScalarInt16, int_M_S, UInt32, Int16, UInt32);
+    scilab_fill_and(UInt32, ScalarUInt16, int_M_S, UInt32, UInt16, UInt32);
+    scilab_fill_and(UInt32, ScalarInt32, int_M_S, UInt32, Int32, UInt32);
+    scilab_fill_and(UInt32, ScalarUInt32, int_M_S, UInt32, UInt32, UInt32);
+    scilab_fill_and(UInt32, ScalarInt64, int_M_S, UInt32, Int64, UInt64);
+    scilab_fill_and(UInt32, ScalarUInt64, int_M_S, UInt32, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt32, Int8, int_S_M, UInt32, Int8, UInt32);
+    scilab_fill_and(ScalarUInt32, UInt8, int_S_M, UInt32, UInt8, UInt32);
+    scilab_fill_and(ScalarUInt32, Int16, int_S_M, UInt32, Int16, UInt32);
+    scilab_fill_and(ScalarUInt32, UInt16, int_S_M, UInt32, UInt16, UInt32);
+    scilab_fill_and(ScalarUInt32, Int32, int_S_M, UInt32, Int32, UInt32);
+    scilab_fill_and(ScalarUInt32, UInt32, int_S_M, UInt32, UInt32, UInt32);
+    scilab_fill_and(ScalarUInt32, Int64, int_S_M, UInt32, Int64, UInt64);
+    scilab_fill_and(ScalarUInt32, UInt64, int_S_M, UInt32, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt32, ScalarInt8, int_S_S, UInt32, Int8, UInt32);
+    scilab_fill_and(ScalarUInt32, ScalarUInt8, int_S_S, UInt32, UInt8, UInt32);
+    scilab_fill_and(ScalarUInt32, ScalarInt16, int_S_S, UInt32, Int16, UInt32);
+    scilab_fill_and(ScalarUInt32, ScalarUInt16, int_S_S, UInt32, UInt16, UInt32);
+    scilab_fill_and(ScalarUInt32, ScalarInt32, int_S_S, UInt32, Int32, UInt32);
+    scilab_fill_and(ScalarUInt32, ScalarUInt32, int_S_S, UInt32, UInt32, UInt32);
+    scilab_fill_and(ScalarUInt32, ScalarInt64, int_S_S, UInt32, Int64, UInt64);
+    scilab_fill_and(ScalarUInt32, ScalarUInt64, int_S_S, UInt32, UInt64, UInt64);
+
+    //int64
+    scilab_fill_and(Int64, Int8, int_M_M, Int64, Int8, Int64);
+    scilab_fill_and(Int64, UInt8, int_M_M, Int64, UInt8, UInt64);
+    scilab_fill_and(Int64, Int16, int_M_M, Int64, Int16, Int64);
+    scilab_fill_and(Int64, UInt16, int_M_M, Int64, UInt16, UInt64);
+    scilab_fill_and(Int64, Int32, int_M_M, Int64, Int32, Int64);
+    scilab_fill_and(Int64, UInt32, int_M_M, Int64, UInt32, UInt64);
+    scilab_fill_and(Int64, Int64, int_M_M, Int64, Int64, Int64);
+    scilab_fill_and(Int64, UInt64, int_M_M, Int64, UInt64, UInt64);
+
+    scilab_fill_and(Int64, ScalarInt8, int_M_S, Int64, Int8, Int64);
+    scilab_fill_and(Int64, ScalarUInt8, int_M_S, Int64, UInt8, UInt64);
+    scilab_fill_and(Int64, ScalarInt16, int_M_S, Int64, Int16, Int64);
+    scilab_fill_and(Int64, ScalarUInt16, int_M_S, Int64, UInt16, UInt64);
+    scilab_fill_and(Int64, ScalarInt32, int_M_S, Int64, Int32, Int64);
+    scilab_fill_and(Int64, ScalarUInt32, int_M_S, Int64, UInt32, UInt64);
+    scilab_fill_and(Int64, ScalarInt64, int_M_S, Int64, Int64, Int64);
+    scilab_fill_and(Int64, ScalarUInt64, int_M_S, Int64, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt64, Int8, int_S_M, Int64, Int8, Int64);
+    scilab_fill_and(ScalarInt64, UInt8, int_S_M, Int64, UInt8, UInt64);
+    scilab_fill_and(ScalarInt64, Int16, int_S_M, Int64, Int16, Int64);
+    scilab_fill_and(ScalarInt64, UInt16, int_S_M, Int64, UInt16, UInt64);
+    scilab_fill_and(ScalarInt64, Int32, int_S_M, Int64, Int32, Int64);
+    scilab_fill_and(ScalarInt64, UInt32, int_S_M, Int64, UInt32, UInt64);
+    scilab_fill_and(ScalarInt64, Int64, int_S_M, Int64, Int64, Int64);
+    scilab_fill_and(ScalarInt64, UInt64, int_S_M, Int64, UInt64, UInt64);
+
+    scilab_fill_and(ScalarInt64, ScalarInt8, int_S_S, Int64, Int8, Int64);
+    scilab_fill_and(ScalarInt64, ScalarUInt8, int_S_S, Int64, UInt8, UInt64);
+    scilab_fill_and(ScalarInt64, ScalarInt16, int_S_S, Int64, Int16, Int64);
+    scilab_fill_and(ScalarInt64, ScalarUInt16, int_S_S, Int64, UInt16, UInt64);
+    scilab_fill_and(ScalarInt64, ScalarInt32, int_S_S, Int64, Int32, Int64);
+    scilab_fill_and(ScalarInt64, ScalarUInt32, int_S_S, Int64, UInt32, UInt64);
+    scilab_fill_and(ScalarInt64, ScalarInt64, int_S_S, Int64, Int64, Int64);
+    scilab_fill_and(ScalarInt64, ScalarUInt64, int_S_S, Int64, UInt64, UInt64);
+
+    //uint64
+    scilab_fill_and(UInt64, Int8, int_M_M, UInt64, Int8, UInt64);
+    scilab_fill_and(UInt64, UInt8, int_M_M, UInt64, UInt8, UInt64);
+    scilab_fill_and(UInt64, Int16, int_M_M, UInt64, Int16, UInt64);
+    scilab_fill_and(UInt64, UInt16, int_M_M, UInt64, UInt16, UInt64);
+    scilab_fill_and(UInt64, Int32, int_M_M, UInt64, Int32, UInt64);
+    scilab_fill_and(UInt64, UInt32, int_M_M, UInt64, UInt32, UInt64);
+    scilab_fill_and(UInt64, Int64, int_M_M, UInt64, Int64, UInt64);
+    scilab_fill_and(UInt64, UInt64, int_M_M, UInt64, UInt64, UInt64);
+
+    scilab_fill_and(UInt64, ScalarInt8, int_M_S, UInt64, Int8, UInt64);
+    scilab_fill_and(UInt64, ScalarUInt8, int_M_S, UInt64, UInt8, UInt64);
+    scilab_fill_and(UInt64, ScalarInt16, int_M_S, UInt64, Int16, UInt64);
+    scilab_fill_and(UInt64, ScalarUInt16, int_M_S, UInt64, UInt16, UInt64);
+    scilab_fill_and(UInt64, ScalarInt32, int_M_S, UInt64, Int32, UInt64);
+    scilab_fill_and(UInt64, ScalarUInt32, int_M_S, UInt64, UInt32, UInt64);
+    scilab_fill_and(UInt64, ScalarInt64, int_M_S, UInt64, Int64, UInt64);
+    scilab_fill_and(UInt64, ScalarUInt64, int_M_S, UInt64, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt64, Int8, int_S_M, UInt64, Int8, UInt64);
+    scilab_fill_and(ScalarUInt64, UInt8, int_S_M, UInt64, UInt8, UInt64);
+    scilab_fill_and(ScalarUInt64, Int16, int_S_M, UInt64, Int16, UInt64);
+    scilab_fill_and(ScalarUInt64, UInt16, int_S_M, UInt64, UInt16, UInt64);
+    scilab_fill_and(ScalarUInt64, Int32, int_S_M, UInt64, Int32, UInt64);
+    scilab_fill_and(ScalarUInt64, UInt32, int_S_M, UInt64, UInt32, UInt64);
+    scilab_fill_and(ScalarUInt64, Int64, int_S_M, UInt64, Int64, UInt64);
+    scilab_fill_and(ScalarUInt64, UInt64, int_S_M, UInt64, UInt64, UInt64);
+
+    scilab_fill_and(ScalarUInt64, ScalarInt8, int_S_S, UInt64, Int8, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarUInt8, int_S_S, UInt64, UInt8, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarInt16, int_S_S, UInt64, Int16, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarUInt16, int_S_S, UInt64, UInt16, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarInt32, int_S_S, UInt64, Int32, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarUInt32, int_S_S, UInt64, UInt32, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarInt64, int_S_S, UInt64, Int64, UInt64);
+    scilab_fill_and(ScalarUInt64, ScalarUInt64, int_S_S, UInt64, UInt64, UInt64);
+
+    //boolean sparse
+    scilab_fill_and(SparseBool, SparseBool, M_M, SparseBool, SparseBool, SparseBool);
+    scilab_fill_and(Bool, SparseBool, M_M, Bool, SparseBool, SparseBool);
+    scilab_fill_and(SparseBool, Bool, M_M, SparseBool, Bool, SparseBool);
+    scilab_fill_and(ScalarBool, SparseBool, M_M, Bool, SparseBool, SparseBool);
+    scilab_fill_and(SparseBool, ScalarBool, M_M, SparseBool, Bool, SparseBool);
+
+#undef scilab_fill_and
+}
+
+// &&
+InternalType* GenericShortcutAnd(InternalType* _pL)
+{
+    InternalType* pResult = NULL;
+    if (_pL->isBool())
+    {
+        BoolAndBool(_pL->getAs<Bool>(), (Bool**)&pResult);
+    }
+
+    if (_pL->isInt())
+    {
+        IntAndInt(_pL, (Bool**)&pResult);
+    }
+
+    if (_pL->isSparseBool())
+    {
+        SparseBoolAndSparseBool(_pL, (Bool**)&pResult);
+    }
+
+    return pResult;
+}
+
+// &
+InternalType* GenericLogicalAnd(InternalType* _pL, InternalType* _pR)
+{
+    InternalType *pResult = NULL;
+
+    and_function bit_and = pAndfunction[_pL->getId()][_pR->getId()];
+    if (bit_and)
+    {
+        pResult = bit_and(_pL, _pR);
+        if (pResult)
+        {
+            return pResult;
+        }
+    }
+
+    /*
+    ** Default case : Return NULL will Call Overloading.
+    */
+    return NULL;
+}
+
+int BoolAndBool(Bool* _pL, Bool** _pOut)
+{
+    for (int i = 0 ; i < _pL->getSize() ; i++)
+    {
+        if (_pL->get(i) == 0)
+        {
+            //false && something -> false
+            *_pOut = new Bool(0);
+            return 0;
+        }
+    }
+
+    //call non shorcut opearion
+    *_pOut = NULL;
+    return 0;
+}
+
+template <class K>
+static int IntAndInt(K* _pL, Bool** _pOut)
+{
+    for (int i = 0 ; i < _pL->getSize() ; i++)
+    {
+        if (_pL->get(i) == 0)
+        {
+            //false && something -> false
+            *_pOut = new Bool(0);
+            return 0;
+        }
+    }
+
+    //call non shorcut opearion
+    *_pOut = NULL;
+    return 0;
+}
+
+int IntAndInt(InternalType* _pL, Bool** _pOut)
+{
+    switch (_pL->getType())
+    {
+        case InternalType::ScilabInt8 :
+        {
+            return IntAndInt(_pL->getAs<Int8>(), _pOut);
+        }
+        case InternalType::ScilabUInt8 :
+        {
+            return IntAndInt(_pL->getAs<UInt8>(), _pOut);
+        }
+        case InternalType::ScilabInt16 :
+        {
+            return IntAndInt(_pL->getAs<Int16>(), _pOut);
+        }
+        case InternalType::ScilabUInt16 :
+        {
+            return IntAndInt(_pL->getAs<UInt16>(), _pOut);
+        }
+        case InternalType::ScilabInt32 :
+        {
+            return IntAndInt(_pL->getAs<Int32>(), _pOut);
+        }
+        case InternalType::ScilabUInt32 :
+        {
+            return IntAndInt(_pL->getAs<UInt32>(), _pOut);
+        }
+        case InternalType::ScilabInt64 :
+        {
+            return IntAndInt(_pL->getAs<Int64>(), _pOut);
+        }
+        case InternalType::ScilabUInt64 :
+        {
+            return IntAndInt(_pL->getAs<UInt64>(), _pOut);
+        }
+        default:
+        {
+            return 3;
+        }
+    }
+}
+
+int SparseBoolAndSparseBool(InternalType* _pL, Bool** _pOut)
+{
+    SparseBool* pL = _pL->getAs<SparseBool>();
+    if (pL->nbTrue() != pL->getSize())
+    {
+        *_pOut = new Bool(0);
+        return 0;
+    }
+
+    *_pOut = NULL;
+    return 0;
+}
+
+
+template<class T, class U, class O>
+InternalType* and_M_M(T *_pL, U *_pR)
+{
+    int iDimsL = _pL->getDims();
+    int iDimsR = _pR->getDims();
+
+    if (iDimsL != iDimsR)
+    {
+        throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
+    }
+
+    int* piDimsL = _pL->getDimsArray();
+    int* piDimsR = _pR->getDimsArray();
+
+    for (int i = 0 ; i < iDimsL ; ++i)
+    {
+        if (piDimsL[i] != piDimsR[i])
+        {
+            throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
+        }
+    }
+
+    O* pOut = new O(iDimsL, piDimsL);
+
+    bit_and(_pL->get(), (long long)_pL->getSize(), _pR->get(), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_S_M(T *_pL, U *_pR)
+{
+    O* pOut = new O(_pR->getDims(), _pR->getDimsArray());
+    bit_and(_pL->get(0), (size_t)_pR->getSize(), _pR->get(), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_M_S(T *_pL, U *_pR)
+{
+    O* pOut = new O(_pL->getDims(), _pL->getDimsArray());
+    bit_and(_pL->get(), (size_t)_pL->getSize(), _pR->get(0), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_S_S(T *_pL, U *_pR)
+{
+    O* pOut = new O(_pL->getDims(), _pL->getDimsArray());
+    bit_and(_pL->get(0), _pR->get(0), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_M_E(T *_pL, U *_pR)
+{
+    return _pR;
+}
+
+template<class T, class U, class O>
+InternalType* and_E_M(T *_pL, U *_pR)
+{
+    return _pL;
+}
+
+template<class T, class U, class O>
+InternalType* and_I_S(T *_pL, U *_pR)
+{
+    return and_S_S<U, T, O>(_pR, _pL);
+}
+
+template<class T, class U, class O>
+InternalType* and_I_M(T *_pL, U *_pR)
+{
+    return and_M_S<U, T, O>(_pR, _pL);
+}
+
+
+template<class T, class U, class O>
+InternalType* and_int_M_M(T *_pL, U *_pR)
+{
+    int iDimsL = _pL->getDims();
+    int iDimsR = _pR->getDims();
+
+    if (iDimsL != iDimsR)
+    {
+        throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
+    }
+
+    int* piDimsL = _pL->getDimsArray();
+    int* piDimsR = _pR->getDimsArray();
+
+    for (int i = 0 ; i < iDimsL ; ++i)
+    {
+        if (piDimsL[i] != piDimsR[i])
+        {
+            throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
+        }
+    }
+
+    O* pOut = new O(iDimsL, piDimsL);
+
+    int_and(_pL->get(), (long long)_pL->getSize(), _pR->get(), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_int_S_M(T *_pL, U *_pR)
+{
+    O* pOut = new O(_pR->getDims(), _pR->getDimsArray());
+    int_and(_pL->get(0), (size_t)_pR->getSize(), _pR->get(), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_int_M_S(T *_pL, U *_pR)
+{
+    O* pOut = new O(_pL->getDims(), _pL->getDimsArray());
+    int_and(_pL->get(), (size_t)_pL->getSize(), _pR->get(0), pOut->get());
+    return pOut;
+}
+
+template<class T, class U, class O>
+InternalType* and_int_S_S(T *_pL, U *_pR)
+{
+    O* pOut = new O(_pL->getDims(), _pL->getDimsArray());
+    int_and(_pL->get(0), _pR->get(0), pOut->get());
+    return pOut;
+}
+
+//boolean sparse
+template<>
+InternalType* and_M_M<SparseBool, SparseBool, SparseBool>(SparseBool* _pL, SparseBool* _pR)
+{
+    SparseBool* pOut = NULL;
+    if (_pL->isScalar())
+    {
+        if (_pL->get(0, 0))
+        {
+            pOut = _pR;
+        }
+        else
+        {
+            pOut = new SparseBool(_pR->getRows(), _pR->getCols());
+        }
+
+        return pOut;
+    }
+
+    if (_pR->isScalar())
+    {
+        if (_pR->get(0, 0))
+        {
+            pOut = _pL;
+        }
+        else
+        {
+            pOut = new SparseBool(_pL->getRows(), _pL->getCols());
+        }
+
+        return pOut;
+    }
+
+    if (_pL->getRows() != _pR->getRows() || _pL->getCols() != _pR->getCols())
+    {
+        throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
+    }
+
+    return _pL->newLogicalAnd(*_pR);
+}
+
+template<>
+InternalType* and_M_M<SparseBool, Bool, SparseBool>(SparseBool* _pL, Bool* _pR)
+{
+    SparseBool* pR = new SparseBool(*_pR);
+    InternalType* pOut = and_M_M<SparseBool, SparseBool, SparseBool>(_pL, pR);
+    delete pR;
+    return pOut;
+}
+
+template<>
+InternalType* and_M_M<Bool, SparseBool, SparseBool>(Bool* _pL, SparseBool* _pR)
+{
+    SparseBool* pL = new SparseBool(*_pL);
+    InternalType* pOut = and_M_M<SparseBool, SparseBool, SparseBool>(pL, _pR);
+    delete pL;
+    return pOut;
+}
+
@@ -16,87 +16,13 @@ extern "C"
 #include "os_swprintf.h"
 }
 
-#include "types_or_and.hxx"
+#include "types_or.hxx"
 #include "int.hxx"
 #include "bool.hxx"
 #include "sparse.hxx"
 
-
 using namespace types;
 
-// &&
-InternalType* GenericShortcutAnd(InternalType* _pL)
-{
-    InternalType* pResult = NULL;
-    if (_pL->isBool())
-    {
-        BoolAndBool(_pL->getAs<Bool>(), (Bool**)&pResult);
-    }
-
-    if (_pL->isInt())
-    {
-        IntAndInt(_pL, (Bool**)&pResult);
-    }
-
-    if (_pL->isSparseBool())
-    {
-        SparseBoolAndSparseBool(_pL, (Bool**)&pResult);
-    }
-
-    return pResult;
-}
-
-// &
-InternalType* GenericLogicalAnd(InternalType* _pL, InternalType* _pR)
-{
-    InternalType* pResult = NULL;
-
-    if (_pL->isBool() && _pR->isBool())
-    {
-        Bool *pL = (Bool*)_pL;
-        Bool *pR = (Bool*)_pR;
-
-        int iResult = BoolLogicalAndBool(pL, pR, (Bool**)&pResult);
-        if (iResult != 0)
-        {
-            wchar_t pMsg[bsiz];
-            os_swprintf(pMsg, bsiz, _W("Error: operator %ls: Matrix dimensions must agree (op1 is %ls, op2 is %ls).\n").c_str(), L"&", pL->DimToString().c_str(), pR->DimToString().c_str());
-            throw ast::ScilabError(pMsg);
-        }
-        return pResult;
-    }
-
-    if (_pL->isInt() && _pR->isInt())
-    {
-        int iResult = IntLogicalAndInt(_pL, _pR, &pResult);
-        if (iResult != 0)
-        {
-            GenericType* pL = _pL->getAs<GenericType>();
-            GenericType* pR = _pR->getAs<GenericType>();
-            wchar_t pMsg[bsiz];
-            os_swprintf(pMsg, bsiz, _W("Error: operator %ls: Matrix dimensions must agree (op1 is %ls, op2 is %ls).\n").c_str(), L"&", pL->DimToString().c_str(), pR->DimToString().c_str());
-            throw ast::ScilabError(pMsg);
-        }
-        return pResult;
-    }
-
-    if (_pL->isSparseBool() && _pR->isSparseBool())
-    {
-        int iResult = SparseBoolLogicalAndSparseBool(_pL, _pR, &pResult);
-        if (iResult != 0)
-        {
-            GenericType* pL = _pL->getAs<GenericType>();
-            GenericType* pR = _pR->getAs<GenericType>();
-            wchar_t pMsg[bsiz];
-            os_swprintf(pMsg, bsiz, _W("Error: operator %ls: Matrix dimensions must agree (op1 is %ls, op2 is %ls).\n").c_str(), L"&", pL->DimToString().c_str(), pR->DimToString().c_str());
-            throw ast::ScilabError(pMsg);
-        }
-        return pResult;
-    }
-
-    return NULL;
-}
-
 // ||
 InternalType* GenericShortcutOr(InternalType* _pL)
 {
@@ -171,23 +97,6 @@ InternalType* GenericLogicalOr(InternalType* _pL, InternalType* _pR)
     return NULL;
 }
 
-int BoolAndBool(Bool* _pL, Bool** _pOut)
-{
-    for (int i = 0 ; i < _pL->getSize() ; i++)
-    {
-        if (_pL->get(i) == 0)
-        {
-            //false && something -> false
-            *_pOut = new Bool(0);
-            return 0;
-        }
-    }
-
-    //call non shorcut opearion
-    *_pOut = NULL;
-    return 0;
-}
-
 int BoolOrBool(Bool* _pL, Bool** _pOut)
 {
     for (int i = 0 ; i < _pL->getSize() ; i++)
@@ -265,171 +174,6 @@ int IntOrInt(InternalType* _pL, Bool** _pOut)
 }
 
 template <class K>
-static int IntAndInt(K* _pL, Bool** _pOut)
-{
-    for (int i = 0 ; i < _pL->getSize() ; i++)
-    {
-        if (_pL->get(i) == 0)
-        {
-            //false && something -> false
-            *_pOut = new Bool(0);
-            return 0;
-        }
-    }
-
-    //call non shorcut opearion
-    *_pOut = NULL;
-    return 0;
-}
-
-int IntAndInt(InternalType* _pL, Bool** _pOut)
-{
-    switch (_pL->getType())
-    {
-        case InternalType::ScilabInt8 :
-        {
-            return IntAndInt(_pL->getAs<Int8>(), _pOut);
-        }
-        case InternalType::ScilabUInt8 :
-        {
-            return IntAndInt(_pL->getAs<UInt8>(), _pOut);
-        }
-        case InternalType::ScilabInt16 :
-        {
-            return IntAndInt(_pL->getAs<Int16>(), _pOut);
-        }
-        case InternalType::ScilabUInt16 :
-        {
-            return IntAndInt(_pL->getAs<UInt16>(), _pOut);
-        }
-        case InternalType::ScilabInt32 :
-        {
-            return IntAndInt(_pL->getAs<Int32>(), _pOut);
-        }
-        case InternalType::ScilabUInt32 :
-        {
-            return IntAndInt(_pL->getAs<UInt32>(), _pOut);
-        }
-        case InternalType::ScilabInt64 :
-        {
-            return IntAndInt(_pL->getAs<Int64>(), _pOut);
-        }
-        case InternalType::ScilabUInt64 :
-        {
-            return IntAndInt(_pL->getAs<UInt64>(), _pOut);
-        }
-        default:
-        {
-            return 3;
-        }
-    }
-}
-
-template <class K>
-static int IntLogicalAndInt(K* _pL, K* _pR, InternalType** _pOut)
-{
-    // left scalar bitwise and right matrix
-    if (_pL->isScalar())
-    {
-        K *pI = new K(_pR->getDims(), _pR->getDimsArray());
-        const typename K::type x = _pL->get(0);
-
-        for (int i = 0 ; i < pI->getSize() ; i++)
-        {
-            pI->set(i, x & _pR->get(i));
-        }
-
-        *_pOut = pI;
-        return 0;
-    }
-
-    // right scalar bitwise and left matrix
-    if (_pR->isScalar())
-    {
-        K *pI = new K(_pL->getDims(), _pL->getDimsArray());
-        const typename K::type x = _pL->get(0);
-
-        for (int i = 0 ; i < pI->getSize() ; i++)
-        {
-            pI->set(i, x & _pL->get(i));
-        }
-
-        *_pOut = pI;
-        return 0;
-    }
-
-    // check dims
-    if (_pL->getDims() != _pR->getDims())
-    {
-        return 1;
-    }
-
-    int* piDimsL = _pL->getDimsArray();
-    int* piDimsR = _pR->getDimsArray();
-
-    for (int i = 0 ; i < _pL->getDims() ; i++)
-    {
-        if (piDimsL[i] != piDimsR[i])
-        {
-            return 1;
-        }
-    }
-
-    // left matrix bitwise and right matrix
-    K* pI = new K(_pR->getDims(), _pR->getDimsArray());
-    for (int i = 0 ; i < _pL->getSize() ; i++)
-    {
-        pI->set(i, _pL->get(i) & _pR->get(i));
-    }
-
-    *_pOut = pI;
-    return 0;
-}
-
-int IntLogicalAndInt(InternalType* _pL, InternalType*  _pR, InternalType** _pOut)
-{
-    switch (_pL->getType())
-    {
-        case InternalType::ScilabInt8 :
-        {
-            return IntLogicalAndInt(_pL->getAs<Int8>(), _pR->getAs<Int8>(), _pOut);
-        }
-        case InternalType::ScilabUInt8 :
-        {
-            return IntLogicalAndInt(_pL->getAs<UInt8>(), _pR->getAs<UInt8>(), _pOut);
-        }
-        case InternalType::ScilabInt16 :
-        {
-            return IntLogicalAndInt(_pL->getAs<Int16>(), _pR->getAs<Int16>(), _pOut);
-        }
-        case InternalType::ScilabUInt16 :
-        {
-            return IntLogicalAndInt(_pL->getAs<UInt16>(), _pR->getAs<UInt16>(), _pOut);
-        }
-        case InternalType::ScilabInt32 :
-        {
-            return IntLogicalAndInt(_pL->getAs<Int32>(), _pR->getAs<Int32>(), _pOut);
-        }
-        case InternalType::ScilabUInt32 :
-        {
-            return IntLogicalAndInt(_pL->getAs<UInt32>(), _pR->getAs<UInt32>(), _pOut);
-        }
-        case InternalType::ScilabInt64 :
-        {
-            return IntLogicalAndInt(_pL->getAs<Int64>(), _pR->getAs<Int64>(), _pOut);
-        }
-        case InternalType::ScilabUInt64 :
-        {
-            return IntLogicalAndInt(_pL->getAs<UInt64>(), _pR->getAs<UInt64>(), _pOut);
-        }
-        default:
-        {
-            return 3;
-        }
-    }
-}
-
-template <class K>
 static int IntLogicalOrInt(K* _pL, K* _pR, InternalType** _pOut)
 {
     // left scalar bitwise or right matrix
@@ -608,120 +352,6 @@ int BoolLogicalOrBool(Bool* _pL, Bool*  _pR, Bool** _pOut)
     return 0;
 }
 
-int BoolLogicalAndBool(Bool* _pL, Bool*  _pR, Bool** _pOut)
-{
-    int* piR = _pR->get();
-    int* piL = _pL->get();
-    int* piB = NULL;
-
-    // M & scalar
-    if (_pR->getSize() == 1)
-    {
-        *_pOut = new Bool(_pL->getDims(), _pL->getDimsArray());
-        piB = (*_pOut)->get();
-        for (int i = 0 ; i < _pL->getSize(); i++)
-        {
-            piB[i] = (piR[0] == 1) && (piL[i] == 1);
-        }
-
-        return 0;
-    }
-
-    if (_pL->getSize() == 1)
-    {
-        // scalar & M
-        *_pOut = new Bool(_pR->getDims(), _pR->getDimsArray());
-        piB = (*_pOut)->get();
-        for (int i = 0 ; i < _pR->getSize(); i++)
-        {
-            piB[i] = (piR[i] == 1) && (piL[0] == 1);
-        }
-
-        return 0;
-    }
-
-    if (_pL->getDims() != _pR->getDims())
-    {
-        return 1;
-    }
-
-    int* piDimsL = _pL->getDimsArray();
-    int* piDimsR = _pR->getDimsArray();
-
-    for (int i = 0; i < _pL->getDims(); i++)
-    {
-        if (piDimsL[i] != piDimsR[i])
-        {
-            return 1;
-        }
-    }
-
-    // M & N (generic case)
-    *_pOut = new Bool(_pR->getDims(), piDimsR);
-    piB = (*_pOut)->get();
-    for (int i = 0 ; i < _pR->getSize(); i++)
-    {
-        piB[i] = (piR[i] == 1) && (piL[i] == 1);
-    }
-
-    return 0;
-}
-
-int SparseBoolAndSparseBool(InternalType* _pL, Bool** _pOut)
-{
-    SparseBool* pL = _pL->getAs<SparseBool>();
-    if (pL->nbTrue() != pL->getSize())
-    {
-        *_pOut = new Bool(0);
-        return 0;
-    }
-
-    *_pOut = NULL;
-    return 0;
-}
-
-int SparseBoolLogicalAndSparseBool(InternalType* _pL, InternalType*  _pR, InternalType** _pOut)
-{
-    SparseBool *pL = (SparseBool*)_pL;
-    SparseBool *pR = (SparseBool*)_pR;
-
-    if (pL->isScalar())
-    {
-        if (pL->get(0, 0))
-        {
-            *_pOut = pR->clone();
-        }
-        else
-        {
-            *_pOut = new SparseBool(pR->getRows(), pR->getCols());
-        }
-
-        return 0;
-    }
-
-    if (pR->isScalar())
-    {
-        if (pR->get(0, 0))
-        {
-            *_pOut = _pL->clone();
-        }
-        else
-        {
-            *_pOut = new SparseBool(pL->getRows(), pL->getCols());
-        }
-
-        return 0;
-    }
-
-    if (pL->getRows() == pR->getRows() && pL->getCols() == pR->getCols())
-    {
-        *_pOut = pL->newLogicalAnd(*pR);
-        return 0;
-    }
-
-    return 1;
-}
-
 int SparseBoolOrSparseBool(InternalType* _pL, Bool** _pOut)
 {
     SparseBool* pL = _pL->getAs<SparseBool>();
diff --git a/scilab/modules/ast/tests/unit_tests/and.dia.ref b/scilab/modules/ast/tests/unit_tests/and.dia.ref
new file mode 100644 (file)
index 0000000..b9a2a8d
--- /dev/null
@@ -0,0 +1,226 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+//
+// <-- JVM NOT MANDATORY -->
+empty = [];
+r = 2;
+R = [1,2;3,4];
+R3(:,:,1) = R;
+R3(:,:,2) = R';
+c = 1 + 2*%i;
+C = [1+2*%i,2+4*%i;3+6*%i,4+8*%i];
+C3(:,:,1) = C;
+C3(:,:,2) = C';
+e = eye();
+ec = (5+%i) * eye();
+p = 1 + %s - %s**2;
+pc = 1 + %s - %s**2 + ( 2 - 3 * %s + 4 * %s**2 ) * %i;
+P = [2*p, -3*p;4*p,-5*p];
+PC = [2*pc, -3*pc;4*pc,-5*pc];
+SP = sparse([1,2;4,5;3,10],[1,2,3]);
+SPC = sparse([1,2;4,5;3,10],[1,2,3]) * ( 1 + 4*%i);
+SPB = sparse([1,2;2,1],[%t;%t],[2,2]);
+i8 = int8(-8);
+ui8 = uint8(8);
+I8 = int8([-8 -16 ; -24 -32]);
+UI8 = uint8([8 16 ; 24 32]);
+I16 = int16([-16 -32 ; -48 -64]);
+UI16 = uint16([16 32 ; 48 64]);
+i16 = int16(-16);
+ui16 = uint16(16);
+i32 = int32(-32);
+ui32 = uint32(32);
+I32 = int32([-32 -64 ; -96 -128]);
+UI32 = uint32([32 64 ; 96 128]);
+str = "string";
+STR = ["string1" "string2";"string3" "string4"];
+b = %f;
+B = [%t %f;%f %t];
+assert_checkequal(empty & empty, []);
+assert_checkequal(empty & r, []);
+assert_checkequal(empty & R, []);
+assert_checkequal(empty & e, []);
+assert_checkequal(empty & b, []);
+assert_checkequal(empty & B, []);
+assert_checkequal(r & empty, []);
+assert_checkequal(r & r, %t);
+assert_checkequal(r & R, [%t,%t;%t,%t]);
+assert_checkequal(r & e, %t);
+assert_checkequal(r & b, %f);
+assert_checkequal(r & B, [%t,%f;%f,%t]);
+assert_checkequal(R & empty, []);
+assert_checkequal(R & r, [%t,%t;%t,%t]);
+assert_checkequal(R & R, [%t,%t;%t,%t]);
+assert_checkequal(R & e, [%t,%t;%t,%t]);
+assert_checkequal(R & b, [%f,%f;%f,%f]);
+assert_checkequal(R & B, [%t,%f;%f,%t]);
+assert_checkequal(e & empty, []);
+assert_checkequal(e & r, %t);
+assert_checkequal(e & R, [%t,%t;%t,%t]);
+assert_checkequal(e & b, %f);
+assert_checkequal(e & B, [%t,%f;%f,%t]);
+assert_checkequal(b & empty, []);
+assert_checkequal(b & r, %f);
+assert_checkequal(b & R, [%f,%f;%f,%f]);
+assert_checkequal(b & e, %f);
+assert_checkequal(b & b, %f);
+assert_checkequal(b & B, [%f,%f;%f,%f]);
+assert_checkequal(b & SPB, sparse([1,1], [%f], [2, 2]));
+assert_checkequal(B & empty, []);
+assert_checkequal(B & r, [%t,%f;%f,%t]);
+assert_checkequal(B & R, [%t,%f;%f,%t]);
+assert_checkequal(B & e, [%t,%f;%f,%t]);
+assert_checkequal(B & b, [%f,%f;%f,%f]);
+assert_checkequal(B & B, [%t,%f;%f,%t]);
+assert_checkequal(B & SPB, sparse([1,1], [%f], [2, 2]));
+assert_checkequal(SPB & b, sparse([1,1], [%f], [2, 2]));
+assert_checkequal(SPB & B, sparse([1,1], [%f], [2, 2]));
+assert_checkequal(SPB & SPB, sparse([1,2;2,1],[%t;%t],[2,2]));
+assert_checkequal(i8 & i8, int8(-8));
+assert_checkequal(i8 & I8, int8([-8,-16;-24,-32]));
+assert_checkequal(i8 & ui8, uint8(8));
+assert_checkequal(i8 & UI8, uint8([8,16;24,32]));
+assert_checkequal(i8 & i16, int16(-16));
+assert_checkequal(i8 & I16, int16([-16,-32;-48,-64]));
+assert_checkequal(i8 & ui16, uint16(16));
+assert_checkequal(i8 & UI16, uint16([16,32;48,64]));
+assert_checkequal(i8 & i32, int32(-32));
+assert_checkequal(i8 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(i8 & ui32, uint32(32));
+assert_checkequal(i8 & UI32, uint32([32,64;96,128]));
+assert_checkequal(I8 & i8, int8([-8,-16;-24,-32]));
+assert_checkequal(I8 & I8, int8([-8,-16;-24,-32]));
+assert_checkequal(I8 & ui8, uint8([8,0;8,0]));
+assert_checkequal(I8 & UI8, uint8([8,16;8,32]));
+assert_checkequal(I8 & i16, int16([-16,-16;-32,-32]));
+assert_checkequal(I8 & I16, int16([-16,-32;-64,-64]));
+assert_checkequal(I8 & ui16, uint16([16,16;0,0]));
+assert_checkequal(I8 & UI16, uint16([16,32;32,64]));
+assert_checkequal(I8 & i32, int32([-32,-32;-32,-32]));
+assert_checkequal(I8 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(I8 & ui32, uint32([32,32;32,32]));
+assert_checkequal(I8 & UI32, uint32([32,64;96,128]));
+assert_checkequal(ui8 & i8, uint8(8));
+assert_checkequal(ui8 & I8, uint8([8,0;8,0]));
+assert_checkequal(ui8 & ui8, uint8(8));
+assert_checkequal(ui8 & UI8, uint8([8,0;8,0]));
+assert_checkequal(ui8 & i16, uint16(0));
+assert_checkequal(ui8 & I16, uint16([0,0;0,0]));
+assert_checkequal(ui8 & ui16, uint16(0));
+assert_checkequal(ui8 & UI16, uint16([0,0;0,0]));
+assert_checkequal(ui8 & i32, uint32(0));
+assert_checkequal(ui8 & I32, uint32([0,0;0,0]));
+assert_checkequal(ui8 & ui32, uint32(0));
+assert_checkequal(ui8 & UI32, uint32([0,0;0,0]));
+assert_checkequal(UI8 & i8, uint8([8,16;24,32]));
+assert_checkequal(UI8 & I8, uint8([8,16;8,32]));
+assert_checkequal(UI8 & ui8, uint8([8,0;8,0]));
+assert_checkequal(UI8 & UI8, uint8([8,16;24,32]));
+assert_checkequal(UI8 & i16, uint16([0,16;16,32]));
+assert_checkequal(UI8 & I16, uint16([0,0;16,0]));
+assert_checkequal(UI8 & ui16, uint16([0,16;16,0]));
+assert_checkequal(UI8 & UI16, uint16([0,0;16,0]));
+assert_checkequal(UI8 & i32, uint32([0,0;0,32]));
+assert_checkequal(UI8 & I32, uint32([0,0;0,0]));
+assert_checkequal(UI8 & ui32, uint32([0,0;0,32]));
+assert_checkequal(UI8 & UI32, uint32([0,0;0,0]));
+assert_checkequal(i16 & i8, int16(-16));
+assert_checkequal(i16 & I8, int16([-16,-16;-32,-32]));
+assert_checkequal(i16 & ui8, uint16(0));
+assert_checkequal(i16 & UI8, uint16([0,16;16,32]));
+assert_checkequal(i16 & i16, int16(-16));
+assert_checkequal(i16 & I16, int16([-16,-32;-48,-64]));
+assert_checkequal(i16 & ui16, uint16(16));
+assert_checkequal(i16 & UI16, uint16([16,32;48,64]));
+assert_checkequal(i16 & i32, int32(-32));
+assert_checkequal(i16 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(i16 & ui32, uint32(32));
+assert_checkequal(i16 & UI32, uint32([32,64;96,128]));
+assert_checkequal(I16 & i8, int16([-16,-32;-48,-64]));
+assert_checkequal(I16 & I8, int16([-16,-32;-64,-64]));
+assert_checkequal(I16 & ui8, uint16([0,0;0,0]));
+assert_checkequal(I16 & UI8, uint16([0,0;16,0]));
+assert_checkequal(I16 & i16, int16([-16,-32;-48,-64]));
+assert_checkequal(I16 & I16, int16([-16,-32;-48,-64]));
+assert_checkequal(I16 & ui16, uint16([16,0;16,0]));
+assert_checkequal(I16 & UI16, uint16([16,32;16,64]));
+assert_checkequal(I16 & i32, int32([-32,-32;-64,-64]));
+assert_checkequal(I16 & I32, int32([-32,-64;-128,-128]));
+assert_checkequal(I16 & ui32, uint32([32,32;0,0]));
+assert_checkequal(I16 & UI32, uint32([32,64;64,128]));
+assert_checkequal(ui16 & i8, uint16(16));
+assert_checkequal(ui16 & I8, uint16([16,16;0,0]));
+assert_checkequal(ui16 & ui8, uint16(0));
+assert_checkequal(ui16 & UI8, uint16([0,16;16,0]));
+assert_checkequal(ui16 & i16, uint16(16));
+assert_checkequal(ui16 & I16, uint16([16,0;16,0]));
+assert_checkequal(ui16 & ui16, uint16(16));
+assert_checkequal(ui16 & UI16, uint16([16,0;16,0]));
+assert_checkequal(ui16 & i32, uint32(0));
+assert_checkequal(ui16 & I32, uint32([0,0;0,0]));
+assert_checkequal(ui16 & ui32, uint32(0));
+assert_checkequal(ui16 & UI32, uint32([0,0;0,0]));
+assert_checkequal(UI16 & i8, uint16([16,32;48,64]));
+assert_checkequal(UI16 & I8, uint16([16,32;32,64]));
+assert_checkequal(UI16 & ui8, uint16([0,0;0,0]));
+assert_checkequal(UI16 & UI8, uint16([0,0;16,0]));
+assert_checkequal(UI16 & i16, uint16([16,32;48,64]));
+assert_checkequal(UI16 & I16, uint16([16,32;16,64]));
+assert_checkequal(UI16 & ui16, uint16([16,0;16,0]));
+assert_checkequal(UI16 & UI16, uint16([16,32;48,64]));
+assert_checkequal(UI16 & i32, uint32([0,32;32,64]));
+assert_checkequal(UI16 & I32, uint32([0,0;32,0]));
+assert_checkequal(UI16 & ui32, uint32([0,32;32,0]));
+assert_checkequal(UI16 & UI32, uint32([0,0;32,0]));
+assert_checkequal(i32 & i8, int32(-32));
+assert_checkequal(i32 & I8, int32([-32,-32;-32,-32]));
+assert_checkequal(i32 & ui8, uint32(0));
+assert_checkequal(i32 & UI8, uint32([0,0;0,32]));
+assert_checkequal(i32 & i16, int32(-32));
+assert_checkequal(i32 & I16, int32([-32,-32;-64,-64]));
+assert_checkequal(i32 & ui16, uint32(0));
+assert_checkequal(i32 & UI16, uint32([0,32;32,64]));
+assert_checkequal(i32 & i32, int32(-32));
+assert_checkequal(i32 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(i32 & ui32, uint32(32));
+assert_checkequal(i32 & UI32, uint32([32,64;96,128]));
+assert_checkequal(I32 & i8, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & I8, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & ui8, uint32([0,0;0,0]));
+assert_checkequal(I32 & UI8, uint32([0,0;0,0]));
+assert_checkequal(I32 & i16, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & I16, int32([-32,-64;-128,-128]));
+assert_checkequal(I32 & ui16, uint32([0,0;0,0]));
+assert_checkequal(I32 & UI16, uint32([0,0;32,0]));
+assert_checkequal(I32 & i32, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & ui32, uint32([32,0;32,0]));
+assert_checkequal(I32 & UI32, uint32([32,64;32,128]));
+assert_checkequal(ui32 & i8, uint32(32));
+assert_checkequal(ui32 & I8, uint32([32,32;32,32]));
+assert_checkequal(ui32 & ui8, uint32(0));
+assert_checkequal(ui32 & UI8, uint32([0,0;0,32]));
+assert_checkequal(ui32 & i16, uint32(32));
+assert_checkequal(ui32 & I16, uint32([32,32;0,0]));
+assert_checkequal(ui32 & ui16, uint32(0));
+assert_checkequal(ui32 & UI16, uint32([0,32;32,0]));
+assert_checkequal(ui32 & i32, uint32(32));
+assert_checkequal(ui32 & I32, uint32([32,0;32,0]));
+assert_checkequal(ui32 & ui32, uint32(32));
+assert_checkequal(ui32 & UI32, uint32([32,0;32,0]));
+assert_checkequal(UI32 & i8, uint32([32,64;96,128]));
+assert_checkequal(UI32 & I8, uint32([32,64;96,128]));
+assert_checkequal(UI32 & ui8, uint32([0,0;0,0]));
+assert_checkequal(UI32 & UI8, uint32([0,0;0,0]));
+assert_checkequal(UI32 & i16, uint32([32,64;96,128]));
+assert_checkequal(UI32 & I16, uint32([32,64;64,128]));
+assert_checkequal(UI32 & ui16, uint32([0,0;0,0]));
+assert_checkequal(UI32 & UI16, uint32([0,0;32,0]));
+assert_checkequal(UI32 & i32, uint32([32,64;96,128]));
+assert_checkequal(UI32 & I32, uint32([32,64;32,128]));
+assert_checkequal(UI32 & ui32, uint32([32,0;32,0]));
+assert_checkequal(UI32 & UI32, uint32([32,64;96,128]));
diff --git a/scilab/modules/ast/tests/unit_tests/and.tst b/scilab/modules/ast/tests/unit_tests/and.tst
new file mode 100644 (file)
index 0000000..153fae2
--- /dev/null
@@ -0,0 +1,251 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+//
+// <-- JVM NOT MANDATORY -->
+
+empty = [];
+r = 2;
+R = [1,2;3,4];
+R3(:,:,1) = R;
+R3(:,:,2) = R';
+c = 1 + 2*%i;
+C = [1+2*%i,2+4*%i;3+6*%i,4+8*%i];
+C3(:,:,1) = C;
+C3(:,:,2) = C';
+e = eye();
+ec = (5+%i) * eye();
+p = 1 + %s - %s**2;
+pc = 1 + %s - %s**2 + ( 2 - 3 * %s + 4 * %s**2 ) * %i;
+P = [2*p, -3*p;4*p,-5*p];
+PC = [2*pc, -3*pc;4*pc,-5*pc];
+SP = sparse([1,2;4,5;3,10],[1,2,3]);
+SPC = sparse([1,2;4,5;3,10],[1,2,3]) * ( 1 + 4*%i);
+SPB = sparse([1,2;2,1],[%t;%t],[2,2]);
+
+i8 = int8(-8);
+ui8 = uint8(8);
+I8 = int8([-8 -16 ; -24 -32]);
+UI8 = uint8([8 16 ; 24 32]);
+
+I16 = int16([-16 -32 ; -48 -64]);
+UI16 = uint16([16 32 ; 48 64]);
+i16 = int16(-16);
+ui16 = uint16(16);
+
+i32 = int32(-32);
+ui32 = uint32(32);
+I32 = int32([-32 -64 ; -96 -128]);
+UI32 = uint32([32 64 ; 96 128]);
+
+str = "string";
+STR = ["string1" "string2";"string3" "string4"];
+
+b = %f;
+B = [%t %f;%f %t];
+
+assert_checkequal(empty & empty, []);
+assert_checkequal(empty & r, []);
+assert_checkequal(empty & R, []);
+assert_checkequal(empty & e, []);
+assert_checkequal(empty & b, []);
+assert_checkequal(empty & B, []);
+
+assert_checkequal(r & empty, []);
+assert_checkequal(r & r, %t);
+assert_checkequal(r & R, [%t,%t;%t,%t]);
+assert_checkequal(r & e, %t);
+assert_checkequal(r & b, %f);
+assert_checkequal(r & B, [%t,%f;%f,%t]);
+
+assert_checkequal(R & empty, []);
+assert_checkequal(R & r, [%t,%t;%t,%t]);
+assert_checkequal(R & R, [%t,%t;%t,%t]);
+assert_checkequal(R & e, [%t,%t;%t,%t]);
+assert_checkequal(R & b, [%f,%f;%f,%f]);
+assert_checkequal(R & B, [%t,%f;%f,%t]);
+
+assert_checkequal(e & empty, []);
+assert_checkequal(e & r, %t);
+assert_checkequal(e & R, [%t,%t;%t,%t]);
+assert_checkequal(e & b, %f);
+assert_checkequal(e & B, [%t,%f;%f,%t]);
+
+assert_checkequal(b & empty, []);
+assert_checkequal(b & r, %f);
+assert_checkequal(b & R, [%f,%f;%f,%f]);
+assert_checkequal(b & e, %f);
+assert_checkequal(b & b, %f);
+assert_checkequal(b & B, [%f,%f;%f,%f]);
+assert_checkequal(b & SPB, sparse([1,1], [%f], [2, 2]));
+
+assert_checkequal(B & empty, []);
+assert_checkequal(B & r, [%t,%f;%f,%t]);
+assert_checkequal(B & R, [%t,%f;%f,%t]);
+assert_checkequal(B & e, [%t,%f;%f,%t]);
+assert_checkequal(B & b, [%f,%f;%f,%f]);
+assert_checkequal(B & B, [%t,%f;%f,%t]);
+assert_checkequal(B & SPB, sparse([1,1], [%f], [2, 2]));
+
+assert_checkequal(SPB & b, sparse([1,1], [%f], [2, 2]));
+assert_checkequal(SPB & B, sparse([1,1], [%f], [2, 2]));
+assert_checkequal(SPB & SPB, sparse([1,2;2,1],[%t;%t],[2,2]));
+
+assert_checkequal(i8 & i8, int8(-8));
+assert_checkequal(i8 & I8, int8([-8,-16;-24,-32]));
+assert_checkequal(i8 & ui8, uint8(8));
+assert_checkequal(i8 & UI8, uint8([8,16;24,32]));
+assert_checkequal(i8 & i16, int16(-16));
+assert_checkequal(i8 & I16, int16([-16,-32;-48,-64]));
+assert_checkequal(i8 & ui16, uint16(16));
+assert_checkequal(i8 & UI16, uint16([16,32;48,64]));
+assert_checkequal(i8 & i32, int32(-32));
+assert_checkequal(i8 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(i8 & ui32, uint32(32));
+assert_checkequal(i8 & UI32, uint32([32,64;96,128]));
+
+assert_checkequal(I8 & i8, int8([-8,-16;-24,-32]));
+assert_checkequal(I8 & I8, int8([-8,-16;-24,-32]));
+assert_checkequal(I8 & ui8, uint8([8,0;8,0]));
+assert_checkequal(I8 & UI8, uint8([8,16;8,32]));
+assert_checkequal(I8 & i16, int16([-16,-16;-32,-32]));
+assert_checkequal(I8 & I16, int16([-16,-32;-64,-64]));
+assert_checkequal(I8 & ui16, uint16([16,16;0,0]));
+assert_checkequal(I8 & UI16, uint16([16,32;32,64]));
+assert_checkequal(I8 & i32, int32([-32,-32;-32,-32]));
+assert_checkequal(I8 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(I8 & ui32, uint32([32,32;32,32]));
+assert_checkequal(I8 & UI32, uint32([32,64;96,128]));
+
+assert_checkequal(ui8 & i8, uint8(8));
+assert_checkequal(ui8 & I8, uint8([8,0;8,0]));
+assert_checkequal(ui8 & ui8, uint8(8));
+assert_checkequal(ui8 & UI8, uint8([8,0;8,0]));
+assert_checkequal(ui8 & i16, uint16(0));
+assert_checkequal(ui8 & I16, uint16([0,0;0,0]));
+assert_checkequal(ui8 & ui16, uint16(0));
+assert_checkequal(ui8 & UI16, uint16([0,0;0,0]));
+assert_checkequal(ui8 & i32, uint32(0));
+assert_checkequal(ui8 & I32, uint32([0,0;0,0]));
+assert_checkequal(ui8 & ui32, uint32(0));
+assert_checkequal(ui8 & UI32, uint32([0,0;0,0]));
+
+assert_checkequal(UI8 & i8, uint8([8,16;24,32]));
+assert_checkequal(UI8 & I8, uint8([8,16;8,32]));
+assert_checkequal(UI8 & ui8, uint8([8,0;8,0]));
+assert_checkequal(UI8 & UI8, uint8([8,16;24,32]));
+assert_checkequal(UI8 & i16, uint16([0,16;16,32]));
+assert_checkequal(UI8 & I16, uint16([0,0;16,0]));
+assert_checkequal(UI8 & ui16, uint16([0,16;16,0]));
+assert_checkequal(UI8 & UI16, uint16([0,0;16,0]));
+assert_checkequal(UI8 & i32, uint32([0,0;0,32]));
+assert_checkequal(UI8 & I32, uint32([0,0;0,0]));
+assert_checkequal(UI8 & ui32, uint32([0,0;0,32]));
+assert_checkequal(UI8 & UI32, uint32([0,0;0,0]));
+
+assert_checkequal(i16 & i8, int16(-16));
+assert_checkequal(i16 & I8, int16([-16,-16;-32,-32]));
+assert_checkequal(i16 & ui8, uint16(0));
+assert_checkequal(i16 & UI8, uint16([0,16;16,32]));
+assert_checkequal(i16 & i16, int16(-16));
+assert_checkequal(i16 & I16, int16([-16,-32;-48,-64]));
+assert_checkequal(i16 & ui16, uint16(16));
+assert_checkequal(i16 & UI16, uint16([16,32;48,64]));
+assert_checkequal(i16 & i32, int32(-32));
+assert_checkequal(i16 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(i16 & ui32, uint32(32));
+assert_checkequal(i16 & UI32, uint32([32,64;96,128]));
+
+assert_checkequal(I16 & i8, int16([-16,-32;-48,-64]));
+assert_checkequal(I16 & I8, int16([-16,-32;-64,-64]));
+assert_checkequal(I16 & ui8, uint16([0,0;0,0]));
+assert_checkequal(I16 & UI8, uint16([0,0;16,0]));
+assert_checkequal(I16 & i16, int16([-16,-32;-48,-64]));
+assert_checkequal(I16 & I16, int16([-16,-32;-48,-64]));
+assert_checkequal(I16 & ui16, uint16([16,0;16,0]));
+assert_checkequal(I16 & UI16, uint16([16,32;16,64]));
+assert_checkequal(I16 & i32, int32([-32,-32;-64,-64]));
+assert_checkequal(I16 & I32, int32([-32,-64;-128,-128]));
+assert_checkequal(I16 & ui32, uint32([32,32;0,0]));
+assert_checkequal(I16 & UI32, uint32([32,64;64,128]));
+
+assert_checkequal(ui16 & i8, uint16(16));
+assert_checkequal(ui16 & I8, uint16([16,16;0,0]));
+assert_checkequal(ui16 & ui8, uint16(0));
+assert_checkequal(ui16 & UI8, uint16([0,16;16,0]));
+assert_checkequal(ui16 & i16, uint16(16));
+assert_checkequal(ui16 & I16, uint16([16,0;16,0]));
+assert_checkequal(ui16 & ui16, uint16(16));
+assert_checkequal(ui16 & UI16, uint16([16,0;16,0]));
+assert_checkequal(ui16 & i32, uint32(0));
+assert_checkequal(ui16 & I32, uint32([0,0;0,0]));
+assert_checkequal(ui16 & ui32, uint32(0));
+assert_checkequal(ui16 & UI32, uint32([0,0;0,0]));
+
+assert_checkequal(UI16 & i8, uint16([16,32;48,64]));
+assert_checkequal(UI16 & I8, uint16([16,32;32,64]));
+assert_checkequal(UI16 & ui8, uint16([0,0;0,0]));
+assert_checkequal(UI16 & UI8, uint16([0,0;16,0]));
+assert_checkequal(UI16 & i16, uint16([16,32;48,64]));
+assert_checkequal(UI16 & I16, uint16([16,32;16,64]));
+assert_checkequal(UI16 & ui16, uint16([16,0;16,0]));
+assert_checkequal(UI16 & UI16, uint16([16,32;48,64]));
+assert_checkequal(UI16 & i32, uint32([0,32;32,64]));
+assert_checkequal(UI16 & I32, uint32([0,0;32,0]));
+assert_checkequal(UI16 & ui32, uint32([0,32;32,0]));
+assert_checkequal(UI16 & UI32, uint32([0,0;32,0]));
+
+assert_checkequal(i32 & i8, int32(-32));
+assert_checkequal(i32 & I8, int32([-32,-32;-32,-32]));
+assert_checkequal(i32 & ui8, uint32(0));
+assert_checkequal(i32 & UI8, uint32([0,0;0,32]));
+assert_checkequal(i32 & i16, int32(-32));
+assert_checkequal(i32 & I16, int32([-32,-32;-64,-64]));
+assert_checkequal(i32 & ui16, uint32(0));
+assert_checkequal(i32 & UI16, uint32([0,32;32,64]));
+assert_checkequal(i32 & i32, int32(-32));
+assert_checkequal(i32 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(i32 & ui32, uint32(32));
+assert_checkequal(i32 & UI32, uint32([32,64;96,128]));
+
+assert_checkequal(I32 & i8, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & I8, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & ui8, uint32([0,0;0,0]));
+assert_checkequal(I32 & UI8, uint32([0,0;0,0]));
+assert_checkequal(I32 & i16, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & I16, int32([-32,-64;-128,-128]));
+assert_checkequal(I32 & ui16, uint32([0,0;0,0]));
+assert_checkequal(I32 & UI16, uint32([0,0;32,0]));
+assert_checkequal(I32 & i32, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & I32, int32([-32,-64;-96,-128]));
+assert_checkequal(I32 & ui32, uint32([32,0;32,0]));
+assert_checkequal(I32 & UI32, uint32([32,64;32,128]));
+
+assert_checkequal(ui32 & i8, uint32(32));
+assert_checkequal(ui32 & I8, uint32([32,32;32,32]));
+assert_checkequal(ui32 & ui8, uint32(0));
+assert_checkequal(ui32 & UI8, uint32([0,0;0,32]));
+assert_checkequal(ui32 & i16, uint32(32));
+assert_checkequal(ui32 & I16, uint32([32,32;0,0]));
+assert_checkequal(ui32 & ui16, uint32(0));
+assert_checkequal(ui32 & UI16, uint32([0,32;32,0]));
+assert_checkequal(ui32 & i32, uint32(32));
+assert_checkequal(ui32 & I32, uint32([32,0;32,0]));
+assert_checkequal(ui32 & ui32, uint32(32));
+assert_checkequal(ui32 & UI32, uint32([32,0;32,0]));
+
+assert_checkequal(UI32 & i8, uint32([32,64;96,128]));
+assert_checkequal(UI32 & I8, uint32([32,64;96,128]));
+assert_checkequal(UI32 & ui8, uint32([0,0;0,0]));
+assert_checkequal(UI32 & UI8, uint32([0,0;0,0]));
+assert_checkequal(UI32 & i16, uint32([32,64;96,128]));
+assert_checkequal(UI32 & I16, uint32([32,64;64,128]));
+assert_checkequal(UI32 & ui16, uint32([0,0;0,0]));
+assert_checkequal(UI32 & UI16, uint32([0,0;32,0]));
+assert_checkequal(UI32 & i32, uint32([32,64;96,128]));
+assert_checkequal(UI32 & I32, uint32([32,64;32,128]));
+assert_checkequal(UI32 & ui32, uint32([32,0;32,0]));
+assert_checkequal(UI32 & UI32, uint32([32,64;96,128]));