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 ILNumerics;
|
---|
42 | using ILNumerics.Misc;
|
---|
43 | using ILNumerics.Storage;
|
---|
44 | using ILNumerics.Native;
|
---|
45 | using ILNumerics.Exceptions;
|
---|
46 |
|
---|
47 | ///// this is a template for unary - inplace functions
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 | namespace ILNumerics {
|
---|
52 |
|
---|
53 | public partial class ILMath {
|
---|
54 |
|
---|
55 | |
---|
56 | /// <summary>
|
---|
57 | /// Invert elements of A, return result into predefined output array
|
---|
58 | /// </summary>
|
---|
59 | /// <param name="A">Input array</param>
|
---|
60 | /// <param name="outArray">Predefined array for results</param>
|
---|
61 | public static void invert(ILInArray<double> A, ILOutArray<double> outArray) {
|
---|
62 | using (ILScope.Enter(A)) {
|
---|
63 | ILSize inDim = A.Size;
|
---|
64 | if (object.Equals(outArray,null))
|
---|
65 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
66 |
|
---|
67 | bool inplace = true;
|
---|
68 | int outLen = A.S.NumberOfElements;
|
---|
69 | ILSize outDims = A.S;
|
---|
70 | double[] retArr = outArray.GetArrayForWrite();
|
---|
71 | double[] aArr = A.GetArrayForRead();
|
---|
72 | if (outArray.S.NumberOfElements != outLen
|
---|
73 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
74 | retArr = ILNumerics.ILMemoryPool.Pool.New<double>(outLen);
|
---|
75 | inplace = false;
|
---|
76 | }
|
---|
77 | unsafe {
|
---|
78 | fixed ( double* inA2 =retArr)
|
---|
79 | fixed ( double* inA1 = aArr) {
|
---|
80 |
|
---|
81 | double* pInA1 = inA1;
|
---|
82 |
|
---|
83 | double* pInA2 = inA2;
|
---|
84 |
|
---|
85 | double* outEnd = inA2 + outLen;
|
---|
86 | if (!inplace) {
|
---|
87 | while (pInA2 < outEnd) { //HC11
|
---|
88 |
|
---|
89 | *pInA2++ = /*dummy*/ (*pInA1++ /*HC:HCoperation*/ * (-1.0)/*dummy*/);
|
---|
90 | }
|
---|
91 | } else {
|
---|
92 | while (pInA2 < outEnd) { //HC11
|
---|
93 | *pInA2 = /*dummy*/ (*pInA2 /*HC:HCoperation*/ * (-1.0)/*dummy*/);
|
---|
94 | pInA2++;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 | outArray.a = new ILRetArray< double>(new ILDenseStorage< double>(retArr, outDims));
|
---|
100 | return;
|
---|
101 | }
|
---|
102 | }
|
---|
103 | |
---|
104 | #region HYCALPER AUTO GENERATED CODE
|
---|
105 | |
---|
106 | /// <summary>
|
---|
107 | /// Invert elements of A, return result into predefined output array
|
---|
108 | /// </summary>
|
---|
109 | /// <param name="A">Input array</param>
|
---|
110 | /// <param name="outArray">Predefined array for results</param>
|
---|
111 | public static void invert(ILInArray<byte> A, ILOutArray<byte> outArray) {
|
---|
112 | using (ILScope.Enter(A)) {
|
---|
113 | ILSize inDim = A.Size;
|
---|
114 | if (object.Equals(outArray,null))
|
---|
115 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
116 |
|
---|
117 | bool inplace = true;
|
---|
118 | int outLen = A.S.NumberOfElements;
|
---|
119 | ILSize outDims = A.S;
|
---|
120 | byte[] retArr = outArray.GetArrayForWrite();
|
---|
121 | byte[] aArr = A.GetArrayForRead();
|
---|
122 | if (outArray.S.NumberOfElements != outLen
|
---|
123 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
124 | retArr = ILNumerics.ILMemoryPool.Pool.New<byte>(outLen);
|
---|
125 | inplace = false;
|
---|
126 | }
|
---|
127 | unsafe {
|
---|
128 | fixed ( byte* inA2 =retArr)
|
---|
129 | fixed ( byte* inA1 = aArr) {
|
---|
130 |
|
---|
131 | byte* pInA1 = inA1;
|
---|
132 |
|
---|
133 | byte* pInA2 = inA2;
|
---|
134 |
|
---|
135 | byte* outEnd = inA2 + outLen;
|
---|
136 | if (!inplace) {
|
---|
137 | while (pInA2 < outEnd) { //HC11
|
---|
138 |
|
---|
139 | *pInA2++ = (byte) (*pInA1++ /*HC:*/ *(-1)/*dummy*/);
|
---|
140 | }
|
---|
141 | } else {
|
---|
142 | while (pInA2 < outEnd) { //HC11
|
---|
143 | *pInA2 = (byte) (*pInA2 /*HC:*/ *(-1)/*dummy*/);
|
---|
144 | pInA2++;
|
---|
145 | }
|
---|
146 | }
|
---|
147 | }
|
---|
148 | }
|
---|
149 | outArray.a = new ILRetArray< byte>(new ILDenseStorage< byte>(retArr, outDims));
|
---|
150 | return;
|
---|
151 | }
|
---|
152 | }
|
---|
153 | /// <summary>
|
---|
154 | /// Invert elements of A, return result into predefined output array
|
---|
155 | /// </summary>
|
---|
156 | /// <param name="A">Input array</param>
|
---|
157 | /// <param name="outArray">Predefined array for results</param>
|
---|
158 | public static void invert(ILInArray<Int64> A, ILOutArray<Int64> outArray) {
|
---|
159 | using (ILScope.Enter(A)) {
|
---|
160 | ILSize inDim = A.Size;
|
---|
161 | if (object.Equals(outArray,null))
|
---|
162 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
163 |
|
---|
164 | bool inplace = true;
|
---|
165 | int outLen = A.S.NumberOfElements;
|
---|
166 | ILSize outDims = A.S;
|
---|
167 | Int64[] retArr = outArray.GetArrayForWrite();
|
---|
168 | Int64[] aArr = A.GetArrayForRead();
|
---|
169 | if (outArray.S.NumberOfElements != outLen
|
---|
170 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
171 | retArr = ILNumerics.ILMemoryPool.Pool.New<Int64>(outLen);
|
---|
172 | inplace = false;
|
---|
173 | }
|
---|
174 | unsafe {
|
---|
175 | fixed ( Int64* inA2 =retArr)
|
---|
176 | fixed ( Int64* inA1 = aArr) {
|
---|
177 |
|
---|
178 | Int64* pInA1 = inA1;
|
---|
179 |
|
---|
180 | Int64* pInA2 = inA2;
|
---|
181 |
|
---|
182 | Int64* outEnd = inA2 + outLen;
|
---|
183 | if (!inplace) {
|
---|
184 | while (pInA2 < outEnd) { //HC11
|
---|
185 |
|
---|
186 | *pInA2++ = (*pInA1++ /*HC:*/ *(-1)/*dummy*/);
|
---|
187 | }
|
---|
188 | } else {
|
---|
189 | while (pInA2 < outEnd) { //HC11
|
---|
190 | *pInA2 = (*pInA2 /*HC:*/ *(-1)/*dummy*/);
|
---|
191 | pInA2++;
|
---|
192 | }
|
---|
193 | }
|
---|
194 | }
|
---|
195 | }
|
---|
196 | outArray.a = new ILRetArray< Int64>(new ILDenseStorage< Int64>(retArr, outDims));
|
---|
197 | return;
|
---|
198 | }
|
---|
199 | }
|
---|
200 | /// <summary>
|
---|
201 | /// Invert elements of A, return result into predefined output array
|
---|
202 | /// </summary>
|
---|
203 | /// <param name="A">Input array</param>
|
---|
204 | /// <param name="outArray">Predefined array for results</param>
|
---|
205 | public static void invert(ILInArray<Int32> A, ILOutArray<Int32> outArray) {
|
---|
206 | using (ILScope.Enter(A)) {
|
---|
207 | ILSize inDim = A.Size;
|
---|
208 | if (object.Equals(outArray,null))
|
---|
209 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
210 |
|
---|
211 | bool inplace = true;
|
---|
212 | int outLen = A.S.NumberOfElements;
|
---|
213 | ILSize outDims = A.S;
|
---|
214 | Int32[] retArr = outArray.GetArrayForWrite();
|
---|
215 | Int32[] aArr = A.GetArrayForRead();
|
---|
216 | if (outArray.S.NumberOfElements != outLen
|
---|
217 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
218 | retArr = ILNumerics.ILMemoryPool.Pool.New<Int32>(outLen);
|
---|
219 | inplace = false;
|
---|
220 | }
|
---|
221 | unsafe {
|
---|
222 | fixed ( Int32* inA2 =retArr)
|
---|
223 | fixed ( Int32* inA1 = aArr) {
|
---|
224 |
|
---|
225 | Int32* pInA1 = inA1;
|
---|
226 |
|
---|
227 | Int32* pInA2 = inA2;
|
---|
228 |
|
---|
229 | Int32* outEnd = inA2 + outLen;
|
---|
230 | if (!inplace) {
|
---|
231 | while (pInA2 < outEnd) { //HC11
|
---|
232 |
|
---|
233 | *pInA2++ = (*pInA1++ /*HC:*/ *(-1)/*dummy*/);
|
---|
234 | }
|
---|
235 | } else {
|
---|
236 | while (pInA2 < outEnd) { //HC11
|
---|
237 | *pInA2 = (*pInA2 /*HC:*/ *(-1)/*dummy*/);
|
---|
238 | pInA2++;
|
---|
239 | }
|
---|
240 | }
|
---|
241 | }
|
---|
242 | }
|
---|
243 | outArray.a = new ILRetArray< Int32>(new ILDenseStorage< Int32>(retArr, outDims));
|
---|
244 | return;
|
---|
245 | }
|
---|
246 | }
|
---|
247 | /// <summary>
|
---|
248 | /// Invert elements of A, return result into predefined output array
|
---|
249 | /// </summary>
|
---|
250 | /// <param name="A">Input array</param>
|
---|
251 | /// <param name="outArray">Predefined array for results</param>
|
---|
252 | public static void invert(ILInArray<float> A, ILOutArray<float> outArray) {
|
---|
253 | using (ILScope.Enter(A)) {
|
---|
254 | ILSize inDim = A.Size;
|
---|
255 | if (object.Equals(outArray,null))
|
---|
256 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
257 |
|
---|
258 | bool inplace = true;
|
---|
259 | int outLen = A.S.NumberOfElements;
|
---|
260 | ILSize outDims = A.S;
|
---|
261 | float[] retArr = outArray.GetArrayForWrite();
|
---|
262 | float[] aArr = A.GetArrayForRead();
|
---|
263 | if (outArray.S.NumberOfElements != outLen
|
---|
264 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
265 | retArr = ILNumerics.ILMemoryPool.Pool.New<float>(outLen);
|
---|
266 | inplace = false;
|
---|
267 | }
|
---|
268 | unsafe {
|
---|
269 | fixed ( float* inA2 =retArr)
|
---|
270 | fixed ( float* inA1 = aArr) {
|
---|
271 |
|
---|
272 | float* pInA1 = inA1;
|
---|
273 |
|
---|
274 | float* pInA2 = inA2;
|
---|
275 |
|
---|
276 | float* outEnd = inA2 + outLen;
|
---|
277 | if (!inplace) {
|
---|
278 | while (pInA2 < outEnd) { //HC11
|
---|
279 |
|
---|
280 | *pInA2++ = (*pInA1++ /*HC:*/ *(-1.0f)/*dummy*/);
|
---|
281 | }
|
---|
282 | } else {
|
---|
283 | while (pInA2 < outEnd) { //HC11
|
---|
284 | *pInA2 = (*pInA2 /*HC:*/ *(-1.0f)/*dummy*/);
|
---|
285 | pInA2++;
|
---|
286 | }
|
---|
287 | }
|
---|
288 | }
|
---|
289 | }
|
---|
290 | outArray.a = new ILRetArray< float>(new ILDenseStorage< float>(retArr, outDims));
|
---|
291 | return;
|
---|
292 | }
|
---|
293 | }
|
---|
294 | /// <summary>
|
---|
295 | /// Invert elements of A, return result into predefined output array
|
---|
296 | /// </summary>
|
---|
297 | /// <param name="A">Input array</param>
|
---|
298 | /// <param name="outArray">Predefined array for results</param>
|
---|
299 | public static void invert(ILInArray<fcomplex> A, ILOutArray<fcomplex> outArray) {
|
---|
300 | using (ILScope.Enter(A)) {
|
---|
301 | ILSize inDim = A.Size;
|
---|
302 | if (object.Equals(outArray,null))
|
---|
303 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
304 |
|
---|
305 | bool inplace = true;
|
---|
306 | int outLen = A.S.NumberOfElements;
|
---|
307 | ILSize outDims = A.S;
|
---|
308 | fcomplex[] retArr = outArray.GetArrayForWrite();
|
---|
309 | fcomplex[] aArr = A.GetArrayForRead();
|
---|
310 | if (outArray.S.NumberOfElements != outLen
|
---|
311 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
312 | retArr = ILNumerics.ILMemoryPool.Pool.New<fcomplex>(outLen);
|
---|
313 | inplace = false;
|
---|
314 | }
|
---|
315 | unsafe {
|
---|
316 | fixed ( fcomplex* inA2 =retArr)
|
---|
317 | fixed ( fcomplex* inA1 = aArr) {
|
---|
318 |
|
---|
319 | fcomplex* pInA1 = inA1;
|
---|
320 |
|
---|
321 | fcomplex* pInA2 = inA2;
|
---|
322 |
|
---|
323 | fcomplex* outEnd = inA2 + outLen;
|
---|
324 | if (!inplace) {
|
---|
325 | while (pInA2 < outEnd) { //HC11
|
---|
326 |
|
---|
327 | *pInA2++ = (*pInA1++ /*HC:*/ *(-1.0f)/*dummy*/);
|
---|
328 | }
|
---|
329 | } else {
|
---|
330 | while (pInA2 < outEnd) { //HC11
|
---|
331 | *pInA2 = (*pInA2 /*HC:*/ *(-1.0f)/*dummy*/);
|
---|
332 | pInA2++;
|
---|
333 | }
|
---|
334 | }
|
---|
335 | }
|
---|
336 | }
|
---|
337 | outArray.a = new ILRetArray< fcomplex>(new ILDenseStorage< fcomplex>(retArr, outDims));
|
---|
338 | return;
|
---|
339 | }
|
---|
340 | }
|
---|
341 | /// <summary>
|
---|
342 | /// Invert elements of A, return result into predefined output array
|
---|
343 | /// </summary>
|
---|
344 | /// <param name="A">Input array</param>
|
---|
345 | /// <param name="outArray">Predefined array for results</param>
|
---|
346 | public static void invert(ILInArray<complex> A, ILOutArray<complex> outArray) {
|
---|
347 | using (ILScope.Enter(A)) {
|
---|
348 | ILSize inDim = A.Size;
|
---|
349 | if (object.Equals(outArray,null))
|
---|
350 | throw new ILArgumentException("output parameter 'outArray' must not be null but reference existing array");
|
---|
351 |
|
---|
352 | bool inplace = true;
|
---|
353 | int outLen = A.S.NumberOfElements;
|
---|
354 | ILSize outDims = A.S;
|
---|
355 | complex[] retArr = outArray.GetArrayForWrite();
|
---|
356 | complex[] aArr = A.GetArrayForRead();
|
---|
357 | if (outArray.S.NumberOfElements != outLen
|
---|
358 | && !A.TryGetStorage4InplaceOp(out retArr)) {
|
---|
359 | retArr = ILNumerics.ILMemoryPool.Pool.New<complex>(outLen);
|
---|
360 | inplace = false;
|
---|
361 | }
|
---|
362 | unsafe {
|
---|
363 | fixed ( complex* inA2 =retArr)
|
---|
364 | fixed ( complex* inA1 = aArr) {
|
---|
365 |
|
---|
366 | complex* pInA1 = inA1;
|
---|
367 |
|
---|
368 | complex* pInA2 = inA2;
|
---|
369 |
|
---|
370 | complex* outEnd = inA2 + outLen;
|
---|
371 | if (!inplace) {
|
---|
372 | while (pInA2 < outEnd) { //HC11
|
---|
373 |
|
---|
374 | *pInA2++ = (*pInA1++ /*HC:*/ *(-1.0)/*dummy*/);
|
---|
375 | }
|
---|
376 | } else {
|
---|
377 | while (pInA2 < outEnd) { //HC11
|
---|
378 | *pInA2 = (*pInA2 /*HC:*/ *(-1.0)/*dummy*/);
|
---|
379 | pInA2++;
|
---|
380 | }
|
---|
381 | }
|
---|
382 | }
|
---|
383 | }
|
---|
384 | outArray.a = new ILRetArray< complex>(new ILDenseStorage< complex>(retArr, outDims));
|
---|
385 | return;
|
---|
386 | }
|
---|
387 | }
|
---|
388 |
|
---|
389 | #endregion HYCALPER AUTO GENERATED CODE
|
---|
390 |
|
---|
391 | }
|
---|
392 | } |
---|