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 add_function getAddFunction(types::InternalType::ScilabId leftId, types::InternalType::ScilabId rightId)
40 return pAddfunction[leftId][rightId];
44 void fillAddFunction()
46 #define scilab_fill_add(id1, id2, func, typeIn1, typeIn2, typeOut) \
47 pAddfunction[types::InternalType::Id ## id1][types::InternalType::Id ## id2] = (add_function)&add_##func<typeIn1, typeIn2, typeOut>
51 scilab_fill_add(Double, Double, M_M, Double, Double, Double);
52 scilab_fill_add(Double, Int8, M_M, Double, Int8, Int8);
53 scilab_fill_add(Double, UInt8, M_M, Double, UInt8, UInt8);
54 scilab_fill_add(Double, Int16, M_M, Double, Int16, Int16);
55 scilab_fill_add(Double, UInt16, M_M, Double, UInt16, UInt16);
56 scilab_fill_add(Double, Int32, M_M, Double, Int32, Int32);
57 scilab_fill_add(Double, UInt32, M_M, Double, UInt32, UInt32);
58 scilab_fill_add(Double, Int64, M_M, Double, Int64, Int64);
59 scilab_fill_add(Double, UInt64, M_M, Double, UInt64, UInt64);
60 scilab_fill_add(Double, Bool, M_M, Double, Bool, Double);
61 scilab_fill_add(Double, Polynom, M_M, Double, Polynom, Polynom);
62 scilab_fill_add(Double, Sparse, M_M, Double, Sparse, Double);
64 //Matrix + Matrix Complex
65 scilab_fill_add(Double, DoubleComplex, M_MC, Double, Double, Double);
66 scilab_fill_add(Double, PolynomComplex, M_M, Double, Polynom, Polynom);
67 scilab_fill_add(Double, SparseComplex, M_M, Double, Sparse, Double);
70 scilab_fill_add(Double, ScalarDouble, M_S, Double, Double, Double);
71 scilab_fill_add(Double, ScalarInt8, M_S, Double, Int8, Int8);
72 scilab_fill_add(Double, ScalarUInt8, M_S, Double, UInt8, UInt8);
73 scilab_fill_add(Double, ScalarInt16, M_S, Double, Int16, Int16);
74 scilab_fill_add(Double, ScalarUInt16, M_S, Double, UInt16, UInt16);
75 scilab_fill_add(Double, ScalarInt32, M_S, Double, Int32, Int32);
76 scilab_fill_add(Double, ScalarUInt32, M_S, Double, UInt32, UInt32);
77 scilab_fill_add(Double, ScalarInt64, M_S, Double, Int64, Int64);
78 scilab_fill_add(Double, ScalarUInt64, M_S, Double, UInt64, UInt64);
79 scilab_fill_add(Double, ScalarBool, M_S, Double, Bool, Double);
80 scilab_fill_add(Double, ScalarPolynom, M_M, Double, Polynom, Polynom);
82 //Matrix + Scalar Complex
83 scilab_fill_add(Double, ScalarDoubleComplex, M_SC, Double, Double, Double);
84 scilab_fill_add(Double, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
86 scilab_fill_add(Double, Empty, M_E, Double, Double, Double);
89 //Matrix Complex + Matrix
90 scilab_fill_add(DoubleComplex, Double, MC_M, Double, Double, Double);
91 scilab_fill_add(DoubleComplex, DoubleComplex, MC_MC, Double, Double, Double);
92 scilab_fill_add(DoubleComplex, ScalarDouble, MC_S, Double, Double, Double);
93 scilab_fill_add(DoubleComplex, ScalarDoubleComplex, MC_SC, Double, Double, Double);
94 scilab_fill_add(DoubleComplex, Empty, MC_E, Double, Double, Double);
95 scilab_fill_add(DoubleComplex, Polynom, M_M, Double, Polynom, Polynom);
96 scilab_fill_add(DoubleComplex, PolynomComplex, M_M, Double, Polynom, Polynom);
97 scilab_fill_add(DoubleComplex, ScalarPolynom, M_M, Double, Polynom, Polynom);
98 scilab_fill_add(DoubleComplex, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
99 scilab_fill_add(DoubleComplex, Sparse, M_M, Double, Sparse, Double);
100 scilab_fill_add(DoubleComplex, SparseComplex, M_M, Double, Sparse, Double);
103 scilab_fill_add(ScalarDouble, Double, S_M, Double, Double, Double);
104 scilab_fill_add(ScalarDouble, Int8, S_M, Double, Int8, Int8);
105 scilab_fill_add(ScalarDouble, UInt8, S_M, Double, UInt8, UInt8);
106 scilab_fill_add(ScalarDouble, Int16, S_M, Double, Int16, Int16);
107 scilab_fill_add(ScalarDouble, UInt16, S_M, Double, UInt16, UInt16);
108 scilab_fill_add(ScalarDouble, Int32, S_M, Double, Int32, Int32);
109 scilab_fill_add(ScalarDouble, UInt32, S_M, Double, UInt32, UInt32);
110 scilab_fill_add(ScalarDouble, Int64, S_M, Double, Int64, Int64);
111 scilab_fill_add(ScalarDouble, UInt64, S_M, Double, UInt64, UInt64);
112 scilab_fill_add(ScalarDouble, Bool, S_M, Double, Bool, Double);
113 scilab_fill_add(ScalarDouble, Polynom, M_M, Double, Polynom, Polynom);
114 scilab_fill_add(ScalarDouble, Sparse, M_M, Double, Sparse, Double);
116 //Scalar + Matrix Complex
117 scilab_fill_add(ScalarDouble, DoubleComplex, S_MC, Double, Double, Double);
118 scilab_fill_add(ScalarDouble, PolynomComplex, M_M, Double, Polynom, Polynom);
119 scilab_fill_add(ScalarDouble, SparseComplex, M_M, Double, Sparse, Double);
122 scilab_fill_add(ScalarDouble, ScalarDouble, S_S, Double, Double, Double);
123 scilab_fill_add(ScalarDouble, ScalarInt8, S_S, Double, Int8, Int8);
124 scilab_fill_add(ScalarDouble, ScalarUInt8, S_S, Double, UInt8, UInt8);
125 scilab_fill_add(ScalarDouble, ScalarInt16, S_S, Double, Int16, Int16);
126 scilab_fill_add(ScalarDouble, ScalarUInt16, S_S, Double, UInt16, UInt16);
127 scilab_fill_add(ScalarDouble, ScalarInt32, S_S, Double, Int32, Int32);
128 scilab_fill_add(ScalarDouble, ScalarUInt32, S_S, Double, UInt32, UInt32);
129 scilab_fill_add(ScalarDouble, ScalarInt64, S_S, Double, Int64, Int64);
130 scilab_fill_add(ScalarDouble, ScalarUInt64, S_S, Double, UInt64, UInt64);
131 scilab_fill_add(ScalarDouble, ScalarBool, S_S, Double, Bool, Double);
132 scilab_fill_add(ScalarDouble, ScalarPolynom, M_M, Double, Polynom, Polynom);
134 //Scalar + Scalar Complex
135 scilab_fill_add(ScalarDouble, ScalarDoubleComplex, S_SC, Double, Double, Double);
136 scilab_fill_add(ScalarDouble, PolynomComplex, M_M, Double, Polynom, Polynom);
137 scilab_fill_add(ScalarDouble, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
140 scilab_fill_add(ScalarDouble, Empty, S_E, Double, Double, Double);
142 //Scalar Complex + Matrix
143 scilab_fill_add(ScalarDoubleComplex, Double, SC_M, Double, Double, Double);
144 scilab_fill_add(ScalarDoubleComplex, Polynom, M_M, Double, Polynom, Polynom);
145 scilab_fill_add(ScalarDoubleComplex, Sparse, M_M, Double, Sparse, Double);
146 //Scalar Complex + Matrix Complex
147 scilab_fill_add(ScalarDoubleComplex, DoubleComplex, SC_MC, Double, Double, Double);
148 scilab_fill_add(ScalarDoubleComplex, PolynomComplex, M_M, Double, Polynom, Polynom);
149 scilab_fill_add(ScalarDoubleComplex, SparseComplex, M_M, Double, Sparse, Double);
150 //Scalar Complex + Scalar
151 scilab_fill_add(ScalarDoubleComplex, ScalarDouble, SC_S, Double, Double, Double);
152 scilab_fill_add(ScalarDoubleComplex, ScalarPolynom, M_M, Double, Polynom, Polynom);
153 //Scalar Complex + Scalar Complex
154 scilab_fill_add(ScalarDoubleComplex, ScalarDoubleComplex, SC_SC, Double, Double, Double);
155 scilab_fill_add(ScalarDoubleComplex, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
156 //Scalar Complex + Empty
157 scilab_fill_add(ScalarDoubleComplex, Empty, SC_E, Double, Double, Double);
160 scilab_fill_add(Empty, Double, E_M, Double, Double, Double);
161 scilab_fill_add(Empty, Int8, E_M, Double, Int8, Int8);
162 scilab_fill_add(Empty, UInt8, E_M, Double, UInt8, UInt8);
163 scilab_fill_add(Empty, Int16, E_M, Double, Int16, Int16);
164 scilab_fill_add(Empty, UInt16, E_M, Double, UInt16, UInt16);
165 //scilab_fill_add(Empty, Int32, E_M, Double, Int32, Int32);
166 scilab_fill_add(Empty, UInt32, E_M, Double, UInt32, UInt32);
167 scilab_fill_add(Empty, Int64, E_M, Double, Int64, Int64);
168 scilab_fill_add(Empty, UInt64, E_M, Double, UInt64, UInt64);
169 //scilab_fill_add(Empty, Bool, E_M, Double, Bool, Double);
170 scilab_fill_add(Empty, String, E_M, Double, String, String);
171 scilab_fill_add(Empty, Polynom, M_M, Double, Polynom, Polynom);
172 scilab_fill_add(Empty, PolynomComplex, M_M, Double, Polynom, Polynom);
173 scilab_fill_add(Empty, Sparse, M_M, Double, Sparse, Sparse);
174 scilab_fill_add(Empty, SparseComplex, M_M, Double, Sparse, Sparse);
176 //Empty + Matrix Complex
177 scilab_fill_add(Empty, DoubleComplex, E_MC, Double, Double, Double);
179 scilab_fill_add(Empty, ScalarDouble, E_S, Double, Double, Double);
180 scilab_fill_add(Empty, ScalarInt8, E_S, Double, Int8, Int8);
181 scilab_fill_add(Empty, ScalarUInt8, E_S, Double, UInt8, UInt8);
182 scilab_fill_add(Empty, ScalarInt16, E_S, Double, Int16, Int16);
183 scilab_fill_add(Empty, ScalarUInt16, E_S, Double, UInt16, UInt16);
184 scilab_fill_add(Empty, ScalarInt32, E_S, Double, Int32, Int32);
185 scilab_fill_add(Empty, ScalarUInt32, E_S, Double, UInt32, UInt32);
186 scilab_fill_add(Empty, ScalarInt64, E_S, Double, Int64, Int64);
187 scilab_fill_add(Empty, ScalarUInt64, E_S, Double, UInt64, UInt64);
188 scilab_fill_add(Empty, ScalarBool, E_S, Double, Bool, Double);
189 scilab_fill_add(Empty, ScalarString, E_S, Double, String, String);
190 scilab_fill_add(Empty, ScalarPolynom, M_M, Double, Polynom, Polynom);
192 //Empty + Scalar Complex
193 scilab_fill_add(Empty, ScalarDoubleComplex, E_SC, Double, Double, Double);
194 scilab_fill_add(Empty, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
196 scilab_fill_add(Empty, Empty, E_E, Double, Double, Double);
198 scilab_fill_add(Empty, Identity, E_I, Double, Double, Double);
199 scilab_fill_add(Empty, IdentityComplex, E_IC, Double, Double, Double);
202 scilab_fill_add(Double, Identity, M_I, Double, Double, Double);
203 scilab_fill_add(Double, IdentityComplex, M_IC, Double, Double, Double);
204 scilab_fill_add(DoubleComplex, Identity, MC_I, Double, Double, Double);
205 scilab_fill_add(DoubleComplex, IdentityComplex, MC_IC, Double, Double, Double);
206 scilab_fill_add(ScalarDouble, Identity, S_I, Double, Double, Double);
207 scilab_fill_add(ScalarDouble, IdentityComplex, S_IC, Double, Double, Double);
208 scilab_fill_add(ScalarDoubleComplex, Identity, SC_I, Double, Double, Double);
209 scilab_fill_add(ScalarDoubleComplex, IdentityComplex, SC_IC, Double, Double, Double);
214 scilab_fill_add(Int8, Double, M_M, Int8, Double, Int8);
215 scilab_fill_add(Int8, Int8, M_M, Int8, Int8, Int8);
216 scilab_fill_add(Int8, UInt8, M_M, Int8, UInt8, UInt8);
217 scilab_fill_add(Int8, Int16, M_M, Int8, Int16, Int16);
218 scilab_fill_add(Int8, UInt16, M_M, Int8, UInt16, UInt16);
219 scilab_fill_add(Int8, Int32, M_M, Int8, Int32, Int32);
220 scilab_fill_add(Int8, UInt32, M_M, Int8, UInt32, UInt32);
221 scilab_fill_add(Int8, Int64, M_M, Int8, Int64, Int64);
222 scilab_fill_add(Int8, UInt64, M_M, Int8, UInt64, UInt64);
223 scilab_fill_add(Int8, Bool, M_M, Int8, Bool, Int8);
224 scilab_fill_add(Int8, Empty, M_M, Int8, Double, Int8);
227 scilab_fill_add(Int8, ScalarDouble, M_S, Int8, Double, Int8);
228 scilab_fill_add(Int8, ScalarInt8, M_S, Int8, Int8, Int8);
229 scilab_fill_add(Int8, ScalarUInt8, M_S, Int8, UInt8, UInt8);
230 scilab_fill_add(Int8, ScalarInt16, M_S, Int8, Int16, Int16);
231 scilab_fill_add(Int8, ScalarUInt16, M_S, Int8, UInt16, UInt16);
232 scilab_fill_add(Int8, ScalarInt32, M_S, Int8, Int32, Int32);
233 scilab_fill_add(Int8, ScalarUInt32, M_S, Int8, UInt32, UInt32);
234 scilab_fill_add(Int8, ScalarInt64, M_S, Int8, Int64, Int64);
235 scilab_fill_add(Int8, ScalarUInt64, M_S, Int8, UInt64, UInt64);
236 scilab_fill_add(Int8, ScalarBool, M_S, Int8, Bool, Int8);
239 scilab_fill_add(ScalarInt8, Double, S_M, Int8, Double, Int8);
240 scilab_fill_add(ScalarInt8, Int8, S_M, Int8, Int8, Int8);
241 scilab_fill_add(ScalarInt8, UInt8, S_M, Int8, UInt8, UInt8);
242 scilab_fill_add(ScalarInt8, Int16, S_M, Int8, Int16, Int16);
243 scilab_fill_add(ScalarInt8, UInt16, S_M, Int8, UInt16, UInt16);
244 scilab_fill_add(ScalarInt8, Int32, S_M, Int8, Int32, Int32);
245 scilab_fill_add(ScalarInt8, UInt32, S_M, Int8, UInt32, UInt32);
246 scilab_fill_add(ScalarInt8, Int64, S_M, Int8, Int64, Int64);
247 scilab_fill_add(ScalarInt8, UInt64, S_M, Int8, UInt64, UInt64);
248 scilab_fill_add(ScalarInt8, Bool, S_M, Int8, Bool, Int8);
249 scilab_fill_add(ScalarInt8, Empty, M_M, Int8, Double, Int8);
252 scilab_fill_add(ScalarInt8, ScalarDouble, S_S, Int8, Double, Int8);
253 scilab_fill_add(ScalarInt8, ScalarInt8, S_S, Int8, Int8, Int8);
254 scilab_fill_add(ScalarInt8, ScalarUInt8, S_S, Int8, UInt8, UInt8);
255 scilab_fill_add(ScalarInt8, ScalarInt16, S_S, Int8, Int16, Int16);
256 scilab_fill_add(ScalarInt8, ScalarUInt16, S_S, Int8, UInt16, UInt16);
257 scilab_fill_add(ScalarInt8, ScalarInt32, S_S, Int8, Int32, Int32);
258 scilab_fill_add(ScalarInt8, ScalarUInt32, S_S, Int8, UInt32, UInt32);
259 scilab_fill_add(ScalarInt8, ScalarInt64, S_S, Int8, Int64, Int64);
260 scilab_fill_add(ScalarInt8, ScalarUInt64, S_S, Int8, UInt64, UInt64);
261 scilab_fill_add(ScalarInt8, ScalarBool, S_S, Int8, Bool, Int8);
265 scilab_fill_add(UInt8, Double, M_M, UInt8, Double, UInt8);
266 scilab_fill_add(UInt8, Int8, M_M, UInt8, Int8, UInt8);
267 scilab_fill_add(UInt8, UInt8, M_M, UInt8, UInt8, UInt8);
268 scilab_fill_add(UInt8, Int16, M_M, UInt8, Int16, UInt16);
269 scilab_fill_add(UInt8, UInt16, M_M, UInt8, UInt16, UInt16);
270 scilab_fill_add(UInt8, Int32, M_M, UInt8, Int32, UInt32);
271 scilab_fill_add(UInt8, UInt32, M_M, UInt8, UInt32, UInt32);
272 scilab_fill_add(UInt8, Int64, M_M, UInt8, Int64, UInt64);
273 scilab_fill_add(UInt8, UInt64, M_M, UInt8, UInt64, UInt64);
274 scilab_fill_add(UInt8, Bool, M_M, UInt8, Bool, UInt8);
275 scilab_fill_add(UInt8, Empty, M_M, UInt8, Double, UInt8);
278 scilab_fill_add(UInt8, ScalarDouble, M_S, UInt8, Double, UInt8);
279 scilab_fill_add(UInt8, ScalarInt8, M_S, UInt8, Int8, UInt8);
280 scilab_fill_add(UInt8, ScalarUInt8, M_S, UInt8, UInt8, UInt8);
281 scilab_fill_add(UInt8, ScalarInt16, M_S, UInt8, Int16, UInt16);
282 scilab_fill_add(UInt8, ScalarUInt16, M_S, UInt8, UInt16, UInt16);
283 scilab_fill_add(UInt8, ScalarInt32, M_S, UInt8, Int32, UInt32);
284 scilab_fill_add(UInt8, ScalarUInt32, M_S, UInt8, UInt32, UInt32);
285 scilab_fill_add(UInt8, ScalarInt64, M_S, UInt8, Int64, UInt64);
286 scilab_fill_add(UInt8, ScalarUInt64, M_S, UInt8, UInt64, UInt64);
287 scilab_fill_add(UInt8, ScalarBool, M_S, UInt8, Bool, UInt8);
290 scilab_fill_add(ScalarUInt8, Double, S_M, UInt8, Double, UInt8);
291 scilab_fill_add(ScalarUInt8, Int8, S_M, UInt8, Int8, UInt8);
292 scilab_fill_add(ScalarUInt8, UInt8, S_M, UInt8, UInt8, UInt8);
293 scilab_fill_add(ScalarUInt8, Int16, S_M, UInt8, Int16, UInt16);
294 scilab_fill_add(ScalarUInt8, UInt16, S_M, UInt8, UInt16, UInt16);
295 scilab_fill_add(ScalarUInt8, Int32, S_M, UInt8, Int32, UInt32);
296 scilab_fill_add(ScalarUInt8, UInt32, S_M, UInt8, UInt32, UInt32);
297 scilab_fill_add(ScalarUInt8, Int64, S_M, UInt8, Int64, UInt64);
298 scilab_fill_add(ScalarUInt8, UInt64, S_M, UInt8, UInt64, UInt64);
299 scilab_fill_add(ScalarUInt8, Bool, S_M, UInt8, Bool, UInt8);
300 scilab_fill_add(ScalarUInt8, Empty, S_M, UInt8, Double, UInt8);
303 scilab_fill_add(ScalarUInt8, ScalarDouble, S_S, UInt8, Double, UInt8);
304 scilab_fill_add(ScalarUInt8, ScalarInt8, S_S, UInt8, Int8, UInt8);
305 scilab_fill_add(ScalarUInt8, ScalarUInt8, S_S, UInt8, UInt8, UInt8);
306 scilab_fill_add(ScalarUInt8, ScalarInt16, S_S, UInt8, Int16, UInt16);
307 scilab_fill_add(ScalarUInt8, ScalarUInt16, S_S, UInt8, UInt16, UInt16);
308 scilab_fill_add(ScalarUInt8, ScalarInt32, S_S, UInt8, Int32, UInt32);
309 scilab_fill_add(ScalarUInt8, ScalarUInt32, S_S, UInt8, UInt32, UInt32);
310 scilab_fill_add(ScalarUInt8, ScalarInt64, S_S, UInt8, Int64, UInt64);
311 scilab_fill_add(ScalarUInt8, ScalarUInt64, S_S, UInt8, UInt64, UInt64);
312 scilab_fill_add(ScalarUInt8, ScalarBool, S_S, UInt8, Bool, UInt8);
316 scilab_fill_add(Int16, Double, M_M, Int16, Double, Int16);
317 scilab_fill_add(Int16, Int8, M_M, Int16, Int8, Int16);
318 scilab_fill_add(Int16, UInt8, M_M, Int16, UInt8, UInt16);
319 scilab_fill_add(Int16, Int16, M_M, Int16, Int16, Int16);
320 scilab_fill_add(Int16, UInt16, M_M, Int16, UInt16, UInt16);
321 scilab_fill_add(Int16, Int32, M_M, Int16, Int32, Int32);
322 scilab_fill_add(Int16, UInt32, M_M, Int16, UInt32, UInt32);
323 scilab_fill_add(Int16, Int64, M_M, Int16, Int64, Int64);
324 scilab_fill_add(Int16, UInt64, M_M, Int16, UInt64, UInt64);
325 scilab_fill_add(Int16, Bool, M_M, Int16, Bool, Int16);
326 scilab_fill_add(Int16, Empty, M_M, Int16, Double, Int16);
329 scilab_fill_add(Int16, ScalarDouble, M_S, Int16, Double, Int16);
330 scilab_fill_add(Int16, ScalarInt8, M_S, Int16, Int8, Int16);
331 scilab_fill_add(Int16, ScalarUInt8, M_S, Int16, UInt8, UInt16);
332 scilab_fill_add(Int16, ScalarInt16, M_S, Int16, Int16, Int16);
333 scilab_fill_add(Int16, ScalarUInt16, M_S, Int16, UInt16, UInt16);
334 scilab_fill_add(Int16, ScalarInt32, M_S, Int16, Int32, Int32);
335 scilab_fill_add(Int16, ScalarUInt32, M_S, Int16, UInt32, UInt32);
336 scilab_fill_add(Int16, ScalarInt64, M_S, Int16, Int64, Int64);
337 scilab_fill_add(Int16, ScalarUInt64, M_S, Int16, UInt64, UInt64);
338 scilab_fill_add(Int16, ScalarBool, M_S, Int16, Bool, Int16);
341 scilab_fill_add(ScalarInt16, Double, S_M, Int16, Double, Int16);
342 scilab_fill_add(ScalarInt16, Int8, S_M, Int16, Int8, Int16);
343 scilab_fill_add(ScalarInt16, UInt8, S_M, Int16, UInt8, UInt16);
344 scilab_fill_add(ScalarInt16, Int16, S_M, Int16, Int16, Int16);
345 scilab_fill_add(ScalarInt16, UInt16, S_M, Int16, UInt16, UInt16);
346 scilab_fill_add(ScalarInt16, Int32, S_M, Int16, Int32, Int32);
347 scilab_fill_add(ScalarInt16, UInt32, S_M, Int16, UInt32, UInt32);
348 scilab_fill_add(ScalarInt16, Int64, S_M, Int16, Int64, Int64);
349 scilab_fill_add(ScalarInt16, UInt64, S_M, Int16, UInt64, UInt64);
350 scilab_fill_add(ScalarInt16, Bool, S_M, Int16, Bool, Int16);
351 scilab_fill_add(ScalarInt16, Empty, M_M, Int16, Double, Int16);
354 scilab_fill_add(ScalarInt16, ScalarDouble, S_S, Int16, Double, Int16);
355 scilab_fill_add(ScalarInt16, ScalarInt8, S_S, Int16, Int8, Int16);
356 scilab_fill_add(ScalarInt16, ScalarUInt8, S_S, Int16, UInt8, UInt16);
357 scilab_fill_add(ScalarInt16, ScalarInt16, S_S, Int16, Int16, Int16);
358 scilab_fill_add(ScalarInt16, ScalarUInt16, S_S, Int16, UInt16, UInt16);
359 scilab_fill_add(ScalarInt16, ScalarInt32, S_S, Int16, Int32, Int32);
360 scilab_fill_add(ScalarInt16, ScalarUInt32, S_S, Int16, UInt32, UInt32);
361 scilab_fill_add(ScalarInt16, ScalarInt64, S_S, Int16, Int64, Int64);
362 scilab_fill_add(ScalarInt16, ScalarUInt64, S_S, Int16, UInt64, UInt64);
363 scilab_fill_add(ScalarInt16, ScalarBool, S_S, Int16, Bool, Int16);
367 scilab_fill_add(UInt16, Double, M_M, UInt16, Double, UInt16);
368 scilab_fill_add(UInt16, Int8, M_M, UInt16, Int8, UInt16);
369 scilab_fill_add(UInt16, UInt8, M_M, UInt16, UInt8, UInt16);
370 scilab_fill_add(UInt16, Int16, M_M, UInt16, Int16, UInt16);
371 scilab_fill_add(UInt16, UInt16, M_M, UInt16, UInt16, UInt16);
372 scilab_fill_add(UInt16, Int32, M_M, UInt16, Int32, UInt32);
373 scilab_fill_add(UInt16, UInt32, M_M, UInt16, UInt32, UInt32);
374 scilab_fill_add(UInt16, Int64, M_M, UInt16, Int64, UInt64);
375 scilab_fill_add(UInt16, UInt64, M_M, UInt16, UInt64, UInt64);
376 scilab_fill_add(UInt16, Bool, M_M, UInt16, Bool, UInt16);
377 scilab_fill_add(UInt16, Empty, M_M, UInt16, Double, UInt16);
380 scilab_fill_add(UInt16, ScalarDouble, M_S, UInt16, Double, UInt16);
381 scilab_fill_add(UInt16, ScalarInt8, M_S, UInt16, Int8, UInt16);
382 scilab_fill_add(UInt16, ScalarUInt8, M_S, UInt16, UInt8, UInt16);
383 scilab_fill_add(UInt16, ScalarInt16, M_S, UInt16, Int16, UInt16);
384 scilab_fill_add(UInt16, ScalarUInt16, M_S, UInt16, UInt16, UInt16);
385 scilab_fill_add(UInt16, ScalarInt32, M_S, UInt16, Int32, UInt32);
386 scilab_fill_add(UInt16, ScalarUInt32, M_S, UInt16, UInt32, UInt32);
387 scilab_fill_add(UInt16, ScalarInt64, M_S, UInt16, Int64, UInt64);
388 scilab_fill_add(UInt16, ScalarUInt64, M_S, UInt16, UInt64, UInt64);
389 scilab_fill_add(UInt16, ScalarBool, M_S, UInt16, Bool, UInt16);
392 scilab_fill_add(ScalarUInt16, Double, S_M, UInt16, Double, UInt16);
393 scilab_fill_add(ScalarUInt16, Int8, S_M, UInt16, Int8, UInt16);
394 scilab_fill_add(ScalarUInt16, UInt8, S_M, UInt16, UInt8, UInt16);
395 scilab_fill_add(ScalarUInt16, Int16, S_M, UInt16, Int16, UInt16);
396 scilab_fill_add(ScalarUInt16, UInt16, S_M, UInt16, UInt16, UInt16);
397 scilab_fill_add(ScalarUInt16, Int32, S_M, UInt16, Int32, UInt32);
398 scilab_fill_add(ScalarUInt16, UInt32, S_M, UInt16, UInt32, UInt32);
399 scilab_fill_add(ScalarUInt16, Int64, S_M, UInt16, Int64, UInt64);
400 scilab_fill_add(ScalarUInt16, UInt64, S_M, UInt16, UInt64, UInt64);
401 scilab_fill_add(ScalarUInt16, Bool, S_M, UInt16, Bool, UInt16);
402 scilab_fill_add(ScalarUInt16, Empty, S_M, UInt16, Double, UInt16);
405 scilab_fill_add(ScalarUInt16, ScalarDouble, S_S, UInt16, Double, UInt16);
406 scilab_fill_add(ScalarUInt16, ScalarInt8, S_S, UInt16, Int8, UInt16);
407 scilab_fill_add(ScalarUInt16, ScalarUInt8, S_S, UInt16, UInt8, UInt16);
408 scilab_fill_add(ScalarUInt16, ScalarInt16, S_S, UInt16, Int16, UInt16);
409 scilab_fill_add(ScalarUInt16, ScalarUInt16, S_S, UInt16, UInt16, UInt16);
410 scilab_fill_add(ScalarUInt16, ScalarInt32, S_S, UInt16, Int32, UInt32);
411 scilab_fill_add(ScalarUInt16, ScalarUInt32, S_S, UInt16, UInt32, UInt32);
412 scilab_fill_add(ScalarUInt16, ScalarInt64, S_S, UInt16, Int64, UInt64);
413 scilab_fill_add(ScalarUInt16, ScalarUInt64, S_S, UInt16, UInt64, UInt64);
414 scilab_fill_add(ScalarUInt16, ScalarBool, S_S, UInt16, Bool, UInt16);
418 scilab_fill_add(Int32, Double, M_M, Int32, Double, Int32);
419 scilab_fill_add(Int32, Int8, M_M, Int32, Int8, Int32);
420 scilab_fill_add(Int32, UInt8, M_M, Int32, UInt8, UInt32);
421 scilab_fill_add(Int32, Int16, M_M, Int32, Int16, Int32);
422 scilab_fill_add(Int32, UInt16, M_M, Int32, UInt16, UInt32);
423 scilab_fill_add(Int32, Int32, M_M, Int32, Int32, Int32);
424 scilab_fill_add(Int32, UInt32, M_M, Int32, UInt32, UInt32);
425 scilab_fill_add(Int32, Int64, M_M, Int32, Int64, Int64);
426 scilab_fill_add(Int32, UInt64, M_M, Int32, UInt64, UInt64);
427 scilab_fill_add(Int32, Bool, M_M, Int32, Bool, Int32);
428 scilab_fill_add(Int32, Empty, M_M, Int32, Double, Int32);
431 scilab_fill_add(Int32, ScalarDouble, M_S, Int32, Double, Int32);
432 scilab_fill_add(Int32, ScalarInt8, M_S, Int32, Int8, Int32);
433 scilab_fill_add(Int32, ScalarUInt8, M_S, Int32, UInt8, UInt32);
434 scilab_fill_add(Int32, ScalarInt16, M_S, Int32, Int16, Int32);
435 scilab_fill_add(Int32, ScalarUInt16, M_S, Int32, UInt16, UInt32);
436 scilab_fill_add(Int32, ScalarInt32, M_S, Int32, Int32, Int32);
437 scilab_fill_add(Int32, ScalarUInt32, M_S, Int32, UInt32, UInt32);
438 scilab_fill_add(Int32, ScalarInt64, M_S, Int32, Int64, Int64);
439 scilab_fill_add(Int32, ScalarUInt64, M_S, Int32, UInt64, UInt64);
440 scilab_fill_add(Int32, ScalarBool, M_S, Int32, Bool, Int32);
443 scilab_fill_add(ScalarInt32, Double, S_M, Int32, Double, Int32);
444 scilab_fill_add(ScalarInt32, Int8, S_M, Int32, Int8, Int32);
445 scilab_fill_add(ScalarInt32, UInt8, S_M, Int32, UInt8, UInt32);
446 scilab_fill_add(ScalarInt32, Int16, S_M, Int32, Int16, Int32);
447 scilab_fill_add(ScalarInt32, UInt16, S_M, Int32, UInt16, UInt32);
448 scilab_fill_add(ScalarInt32, Int32, S_M, Int32, Int32, Int32);
449 scilab_fill_add(ScalarInt32, UInt32, S_M, Int32, UInt32, UInt32);
450 scilab_fill_add(ScalarInt32, Int64, S_M, Int32, Int64, Int64);
451 scilab_fill_add(ScalarInt32, UInt64, S_M, Int32, UInt64, UInt64);
452 scilab_fill_add(ScalarInt32, Bool, S_M, Int32, Bool, Int32);
453 scilab_fill_add(ScalarInt32, Empty, M_M, Int32, Double, Int32);
456 scilab_fill_add(ScalarInt32, ScalarDouble, S_S, Int32, Double, Int32);
457 scilab_fill_add(ScalarInt32, ScalarInt8, S_S, Int32, Int8, Int32);
458 scilab_fill_add(ScalarInt32, ScalarUInt8, S_S, Int32, UInt8, UInt32);
459 scilab_fill_add(ScalarInt32, ScalarInt16, S_S, Int32, Int16, Int32);
460 scilab_fill_add(ScalarInt32, ScalarUInt16, S_S, Int32, UInt16, UInt32);
461 scilab_fill_add(ScalarInt32, ScalarInt32, S_S, Int32, Int32, Int32);
462 scilab_fill_add(ScalarInt32, ScalarUInt32, S_S, Int32, UInt32, UInt32);
463 scilab_fill_add(ScalarInt32, ScalarInt64, S_S, Int32, Int64, Int64);
464 scilab_fill_add(ScalarInt32, ScalarUInt64, S_S, Int32, UInt64, UInt64);
465 scilab_fill_add(ScalarInt32, ScalarBool, S_S, Int32, Bool, Int32);
469 scilab_fill_add(UInt32, Double, M_M, UInt32, Double, UInt32);
470 scilab_fill_add(UInt32, Int8, M_M, UInt32, Int8, UInt32);
471 scilab_fill_add(UInt32, UInt8, M_M, UInt32, UInt8, UInt32);
472 scilab_fill_add(UInt32, Int16, M_M, UInt32, Int16, UInt32);
473 scilab_fill_add(UInt32, UInt16, M_M, UInt32, UInt16, UInt32);
474 scilab_fill_add(UInt32, Int32, M_M, UInt32, Int32, UInt32);
475 scilab_fill_add(UInt32, UInt32, M_M, UInt32, UInt32, UInt32);
476 scilab_fill_add(UInt32, Int64, M_M, UInt32, Int64, UInt64);
477 scilab_fill_add(UInt32, UInt64, M_M, UInt32, UInt64, UInt64);
478 scilab_fill_add(UInt32, Bool, M_M, UInt32, Bool, UInt32);
479 scilab_fill_add(UInt32, Empty, M_M, UInt32, Double, UInt32);
482 scilab_fill_add(UInt32, ScalarDouble, M_S, UInt32, Double, UInt32);
483 scilab_fill_add(UInt32, ScalarInt8, M_S, UInt32, Int8, UInt32);
484 scilab_fill_add(UInt32, ScalarUInt8, M_S, UInt32, UInt8, UInt32);
485 scilab_fill_add(UInt32, ScalarInt16, M_S, UInt32, Int16, UInt32);
486 scilab_fill_add(UInt32, ScalarUInt16, M_S, UInt32, UInt16, UInt32);
487 scilab_fill_add(UInt32, ScalarInt32, M_S, UInt32, Int32, UInt32);
488 scilab_fill_add(UInt32, ScalarUInt32, M_S, UInt32, UInt32, UInt32);
489 scilab_fill_add(UInt32, ScalarInt64, M_S, UInt32, Int64, UInt64);
490 scilab_fill_add(UInt32, ScalarUInt64, M_S, UInt32, UInt64, UInt64);
491 scilab_fill_add(UInt32, ScalarBool, M_S, UInt32, Bool, UInt32);
494 scilab_fill_add(ScalarUInt32, Double, S_M, UInt32, Double, UInt32);
495 scilab_fill_add(ScalarUInt32, Int8, S_M, UInt32, Int8, UInt32);
496 scilab_fill_add(ScalarUInt32, UInt8, S_M, UInt32, UInt8, UInt32);
497 scilab_fill_add(ScalarUInt32, Int16, S_M, UInt32, Int16, UInt32);
498 scilab_fill_add(ScalarUInt32, UInt16, S_M, UInt32, UInt16, UInt32);
499 scilab_fill_add(ScalarUInt32, Int32, S_M, UInt32, Int32, UInt32);
500 scilab_fill_add(ScalarUInt32, UInt32, S_M, UInt32, UInt32, UInt32);
501 scilab_fill_add(ScalarUInt32, Int64, S_M, UInt32, Int64, UInt64);
502 scilab_fill_add(ScalarUInt32, UInt64, S_M, UInt32, UInt64, UInt64);
503 scilab_fill_add(ScalarUInt32, Bool, S_M, UInt32, Bool, UInt32);
504 scilab_fill_add(ScalarUInt32, Empty, S_M, UInt32, Double, UInt32);
507 scilab_fill_add(ScalarUInt32, ScalarDouble, S_S, UInt32, Double, UInt32);
508 scilab_fill_add(ScalarUInt32, ScalarInt8, S_S, UInt32, Int8, UInt32);
509 scilab_fill_add(ScalarUInt32, ScalarUInt8, S_S, UInt32, UInt8, UInt32);
510 scilab_fill_add(ScalarUInt32, ScalarInt16, S_S, UInt32, Int16, UInt32);
511 scilab_fill_add(ScalarUInt32, ScalarUInt16, S_S, UInt32, UInt16, UInt32);
512 scilab_fill_add(ScalarUInt32, ScalarInt32, S_S, UInt32, Int32, UInt32);
513 scilab_fill_add(ScalarUInt32, ScalarUInt32, S_S, UInt32, UInt32, UInt32);
514 scilab_fill_add(ScalarUInt32, ScalarInt64, S_S, UInt32, Int64, UInt64);
515 scilab_fill_add(ScalarUInt32, ScalarUInt64, S_S, UInt32, UInt64, UInt64);
516 scilab_fill_add(ScalarUInt32, ScalarBool, S_S, UInt32, Bool, UInt32);
520 scilab_fill_add(Int64, Double, M_M, Int64, Double, Int64);
521 scilab_fill_add(Int64, Int8, M_M, Int64, Int8, Int64);
522 scilab_fill_add(Int64, UInt8, M_M, Int64, UInt8, UInt64);
523 scilab_fill_add(Int64, Int16, M_M, Int64, Int16, Int64);
524 scilab_fill_add(Int64, UInt16, M_M, Int64, UInt16, UInt64);
525 scilab_fill_add(Int64, Int32, M_M, Int64, Int32, Int64);
526 scilab_fill_add(Int64, UInt32, M_M, Int64, UInt32, UInt64);
527 scilab_fill_add(Int64, Int64, M_M, Int64, Int64, Int64);
528 scilab_fill_add(Int64, UInt64, M_M, Int64, UInt64, UInt64);
529 scilab_fill_add(Int64, Bool, M_M, Int64, Bool, Int64);
530 scilab_fill_add(Int64, Empty, M_M, Int64, Double, Int64);
533 scilab_fill_add(Int64, ScalarDouble, M_S, Int64, Double, Int64);
534 scilab_fill_add(Int64, ScalarInt8, M_S, Int64, Int8, Int64);
535 scilab_fill_add(Int64, ScalarUInt8, M_S, Int64, UInt8, UInt64);
536 scilab_fill_add(Int64, ScalarInt16, M_S, Int64, Int16, Int64);
537 scilab_fill_add(Int64, ScalarUInt16, M_S, Int64, UInt16, UInt64);
538 scilab_fill_add(Int64, ScalarInt32, M_S, Int64, Int32, Int64);
539 scilab_fill_add(Int64, ScalarUInt32, M_S, Int64, UInt32, UInt64);
540 scilab_fill_add(Int64, ScalarInt64, M_S, Int64, Int64, Int64);
541 scilab_fill_add(Int64, ScalarUInt64, M_S, Int64, UInt64, UInt64);
542 scilab_fill_add(Int64, ScalarBool, M_S, Int64, Bool, Int64);
545 scilab_fill_add(ScalarInt64, Double, S_M, Int64, Double, Int64);
546 scilab_fill_add(ScalarInt64, Int8, S_M, Int64, Int8, Int64);
547 scilab_fill_add(ScalarInt64, UInt8, S_M, Int64, UInt8, UInt64);
548 scilab_fill_add(ScalarInt64, Int16, S_M, Int64, Int16, Int64);
549 scilab_fill_add(ScalarInt64, UInt16, S_M, Int64, UInt16, UInt64);
550 scilab_fill_add(ScalarInt64, Int32, S_M, Int64, Int32, Int64);
551 scilab_fill_add(ScalarInt64, UInt32, S_M, Int64, UInt32, UInt64);
552 scilab_fill_add(ScalarInt64, Int64, S_M, Int64, Int64, Int64);
553 scilab_fill_add(ScalarInt64, UInt64, S_M, Int64, UInt64, UInt64);
554 scilab_fill_add(ScalarInt64, Bool, S_M, Int64, Bool, Int64);
555 scilab_fill_add(ScalarInt64, Empty, M_M, Int64, Double, Int64);
558 scilab_fill_add(ScalarInt64, ScalarDouble, S_S, Int64, Double, Int64);
559 scilab_fill_add(ScalarInt64, ScalarInt8, S_S, Int64, Int8, Int64);
560 scilab_fill_add(ScalarInt64, ScalarUInt8, S_S, Int64, UInt8, UInt64);
561 scilab_fill_add(ScalarInt64, ScalarInt16, S_S, Int64, Int16, Int64);
562 scilab_fill_add(ScalarInt64, ScalarUInt16, S_S, Int64, UInt16, UInt64);
563 scilab_fill_add(ScalarInt64, ScalarInt32, S_S, Int64, Int32, Int64);
564 scilab_fill_add(ScalarInt64, ScalarUInt32, S_S, Int64, UInt32, UInt64);
565 scilab_fill_add(ScalarInt64, ScalarInt64, S_S, Int64, Int64, Int64);
566 scilab_fill_add(ScalarInt64, ScalarUInt64, S_S, Int64, UInt64, UInt64);
567 scilab_fill_add(ScalarInt64, ScalarBool, S_S, Int64, Bool, Int64);
571 scilab_fill_add(UInt64, Double, M_M, UInt64, Double, UInt64);
572 scilab_fill_add(UInt64, Int8, M_M, UInt64, Int8, UInt64);
573 scilab_fill_add(UInt64, UInt8, M_M, UInt64, UInt8, UInt64);
574 scilab_fill_add(UInt64, Int16, M_M, UInt64, Int16, UInt64);
575 scilab_fill_add(UInt64, UInt16, M_M, UInt64, UInt16, UInt64);
576 scilab_fill_add(UInt64, Int32, M_M, UInt64, Int32, UInt64);
577 scilab_fill_add(UInt64, UInt32, M_M, UInt64, UInt32, UInt64);
578 scilab_fill_add(UInt64, Int64, M_M, UInt64, Int64, UInt64);
579 scilab_fill_add(UInt64, UInt64, M_M, UInt64, UInt64, UInt64);
580 scilab_fill_add(UInt64, Bool, M_M, UInt64, Bool, UInt64);
581 scilab_fill_add(UInt64, Empty, M_M, UInt64, Double, UInt64);
584 scilab_fill_add(UInt64, ScalarDouble, M_S, UInt64, Double, UInt64);
585 scilab_fill_add(UInt64, ScalarInt8, M_S, UInt64, Int8, UInt64);
586 scilab_fill_add(UInt64, ScalarUInt8, M_S, UInt64, UInt8, UInt64);
587 scilab_fill_add(UInt64, ScalarInt16, M_S, UInt64, Int16, UInt64);
588 scilab_fill_add(UInt64, ScalarUInt16, M_S, UInt64, UInt16, UInt64);
589 scilab_fill_add(UInt64, ScalarInt32, M_S, UInt64, Int32, UInt64);
590 scilab_fill_add(UInt64, ScalarUInt32, M_S, UInt64, UInt32, UInt64);
591 scilab_fill_add(UInt64, ScalarInt64, M_S, UInt64, Int64, UInt64);
592 scilab_fill_add(UInt64, ScalarUInt64, M_S, UInt64, UInt64, UInt64);
593 scilab_fill_add(UInt64, ScalarBool, M_S, UInt64, Bool, UInt64);
596 scilab_fill_add(ScalarUInt64, Double, S_M, UInt64, Double, UInt64);
597 scilab_fill_add(ScalarUInt64, Int8, S_M, UInt64, Int8, UInt64);
598 scilab_fill_add(ScalarUInt64, UInt8, S_M, UInt64, UInt8, UInt64);
599 scilab_fill_add(ScalarUInt64, Int16, S_M, UInt64, Int16, UInt64);
600 scilab_fill_add(ScalarUInt64, UInt16, S_M, UInt64, UInt16, UInt64);
601 scilab_fill_add(ScalarUInt64, Int32, S_M, UInt64, Int32, UInt64);
602 scilab_fill_add(ScalarUInt64, UInt32, S_M, UInt64, UInt32, UInt64);
603 scilab_fill_add(ScalarUInt64, Int64, S_M, UInt64, Int64, UInt64);
604 scilab_fill_add(ScalarUInt64, UInt64, S_M, UInt64, UInt64, UInt64);
605 scilab_fill_add(ScalarUInt64, Bool, S_M, UInt64, Bool, UInt64);
606 scilab_fill_add(ScalarUInt64, Empty, S_M, UInt64, Double, UInt64);
609 scilab_fill_add(ScalarUInt64, ScalarDouble, S_S, UInt64, Double, UInt64);
610 scilab_fill_add(ScalarUInt64, ScalarInt8, S_S, UInt64, Int8, UInt64);
611 scilab_fill_add(ScalarUInt64, ScalarUInt8, S_S, UInt64, UInt8, UInt64);
612 scilab_fill_add(ScalarUInt64, ScalarInt16, S_S, UInt64, Int16, UInt64);
613 scilab_fill_add(ScalarUInt64, ScalarUInt16, S_S, UInt64, UInt16, UInt64);
614 scilab_fill_add(ScalarUInt64, ScalarInt32, S_S, UInt64, Int32, UInt64);
615 scilab_fill_add(ScalarUInt64, ScalarUInt32, S_S, UInt64, UInt32, UInt64);
616 scilab_fill_add(ScalarUInt64, ScalarInt64, S_S, UInt64, Int64, UInt64);
617 scilab_fill_add(ScalarUInt64, ScalarUInt64, S_S, UInt64, UInt64, UInt64);
618 scilab_fill_add(ScalarUInt64, ScalarBool, S_S, UInt64, Bool, UInt64);
622 scilab_fill_add(Bool, Double, M_M, Bool, Double, Double);
623 scilab_fill_add(Bool, Int8, M_M, Bool, Int8, Int8);
624 scilab_fill_add(Bool, UInt8, M_M, Bool, UInt8, UInt8);
625 scilab_fill_add(Bool, Int16, M_M, Bool, Int16, Int16);
626 scilab_fill_add(Bool, UInt16, M_M, Bool, UInt16, UInt16);
627 scilab_fill_add(Bool, Int32, M_M, Bool, Int32, Int32);
628 scilab_fill_add(Bool, UInt32, M_M, Bool, UInt32, UInt32);
629 scilab_fill_add(Bool, Int64, M_M, Bool, Int64, Int64);
630 scilab_fill_add(Bool, UInt64, M_M, Bool, UInt64, UInt64);
631 scilab_fill_add(Bool, Bool, M_M, Bool, Bool, Bool);
632 scilab_fill_add(Bool, Empty, M_M, Bool, Double, Double);
635 scilab_fill_add(Bool, ScalarDouble, M_S, Bool, Double, Double);
636 scilab_fill_add(Bool, ScalarInt8, M_S, Bool, Int8, Int8);
637 scilab_fill_add(Bool, ScalarUInt8, M_S, Bool, UInt8, UInt8);
638 scilab_fill_add(Bool, ScalarInt16, M_S, Bool, Int16, Int16);
639 scilab_fill_add(Bool, ScalarUInt16, M_S, Bool, UInt16, UInt16);
640 scilab_fill_add(Bool, ScalarInt32, M_S, Bool, Int32, Int32);
641 scilab_fill_add(Bool, ScalarUInt32, M_S, Bool, UInt32, UInt32);
642 scilab_fill_add(Bool, ScalarInt64, M_S, Bool, Int64, Int64);
643 scilab_fill_add(Bool, ScalarUInt64, M_S, Bool, UInt64, UInt64);
644 scilab_fill_add(Bool, ScalarBool, M_S, Bool, Bool, Bool);
647 scilab_fill_add(ScalarBool, Double, S_M, Bool, Double, Double);
648 scilab_fill_add(ScalarBool, Int8, S_M, Bool, Int8, Int8);
649 scilab_fill_add(ScalarBool, UInt8, S_M, Bool, UInt8, UInt8);
650 scilab_fill_add(ScalarBool, Int16, S_M, Bool, Int16, Int16);
651 scilab_fill_add(ScalarBool, UInt16, S_M, Bool, UInt16, UInt16);
652 scilab_fill_add(ScalarBool, Int32, S_M, Bool, Int32, Int32);
653 scilab_fill_add(ScalarBool, UInt32, S_M, Bool, UInt32, UInt32);
654 scilab_fill_add(ScalarBool, Int64, S_M, Bool, Int64, Int64);
655 scilab_fill_add(ScalarBool, UInt64, S_M, Bool, UInt64, UInt64);
656 scilab_fill_add(ScalarBool, Bool, S_M, Bool, Bool, Bool);
657 scilab_fill_add(ScalarBool, Empty, M_M, Bool, Double, Double);
660 scilab_fill_add(ScalarBool, ScalarDouble, S_S, Bool, Double, Double);
661 scilab_fill_add(ScalarBool, ScalarInt8, S_S, Bool, Int8, Int8);
662 scilab_fill_add(ScalarBool, ScalarUInt8, S_S, Bool, UInt8, UInt8);
663 scilab_fill_add(ScalarBool, ScalarInt16, S_S, Bool, Int16, Int16);
664 scilab_fill_add(ScalarBool, ScalarUInt16, S_S, Bool, UInt16, UInt16);
665 scilab_fill_add(ScalarBool, ScalarInt32, S_S, Bool, Int32, Int32);
666 scilab_fill_add(ScalarBool, ScalarUInt32, S_S, Bool, UInt32, UInt32);
667 scilab_fill_add(ScalarBool, ScalarInt64, S_S, Bool, Int64, Int64);
668 scilab_fill_add(ScalarBool, ScalarUInt64, S_S, Bool, UInt64, UInt64);
669 scilab_fill_add(ScalarBool, ScalarBool, S_S, Bool, Bool, Bool);
672 scilab_fill_add(String, String, M_M, String, String, String);
673 scilab_fill_add(String, ScalarString, M_S, String, String, String);
674 scilab_fill_add(String, Empty, M_E, String, Double, String);
676 scilab_fill_add(ScalarString, String, S_M, String, String, String);
677 scilab_fill_add(ScalarString, ScalarString, S_S, String, String, String);
678 scilab_fill_add(ScalarString, Empty, S_E, String, Double, String);
681 scilab_fill_add(Identity, Double, I_M, Double, Double, Double);
682 scilab_fill_add(Identity, DoubleComplex, I_MC, Double, Double, Double);
683 scilab_fill_add(Identity, ScalarDouble, I_S, Double, Double, Double);
684 scilab_fill_add(Identity, ScalarDoubleComplex, I_SC, Double, Double, Double);
685 scilab_fill_add(Identity, Identity, I_I, Double, Double, Double);
686 scilab_fill_add(Identity, IdentityComplex, I_IC, Double, Double, Double);
687 scilab_fill_add(Identity, Empty, I_E, Double, Double, Double);
689 scilab_fill_add(Identity, Polynom, M_M, Double, Polynom, Polynom);
690 scilab_fill_add(Identity, PolynomComplex, M_M, Double, Polynom, Polynom);
691 scilab_fill_add(Identity, ScalarPolynom, M_M, Double, Polynom, Polynom);
692 scilab_fill_add(Identity, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
693 scilab_fill_add(Identity, Sparse, M_M, Double, Sparse, Sparse);
694 scilab_fill_add(Identity, SparseComplex, M_M, Double, Sparse, Sparse);
696 scilab_fill_add(IdentityComplex, Double, IC_M, Double, Double, Double);
697 scilab_fill_add(IdentityComplex, DoubleComplex, IC_MC, Double, Double, Double);
698 scilab_fill_add(IdentityComplex, ScalarDouble, IC_S, Double, Double, Double);
699 scilab_fill_add(IdentityComplex, ScalarDoubleComplex, IC_SC, Double, Double, Double);
700 scilab_fill_add(IdentityComplex, Identity, IC_I, Double, Double, Double);
701 scilab_fill_add(IdentityComplex, IdentityComplex, IC_IC, Double, Double, Double);
702 scilab_fill_add(IdentityComplex, Empty, IC_E, Double, Double, Double);
704 scilab_fill_add(IdentityComplex, Polynom, M_M, Double, Polynom, Polynom);
705 scilab_fill_add(IdentityComplex, PolynomComplex, M_M, Double, Polynom, Polynom);
706 scilab_fill_add(IdentityComplex, ScalarPolynom, M_M, Double, Polynom, Polynom);
707 scilab_fill_add(IdentityComplex, ScalarPolynomComplex, M_M, Double, Polynom, Polynom);
708 scilab_fill_add(IdentityComplex, Sparse, M_M, Double, Sparse, Sparse);
709 scilab_fill_add(IdentityComplex, SparseComplex, M_M, Double, Sparse, Sparse);
714 scilab_fill_add(Polynom, Polynom, M_M, Polynom, Polynom, Polynom);
715 scilab_fill_add(Polynom, PolynomComplex, M_M, Polynom, Polynom, Polynom);
716 scilab_fill_add(PolynomComplex, Polynom, M_M, Polynom, Polynom, Polynom);
717 scilab_fill_add(PolynomComplex, PolynomComplex, M_M, Polynom, Polynom, Polynom);
720 scilab_fill_add(Polynom, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
721 scilab_fill_add(Polynom, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
722 scilab_fill_add(PolynomComplex, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
723 scilab_fill_add(PolynomComplex, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
726 scilab_fill_add(Polynom, Double, M_M, Polynom, Double, Polynom);
727 scilab_fill_add(Polynom, DoubleComplex, M_M, Polynom, Double, Polynom);
728 scilab_fill_add(PolynomComplex, Double, M_M, Polynom, Double, Polynom);
729 scilab_fill_add(PolynomComplex, DoubleComplex, M_M, Polynom, Double, Polynom);
731 //poly + scalar double
732 scilab_fill_add(Polynom, ScalarDouble, M_M, Polynom, Double, Polynom);
733 scilab_fill_add(Polynom, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
734 scilab_fill_add(PolynomComplex, ScalarDouble, M_M, Polynom, Double, Polynom);
735 scilab_fill_add(PolynomComplex, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
738 scilab_fill_add(Polynom, Empty, M_M, Polynom, Double, Polynom);
739 scilab_fill_add(PolynomComplex, Empty, M_M, Polynom, Double, Polynom);
742 scilab_fill_add(Polynom, Identity, M_M, Polynom, Double, Polynom);
743 scilab_fill_add(Polynom, IdentityComplex, M_M, Polynom, Double, Polynom);
744 scilab_fill_add(PolynomComplex, Identity, M_M, Polynom, Double, Polynom);
745 scilab_fill_add(PolynomComplex, IdentityComplex, M_M, Polynom, Double, Polynom);
748 scilab_fill_add(ScalarPolynom, Polynom, M_M, Polynom, Polynom, Polynom);
749 scilab_fill_add(ScalarPolynom, PolynomComplex, M_M, Polynom, Polynom, Polynom);
750 scilab_fill_add(ScalarPolynomComplex, Polynom, M_M, Polynom, Polynom, Polynom);
751 scilab_fill_add(ScalarPolynomComplex, PolynomComplex, M_M, Polynom, Polynom, Polynom);
753 //scalar poly + scalar poly
754 scilab_fill_add(ScalarPolynom, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
755 scilab_fill_add(ScalarPolynom, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
756 scilab_fill_add(ScalarPolynomComplex, ScalarPolynom, M_M, Polynom, Polynom, Polynom);
757 scilab_fill_add(ScalarPolynomComplex, ScalarPolynomComplex, M_M, Polynom, Polynom, Polynom);
759 //scalar poly + double
760 scilab_fill_add(ScalarPolynom, Double, M_M, Polynom, Double, Polynom);
761 scilab_fill_add(ScalarPolynom, DoubleComplex, M_M, Polynom, Double, Polynom);
762 scilab_fill_add(ScalarPolynomComplex, Double, M_M, Polynom, Double, Polynom);
763 scilab_fill_add(ScalarPolynomComplex, DoubleComplex, M_M, Polynom, Double, Polynom);
765 //scalar poly + scalar double
766 scilab_fill_add(ScalarPolynom, ScalarDouble, M_M, Polynom, Double, Polynom);
767 scilab_fill_add(ScalarPolynom, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
768 scilab_fill_add(ScalarPolynomComplex, ScalarDouble, M_M, Polynom, Double, Polynom);
769 scilab_fill_add(ScalarPolynomComplex, ScalarDoubleComplex, M_M, Polynom, Double, Polynom);
772 scilab_fill_add(ScalarPolynom, Empty, M_M, Polynom, Double, Polynom);
773 scilab_fill_add(ScalarPolynomComplex, Empty, M_M, Polynom, Double, Polynom);
776 scilab_fill_add(ScalarPolynom, Identity, M_M, Polynom, Double, Polynom);
777 scilab_fill_add(ScalarPolynom, IdentityComplex, M_M, Polynom, Double, Polynom);
778 scilab_fill_add(ScalarPolynomComplex, Identity, M_M, Polynom, Double, Polynom);
779 scilab_fill_add(ScalarPolynomComplex, IdentityComplex, M_M, Polynom, Double, Polynom);
782 scilab_fill_add(Sparse, Sparse, M_M, Sparse, Sparse, Sparse);
783 scilab_fill_add(Sparse, SparseComplex, M_M, Sparse, Sparse, Sparse);
784 scilab_fill_add(Sparse, Double, M_M, Sparse, Double, Double);
785 scilab_fill_add(Sparse, DoubleComplex, M_M, Sparse, Double, Double);
786 scilab_fill_add(Sparse, ScalarDouble, M_M, Sparse, Double, Double);
787 scilab_fill_add(Sparse, ScalarDoubleComplex, M_M, Sparse, Double, Double);
789 scilab_fill_add(Sparse, Empty, M_M, Sparse, Double, Sparse);
790 scilab_fill_add(Sparse, Identity, M_M, Sparse, Double, Sparse);
791 scilab_fill_add(Sparse, IdentityComplex, M_M, Sparse, Double, Sparse);
793 scilab_fill_add(SparseComplex, Sparse, M_M, Sparse, Sparse, Sparse);
794 scilab_fill_add(SparseComplex, SparseComplex, M_M, Sparse, Sparse, Sparse);
795 scilab_fill_add(SparseComplex, Double, M_M, Sparse, Double, Double);
796 scilab_fill_add(SparseComplex, DoubleComplex, M_M, Sparse, Double, Double);
797 scilab_fill_add(SparseComplex, ScalarDouble, M_M, Sparse, Double, Double);
798 scilab_fill_add(SparseComplex, ScalarDoubleComplex, M_M, Sparse, Double, Double);
800 scilab_fill_add(SparseComplex, Empty, M_M, Sparse, Double, Sparse);
801 scilab_fill_add(SparseComplex, Identity, M_M, Sparse, Double, Sparse);
802 scilab_fill_add(SparseComplex, IdentityComplex, M_M, Sparse, Double, Sparse);
804 #undef scilab_fill_add
807 InternalType *GenericPlus(InternalType *_pLeftOperand, InternalType *_pRightOperand)
809 InternalType *pResult = NULL;
811 add_function add = pAddfunction[_pLeftOperand->getId()][_pRightOperand->getId()];
814 pResult = add(_pLeftOperand, _pRightOperand);
822 ** Default case : Return NULL will Call Overloading.
827 int AddSparseToSparse(Sparse* sp1, Sparse* sp2, Sparse** pSpRes)
829 //check scalar hidden in a sparse ;)
830 if (sp1->getRows() == 1 && sp1->getCols() == 1)
834 if (sp1->isComplex())
836 std::complex<double> dbl = sp1->getImg(0, 0);
837 pDbl = new Double(dbl.real(), dbl.imag());
841 pDbl = new Double(sp1->get(0, 0));
844 AddSparseToDouble(sp2, pDbl, (GenericType**)pSpRes);
849 if (sp2->getRows() == 1 && sp2->getCols() == 1)
853 if (sp2->isComplex())
855 std::complex<double> dbl = sp2->getImg(0, 0);
856 pDbl = new Double(dbl.real(), dbl.imag());
860 pDbl = new Double(sp2->get(0, 0));
863 AddSparseToDouble(sp1, pDbl, (GenericType**)pSpRes);
868 if (sp1->getRows() != sp2->getRows() || sp1->getCols() != sp2->getCols())
870 //dimensions not match
874 if (sp1->nonZeros() == 0)
877 *pSpRes = new Sparse(*sp2);
881 if (sp2->nonZeros() == 0)
884 *pSpRes = new Sparse(*sp1);
889 *pSpRes = sp1->add(*sp2);
893 int AddSparseToDouble(Sparse* sp, Double* d, GenericType** pDRes)
895 int iOne = 1; //fortran
896 bool bComplex1 = sp->isComplex();
897 bool bComplex2 = d->isComplex();
902 Sparse* pS = new Sparse(sp->getRows(), sp->getCols(), d->isComplex());
905 for (int i = 0 ; i < Min(sp->getRows(), sp->getCols()) ; i++)
907 pS->set(i, i, std::complex<double>(d->get(0), d->getImg(0)));
912 for (int i = 0 ; i < Min(sp->getRows(), sp->getCols()) ; i++)
914 pS->set(i, i, d->get(0));
918 AddSparseToSparse(sp, pS, (Sparse**)pDRes);
923 if (sp->isScalar() && d->isScalar())
926 Double* pRes = (Double*)d->clone();
927 pRes->setComplex(bComplex1 | bComplex2);
930 std::complex<double> dbl = sp->getImg(0, 0);
931 pRes->set(0, pRes->get(0) + dbl.real());
932 pRes->setImg(0, pRes->getImg(0) + dbl.imag());
936 pRes->set(0, pRes->get(0) + sp->get(0, 0));
946 Double* pRes = new Double(sp->getRows(), sp->getCols(), bComplex1 | bComplex2);
947 int iSize = sp->getSize();
948 double dblVal = d->get(0);
949 C2F(dset)(&iSize, &dblVal, pRes->get(), &iOne);
952 double dblValI = d->getImg(0);
953 C2F(dset)(&iSize, &dblValI, pRes->getImg(), &iOne);
957 //initialize imag part at 0
959 C2F(dset)(&iSize, &dblValI, pRes->getImg(), &iOne);
962 int nonZeros = static_cast<int>(sp->nonZeros());
963 int* pRows = new int[nonZeros * 2];
964 sp->outputRowCol(pRows);
965 int* pCols = pRows + nonZeros;
969 for (int i = 0 ; i < nonZeros ; i++)
971 int iRow = static_cast<int>(pRows[i]) - 1;
972 int iCol = static_cast<int>(pCols[i]) - 1;
973 std::complex<double> dbl = sp->getImg(iRow, iCol);
974 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + dbl.real());
975 pRes->setImg(iRow, iCol, pRes->getImg(iRow, iCol) + dbl.imag());
980 for (int i = 0 ; i < nonZeros ; i++)
982 int iRow = static_cast<int>(pRows[i]) - 1;
983 int iCol = static_cast<int>(pCols[i]) - 1;
984 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + sp->get(iRow, iCol));
998 Double* pRes = (Double*)d->clone();
999 pRes->setComplex(bComplex1 | bComplex2);
1003 double* pReal = pRes->get();
1004 double* pImg = pRes->getImg();
1005 for (int i = 0 ; i < pRes->getSize() ; i++)
1007 std::complex<double> dbl = sp->getImg(0, 0);
1008 pReal[i] += dbl.real();
1009 pImg[i] += dbl.imag();
1014 double* pReal = pRes->get();
1015 for (int i = 0 ; i < pRes->getSize() ; i++)
1017 pReal[i] += sp->get(0, 0);
1026 if (sp->getRows() == d->getRows() && sp->getCols() == d->getCols())
1029 Double* pRes = (Double*)d->clone();
1030 pRes->setComplex(bComplex1 | bComplex2);
1032 int nonZeros = static_cast<int>(sp->nonZeros());
1033 int* pRows = new int[nonZeros * 2];
1034 sp->outputRowCol(pRows);
1035 int* pCols = pRows + nonZeros;
1039 for (int i = 0 ; i < nonZeros ; i++)
1041 int iRow = static_cast<int>(pRows[i]) - 1;
1042 int iCol = static_cast<int>(pCols[i]) - 1;
1043 std::complex<double> dbl = sp->getImg(iRow, iCol);
1044 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + dbl.real());
1045 pRes->setImg(iRow, iCol, pRes->getImg(iRow, iCol) + dbl.imag());
1050 for (int i = 0 ; i < nonZeros ; i++)
1052 int iRow = static_cast<int>(pRows[i]) - 1;
1053 int iCol = static_cast<int>(pCols[i]) - 1;
1054 pRes->set(iRow, iCol, pRes->get(iRow, iCol) + sp->get(iRow, iCol));
1066 int AddDoubleToSparse(Double* d, Sparse* sp, GenericType** pDRes)
1068 /* uses commutativity */
1069 return AddSparseToDouble(sp, d, pDRes);
1072 template<class T, class U, class O>
1073 InternalType* add_M_M(T *_pL, U *_pR)
1075 int iDimsL = _pL->getDims();
1076 int iDimsR = _pR->getDims();
1078 if (iDimsL != iDimsR)
1080 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1083 int* piDimsL = _pL->getDimsArray();
1084 int* piDimsR = _pR->getDimsArray();
1086 for (int i = 0 ; i < iDimsL ; ++i)
1088 if (piDimsL[i] != piDimsR[i])
1090 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1094 O* pOut = new O(iDimsL, piDimsL);
1096 add(_pL->get(), (long long)_pL->getSize(), _pR->get(), pOut->get());
1100 template<class T, class U, class O>
1101 InternalType* add_M_MC(T *_pL, U *_pR)
1103 int iDimsL = _pL->getDims();
1104 int iDimsR = _pR->getDims();
1106 if (iDimsL != iDimsR)
1108 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1111 int* piDimsL = _pL->getDimsArray();
1112 int* piDimsR = _pR->getDimsArray();
1114 for (int i = 0 ; i < iDimsL ; ++i)
1116 if (piDimsL[i] != piDimsR[i])
1118 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1122 O* pOut = new O(iDimsL, piDimsL, true);
1124 add(_pL->get(), (long long)_pL->getSize(), _pR->get(), _pR->getImg(), pOut->get(), pOut->getImg());
1128 template<class T, class U, class O>
1129 InternalType* add_M_S(T *_pL, U *_pR)
1131 O* pOut = new O(_pL->getDims(), _pL->getDimsArray());
1132 add(_pL->get(), (long long)_pL->getSize(), _pR->get(0), pOut->get());
1136 template<class T, class U, class O>
1137 InternalType* add_M_SC(T *_pL, U *_pR)
1139 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1140 add(_pL->get(), (long long)_pL->getSize(), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1144 template<class T, class U, class O>
1145 InternalType* add_M_E(T *_pL, U *_pR)
1151 template<class T, class U, class O>
1152 InternalType* add_MC_M(T *_pL, U *_pR)
1154 return add_M_MC<U, T, O>(_pR, _pL);
1157 template<class T, class U, class O>
1158 InternalType* add_MC_MC(T *_pL, U *_pR)
1160 int iDimsL = _pL->getDims();
1161 int iDimsR = _pR->getDims();
1163 if (iDimsL != iDimsR)
1165 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1168 int* piDimsL = _pL->getDimsArray();
1169 int* piDimsR = _pR->getDimsArray();
1171 for (int i = 0 ; i < iDimsL ; ++i)
1173 if (piDimsL[i] != piDimsR[i])
1175 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1179 O* pOut = new O(iDimsL, piDimsL, true);
1181 add(_pL->get(), _pL->getImg(), (long long)_pL->getSize(), _pR->get(), _pR->getImg(), pOut->get(), pOut->getImg());
1185 template<class T, class U, class O>
1186 InternalType* add_MC_S(T *_pL, U *_pR)
1188 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1189 add(_pL->get(), _pL->getImg(), (long long)_pL->getSize(), _pR->get(0), pOut->get(), pOut->getImg());
1193 template<class T, class U, class O>
1194 InternalType* add_MC_SC(T *_pL, U *_pR)
1196 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1197 add(_pL->get(), _pL->getImg(), (long long)_pL->getSize(), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1201 template<class T, class U, class O>
1202 InternalType* add_MC_E(T *_pL, U *_pR)
1204 O* pOut = new O(_pL->getDims(), _pL->getDimsArray(), true);
1205 add(_pL->get(), _pL->getImg(), (long long)_pL->getSize(), pOut->get(), pOut->getImg());
1210 template<class T, class U, class O>
1211 InternalType* add_S_M(T *_pL, U *_pR)
1213 return add_M_S<U, T, O>(_pR, _pL);
1216 template<class T, class U, class O>
1217 InternalType* add_S_MC(T *_pL, U *_pR)
1219 return add_MC_S<U, T, O>(_pR, _pL);
1222 template<class T, class U, class O>
1223 InternalType* add_S_S(T *_pL, U *_pR)
1226 add(_pL->get(0), _pR->get(0), pOut->get());
1230 template<class T, class U, class O>
1231 InternalType* add_S_SC(T *_pL, U *_pR)
1233 O* pOut = new O(0.0, 0.0);
1234 add(_pL->get(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1238 template<class T, class U, class O>
1239 InternalType* add_S_E(T *_pL, U *_pR)
1242 add(_pL->get(0), pOut->get());
1247 template<class T, class U, class O>
1248 InternalType* add_SC_M(T *_pL, U *_pR)
1250 return add_M_SC<U, T, O>(_pR, _pL);
1253 template<class T, class U, class O>
1254 InternalType* add_SC_MC(T *_pL, U *_pR)
1256 return add_MC_SC<U, T, O>(_pR, _pL);
1259 template<class T, class U, class O>
1260 InternalType* add_SC_S(T *_pL, U *_pR)
1262 return add_S_SC<U, T, O>(_pR, _pL);
1265 template<class T, class U, class O>
1266 InternalType* add_SC_SC(T *_pL, U *_pR)
1268 O* pOut = new O(0.0, 0.0);
1269 add(_pL->get(0), _pL->getImg(0), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1273 template<class T, class U, class O>
1274 InternalType* add_SC_E(T *_pL, U *_pR)
1276 O* pOut = new O(0.0, 0.0);
1277 add(_pL->get(0), _pL->getImg(0), pOut->get(), pOut->getImg());
1282 template<class T, class U, class O>
1283 InternalType* add_E_M(T *_pL, U *_pR)
1285 return add_M_E<U, T, O>(_pR, _pL);
1288 template<class T, class U, class O>
1289 InternalType* add_E_MC(T *_pL, U *_pR)
1291 return add_MC_E<U, T, O>(_pR, _pL);
1294 template<class T, class U, class O>
1295 InternalType* add_E_S(T *_pL, U *_pR)
1297 return add_S_E<U, T, O>(_pR, _pL);
1300 template<class T, class U, class O>
1301 InternalType* add_E_SC(T *_pL, U *_pR)
1303 return add_SC_E<U, T, O>(_pR, _pL);
1306 template<class T, class U, class O>
1307 InternalType* add_E_E(T *_pL, U *_pR)
1309 Double* pOut = Double::Empty();
1314 template<class T, class U, class O>
1315 InternalType* add_I_M(T *_pL, U *_pR)
1317 int iDims = _pR->getDims();
1318 int* piDims = _pR->getDimsArray();
1319 O* pOut = (O*)_pR->clone();
1320 double* pdblOut = pOut->get();
1321 double* pdblRight = _pR->get();
1322 double dblLeft = _pL->get(0);
1323 int iLeadDims = piDims[0];
1324 int* piIndex = new int[iDims];
1328 for (int i = 1 ; i < iDims ; ++i)
1333 if (iLeadDims > piDims[i])
1335 iLeadDims = piDims[i];
1339 for (int i = 0 ; i < iLeadDims ; ++i)
1341 for (int j = 0 ; j < iDims ; ++j)
1346 int index = _pR->getIndex(piIndex);
1347 add(dblLeft, pdblRight[index], pdblOut + index);
1353 template<class T, class U, class O>
1354 InternalType* add_I_MC(T *_pL, U *_pR)
1356 return add_I_M<T, U, O>(_pL, _pR);
1359 template<class T, class U, class O>
1360 InternalType* add_IC_M(T *_pL, U *_pR)
1362 int iDims = _pR->getDims();
1363 int* piDims = _pR->getDimsArray();
1364 O* pOut = (O*)_pR->clone();
1365 pOut->setComplex(true);
1366 int iLeadDims = piDims[0];
1367 int* piIndex = new int[iDims];
1370 for (int i = 1 ; i < iDims ; ++i)
1375 if (iLeadDims > piDims[i])
1377 iLeadDims = piDims[i];
1381 for (int i = 0 ; i < iLeadDims ; ++i)
1383 for (int j = 0 ; j < iDims ; ++j)
1388 int index = _pR->getIndex(piIndex);
1389 add(_pR->get() + index, 1, _pL->get(0), _pL->getImg(0), pOut->get() + index, pOut->getImg() + index);
1395 template<class T, class U, class O>
1396 InternalType* add_IC_MC(T *_pL, U *_pR)
1398 int iDims = _pR->getDims();
1399 int* piDims = _pR->getDimsArray();
1400 O* pOut = (O*)_pR->clone();
1401 int iLeadDims = piDims[0];
1402 int* piIndex = new int[iDims];
1405 for (int i = 1 ; i < iDims ; ++i)
1410 if (iLeadDims > piDims[i])
1412 iLeadDims = piDims[i];
1416 for (int i = 0 ; i < iLeadDims ; ++i)
1418 for (int j = 0 ; j < iDims ; ++j)
1423 int index = _pR->getIndex(piIndex);
1425 add(_pL->get(0), _pL->getImg(0), _pR->get(index), _pR->getImg(index), pOut->get() + index, pOut->getImg() + index);
1431 template<class T, class U, class O>
1432 InternalType* add_I_S(T *_pL, U *_pR)
1435 add(_pL->get(0), _pR->get(0), pOut->get());
1439 template<class T, class U, class O>
1440 InternalType* add_IC_S(T *_pL, U *_pR)
1442 O* pOut = new O(0.0, 0.0);
1443 add( _pR->get(), 1, _pL->get(0), _pL->getImg(0), pOut->get(), pOut->getImg());
1447 template<class T, class U, class O>
1448 InternalType* add_I_SC(T *_pL, U *_pR)
1450 O* pOut = new O(0.0, 0.0);
1451 add(_pL->get(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1455 template<class T, class U, class O>
1456 InternalType* add_IC_SC(T *_pL, U *_pR)
1458 O* pOut = new O(0.0, 0.0);
1459 add(_pL->get(), _pL->getImg(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1463 template<class T, class U, class O> InternalType* add_M_I(T *_pL, U *_pR)
1465 return add_I_M<U, T, O>(_pR, _pL);
1468 template<class T, class U, class O> InternalType* add_MC_I(T *_pL, U *_pR)
1470 return add_I_MC<U, T, O>(_pR, _pL);
1473 template<class T, class U, class O> InternalType* add_M_IC(T *_pL, U *_pR)
1475 return add_IC_M<U, T, O>(_pR, _pL);
1478 template<class T, class U, class O> InternalType* add_MC_IC(T *_pL, U *_pR)
1480 return add_IC_MC<U, T, O>(_pR, _pL);
1483 template<class T, class U, class O> InternalType* add_S_I(T *_pL, U *_pR)
1485 return add_I_S<U, T, O>(_pR, _pL);
1488 template<class T, class U, class O> InternalType* add_SC_I(T *_pL, U *_pR)
1490 return add_I_SC<U, T, O>(_pR, _pL);
1493 template<class T, class U, class O> InternalType* add_S_IC(T *_pL, U *_pR)
1495 return add_IC_S<U, T, O>(_pR, _pL);
1498 template<class T, class U, class O> InternalType* add_SC_IC(T *_pL, U *_pR)
1500 return add_IC_SC<U, T, O>(_pR, _pL);
1503 template<class T, class U, class O> InternalType* add_I_I(T *_pL, U *_pR)
1505 O* pOut = (O*)_pL->clone();
1506 add(_pL->get(0), _pR->get(0), pOut->get());
1510 template<class T, class U, class O> InternalType* add_I_IC(T *_pL, U *_pR)
1512 O* pOut = (O*)_pR->clone();
1513 add(_pL->get(), 1, _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1517 template<class T, class U, class O> InternalType* add_IC_I(T *_pL, U *_pR)
1519 return add_I_IC<U, T, O>(_pR, _pL);
1522 template<class T, class U, class O> InternalType* add_IC_IC(T *_pL, U *_pR)
1524 O* pOut = (O*)_pL->clone();
1525 add(_pL->get(0), _pL->getImg(0), _pR->get(0), _pR->getImg(0), pOut->get(), pOut->getImg());
1529 template<class T, class U, class O> types::InternalType* add_I_E(T *_pL, U *_pR)
1531 O* pOut = (O*)_pL->clone();
1535 template<class T, class U, class O> types::InternalType* add_IC_E(T *_pL, U *_pR)
1537 O* pOut = (O*)_pL->clone();
1541 template<class T, class U, class O> types::InternalType* add_E_I(T *_pL, U *_pR)
1543 O* pOut = (O*)_pR->clone();
1547 template<class T, class U, class O> types::InternalType* add_E_IC(T *_pL, U *_pR)
1549 O* pOut = (O*)_pR->clone();
1553 //specifiaction for String Matrix + String Matrix
1555 InternalType* add_M_M<String, String, String>(String* _pL, String* _pR)
1557 int iDimsL = _pL->getDims();
1558 int iDimsR = _pR->getDims();
1560 if (iDimsL != iDimsR)
1562 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1565 int* piDimsL = _pL->getDimsArray();
1566 int* piDimsR = _pR->getDimsArray();
1568 for (int i = 0 ; i < iDimsL ; ++i)
1570 if (piDimsL[i] != piDimsR[i])
1572 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
1576 String* pOut = new String(iDimsL, piDimsL);
1577 int size = _pL->getSize();
1578 int* sizeOut = new int[size];
1579 for (int i = 0 ; i < size ; ++i)
1581 wchar_t* pwstL = _pL->get(i);
1582 wchar_t* pwstR = _pR->get(i);
1583 int sizeL = (int)wcslen(pwstL);
1584 int sizeR = (int)wcslen(pwstR);
1586 sizeOut[i] = sizeL + sizeR + 1;
1587 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut[i] * sizeof(wchar_t));
1588 //assign ptr without strdup
1589 pOut->get()[i] = pwstOut;
1592 add(_pL->get(), size, _pR->get(), sizeOut, pOut->get());
1597 //specifiaction for String Matrix + String Scalar
1599 InternalType* add_S_M<String, String, String>(String* _pL, String* _pR)
1601 String* pOut = new String(_pR->getDims(), _pR->getDimsArray());
1602 int size = _pR->getSize();
1603 int* sizeOut = new int[size];
1604 wchar_t* pwstL = _pL->get(0);
1605 int sizeL = (int)wcslen(pwstL);
1607 for (int i = 0 ; i < size ; ++i)
1609 wchar_t* pwstR = _pR->get(i);
1610 int sizeR = (int)wcslen(pwstR);
1612 sizeOut[i] = sizeL + sizeR + 1;
1613 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut[i] * sizeof(wchar_t));
1614 //assign ptr without strdup
1615 pOut->get()[i] = pwstOut;
1618 add(pwstL, size, _pR->get(), sizeOut, pOut->get());
1623 //specifiaction for String Scalar + String MAtrix
1625 InternalType* add_M_S<String, String, String>(String* _pL, String* _pR)
1627 String* pOut = new String(_pL->getDims(), _pL->getDimsArray());
1628 int size = _pL->getSize();
1629 int* sizeOut = new int[size];
1630 wchar_t* pwstR = _pR->get(0);
1631 int sizeR = (int)wcslen(pwstR);
1633 for (int i = 0 ; i < size ; ++i)
1635 wchar_t* pwstL = _pL->get(i);
1636 int sizeL = (int)wcslen(pwstL);
1638 sizeOut[i] = sizeL + sizeR + 1;
1639 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut[i] * sizeof(wchar_t));
1640 //assign ptr without strdup
1641 pOut->get()[i] = pwstOut;
1644 add(_pL->get(), size, pwstR, sizeOut, pOut->get());
1649 //specifiaction for String Scalar + String Scalar
1651 InternalType* add_S_S<String, String, String>(String* _pL, String* _pR)
1653 String* pOut = new String(1, 1);
1654 wchar_t* pwstL = _pL->get(0);
1655 wchar_t* pwstR = _pR->get(0);
1656 int sizeL = (int)wcslen(pwstL);
1657 int sizeR = (int)wcslen(pwstR);
1659 int sizeOut = sizeL + sizeR + 1;
1660 wchar_t* pwstOut = (wchar_t*) MALLOC(sizeOut * sizeof(wchar_t));
1661 //assign ptr without strdup
1662 pOut->get()[0] = pwstOut;
1663 add(pwstL, pwstR, sizeOut, *pOut->get());
1668 InternalType* add_M_E<String, Double, String>(String* _pL, Double* _pR)
1674 InternalType* add_S_E<String, Double, String>(String* _pL, Double* _pR)
1680 InternalType* add_E_M<Double, String, String>(Double* _pL, String* _pR)
1686 InternalType* add_E_S<Double, String, String>(Double* _pL, String* _pR)
1691 template<> InternalType* add_M_M<Polynom, Polynom, Polynom>(Polynom* _pL, Polynom* _pR)
1693 Polynom* pOut = NULL;
1694 if (_pL->getVariableName() != _pR->getVariableName())
1696 std::wostringstream os;
1697 os << _W("variables don't have the same formal variable");
1698 //os << ((Location)e.right_get().location_get()).location_getString() << std::endl;
1699 throw ast::ScilabError(os.str());
1702 if (_pL->isScalar())
1704 int *pRank = new int[_pR->getSize()];
1705 int *pRank1 = new int[_pR->getSize()];
1706 int *pRank2 = new int[_pR->getSize()];
1707 bool bComplex1 = _pL->isComplex();
1708 bool bComplex2 = _pR->isComplex();
1710 memset(pRank1, 0x00, _pR->getSize() * sizeof(int));
1712 _pL->getRank(pRank1);
1713 _pR->getRank(pRank2);
1714 for (int i = 0 ; i < _pR->getSize() ; i++)
1716 pRank[i] = Max(pRank1[0], pRank2[i]);
1719 pOut = new Polynom(_pR->getVariableName(), _pR->getDims(), _pR->getDimsArray(), pRank);
1720 if (bComplex1 || bComplex2)
1722 pOut->setComplex(true);
1725 //Result P1(0) + P2(i)
1726 Double *pCoef1 = _pL->get(0)->getCoef();
1727 double *p1R = pCoef1->getReal();
1728 double *p1I = pCoef1->getImg();
1729 for (int i = 0 ; i < _pR->getSize() ; i++)
1731 Double *pCoef2 = _pR->get(i)->getCoef();
1732 double *p2R = pCoef2->getReal();
1733 double *p2I = pCoef2->getImg();
1735 Double *pCoefR = pOut->get(i)->getCoef();
1736 double *pRR = pCoefR->getReal();
1737 double *pRI = pCoefR->getImg();
1739 for (int j = 0 ; j < Min(pRank1[0], pRank2[i]) ; j++)
1741 pRR[j] = p1R[j] + p2R[j];
1744 double *pTemp = (pRank1[0] > pRank2[i] ? p1R : p2R);
1745 for (int j = Min(pRank1[0], pRank2[i]) ; j < Max(pRank1[0], pRank2[i]) ; j++)
1750 if (pOut->isComplex())
1752 for (int j = 0 ; j < Min(pRank1[0], pRank2[i]) ; j++)
1754 pRI[j] = (p1I == NULL ? 0 : p1I[j]) + (p2I == NULL ? 0 : p2I[j]);
1757 double *pTemp = (pRank1[0] > pRank2[i] ? p1I : p2I);
1758 for (int j = Min(pRank1[0], pRank2[i]) ; j < Max(pRank1[0], pRank2[i]); j++)
1760 pRI[j] = pTemp == NULL ? 0 : pTemp[j];
1771 if (_pR->isScalar())
1773 int *pRank = new int[_pL->getSize()];
1774 int *pRank1 = new int[_pL->getSize()];
1775 int *pRank2 = new int[_pL->getSize()];
1776 bool bComplex1 = _pL->isComplex();
1777 bool bComplex2 = _pR->isComplex();
1779 memset(pRank2, 0x00, _pL->getSize() * sizeof(int));
1781 _pL->getRank(pRank1);
1782 _pR->getRank(pRank2);
1783 for (int i = 0 ; i < _pL->getSize() ; i++)
1785 pRank[i] = Max(pRank1[i], pRank2[0]);
1788 pOut = new Polynom(_pL->getVariableName(), _pL->getDims(), _pL->getDimsArray(), pRank);
1789 if (bComplex1 || bComplex2)
1791 pOut->setComplex(true);
1794 //Result P1(i) + P2(0)
1795 Double *pCoef2 = _pR->get(0)->getCoef();
1796 double *p2R = pCoef2->getReal();
1797 double *p2I = pCoef2->getImg();
1799 for (int i = 0 ; i < _pL->getSize() ; i++)
1801 Double *pCoef1 = _pL->get(i)->getCoef();
1802 double *p1R = pCoef1->getReal();
1803 double *p1I = pCoef1->getImg();
1805 Double *pCoefR = pOut->get(i)->getCoef();
1806 double *pRR = pCoefR->getReal();
1807 double *pRI = pCoefR->getImg();
1809 for (int j = 0 ; j < Min(pRank1[i], pRank2[0]) ; j++)
1811 pRR[j] = p1R[j] + p2R[j];
1814 double *pTemp = (pRank1[i] > pRank2[0] ? p1R : p2R);
1815 for (int j = Min(pRank1[i], pRank2[0]) ; j < Max(pRank1[i], pRank2[0]) ; j++)
1820 if (pOut->isComplex())
1822 for (int j = 0 ; j < Min(pRank1[i], pRank2[0]) ; j++)
1824 pRI[j] = (p1I == NULL ? 0 : p1I[j]) + (p2I == NULL ? 0 : p2I[j]);
1827 double *pTemp = (pRank1[i] > pRank2[0] ? p1I : p2I);
1828 for (int j = Min(pRank1[i], pRank2[0]) ; j < Max(pRank1[i], pRank2[0]); j++)
1830 pRI[j] = pTemp == NULL ? 0 : pTemp[j];
1841 int iDims1 = _pL->getDims();
1842 int iDims2 = _pR->getDims();
1844 if (iDims1 != iDims2)
1847 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());
1848 throw ast::ScilabError(pMsg);
1851 int* piDims1 = _pL->getDimsArray();
1852 int* piDims2 = _pR->getDimsArray();
1854 for (int i = 0 ; i < iDims1 ; i++)
1856 if (piDims1[i] != piDims2[i])
1859 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());
1860 throw ast::ScilabError(pMsg);
1864 int *pRank = new int[_pL->getSize()];
1865 int *pRank1 = new int[_pL->getSize()];
1866 int *pRank2 = new int[_pR->getSize()];
1867 bool bComplex1 = _pL->isComplex();
1868 bool bComplex2 = _pR->isComplex();
1870 _pL->getRank(pRank1);
1871 _pR->getRank(pRank2);
1872 for (int i = 0 ; i < _pL->getSize() ; i++)
1874 pRank[i] = Max(pRank1[i], pRank2[i]);
1877 pOut = new Polynom(_pR->getVariableName(), _pL->getDims(), _pL->getDimsArray(), pRank);
1878 if (_pL->isComplex() || _pR->isComplex())
1880 pOut->setComplex(true);
1883 if (bComplex1 == false && bComplex2 == false)
1885 for (int i = 0 ; i < _pL->getSize() ; i++)
1887 iAddScilabPolynomToScilabPolynom(
1888 _pL->get(i)->getCoef()->getReal(), pRank1[i],
1889 _pR->get(i)->getCoef()->getReal(), pRank2[i],
1890 pOut->get(i)->getCoef()->getReal(), pRank[i]);
1893 else if (bComplex1 == false && bComplex2 == true)
1895 for (int i = 0 ; i < _pL->getSize() ; i++)
1897 iAddScilabPolynomToComplexPoly(
1898 _pL->get(i)->getCoef()->getReal(), pRank1[i],
1899 _pR->get(i)->getCoef()->getReal(), _pR->get(i)->getCoef()->getImg(), pRank2[i],
1900 pOut->get(i)->getCoef()->getReal(), pOut->get(i)->getCoef()->getImg(), pRank[i]);
1903 else if (bComplex1 == true && bComplex2 == false)
1905 for (int i = 0 ; i < _pL->getSize() ; i++)
1907 iAddScilabPolynomToComplexPoly(
1908 _pR->get(i)->getCoef()->getReal(), pRank2[i],
1909 _pL->get(i)->getCoef()->getReal(), _pL->get(i)->getCoef()->getImg(), pRank1[i],
1910 pOut->get(i)->getCoef()->getReal(), pOut->get(i)->getCoef()->getImg(), pRank[i]);
1913 else if (bComplex1 == true && bComplex2 == true)
1915 for (int i = 0 ; i < _pL->getSize() ; i++)
1917 iAddComplexPolyToComplexPoly(
1918 _pL->get(i)->getCoef()->getReal(), _pL->get(i)->getCoef()->getImg(), pRank1[i],
1919 _pR->get(i)->getCoef()->getReal(), _pR->get(i)->getCoef()->getImg(), pRank2[i],
1920 pOut->get(i)->getCoef()->getReal(), pOut->get(i)->getCoef()->getImg(), pRank[i]);
1936 template<> InternalType* add_M_M<Polynom, Double, Polynom>(Polynom* _pL, Double* _pR)
1938 return add_M_M<Double, Polynom, Polynom>(_pR, _pL);
1941 template<> InternalType* add_M_M<Double, Polynom, Polynom>(Double* _pL, Polynom* _pR)
1943 Polynom* pOut = NULL;
1944 bool bComplex1 = _pR->isComplex();
1945 bool bComplex2 = _pL->isComplex();
1947 double *pInDblR = _pL->getReal();
1948 double *pInDblI = _pL->getImg();
1955 if (_pR->isScalar())
1957 int *piRank = new int[_pL->getSize()];
1958 for (int i = 0 ; i < _pL->getSize() ; i++)
1960 piRank[i] = _pR->get(0)->getRank();
1963 pOut = new Polynom(_pR->getVariableName(), _pL->getDims(), _pL->getDimsArray(), piRank);
1964 if (bComplex1 || bComplex2)
1966 pOut->setComplex(true);
1969 for (int i = 0 ; i < pOut->getSize() ; i++)
1971 SinglePoly *pInPoly = _pR->get(0);
1972 SinglePoly *pOutPoly = pOut->get(i);
1973 double *pInPolyR = pInPoly->getCoef()->getReal();
1974 double *pOutPolyR = pOutPoly->getCoef()->getReal();
1976 pOutPolyR[0] = pInDblR[i] + pInPolyR[0];
1978 for (int j = 1 ; j < pInPoly->getRank() ; j++)
1980 pOutPolyR[j] = pInPolyR[j];
1984 if (pOut->isComplex())
1986 for (int i = 0 ; i < pOut->getSize() ; i++)
1988 SinglePoly *pInPoly = _pR->get(0);
1989 SinglePoly *pOutPoly = pOut->get(i);
1990 double *pInPolyI = pInPoly->getCoef()->getImg();
1991 double *pOutPolyI = pOutPoly->getCoef()->getImg();
1993 pOutPolyI[0] = (pInDblI != NULL ? pInDblI[i] : 0) + (pInPolyI != NULL ? pInPolyI[0] : 0);
1995 for (int j = 1 ; j < pInPoly->getRank() ; j++)
1997 pOutPolyI[j] = (pInPolyI != NULL ? pInPolyI[j] : 0);
2005 if (_pL->isScalar())
2007 pOut = (Polynom*)_pR->clone();
2009 if (bComplex1 && bComplex2)
2011 for (int i = 0 ; i < pOut->getSize() ; i++)
2013 SinglePoly *pSPOut = pOut->get(i);
2014 double *pOutPolyR = pSPOut->getCoef()->getReal();
2015 double *pOutPolyI = pSPOut->getCoef()->getImg();
2017 pOutPolyR[0] += pInDblR[0];
2018 pOutPolyI[0] += pInDblI[0];
2023 pOut->setComplex(true);
2024 for (int i = 0 ; i < pOut->getSize() ; i++)
2026 SinglePoly *pSPOut = pOut->get(i);
2027 double *pOutPolyR = pSPOut->getCoef()->getReal();
2028 double *pOutPolyI = pSPOut->getCoef()->getImg();
2030 pOutPolyR[0] += pInDblR[0];
2031 pOutPolyI[0] = pInDblI[0];
2036 for (int i = 0 ; i < pOut->getSize() ; i++)
2038 SinglePoly *pSPOut = pOut->get(i);
2039 double *pOutPolyR = pSPOut->getCoef()->getReal();
2041 pOutPolyR[0] += pInDblR[0];
2048 int iDims1 = _pR->getDims();
2049 int iDims2 = _pL->getDims();
2051 if (iDims1 != iDims2)
2054 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());
2055 throw ast::ScilabError(pMsg);
2058 int* piDims1 = _pR->getDimsArray();
2059 int* piDims2 = _pL->getDimsArray();
2061 for (int i = 0 ; i < iDims1 ; i++)
2063 if (piDims1[i] != piDims2[i])
2066 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());
2067 throw ast::ScilabError(pMsg);
2071 pOut = (Polynom*)_pR->clone();
2072 if (bComplex1 && bComplex2)
2074 for (int i = 0 ; i < pOut->getSize() ; i++)
2076 SinglePoly *pSPOut = pOut->get(i);
2077 double *pOutPolyR = pSPOut->getCoef()->getReal();
2078 double *pOutPolyI = pSPOut->getCoef()->getImg();
2080 pOutPolyR[0] += pInDblR[i];
2081 pOutPolyI[0] += pInDblI[i];
2086 pOut->setComplex(true);
2087 for (int i = 0 ; i < pOut->getSize() ; i++)
2089 SinglePoly *pSPOut = pOut->get(i);
2090 double *pOutPolyR = pSPOut->getCoef()->getReal();
2091 double *pOutPolyI = pSPOut->getCoef()->getImg();
2093 pOutPolyR[0] += pInDblR[i];
2094 pOutPolyI[0] = pInDblI[i];
2099 for (int i = 0 ; i < pOut->getSize() ; i++)
2101 SinglePoly *pSPOut = pOut->get(i);
2102 double *pOutPolyR = pSPOut->getCoef()->getReal();
2104 pOutPolyR[0] += pInDblR[i];
2112 template<> InternalType* add_M_M<Sparse, Sparse, Sparse>(Sparse* _pL, Sparse* _pR)
2114 Sparse* pOut = NULL;
2115 //check scalar hidden in a sparse ;)
2116 if (_pL->getRows() == 1 && _pL->getCols() == 1)
2119 Double* pDbl = NULL;
2120 if (_pL->isComplex())
2122 std::complex<double> dbl = _pL->getImg(0, 0);
2123 pDbl = new Double(dbl.real(), dbl.imag());
2127 pDbl = new Double(_pL->get(0, 0));
2130 AddSparseToDouble(_pR, pDbl, (GenericType**)pOut);
2135 if (_pR->getRows() == 1 && _pR->getCols() == 1)
2138 Double* pDbl = NULL;
2139 if (_pR->isComplex())
2141 std::complex<double> dbl = _pR->getImg(0, 0);
2142 pDbl = new Double(dbl.real(), dbl.imag());
2146 pDbl = new Double(_pR->get(0, 0));
2149 AddSparseToDouble(_pL, pDbl, (GenericType**)pOut);
2154 if (_pL->getRows() != _pR->getRows() || _pL->getCols() != _pR->getCols())
2156 //dimensions not match
2157 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
2160 if (_pL->nonZeros() == 0)
2166 if (_pR->nonZeros() == 0)
2172 return _pL->add(*_pR);
2176 template<> InternalType* add_M_M<Double, Sparse, Double>(Double* _pL, Sparse* _pR)
2178 return add_M_M<Sparse, Double, Double>(_pR, _pL);
2182 template<> InternalType* add_M_M<Sparse, Double, Double>(Sparse* _pL, Double* _pR)
2184 Double* pOut = NULL;
2185 int iOne = 1; //fortran
2186 bool bComplex1 = _pL->isComplex();
2187 bool bComplex2 = _pR->isComplex();
2189 if (_pL->isScalar() && _pR->isScalar())
2192 pOut = (Double*)_pR->clone();
2193 pOut->setComplex(bComplex1 | bComplex2);
2196 std::complex<double> dbl = _pL->getImg(0, 0);
2197 pOut->set(0, pOut->get(0) + dbl.real());
2198 pOut->setImg(0, pOut->getImg(0) + dbl.imag());
2202 pOut->set(0, pOut->get(0) + _pL->get(0, 0));
2208 if (_pR->isScalar())
2211 pOut = new Double(_pL->getRows(), _pL->getCols(), bComplex1 | bComplex2);
2212 int iSize = _pL->getSize();
2213 double dblVal = _pR->get(0);
2214 C2F(dset)(&iSize, &dblVal, pOut->get(), &iOne);
2217 double dblValI = _pR->getImg(0);
2218 C2F(dset)(&iSize, &dblValI, pOut->getImg(), &iOne);
2222 //initialize imag part at 0
2224 C2F(dset)(&iSize, &dblValI, pOut->getImg(), &iOne);
2227 int nonZeros = static_cast<int>(_pL->nonZeros());
2228 int* pRows = new int[nonZeros * 2];
2229 _pL->outputRowCol(pRows);
2230 int* pCols = pRows + nonZeros;
2234 for (int i = 0 ; i < nonZeros ; i++)
2236 int iRow = static_cast<int>(pRows[i]) - 1;
2237 int iCol = static_cast<int>(pCols[i]) - 1;
2238 std::complex<double> dbl = _pL->getImg(iRow, iCol);
2239 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + dbl.real());
2240 pOut->setImg(iRow, iCol, pOut->getImg(iRow, iCol) + dbl.imag());
2245 for (int i = 0 ; i < nonZeros ; i++)
2247 int iRow = static_cast<int>(pRows[i]) - 1;
2248 int iCol = static_cast<int>(pCols[i]) - 1;
2249 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + _pL->get(iRow, iCol));
2259 if (_pL->isScalar())
2262 pOut = (Double*)_pR->clone();
2263 pOut->setComplex(bComplex1 | bComplex2);
2267 double* pReal = pOut->get();
2268 double* pImg = pOut->getImg();
2269 int size = pOut->getSize();
2270 for (int i = 0 ; i < size ; i++)
2272 std::complex<double> dbl = _pL->getImg(0, 0);
2273 pReal[i] += dbl.real();
2274 pImg[i] += dbl.imag();
2279 double* pReal = pOut->get();
2280 int size = pOut->getSize();
2281 for (int i = 0 ; i < size ; i++)
2283 pReal[i] += _pL->get(0, 0);
2291 if (_pL->getRows() == _pR->getRows() && _pL->getCols() == _pR->getCols())
2294 pOut = (Double*)_pR->clone();
2295 pOut->setComplex(bComplex1 | bComplex2);
2297 int nonZeros = static_cast<int>(_pL->nonZeros());
2298 int* pRows = new int[nonZeros * 2];
2299 _pL->outputRowCol(pRows);
2300 int* pCols = pRows + nonZeros;
2304 for (int i = 0 ; i < nonZeros ; i++)
2306 int iRow = static_cast<int>(pRows[i]) - 1;
2307 int iCol = static_cast<int>(pCols[i]) - 1;
2308 std::complex<double> dbl = _pL->getImg(iRow, iCol);
2309 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + dbl.real());
2310 pOut->setImg(iRow, iCol, pOut->getImg(iRow, iCol) + dbl.imag());
2315 for (int i = 0 ; i < nonZeros ; i++)
2317 int iRow = static_cast<int>(pRows[i]) - 1;
2318 int iCol = static_cast<int>(pCols[i]) - 1;
2319 pOut->set(iRow, iCol, pOut->get(iRow, iCol) + _pL->get(iRow, iCol));
2329 throw ast::ScilabError(_W("Inconsistent row/column dimensions.\n"));
2334 template<> InternalType* add_M_M<Double, Sparse, Sparse>(Double* _pL, Sparse* _pR)
2336 return add_M_M<Sparse, Double, Sparse>(_pR, _pL);
2340 template<> InternalType* add_M_M<Sparse, Double, Sparse>(Sparse* _pL, Double* _pR)
2342 Sparse* pOut = NULL;
2343 if (_pR->isIdentity())
2346 Sparse* pS = new Sparse(_pL->getRows(), _pL->getCols(), _pR->isComplex());
2347 if (pS->isComplex())
2349 int size = Min(_pL->getRows(), _pL->getCols());
2350 for (int i = 0 ; i < size ; i++)
2352 pS->set(i, i, std::complex<double>(_pR->get(0), _pR->getImg(0)));
2357 int size = Min(_pL->getRows(), _pL->getCols());
2358 for (int i = 0 ; i < size ; i++)
2360 pS->set(i, i, _pR->get(0));
2364 AddSparseToSparse(_pL, pS, (Sparse**)pOut);