Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GaussianProcessTuning/ILNumerics.2.14.4735.573/Array/Operator_Overloads.cs @ 9102

Last change on this file since 9102 was 9102, checked in by gkronber, 12 years ago

#1967: ILNumerics source for experimentation

File size: 32.3 KB
Line 
1///
2///    This file is part of ILNumerics Community Edition.
3///
4///    ILNumerics Community Edition - high performance computing for applications.
5///    Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
6///
7///    ILNumerics Community Edition is free software: you can redistribute it and/or modify
8///    it under the terms of the GNU General Public License version 3 as published by
9///    the Free Software Foundation.
10///
11///    ILNumerics Community Edition is distributed in the hope that it will be useful,
12///    but WITHOUT ANY WARRANTY; without even the implied warranty of
13///    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14///    GNU General Public License for more details.
15///
16///    You should have received a copy of the GNU General Public License
17///    along with ILNumerics Community Edition. See the file License.txt in the root
18///    of your distribution package. If not, see <http://www.gnu.org/licenses/>.
19///
20///    In addition this software uses the following components and/or licenses:
21///
22///    =================================================================================
23///    The Open Toolkit Library License
24///   
25///    Copyright (c) 2006 - 2009 the Open Toolkit library.
26///   
27///    Permission is hereby granted, free of charge, to any person obtaining a copy
28///    of this software and associated documentation files (the "Software"), to deal
29///    in the Software without restriction, including without limitation the rights to
30///    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
31///    the Software, and to permit persons to whom the Software is furnished to do
32///    so, subject to the following conditions:
33///
34///    The above copyright notice and this permission notice shall be included in all
35///    copies or substantial portions of the Software.
36///
37///    =================================================================================
38///   
39
40using System;
41using ILNumerics;
42using ILNumerics.Misc;
43using ILNumerics.Storage;
44using ILNumerics.Native;
45using ILNumerics.Exceptions;
46
47namespace ILNumerics {
48
49    public abstract partial class ILDenseArray<ElementType> {
50
51        /// <summary>
52        /// Elementwise subtraction operator
53        /// </summary>
54        /// <param name="A">Left side</param>
55        /// <param name="B">Right side</param>
56        /// <returns>Result of subtraction</returns>
57        /// <remarks>The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
58        /// fcomplex, int, long, byte).</remarks>
59        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If the array elements are of an unsupported type</exception>
60        public static ILRetArray<ElementType> operator -(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
61            using (ILScope.Enter(A,B))
62            // TODO: check if (A.GetType() == typeof(ILDenseArray<double>)) is faster due to JIT optimizations
63            if (A is ILDenseArray< double>) {
64                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<double>).C, (B as ILDenseArray<double>).C);
65            } else if (A is  ILDenseArray<float>) {
66                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
67            } else if (A is  ILDenseArray<complex>) {
68                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
69            } else if (A is  ILDenseArray<fcomplex>) {
70                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
71            } else if (A is  ILDenseArray<int>) {
72                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<int>).C, (B as ILDenseArray<int>).C);
73            } else if (A is  ILDenseArray<long>) {
74                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<long>).C, (B as ILDenseArray<long>).C);
75            } else if (A is  ILDenseArray<byte>) {
76                return (ILRetArray<ElementType>)(object)ILMath.subtract((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
77            } else {
78                throw new ILArgumentException("Operator - not defined for arrays of element type '" + typeof(ElementType).Name + "'");
79            }
80        }
81
82        /// <summary>
83        /// Elementwise addition operator
84        /// </summary>
85        /// <param name="A">Left side</param>
86        /// <param name="B">Right side</param>
87        /// <returns>Result of addition</returns>
88        /// <remarks>The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
89        /// fcomplex, int, long, byte).</remarks>
90        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If the array elements are of an unsupported type</exception>
91        public static ILRetArray<ElementType> operator +(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
92            using (ILScope.Enter(A, B))
93                if (A is ILDenseArray< double>) {
94                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<double>).C, (B as ILDenseArray<double>).C);
95            } else if (A is  ILDenseArray<float>) {
96                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
97            } else if (A is  ILDenseArray<complex>) {
98                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
99            } else if (A is  ILDenseArray<fcomplex>) {
100                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
101            } else if (A is  ILDenseArray<int>) {
102                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<int>).C, (B as ILDenseArray<int>).C);
103            } else if (A is  ILDenseArray<long>) {
104                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<long>).C, (B as ILDenseArray<long>).C);
105            } else if (A is  ILDenseArray<byte>) {
106                return (ILRetArray<ElementType>)(object)ILMath.add((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
107            } else {
108                throw new ILArgumentException("Operator + not defined for arrays of element type '" + typeof(ElementType).Name + "'");
109            }
110        }
111
112        /// <summary>
113        /// Elementwise multiplication operator
114        /// </summary>
115        /// <param name="A">Left side</param>
116        /// <param name="B">Right side</param>
117        /// <returns>Result of multiplication</returns>
118        /// <remarks>The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
119        /// fcomplex, int, long, byte).</remarks>
120        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If the array elements are of an unsupported type</exception>
121        public static ILRetArray<ElementType> operator *(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
122            using (ILScope.Enter(A, B))
123                if (A is ILDenseArray< double>) {
124                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<double>).C, (B as ILDenseArray<double>).C);
125            } else if (A is  ILDenseArray<float>) {
126                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
127            } else if (A is  ILDenseArray<complex>) {
128                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
129            } else if (A is  ILDenseArray<fcomplex>) {
130                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
131            } else if (A is  ILDenseArray<int>) {
132                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<int>).C, (B as ILDenseArray<int>).C);
133            } else if (A is  ILDenseArray<long>) {
134                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<long>).C, (B as ILDenseArray<long>).C);
135            } else if (A is  ILDenseArray<byte>) {
136                return (ILRetArray<ElementType>)(object)ILMath.multiplyElem((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
137            } else {
138                throw new ILArgumentException("Operator * not defined for arrays of element type '" + typeof(ElementType).Name + "'");
139            }
140        }
141
142        ///// <summary>
143        ///// Elementwise exponentiation operator   ----------- CAUTION! THE ^ OPERATOR HAS LOWER PRECEEDENCE AS THE *,+,-... OPERATORS!
144        ///// </summary>
145        ///// <param name="A">Bases</param>
146        ///// <param name="B">Exponents</param>
147        ///// <returns>Result of exponentiation of base elements A and exponents in B</returns>
148        ///// <remarks>The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
149        ///// fcomplex, int, long, byte).</remarks>
150        ///// <exception cref="ILNumerics.Exceptions.ILArgumentException">If the array elements are of an unsupported type</exception>
151        //public static ILRetArray<ElementType> operator ^(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
152        //    if (A is ILDenseArray< double >) {
153        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<double>).C, (B as ILDenseArray<double>).C);
154        //    } else if (A is  ILDenseArray<float>) {
155        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
156        //    } else if (A is  ILDenseArray<complex>) {
157        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
158        //    } else if (A is  ILDenseArray<fcomplex>) {
159        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
160        //    } else if (A is  ILDenseArray<int>) {
161        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<int>).C, (B as ILDenseArray<int>).C);
162        //    } else if (A is  ILDenseArray<long>) {
163        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<long>).C, (B as ILDenseArray<long>).C);
164        //    } else if (A is  ILDenseArray<byte>) {
165        //        return (ILRetArray<ElementType>)(object)ILMath.pow((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
166        //    } else  {
167        //        throw new ILArgumentException("Operator * not defined for "+ A.GetType().Name + " and " + B.GetType().Name);
168        //    }
169        //}
170
171        /// <summary>
172        /// Elementwise division operator
173        /// </summary>
174        /// <param name="A">Left side</param>
175        /// <param name="B">Right side</param>
176        /// <returns>Result of division</returns>
177        /// <remarks>The operator is defined for both arrays of the same numeric 'ElementType' (double, float, complex,
178        /// fcomplex, int, long, byte).</remarks>
179        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If the array elements are of an unsupported type</exception>
180        public static ILRetArray<ElementType> operator /(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
181            using (ILScope.Enter(A, B))
182                if (A is ILDenseArray< double>) {
183                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<double>).C, (B as ILDenseArray<double>).C);
184                } else if (A is  ILDenseArray<float>) {
185                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
186                } else if (A is  ILDenseArray<complex>) {
187                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
188                } else if (A is  ILDenseArray<fcomplex>) {
189                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
190                } else if (A is  ILDenseArray<int>) {
191                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<int>).C, (B as ILDenseArray<int>).C);
192                } else if (A is  ILDenseArray<long>) {
193                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<long>).C, (B as ILDenseArray<long>).C);
194                } else if (A is  ILDenseArray<byte>) {
195                    return (ILRetArray<ElementType>)(object)ILMath.divide((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
196                } else {
197                    throw new ILArgumentException("Operator / not defined for arrays of element type '" + typeof(ElementType).Name + "'");
198                }
199        }
200
201        /// <summary>
202        /// Elementwise modulus operator
203        /// </summary>
204        /// <param name="A">Left side</param>
205        /// <param name="B">Right side</param>
206        /// <returns>Result of modulus operation</returns>
207        /// <remarks>The operator is defined for 2 arrays of the same numeric real element types: double, float, int, long, byte.</remarks>
208        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If the array elements are of an unsupported type</exception>
209        public static ILRetArray<ElementType> operator %(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
210            using (ILScope.Enter(A, B))
211                if (A is ILDenseArray< double>) {
212                    return (ILRetArray<ElementType>)(object)ILMath.mod((A as ILDenseArray<double>).C, (B as ILDenseArray<double>).C);
213                } else if (A is  ILDenseArray<float>) {
214                    return (ILRetArray<ElementType>)(object)ILMath.mod((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
215                } else if (A is  ILDenseArray<int>) {
216                    return (ILRetArray<ElementType>)(object)ILMath.mod((A as ILDenseArray<int>).C, (B as ILDenseArray<int>).C);
217                } else if (A is  ILDenseArray<long>) {
218                    return (ILRetArray<ElementType>)(object)ILMath.mod((A as ILDenseArray<long>).C, (B as ILDenseArray<long>).C);
219                } else if (A is  ILDenseArray<byte>) {
220                    return (ILRetArray<ElementType>)(object)ILMath.mod((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
221                } else {
222                    throw new ILArgumentException("Operator % not defined for arrays of element type '" + typeof(ElementType).Name + "'");
223                }
224        }
225
226        /// <summary>
227        /// 'Equalty' operator of two arrays
228        /// </summary>
229        /// <param name="A">Left side</param>
230        /// <param name="B">Right side</param>
231        /// <returns>Logical array of same size than A and B, result of operation along all elements</returns>
232        /// <remarks>Sizes and types of A and B must match.</remarks>
233        public static ILRetLogical operator ==(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
234            using (ILScope.Enter(A, B)) {
235                if (object.Equals(A, null)) {
236                    if (object.Equals(B, null)) {
237                        return true;
238                    } else {
239                        return false;
240                    }
241                } else {
242                    if (object.Equals(B, null)) {
243                        return false;
244                    }
245                }
246                if (false) {
247
248                } else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
249                    return ILMath.eq((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
250
251                    #region HYCALPER AUTO GENERATED CODE
252
253                } else if (A is ILDenseArray<Int64> && B is ILDenseArray<Int64>) {
254                    return ILMath.eq((A as ILDenseArray<Int64>).C, (B as ILDenseArray<Int64>).C);
255                } else if (A is ILDenseArray<Int32> && B is ILDenseArray<Int32>) {
256                    return ILMath.eq((A as ILDenseArray<Int32>).C, (B as ILDenseArray<Int32>).C);
257                } else if (A is ILDenseArray<float> && B is ILDenseArray<float>) {
258                    return ILMath.eq((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
259                } else if (A is ILDenseArray<fcomplex> && B is ILDenseArray<fcomplex>) {
260                    return ILMath.eq((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
261                } else if (A is ILDenseArray<complex> && B is ILDenseArray<complex>) {
262                    return ILMath.eq((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
263                } else if (A is ILDenseArray<byte> && B is ILDenseArray<byte>) {
264                    return ILMath.eq((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
265
266                    #endregion HYCALPER AUTO GENERATED CODE
267                } else if (A is ILDenseArray<String> && B is ILDenseArray<String>) {
268                    return ILMath.eq((A as ILDenseArray<String>).C, (B as ILDenseArray<String>).C);
269                } else {
270                    throw new ILArgumentTypeException("Operator '==' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
271                }
272            }
273        }
274
275        /// <summary>
276        /// 'unequalty' operator of two arrays
277        /// </summary>
278        /// <param name="A">Left side</param>
279        /// <param name="B">Right side</param>
280        /// <returns>Logical array of same size than A and B, result of operation along all elements</returns>
281        /// <remarks>Sizes and types of A and B must match.</remarks>
282        public static ILRetLogical operator !=(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
283            using (ILScope.Enter(A, B)) {
284                if (object.Equals(A, null)) {
285                    if (object.Equals(B, null)) {
286                        return false;
287                    } else {
288                        return true;
289                    }
290                } else {
291                    if (object.Equals(B, null)) {
292                        return true;
293                    }
294                }
295                if (false) {
296
297                } else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
298                    return ILMath.neq((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
299
300                    #region HYCALPER AUTO GENERATED CODE
301
302                } else if (A is ILDenseArray<Int64> && B is ILDenseArray<Int64>) {
303                    return ILMath.neq((A as ILDenseArray<Int64>).C, (B as ILDenseArray<Int64>).C);
304                } else if (A is ILDenseArray<Int32> && B is ILDenseArray<Int32>) {
305                    return ILMath.neq((A as ILDenseArray<Int32>).C, (B as ILDenseArray<Int32>).C);
306                } else if (A is ILDenseArray<float> && B is ILDenseArray<float>) {
307                    return ILMath.neq((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
308                } else if (A is ILDenseArray<fcomplex> && B is ILDenseArray<fcomplex>) {
309                    return ILMath.neq((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
310                } else if (A is ILDenseArray<complex> && B is ILDenseArray<complex>) {
311                    return ILMath.neq((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
312                } else if (A is ILDenseArray<byte> && B is ILDenseArray<byte>) {
313                    return ILMath.neq((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
314
315                    #endregion HYCALPER AUTO GENERATED CODE
316                } else if (A is ILDenseArray<String> && B is ILDenseArray<String>) {
317                    return ILMath.neq((A as ILDenseArray<String>).C, (B as ILDenseArray<String>).C);
318                } else {
319                    throw new ILArgumentTypeException("Operator '!=' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
320                }
321            }
322        }
323
324        /// <summary>
325        /// 'greater or equal' operator of two arrays
326        /// </summary>
327        /// <param name="A">Left side</param>
328        /// <param name="B">Right side</param>
329        /// <returns>Logical array of same size than A and B, result of operation along all elements</returns>
330        /// <remarks>Sizes and types of A and B must match.</remarks>
331        public static ILRetLogical operator >=(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
332            using (ILScope.Enter(A, B)) {
333                if (false) {
334
335                } else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
336                    return ILMath.ge((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
337
338                    #region HYCALPER AUTO GENERATED CODE
339
340                } else if (A is ILDenseArray<Int64> && B is ILDenseArray<Int64>) {
341                    return ILMath.ge((A as ILDenseArray<Int64>).C, (B as ILDenseArray<Int64>).C);
342                } else if (A is ILDenseArray<Int32> && B is ILDenseArray<Int32>) {
343                    return ILMath.ge((A as ILDenseArray<Int32>).C, (B as ILDenseArray<Int32>).C);
344                } else if (A is ILDenseArray<float> && B is ILDenseArray<float>) {
345                    return ILMath.ge((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
346                } else if (A is ILDenseArray<fcomplex> && B is ILDenseArray<fcomplex>) {
347                    return ILMath.ge((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
348                } else if (A is ILDenseArray<complex> && B is ILDenseArray<complex>) {
349                    return ILMath.ge((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
350                } else if (A is ILDenseArray<byte> && B is ILDenseArray<byte>) {
351                    return ILMath.ge((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
352
353                    #endregion HYCALPER AUTO GENERATED CODE
354                } else {
355                    throw new ILArgumentTypeException("Operator '>=' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
356                }
357            }
358        }
359
360        /// <summary>
361        /// 'smaller or equal' operator of two arrays
362        /// </summary>
363        /// <param name="A">Left side</param>
364        /// <param name="B">Right side</param>
365        /// <returns>Logical array of same size than A and B, result of operation along all elements</returns>
366        /// <remarks>Sizes and types of A and B must match.</remarks>
367        public static ILRetLogical operator <=(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
368            using (ILScope.Enter(A, B)) {
369                if (false) {
370
371                } else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
372                    return ILMath.le((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
373
374                    #region HYCALPER AUTO GENERATED CODE
375
376                } else if (A is ILDenseArray<Int64> && B is ILDenseArray<Int64>) {
377                    return ILMath.le((A as ILDenseArray<Int64>).C, (B as ILDenseArray<Int64>).C);
378                } else if (A is ILDenseArray<Int32> && B is ILDenseArray<Int32>) {
379                    return ILMath.le((A as ILDenseArray<Int32>).C, (B as ILDenseArray<Int32>).C);
380                } else if (A is ILDenseArray<float> && B is ILDenseArray<float>) {
381                    return ILMath.le((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
382                } else if (A is ILDenseArray<fcomplex> && B is ILDenseArray<fcomplex>) {
383                    return ILMath.le((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
384                } else if (A is ILDenseArray<complex> && B is ILDenseArray<complex>) {
385                    return ILMath.le((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
386                } else if (A is ILDenseArray<byte> && B is ILDenseArray<byte>) {
387                    return ILMath.le((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
388
389                    #endregion HYCALPER AUTO GENERATED CODE
390                } else {
391                    throw new ILArgumentTypeException("Operator '<=' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
392                }
393            }
394        }
395
396        /// <summary>
397        /// 'greater' operator of two arrays
398        /// </summary>
399        /// <param name="A">Left side</param>
400        /// <param name="B">Right side</param>
401        /// <returns>Logical array of same size than A and B, result of operation along all elements</returns>
402        /// <remarks>Dimension and types of A and B must match.</remarks>
403        public static ILRetLogical operator >(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
404            using (ILScope.Enter(A, B)) {
405                if (false) {
406
407                } else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
408                    return ILMath.gt((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
409
410                    #region HYCALPER AUTO GENERATED CODE
411
412                } else if (A is ILDenseArray<Int64> && B is ILDenseArray<Int64>) {
413                    return ILMath.gt((A as ILDenseArray<Int64>).C, (B as ILDenseArray<Int64>).C);
414                } else if (A is ILDenseArray<Int32> && B is ILDenseArray<Int32>) {
415                    return ILMath.gt((A as ILDenseArray<Int32>).C, (B as ILDenseArray<Int32>).C);
416                } else if (A is ILDenseArray<float> && B is ILDenseArray<float>) {
417                    return ILMath.gt((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
418                } else if (A is ILDenseArray<fcomplex> && B is ILDenseArray<fcomplex>) {
419                    return ILMath.gt((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
420                } else if (A is ILDenseArray<complex> && B is ILDenseArray<complex>) {
421                    return ILMath.gt((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
422                } else if (A is ILDenseArray<byte> && B is ILDenseArray<byte>) {
423                    return ILMath.gt((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
424
425                    #endregion HYCALPER AUTO GENERATED CODE
426                } else {
427                    throw new ILArgumentTypeException("Operator '>' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
428                }
429            }
430        }
431        /// <summary>
432        /// 'smaller' operator of two arrays
433        /// </summary>
434        /// <param name="A">Left side</param>
435        /// <param name="B">Right side</param>
436        /// <returns>Logical array of same size than A and B, result of operation along all elements</returns>
437        /// <remarks>Dimension and types of A and B must match.</remarks>
438        public static ILRetLogical operator <(ILDenseArray<ElementType> A, ILDenseArray<ElementType> B) {
439            using (ILScope.Enter(A, B)) {
440                if (false) {
441
442                } else if (A is ILDenseArray< double> && B is ILDenseArray< double>) {
443                    return ILMath.lt((A as ILDenseArray< double>).C, (B as ILDenseArray< double>).C);
444
445                    #region HYCALPER AUTO GENERATED CODE
446
447                } else if (A is ILDenseArray<Int64> && B is ILDenseArray<Int64>) {
448                    return ILMath.lt((A as ILDenseArray<Int64>).C, (B as ILDenseArray<Int64>).C);
449                } else if (A is ILDenseArray<Int32> && B is ILDenseArray<Int32>) {
450                    return ILMath.lt((A as ILDenseArray<Int32>).C, (B as ILDenseArray<Int32>).C);
451                } else if (A is ILDenseArray<float> && B is ILDenseArray<float>) {
452                    return ILMath.lt((A as ILDenseArray<float>).C, (B as ILDenseArray<float>).C);
453                } else if (A is ILDenseArray<fcomplex> && B is ILDenseArray<fcomplex>) {
454                    return ILMath.lt((A as ILDenseArray<fcomplex>).C, (B as ILDenseArray<fcomplex>).C);
455                } else if (A is ILDenseArray<complex> && B is ILDenseArray<complex>) {
456                    return ILMath.lt((A as ILDenseArray<complex>).C, (B as ILDenseArray<complex>).C);
457                } else if (A is ILDenseArray<byte> && B is ILDenseArray<byte>) {
458                    return ILMath.lt((A as ILDenseArray<byte>).C, (B as ILDenseArray<byte>).C);
459
460                    #endregion HYCALPER AUTO GENERATED CODE
461                } else {
462                    throw new ILArgumentTypeException("Operator '<' not defined for arrays of element type '" + typeof(ElementType).Name + "'");
463                }
464            }
465        }
466
467        /// <summary>
468        /// Explicitly convert scalar array to System.Value type (ElementType)
469        /// </summary>
470        /// <param name="val">Array of arbitrary type and size of 1x1</param>
471        /// <returns>Single value of type ElementType and of scalar size (1x1)</returns>
472        /// <exception cref="ILNumerics.Exceptions.ILCastException">If input array is not scalar</exception>
473        /// <exception cref="System.NullReferenceException">If val is null</exception>
474        public static explicit operator ElementType(ILDenseArray<ElementType> val) {
475            using (ILScope.Enter(val)) {
476                if (!val.IsScalar)
477                    throw new ILCastException("unable to convert array to scalar");
478                return val.GetValue(0);
479            }
480        }
481
482        /// <summary>
483        /// Implicitly convert scalar to array of size 1x1 (scalar).
484        /// </summary>
485        /// <param name="val">Single element of ElementType type</param>
486        /// <returns>New array of type ILRetArray<![CDATA[<ElementType>]]> of size 1x1
487        /// holding the only element with value of val.
488        /// </returns>
489        public static implicit operator ILDenseArray<ElementType>(ElementType val) {
490            ILArray<ElementType> ret = new ILArray<ElementType>(new ILDenseStorage<ElementType>(ILSize.Scalar1_1));
491            ret.SetValue(val, 0, 0);
492            return ret.C;
493        }
494
495        /// <summary>
496        /// Negate elements of array - if applicable
497        /// </summary>
498        /// <param name="A">Input array</param>
499        /// <returns>New solid arrray having the elements of A negated</returns>
500        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If elements of the array are not of
501        /// any supported numeric type</exception>
502        public static ILRetArray<ElementType> operator -(ILDenseArray<ElementType> A) {
503            using (ILScope.Enter(A)) {
504                ILArray<ElementType> ret = ILMath.empty<ElementType>();
505                if (A is ILDenseArray<double>) {
506                    ILMath.invert((A as ILDenseArray<double>).C, (ret as ILArray<double>));
507                } else if (A is ILDenseArray<float>) {
508                    ILMath.invert((A as ILDenseArray<float>).C, (ret as ILArray<float>));
509                } else if (A is ILDenseArray<complex>) {
510                    ILMath.invert((A as ILDenseArray<complex>).C, (ret as ILArray<complex>));
511                } else if (A is ILDenseArray<fcomplex>) {
512                    ILMath.invert((A as ILDenseArray<fcomplex>).C, (ret as ILArray<fcomplex>));
513                } else if (A is ILDenseArray<Int32>) {
514                    ILMath.invert((A as ILDenseArray<Int32>).C, (ret as ILArray<Int32>));
515                } else if (A is ILDenseArray<Int64>) {
516                    ILMath.invert((A as ILDenseArray<Int64>).C, (ret as ILArray<Int64>));
517                } else if (A is ILDenseArray<byte>) {
518                    ILMath.invert((A as ILDenseArray<byte>).C, (ret as ILArray<byte>));
519                } else {
520                    throw new ILArgumentException("unary - operator not defined for arrays of element type '" + typeof(ElementType).Name + "'");
521                }
522                return ret.C;
523            }
524        }
525
526    }
527}
Note: See TracBrowser for help on using the repository browser.