forked from SciSharp/NumSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnp.empty.cs
More file actions
69 lines (63 loc) · 3.56 KB
/
np.empty.cs
File metadata and controls
69 lines (63 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using NumSharp.Backends;
namespace NumSharp
{
public static partial class np
{
/// <summary>
/// Return a new array of given shape and type, without initializing entries.
/// </summary>
/// <param name="shapes">Shape of the empty array, e.g., (2, 3) or 2.</param>
/// <returns>Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.</returns>
/// <remarks>https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html</remarks>
public static NDArray empty(params int[] shapes)
{
return empty(shapes, null);
}
/// <summary>
/// Return a new array of given shape and type, without initializing entries.
/// </summary>
/// <param name="shapes">Shape of the empty array, e.g., (2, 3) or 2.</param>
/// <returns>Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.</returns>
/// <remarks>https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html</remarks>
public static NDArray empty<T>(params int[] shapes)
{
return empty(shapes, typeof(T));
}
/// <summary>
/// Return a new array of given shape and type, without initializing entries.
/// </summary>
/// <param name="shape">Shape of the empty array, e.g., (2, 3) or 2.</param>
/// <param name="dtype">Desired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.</param>
/// <returns>Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.</returns>
/// <remarks>https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html</remarks>
public static NDArray empty(Shape shape, Type dtype)
{
return empty(shape, (dtype ?? typeof(double)).GetTypeCode());
}
/// <summary>
/// Return a new array of given shape and type, without initializing entries.
/// </summary>
/// <param name="shape">Shape of the empty array, e.g., (2, 3) or 2.</param>
/// <param name="typeCode">Desired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.</param>
/// <returns>Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.</returns>
/// <remarks>https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html</remarks>
public static NDArray empty(Shape shape, NPTypeCode typeCode)
{
if (typeCode == NPTypeCode.Empty)
throw new ArgumentNullException(nameof(typeCode));
return new NDArray(typeCode, shape, false);
}
/// <summary>
/// Return a new array of given shape and type, without initializing entries.
/// </summary>
/// <param name="shape">Shape of the empty array, e.g., (2, 3) or 2.</param>
/// <param name="dtype">Desired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.</param>
/// <returns>Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.</returns>
/// <remarks>https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html</remarks>
public static NDArray empty(Shape shape)
{
return new NDArray(NPTypeCode.Double, shape, false);
}
}
}