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 #include "types_addition.hxx"
15 #include "operations.hxx"
19 #include "scilabexception.hxx"
24 #include "core_math.h"
25 #include "matrix_addition.h"
26 #include "localization.h"
27 #include "charEncoding.h"
28 #include "os_swprintf.h"
29 #include "elem_common.h" //dset
32 using namespace types;
35 //define arrays on operation functions
36 static add_function pAddfunction[types::InternalType::IdLast][types::InternalType::IdLast] = {NULL};
38 void fillAddFunction()
40 #define scilab_fill_add(id1, id2, func, typeIn1, typeIn2, typeOut) \
41 pAddfunction[types::InternalType::Id ## id1][types::InternalType::Id ## id2] = (add_function)&add_##func<typeIn1, typeIn2, typeOut>
45 scilab_fill_add(Double, Double, M_M, Double, Double, Double);
46 scilab_fill_add(Double, Int8, M_M, Double, Int8, Int8);
47 scilab_fill_add(Double, UInt8, M_M, Double, UInt8, UInt8);
48 scilab_fill_add(Double, Int16, M_M, Double, Int16, Int16);
49 scilab_fill_add(Double, UInt16, M_M, Double, UInt16, UInt16);
50 scilab_fill_add(Double, Int32, M_M, Double, Int32, Int32);
51 scilab_fill_add(Double, UInt32, M_M, Double, UInt32, UInt32);
52 scilab_fill_add(Double, Int64, M_M, Double, Int64, Int64);
53 scilab_fill_add(Double, UInt64, M_M, Double, UInt64, UInt64);
54 scilab_fill_add(Double, Bool, M_M, Double, Bool, Double);
55 scilab_fill_add(Double, Polynom, M_M, Double, Polynom, Polynom);
56 scilab_fill_add(Double, Sparse, M_M, Double, Sparse, Double);
58 //Matrix + Matrix Complex
59 scilab_fill_add(Double, DoubleComplex, M_MC, Double, Double, Double);
60 scilab_fill_add(Double, PolynomComplex, M_M, Double, Polynom, Polynom);
61 scilab_fill_add(Double, SparseComplex, M_M, Double, Sparse, Double);
64 scilab_fill_add(Double, ScalarDouble, M_S, Double, Double, Double);
65 scilab_fill_add(Double, ScalarInt8, M_S, Double, Int8, Int8);
66 scilab_fill_add(Double, ScalarUInt8, M_S, Double, UInt8, UInt8);
67 scilab_fill_add(Double, ScalarInt16, M_S, Double, Int16, Int16);
68 scilab_fill_add(Double, ScalarUInt16, M_S, Double, UInt16, UInt16);
69 scilab_fill_add(Double, ScalarInt32, M_S, Double, Int32, Int32);
70 scilab_fill_add(Double, ScalarUInt32, M_S, Double, UInt32, UInt32);
71 scilab_fill_add(Double, ScalarInt64, M_S, Double, Int64, Int64);
72 scilab_fill_add(Double, ScalarUInt64, M_S, Double, UInt64, UInt64);
73 scilab_fill_add(Double, ScalarBool, M_S, Double, Bool, Double);
74 scilab_fill_add(Double, ScalarPolynom, M_M, Double, Polynom, Polynom);
76 //Matrix + Scalar Complex
77 scilab_fill_add(Double, ScalarDoubleComplex, M_SC, Double, Double, Double);
78 scilab_fill_add(Double, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
80 scilab_fill_add(Double, Empty, M_E, Double, Double, Double);
83 //Matrix Complex + Matrix
84 scilab_fill_add(DoubleComplex, Double, MC_M, Double, Double, Double);
85 scilab_fill_add(DoubleComplex, DoubleComplex, MC_MC, Double, Double, Double);
86 scilab_fill_add(DoubleComplex, ScalarDouble, MC_S, Double, Double, Double);
87 scilab_fill_add(DoubleComplex, ScalarDoubleComplex, MC_SC, Double, Double, Double);
88 scilab_fill_add(DoubleComplex, Empty, MC_E, Double, Double, Double);
89 scilab_fill_add(DoubleComplex, Polynom, M_M, Double, Polynom, Polynom);
90 scilab_fill_add(DoubleComplex, PolynomComplex, M_M, Double, Polynom, Polynom);
91 scilab_fill_add(DoubleComplex, ScalarPolynom, M_M, Double, Polynom, Polynom);
92 scilab_fill_add(DoubleComplex, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
93 scilab_fill_add(DoubleComplex, Sparse, M_M, Double, Sparse, Double);
94 scilab_fill_add(DoubleComplex, SparseComplex, M_M, Double, Sparse, Double);
97 scilab_fill_add(ScalarDouble, Double, S_M, Double, Double, Double);
98 scilab_fill_add(ScalarDouble, Int8, S_M, Double, Int8, Int8);
99 scilab_fill_add(ScalarDouble, UInt8, S_M, Double, UInt8, UInt8);
100 scilab_fill_add(ScalarDouble, Int16, S_M, Double, Int16, Int16);
101 scilab_fill_add(ScalarDouble, UInt16, S_M, Double, UInt16, UInt16);
102 scilab_fill_add(ScalarDouble, Int32, S_M, Double, Int32, Int32);
103 scilab_fill_add(ScalarDouble, UInt32, S_M, Double, UInt32, UInt32);
104 scilab_fill_add(ScalarDouble, Int64, S_M, Double, Int64, Int64);
105 scilab_fill_add(ScalarDouble, UInt64, S_M, Double, UInt64, UInt64);
106 scilab_fill_add(ScalarDouble, Bool, S_M, Double, Bool, Double);
107 scilab_fill_add(ScalarDouble, Polynom, M_M, Double, Polynom, Polynom);
108 scilab_fill_add(ScalarDouble, Sparse, M_M, Double, Sparse, Double);
110 //Scalar + Matrix Complex
111 scilab_fill_add(ScalarDouble, DoubleComplex, S_MC, Double, Double, Double);
112 scilab_fill_add(ScalarDouble, PolynomComplex, M_M, Double, Polynom, Polynom);
113 scilab_fill_add(ScalarDouble, SparseComplex, M_M, Double, Sparse, Double);
116 scilab_fill_add(ScalarDouble, ScalarDouble, S_S, Double, Double, Double);
117 scilab_fill_add(ScalarDouble, ScalarInt8, S_S, Double, Int8, Int8);
118 scilab_fill_add(ScalarDouble, ScalarUInt8, S_S, Double, UInt8, UInt8);
119 scilab_fill_add(ScalarDouble, ScalarInt16, S_S, Double, Int16, Int16);
120 scilab_fill_add(ScalarDouble, ScalarUInt16, S_S, Double, UInt16, UInt16);
121 scilab_fill_add(ScalarDouble, ScalarInt32, S_S, Double, Int32, Int32);
122 scilab_fill_add(ScalarDouble, ScalarUInt32, S_S, Double, UInt32, UInt32);
123 scilab_fill_add(ScalarDouble, ScalarInt64, S_S, Double, Int64, Int64);
124 scilab_fill_add(ScalarDouble, ScalarUInt64, S_S, Double, UInt64, UInt64);
125 scilab_fill_add(ScalarDouble, ScalarBool, S_S, Double, Bool, Double);
126 scilab_fill_add(ScalarDouble, ScalarPolynom, M_M, Double, Polynom, Polynom);
128 //Scalar + Scalar Complex
129 scilab_fill_add(ScalarDouble, ScalarDoubleComplex, S_SC, Double, Double, Double);
130 scilab_fill_add(ScalarDouble, PolynomComplex, M_M, Double, Polynom, Polynom);
131 scilab_fill_add(ScalarDouble, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
134 scilab_fill_add(ScalarDouble, Empty, S_E, Double, Double, Double);
136 //Scalar Complex + Matrix
137 scilab_fill_add(ScalarDoubleComplex, Double, SC_M, Double, Double, Double);
138 scilab_fill_add(ScalarDoubleComplex, Polynom, M_M, Double, Polynom, Polynom);
139 scilab_fill_add(ScalarDoubleComplex, Sparse, M_M, Double, Sparse, Double);
140 //Scalar Complex + Matrix Complex
141 scilab_fill_add(ScalarDoubleComplex, DoubleComplex, SC_MC, Double, Double, Double);
142 scilab_fill_add(ScalarDoubleComplex, PolynomComplex, M_M, Double, Polynom, Polynom);
143 scilab_fill_add(ScalarDoubleComplex, SparseComplex, M_M, Double, Sparse, Double);
144 //Scalar Complex + Scalar
145 scilab_fill_add(ScalarDoubleComplex, ScalarDouble, SC_S, Double, Double, Double);
146 scilab_fill_add(ScalarDoubleComplex, ScalarPolynom, M_M, Double, Polynom, Polynom);
147 //Scalar Complex + Scalar Complex
148 scilab_fill_add(ScalarDoubleComplex, ScalarDoubleComplex, SC_SC, Double, Double, Double);
149 scilab_fill_add(ScalarDoubleComplex, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
150 //Scalar Complex + Empty
151 scilab_fill_add(ScalarDoubleComplex, Empty, SC_E, Double, Double, Double);
154 scilab_fill_add(Empty, Double, E_M, Double, Double, Double);
155 scilab_fill_add(Empty, Int8, E_M, Double, Int8, Int8);
156 scilab_fill_add(Empty, UInt8, E_M, Double, UInt8, UInt8);
157 scilab_fill_add(Empty, Int16, E_M, Double, Int16, Int16);
158 scilab_fill_add(Empty, UInt16, E_M, Double, UInt16, UInt16);
159 scilab_fill_add(Empty, Int32, E_M, Double, Int32, Int32);
160 scilab_fill_add(Empty, UInt32, E_M, Double, UInt32, UInt32);
161 scilab_fill_add(Empty, Int64, E_M, Double, Int64, Int64);
162 scilab_fill_add(Empty, UInt64, E_M, Double, UInt64, UInt64);
163 scilab_fill_add(Empty, Bool, E_M, Double, Bool, Double);
164 scilab_fill_add(Empty, String, E_M, Double, String, String);
165 scilab_fill_add(Empty, Polynom, M_M, Double, Polynom, Polynom);
166 scilab_fill_add(Empty, PolynomComplex, M_M, Double, Polynom, Polynom);
167 scilab_fill_add(Empty, Sparse, M_M, Double, Sparse, Sparse);
168 scilab_fill_add(Empty, SparseComplex, M_M, Double, Sparse, Sparse);
170 //Empty + Matrix Complex
171 scilab_fill_add(Empty, DoubleComplex, E_MC, Double, Double, Double);
173 scilab_fill_add(Empty, ScalarDouble, E_S, Double, Double, Double);
174 scilab_fill_add(Empty, ScalarInt8, E_S, Double, Int8, Int8);
175 scilab_fill_add(Empty, ScalarUInt8, E_S, Double, UInt8, UInt8);
176 scilab_fill_add(Empty, ScalarInt16, E_S, Double, Int16, Int16);
177 scilab_fill_add(Empty, ScalarUInt16, E_S, Double, UInt16, UInt16);
178 scilab_fill_add(Empty, ScalarInt32, E_S, Double, Int32, Int32);
179 scilab_fill_add(Empty, ScalarUInt32, E_S, Double, UInt32, UInt32);
180 scilab_fill_add(Empty, ScalarInt64, E_S, Double, Int64, Int64);
181 scilab_fill_add(Empty, ScalarUInt64, E_S, Double, UInt64, UInt64);
182 scilab_fill_add(Empty, ScalarBool, E_S, Double, Bool, Double);
183 scilab_fill_add(Empty, ScalarString, E_S, Double, String, String);
184 scilab_fill_add(Empty, ScalarPolynom, M_M, Double, Polynom, Polynom);
186 //Empty + Scalar Complex
187 scilab_fill_add(Empty, ScalarDoubleComplex, E_SC, Double, Double, Double);
188 scilab_fill_add(Empty, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
190 scilab_fill_add(Empty, Empty, E_E, Double, Double, Double);
192 scilab_fill_add(Empty, Identity, E_I, Double, Double, Double);
193 scilab_fill_add(Empty, IdentityComplex, E_IC, Double, Double, Double);
196 scilab_fill_add(Double, Identity, M_I, Double, Double, Double);
197 scilab_fill_add(Double, IdentityComplex, M_IC, Double, Double, Double);
198 scilab_fill_add(DoubleComplex, Identity, MC_I, Double, Double, Double);
199 scilab_fill_add(DoubleComplex, IdentityComplex, MC_IC, Double, Double, Double);
200 scilab_fill_add(ScalarDouble, Identity, S_I, Double, Double, Double);
201 scilab_fill_add(ScalarDouble, IdentityComplex, S_IC, Double, Double, Double);
202 scilab_fill_add(ScalarDoubleComplex, Identity, SC_I, Double, Double, Double);
203 scilab_fill_add(ScalarDoubleComplex, IdentityComplex, SC_IC, Double, Double, Double);
208 scilab_fill_add(Int8, Double, M_M, Int8, Double, Int8);
209 scilab_fill_add(Int8, Int8, M_M, Int8, Int8, Int8);
210 scilab_fill_add(Int8, UInt8, M_M, Int8, UInt8, UInt8);
211 scilab_fill_add(Int8, Int16, M_M, Int8, Int16, Int16);
212 scilab_fill_add(Int8, UInt16, M_M, Int8, UInt16, UInt16);
213 scilab_fill_add(Int8, Int32, M_M, Int8, Int32, Int32);
214 scilab_fill_add(Int8, UInt32, M_M, Int8, UInt32, UInt32);
215 scilab_fill_add(Int8, Int64, M_M, Int8, Int64, Int64);
216 scilab_fill_add(Int8, UInt64, M_M, Int8, UInt64, UInt64);
217 scilab_fill_add(Int8, Bool, M_M, Int8, Bool, Int8);
218 scilab_fill_add(Int8, Empty, M_E, Int8, Double, Int8);
221 scilab_fill_add(Int8, ScalarDouble, M_S, Int8, Double, Int8);
222 scilab_fill_add(Int8, ScalarInt8, M_S, Int8, Int8, Int8);
223 scilab_fill_add(Int8, ScalarUInt8, M_S, Int8, UInt8, UInt8);
224 scilab_fill_add(Int8, ScalarInt16, M_S, Int8, Int16, Int16);
225 scilab_fill_add(Int8, ScalarUInt16, M_S, Int8, UInt16, UInt16);
226 scilab_fill_add(Int8, ScalarInt32, M_S, Int8, Int32, Int32);
227 scilab_fill_add(Int8, ScalarUInt32, M_S, Int8, UInt32, UInt32);
228 scilab_fill_add(Int8, ScalarInt64, M_S, Int8, Int64, Int64);
229 scilab_fill_add(Int8, ScalarUInt64, M_S, Int8, UInt64, UInt64);
230 scilab_fill_add(Int8, ScalarBool, M_S, Int8, Bool, Int8);
233 scilab_fill_add(ScalarInt8, Double, S_M, Int8, Double, Int8);
234 scilab_fill_add(ScalarInt8, Int8, S_M, Int8, Int8, Int8);
235 scilab_fill_add(ScalarInt8, UInt8, S_M, Int8, UInt8, UInt8);
236 scilab_fill_add(ScalarInt8, Int16, S_M, Int8, Int16, Int16);
237 scilab_fill_add(ScalarInt8, UInt16, S_M, Int8, UInt16, UInt16);
238 scilab_fill_add(ScalarInt8, Int32, S_M, Int8, Int32, Int32);
239 scilab_fill_add(ScalarInt8, UInt32, S_M, Int8, UInt32, UInt32);
240 scilab_fill_add(ScalarInt8, Int64, S_M, Int8, Int64, Int64);
241 scilab_fill_add(ScalarInt8, UInt64, S_M, Int8, UInt64, UInt64);
242 scilab_fill_add(ScalarInt8, Bool, S_M, Int8, Bool, Int8);
243 scilab_fill_add(ScalarInt8, Empty, S_E, Int8, Double, Int8);
246 scilab_fill_add(ScalarInt8, ScalarDouble, S_S, Int8, Double, Int8);
247 scilab_fill_add(ScalarInt8, ScalarInt8, S_S, Int8, Int8, Int8);
248 scilab_fill_add(ScalarInt8, ScalarUInt8, S_S, Int8, UInt8, UInt8);
249 scilab_fill_add(ScalarInt8, ScalarInt16, S_S, Int8, Int16, Int16);
250 scilab_fill_add(ScalarInt8, ScalarUInt16, S_S, Int8, UInt16, UInt16);
251 scilab_fill_add(ScalarInt8, ScalarInt32, S_S, Int8, Int32, Int32);
252 scilab_fill_add(ScalarInt8, ScalarUInt32, S_S, Int8, UInt32, UInt32);
253 scilab_fill_add(ScalarInt8, ScalarInt64, S_S, Int8, Int64, Int64);
254 scilab_fill_add(ScalarInt8, ScalarUInt64, S_S, Int8, UInt64, UInt64);
255 scilab_fill_add(ScalarInt8, ScalarBool, S_S, Int8, Bool, Int8);
259 scilab_fill_add(UInt8, Double, M_M, UInt8, Double, UInt8);
260 scilab_fill_add(UInt8, Int8, M_M, UInt8, Int8, UInt8);
261 scilab_fill_add(UInt8, UInt8, M_M, UInt8, UInt8, UInt8);
262 scilab_fill_add(UInt8, Int16, M_M, UInt8, Int16, UInt16);
263 scilab_fill_add(UInt8, UInt16, M_M, UInt8, UInt16, UInt16);
264 scilab_fill_add(UInt8, Int32, M_M, UInt8, Int32, UInt32);
265 scilab_fill_add(UInt8, UInt32, M_M, UInt8, UInt32, UInt32);
266 scilab_fill_add(UInt8, Int64, M_M, UInt8, Int64, UInt64);
267 scilab_fill_add(UInt8, UInt64, M_M, UInt8, UInt64, UInt64);
268 scilab_fill_add(UInt8, Bool, M_M, UInt8, Bool, UInt8);
269 scilab_fill_add(UInt8, Empty, M_E, UInt8, Double, UInt8);
272 scilab_fill_add(UInt8, ScalarDouble, M_S, UInt8, Double, UInt8);
273 scilab_fill_add(UInt8, ScalarInt8, M_S, UInt8, Int8, UInt8);
274 scilab_fill_add(UInt8, ScalarUInt8, M_S, UInt8, UInt8, UInt8);
275 scilab_fill_add(UInt8, ScalarInt16, M_S, UInt8, Int16, UInt16);
276 scilab_fill_add(UInt8, ScalarUInt16, M_S, UInt8, UInt16, UInt16);
277 scilab_fill_add(UInt8, ScalarInt32, M_S, UInt8, Int32, UInt32);
278 scilab_fill_add(UInt8, ScalarUInt32, M_S, UInt8, UInt32, UInt32);
279 scilab_fill_add(UInt8, ScalarInt64, M_S, UInt8, Int64, UInt64);
280 scilab_fill_add(UInt8, ScalarUInt64, M_S, UInt8, UInt64, UInt64);
281 scilab_fill_add(UInt8, ScalarBool, M_S, UInt8, Bool, UInt8);
284 scilab_fill_add(ScalarUInt8, Double, S_M, UInt8, Double, UInt8);
285 scilab_fill_add(ScalarUInt8, Int8, S_M, UInt8, Int8, UInt8);
286 scilab_fill_add(ScalarUInt8, UInt8, S_M, UInt8, UInt8, UInt8);
287 scilab_fill_add(ScalarUInt8, Int16, S_M, UInt8, Int16, UInt16);
288 scilab_fill_add(ScalarUInt8, UInt16, S_M, UInt8, UInt16, UInt16);
289 scilab_fill_add(ScalarUInt8, Int32, S_M, UInt8, Int32, UInt32);
290 scilab_fill_add(ScalarUInt8, UInt32, S_M, UInt8, UInt32, UInt32);
291 scilab_fill_add(ScalarUInt8, Int64, S_M, UInt8, Int64, UInt64);
292 scilab_fill_add(ScalarUInt8, UInt64, S_M, UInt8, UInt64, UInt64);
293 scilab_fill_add(ScalarUInt8, Bool, S_M, UInt8, Bool, UInt8);
294 scilab_fill_add(ScalarUInt8, Empty, S_E, UInt8, Double, UInt8);
297 scilab_fill_add(ScalarUInt8, ScalarDouble, S_S, UInt8, Double, UInt8);
298 scilab_fill_add(ScalarUInt8, ScalarInt8, S_S, UInt8, Int8, UInt8);
299 scilab_fill_add(ScalarUInt8, ScalarUInt8, S_S, UInt8, UInt8, UInt8);
300 scilab_fill_add(ScalarUInt8, ScalarInt16, S_S, UInt8, Int16, UInt16);
301 scilab_fill_add(ScalarUInt8, ScalarUInt16, S_S, UInt8, UInt16, UInt16);
302 scilab_fill_add(ScalarUInt8, ScalarInt32, S_S, UInt8, Int32, UInt32);
303 scilab_fill_add(ScalarUInt8, ScalarUInt32, S_S, UInt8, UInt32, UInt32);
304 scilab_fill_add(ScalarUInt8, ScalarInt64, S_S, UInt8, Int64, UInt64);
305 scilab_fill_add(ScalarUInt8, ScalarUInt64, S_S, UInt8, UInt64, UInt64);
306 scilab_fill_add(ScalarUInt8, ScalarBool, S_S, UInt8, Bool, UInt8);
310 scilab_fill_add(Int16, Double, M_M, Int16, Double, Int16);
311 scilab_fill_add(Int16, Int8, M_M, Int16, Int8, Int16);
312 scilab_fill_add(Int16, UInt8, M_M, Int16, UInt8, UInt16);
313 scilab_fill_add(Int16, Int16, M_M, Int16, Int16, Int16);
314 scilab_fill_add(Int16, UInt16, M_M, Int16, UInt16, UInt16);
315 scilab_fill_add(Int16, Int32, M_M, Int16, Int32, Int32);
316 scilab_fill_add(Int16, UInt32, M_M, Int16, UInt32, UInt32);
317 scilab_fill_add(Int16, Int64, M_M, Int16, Int64, Int64);
318 scilab_fill_add(Int16, UInt64, M_M, Int16, UInt64, UInt64);
319 scilab_fill_add(Int16, Bool, M_M, Int16, Bool, Int16);
320 scilab_fill_add(Int16, Empty, M_E, Int16, Double, Int16);
323 scilab_fill_add(Int16, ScalarDouble, M_S, Int16, Double, Int16);
324 scilab_fill_add(Int16, ScalarInt8, M_S, Int16, Int8, Int16);
325 scilab_fill_add(Int16, ScalarUInt8, M_S, Int16, UInt8, UInt16);
326 scilab_fill_add(Int16, ScalarInt16, M_S, Int16, Int16, Int16);
327 scilab_fill_add(Int16, ScalarUInt16, M_S, Int16, UInt16, UInt16);
328 scilab_fill_add(Int16, ScalarInt32, M_S, Int16, Int32, Int32);
329 scilab_fill_add(Int16, ScalarUInt32, M_S, Int16, UInt32, UInt32);
330 scilab_fill_add(Int16, ScalarInt64, M_S, Int16, Int64, Int64);
331 scilab_fill_add(Int16, ScalarUInt64, M_S, Int16, UInt64, UInt64);
332 scilab_fill_add(Int16, ScalarBool, M_S, Int16, Bool, Int16);
335 scilab_fill_add(ScalarInt16, Double, S_M, Int16, Double, Int16);
336 scilab_fill_add(ScalarInt16, Int8, S_M, Int16, Int8, Int16);
337 scilab_fill_add(ScalarInt16, UInt8, S_M, Int16, UInt8, UInt16);
338 scilab_fill_add(ScalarInt16, Int16, S_M, Int16, Int16, Int16);
339 scilab_fill_add(ScalarInt16, UInt16, S_M, Int16, UInt16, UInt16);
340 scilab_fill_add(ScalarInt16, Int32, S_M, Int16, Int32, Int32);
341 scilab_fill_add(ScalarInt16, UInt32, S_M, Int16, UInt32, UInt32);
342 scilab_fill_add(ScalarInt16, Int64, S_M, Int16, Int64, Int64);
343 scilab_fill_add(ScalarInt16, UInt64, S_M, Int16, UInt64, UInt64);
344 scilab_fill_add(ScalarInt16, Bool, S_M, Int16, Bool, Int16);
345 scilab_fill_add(ScalarInt16, Empty, S_E, Int16, Double, Int16);
348 scilab_fill_add(ScalarInt16, ScalarDouble, S_S, Int16, Double, Int16);
349 scilab_fill_add(ScalarInt16, ScalarInt8, S_S, Int16, Int8, Int16);
350 scilab_fill_add(ScalarInt16, ScalarUInt8, S_S, Int16, UInt8, UInt16);
351 scilab_fill_add(ScalarInt16, ScalarInt16, S_S, Int16, Int16, Int16);
352 scilab_fill_add(ScalarInt16, ScalarUInt16, S_S, Int16, UInt16, UInt16);
353 scilab_fill_add(ScalarInt16, ScalarInt32, S_S, Int16, Int32, Int32);
354 scilab_fill_add(ScalarInt16, ScalarUInt32, S_S, Int16, UInt32, UInt32);
355 scilab_fill_add(ScalarInt16, ScalarInt64, S_S, Int16, Int64, Int64);
356 scilab_fill_add(ScalarInt16, ScalarUInt64, S_S, Int16, UInt64, UInt64);
357 scilab_fill_add(ScalarInt16, ScalarBool, S_S, Int16, Bool, Int16);
361 scilab_fill_add(UInt16, Double, M_M, UInt16, Double, UInt16);
362 scilab_fill_add(UInt16, Int8, M_M, UInt16, Int8, UInt16);
363 scilab_fill_add(UInt16, UInt8, M_M, UInt16, UInt8, UInt16);
364 scilab_fill_add(UInt16, Int16, M_M, UInt16, Int16, UInt16);
365 scilab_fill_add(UInt16, UInt16, M_M, UInt16, UInt16, UInt16);
366 scilab_fill_add(UInt16, Int32, M_M, UInt16, Int32, UInt32);
367 scilab_fill_add(UInt16, UInt32, M_M, UInt16, UInt32, UInt32);
368 scilab_fill_add(UInt16, Int64, M_M, UInt16, Int64, UInt64);
369 scilab_fill_add(UInt16, UInt64, M_M, UInt16, UInt64, UInt64);
370 scilab_fill_add(UInt16, Bool, M_M, UInt16, Bool, UInt16);
371 scilab_fill_add(UInt16, Empty, M_E, UInt16, Double, UInt16);
374 scilab_fill_add(UInt16, ScalarDouble, M_S, UInt16, Double, UInt16);
375 scilab_fill_add(UInt16, ScalarInt8, M_S, UInt16, Int8, UInt16);
376 scilab_fill_add(UInt16, ScalarUInt8, M_S, UInt16, UInt8, UInt16);
377 scilab_fill_add(UInt16, ScalarInt16, M_S, UInt16, Int16, UInt16);
378 scilab_fill_add(UInt16, ScalarUInt16, M_S, UInt16, UInt16, UInt16);
379 scilab_fill_add(UInt16, ScalarInt32, M_S, UInt16, Int32, UInt32);
380 scilab_fill_add(UInt16, ScalarUInt32, M_S, UInt16, UInt32, UInt32);
381 scilab_fill_add(UInt16, ScalarInt64, M_S, UInt16, Int64, UInt64);
382 scilab_fill_add(UInt16, ScalarUInt64, M_S, UInt16, UInt64, UInt64);
383 scilab_fill_add(UInt16, ScalarBool, M_S, UInt16, Bool, UInt16);
386 scilab_fill_add(ScalarUInt16, Double, S_M, UInt16, Double, UInt16);
387 scilab_fill_add(ScalarUInt16, Int8, S_M, UInt16, Int8, UInt16);
388 scilab_fill_add(ScalarUInt16, UInt8, S_M, UInt16, UInt8, UInt16);
389 scilab_fill_add(ScalarUInt16, Int16, S_M, UInt16, Int16, UInt16);
390 scilab_fill_add(ScalarUInt16, UInt16, S_M, UInt16, UInt16, UInt16);
391 scilab_fill_add(ScalarUInt16, Int32, S_M, UInt16, Int32, UInt32);
392 scilab_fill_add(ScalarUInt16, UInt32, S_M, UInt16, UInt32, UInt32);
393 scilab_fill_add(ScalarUInt16, Int64, S_M, UInt16, Int64, UInt64);
394 scilab_fill_add(ScalarUInt16, UInt64, S_M, UInt16, UInt64, UInt64);
395 scilab_fill_add(ScalarUInt16, Bool, S_M, UInt16, Bool, UInt16);
396 scilab_fill_add(ScalarUInt16, Empty, S_E, UInt16, Double, UInt16);
399 scilab_fill_add(ScalarUInt16, ScalarDouble, S_S, UInt16, Double, UInt16);
400 scilab_fill_add(ScalarUInt16, ScalarInt8, S_S, UInt16, Int8, UInt16);
401 scilab_fill_add(ScalarUInt16, ScalarUInt8, S_S, UInt16, UInt8, UInt16);
402 scilab_fill_add(ScalarUInt16, ScalarInt16, S_S, UInt16, Int16, UInt16);
403 scilab_fill_add(ScalarUInt16, ScalarUInt16, S_S, UInt16, UInt16, UInt16);
404 scilab_fill_add(ScalarUInt16, ScalarInt32, S_S, UInt16, Int32, UInt32);
405 scilab_fill_add(ScalarUInt16, ScalarUInt32, S_S, UInt16, UInt32, UInt32);
406 scilab_fill_add(ScalarUInt16, ScalarInt64, S_S, UInt16, Int64, UInt64);
407 scilab_fill_add(ScalarUInt16, ScalarUInt64, S_S, UInt16, UInt64, UInt64);
408 scilab_fill_add(ScalarUInt16, ScalarBool, S_S, UInt16, Bool, UInt16);
412 scilab_fill_add(Int32, Double, M_M, Int32, Double, Int32);
413 scilab_fill_add(Int32, Int8, M_M, Int32, Int8, Int32);
414 scilab_fill_add(Int32, UInt8, M_M, Int32, UInt8, UInt32);
415 scilab_fill_add(Int32, Int16, M_M, Int32, Int16, Int32);
416 scilab_fill_add(Int32, UInt16, M_M, Int32, UInt16, UInt32);
417 scilab_fill_add(Int32, Int32, M_M, Int32, Int32, Int32);
418 scilab_fill_add(Int32, UInt32, M_M, Int32, UInt32, UInt32);
419 scilab_fill_add(Int32, Int64, M_M, Int32, Int64, Int64);
420 scilab_fill_add(Int32, UInt64, M_M, Int32, UInt64, UInt64);
421 scilab_fill_add(Int32, Bool, M_M, Int32, Bool, Int32);
422 scilab_fill_add(Int32, Empty, M_E, Int32, Double, Int32);
425 scilab_fill_add(Int32, ScalarDouble, M_S, Int32, Double, Int32);
426 scilab_fill_add(Int32, ScalarInt8, M_S, Int32, Int8, Int32);
427 scilab_fill_add(Int32, ScalarUInt8, M_S, Int32, UInt8, UInt32);
428 scilab_fill_add(Int32, ScalarInt16, M_S, Int32, Int16, Int32);
429 scilab_fill_add(Int32, ScalarUInt16, M_S, Int32, UInt16, UInt32);
430 scilab_fill_add(Int32, ScalarInt32, M_S, Int32, Int32, Int32);
431 scilab_fill_add(Int32, ScalarUInt32, M_S, Int32, UInt32, UInt32);
432 scilab_fill_add(Int32, ScalarInt64, M_S, Int32, Int64, Int64);
433 scilab_fill_add(Int32, ScalarUInt64, M_S, Int32, UInt64, UInt64);
434 scilab_fill_add(Int32, ScalarBool, M_S, Int32, Bool, Int32);
437 scilab_fill_add(ScalarInt32, Double, S_M, Int32, Double, Int32);
438 scilab_fill_add(ScalarInt32, Int8, S_M, Int32, Int8, Int32);
439 scilab_fill_add(ScalarInt32, UInt8, S_M, Int32, UInt8, UInt32);
440 scilab_fill_add(ScalarInt32, Int16, S_M, Int32, Int16, Int32);
441 scilab_fill_add(ScalarInt32, UInt16, S_M, Int32, UInt16, UInt32);
442 scilab_fill_add(ScalarInt32, Int32, S_M, Int32, Int32, Int32);
443 scilab_fill_add(ScalarInt32, UInt32, S_M, Int32, UInt32, UInt32);
444 scilab_fill_add(ScalarInt32, Int64, S_M, Int32, Int64, Int64);
445 scilab_fill_add(ScalarInt32, UInt64, S_M, Int32, UInt64, UInt64);
446 scilab_fill_add(ScalarInt32, Bool, S_M, Int32, Bool, Int32);
447 scilab_fill_add(ScalarInt32, Empty, S_E, Int32, Double, Int32);
450 scilab_fill_add(ScalarInt32, ScalarDouble, S_S, Int32, Double, Int32);
451 scilab_fill_add(ScalarInt32, ScalarInt8, S_S, Int32, Int8, Int32);
452 scilab_fill_add(ScalarInt32, ScalarUInt8, S_S, Int32, UInt8, UInt32);
453 scilab_fill_add(ScalarInt32, ScalarInt16, S_S, Int32, Int16, Int32);
454 scilab_fill_add(ScalarInt32, ScalarUInt16, S_S, Int32, UInt16, UInt32);
455 scilab_fill_add(ScalarInt32, ScalarInt32, S_S, Int32, Int32, Int32);
456 scilab_fill_add(ScalarInt32, ScalarUInt32, S_S, Int32, UInt32, UInt32);
457 scilab_fill_add(ScalarInt32, ScalarInt64, S_S, Int32, Int64, Int64);
458 scilab_fill_add(ScalarInt32, ScalarUInt64, S_S, Int32, UInt64, UInt64);
459 scilab_fill_add(ScalarInt32, ScalarBool, S_S, Int32, Bool, Int32);
463 scilab_fill_add(UInt32, Double, M_M, UInt32, Double, UInt32);
464 scilab_fill_add(UInt32, Int8, M_M, UInt32, Int8, UInt32);
465 scilab_fill_add(UInt32, UInt8, M_M, UInt32, UInt8, UInt32);
466 scilab_fill_add(UInt32, Int16, M_M, UInt32, Int16, UInt32);
467 scilab_fill_add(UInt32, UInt16, M_M, UInt32, UInt16, UInt32);
468 scilab_fill_add(UInt32, Int32, M_M, UInt32, Int32, UInt32);
469 scilab_fill_add(UInt32, UInt32, M_M, UInt32, UInt32, UInt32);
470 scilab_fill_add(UInt32, Int64, M_M, UInt32, Int64, UInt64);
471 scilab_fill_add(UInt32, UInt64, M_M, UInt32, UInt64, UInt64);
472 scilab_fill_add(UInt32, Bool, M_M, UInt32, Bool, UInt32);
473 scilab_fill_add(UInt32, Empty, M_E, UInt32, Double, UInt32);
476 scilab_fill_add(UInt32, ScalarDouble, M_S, UInt32, Double, UInt32);
477 scilab_fill_add(UInt32, ScalarInt8, M_S, UInt32, Int8, UInt32);
478 scilab_fill_add(UInt32, ScalarUInt8, M_S, UInt32, UInt8, UInt32);
479 scilab_fill_add(UInt32, ScalarInt16, M_S, UInt32, Int16, UInt32);
480 scilab_fill_add(UInt32, ScalarUInt16, M_S, UInt32, UInt16, UInt32);
481 scilab_fill_add(UInt32, ScalarInt32, M_S, UInt32, Int32, UInt32);
482 scilab_fill_add(UInt32, ScalarUInt32, M_S, UInt32, UInt32, UInt32);
483 scilab_fill_add(UInt32, ScalarInt64, M_S, UInt32, Int64, UInt64);
484 scilab_fill_add(UInt32, ScalarUInt64, M_S, UInt32, UInt64, UInt64);
485 scilab_fill_add(UInt32, ScalarBool, M_S, UInt32, Bool, UInt32);
488 scilab_fill_add(ScalarUInt32, Double, S_M, UInt32, Double, UInt32);
489 scilab_fill_add(ScalarUInt32, Int8, S_M, UInt32, Int8, UInt32);
490 scilab_fill_add(ScalarUInt32, UInt8, S_M, UInt32, UInt8, UInt32);
491 scilab_fill_add(ScalarUInt32, Int16, S_M, UInt32, Int16, UInt32);
492 scilab_fill_add(ScalarUInt32, UInt16, S_M, UInt32, UInt16, UInt32);
493 scilab_fill_add(ScalarUInt32, Int32, S_M, UInt32, Int32, UInt32);
494 scilab_fill_add(ScalarUInt32, UInt32, S_M, UInt32, UInt32, UInt32);
495 scilab_fill_add(ScalarUInt32, Int64, S_M, UInt32, Int64, UInt64);
496 scilab_fill_add(ScalarUInt32, UInt64, S_M, UInt32, UInt64, UInt64);
497 scilab_fill_add(ScalarUInt32, Bool, S_M, UInt32, Bool, UInt32);
498 scilab_fill_add(ScalarUInt32, Empty, S_E, UInt32, Double, UInt32);
501 scilab_fill_add(ScalarUInt32, ScalarDouble, S_S, UInt32, Double, UInt32);
502 scilab_fill_add(ScalarUInt32, ScalarInt8, S_S, UInt32, Int8, UInt32);
503 scilab_fill_add(ScalarUInt32, ScalarUInt8, S_S, UInt32, UInt8, UInt32);
504 scilab_fill_add(ScalarUInt32, ScalarInt16, S_S, UInt32, Int16, UInt32);
505 scilab_fill_add(ScalarUInt32, ScalarUInt16, S_S, UInt32, UInt16, UInt32);
506 scilab_fill_add(ScalarUInt32, ScalarInt32, S_S, UInt32, Int32, UInt32);
507 scilab_fill_add(ScalarUInt32, ScalarUInt32, S_S, UInt32, UInt32, UInt32);
508 scilab_fill_add(ScalarUInt32, ScalarInt64, S_S, UInt32, Int64, UInt64);
509 scilab_fill_add(ScalarUInt32, ScalarUInt64, S_S, UInt32, UInt64, UInt64);
510 scilab_fill_add(ScalarUInt32, ScalarBool, S_S, UInt32, Bool, UInt32);
514 scilab_fill_add(Int64, Double, M_M, Int64, Double, Int64);
515 scilab_fill_add(Int64, Int8, M_M, Int64, Int8, Int64);
516 scilab_fill_add(Int64, UInt8, M_M, Int64, UInt8, UInt64);
517 scilab_fill_add(Int64, Int16, M_M, Int64, Int16, Int64);
518 scilab_fill_add(Int64, UInt16, M_M, Int64, UInt16, UInt64);
519 scilab_fill_add(Int64, Int32, M_M, Int64, Int32, Int64);
520 scilab_fill_add(Int64, UInt32, M_M, Int64, UInt32, UInt64);
521 scilab_fill_add(Int64, Int64, M_M, Int64, Int64, Int64);
522 scilab_fill_add(Int64, UInt64, M_M, Int64, UInt64, UInt64);
523 scilab_fill_add(Int64, Bool, M_M, Int64, Bool, Int64);
524 scilab_fill_add(Int64, Empty, M_E, Int64, Double, Int64);
527 scilab_fill_add(Int64, ScalarDouble, M_S, Int64, Double, Int64);
528 scilab_fill_add(Int64, ScalarInt8, M_S, Int64, Int8, Int64);
529 scilab_fill_add(Int64, ScalarUInt8, M_S, Int64, UInt8, UInt64);
530 scilab_fill_add(Int64, ScalarInt16, M_S, Int64, Int16, Int64);
531 scilab_fill_add(Int64, ScalarUInt16, M_S, Int64, UInt16, UInt64);
532 scilab_fill_add(Int64, ScalarInt32, M_S, Int64, Int32, Int64);
533 scilab_fill_add(Int64, ScalarUInt32, M_S, Int64, UInt32, UInt64);
534 scilab_fill_add(Int64, ScalarInt64, M_S, Int64, Int64, Int64);
535 scilab_fill_add(Int64, ScalarUInt64, M_S, Int64, UInt64, UInt64);
536 scilab_fill_add(Int64, ScalarBool, M_S, Int64, Bool, Int64);
539 scilab_fill_add(ScalarInt64, Double, S_M, Int64, Double, Int64);
540 scilab_fill_add(ScalarInt64, Int8, S_M, Int64, Int8, Int64);
541 scilab_fill_add(ScalarInt64, UInt8, S_M, Int64, UInt8, UInt64);
542 scilab_fill_add(ScalarInt64, Int16, S_M, Int64, Int16, Int64);
543 scilab_fill_add(ScalarInt64, UInt16, S_M, Int64, UInt16, UInt64);
544 scilab_fill_add(ScalarInt64, Int32, S_M, Int64, Int32, Int64);
545 scilab_fill_add(ScalarInt64, UInt32, S_M, Int64, UInt32, UInt64);
546 scilab_fill_add(ScalarInt64, Int64, S_M, Int64, Int64, Int64);
547 scilab_fill_add(ScalarInt64, UInt64, S_M, Int64, UInt64, UInt64);
548 scilab_fill_add(ScalarInt64, Bool, S_M, Int64, Bool, Int64);
549 scilab_fill_add(ScalarInt64, Empty, S_E, Int64, Double, Int64);
552 scilab_fill_add(ScalarInt64, ScalarDouble, S_S, Int64, Double, Int64);
553 scilab_fill_add(ScalarInt64, ScalarInt8, S_S, Int64, Int8, Int64);
554 scilab_fill_add(ScalarInt64, ScalarUInt8, S_S, Int64, UInt8, UInt64);
555 scilab_fill_add(ScalarInt64, ScalarInt16, S_S, Int64, Int16, Int64);
556 scilab_fill_add(ScalarInt64, ScalarUInt16, S_S, Int64, UInt16, UInt64);
557 scilab_fill_add(ScalarInt64, ScalarInt32, S_S, Int64, Int32, Int64);
558 scilab_fill_add(ScalarInt64, ScalarUInt32, S_S, Int64, UInt32, UInt64);
559 scilab_fill_add(ScalarInt64, ScalarInt64, S_S, Int64, Int64, Int64);
560 scilab_fill_add(ScalarInt64, ScalarUInt64, S_S, Int64, UInt64, UInt64);
561 scilab_fill_add(ScalarInt64, ScalarBool, S_S, Int64, Bool, Int64);
565 scilab_fill_add(UInt64, Double, M_M, UInt64, Double, UInt64);
566 scilab_fill_add(UInt64, Int8, M_M, UInt64, Int8, UInt64);
567 scilab_fill_add(UInt64, UInt8, M_M, UInt64, UInt8, UInt64);
568 scilab_fill_add(UInt64, Int16, M_M, UInt64, Int16, UInt64);
569 scilab_fill_add(UInt64, UInt16, M_M, UInt64, UInt16, UInt64);
570 scilab_fill_add(UInt64, Int32, M_M, UInt64, Int32, UInt64);
571 scilab_fill_add(UInt64, UInt32, M_M, UInt64, UInt32, UInt64);
572 scilab_fill_add(UInt64, Int64, M_M, UInt64, Int64, UInt64);
573 scilab_fill_add(UInt64, UInt64, M_M, UInt64, UInt64, UInt64);
574 scilab_fill_add(UInt64, Bool, M_M, UInt64, Bool, UInt64);
575 scilab_fill_add(UInt64, Empty, M_E, UInt64, Double, UInt64);
578 scilab_fill_add(UInt64, ScalarDouble, M_S, UInt64, Double, UInt64);
579 scilab_fill_add(UInt64, ScalarInt8, M_S, UInt64, Int8, UInt64);
580 scilab_fill_add(UInt64, ScalarUInt8, M_S, UInt64, UInt8, UInt64);
581 scilab_fill_add(UInt64, ScalarInt16, M_S, UInt64, Int16, UInt64);
582 scilab_fill_add(UInt64, ScalarUInt16, M_S, UInt64, UInt16, UInt64);
583 scilab_fill_add(UInt64, ScalarInt32, M_S, UInt64, Int32, UInt64);
584 scilab_fill_add(UInt64, ScalarUInt32, M_S, UInt64, UInt32, UInt64);
585 scilab_fill_add(UInt64, ScalarInt64, M_S, UInt64, Int64, UInt64);
586 scilab_fill_add(UInt64, ScalarUInt64, M_S, UInt64, UInt64, UInt64);
587 scilab_fill_add(UInt64, ScalarBool, M_S, UInt64, Bool, UInt64);
590 scilab_fill_add(ScalarUInt64, Double, S_M, UInt64, Double, UInt64);
591 scilab_fill_add(ScalarUInt64, Int8, S_M, UInt64, Int8, UInt64);
592 scilab_fill_add(ScalarUInt64, UInt8, S_M, UInt64, UInt8, UInt64);
593 scilab_fill_add(ScalarUInt64, Int16, S_M, UInt64, Int16, UInt64);
594 scilab_fill_add(ScalarUInt64, UInt16, S_M, UInt64, UInt16, UInt64);
595 scilab_fill_add(ScalarUInt64, Int32, S_M, UInt64, Int32, UInt64);
596 scilab_fill_add(ScalarUInt64, UInt32, S_M, UInt64, UInt32, UInt64);
597 scilab_fill_add(ScalarUInt64, Int64, S_M, UInt64, Int64, UInt64);
598 scilab_fill_add(ScalarUInt64, UInt64, S_M, UInt64, UInt64, UInt64);
599 scilab_fill_add(ScalarUInt64, Bool, S_M, UInt64, Bool, UInt64);
600 scilab_fill_add(ScalarUInt64, Empty, S_E, UInt64, Double, UInt64);
603 scilab_fill_add(ScalarUInt64, ScalarDouble, S_S, UInt64, Double, UInt64);
604 scilab_fill_add(ScalarUInt64, ScalarInt8, S_S, UInt64, Int8, UInt64);
605 scilab_fill_add(ScalarUInt64, ScalarUInt8, S_S, UInt64, UInt8, UInt64);
606 scilab_fill_add(ScalarUInt64, ScalarInt16, S_S, UInt64, Int16, UInt64);
607 scilab_fill_add(ScalarUInt64, ScalarUInt16, S_S, UInt64, UInt16, UInt64);
608 scilab_fill_add(ScalarUInt64, ScalarInt32, S_S, UInt64, Int32, UInt64);
609 scilab_fill_add(ScalarUInt64, ScalarUInt32, S_S, UInt64, UInt32, UInt64);
610 scilab_fill_add(ScalarUInt64, ScalarInt64, S_S, UInt64, Int64, UInt64);
611 scilab_fill_add(ScalarUInt64, ScalarUInt64, S_S, UInt64, UInt64, UInt64);
612 scilab_fill_add(ScalarUInt64, ScalarBool, S_S, UInt64, Bool, UInt64);
616 scilab_fill_add(Bool, Double, M_M, Bool, Double, Double);
617 scilab_fill_add(Bool, Int8, M_M, Bool, Int8, Int8);
618 scilab_fill_add(Bool, UInt8, M_M, Bool, UInt8, UInt8);
619 scilab_fill_add(Bool, Int16, M_M, Bool, Int16, Int16);
620 scilab_fill_add(Bool, UInt16, M_M, Bool, UInt16, UInt16);
621 scilab_fill_add(Bool, Int32, M_M, Bool, Int32, Int32);
622 scilab_fill_add(Bool, UInt32, M_M, Bool, UInt32, UInt32);
623 scilab_fill_add(Bool, Int64, M_M, Bool, Int64, Int64);
624 scilab_fill_add(Bool, UInt64, M_M, Bool, UInt64, UInt64);
625 scilab_fill_add(Bool, Bool, M_M, Bool, Bool, Bool);
626 scilab_fill_add(Bool, Empty, M_E, Bool, Double, Double);
629 scilab_fill_add(Bool, ScalarDouble, M_S, Bool, Double, Double);
630 scilab_fill_add(Bool, ScalarInt8, M_S, Bool, Int8, Int8);
631 scilab_fill_add(Bool, ScalarUInt8, M_S, Bool, UInt8, UInt8);
632 scilab_fill_add(Bool, ScalarInt16, M_S, Bool, Int16, Int16);
633 scilab_fill_add(Bool, ScalarUInt16, M_S, Bool, UInt16, UInt16);
634 scilab_fill_add(Bool, ScalarInt32, M_S, Bool, Int32, Int32);
635 scilab_fill_add(Bool, ScalarUInt32, M_S, Bool, UInt32, UInt32);
636 scilab_fill_add(Bool, ScalarInt64, M_S, Bool, Int64, Int64);
637 scilab_fill_add(Bool, ScalarUInt64, M_S, Bool, UInt64, UInt64);
638 scilab_fill_add(Bool, ScalarBool, M_S, Bool, Bool, Bool);
641 scilab_fill_add(ScalarBool, Double, S_M, Bool, Double, Double);
642 scilab_fill_add(ScalarBool, Int8, S_M, Bool, Int8, Int8);
643 scilab_fill_add(ScalarBool, UInt8, S_M, Bool, UInt8, UInt8);
644 scilab_fill_add(ScalarBool, Int16, S_M, Bool, Int16, Int16);
645 scilab_fill_add(ScalarBool, UInt16, S_M, Bool, UInt16, UInt16);
646 scilab_fill_add(ScalarBool, Int32, S_M, Bool, Int32, Int32);
647 scilab_fill_add(ScalarBool, UInt32, S_M, Bool, UInt32, UInt32);
648 scilab_fill_add(ScalarBool, Int64, S_M, Bool, Int64, Int64);
649 scilab_fill_add(ScalarBool, UInt64, S_M, Bool, UInt64, UInt64);
650 scilab_fill_add(ScalarBool, Bool, S_M, Bool, Bool, Bool);
651 scilab_fill_add(ScalarBool, Empty, S_E, Bool, Double, Double);
654 scilab_fill_add(ScalarBool, ScalarDouble, S_S, Bool, Double, Double);
655 scilab_fill_add(ScalarBool, ScalarInt8, S_S, Bool, Int8, Int8);
656 scilab_fill_add(ScalarBool, ScalarUInt8, S_S, Bool, UInt8, UInt8);
657 scilab_fill_add(ScalarBool, ScalarInt16, S_S, Bool, Int16, Int16);
658 scilab_fill_add(ScalarBool, ScalarUInt16, S_S, Bool, UInt16, UInt16);
659 scilab_fill_add(ScalarBool, ScalarInt32, S_S, Bool, Int32, Int32);
660 scilab_fill_add(ScalarBool, ScalarUInt32, S_S, Bool, UInt32, UInt32);
661 scilab_fill_add(ScalarBool, ScalarInt64, S_S, Bool, Int64, Int64);
662 scilab_fill_add(ScalarBool, ScalarUInt64, S_S, Bool, UInt64, UInt64);
663 scilab_fill_add(ScalarBool, ScalarBool, S_S, Bool, Bool, Bool);
666 scilab_fill_add(String, String, M_M, String, String, String);
667 scilab_fill_add(String, ScalarString, M_S, String, String, String);
668 scilab_fill_add(String, Empty, M_E, String, Double, String);
670 scilab_fill_add(ScalarString, String, S_M, String, String, String);
671 scilab_fill_add(ScalarString, ScalarString, S_S, String, String, String);
672 scilab_fill_add(ScalarString, Empty, S_E, String, Double, String);
675 scilab_fill_add(Identity, Double, I_M, Double, Double, Double);
676 scilab_fill_add(Identity, DoubleComplex, I_MC, Double, Double, Double);
677 scilab_fill_add(Identity, ScalarDouble, I_S, Double, Double, Double);
678 scilab_fill_add(Identity, ScalarDoubleComplex, I_SC, Double, Double, Double);
679 scilab_fill_add(Identity, Identity, I_I, Double, Double, Double);
680 scilab_fill_add(Identity, IdentityComplex, I_IC, Double, Double, Double);
681 scilab_fill_add(Identity, Empty, I_E, Double, Double, Double);
683 scilab_fill_add(Identity, Polynom, I_M, Double, Polynom, Polynom);
684 scilab_fill_add(Identity, PolynomComplex, I_M, Double, Polynom, Polynom);
685 scilab_fill_add(Identity, ScalarPolynom, I_M, Double, Polynom, Polynom);
686 scilab_fill_add(Identity, ScalarPolynomComplex, I_M, Double, Polynom, Polynom);
687 scilab_fill_add(Identity, Sparse, M_M, Double, Sparse, Sparse);
688 scilab_fill_add(Identity, SparseComplex, M_M, Double, Sparse, Sparse);
690 scilab_fill_add(IdentityComplex, Double, IC_M, Double, Double, Double);
691 scilab_fill_add(IdentityComplex, DoubleComplex, IC_MC, Double, Double, Double);
692 scilab_fill_add(IdentityComplex, ScalarDouble, IC_S, Double, Double, Double);
693 scilab_fill_add(IdentityComplex, ScalarDoubleComplex, IC_SC, Double, Double, Double);
694 scilab_fill_add(IdentityComplex, Identity, IC_I, Double, Double, Double);
695 scilab_fill_add(IdentityComplex, IdentityComplex, IC_IC, Double, Double, Double);
696 scilab_fill_add(IdentityComplex, Empty, IC_E, Double, Double, Double);
698 scilab_fill_add(IdentityComplex, Polynom, I_M, Double, Polynom, Polynom);
699 scilab_fill_add(IdentityComplex, PolynomComplex, I_M, Double, Polynom, Polynom);
700 scilab_fill_add(IdentityComplex, ScalarPolynom, I_M, Double, Polynom, Polynom);
701 scilab_fill_add(IdentityComplex, ScalarPolynomComplex, I_M, Double, Polynom, Polynom);
702 scilab_fill_add(IdentityComplex, Sparse, M_M, Double, Sparse, Sparse);
703 scilab_fill_add(IdentityComplex, SparseComplex, M_M, Double, Sparse, Sparse);
708 scilab_fill_add(Polynom, Polynom, M_M, Polynom, Polynom, Polynom);
709 scilab_fill_add(Polynom, PolynomComplex, M_M, Polynom, Polynom, Polynom);
710 scilab_fill_add(PolynomComplex, Polynom, M_M, Polynom, Polynom, Polynom);
711 scilab_fill_add(PolynomComplex, PolynomComplex, M_M, Polynom, Polynom, Polynom);
714 scilab_fill_add(Polynom, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
715 scilab_fill_add(Polynom, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
716 scilab_fill_add(PolynomComplex, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
717 scilab_fill_add(PolynomComplex, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
720 scilab_fill_add(Polynom, Double, M_M, Polynom, Double, Polynom);
721 scilab_fill_add(Polynom, DoubleComplex, M_M, Polynom, Double, Polynom);
722 scilab_fill_add(PolynomComplex, Double, M_M, Polynom, Double, Polynom);
723 scilab_fill_add(PolynomComplex, DoubleComplex, M_M, Polynom, Double, Polynom);
725 //poly + scalar double
726 scilab_fill_add(Polynom, ScalarDouble, M_M, Polynom, Double, Polynom);
727 scilab_fill_add(Polynom, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
728 scilab_fill_add(PolynomComplex, ScalarDouble, M_M, Polynom, Double, Polynom);
729 scilab_fill_add(PolynomComplex, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
732 scilab_fill_add(Polynom, Empty, M_M, Polynom, Double, Polynom);
733 scilab_fill_add(PolynomComplex, Empty, M_M, Polynom, Double, Polynom);
736 scilab_fill_add(Polynom, Identity, M_I, Polynom, Double, Polynom);
737 scilab_fill_add(Polynom, IdentityComplex, M_I, Polynom, Double, Polynom);
738 scilab_fill_add(PolynomComplex, Identity, M_I, Polynom, Double, Polynom);
739 scilab_fill_add(PolynomComplex, IdentityComplex, M_I, Polynom, Double, Polynom);
742 scilab_fill_add(ScalarPolynom, Polynom, M_M, Polynom, Polynom, Polynom);
743 scilab_fill_add(ScalarPolynom, PolynomComplex, M_M, Polynom, Polynom, Polynom);
744 scilab_fill_add(ScalarPolynomComplex, Polynom, M_M, Polynom, Polynom, Polynom);
745 scilab_fill_add(ScalarPolynomComplex, PolynomComplex, M_M, Polynom, Polynom, Polynom);
747 //scalar poly + scalar poly
748 scilab_fill_add(ScalarPolynom, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
749 scilab_fill_add(ScalarPolynom, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
750 scilab_fill_add(ScalarPolynomComplex, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
751 scilab_fill_add(ScalarPolynomComplex, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
753 //scalar poly + double
754 scilab_fill_add(ScalarPolynom, Double, M_M, Polynom, Double, Polynom);
755 scilab_fill_add(ScalarPolynom, DoubleComplex, M_M, Polynom, Double, Polynom);
756 scilab_fill_add(ScalarPolynomComplex, Double, M_M, Polynom, Double, Polynom);
757 scilab_fill_add(ScalarPolynomComplex, DoubleComplex, M_M, Polynom, Double, Polynom);
759 //scalar poly + scalar double
760 scilab_fill_add(ScalarPolynom, ScalarDouble, M_M, Polynom, Double, Polynom);
761 scilab_fill_add(ScalarPolynom, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
762 scilab_fill_add(ScalarPolynomComplex, ScalarDouble, M_M, Polynom, Double, Polynom);
763 scilab_fill_add(ScalarPolynomComplex, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
766 scilab_fill_add(ScalarPolynom, Empty, M_M, Polynom, Double, Polynom);
767 scilab_fill_add(ScalarPolynomComplex, Empty, M_M, Polynom, Double, Polynom);
770 scilab_fill_add(ScalarPolynom, Identity, M_I, Polynom, Double, Polynom);
771 scilab_fill_add(ScalarPolynom, IdentityComplex, M_I, Polynom, Double, Polynom);
772 scilab_fill_add(ScalarPolynomComplex, Identity, M_I, Polynom, Double, Polynom);
773 scilab_fill_add(ScalarPolynomComplex, IdentityComplex, M_I, Polynom, Double, Polynom);
776 scilab_fill_add(Sparse, Sparse, M_M, Sparse, Sparse, Sparse);
777 scilab_fill_add(Sparse, SparseComplex, M_M, Sparse, Sparse, Sparse);
778 scilab_fill_add(Sparse, Double, M_M, Sparse, Double, Double);
779 scilab_fill_add(Sparse, DoubleComplex, M_M, Sparse, Double, Double);
780 scilab_fill_add(Sparse, ScalarDouble, M_M, Sparse, Double, Double);
781 scilab_fill_add(Sparse, ScalarDoubleComplex, M_M, Sparse, Double, Double);
783 scilab_fill_add(Sparse, Empty, M_M, Sparse, Double, Sparse);
784 scilab_fill_add(Sparse, Identity, M_M, Sparse, Double, Sparse);
785 scilab_fill_add(Sparse, IdentityComplex, M_M, Sparse, Double, Sparse);
787 scilab_fill_add(SparseComplex, Sparse, M_M, Sparse, Sparse, Sparse);
788 scilab_fill_add(SparseComplex, SparseComplex, M_M, Sparse, Sparse, Sparse);
789 scilab_fill_add(SparseComplex, Double, M_M, Sparse, Double, Double);
790 scilab_fill_add(SparseComplex, DoubleComplex, M_M, Sparse, Double, Double);
791 scilab_fill_add(SparseComplex, ScalarDouble, M_M, Sparse, Double, Double);
792 scilab_fill_add(SparseComplex, ScalarDoubleComplex, M_M, Sparse, Double, Double);
794 scilab_fill_add(SparseComplex, Empty, M_M, Sparse, Double, Sparse);
795 scilab_fill_add(SparseComplex, Identity, M_M, Sparse, Double, Sparse);
796 scilab_fill_add(SparseComplex, IdentityComplex, M_M, Sparse, Double, Sparse);
798 #undef scilab_fill_add
801 InternalType *GenericPlus(InternalType *_pLeftOperand, InternalType *_pRightOperand)
803 InternalType *pResult = NULL;
805 add_function add = pAddfunction[_pLeftOperand->getId()][_pRightOperand->getId()];
808 pResult = add(_pLeftOperand, _pRightOperand);
816 ** Default case : Return NULL will Call Overloading.
821 int AddSparseToSparse(Sparse* sp1, Sparse* sp2, Sparse** pSpRes)
823 //check scalar hidden in a sparse ;)
824 if (sp1->getRows() == 1 && sp1->getCols() == 1)
828 if (sp1->isComplex())
830 std::complex<double> dbl = sp1->getImg(0, 0);
831 pDbl = new Double(dbl.real(), dbl.imag());
835 pDbl = new Double(sp1->get(0, 0));
838 AddSparseToDouble(sp2, pDbl, (GenericType**)pSpRes);
843 if (sp2->getRows() == 1 && sp2->getCols() == 1)
847 if (sp2->isComplex())
849 std::complex<double> dbl = sp2->getImg(0, 0);
850 pDbl = new Double(dbl.real(), dbl.imag());
854 pDbl = new Double(sp2->get(0, 0));
857 AddSparseToDouble(sp1, pDbl, (GenericType**)pSpRes);
862 if (sp1->getRows() != sp2->getRows() || sp1->getCols() != sp2->getCols())
864 //dimensions not match
868 if (sp1->nonZeros() == 0)
871 *pSpRes = new Sparse(*sp2);
875 if (sp2->nonZeros() == 0)
878 *pSpRes = new Sparse(*sp1);
883 *pSpRes = sp1->add(*sp2);
887 int AddSparseToDouble(Sparse* sp, Double* d, GenericType** pDRes)
889 int iOne = 1; //fortran
890 bool bComplex1 = sp->isComplex();
891 bool bComplex2 = d->isComplex();
896 Sparse* pS = new Sparse(sp->getRows(), sp->getCols(), d->isComplex());
899 for (int i = 0 ; i < std::min(sp->getRows(), sp->getCols()) ; i++)
901 pS->set(i, i, std::complex<double>(d->get(0), d->getImg(0)));
906 for (int i = 0 ; i < std::min(sp->getRows(), sp->getCols()) ; i++)
908 pS->set(i, i, d->get(0));
912 AddSparseToSparse(sp, pS, (Sparse**)pDRes);
917 if (sp->isScalar() && d->isScalar())
920 Double* pRes = (Double*)d->clone();
921 pRes->setComplex(bComplex1 | bComplex2);
924 std::complex<double> dbl = sp->getImg(0, 0);
925 pRes->set(0, pRes->get(0) + dbl.real());
926 pRes->setImg(0, pRes->getImg(0) + dbl.imag());
930 pRes->set(0, pRes->get(0) + sp->get(0, 0));
940 Double* pRes = new Double(sp->getRows(), sp->getCols(), bComplex1 | bComplex2);
941 int iSize = sp->getSize();
942 double dblVal = d->get(0);
943 C2F(dset)(&iSize, &dblVal, pRes->get(), &iOne);
946 double dblValI = d->getImg(0);
947 C2F(dset)(&iSize, &dblValI, pRes->getImg(), &iOne);
951 //initialize imag part at 0
953 C2F(dset)(&iSize, &dblValI, pRes->getImg(), &iOne);
956 int nonZeros = static_cast<int>(sp->nonZeros());
957 int* pRows = new int[nonZeros * 2];
958 sp->outputRowCol(pRows);
959 int* pCols = pRows + nonZeros;
963 for (int i = 0 ; i < nonZeros ; i++)
965 int iRow = static_cast<int>(pRows[i]) - 1;
966 int iCol = static_cast<int>(pCols[i]) - 1;
967 std::complex<double> dbl = sp->getImg(iRow, iCol);
968 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + dbl.real());
969 pRes->setImg(iRow, iCol, pRes->getImg(iRow, iCol) + dbl.imag());
974 for (int i = 0 ; i < nonZeros ; i++)
976 int iRow = static_cast<int>(pRows[i]) - 1;
977 int iCol = static_cast<int>(pCols[i]) - 1;
978 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + sp->get(iRow, iCol));
992 Double* pRes = (Double*)d->clone();
993 pRes->setComplex(bComplex1 | bComplex2);
997 double* pReal = pRes->get();
998 double* pImg = pRes->getImg();
999 for (int i = 0 ; i < pRes->getSize() ; i++)
1001 std::complex<double> dbl = sp->getImg(0, 0);
1002 pReal[i] += dbl.real();
1003 pImg[i] += dbl.imag();
1008 double* pReal = pRes->get();
1009 for (int i = 0 ; i < pRes->getSize() ; i++)
1011 pReal[i] += sp->get(0, 0);
1020 if (sp->getRows() == d->getRows() && sp->getCols() == d->getCols())
1023 Double* pRes = (Double*)d->clone();
1024 pRes->setComplex(bComplex1 | bComplex2);
1026 int nonZeros = static_cast<int>(sp->nonZeros());
1027 int* pRows = new int[nonZeros * 2];
1028 sp->outputRowCol(pRows);
1029 int* pCols = pRows + nonZeros;
1033 for (int i = 0 ; i < nonZeros ; i++)
1035 int iRow = static_cast<int>(pRows[i]) - 1;
1036 int iCol = static_cast<int>(pCols[i]) - 1;
1037 std::complex<double> dbl = sp->getImg(iRow, iCol);
1038 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + dbl.real());
1039 pRes->setImg(iRow, iCol, pRes->getImg(iRow, iCol) + dbl.imag());
1044 for (int i = 0 ; i < nonZeros ; i++)
1046 int iRow = static_cast<int>(pRows[i]) - 1;
1047 int iCol = static_cast<int>(pCols[i]) - 1;
1048 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + sp->get(iRow, iCol));
1060 int AddDoubleToSparse(Double* d, Sparse* sp, GenericType** pDRes)
1062 /* uses commutativity */
1063 return AddSparseToDouble(sp, d, pDRes);
1066 template<class T, class U, class O>
1067 InternalType* add_M_M(T *_pL, U *_pR)
1069 int iDimsL = _pL->getDims();
1070 int iDimsR = _pR->getDims();
1072 if (iDimsL != iDimsR)
1074 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1077 int* piDimsL = _pL->getDimsArray();
1078 int* piDimsR = _pR->getDimsArray();
1080 for (int i = 0 ; i < iDimsL ; ++i)
1082 if (piDimsL[i] != piDimsR[i])
1084 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1088 O* pOut = new O(iDimsL, piDimsL);
1090 add(_pL->get(), (size_t)_pL->getSize(), _pR->get(), pOut->get());
1094 template<class T, class U, class O>
1095 InternalType* add_M_MC(T *_pL, U *_pR)
1097 int iDimsL = _pL->getDims();
1098 int iDimsR = _pR->getDims();
1100 if (iDimsL != iDimsR)
1102 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1105 int* piDimsL = _pL->getDimsArray();
1106 int* piDimsR = _pR->getDimsArray();
1108 for (int i = 0 ; i < iDimsL ; ++i)
1110 if (piDimsL[i] != piDimsR[i])
1112 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1116 O* pOut = new O(iDimsL, piDimsL, true);
1118 add(_pL->get(), (size_t)_pL->getSize(), _pR->get(), _pR->getImg(), pOut->get(), pOut->getImg());
1122 template<class T, class U, class O>
1123 InternalType* add_M_S(T *_pL, U *_pR)
1125 O* pOut = new O(_pL->getDims(), _pL->getDimsArray());
1126 add(_pL->get(), (size_t)_pL->getSize(), _pR->get(0), pOut->get());
1130 template<class T, class U, class O>
1131 InternalType* add_M_SC(T *_pL, U *_pR)
1133 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1134 add(_pL->get(), (size_t)_pL->getSize(), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1138 template<class T, class U, class O>
1139 InternalType* add_M_E(T *_pL, U * /*_pR*/)
1145 template<class T, class U, class O>
1146 InternalType* add_MC_M(T *_pL, U *_pR)
1148 return add_M_MC<U, T, O>(_pR, _pL);
1151 template<class T, class U, class O>
1152 InternalType* add_MC_MC(T *_pL, U *_pR)
1154 int iDimsL = _pL->getDims();
1155 int iDimsR = _pR->getDims();
1157 if (iDimsL != iDimsR)
1159 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1162 int* piDimsL = _pL->getDimsArray();
1163 int* piDimsR = _pR->getDimsArray();
1165 for (int i = 0 ; i < iDimsL ; ++i)
1167 if (piDimsL[i] != piDimsR[i])
1169 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1173 O* pOut = new O(iDimsL, piDimsL, true);
1175 add(_pL->get(), _pL->getImg(), (size_t)_pL->getSize(), _pR->get(), _pR->getImg(), pOut->get(), pOut->getImg());
1179 template<class T, class U, class O>
1180 InternalType* add_MC_S(T *_pL, U *_pR)
1182 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1183 add(_pL->get(), _pL->getImg(), (size_t)_pL->getSize(), _pR->get(0), pOut->get(), pOut->getImg());
1187 template<class T, class U, class O>
1188 InternalType* add_MC_SC(T *_pL, U *_pR)
1190 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1191 add(_pL->get(), _pL->getImg(), (size_t)_pL->getSize(), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1195 template<class T, class U, class O>
1196 InternalType* add_MC_E(T *_pL, U * /*_pR*/)
1198 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1199 add(_pL->get(), _pL->getImg(), (size_t)_pL->getSize(), pOut->get(), pOut->getImg());
1204 template<class T, class U, class O>
1205 InternalType* add_S_M(T *_pL, U *_pR)
1207 return add_M_S<U, T, O>(_pR, _pL);
1210 template<class T, class U, class O>
1211 InternalType* add_S_MC(T *_pL, U *_pR)
1213 return add_MC_S<U, T, O>(_pR, _pL);
1216 template<class T, class U, class O>
1217 InternalType* add_S_S(T *_pL, U *_pR)
1220 add(_pL->get(0), _pR->get(0), pOut->get());
1224 template<class T, class U, class O>
1225 InternalType* add_S_SC(T *_pL, U *_pR)
1227 O* pOut = new O(0.0, 0.0);
1228 add(_pL->get(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1232 template<class T, class U, class O>
1233 InternalType* add_S_E(T *_pL, U * /*_pR*/)
1236 add(_pL->get(0), pOut->get());
1241 template<class T, class U, class O>
1242 InternalType* add_SC_M(T *_pL, U *_pR)
1244 return add_M_SC<U, T, O>(_pR, _pL);
1247 template<class T, class U, class O>
1248 InternalType* add_SC_MC(T *_pL, U *_pR)
1250 return add_MC_SC<U, T, O>(_pR, _pL);
1253 template<class T, class U, class O>
1254 InternalType* add_SC_S(T *_pL, U *_pR)
1256 return add_S_SC<U, T, O>(_pR, _pL);
1259 template<class T, class U, class O>
1260 InternalType* add_SC_SC(T *_pL, U *_pR)
1262 O* pOut = new O(0.0, 0.0);
1263 add(_pL->get(0), _pL->getImg(0), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1267 template<class T, class U, class O>
1268 InternalType* add_SC_E(T *_pL, U * /*_pR*/)
1270 O* pOut = new O(0.0, 0.0);
1271 add(_pL->get(0), _pL->getImg(0), pOut->get(), pOut->getImg());
1276 template<class T, class U, class O>
1277 InternalType* add_E_M(T *_pL, U *_pR)
1279 return add_M_E<U, T, O>(_pR, _pL);
1282 template<class T, class U, class O>
1283 InternalType* add_E_MC(T *_pL, U *_pR)
1285 return add_MC_E<U, T, O>(_pR, _pL);
1288 template<class T, class U, class O>
1289 InternalType* add_E_S(T *_pL, U *_pR)
1291 return add_S_E<U, T, O>(_pR, _pL);
1294 template<class T, class U, class O>
1295 InternalType* add_E_SC(T *_pL, U *_pR)
1297 return add_SC_E<U, T, O>(_pR, _pL);
1300 template<class T, class U, class O>
1301 InternalType* add_E_E(T * /*_pL*/, U * /*_pR*/)
1303 Double* pOut = Double::Empty();
1308 template<class T, class U, class O>
1309 InternalType* add_I_M(T *_pL, U *_pR)
1311 int iDims = _pR->getDims();
1312 int* piDims = _pR->getDimsArray();
1313 O* pOut = (O*)_pR->clone();
1314 double* pdblOut = pOut->get();
1315 double* pdblRight = _pR->get();
1316 double dblLeft = _pL->get(0);
1317 int iLeadDims = piDims[0];
1318 int* piIndex = new int[iDims];
1322 for (int i = 1 ; i < iDims ; ++i)
1327 if (iLeadDims > piDims[i])
1329 iLeadDims = piDims[i];
1333 for (int i = 0 ; i < iLeadDims ; ++i)
1335 for (int j = 0 ; j < iDims ; ++j)
1340 int index = _pR->getIndex(piIndex);
1341 add(dblLeft, pdblRight[index], pdblOut + index);
1347 template<class T, class U, class O>
1348 InternalType* add_I_MC(T *_pL, U *_pR)
1350 return add_I_M<T, U, O>(_pL, _pR);
1353 template<class T, class U, class O>
1354 InternalType* add_IC_M(T *_pL, U *_pR)
1356 int iDims = _pR->getDims();
1357 int* piDims = _pR->getDimsArray();
1358 O* pOut = (O*)_pR->clone();
1359 pOut->setComplex(true);
1360 int iLeadDims = piDims[0];
1361 int* piIndex = new int[iDims];
1364 for (int i = 1 ; i < iDims ; ++i)
1369 if (iLeadDims > piDims[i])
1371 iLeadDims = piDims[i];
1375 for (int i = 0 ; i < iLeadDims ; ++i)
1377 for (int j = 0 ; j < iDims ; ++j)
1382 int index = _pR->getIndex(piIndex);
1383 add(_pR->get() + index, 1, _pL->get(0), _pL->getImg(0), pOut->get() + index, pOut->getImg() + index);
1389 template<class T, class U, class O>
1390 InternalType* add_IC_MC(T *_pL, U *_pR)
1392 int iDims = _pR->getDims();
1393 int* piDims = _pR->getDimsArray();
1394 O* pOut = (O*)_pR->clone();
1395 int iLeadDims = piDims[0];
1396 int* piIndex = new int[iDims];
1399 for (int i = 1 ; i < iDims ; ++i)
1404 if (iLeadDims > piDims[i])
1406 iLeadDims = piDims[i];
1410 for (int i = 0 ; i < iLeadDims ; ++i)
1412 for (int j = 0 ; j < iDims ; ++j)
1417 int index = _pR->getIndex(piIndex);
1419 add(_pL->get(0), _pL->getImg(0), _pR->get(index), _pR->getImg(index), pOut->get() + index, pOut->getImg() + index);
1425 template<class T, class U, class O>
1426 InternalType* add_I_S(T *_pL, U *_pR)
1429 add(_pL->get(0), _pR->get(0), pOut->get());
1433 template<class T, class U, class O>
1434 InternalType* add_IC_S(T *_pL, U *_pR)
1436 O* pOut = new O(0.0, 0.0);
1437 add( _pR->get(), 1, _pL->get(0), _pL->getImg(0), pOut->get(), pOut->getImg());
1441 template<class T, class U, class O>
1442 InternalType* add_I_SC(T *_pL, U *_pR)
1444 O* pOut = new O(0.0, 0.0);
1445 add(_pL->get(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1449 template<class T, class U, class O>
1450 InternalType* add_IC_SC(T *_pL, U *_pR)
1452 O* pOut = new O(0.0, 0.0);
1453 add(_pL->get(), _pL->getImg(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1457 template<class T, class U, class O> InternalType* add_M_I(T *_pL, U *_pR)
1459 return add_I_M<U, T, O>(_pR, _pL);
1462 template<class T, class U, class O> InternalType* add_MC_I(T *_pL, U *_pR)
1464 return add_I_MC<U, T, O>(_pR, _pL);
1467 template<class T, class U, class O> InternalType* add_M_IC(T *_pL, U *_pR)
1469 return add_IC_M<U, T, O>(_pR, _pL);
1472 template<class T, class U, class O> InternalType* add_MC_IC(T *_pL, U *_pR)
1474 return add_IC_MC<U, T, O>(_pR, _pL);
1477 template<class T, class U, class O> InternalType* add_S_I(T *_pL, U *_pR)
1479 return add_I_S<U, T, O>(_pR, _pL);
1482 template<class T, class U, class O> InternalType* add_SC_I(T *_pL, U *_pR)
1484 return add_I_SC<U, T, O>(_pR, _pL);
1487 template<class T, class U, class O> InternalType* add_S_IC(T *_pL, U *_pR)
1489 return add_IC_S<U, T, O>(_pR, _pL);
1492 template<class T, class U, class O> InternalType* add_SC_IC(T *_pL, U *_pR)
1494 return add_IC_SC<U, T, O>(_pR, _pL);
1497 template<class T, class U, class O> InternalType* add_I_I(T *_pL, U *_pR)
1499 O* pOut = (O*)_pL->clone();
1500 add(_pL->get(0), _pR->get(0), pOut->get());
1504 template<class T, class U, class O> InternalType* add_I_IC(T *_pL, U *_pR)
1506 O* pOut = (O*)_pR->clone();
1507 add(_pL->get(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1511 template<class T, class U, class O> InternalType* add_IC_I(T *_pL, U *_pR)
1513 return add_I_IC<U, T, O>(_pR, _pL);
1516 template<class T, class U, class O> InternalType* add_IC_IC(T *_pL, U *_pR)
1518 O* pOut = (O*)_pL->clone();
1519 add(_pL->get(0), _pL->getImg(0), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1523 template<class T, class U, class O> types::InternalType* add_I_E(T *_pL, U * /*_pR*/)
1525 O* pOut = (O*)_pL->clone();
1529 template<class T, class U, class O> types::InternalType* add_IC_E(T *_pL, U * /*_pR*/)
1531 O* pOut = (O*)_pL->clone();
1535 template<class T, class U, class O> types::InternalType* add_E_I(T * /*_pL*/, U *_pR)
1537 O* pOut = (O*)_pR->clone();
1541 template<class T, class U, class O> types::InternalType* add_E_IC(T * /*_pL*/, U *_pR)
1543 O* pOut = (O*)_pR->clone();
1547 //specifiaction for String Matrix + String Matrix
1549 InternalType* add_M_M<String, String, String>(String* _pL, String* _pR)
1551 int iDimsL = _pL->getDims();
1552 int iDimsR = _pR->getDims();
1554 if (iDimsL != iDimsR)
1556 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1559 int* piDimsL = _pL->getDimsArray();
1560 int* piDimsR = _pR->getDimsArray();
1562 for (int i = 0 ; i < iDimsL ; ++i)
1564 if (piDimsL[i] != piDimsR[i])
1566 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1570 String* pOut = new String(iDimsL, piDimsL);
1571 int size = _pL->getSize();
1572 int* sizeOut = new int[size];
1573 for (int i = 0 ; i < size ; ++i)
1575 wchar_t* pwstL = _pL->get(i);
1576 wchar_t* pwstR = _pR->get(i);
1577 int sizeL = (int)wcslen(pwstL);
1578 int sizeR = (int)wcslen(pwstR);
1580 sizeOut[i] = sizeL + sizeR + 1;
1581 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut[i] * sizeof(wchar_t));
1582 //assign ptr without strdup
1583 pOut->get()[i] = pwstOut;
1586 add(_pL->get(), size, _pR->get(), sizeOut, pOut->get());
1591 //specifiaction for String Matrix + String Scalar
1593 InternalType* add_S_M<String, String, String>(String* _pL, String* _pR)
1595 String* pOut = new String(_pR->getDims(), _pR->getDimsArray());
1596 int size = _pR->getSize();
1597 int* sizeOut = new int[size];
1598 wchar_t* pwstL = _pL->get(0);
1599 int sizeL = (int)wcslen(pwstL);
1601 for (int i = 0 ; i < size ; ++i)
1603 wchar_t* pwstR = _pR->get(i);
1604 int sizeR = (int)wcslen(pwstR);
1606 sizeOut[i] = sizeL + sizeR + 1;
1607 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut[i] * sizeof(wchar_t));
1608 //assign ptr without strdup
1609 pOut->get()[i] = pwstOut;
1612 add(pwstL, size, _pR->get(), sizeOut, pOut->get());
1617 //specifiaction for String Scalar + String MAtrix
1619 InternalType* add_M_S<String, String, String>(String* _pL, String* _pR)
1621 String* pOut = new String(_pL->getDims(), _pL->getDimsArray());
1622 int size = _pL->getSize();
1623 int* sizeOut = new int[size];
1624 wchar_t* pwstR = _pR->get(0);
1625 int sizeR = (int)wcslen(pwstR);
1627 for (int i = 0 ; i < size ; ++i)
1629 wchar_t* pwstL = _pL->get(i);
1630 int sizeL = (int)wcslen(pwstL);
1632 sizeOut[i] = sizeL + sizeR + 1;
1633 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut[i] * sizeof(wchar_t));
1634 //assign ptr without strdup
1635 pOut->get()[i] = pwstOut;
1638 add(_pL->get(), size, pwstR, sizeOut, pOut->get());
1643 //specifiaction for String Scalar + String Scalar
1645 InternalType* add_S_S<String, String, String>(String* _pL, String* _pR)
1647 String* pOut = new String(1, 1);
1648 wchar_t* pwstL = _pL->get(0);
1649 wchar_t* pwstR = _pR->get(0);
1650 int sizeL = (int)wcslen(pwstL);
1651 int sizeR = (int)wcslen(pwstR);
1653 int sizeOut = sizeL + sizeR + 1;
1654 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut * sizeof(wchar_t));
1655 //assign ptr without strdup
1656 pOut->get()[0] = pwstOut;
1657 add(pwstL, pwstR, sizeOut, *pOut->get());
1662 InternalType* add_M_E<String, Double, String>(String* _pL, Double* /*_pR*/)
1668 InternalType* add_S_E<String, Double, String>(String* _pL, Double* /*_pR*/)
1674 InternalType* add_E_M<Double, String, String>(Double* /*_pL*/, String* _pR)
1680 InternalType* add_E_S<Double, String, String>(Double* /*_pL*/, String* _pR)
1685 template<> InternalType* add_M_M<Polynom, Polynom, Polynom>(Polynom* _pL, Polynom* _pR)
1687 Polynom* pOut = NULL;
1688 if (_pL->getVariableName() != _pR->getVariableName())
1690 std::wostringstream os;
1691 os << _W("variables don't have the same formal variable");
1692 //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
1693 throw ast::ScilabError(os.str());
1696 if (_pL->isScalar())
1698 int *pRank = new int[_pR->getSize()];
1699 int *pRank1 = new int[_pR->getSize()];
1700 int *pRank2 = new int[_pR->getSize()];
1701 bool bComplex1 = _pL->isComplex();
1702 bool bComplex2 = _pR->isComplex();
1704 memset(pRank1, 0x00, _pR->getSize() * sizeof(int));
1706 _pL->getRank(pRank1);
1707 _pR->getRank(pRank2);
1708 for (int i = 0 ; i < _pR->getSize() ; i++)
1710 pRank[i] = std::max(pRank1[0], pRank2[i]);
1713 pOut = new Polynom(_pR->getVariableName(), _pR->getDims(), _pR->getDimsArray(), pRank);
1714 if (bComplex1 || bComplex2)
1716 pOut->setComplex(true);
1719 //Result P1(0) + P2(i)
1720 SinglePoly *pCoef1 = _pL->get(0);
1721 double *p1R = pCoef1->get();
1722 double *p1I = pCoef1->getImg();
1723 for (int i = 0 ; i < _pR->getSize() ; i++)
1725 SinglePoly *pCoef2 = _pR->get(i);
1726 double *p2R = pCoef2->get();
1727 double *p2I = pCoef2->getImg();
1729 SinglePoly *pCoefR = pOut->get(i);
1730 double *pRR = pCoefR->get();
1731 double *pRI = pCoefR->getImg();
1733 for (int j = 0 ; j < std::min(pRank1[0], pRank2[i]) + 1; j++)
1735 pRR[j] = p1R[j] + p2R[j];
1738 double *pTemp = (pRank1[0] > pRank2[i] ? p1R : p2R);
1739 for (int j = std::min(pRank1[0], pRank2[i]) + 1; j < std::max(pRank1[0], pRank2[i]) + 1; j++)
1744 if (pOut->isComplex())
1746 for (int j = 0 ; j < std::min(pRank1[0], pRank2[i]) + 1; j++)
1748 pRI[j] = (p1I == NULL ? 0 : p1I[j]) + (p2I == NULL ? 0 : p2I[j]);
1751 double *pTemp = (pRank1[0] > pRank2[i] ? p1I : p2I);
1752 for (int j = std::min(pRank1[0], pRank2[i]) + 1; j < std::max(pRank1[0], pRank2[i]) + 1; j++)
1754 pRI[j] = pTemp == NULL ? 0 : pTemp[j];
1765 if (_pR->isScalar())
1767 int *pRank = new int[_pL->getSize()];
1768 int *pRank1 = new int[_pL->getSize()];
1769 int *pRank2 = new int[_pL->getSize()];
1770 bool bComplex1 = _pL->isComplex();
1771 bool bComplex2 = _pR->isComplex();
1773 memset(pRank2, 0x00, _pL->getSize() * sizeof(int));
1775 _pL->getRank(pRank1);
1776 _pR->getRank(pRank2);
1777 for (int i = 0 ; i < _pL->getSize() ; i++)
1779 pRank[i] = std::max(pRank1[i], pRank2[0]);
1782 pOut = new Polynom(_pL->getVariableName(), _pL->getDims(), _pL->getDimsArray(), pRank);
1783 if (bComplex1 || bComplex2)
1785 pOut->setComplex(true);
1788 //Result P1(i) + P2(0)
1789 SinglePoly *pCoef2 = _pR->get(0);
1790 double *p2R = pCoef2->get();
1791 double *p2I = pCoef2->getImg();
1793 for (int i = 0 ; i < _pL->getSize() ; i++)
1795 SinglePoly *pCoef1 = _pL->get(i);
1796 double *p1R = pCoef1->get();
1797 double *p1I = pCoef1->getImg();
1799 SinglePoly *pCoefR = pOut->get(i);
1800 double *pRR = pCoefR->get();
1801 double *pRI = pCoefR->getImg();
1803 for (int j = 0 ; j < std::min(pRank1[i], pRank2[0]) + 1 ; j++)
1805 pRR[j] = p1R[j] + p2R[j];
1808 double *pTemp = (pRank1[i] > pRank2[0] ? p1R : p2R);
1809 for (int j = std::min(pRank1[i], pRank2[0]) + 1; j < std::max(pRank1[i], pRank2[0]) + 1; j++)
1814 if (pOut->isComplex())
1816 for (int j = 0 ; j < std::min(pRank1[i], pRank2[0]) + 1; j++)
1818 pRI[j] = (p1I == NULL ? 0 : p1I[j]) + (p2I == NULL ? 0 : p2I[j]);
1821 double *pTemp = (pRank1[i] > pRank2[0] ? p1I : p2I);
1822 for (int j = std::min(pRank1[i], pRank2[0]) + 1; j < std::max(pRank1[i], pRank2[0]) + 1; j++)
1824 pRI[j] = pTemp == NULL ? 0 : pTemp[j];
1835 int iDims1 = _pL->getDims();
1836 int iDims2 = _pR->getDims();
1838 if (iDims1 != iDims2)
1841 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());
1842 throw ast::ScilabError(pMsg);
1845 int* piDims1 = _pL->getDimsArray();
1846 int* piDims2 = _pR->getDimsArray();
1848 for (int i = 0 ; i < iDims1 ; i++)
1850 if (piDims1[i] != piDims2[i])
1853 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());
1854 throw ast::ScilabError(pMsg);
1858 int *pRank = new int[_pL->getSize()];
1859 int *pRank1 = new int[_pL->getSize()];
1860 int *pRank2 = new int[_pR->getSize()];
1861 bool bComplex1 = _pL->isComplex();
1862 bool bComplex2 = _pR->isComplex();
1864 _pL->getRank(pRank1);
1865 _pR->getRank(pRank2);
1866 for (int i = 0 ; i < _pL->getSize() ; i++)
1868 pRank[i] = std::max(pRank1[i], pRank2[i]);
1871 pOut = new Polynom(_pR->getVariableName(), _pL->getDims(), _pL->getDimsArray(), pRank);
1872 if (_pL->isComplex() || _pR->isComplex())
1874 pOut->setComplex(true);
1877 if (bComplex1 == false && bComplex2 == false)
1879 for (int i = 0 ; i < _pL->getSize() ; i++)
1881 iAddScilabPolynomToScilabPolynom(
1882 _pL->get(i)->get(), pRank1[i] + 1,
1883 _pR->get(i)->get(), pRank2[i] + 1,
1884 pOut->get(i)->get(), pRank[i] + 1);
1887 else if (bComplex1 == false && bComplex2 == true)
1889 for (int i = 0 ; i < _pL->getSize() ; i++)
1891 iAddScilabPolynomToComplexPoly(
1892 _pL->get(i)->get(), pRank1[i] + 1,
1893 _pR->get(i)->get(), _pR->get(i)->getImg(), pRank2[i] + 1,
1894 pOut->get(i)->get(), pOut->get(i)->getImg(), pRank[i] + 1);
1897 else if (bComplex1 == true && bComplex2 == false)
1899 for (int i = 0 ; i < _pL->getSize() ; i++)
1901 iAddScilabPolynomToComplexPoly(
1902 _pR->get(i)->get(), pRank2[i] + 1,
1903 _pL->get(i)->get(), _pL->get(i)->getImg(), pRank1[i] + 1,
1904 pOut->get(i)->get(), pOut->get(i)->getImg(), pRank[i] + 1);
1907 else if (bComplex1 == true && bComplex2 == true)
1909 for (int i = 0 ; i < _pL->getSize() ; i++)
1911 iAddComplexPolyToComplexPoly(
1912 _pL->get(i)->get(), _pL->get(i)->getImg(), pRank1[i] + 1,
1913 _pR->get(i)->get(), _pR->get(i)->getImg(), pRank2[i] + 1,
1914 pOut->get(i)->get(), pOut->get(i)->getImg(), pRank[i] + 1);
1930 template<> InternalType* add_M_M<Polynom, Double, Polynom>(Polynom* _pL, Double* _pR)
1932 return add_M_M<Double, Polynom, Polynom>(_pR, _pL);
1935 template<> InternalType* add_M_M<Double, Polynom, Polynom>(Double* _pL, Polynom* _pR)
1937 Polynom* pOut = NULL;
1938 bool bComplex1 = _pR->isComplex();
1939 bool bComplex2 = _pL->isComplex();
1941 double *pInDblR = _pL->getReal();
1942 double *pInDblI = _pL->getImg();
1949 if (_pR->isScalar())
1951 int *piRank = new int[_pL->getSize()];
1952 for (int i = 0 ; i < _pL->getSize() ; i++)
1954 piRank[i] = _pR->get(0)->getRank();
1957 pOut = new Polynom(_pR->getVariableName(), _pL->getDims(), _pL->getDimsArray(), piRank);
1958 if (bComplex1 || bComplex2)
1960 pOut->setComplex(true);
1963 for (int i = 0 ; i < pOut->getSize() ; i++)
1965 SinglePoly *pInPoly = _pR->get(0);
1966 SinglePoly *pOutPoly = pOut->get(i);
1967 double *pInPolyR = pInPoly->get();
1968 double *pOutPolyR = pOutPoly->get();
1970 pOutPolyR[0] = pInDblR[i] + pInPolyR[0];
1972 for (int j = 1 ; j < pInPoly->getSize() ; j++)
1974 pOutPolyR[j] = pInPolyR[j];
1978 if (pOut->isComplex())
1980 for (int i = 0 ; i < pOut->getSize() ; i++)
1982 SinglePoly *pInPoly = _pR->get(0);
1983 SinglePoly *pOutPoly = pOut->get(i);
1984 double *pInPolyI = pInPoly->getImg();
1985 double *pOutPolyI = pOutPoly->getImg();
1987 pOutPolyI[0] = (pInDblI != NULL ? pInDblI[i] : 0) + (pInPolyI != NULL ? pInPolyI[0] : 0);
1989 for (int j = 1 ; j < pInPoly->getSize() ; j++)
1991 pOutPolyI[j] = (pInPolyI != NULL ? pInPolyI[j] : 0);
1999 if (_pL->isScalar())
2001 pOut = (Polynom*)_pR->clone();
2003 if (bComplex1 && bComplex2)
2005 for (int i = 0 ; i < pOut->getSize() ; i++)
2007 SinglePoly *pSPOut = pOut->get(i);
2008 double *pOutPolyR = pSPOut->get();
2009 double *pOutPolyI = pSPOut->getImg();
2011 pOutPolyR[0] += pInDblR[0];
2012 pOutPolyI[0] += pInDblI[0];
2017 pOut->setComplex(true);
2018 for (int i = 0 ; i < pOut->getSize() ; i++)
2020 SinglePoly *pSPOut = pOut->get(i);
2021 double *pOutPolyR = pSPOut->get();
2022 double *pOutPolyI = pSPOut->getImg();
2024 pOutPolyR[0] += pInDblR[0];
2025 pOutPolyI[0] = pInDblI[0];
2030 for (int i = 0 ; i < pOut->getSize() ; i++)
2032 SinglePoly *pSPOut = pOut->get(i);
2033 double *pOutPolyR = pSPOut->get();
2035 pOutPolyR[0] += pInDblR[0];
2042 int iDims1 = _pR->getDims();
2043 int iDims2 = _pL->getDims();
2045 if (iDims1 != iDims2)
2048 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());
2049 throw ast::ScilabError(pMsg);
2052 int* piDims1 = _pR->getDimsArray();
2053 int* piDims2 = _pL->getDimsArray();
2055 for (int i = 0 ; i < iDims1 ; i++)
2057 if (piDims1[i] != piDims2[i])
2060 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());
2061 throw ast::ScilabError(pMsg);
2065 pOut = (Polynom*)_pR->clone();
2066 if (bComplex1 && bComplex2)
2068 for (int i = 0 ; i < pOut->getSize() ; i++)
2070 SinglePoly *pSPOut = pOut->get(i);
2071 double *pOutPolyR = pSPOut->get();
2072 double *pOutPolyI = pSPOut->getImg();
2074 pOutPolyR[0] += pInDblR[i];
2075 pOutPolyI[0] += pInDblI[i];
2080 pOut->setComplex(true);
2081 for (int i = 0 ; i < pOut->getSize() ; i++)
2083 SinglePoly *pSPOut = pOut->get(i);
2084 double *pOutPolyR = pSPOut->get();
2085 double *pOutPolyI = pSPOut->getImg();
2087 pOutPolyR[0] += pInDblR[i];
2088 pOutPolyI[0] = pInDblI[i];
2093 for (int i = 0 ; i < pOut->getSize() ; i++)
2095 SinglePoly *pSPOut = pOut->get(i);
2096 double *pOutPolyR = pSPOut->get();
2098 pOutPolyR[0] += pInDblR[i];
2106 template<> InternalType* add_M_I<Polynom, Double, Polynom>(Polynom* _pL, Double* _pR)
2108 Polynom* pOut = (Polynom*)_pL->clone();
2109 bool isComplex = _pL->isComplex() || _pR->isComplex();
2110 pOut->setComplex(isComplex);
2112 int iDims = _pL->getDims();
2113 int* piDims = _pL->getDimsArray();
2114 int iLeadDims = piDims[0];
2115 int* piIndex = new int[iDims];
2119 for (int i = 1 ; i < iDims ; ++i)
2124 if (iLeadDims > piDims[i])
2126 iLeadDims = piDims[i];
2130 double dblR = _pR->get(0);
2134 SinglePoly** pSP = pOut->get();
2137 if (_pR->isComplex())
2139 dblI = _pR->getImg(0);
2142 for (int i = 0 ; i < iLeadDims ; ++i)
2144 for (int j = 0 ; j < iDims ; ++j)
2149 int index = _pL->getIndex(piIndex);
2150 add(dblR, dblI, pSP[index]->get(0), pSP[index]->getImg(0), pSP[index]->get(), pSP[index]->getImg());
2155 SinglePoly** pSP = pOut->get();
2156 for (int i = 0 ; i < iLeadDims ; ++i)
2158 for (int j = 0 ; j < iDims ; ++j)
2163 int index = _pL->getIndex(piIndex);
2164 add(dblR, pSP[index]->get(0), pSP[index]->get());
2170 template<> InternalType* add_I_M<Double, Polynom, Polynom>(Double* _pL, Polynom* _pR)
2172 return add_M_I<Polynom, Double, Polynom>(_pR, _pL);
2176 template<> InternalType* add_M_M<Sparse, Sparse, Sparse>(Sparse* _pL, Sparse* _pR)
2178 Sparse* pOut = NULL;
2179 //check scalar hidden in a sparse ;)
2180 if (_pL->getRows() == 1 && _pL->getCols() == 1)
2183 Double* pDbl = NULL;
2184 if (_pL->isComplex())
2186 std::complex<double> dbl = _pL->getImg(0, 0);
2187 pDbl = new Double(dbl.real(), dbl.imag());
2191 pDbl = new Double(_pL->get(0, 0));
2194 AddSparseToDouble(_pR, pDbl, (GenericType**)pOut);
2199 if (_pR->getRows() == 1 && _pR->getCols() == 1)
2202 Double* pDbl = NULL;
2203 if (_pR->isComplex())
2205 std::complex<double> dbl = _pR->getImg(0, 0);
2206 pDbl = new Double(dbl.real(), dbl.imag());
2210 pDbl = new Double(_pR->get(0, 0));
2213 AddSparseToDouble(_pL, pDbl, (GenericType**)pOut);
2218 if (_pL->getRows() != _pR->getRows() || _pL->getCols() != _pR->getCols())
2220 //dimensions not match
2221 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
2224 if (_pL->nonZeros() == 0)
2230 if (_pR->nonZeros() == 0)
2236 return _pL->add(*_pR);
2240 template<> InternalType* add_M_M<Double, Sparse, Double>(Double* _pL, Sparse* _pR)
2242 return add_M_M<Sparse, Double, Double>(_pR, _pL);
2246 template<> InternalType* add_M_M<Sparse, Double, Double>(Sparse* _pL, Double* _pR)
2248 Double* pOut = NULL;
2249 int iOne = 1; //fortran
2250 bool bComplex1 = _pL->isComplex();
2251 bool bComplex2 = _pR->isComplex();
2253 if (_pL->isScalar() && _pR->isScalar())
2256 pOut = (Double*)_pR->clone();
2257 pOut->setComplex(bComplex1 | bComplex2);
2260 std::complex<double> dbl = _pL->getImg(0, 0);
2261 pOut->set(0, pOut->get(0) + dbl.real());
2262 pOut->setImg(0, pOut->getImg(0) + dbl.imag());
2266 pOut->set(0, pOut->get(0) + _pL->get(0, 0));
2272 if (_pR->isScalar())
2275 pOut = new Double(_pL->getRows(), _pL->getCols(), bComplex1 | bComplex2);
2276 int iSize = _pL->getSize();
2277 double dblVal = _pR->get(0);
2278 C2F(dset)(&iSize, &dblVal, pOut->get(), &iOne);
2281 double dblValI = _pR->getImg(0);
2282 C2F(dset)(&iSize, &dblValI, pOut->getImg(), &iOne);
2286 //initialize imag part at 0
2288 C2F(dset)(&iSize, &dblValI, pOut->getImg(), &iOne);
2291 int nonZeros = static_cast<int>(_pL->nonZeros());
2292 int* pRows = new int[nonZeros * 2];
2293 _pL->outputRowCol(pRows);
2294 int* pCols = pRows + nonZeros;
2298 for (int i = 0 ; i < nonZeros ; i++)
2300 int iRow = static_cast<int>(pRows[i]) - 1;
2301 int iCol = static_cast<int>(pCols[i]) - 1;
2302 std::complex<double> dbl = _pL->getImg(iRow, iCol);
2303 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + dbl.real());
2304 pOut->setImg(iRow, iCol, pOut->getImg(iRow, iCol) + dbl.imag());
2309 for (int i = 0 ; i < nonZeros ; i++)
2311 int iRow = static_cast<int>(pRows[i]) - 1;
2312 int iCol = static_cast<int>(pCols[i]) - 1;
2313 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + _pL->get(iRow, iCol));
2323 if (_pL->isScalar())
2326 pOut = (Double*)_pR->clone();
2327 pOut->setComplex(bComplex1 | bComplex2);
2331 double* pReal = pOut->get();
2332 double* pImg = pOut->getImg();
2333 int size = pOut->getSize();
2334 for (int i = 0 ; i < size ; i++)
2336 std::complex<double> dbl = _pL->getImg(0, 0);
2337 pReal[i] += dbl.real();
2338 pImg[i] += dbl.imag();
2343 double* pReal = pOut->get();
2344 int size = pOut->getSize();
2345 for (int i = 0 ; i < size ; i++)
2347 pReal[i] += _pL->get(0, 0);
2355 if (_pL->getRows() == _pR->getRows() && _pL->getCols() == _pR->getCols())
2358 pOut = (Double*)_pR->clone();
2359 pOut->setComplex(bComplex1 | bComplex2);
2361 int nonZeros = static_cast<int>(_pL->nonZeros());
2362 int* pRows = new int[nonZeros * 2];
2363 _pL->outputRowCol(pRows);
2364 int* pCols = pRows + nonZeros;
2368 for (int i = 0 ; i < nonZeros ; i++)
2370 int iRow = static_cast<int>(pRows[i]) - 1;
2371 int iCol = static_cast<int>(pCols[i]) - 1;
2372 std::complex<double> dbl = _pL->getImg(iRow, iCol);
2373 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + dbl.real());
2374 pOut->setImg(iRow, iCol, pOut->getImg(iRow, iCol) + dbl.imag());
2379 for (int i = 0 ; i < nonZeros ; i++)
2381 int iRow = static_cast<int>(pRows[i]) - 1;
2382 int iCol = static_cast<int>(pCols[i]) - 1;
2383 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + _pL->get(iRow, iCol));
2393 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
2398 template<> InternalType* add_M_M<Double, Sparse, Sparse>(Double* _pL, Sparse* _pR)
2400 return add_M_M<Sparse, Double, Sparse>(_pR, _pL);
2404 template<> InternalType* add_M_M<Sparse, Double, Sparse>(Sparse* _pL, Double* _pR)
2406 Sparse* pOut = NULL;
2407 if (_pR->isIdentity())
2410 pOut = (Sparse*)_pL->clone();
2411 bool isComplex = _pL->isComplex() || _pR->isComplex();
2417 int size = std::min(_pL->getRows(), _pL->getCols());
2418 double dblR = _pR->get(0);
2422 std::complex<double> cplx_add(dblR, 0);
2423 if (_pR->isComplex())
2425 cplx_add.imag(_pR->getImg(0));
2428 for (int i = 0 ; i < size ; i++)
2430 pOut->set(i, i, pOut->get(i, i) + cplx_add, false);
2435 for (int i = 0 ; i < size ; i++)
2437 pOut->set(i, i, _pL->get(i, i) + dblR, false);