Skip to content

Commit cd664f8

Browse files
committed
v0.7.0, Shape
1 parent aa570de commit cd664f8

21 files changed

+44
-54
lines changed

src/NumSharp.Core/Creation/NdArray.Eye.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public NDArray eye(int dim, int diagonalIndex = 0)
1616

1717
if((ndim == 1) && (dim != 1))
1818
{
19-
puffer = new NDArray(this.dtype, dim,dim);
19+
puffer = new NDArray(this.dtype, new Shape(dim, dim));
2020
}
2121
else
2222
{

src/NumSharp.Core/Creation/np.array.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static NDArray array(System.Drawing.Bitmap image)
4949

5050
public static NDArray array<T>(T[][] data)
5151
{
52-
var nd = new NDArray(typeof(T),data.Length,data[0].Length);
52+
var nd = new NDArray(typeof(T), new Shape(data.Length, data[0].Length));
5353

5454
for (int row = 0; row < data.Length; row++)
5555
{

src/NumSharp.Core/Generics/NDArrayGeneric.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public NDArray()
3535
Storage = new NDStorage(typeof(T));
3636
Storage.Allocate(this.dtype,new Shape(1),1);
3737
}
38-
public NDArray(IShape shape) : this()
38+
public NDArray(Shape shape) : this()
3939
{
4040
Storage = new NDStorage(typeof(T));
4141
Storage.Allocate(this.dtype, shape,1);

src/NumSharp.Core/Interfaces/IShape.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ public interface IShape
1313
int[] Dimensions {get;}
1414
int GetIndexInShape(params int[] select);
1515
int[] GetDimIndexOutShape(int select);
16-
int UniShape {get;}
17-
(int, int) BiShape {get;}
18-
(int, int, int) TriShape {get;}
1916
void ChangeTensorLayout(int order);
2017
void ReShape(params int[] dims);
2118
}

src/NumSharp.Core/Interfaces/IStorage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface IStorage : ICloneable
2929
/// storage shape for outside representation
3030
/// </summary>
3131
/// <value>numpys equal shape</value>
32-
IShape Shape {get;}
32+
Shape Shape {get;}
3333
/// <summary>
3434
/// column wise or row wise order
3535
/// </summary>
@@ -41,7 +41,7 @@ public interface IStorage : ICloneable
4141
/// <param name="dtype">storage data type</param>
4242
/// <param name="shape">storage data shape</param>
4343
/// <param name="tensorOrder">row or column wise</param>
44-
void Allocate(Type dtype, IShape shape, int tensorOrder = 1);
44+
void Allocate(Type dtype, Shape shape, int tensorOrder = 1);
4545
/// <summary>
4646
/// Allocate memory by Array and tensororder and deduce shape and dtype (default column wise)
4747
/// </summary>

src/NumSharp.Core/LinearAlgebra/NdArray.Dot.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public NDArray dot(NDArray nd2)
6060
int iterator = this.shape[1];
6161
int dim0 = this.shape[0];
6262
int dim1 = nd2.shape[1];
63-
64-
var prod = new NDArray(this.Storage.DType, dim0, dim1);
63+
64+
var prod = new NDArray(this.Storage.DType, new Shape(dim0, dim1));
6565

6666
Array nd1SystemArray = this.Storage.GetData();
6767

src/NumSharp.Core/LinearAlgebra/NdArray.QR.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public partial class NDArray
3434
RDouble[idx+jdx * n] = a[idx+jdx*n];
3535

3636

37-
var R = new NDArray(typeof(double),n,n);
37+
var R = new NDArray(typeof(double), new Shape(n, n));
3838

3939
R.Storage.SetData(RDouble);
4040

4141
int k = tau.Length;
4242

4343
LAPACK.dorgqr_(ref m, ref n,ref k ,a, ref lda, tau, work, ref lwork,ref info);
4444

45-
var Q = new NDArray(typeof(double),tau.Length,tau.Length);
45+
var Q = new NDArray(typeof(double), new Shape(tau.Length, tau.Length));
4646

4747
Q.Storage.Allocate(Q.Storage.DType,Q.Storage.Shape,2);
4848
Q.Storage.SetData(a);

src/NumSharp.Core/LinearAlgebra/NdArray.SVD.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public partial class NDArray
3838

3939
work = new double[lwork];
4040

41-
LAPACK.dgesvd_("ALL".ToCharArray(),"All".ToCharArray(),ref m, ref n, A, ref lda, s, u, ref ldu, vt, ref ldvt, work, ref lwork, ref info );
41+
LAPACK.dgesvd_("ALL".ToCharArray(),"All".ToCharArray(),ref m, ref n, A, ref lda, s, u, ref ldu, vt, ref ldvt, work, ref lwork, ref info );
4242

43-
var uNDArr = new NDArray(typeof(double),m,n);
44-
var vtNDArr = new NDArray(typeof(double),n,n);
45-
var sNDArr = new NDArray(typeof(double),n);
43+
var uNDArr = new NDArray(typeof(double), new Shape(m, n));
44+
var vtNDArr = new NDArray(typeof(double), new Shape(n, n));
45+
var sNDArr = new NDArray(typeof(double), n);
4646

4747
// set variables
4848
double[] uDouble = uNDArr.Storage.GetData<double>();

src/NumSharp.Core/NDStorage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class NDStorage : IStorage
2626
{
2727
protected Array _values;
2828
protected Type _DType;
29-
protected IShape _Shape;
29+
protected Shape _Shape;
3030
protected int _TensorLayout;
3131
protected void _ChangeRowToColumnLayout()
3232
{
@@ -192,7 +192,7 @@ public int DTypeSize
192192
/// storage shape for outside representation
193193
/// </summary>
194194
/// <value>numpys equal shape</value>
195-
public IShape Shape {get {return _Shape;}}
195+
public Shape Shape {get {return _Shape;}}
196196
/// <summary>
197197
/// column wise or row wise order
198198
/// </summary>
@@ -232,7 +232,7 @@ public NDStorage(object[] values)
232232
/// <param name="dtype">storage data type</param>
233233
/// <param name="shape">storage data shape</param>
234234
/// <param name="tensorOrder">row or column wise</param>
235-
public void Allocate(Type dtype, IShape shape, int tensorOrder = 1)
235+
public void Allocate(Type dtype, Shape shape, int tensorOrder = 1)
236236
{
237237
_DType = dtype;
238238
_Shape = shape;

src/NumSharp.Core/NdArray.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,11 @@ public NDArray(Array values ) : this(values.GetType().GetElementType())
121121
/// </summary>
122122
/// <param name="dtype">internal data type</param>
123123
/// <param name="shape">Shape of NDArray</param>
124-
public NDArray(Type dtype, IShape shape)
124+
public NDArray(Type dtype, Shape shape)
125125
{
126126
Storage = new NDStorage();
127127
Storage.Allocate(dtype,shape,1);
128128
}
129-
/// <summary>
130-
/// Constructor which initialize elements with 0
131-
/// type and dimensions are given.
132-
/// </summary>
133-
/// <param name="dtype">internal data type</param>
134-
/// <param name="shapes">dimensions</param>
135-
/// <returns></returns>
136-
public NDArray(Type dtype, params int[] shapes) : this(dtype, new Shape(shapes) )
137-
{
138-
}
139129

140130
public override int GetHashCode()
141131
{

0 commit comments

Comments
 (0)