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 System.Runtime.InteropServices;
|
---|
44 | using ILNumerics.Storage;
|
---|
45 | using ILNumerics.Misc;
|
---|
46 | using ILNumerics.Native;
|
---|
47 | using ILNumerics.Exceptions;
|
---|
48 |
|
---|
49 | namespace ILNumerics {
|
---|
50 |
|
---|
51 | public partial class ILMath {
|
---|
52 |
|
---|
53 | /// <summary>
|
---|
54 | /// Create empty double array of size [0,0].
|
---|
55 | /// </summary>
|
---|
56 | /// <returns>Empty array</returns>
|
---|
57 | public static ILRetArray<double> empty() {
|
---|
58 | return ILRetArray<double>.empty(ILSize.Empty00);
|
---|
59 | }
|
---|
60 | /// <summary>
|
---|
61 | /// Create empty double array of specific size
|
---|
62 | /// </summary>
|
---|
63 | /// <param name="size">(Empty-) size of new empty array</param>
|
---|
64 | /// <returns>Empty array</returns>
|
---|
65 | public static ILRetArray<T> empty<T>(ILSize size) {
|
---|
66 | if (size.NumberOfElements > 0)
|
---|
67 | throw new ILArgumentException("the 'size' parameter must define an empty array size");
|
---|
68 | return new ILRetArray<T>(size);
|
---|
69 | }
|
---|
70 | /// <summary>
|
---|
71 | /// Create empty double array of specific size
|
---|
72 | /// </summary>
|
---|
73 | /// <param name="size">(Empty-) size of new empty array</param>
|
---|
74 | /// <returns>Empty array</returns>
|
---|
75 | public static ILRetArray<T> empty<T>(params int[] size) {
|
---|
76 | ILSize newDims = new ILSize(size);
|
---|
77 | if (newDims.NumberOfElements > 0)
|
---|
78 | throw new ILArgumentException("the 'size' parameter must define an empty array size");
|
---|
79 | return new ILRetArray<T>(newDims);
|
---|
80 | }
|
---|
81 | /// <summary>
|
---|
82 | /// Create empty array of size [0,0] and arbitrary element type
|
---|
83 | /// </summary>
|
---|
84 | /// <returns>Empty array</returns>
|
---|
85 | public static ILRetArray<T> empty<T>() {
|
---|
86 | return new ILRetArray<T>(ILSize.Empty00);
|
---|
87 | }
|
---|
88 | /// <summary>
|
---|
89 | /// Create empty double array of specific size
|
---|
90 | /// </summary>
|
---|
91 | /// <param name="size">(Empty-) size of new empty array</param>
|
---|
92 | /// <returns>Empty array</returns>
|
---|
93 | public static ILRetArray<double> empty(ILSize size) {
|
---|
94 | if (size.NumberOfElements > 0)
|
---|
95 | throw new ILArgumentException("the 'size' parameter must define an empty array size");
|
---|
96 | return new ILRetArray<double>(size);
|
---|
97 | }
|
---|
98 | /// <summary>
|
---|
99 | /// Create empty double array of specific size
|
---|
100 | /// </summary>
|
---|
101 | /// <param name="size">(Empty-) size of new empty array</param>
|
---|
102 | /// <returns>Empty array</returns>
|
---|
103 | public static ILRetArray<double> empty(params int[] size) {
|
---|
104 | ILSize newDims = new ILSize(size);
|
---|
105 | if (newDims.NumberOfElements > 0)
|
---|
106 | throw new ILArgumentException("the 'size' parameter must define an empty array size");
|
---|
107 | return new ILRetArray<double>(newDims);
|
---|
108 | }
|
---|
109 | /// <summary>
|
---|
110 | /// Create new empty array, used for array class members
|
---|
111 | /// </summary>
|
---|
112 | /// <typeparam name="T">Element type</typeparam>
|
---|
113 | /// <returns>Empty array which can afterwards be used for arbitrary assignements (Assign(), or 'array.A = ..' assignements)</returns>
|
---|
114 | /// <remarks>The array returned will be an empty array initially. Its main purpose is to provide
|
---|
115 | /// a persistant array initialization. The array will not be disposed after leaving the current scope
|
---|
116 | /// and can therefore be utilized for initializing class attributes. After initialization, use the 'ILArray.A = ...' property (C#)
|
---|
117 | /// or the ILArray.Assign() function to assign new values to the array.</remarks>
|
---|
118 | public static ILArray<T> returnType<T>() {
|
---|
119 | return new ILArray<T>(new ILDenseStorage<T>(ILSize.Empty00), false);
|
---|
120 | }
|
---|
121 |
|
---|
122 | }
|
---|
123 | }
|
---|