2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #ifndef __TYPES_AND_H__
14 #define __TYPES_AND_H__
16 #include "generic_operations.hxx"
20 void fillAndFunction();
22 //define arrays on operation functions
23 typedef types::InternalType*(*and_function)(types::InternalType*, types::InternalType*);
25 #define DECLARE_AND_PROTO(x) \
26 template<class T, class U, class O> \
27 types::InternalType* x(T *_pL, U *_pR)
29 DECLARE_AND_PROTO(and_M_M);
30 DECLARE_AND_PROTO(and_M_S);
31 DECLARE_AND_PROTO(and_M_E);
33 DECLARE_AND_PROTO(and_S_M);
34 DECLARE_AND_PROTO(and_S_S);
35 DECLARE_AND_PROTO(and_S_E);
38 DECLARE_AND_PROTO(and_E_M);
41 DECLARE_AND_PROTO(and_I_M);
42 DECLARE_AND_PROTO(and_I_S);
44 DECLARE_AND_PROTO(and_int_M_M);
45 DECLARE_AND_PROTO(and_int_M_S);
46 DECLARE_AND_PROTO(and_int_S_M);
47 DECLARE_AND_PROTO(and_int_S_S);
49 //boolean sparse specialisation
50 template<> types::InternalType* and_M_M<types::SparseBool, types::SparseBool, types::SparseBool>(types::SparseBool* _pL, types::SparseBool* _pR);
51 template<> types::InternalType* and_M_M<types::SparseBool, types::Bool, types::SparseBool>(types::SparseBool* _pL, types::Bool* _pR);
52 template<> types::InternalType* and_M_M<types::Bool, types::SparseBool, types::SparseBool>(types::Bool* _pL, types::SparseBool* _pR);
55 template<typename T, typename U, typename O> inline static void bit_and(T* l, long long size, U* r, O* o)
57 for (int i = 0; i < size ; ++i)
59 o[i] = (((O)l[i] != (O)0) && ((O)r[i] != (O)0)) ? (O)1 : (O)0;
64 template<typename T, typename U, typename O> inline static void bit_and(T l, long long size, U* r, O* o)
66 for (int i = 0; i < size ; ++i)
68 o[i] = (((O)l != (O)0) && ((O)r[i] != (O)0)) ? (O)1 : (O)0;
73 template<typename T, typename U, typename O> inline static void bit_and(T* l, long long size, U r, O* o)
75 for (int i = 0; i < size ; ++i)
77 o[i] = (((O)l[i] != (O)0) && ((O)r != (O)0)) ? (O)1 : (O)0;
82 template<typename T, typename U, typename O> inline static void bit_and(T l, U r, O* o)
84 *o = (((O)l != (O)0) && ((O)r != (O)0)) ? (O)1 : (O)0;
88 //int, real & operation,
90 template<typename T, typename U, typename O> inline static void int_and(T* l, long long size, U* r, O* o)
92 for (int i = 0; i < size ; ++i)
94 o[i] = (O)l[i] & (O)r[i];
99 template<typename T, typename U, typename O> inline static void int_and(T l, long long size, U* r, O* o)
101 for (int i = 0; i < size ; ++i)
103 o[i] = (O)l & (O)r[i];
108 template<typename T, typename U, typename O> inline static void int_and(T* l, long long size, U r, O* o)
110 for (int i = 0; i < size ; ++i)
112 o[i] = (O)l[i] & (O)r;
117 template<typename T, typename U, typename O> inline static void int_and(T l, U r, O* o)
123 int IntAndInt(types::InternalType* _pL, types::Bool** _pOut);
124 int BoolAndBool(types::Bool* _pL, types::Bool** _pOut);
125 int SparseBoolAndSparseBool(types::InternalType* _pL, types::Bool** _pOut);
127 #undef DECLARE_AND_PROTO
128 #endif /* !__TYPES_AND_H__ */