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 |
|
---|
40 | using System;
|
---|
41 | using System.Collections.Generic;
|
---|
42 | using System.Text;
|
---|
43 | using ILNumerics.Storage;
|
---|
44 | using ILNumerics.Misc;
|
---|
45 | using ILNumerics.Exceptions;
|
---|
46 |
|
---|
47 | namespace ILNumerics {
|
---|
48 |
|
---|
49 | public partial class ILMath {
|
---|
50 |
|
---|
51 | |
---|
52 | /// <summary>
|
---|
53 | /// Sum all elements of array A
|
---|
54 | /// </summary>
|
---|
55 | /// <param name="A">Input array</param>
|
---|
56 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
57 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
58 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
59 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
60 | public static ILRetArray<double> sumall( ILInArray<double> A ) {
|
---|
61 | if (object.Equals(A, null))
|
---|
62 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
63 | using (ILScope.Enter(A)) {
|
---|
64 | if (A.IsEmpty) {
|
---|
65 | return empty<double>(ILSize.Empty00);
|
---|
66 | }
|
---|
67 |
|
---|
68 | double retArr = 0;
|
---|
69 | unsafe {
|
---|
70 | fixed ( double* inArrStart = A.GetArrayForRead()) {
|
---|
71 |
|
---|
72 | double* inArrWalk = inArrStart;
|
---|
73 |
|
---|
74 | double* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
75 | while (inArrWalk < inArrEnd) {
|
---|
76 | retArr += *inArrWalk++;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | }
|
---|
80 | return array<double>(retArr, 1, 1);
|
---|
81 | }
|
---|
82 | }
|
---|
83 | |
---|
84 | #region HYCALPER AUTO GENERATED CODE
|
---|
85 | |
---|
86 | /// <summary>
|
---|
87 | /// Sum all elements of array A
|
---|
88 | /// </summary>
|
---|
89 | /// <param name="A">Input array</param>
|
---|
90 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
91 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
92 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
93 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
94 | public static ILRetArray<Int64> sumall( ILInArray<Int64> A ) {
|
---|
95 | if (object.Equals(A, null))
|
---|
96 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
97 | using (ILScope.Enter(A)) {
|
---|
98 | if (A.IsEmpty) {
|
---|
99 | return empty<Int64>(ILSize.Empty00);
|
---|
100 | }
|
---|
101 |
|
---|
102 | Int64 retArr = 0;
|
---|
103 | unsafe {
|
---|
104 | fixed ( Int64* inArrStart = A.GetArrayForRead()) {
|
---|
105 |
|
---|
106 | Int64* inArrWalk = inArrStart;
|
---|
107 |
|
---|
108 | Int64* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
109 | while (inArrWalk < inArrEnd) {
|
---|
110 | retArr += *inArrWalk++;
|
---|
111 | }
|
---|
112 | }
|
---|
113 | }
|
---|
114 | return array<Int64>(retArr, 1, 1);
|
---|
115 | }
|
---|
116 | }
|
---|
117 | /// <summary>
|
---|
118 | /// Sum all elements of array A
|
---|
119 | /// </summary>
|
---|
120 | /// <param name="A">Input array</param>
|
---|
121 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
122 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
123 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
124 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
125 | public static ILRetArray<Int32> sumall( ILInArray<Int32> A ) {
|
---|
126 | if (object.Equals(A, null))
|
---|
127 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
128 | using (ILScope.Enter(A)) {
|
---|
129 | if (A.IsEmpty) {
|
---|
130 | return empty<Int32>(ILSize.Empty00);
|
---|
131 | }
|
---|
132 |
|
---|
133 | Int32 retArr = 0;
|
---|
134 | unsafe {
|
---|
135 | fixed ( Int32* inArrStart = A.GetArrayForRead()) {
|
---|
136 |
|
---|
137 | Int32* inArrWalk = inArrStart;
|
---|
138 |
|
---|
139 | Int32* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
140 | while (inArrWalk < inArrEnd) {
|
---|
141 | retArr += *inArrWalk++;
|
---|
142 | }
|
---|
143 | }
|
---|
144 | }
|
---|
145 | return array<Int32>(retArr, 1, 1);
|
---|
146 | }
|
---|
147 | }
|
---|
148 | /// <summary>
|
---|
149 | /// Sum all elements of array A
|
---|
150 | /// </summary>
|
---|
151 | /// <param name="A">Input array</param>
|
---|
152 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
153 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
154 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
155 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
156 | public static ILRetArray<byte> sumall( ILInArray<byte> A ) {
|
---|
157 | if (object.Equals(A, null))
|
---|
158 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
159 | using (ILScope.Enter(A)) {
|
---|
160 | if (A.IsEmpty) {
|
---|
161 | return empty<byte>(ILSize.Empty00);
|
---|
162 | }
|
---|
163 |
|
---|
164 | byte retArr = 0;
|
---|
165 | unsafe {
|
---|
166 | fixed ( byte* inArrStart = A.GetArrayForRead()) {
|
---|
167 |
|
---|
168 | byte* inArrWalk = inArrStart;
|
---|
169 |
|
---|
170 | byte* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
171 | while (inArrWalk < inArrEnd) {
|
---|
172 | retArr += *inArrWalk++;
|
---|
173 | }
|
---|
174 | }
|
---|
175 | }
|
---|
176 | return array<byte>(retArr, 1, 1);
|
---|
177 | }
|
---|
178 | }
|
---|
179 | /// <summary>
|
---|
180 | /// Sum all elements of array A
|
---|
181 | /// </summary>
|
---|
182 | /// <param name="A">Input array</param>
|
---|
183 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
184 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
185 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
186 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
187 | public static ILRetArray<fcomplex> sumall( ILInArray<fcomplex> A ) {
|
---|
188 | if (object.Equals(A, null))
|
---|
189 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
190 | using (ILScope.Enter(A)) {
|
---|
191 | if (A.IsEmpty) {
|
---|
192 | return empty<fcomplex>(ILSize.Empty00);
|
---|
193 | }
|
---|
194 |
|
---|
195 | fcomplex retArr = new fcomplex(0.0f,0.0f);
|
---|
196 | unsafe {
|
---|
197 | fixed ( fcomplex* inArrStart = A.GetArrayForRead()) {
|
---|
198 |
|
---|
199 | fcomplex* inArrWalk = inArrStart;
|
---|
200 |
|
---|
201 | fcomplex* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
202 | while (inArrWalk < inArrEnd) {
|
---|
203 | retArr += *inArrWalk++;
|
---|
204 | }
|
---|
205 | }
|
---|
206 | }
|
---|
207 | return array<fcomplex>(retArr, 1, 1);
|
---|
208 | }
|
---|
209 | }
|
---|
210 | /// <summary>
|
---|
211 | /// Sum all elements of array A
|
---|
212 | /// </summary>
|
---|
213 | /// <param name="A">Input array</param>
|
---|
214 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
215 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
216 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
217 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
218 | public static ILRetArray<float> sumall( ILInArray<float> A ) {
|
---|
219 | if (object.Equals(A, null))
|
---|
220 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
221 | using (ILScope.Enter(A)) {
|
---|
222 | if (A.IsEmpty) {
|
---|
223 | return empty<float>(ILSize.Empty00);
|
---|
224 | }
|
---|
225 |
|
---|
226 | float retArr = 0.0f;
|
---|
227 | unsafe {
|
---|
228 | fixed ( float* inArrStart = A.GetArrayForRead()) {
|
---|
229 |
|
---|
230 | float* inArrWalk = inArrStart;
|
---|
231 |
|
---|
232 | float* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
233 | while (inArrWalk < inArrEnd) {
|
---|
234 | retArr += *inArrWalk++;
|
---|
235 | }
|
---|
236 | }
|
---|
237 | }
|
---|
238 | return array<float>(retArr, 1, 1);
|
---|
239 | }
|
---|
240 | }
|
---|
241 | /// <summary>
|
---|
242 | /// Sum all elements of array A
|
---|
243 | /// </summary>
|
---|
244 | /// <param name="A">Input array</param>
|
---|
245 | /// <returns><para>Scalar sum of all elements of A.</para>
|
---|
246 | /// <para>If A is empty, an empty array will be returned.</para></returns>
|
---|
247 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">If A was null.</exception>
|
---|
248 | /// <seealso cref="ILNumerics.ILMath.sum(ILInArray<double>,int)"/>
|
---|
249 | public static ILRetArray<complex> sumall( ILInArray<complex> A ) {
|
---|
250 | if (object.Equals(A, null))
|
---|
251 | throw new ILArgumentException("sumall: argument must not be null!");
|
---|
252 | using (ILScope.Enter(A)) {
|
---|
253 | if (A.IsEmpty) {
|
---|
254 | return empty<complex>(ILSize.Empty00);
|
---|
255 | }
|
---|
256 |
|
---|
257 | complex retArr = new complex(0.0,0.0);
|
---|
258 | unsafe {
|
---|
259 | fixed ( complex* inArrStart = A.GetArrayForRead()) {
|
---|
260 |
|
---|
261 | complex* inArrWalk = inArrStart;
|
---|
262 |
|
---|
263 | complex* inArrEnd = inArrStart + A.Size.NumberOfElements;
|
---|
264 | while (inArrWalk < inArrEnd) {
|
---|
265 | retArr += *inArrWalk++;
|
---|
266 | }
|
---|
267 | }
|
---|
268 | }
|
---|
269 | return array<complex>(retArr, 1, 1);
|
---|
270 | }
|
---|
271 | }
|
---|
272 |
|
---|
273 | #endregion HYCALPER AUTO GENERATED CODE
|
---|
274 |
|
---|
275 | }
|
---|
276 | }
|
---|