2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
4 * Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 #ifndef __TYPES_SUB_H__
15 #define __TYPES_SUB_H__
17 #include "generic_operations.hxx"
19 #include "polynom.hxx"
22 void fillSubtractFunction();
24 //define arrays on operation functions
25 typedef types::InternalType*(*sub_function)(types::InternalType*, types::InternalType*);
27 #define DECLARE_SUB_PROTO(x) template<class T, class U, class O> inline types::InternalType* x(T *_pL, U *_pR)
29 DECLARE_SUB_PROTO(sub_M_M);
30 DECLARE_SUB_PROTO(sub_M_MC);
31 DECLARE_SUB_PROTO(sub_M_S);
32 DECLARE_SUB_PROTO(sub_M_SC);
33 DECLARE_SUB_PROTO(sub_M_E);
35 DECLARE_SUB_PROTO(sub_MC_M);
36 DECLARE_SUB_PROTO(sub_MC_MC);
37 DECLARE_SUB_PROTO(sub_MC_S);
38 DECLARE_SUB_PROTO(sub_MC_SC);
39 DECLARE_SUB_PROTO(sub_MC_E);
41 DECLARE_SUB_PROTO(sub_S_M);
42 DECLARE_SUB_PROTO(sub_S_MC);
43 DECLARE_SUB_PROTO(sub_S_S);
44 DECLARE_SUB_PROTO(sub_S_SC);
45 DECLARE_SUB_PROTO(sub_S_E);
47 DECLARE_SUB_PROTO(sub_SC_M);
48 DECLARE_SUB_PROTO(sub_SC_MC);
49 DECLARE_SUB_PROTO(sub_SC_S);
50 DECLARE_SUB_PROTO(sub_SC_SC);
51 DECLARE_SUB_PROTO(sub_SC_E);
54 DECLARE_SUB_PROTO(sub_E_M);
55 DECLARE_SUB_PROTO(sub_E_MC);
56 DECLARE_SUB_PROTO(sub_E_E);
59 DECLARE_SUB_PROTO(sub_I_M);
60 DECLARE_SUB_PROTO(sub_I_MC);
61 DECLARE_SUB_PROTO(sub_IC_M);
62 DECLARE_SUB_PROTO(sub_IC_MC);
64 DECLARE_SUB_PROTO(sub_I_S);
65 DECLARE_SUB_PROTO(sub_I_SC);
66 DECLARE_SUB_PROTO(sub_IC_S);
67 DECLARE_SUB_PROTO(sub_IC_SC);
69 DECLARE_SUB_PROTO(sub_M_I);
70 DECLARE_SUB_PROTO(sub_MC_I);
71 DECLARE_SUB_PROTO(sub_M_IC);
72 DECLARE_SUB_PROTO(sub_MC_IC);
74 DECLARE_SUB_PROTO(sub_S_I);
75 DECLARE_SUB_PROTO(sub_SC_I);
76 DECLARE_SUB_PROTO(sub_S_IC);
77 DECLARE_SUB_PROTO(sub_SC_IC);
79 DECLARE_SUB_PROTO(sub_I_I);
80 DECLARE_SUB_PROTO(sub_I_IC);
81 DECLARE_SUB_PROTO(sub_IC_I);
82 DECLARE_SUB_PROTO(sub_IC_IC);
84 DECLARE_SUB_PROTO(sub_I_E);
85 DECLARE_SUB_PROTO(sub_IC_E);
86 DECLARE_SUB_PROTO(sub_E_I);
87 DECLARE_SUB_PROTO(sub_E_IC);
89 template<> inline types::InternalType* sub_M_M<types::Polynom, types::Polynom, types::Polynom>(types::Polynom* _pL, types::Polynom* _pR);
90 template<> inline types::InternalType* sub_M_M<types::Polynom, types::Double, types::Polynom>(types::Polynom* _pL, types::Double* _pR);
91 template<> inline types::InternalType* sub_M_M<types::Double, types::Polynom, types::Polynom>(types::Double* _pL, types::Polynom* _pR);
92 template<> inline types::InternalType* sub_I_M<types::Double, types::Polynom, types::Polynom>(types::Double* _pL, types::Polynom* _pR);
93 template<> inline types::InternalType* sub_IC_M<types::Double, types::Polynom, types::Polynom>(types::Double* _pL, types::Polynom* _pR);
94 template<> inline types::InternalType* sub_I_MC<types::Double, types::Polynom, types::Polynom>(types::Double* _pL, types::Polynom* _pR);
95 template<> inline types::InternalType* sub_IC_MC<types::Double, types::Polynom, types::Polynom>(types::Double* _pL, types::Polynom* _pR);
97 template<> inline types::InternalType* sub_M_M<types::Sparse, types::Sparse, types::Sparse>(types::Sparse* _pL, types::Sparse* _pR);
98 template<> inline types::InternalType* sub_M_M<types::Double, types::Sparse, types::Double>(types::Double* _pL, types::Sparse* _pR);
99 template<> inline types::InternalType* sub_M_M<types::Sparse, types::Double, types::Double>(types::Sparse* _pL, types::Double* _pR);
100 template<> inline types::InternalType* sub_M_M<types::Double, types::Sparse, types::Sparse>(types::Double* _pL, types::Sparse* _pR);
101 template<> inline types::InternalType* sub_M_M<types::Sparse, types::Double, types::Sparse>(types::Sparse* _pL, types::Double* _pR);
103 //add matrix - matrix ( double, int, bool )
105 template<typename T, typename O> inline static void sub(T* l, size_t size, T* r, O* o)
107 for (size_t i = 0; i < size ; ++i)
109 o[i] = (O)l[i] - (O)r[i];
114 template<typename T, typename U, typename O> inline static void sub(T* l, size_t size, U* r, O* o)
116 for (size_t i = 0; i < size ; ++i)
118 o[i] = (O)l[i] - (O)r[i];
124 template<typename T, typename U, typename O> inline static void sub(T* l, size_t size, U* r, U* rc, O* o, O* oc)
126 for (size_t i = 0; i < size ; ++i)
128 o[i] = (O)l[i] - (O)r[i];
134 template<typename T, typename U, typename O> inline static void sub(T* l, T* lc, size_t size, U* r, O* o, O* oc)
136 for (size_t i = 0; i < size ; ++i)
138 o[i] = (O)l[i] - (O)r[i];
144 template<typename T, typename O> inline static void sub(T* l, T* lc, size_t size, T* r, T* rc, O* o, O* oc)
146 for (size_t i = 0; i < size ; ++i)
148 o[i] = (O)l[i] - (O)r[i];
149 oc[i] = (O)lc[i] - (O)rc[i];
153 //add matrix - scalar ( double, int, bool )
155 template<typename T, typename U, typename O> inline static void sub(T* l, size_t size, U r, O* o)
157 for (size_t i = 0; i < size ; ++i)
159 o[i] = (O)l[i] - (O)r;
164 template<typename T, typename U, typename O> inline static void sub(T* l, T* lc, size_t size, U r, O* o, O* oc)
166 for (size_t i = 0; i < size ; ++i)
168 o[i] = (O)l[i] - (O)r;
174 template<typename T, typename U, typename O> inline static void sub(T* l, size_t size, U r, U rc, O* o, O* oc)
176 for (size_t i = 0; i < size ; ++i)
178 o[i] = (O)l[i] - (O) r;
184 template<typename T, typename O> inline static void sub(T* l, T* lc, size_t size, T r, T rc, O* o, O* oc)
186 for (size_t i = 0; i < size ; ++i)
188 o[i] = (O)l[i] - (O)r;
189 oc[i] = (O)lc[i] - (O)rc;
193 //add scalar - matrix ( double, int, bool )
195 template<typename T, typename U, typename O> inline static void sub(T l, size_t size, U* r, O* o)
197 for (size_t i = 0; i < size ; ++i)
199 o[i] = (O)l - (O)r[i];
204 template<typename T, typename U, typename O> inline static void sub(T l, size_t size, U* r, U* rc, O* o, O* oc)
206 for (size_t i = 0; i < size ; ++i)
208 o[i] = (O)l - (O)r[i];
214 template<typename T, typename U, typename O> inline static void sub(T l, T lc, size_t size, U* r, O* o, O* oc)
216 for (size_t i = 0; i < size ; ++i)
218 o[i] = (O)l - (O)r[i];
224 template<typename T, typename O> inline static void sub(T l, T lc, size_t size, T* r, T* rc, O* o, O* oc)
226 for (size_t i = 0; i < size ; ++i)
228 o[i] = (O)l - (O)r[i];
229 oc[i] = (O)lc - rc[i];
234 //add scalar - scalar ( double, int, bool )
236 template<typename T, typename O> inline static void sub(T l, T r, O* o)
241 template<typename T, typename U, typename O> inline static void sub(T l, U r, O* o)
247 template<typename T, typename U, typename O> inline static void sub(T l, T lc, U r, U rc, O* o, O* oc)
254 template<typename T, typename O> inline static void sub(T l, O* o)
260 template<typename T, typename O> inline static void sub(T l, T lc, O* o, O* oc)
267 inline static void sub()
271 #endif /* __TYPES_SUB_H__ */