2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
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_OR_H__
14 #define __TYPES_OR_H__
16 #include "generic_operations.hxx"
20 void fillOrFunction();
22 //define arrays on operation functions
23 typedef types::InternalType*(*or_function)(types::InternalType*, types::InternalType*);
25 #define DECLARE_OR_PROTO(x) \
26 template<class T, class U, class O> \
27 inline types::InternalType* x(T *_pL, U *_pR)
29 DECLARE_OR_PROTO(or_M_M);
30 DECLARE_OR_PROTO(or_M_S);
31 DECLARE_OR_PROTO(or_M_E);
33 DECLARE_OR_PROTO(or_S_M);
34 DECLARE_OR_PROTO(or_S_S);
35 DECLARE_OR_PROTO(or_S_E);
38 DECLARE_OR_PROTO(or_E_M);
41 DECLARE_OR_PROTO(or_I_M);
42 DECLARE_OR_PROTO(or_I_S);
44 DECLARE_OR_PROTO(or_int_M_M);
45 DECLARE_OR_PROTO(or_int_M_S);
46 DECLARE_OR_PROTO(or_int_S_M);
47 DECLARE_OR_PROTO(or_int_S_S);
49 //boolean sparse specialisation
50 template<> inline types::InternalType* or_M_M<types::SparseBool, types::SparseBool, types::SparseBool>(types::SparseBool* _pL, types::SparseBool* _pR);
51 template<> inline types::InternalType* or_M_M<types::SparseBool, types::Bool, types::SparseBool>(types::SparseBool* _pL, types::Bool* _pR);
52 template<> inline types::InternalType* or_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_or(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_or(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_or(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_or(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_or(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_or(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_or(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_or(T l, U r, O* o)
123 int IntOrInt(types::InternalType* _pL, types::Bool** _pOut);
124 int BoolOrBool(types::Bool* _pI1, types::Bool** _pOut);
125 int SparseBoolOrSparseBool(types::InternalType* _pL, types::Bool** _pOut);
127 #endif /* __TYPES_OR_H__ */