forked from SciSharp/Numpy.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumPy.reshape.cs
More file actions
52 lines (51 loc) · 2.06 KB
/
NumPy.reshape.cs
File metadata and controls
52 lines (51 loc) · 2.06 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Numpy;
using Numpy.Models;
using Python.Runtime;
namespace Numpy
{
/// <summary>
/// Manual type conversions
/// </summary>
public static partial class np
{
/// <summary>
/// Gives a new shape to an array without changing its data.
///
/// Notes
///
/// It is not always possible to change the shape of an array without
/// copying the data. If you want an error to be raised when the data is copied,
/// you should assign the new shape to the shape attribute of the array:
///
/// The order keyword gives the index ordering both for fetching the values
/// from a, and then placing the values into the output array.
/// For example, let’s say you have an array:
///
/// You can think of reshaping as first raveling the array (using the given
/// index order), then inserting the elements from the raveled array into the
/// new array using the same kind of index ordering as was used for the
/// raveling.
/// </summary>
/// <param name="a">The array to reshape</param>
/// <param name="newshape">
/// The new shape should be compatible with the original shape. If
/// an integer, then the result will be a 1-D array of that length.
/// One shape dimension can be -1. In this case, the value is
/// inferred from the length of the array and remaining dimensions.
/// </param>
/// <returns>
/// This will be a new view object if possible; otherwise, it will
/// be a copy. Note there is no guarantee of the memory layout (C- or
/// Fortran- contiguous) of the returned array.
/// </returns>
public static NDarray reshape(NDarray a, params int[] newshape)
{
return NumPy.Instance.reshape(a, new Shape(newshape));
}
}
}