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;
|
---|
44 | using ILNumerics.Exceptions;
|
---|
45 | using ILNumerics.Storage;
|
---|
46 | using ILNumerics.Misc;
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 | namespace ILNumerics {
|
---|
51 | public partial class ILMath {
|
---|
52 |
|
---|
53 | |
---|
54 |
|
---|
55 | |
---|
56 | #region HYCALPER AUTO GENERATED CODE
|
---|
57 | |
---|
58 | /// <summary>Logarithm of array elements - complex output</summary>
|
---|
59 | /// <param name="A">Input array</param>
|
---|
60 | /// <returns>Complex logarithm of array elements</returns>
|
---|
61 | /// <remarks><para>If the input array is empty, an empty array will be returned.</para>
|
---|
62 | /// <para>The array returned will be a dense array.</para></remarks>
|
---|
63 | public unsafe static ILRetArray<fcomplex> logc (ILInArray< float > A) {
|
---|
64 | using (ILScope.Enter(A)) {
|
---|
65 | if (A.IsEmpty)
|
---|
66 | return new ILRetArray<fcomplex>(A.Size);
|
---|
67 | ILSize inDim = A.Size;
|
---|
68 | float[] arrA = A.GetArrayForRead();
|
---|
69 | fcomplex [] retArr;
|
---|
70 | int outLen = inDim.NumberOfElements;
|
---|
71 | bool inplace = true;
|
---|
72 |
|
---|
73 | if (true) {
|
---|
74 | retArr = ILMemoryPool.Pool.New<fcomplex>(outLen);
|
---|
75 | inplace = false;
|
---|
76 | }
|
---|
77 | int i = 0, workItemCount = Settings.s_maxNumberThreads, workItemLength, workerCount = 1;
|
---|
78 | if (Settings.s_maxNumberThreads > 1 && outLen / 2 > Settings.s_minParallelElement1Count) {
|
---|
79 | if (outLen / workItemCount > Settings.s_minParallelElement1Count) {
|
---|
80 | workItemLength = outLen / workItemCount;
|
---|
81 | //workItemLength = (int)((double)outLen / workItemCount * 1.05);
|
---|
82 | } else {
|
---|
83 | workItemLength = outLen / 2;
|
---|
84 | workItemCount = 2;
|
---|
85 | }
|
---|
86 | } else {
|
---|
87 | workItemLength = outLen;
|
---|
88 | workItemCount = 1;
|
---|
89 | }
|
---|
90 | ILDenseStorage<fcomplex> retStorage = new ILDenseStorage<fcomplex>(retArr, inDim);
|
---|
91 |
|
---|
92 | Action<object> worker = data => {
|
---|
93 | Tuple<int, int, IntPtr, IntPtr, bool> range = (Tuple<int, int, IntPtr, IntPtr, bool>)data;
|
---|
94 |
|
---|
95 | fcomplex* cp = ((fcomplex*)range.Item4 + range.Item1);
|
---|
96 | int len = range.Item2;
|
---|
97 | if (range.Item5) {
|
---|
98 | // inplace
|
---|
99 | while (len > 20) {
|
---|
100 | cp[0] = fcomplex.Log(cp[0] ) /*dummy*/;
|
---|
101 | cp[1] = fcomplex.Log(cp[1] ) /*dummy*/;
|
---|
102 | cp[2] = fcomplex.Log(cp[2] ) /*dummy*/;
|
---|
103 | cp[3] = fcomplex.Log(cp[3] ) /*dummy*/;
|
---|
104 | cp[4] = fcomplex.Log(cp[4] ) /*dummy*/;
|
---|
105 | cp[5] = fcomplex.Log(cp[5] ) /*dummy*/;
|
---|
106 | cp[6] = fcomplex.Log(cp[6] ) /*dummy*/;
|
---|
107 | cp[7] = fcomplex.Log(cp[7] ) /*dummy*/;
|
---|
108 | cp[8] = fcomplex.Log(cp[8] ) /*dummy*/;
|
---|
109 | cp[9] = fcomplex.Log(cp[9] ) /*dummy*/;
|
---|
110 | cp[10] = fcomplex.Log(cp[10] ) /*dummy*/;
|
---|
111 | cp[11] = fcomplex.Log(cp[11] ) /*dummy*/;
|
---|
112 | cp[12] = fcomplex.Log(cp[12] ) /*dummy*/;
|
---|
113 | cp[13] = fcomplex.Log(cp[13] ) /*dummy*/;
|
---|
114 | cp[14] = fcomplex.Log(cp[14] ) /*dummy*/;
|
---|
115 | cp[15] = fcomplex.Log(cp[15] ) /*dummy*/;
|
---|
116 | cp[16] = fcomplex.Log(cp[16] ) /*dummy*/;
|
---|
117 | cp[17] = fcomplex.Log(cp[17] ) /*dummy*/;
|
---|
118 | cp[18] = fcomplex.Log(cp[18] ) /*dummy*/;
|
---|
119 | cp[19] = fcomplex.Log(cp[19] ) /*dummy*/;
|
---|
120 | cp[20] = fcomplex.Log(cp[20] ) /*dummy*/;
|
---|
121 | cp+=21; len -= 21;
|
---|
122 | }
|
---|
123 | while (len-- > 0) {
|
---|
124 | *cp = fcomplex.Log(*cp ) /*dummy*/;
|
---|
125 | cp++;
|
---|
126 | }
|
---|
127 | } else {
|
---|
128 | float* ap = ((float*)range.Item3 + range.Item1);
|
---|
129 | while (len > 20) {
|
---|
130 | cp[0] = fcomplex.Log(ap[0] ) /*dummy*/;
|
---|
131 | cp[1] = fcomplex.Log(ap[1] ) /*dummy*/;
|
---|
132 | cp[2] = fcomplex.Log(ap[2] ) /*dummy*/;
|
---|
133 | cp[3] = fcomplex.Log(ap[3] ) /*dummy*/;
|
---|
134 | cp[4] = fcomplex.Log(ap[4] ) /*dummy*/;
|
---|
135 | cp[5] = fcomplex.Log(ap[5] ) /*dummy*/;
|
---|
136 | cp[6] = fcomplex.Log(ap[6] ) /*dummy*/;
|
---|
137 | cp[7] = fcomplex.Log(ap[7] ) /*dummy*/;
|
---|
138 | cp[8] = fcomplex.Log(ap[8] ) /*dummy*/;
|
---|
139 | cp[9] = fcomplex.Log(ap[9] ) /*dummy*/;
|
---|
140 | cp[10] = fcomplex.Log(ap[10] ) /*dummy*/;
|
---|
141 | cp[11] = fcomplex.Log(ap[11] ) /*dummy*/;
|
---|
142 | cp[12] = fcomplex.Log(ap[12] ) /*dummy*/;
|
---|
143 | cp[13] = fcomplex.Log(ap[13] ) /*dummy*/;
|
---|
144 | cp[14] = fcomplex.Log(ap[14] ) /*dummy*/;
|
---|
145 | cp[15] = fcomplex.Log(ap[15] ) /*dummy*/;
|
---|
146 | cp[16] = fcomplex.Log(ap[16] ) /*dummy*/;
|
---|
147 | cp[17] = fcomplex.Log(ap[17] ) /*dummy*/;
|
---|
148 | cp[18] = fcomplex.Log(ap[18] ) /*dummy*/;
|
---|
149 | cp[19] = fcomplex.Log(ap[19] ) /*dummy*/;
|
---|
150 | cp[20] = fcomplex.Log(ap[20] ) /*dummy*/;
|
---|
151 | ap += 21;
|
---|
152 | cp += 21;
|
---|
153 | len -= 21;
|
---|
154 | }
|
---|
155 | while (len-- > 0) {
|
---|
156 | *cp = fcomplex.Log(*ap ) /*dummy*/;
|
---|
157 | ap++;
|
---|
158 | cp++;
|
---|
159 | }
|
---|
160 | }
|
---|
161 | System.Threading.Interlocked.Decrement(ref workerCount);
|
---|
162 | };
|
---|
163 |
|
---|
164 | fixed ( float* arrAP = arrA)
|
---|
165 | fixed ( fcomplex* retArrP = retArr) {
|
---|
166 | for (; i < workItemCount - 1; i++) {
|
---|
167 | Tuple<int, int, IntPtr, IntPtr, bool> range
|
---|
168 | = new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
169 | (i * workItemLength, workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace);
|
---|
170 | System.Threading.Interlocked.Increment(ref workerCount);
|
---|
171 | ILThreadPool.QueueUserWorkItem(i,worker, range);
|
---|
172 | }
|
---|
173 | // the last (or may the only) chunk is done right here
|
---|
174 | worker(new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
175 | (i * workItemLength, outLen - i * workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace));
|
---|
176 |
|
---|
177 | ILThreadPool.Wait4Workers(ref workerCount);
|
---|
178 | }
|
---|
179 | return new ILRetArray<fcomplex>(retStorage);
|
---|
180 | }
|
---|
181 | }
|
---|
182 | /// <summary>Logarithm of array elements - complex output</summary>
|
---|
183 | /// <param name="A">Input array</param>
|
---|
184 | /// <returns>Complex logarithm of array elements</returns>
|
---|
185 | /// <remarks><para>If the input array is empty, an empty array will be returned.</para>
|
---|
186 | /// <para>The array returned will be a dense array.</para></remarks>
|
---|
187 | public unsafe static ILRetArray<complex> logc (ILInArray< double > A) {
|
---|
188 | using (ILScope.Enter(A)) {
|
---|
189 | if (A.IsEmpty)
|
---|
190 | return new ILRetArray<complex>(A.Size);
|
---|
191 | ILSize inDim = A.Size;
|
---|
192 | double[] arrA = A.GetArrayForRead();
|
---|
193 | complex [] retArr;
|
---|
194 | int outLen = inDim.NumberOfElements;
|
---|
195 | bool inplace = true;
|
---|
196 |
|
---|
197 | if (true) {
|
---|
198 | retArr = ILMemoryPool.Pool.New<complex>(outLen);
|
---|
199 | inplace = false;
|
---|
200 | }
|
---|
201 | int i = 0, workItemCount = Settings.s_maxNumberThreads, workItemLength, workerCount = 1;
|
---|
202 | if (Settings.s_maxNumberThreads > 1 && outLen / 2 > Settings.s_minParallelElement1Count) {
|
---|
203 | if (outLen / workItemCount > Settings.s_minParallelElement1Count) {
|
---|
204 | workItemLength = outLen / workItemCount;
|
---|
205 | //workItemLength = (int)((double)outLen / workItemCount * 1.05);
|
---|
206 | } else {
|
---|
207 | workItemLength = outLen / 2;
|
---|
208 | workItemCount = 2;
|
---|
209 | }
|
---|
210 | } else {
|
---|
211 | workItemLength = outLen;
|
---|
212 | workItemCount = 1;
|
---|
213 | }
|
---|
214 | ILDenseStorage<complex> retStorage = new ILDenseStorage<complex>(retArr, inDim);
|
---|
215 |
|
---|
216 | Action<object> worker = data => {
|
---|
217 | Tuple<int, int, IntPtr, IntPtr, bool> range = (Tuple<int, int, IntPtr, IntPtr, bool>)data;
|
---|
218 |
|
---|
219 | complex* cp = ((complex*)range.Item4 + range.Item1);
|
---|
220 | int len = range.Item2;
|
---|
221 | if (range.Item5) {
|
---|
222 | // inplace
|
---|
223 | while (len > 20) {
|
---|
224 | cp[0] = complex.Log(cp[0] ) /*dummy*/;
|
---|
225 | cp[1] = complex.Log(cp[1] ) /*dummy*/;
|
---|
226 | cp[2] = complex.Log(cp[2] ) /*dummy*/;
|
---|
227 | cp[3] = complex.Log(cp[3] ) /*dummy*/;
|
---|
228 | cp[4] = complex.Log(cp[4] ) /*dummy*/;
|
---|
229 | cp[5] = complex.Log(cp[5] ) /*dummy*/;
|
---|
230 | cp[6] = complex.Log(cp[6] ) /*dummy*/;
|
---|
231 | cp[7] = complex.Log(cp[7] ) /*dummy*/;
|
---|
232 | cp[8] = complex.Log(cp[8] ) /*dummy*/;
|
---|
233 | cp[9] = complex.Log(cp[9] ) /*dummy*/;
|
---|
234 | cp[10] = complex.Log(cp[10] ) /*dummy*/;
|
---|
235 | cp[11] = complex.Log(cp[11] ) /*dummy*/;
|
---|
236 | cp[12] = complex.Log(cp[12] ) /*dummy*/;
|
---|
237 | cp[13] = complex.Log(cp[13] ) /*dummy*/;
|
---|
238 | cp[14] = complex.Log(cp[14] ) /*dummy*/;
|
---|
239 | cp[15] = complex.Log(cp[15] ) /*dummy*/;
|
---|
240 | cp[16] = complex.Log(cp[16] ) /*dummy*/;
|
---|
241 | cp[17] = complex.Log(cp[17] ) /*dummy*/;
|
---|
242 | cp[18] = complex.Log(cp[18] ) /*dummy*/;
|
---|
243 | cp[19] = complex.Log(cp[19] ) /*dummy*/;
|
---|
244 | cp[20] = complex.Log(cp[20] ) /*dummy*/;
|
---|
245 | cp+=21; len -= 21;
|
---|
246 | }
|
---|
247 | while (len-- > 0) {
|
---|
248 | *cp = complex.Log(*cp ) /*dummy*/;
|
---|
249 | cp++;
|
---|
250 | }
|
---|
251 | } else {
|
---|
252 | double* ap = ((double*)range.Item3 + range.Item1);
|
---|
253 | while (len > 20) {
|
---|
254 | cp[0] = complex.Log(ap[0] ) /*dummy*/;
|
---|
255 | cp[1] = complex.Log(ap[1] ) /*dummy*/;
|
---|
256 | cp[2] = complex.Log(ap[2] ) /*dummy*/;
|
---|
257 | cp[3] = complex.Log(ap[3] ) /*dummy*/;
|
---|
258 | cp[4] = complex.Log(ap[4] ) /*dummy*/;
|
---|
259 | cp[5] = complex.Log(ap[5] ) /*dummy*/;
|
---|
260 | cp[6] = complex.Log(ap[6] ) /*dummy*/;
|
---|
261 | cp[7] = complex.Log(ap[7] ) /*dummy*/;
|
---|
262 | cp[8] = complex.Log(ap[8] ) /*dummy*/;
|
---|
263 | cp[9] = complex.Log(ap[9] ) /*dummy*/;
|
---|
264 | cp[10] = complex.Log(ap[10] ) /*dummy*/;
|
---|
265 | cp[11] = complex.Log(ap[11] ) /*dummy*/;
|
---|
266 | cp[12] = complex.Log(ap[12] ) /*dummy*/;
|
---|
267 | cp[13] = complex.Log(ap[13] ) /*dummy*/;
|
---|
268 | cp[14] = complex.Log(ap[14] ) /*dummy*/;
|
---|
269 | cp[15] = complex.Log(ap[15] ) /*dummy*/;
|
---|
270 | cp[16] = complex.Log(ap[16] ) /*dummy*/;
|
---|
271 | cp[17] = complex.Log(ap[17] ) /*dummy*/;
|
---|
272 | cp[18] = complex.Log(ap[18] ) /*dummy*/;
|
---|
273 | cp[19] = complex.Log(ap[19] ) /*dummy*/;
|
---|
274 | cp[20] = complex.Log(ap[20] ) /*dummy*/;
|
---|
275 | ap += 21;
|
---|
276 | cp += 21;
|
---|
277 | len -= 21;
|
---|
278 | }
|
---|
279 | while (len-- > 0) {
|
---|
280 | *cp = complex.Log(*ap ) /*dummy*/;
|
---|
281 | ap++;
|
---|
282 | cp++;
|
---|
283 | }
|
---|
284 | }
|
---|
285 | System.Threading.Interlocked.Decrement(ref workerCount);
|
---|
286 | };
|
---|
287 |
|
---|
288 | fixed ( double* arrAP = arrA)
|
---|
289 | fixed ( complex* retArrP = retArr) {
|
---|
290 | for (; i < workItemCount - 1; i++) {
|
---|
291 | Tuple<int, int, IntPtr, IntPtr, bool> range
|
---|
292 | = new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
293 | (i * workItemLength, workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace);
|
---|
294 | System.Threading.Interlocked.Increment(ref workerCount);
|
---|
295 | ILThreadPool.QueueUserWorkItem(i,worker, range);
|
---|
296 | }
|
---|
297 | // the last (or may the only) chunk is done right here
|
---|
298 | worker(new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
299 | (i * workItemLength, outLen - i * workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace));
|
---|
300 |
|
---|
301 | ILThreadPool.Wait4Workers(ref workerCount);
|
---|
302 | }
|
---|
303 | return new ILRetArray<complex>(retStorage);
|
---|
304 | }
|
---|
305 | }
|
---|
306 | /// <summary>Logarithm of array elements</summary>
|
---|
307 | /// <param name="A">Input array</param>
|
---|
308 | /// <returns>Complex logarithm of array elements</returns>
|
---|
309 | /// <remarks><para>If the input array is empty, an empty array will be returned.</para>
|
---|
310 | /// <para>The array returned will be a dense array.</para></remarks>
|
---|
311 | public unsafe static ILRetArray<complex> log (ILInArray< complex > A) {
|
---|
312 | using (ILScope.Enter(A)) {
|
---|
313 | if (A.IsEmpty)
|
---|
314 | return new ILRetArray<complex>(A.Size);
|
---|
315 | ILSize inDim = A.Size;
|
---|
316 | complex[] arrA = A.GetArrayForRead();
|
---|
317 | complex [] retArr;
|
---|
318 | int outLen = inDim.NumberOfElements;
|
---|
319 | bool inplace = true;
|
---|
320 |
|
---|
321 | if (true) {
|
---|
322 | retArr = ILMemoryPool.Pool.New<complex>(outLen);
|
---|
323 | inplace = false;
|
---|
324 | }
|
---|
325 | int i = 0, workItemCount = Settings.s_maxNumberThreads, workItemLength, workerCount = 1;
|
---|
326 | if (Settings.s_maxNumberThreads > 1 && outLen / 2 > Settings.s_minParallelElement1Count) {
|
---|
327 | if (outLen / workItemCount > Settings.s_minParallelElement1Count) {
|
---|
328 | workItemLength = outLen / workItemCount;
|
---|
329 | //workItemLength = (int)((double)outLen / workItemCount * 1.05);
|
---|
330 | } else {
|
---|
331 | workItemLength = outLen / 2;
|
---|
332 | workItemCount = 2;
|
---|
333 | }
|
---|
334 | } else {
|
---|
335 | workItemLength = outLen;
|
---|
336 | workItemCount = 1;
|
---|
337 | }
|
---|
338 | ILDenseStorage<complex> retStorage = new ILDenseStorage<complex>(retArr, inDim);
|
---|
339 |
|
---|
340 | Action<object> worker = data => {
|
---|
341 | Tuple<int, int, IntPtr, IntPtr, bool> range = (Tuple<int, int, IntPtr, IntPtr, bool>)data;
|
---|
342 |
|
---|
343 | complex* cp = ((complex*)range.Item4 + range.Item1);
|
---|
344 | int len = range.Item2;
|
---|
345 | if (range.Item5) {
|
---|
346 | // inplace
|
---|
347 | while (len > 20) {
|
---|
348 | cp[0] = complex.Log(cp[0] ) /*dummy*/;
|
---|
349 | cp[1] = complex.Log(cp[1] ) /*dummy*/;
|
---|
350 | cp[2] = complex.Log(cp[2] ) /*dummy*/;
|
---|
351 | cp[3] = complex.Log(cp[3] ) /*dummy*/;
|
---|
352 | cp[4] = complex.Log(cp[4] ) /*dummy*/;
|
---|
353 | cp[5] = complex.Log(cp[5] ) /*dummy*/;
|
---|
354 | cp[6] = complex.Log(cp[6] ) /*dummy*/;
|
---|
355 | cp[7] = complex.Log(cp[7] ) /*dummy*/;
|
---|
356 | cp[8] = complex.Log(cp[8] ) /*dummy*/;
|
---|
357 | cp[9] = complex.Log(cp[9] ) /*dummy*/;
|
---|
358 | cp[10] = complex.Log(cp[10] ) /*dummy*/;
|
---|
359 | cp[11] = complex.Log(cp[11] ) /*dummy*/;
|
---|
360 | cp[12] = complex.Log(cp[12] ) /*dummy*/;
|
---|
361 | cp[13] = complex.Log(cp[13] ) /*dummy*/;
|
---|
362 | cp[14] = complex.Log(cp[14] ) /*dummy*/;
|
---|
363 | cp[15] = complex.Log(cp[15] ) /*dummy*/;
|
---|
364 | cp[16] = complex.Log(cp[16] ) /*dummy*/;
|
---|
365 | cp[17] = complex.Log(cp[17] ) /*dummy*/;
|
---|
366 | cp[18] = complex.Log(cp[18] ) /*dummy*/;
|
---|
367 | cp[19] = complex.Log(cp[19] ) /*dummy*/;
|
---|
368 | cp[20] = complex.Log(cp[20] ) /*dummy*/;
|
---|
369 | cp+=21; len -= 21;
|
---|
370 | }
|
---|
371 | while (len-- > 0) {
|
---|
372 | *cp = complex.Log(*cp ) /*dummy*/;
|
---|
373 | cp++;
|
---|
374 | }
|
---|
375 | } else {
|
---|
376 | complex* ap = ((complex*)range.Item3 + range.Item1);
|
---|
377 | while (len > 20) {
|
---|
378 | cp[0] = complex.Log(ap[0] ) /*dummy*/;
|
---|
379 | cp[1] = complex.Log(ap[1] ) /*dummy*/;
|
---|
380 | cp[2] = complex.Log(ap[2] ) /*dummy*/;
|
---|
381 | cp[3] = complex.Log(ap[3] ) /*dummy*/;
|
---|
382 | cp[4] = complex.Log(ap[4] ) /*dummy*/;
|
---|
383 | cp[5] = complex.Log(ap[5] ) /*dummy*/;
|
---|
384 | cp[6] = complex.Log(ap[6] ) /*dummy*/;
|
---|
385 | cp[7] = complex.Log(ap[7] ) /*dummy*/;
|
---|
386 | cp[8] = complex.Log(ap[8] ) /*dummy*/;
|
---|
387 | cp[9] = complex.Log(ap[9] ) /*dummy*/;
|
---|
388 | cp[10] = complex.Log(ap[10] ) /*dummy*/;
|
---|
389 | cp[11] = complex.Log(ap[11] ) /*dummy*/;
|
---|
390 | cp[12] = complex.Log(ap[12] ) /*dummy*/;
|
---|
391 | cp[13] = complex.Log(ap[13] ) /*dummy*/;
|
---|
392 | cp[14] = complex.Log(ap[14] ) /*dummy*/;
|
---|
393 | cp[15] = complex.Log(ap[15] ) /*dummy*/;
|
---|
394 | cp[16] = complex.Log(ap[16] ) /*dummy*/;
|
---|
395 | cp[17] = complex.Log(ap[17] ) /*dummy*/;
|
---|
396 | cp[18] = complex.Log(ap[18] ) /*dummy*/;
|
---|
397 | cp[19] = complex.Log(ap[19] ) /*dummy*/;
|
---|
398 | cp[20] = complex.Log(ap[20] ) /*dummy*/;
|
---|
399 | ap += 21;
|
---|
400 | cp += 21;
|
---|
401 | len -= 21;
|
---|
402 | }
|
---|
403 | while (len-- > 0) {
|
---|
404 | *cp = complex.Log(*ap ) /*dummy*/;
|
---|
405 | ap++;
|
---|
406 | cp++;
|
---|
407 | }
|
---|
408 | }
|
---|
409 | System.Threading.Interlocked.Decrement(ref workerCount);
|
---|
410 | };
|
---|
411 |
|
---|
412 | fixed ( complex* arrAP = arrA)
|
---|
413 | fixed ( complex* retArrP = retArr) {
|
---|
414 | for (; i < workItemCount - 1; i++) {
|
---|
415 | Tuple<int, int, IntPtr, IntPtr, bool> range
|
---|
416 | = new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
417 | (i * workItemLength, workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace);
|
---|
418 | System.Threading.Interlocked.Increment(ref workerCount);
|
---|
419 | ILThreadPool.QueueUserWorkItem(i,worker, range);
|
---|
420 | }
|
---|
421 | // the last (or may the only) chunk is done right here
|
---|
422 | worker(new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
423 | (i * workItemLength, outLen - i * workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace));
|
---|
424 |
|
---|
425 | ILThreadPool.Wait4Workers(ref workerCount);
|
---|
426 | }
|
---|
427 | return new ILRetArray<complex>(retStorage);
|
---|
428 | }
|
---|
429 | }
|
---|
430 | /// <summary>Logarithm of array elements</summary>
|
---|
431 | /// <param name="A">Input array</param>
|
---|
432 | /// <returns>Complex logarithm of array elements</returns>
|
---|
433 | /// <remarks><para>If the input array is empty, an empty array will be returned.</para>
|
---|
434 | /// <para>The array returned will be a dense array.</para></remarks>
|
---|
435 | public unsafe static ILRetArray<fcomplex> log (ILInArray< fcomplex > A) {
|
---|
436 | using (ILScope.Enter(A)) {
|
---|
437 | if (A.IsEmpty)
|
---|
438 | return new ILRetArray<fcomplex>(A.Size);
|
---|
439 | ILSize inDim = A.Size;
|
---|
440 | fcomplex[] arrA = A.GetArrayForRead();
|
---|
441 | fcomplex [] retArr;
|
---|
442 | int outLen = inDim.NumberOfElements;
|
---|
443 | bool inplace = true;
|
---|
444 |
|
---|
445 | if (true) {
|
---|
446 | retArr = ILMemoryPool.Pool.New<fcomplex>(outLen);
|
---|
447 | inplace = false;
|
---|
448 | }
|
---|
449 | int i = 0, workItemCount = Settings.s_maxNumberThreads, workItemLength, workerCount = 1;
|
---|
450 | if (Settings.s_maxNumberThreads > 1 && outLen / 2 > Settings.s_minParallelElement1Count) {
|
---|
451 | if (outLen / workItemCount > Settings.s_minParallelElement1Count) {
|
---|
452 | workItemLength = outLen / workItemCount;
|
---|
453 | //workItemLength = (int)((double)outLen / workItemCount * 1.05);
|
---|
454 | } else {
|
---|
455 | workItemLength = outLen / 2;
|
---|
456 | workItemCount = 2;
|
---|
457 | }
|
---|
458 | } else {
|
---|
459 | workItemLength = outLen;
|
---|
460 | workItemCount = 1;
|
---|
461 | }
|
---|
462 | ILDenseStorage<fcomplex> retStorage = new ILDenseStorage<fcomplex>(retArr, inDim);
|
---|
463 |
|
---|
464 | Action<object> worker = data => {
|
---|
465 | Tuple<int, int, IntPtr, IntPtr, bool> range = (Tuple<int, int, IntPtr, IntPtr, bool>)data;
|
---|
466 |
|
---|
467 | fcomplex* cp = ((fcomplex*)range.Item4 + range.Item1);
|
---|
468 | int len = range.Item2;
|
---|
469 | if (range.Item5) {
|
---|
470 | // inplace
|
---|
471 | while (len > 20) {
|
---|
472 | cp[0] = fcomplex.Log(cp[0] ) /*dummy*/;
|
---|
473 | cp[1] = fcomplex.Log(cp[1] ) /*dummy*/;
|
---|
474 | cp[2] = fcomplex.Log(cp[2] ) /*dummy*/;
|
---|
475 | cp[3] = fcomplex.Log(cp[3] ) /*dummy*/;
|
---|
476 | cp[4] = fcomplex.Log(cp[4] ) /*dummy*/;
|
---|
477 | cp[5] = fcomplex.Log(cp[5] ) /*dummy*/;
|
---|
478 | cp[6] = fcomplex.Log(cp[6] ) /*dummy*/;
|
---|
479 | cp[7] = fcomplex.Log(cp[7] ) /*dummy*/;
|
---|
480 | cp[8] = fcomplex.Log(cp[8] ) /*dummy*/;
|
---|
481 | cp[9] = fcomplex.Log(cp[9] ) /*dummy*/;
|
---|
482 | cp[10] = fcomplex.Log(cp[10] ) /*dummy*/;
|
---|
483 | cp[11] = fcomplex.Log(cp[11] ) /*dummy*/;
|
---|
484 | cp[12] = fcomplex.Log(cp[12] ) /*dummy*/;
|
---|
485 | cp[13] = fcomplex.Log(cp[13] ) /*dummy*/;
|
---|
486 | cp[14] = fcomplex.Log(cp[14] ) /*dummy*/;
|
---|
487 | cp[15] = fcomplex.Log(cp[15] ) /*dummy*/;
|
---|
488 | cp[16] = fcomplex.Log(cp[16] ) /*dummy*/;
|
---|
489 | cp[17] = fcomplex.Log(cp[17] ) /*dummy*/;
|
---|
490 | cp[18] = fcomplex.Log(cp[18] ) /*dummy*/;
|
---|
491 | cp[19] = fcomplex.Log(cp[19] ) /*dummy*/;
|
---|
492 | cp[20] = fcomplex.Log(cp[20] ) /*dummy*/;
|
---|
493 | cp+=21; len -= 21;
|
---|
494 | }
|
---|
495 | while (len-- > 0) {
|
---|
496 | *cp = fcomplex.Log(*cp ) /*dummy*/;
|
---|
497 | cp++;
|
---|
498 | }
|
---|
499 | } else {
|
---|
500 | fcomplex* ap = ((fcomplex*)range.Item3 + range.Item1);
|
---|
501 | while (len > 20) {
|
---|
502 | cp[0] = fcomplex.Log(ap[0] ) /*dummy*/;
|
---|
503 | cp[1] = fcomplex.Log(ap[1] ) /*dummy*/;
|
---|
504 | cp[2] = fcomplex.Log(ap[2] ) /*dummy*/;
|
---|
505 | cp[3] = fcomplex.Log(ap[3] ) /*dummy*/;
|
---|
506 | cp[4] = fcomplex.Log(ap[4] ) /*dummy*/;
|
---|
507 | cp[5] = fcomplex.Log(ap[5] ) /*dummy*/;
|
---|
508 | cp[6] = fcomplex.Log(ap[6] ) /*dummy*/;
|
---|
509 | cp[7] = fcomplex.Log(ap[7] ) /*dummy*/;
|
---|
510 | cp[8] = fcomplex.Log(ap[8] ) /*dummy*/;
|
---|
511 | cp[9] = fcomplex.Log(ap[9] ) /*dummy*/;
|
---|
512 | cp[10] = fcomplex.Log(ap[10] ) /*dummy*/;
|
---|
513 | cp[11] = fcomplex.Log(ap[11] ) /*dummy*/;
|
---|
514 | cp[12] = fcomplex.Log(ap[12] ) /*dummy*/;
|
---|
515 | cp[13] = fcomplex.Log(ap[13] ) /*dummy*/;
|
---|
516 | cp[14] = fcomplex.Log(ap[14] ) /*dummy*/;
|
---|
517 | cp[15] = fcomplex.Log(ap[15] ) /*dummy*/;
|
---|
518 | cp[16] = fcomplex.Log(ap[16] ) /*dummy*/;
|
---|
519 | cp[17] = fcomplex.Log(ap[17] ) /*dummy*/;
|
---|
520 | cp[18] = fcomplex.Log(ap[18] ) /*dummy*/;
|
---|
521 | cp[19] = fcomplex.Log(ap[19] ) /*dummy*/;
|
---|
522 | cp[20] = fcomplex.Log(ap[20] ) /*dummy*/;
|
---|
523 | ap += 21;
|
---|
524 | cp += 21;
|
---|
525 | len -= 21;
|
---|
526 | }
|
---|
527 | while (len-- > 0) {
|
---|
528 | *cp = fcomplex.Log(*ap ) /*dummy*/;
|
---|
529 | ap++;
|
---|
530 | cp++;
|
---|
531 | }
|
---|
532 | }
|
---|
533 | System.Threading.Interlocked.Decrement(ref workerCount);
|
---|
534 | };
|
---|
535 |
|
---|
536 | fixed ( fcomplex* arrAP = arrA)
|
---|
537 | fixed ( fcomplex* retArrP = retArr) {
|
---|
538 | for (; i < workItemCount - 1; i++) {
|
---|
539 | Tuple<int, int, IntPtr, IntPtr, bool> range
|
---|
540 | = new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
541 | (i * workItemLength, workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace);
|
---|
542 | System.Threading.Interlocked.Increment(ref workerCount);
|
---|
543 | ILThreadPool.QueueUserWorkItem(i,worker, range);
|
---|
544 | }
|
---|
545 | // the last (or may the only) chunk is done right here
|
---|
546 | worker(new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
547 | (i * workItemLength, outLen - i * workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace));
|
---|
548 |
|
---|
549 | ILThreadPool.Wait4Workers(ref workerCount);
|
---|
550 | }
|
---|
551 | return new ILRetArray<fcomplex>(retStorage);
|
---|
552 | }
|
---|
553 | }
|
---|
554 | /// <summary>Logarithm of array elements - real output</summary>
|
---|
555 | /// <param name="A">Input array</param>
|
---|
556 | /// <returns>Logarithm of array elements - real output</returns>
|
---|
557 | /// <remarks><para>If the input array is empty, an empty array will be returned.</para>
|
---|
558 | /// <para>The array returned will be a dense array.</para></remarks>
|
---|
559 | public unsafe static ILRetArray<float> log (ILInArray< float > A) {
|
---|
560 | using (ILScope.Enter(A)) {
|
---|
561 | if (A.IsEmpty)
|
---|
562 | return new ILRetArray<float>(A.Size);
|
---|
563 | ILSize inDim = A.Size;
|
---|
564 | float[] arrA = A.GetArrayForRead();
|
---|
565 | float [] retArr;
|
---|
566 | int outLen = inDim.NumberOfElements;
|
---|
567 | bool inplace = true;
|
---|
568 |
|
---|
569 | if (true) {
|
---|
570 | retArr = ILMemoryPool.Pool.New<float>(outLen);
|
---|
571 | inplace = false;
|
---|
572 | }
|
---|
573 | int i = 0, workItemCount = Settings.s_maxNumberThreads, workItemLength, workerCount = 1;
|
---|
574 | if (Settings.s_maxNumberThreads > 1 && outLen / 2 > Settings.s_minParallelElement1Count) {
|
---|
575 | if (outLen / workItemCount > Settings.s_minParallelElement1Count) {
|
---|
576 | workItemLength = outLen / workItemCount;
|
---|
577 | //workItemLength = (int)((double)outLen / workItemCount * 1.05);
|
---|
578 | } else {
|
---|
579 | workItemLength = outLen / 2;
|
---|
580 | workItemCount = 2;
|
---|
581 | }
|
---|
582 | } else {
|
---|
583 | workItemLength = outLen;
|
---|
584 | workItemCount = 1;
|
---|
585 | }
|
---|
586 | ILDenseStorage<float> retStorage = new ILDenseStorage<float>(retArr, inDim);
|
---|
587 |
|
---|
588 | Action<object> worker = data => {
|
---|
589 | Tuple<int, int, IntPtr, IntPtr, bool> range = (Tuple<int, int, IntPtr, IntPtr, bool>)data;
|
---|
590 |
|
---|
591 | float* cp = ((float*)range.Item4 + range.Item1);
|
---|
592 | int len = range.Item2;
|
---|
593 | if (range.Item5) {
|
---|
594 | // inplace
|
---|
595 | while (len > 20) {
|
---|
596 | cp[0] = (float)Math.Log(cp[0] ) /*dummy*/;
|
---|
597 | cp[1] = (float)Math.Log(cp[1] ) /*dummy*/;
|
---|
598 | cp[2] = (float)Math.Log(cp[2] ) /*dummy*/;
|
---|
599 | cp[3] = (float)Math.Log(cp[3] ) /*dummy*/;
|
---|
600 | cp[4] = (float)Math.Log(cp[4] ) /*dummy*/;
|
---|
601 | cp[5] = (float)Math.Log(cp[5] ) /*dummy*/;
|
---|
602 | cp[6] = (float)Math.Log(cp[6] ) /*dummy*/;
|
---|
603 | cp[7] = (float)Math.Log(cp[7] ) /*dummy*/;
|
---|
604 | cp[8] = (float)Math.Log(cp[8] ) /*dummy*/;
|
---|
605 | cp[9] = (float)Math.Log(cp[9] ) /*dummy*/;
|
---|
606 | cp[10] = (float)Math.Log(cp[10] ) /*dummy*/;
|
---|
607 | cp[11] = (float)Math.Log(cp[11] ) /*dummy*/;
|
---|
608 | cp[12] = (float)Math.Log(cp[12] ) /*dummy*/;
|
---|
609 | cp[13] = (float)Math.Log(cp[13] ) /*dummy*/;
|
---|
610 | cp[14] = (float)Math.Log(cp[14] ) /*dummy*/;
|
---|
611 | cp[15] = (float)Math.Log(cp[15] ) /*dummy*/;
|
---|
612 | cp[16] = (float)Math.Log(cp[16] ) /*dummy*/;
|
---|
613 | cp[17] = (float)Math.Log(cp[17] ) /*dummy*/;
|
---|
614 | cp[18] = (float)Math.Log(cp[18] ) /*dummy*/;
|
---|
615 | cp[19] = (float)Math.Log(cp[19] ) /*dummy*/;
|
---|
616 | cp[20] = (float)Math.Log(cp[20] ) /*dummy*/;
|
---|
617 | cp+=21; len -= 21;
|
---|
618 | }
|
---|
619 | while (len-- > 0) {
|
---|
620 | *cp = (float)Math.Log(*cp ) /*dummy*/;
|
---|
621 | cp++;
|
---|
622 | }
|
---|
623 | } else {
|
---|
624 | float* ap = ((float*)range.Item3 + range.Item1);
|
---|
625 | while (len > 20) {
|
---|
626 | cp[0] = (float)Math.Log(ap[0] ) /*dummy*/;
|
---|
627 | cp[1] = (float)Math.Log(ap[1] ) /*dummy*/;
|
---|
628 | cp[2] = (float)Math.Log(ap[2] ) /*dummy*/;
|
---|
629 | cp[3] = (float)Math.Log(ap[3] ) /*dummy*/;
|
---|
630 | cp[4] = (float)Math.Log(ap[4] ) /*dummy*/;
|
---|
631 | cp[5] = (float)Math.Log(ap[5] ) /*dummy*/;
|
---|
632 | cp[6] = (float)Math.Log(ap[6] ) /*dummy*/;
|
---|
633 | cp[7] = (float)Math.Log(ap[7] ) /*dummy*/;
|
---|
634 | cp[8] = (float)Math.Log(ap[8] ) /*dummy*/;
|
---|
635 | cp[9] = (float)Math.Log(ap[9] ) /*dummy*/;
|
---|
636 | cp[10] = (float)Math.Log(ap[10] ) /*dummy*/;
|
---|
637 | cp[11] = (float)Math.Log(ap[11] ) /*dummy*/;
|
---|
638 | cp[12] = (float)Math.Log(ap[12] ) /*dummy*/;
|
---|
639 | cp[13] = (float)Math.Log(ap[13] ) /*dummy*/;
|
---|
640 | cp[14] = (float)Math.Log(ap[14] ) /*dummy*/;
|
---|
641 | cp[15] = (float)Math.Log(ap[15] ) /*dummy*/;
|
---|
642 | cp[16] = (float)Math.Log(ap[16] ) /*dummy*/;
|
---|
643 | cp[17] = (float)Math.Log(ap[17] ) /*dummy*/;
|
---|
644 | cp[18] = (float)Math.Log(ap[18] ) /*dummy*/;
|
---|
645 | cp[19] = (float)Math.Log(ap[19] ) /*dummy*/;
|
---|
646 | cp[20] = (float)Math.Log(ap[20] ) /*dummy*/;
|
---|
647 | ap += 21;
|
---|
648 | cp += 21;
|
---|
649 | len -= 21;
|
---|
650 | }
|
---|
651 | while (len-- > 0) {
|
---|
652 | *cp = (float)Math.Log(*ap ) /*dummy*/;
|
---|
653 | ap++;
|
---|
654 | cp++;
|
---|
655 | }
|
---|
656 | }
|
---|
657 | System.Threading.Interlocked.Decrement(ref workerCount);
|
---|
658 | };
|
---|
659 |
|
---|
660 | fixed ( float* arrAP = arrA)
|
---|
661 | fixed ( float* retArrP = retArr) {
|
---|
662 | for (; i < workItemCount - 1; i++) {
|
---|
663 | Tuple<int, int, IntPtr, IntPtr, bool> range
|
---|
664 | = new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
665 | (i * workItemLength, workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace);
|
---|
666 | System.Threading.Interlocked.Increment(ref workerCount);
|
---|
667 | ILThreadPool.QueueUserWorkItem(i,worker, range);
|
---|
668 | }
|
---|
669 | // the last (or may the only) chunk is done right here
|
---|
670 | worker(new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
671 | (i * workItemLength, outLen - i * workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace));
|
---|
672 |
|
---|
673 | ILThreadPool.Wait4Workers(ref workerCount);
|
---|
674 | }
|
---|
675 | return new ILRetArray<float>(retStorage);
|
---|
676 | }
|
---|
677 | }
|
---|
678 | /// <summary>Logarithm of array elements - real output</summary>
|
---|
679 | /// <param name="A">Input array</param>
|
---|
680 | /// <returns>Logarithm of array elements - real output</returns>
|
---|
681 | /// <remarks><para>If the input array is empty, an empty array will be returned.</para>
|
---|
682 | /// <para>The array returned will be a dense array.</para></remarks>
|
---|
683 | public unsafe static ILRetArray<double> log (ILInArray< double > A) {
|
---|
684 | using (ILScope.Enter(A)) {
|
---|
685 | if (A.IsEmpty)
|
---|
686 | return new ILRetArray<double>(A.Size);
|
---|
687 | ILSize inDim = A.Size;
|
---|
688 | double[] arrA = A.GetArrayForRead();
|
---|
689 | double [] retArr;
|
---|
690 | int outLen = inDim.NumberOfElements;
|
---|
691 | bool inplace = true;
|
---|
692 |
|
---|
693 | if (true) {
|
---|
694 | retArr = ILMemoryPool.Pool.New<double>(outLen);
|
---|
695 | inplace = false;
|
---|
696 | }
|
---|
697 | int i = 0, workItemCount = Settings.s_maxNumberThreads, workItemLength, workerCount = 1;
|
---|
698 | if (Settings.s_maxNumberThreads > 1 && outLen / 2 > Settings.s_minParallelElement1Count) {
|
---|
699 | if (outLen / workItemCount > Settings.s_minParallelElement1Count) {
|
---|
700 | workItemLength = outLen / workItemCount;
|
---|
701 | //workItemLength = (int)((double)outLen / workItemCount * 1.05);
|
---|
702 | } else {
|
---|
703 | workItemLength = outLen / 2;
|
---|
704 | workItemCount = 2;
|
---|
705 | }
|
---|
706 | } else {
|
---|
707 | workItemLength = outLen;
|
---|
708 | workItemCount = 1;
|
---|
709 | }
|
---|
710 | ILDenseStorage<double> retStorage = new ILDenseStorage<double>(retArr, inDim);
|
---|
711 |
|
---|
712 | Action<object> worker = data => {
|
---|
713 | Tuple<int, int, IntPtr, IntPtr, bool> range = (Tuple<int, int, IntPtr, IntPtr, bool>)data;
|
---|
714 |
|
---|
715 | double* cp = ((double*)range.Item4 + range.Item1);
|
---|
716 | int len = range.Item2;
|
---|
717 | if (range.Item5) {
|
---|
718 | // inplace
|
---|
719 | while (len > 20) {
|
---|
720 | cp[0] = Math.Log(cp[0] ) /*dummy*/;
|
---|
721 | cp[1] = Math.Log(cp[1] ) /*dummy*/;
|
---|
722 | cp[2] = Math.Log(cp[2] ) /*dummy*/;
|
---|
723 | cp[3] = Math.Log(cp[3] ) /*dummy*/;
|
---|
724 | cp[4] = Math.Log(cp[4] ) /*dummy*/;
|
---|
725 | cp[5] = Math.Log(cp[5] ) /*dummy*/;
|
---|
726 | cp[6] = Math.Log(cp[6] ) /*dummy*/;
|
---|
727 | cp[7] = Math.Log(cp[7] ) /*dummy*/;
|
---|
728 | cp[8] = Math.Log(cp[8] ) /*dummy*/;
|
---|
729 | cp[9] = Math.Log(cp[9] ) /*dummy*/;
|
---|
730 | cp[10] = Math.Log(cp[10] ) /*dummy*/;
|
---|
731 | cp[11] = Math.Log(cp[11] ) /*dummy*/;
|
---|
732 | cp[12] = Math.Log(cp[12] ) /*dummy*/;
|
---|
733 | cp[13] = Math.Log(cp[13] ) /*dummy*/;
|
---|
734 | cp[14] = Math.Log(cp[14] ) /*dummy*/;
|
---|
735 | cp[15] = Math.Log(cp[15] ) /*dummy*/;
|
---|
736 | cp[16] = Math.Log(cp[16] ) /*dummy*/;
|
---|
737 | cp[17] = Math.Log(cp[17] ) /*dummy*/;
|
---|
738 | cp[18] = Math.Log(cp[18] ) /*dummy*/;
|
---|
739 | cp[19] = Math.Log(cp[19] ) /*dummy*/;
|
---|
740 | cp[20] = Math.Log(cp[20] ) /*dummy*/;
|
---|
741 | cp+=21; len -= 21;
|
---|
742 | }
|
---|
743 | while (len-- > 0) {
|
---|
744 | *cp = Math.Log(*cp ) /*dummy*/;
|
---|
745 | cp++;
|
---|
746 | }
|
---|
747 | } else {
|
---|
748 | double* ap = ((double*)range.Item3 + range.Item1);
|
---|
749 | while (len > 20) {
|
---|
750 | cp[0] = Math.Log(ap[0] ) /*dummy*/;
|
---|
751 | cp[1] = Math.Log(ap[1] ) /*dummy*/;
|
---|
752 | cp[2] = Math.Log(ap[2] ) /*dummy*/;
|
---|
753 | cp[3] = Math.Log(ap[3] ) /*dummy*/;
|
---|
754 | cp[4] = Math.Log(ap[4] ) /*dummy*/;
|
---|
755 | cp[5] = Math.Log(ap[5] ) /*dummy*/;
|
---|
756 | cp[6] = Math.Log(ap[6] ) /*dummy*/;
|
---|
757 | cp[7] = Math.Log(ap[7] ) /*dummy*/;
|
---|
758 | cp[8] = Math.Log(ap[8] ) /*dummy*/;
|
---|
759 | cp[9] = Math.Log(ap[9] ) /*dummy*/;
|
---|
760 | cp[10] = Math.Log(ap[10] ) /*dummy*/;
|
---|
761 | cp[11] = Math.Log(ap[11] ) /*dummy*/;
|
---|
762 | cp[12] = Math.Log(ap[12] ) /*dummy*/;
|
---|
763 | cp[13] = Math.Log(ap[13] ) /*dummy*/;
|
---|
764 | cp[14] = Math.Log(ap[14] ) /*dummy*/;
|
---|
765 | cp[15] = Math.Log(ap[15] ) /*dummy*/;
|
---|
766 | cp[16] = Math.Log(ap[16] ) /*dummy*/;
|
---|
767 | cp[17] = Math.Log(ap[17] ) /*dummy*/;
|
---|
768 | cp[18] = Math.Log(ap[18] ) /*dummy*/;
|
---|
769 | cp[19] = Math.Log(ap[19] ) /*dummy*/;
|
---|
770 | cp[20] = Math.Log(ap[20] ) /*dummy*/;
|
---|
771 | ap += 21;
|
---|
772 | cp += 21;
|
---|
773 | len -= 21;
|
---|
774 | }
|
---|
775 | while (len-- > 0) {
|
---|
776 | *cp = Math.Log(*ap ) /*dummy*/;
|
---|
777 | ap++;
|
---|
778 | cp++;
|
---|
779 | }
|
---|
780 | }
|
---|
781 | System.Threading.Interlocked.Decrement(ref workerCount);
|
---|
782 | };
|
---|
783 |
|
---|
784 | fixed ( double* arrAP = arrA)
|
---|
785 | fixed ( double* retArrP = retArr) {
|
---|
786 | for (; i < workItemCount - 1; i++) {
|
---|
787 | Tuple<int, int, IntPtr, IntPtr, bool> range
|
---|
788 | = new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
789 | (i * workItemLength, workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace);
|
---|
790 | System.Threading.Interlocked.Increment(ref workerCount);
|
---|
791 | ILThreadPool.QueueUserWorkItem(i,worker, range);
|
---|
792 | }
|
---|
793 | // the last (or may the only) chunk is done right here
|
---|
794 | worker(new Tuple<int, int, IntPtr, IntPtr, bool>
|
---|
795 | (i * workItemLength, outLen - i * workItemLength, (IntPtr)arrAP, (IntPtr)retArrP, inplace));
|
---|
796 |
|
---|
797 | ILThreadPool.Wait4Workers(ref workerCount);
|
---|
798 | }
|
---|
799 | return new ILRetArray<double>(retStorage);
|
---|
800 | }
|
---|
801 | }
|
---|
802 |
|
---|
803 | #endregion HYCALPER AUTO GENERATED CODE
|
---|
804 |
|
---|
805 | }
|
---|
806 | }
|
---|