8000 Rewrite of the library by Nucs · Pull Request #336 · SciSharp/NumSharp · GitHub
[go: up one dir, main page]

Skip to content

Rewrite of the library #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 355 commits into from
Aug 6, 2019
Merged
Changes from 1 commit
Commits
Show all changes
355 commits
Select commit Hold shift + click to select a range
6e0caed
Revamped np.random.permutation
Nucs Jul 23, 2019
4ad8b9f
Revamped np.random.rand to support slicing
Nucs Jul 23, 2019
30c68e3
Revamped np.itemset and np.repeat
Nucs Jul 23, 2019
7abf0e0
Added Shape.GetAxis
Nucs Jul 23, 2019
7e87a63
WIP: ndarray.ravel()
Nucs Jul 23, 2019
426d567
Revamped Default.All
Nucs Jul 23, 2019
00ed83a
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 23, 2019
b66339b
Fixed Default.Sum's compilation
Nucs Jul 23, 2019
4da7667
Reformatted IArraySlice, NDArray<T>
Nucs Jul 23, 2019
3b6aeb4
Revamped np.random.shuffle, changed np.random.permutation
Nucs Jul 23, 2019
a8fe494
Added support for NDArray.GetEnumerator() when shape is sliced.
Nucs Jul 24, 2019
0231b48
Added explicit cast to string for NDArray.
N 8000 ucs Jul 24, 2019
84383a3
Revamped np.squeeze
Nucs Jul 24, 2019
2d3a992
Fixed np.expand_dims
Nucs Jul 24, 2019
49d58ba
Documentation for np.fromfile and np.tofile
Nucs Jul 24, 2019
b144047
Added support for casting a sliced NDArray
Nucs Jul 24, 2019
ad50631
Revamped np.vstack
Nucs Jul 24, 2019
807cf9f
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Jul 24, 2019
5f4707a
fixed merge
henon Jul 24, 2019
e24a11e
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Jul 24, 2019
0477eb7
Added np.full, np.full_like, np.empty, np.empty_like. Revamped np.one…
Nucs Jul 24, 2019
7425e40
slicing: nested slicing is working
henon Jul 24, 2019
6c1d331
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Jul 24, 2019
6e4fcf1
slicing: nested slicing test 1D passes
henon Jul 24, 2019
104d14f
Fixed UnmanagedStorage casting to wrong dtype.
Nucs Jul 24, 2019
ab743f3
slicing: 2D test passes
henon Jul 25, 2019
202692a
slicing: nested 2D slicing test passes
henon Jul 25, 2019
cb87c56
NDArray: fixed GetData of sliced arrays
henon Jul 25, 2019
627dd7b
Revamped np.ravel, removed IStorage.AsArray, Added UnmanagedStorage.C…
Nucs Jul 25, 2019
38f1cb5
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 25, 2019
6ff915c
Added Shape.GetOffset
Nucs Jul 25, 2019
a9ad24f
Improved support for sliced arrays, read description
Nucs Jul 25, 2019
dd1d322
Renamed GetDimIndexOutShape to GetCoordinates
Nucs Jul 25, 2019
60de505
Renamed GetOffset to TransformOffset
Nucs Jul 25, 2019
1d1ea5a
Renamed GetOffset to TransformOffset
Nucs Jul 25, 2019
72c6ad5
Renamed GetIndexInShape to GetOffset
Nucs Jul 25, 2019
9acb4ca
Cosmetic changes
Nucs Jul 25, 2019
e895696
Added generic ArraySlice<T>.Allocate and ArraySlice.Allocate<T>
Nucs Jul 25, 2019
92993b0
Added ArraySlice.CopyTo overloads
Nucs Jul 25, 2019
b2444b7
Shape.GetDimIndexOutShape: sliced shape support (untested)
henon Jul 25, 2019
4bc29d6
slicing: reduce to scalar works
henon Jul 25, 2019
dc5ce9d
slice: dimensionality reduction works in general (some cases are stil…
henon Jul 25, 2019
054482d
slicing: fixed slicing with nested dimensionality reduction
henon Jul 26, 2019
b71fb16
UnmanagedStorage: all slicing tests are passing!
henon Jul 26, 2019
88cf525
Added endCallback to NDIndexArrayIncrementor
Nucs Jul 26, 2019
c2737cb
Added UnmanagedStorage.SetAtIndexUnsafe and fixed SetAtIndex<T>
Nucs Jul 26, 2019
586625f
Added np.find_common_type(string[]) for regen generation.
Nucs Jul 26, 2019
2572942
Update NDArray.Indexing.cs
Nucs Jul 26, 2019
f39f9d5
Reformatted and micro-opt of Shape
Nucs Jul 26, 2019
918b088
Added internal Operator which provides mathops between all known types.
Nucs Jul 26, 2019
da6eacc
Revamped np.eye and added np.identity
Nucs Jul 26, 2019
cb5ee8c
Fixed NDArray constructor not using parameter
Nucs Jul 26, 2019
aaa06d1
Added missing NDArray.GetValue<T>(int[])
Nucs Jul 26, 2019
3dcae1a
Added NDArray.flat property
Nucs Jul 26, 2019
e62bf8d
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 26, 2019
d17eecb
fixed merging of slices with index-slices
henon Jul 26, 2019
360d8f8
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Jul 26, 2019
75970d2
Added NDIterator<T> and NDIterator with slicing support
Nucs Jul 26, 2019
05e313d
slicing: fixed indexing in reduced slice
henon Jul 26, 2019
1aeeefa
Fixed handling scalar in NDIndexArrayIncrememntor
Nucs Jul 26, 2019
47c0e1b
Added guards for NDIterators and fixed support for scalar
Nucs Jul 26, 2019
777bd1e
Create MultiIterator.cs
Nucs Jul 26, 2019
a52cd81
Changed UnmanagedStorage.CloneData to use NDIterator
Nucs Jul 26, 2019
99fba51
NDArray.ToString() uses NDIterator
Nucs Jul 26, 2019
00a7ce9
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 26, 2019
9a11d8e
NDArray: fixed slicing related bugs
henon Jul 26, 2019
09e2a6f
Refactored NDArray.cs and directed all methods to use storage.
Nucs Jul 26, 2019
f3a8f74
Revamped NDArray.view(...)
Nucs Jul 26, 2019
b44ade3
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 26, 2019
b0097e8
Fixed UnmanagedStorage.Alias
Nucs Jul 26, 2019
2f72930
Fixed UnmanagedStorage.Alias again.
Nucs Jul 26, 2019
1870ac8
Shape: fixed another slicing related bug
henon Jul 26, 2019
a87610b
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Jul 26, 2019
de0b9e8
Revamped np.reshape
Nucs Jul 26, 2019
1493fce
Added SetT(T, int[]) to NDArray and UnmanagedStorage
Nucs Jul 26, 2019
bacbc23
NDArray.Indexing.Test: fixed some tests
henon Jul 26, 2019
bedd477
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Jul 26, 2019
a1195c5
Fixed np.random.randint
Nucs Jul 26, 2019
665a1fc
Commented out Default.Transpose
Nucs Jul 26, 2019
fd9e03c
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 26, 2019
21f798b
added an ignored test for reshaping sliced arrays which is not suppor…
henon Jul 26, 2019
230b0e7
Fixed System.Array allocation in NDArray when shape is default
Nucs Jul 26, 2019
3e60dbb
Fixed various unit tests
Nucs Jul 26, 2019
31ab13d
Fixed NDOffsetIncrementor to return first, move next after.
Nucs Jul 26, 2019
1af1afa
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Jul 26, 2019
9b87de4
Revamped Array (non-generic) to NDArray conversion
Nucs Jul 26, 2019
2d86f68
Changed System.Array allocation in UnmanagedStorage to use Shape.Extr…
Nucs Jul 26, 2019
e7e0138
Reformatted Shape.cs and added docs
Nucs Jul 26, 2019
a0f46ac
Added Converts.cs, provides various methods related to System.Convert
Nucs Jul 27, 2019
66df528
Added ViewInfo.Clone()
Nucs Jul 27, 2019
f1435f8
Changed ndarray.itemset, np.asscalar, np.full to accept ValueType ins…
Nucs Jul 27, 2019
b491a45
Added to Shape.Clone a parameter 'unview'
Nucs Jul 27, 2019
d9d0139
Fixed new Shape(Shape other)
Nucs Jul 27, 2019
69758fe
Fixed Shape slicing not returning proper scalar shape.
Nucs Jul 27, 2019
4a333da
Shape micro-opts
Nucs Jul 27, 2019
d31e1ee
Finished NDArray.GetData, NDArray.SetData and NDIterators, Revamped n…
Nucs Jul 27, 2019
d5ec02b
Reformatted NDArray.cs
Nucs Jul 27, 2019
4b48149
Perf-opt Slice
Nucs Jul 27, 2019
ad31ca6
Added Slice++ and Slice-- operators.
Nucs Jul 27, 2019
1e15602
Created NDCoordinatesAxisIncrementor to handle axis iteration.
Nucs Jul 27, 2019
07c8323
Renamed NDIndexArrayIncrementor to NDCoordinatesIncrementor
Nucs Jul 27, 2019
a695416
Moved all incrementors to NumSharp.Core/Utilities/Incrementors and ad…
Nucs Jul 27, 2019
6f96e61
Moved all iterators to NumSharp.Core/Backend/Iterators/
Nucs Jul 27, 2019
db13271
Changed NDArray.Scalar from accepting object to ValueType.
Nucs Jul 27, 2019
92ab2c2
Fixed invalid shape handling.
Nucs Jul 27, 2019
76f681b
NDarray`1 minor perf-opt
Nucs Jul 27, 2019
0dddb3e
Fixed castings of object to ValueType
Nucs Jul 27, 2019
b5130cd
Fixed NDIterator not moving next properly when auto-resetting as a ve…
Nucs Jul 27, 2019
8120bc7
Moved DecimalEx.cs
Nucs Jul 27, 2019
2d1c3c2
Reverted NDArray.Scalar from accepting ValueType
Nucs Jul 27, 2019
4d27fdd
Added NDArray.Scalar(ValueType)
Nucs Jul 27, 2019
8eb75e4
Added fast internal np.squeeze methods.
Nucs Jul 27, 2019
4fb9f9b
Added Default.ReduceAdd, Revamped np.sum/DefaultEngine.sum
Nucs Jul 27, 2019
5692913
Fixed various unit tests
Nucs Jul 28, 2019
c146fee
Update IncorrectTypeException.cs
Nucs Jul 28, 2019
21e2dd6
Added IUnmanagedMemoryBlock
Nucs Jul 28, 2019
0978902
Perf-opts for Default.Broadcasting and added more optimized overloads.
Nucs Jul 28, 2019
d0fbbd7
Added additional overloads for np.full
Nucs Jul 28, 2019
be112a9
Added NPTypeCode extensions: GetAccumulatingType, GetComputingType
Nucs Jul 28, 2019
aaff04c
Added np.mean (full axis and nd support), Fixed np.sum return type re…
Nucs Jul 28, 2019
311584b
Revamped np.asanyarray
Nucs Jul 28, 2019
46a798d
Added NDArray.GetNDArrays
Nucs Jul 28, 2019
21e0f9e
Added guard for empty slicing.
Nucs Jul 28, 2019
82caf76
Added NDCoordinatesLeftToAxisIncrementor.
Nucs Jul 28, 2019
d397238
Minor changes
Nucs Jul 28, 2019
b3889f5
Fixed NDArray[Slice[]] setter.
Nucs Jul 28, 2019
fead9f5
Revamped np.concatenate
Nucs Jul 28, 2019
61c0343
Renamed SetData<T> and SetData(ValueType) to SetValue<T> and SetValue…
Nucs Jul 29, 2019
1437242
Revamped NDArray.ToMultiDimArray<T>()
Nucs Jul 29, 2019
2ee18d0
Added overloads for np.concatenate
Nucs Jul 29, 2019
190e0d9
Added GetPinnableReference for Reference class.
Nucs Jul 29, 2019
8d4cf37
Fixed np.concatenate.Test compilation.
Nucs Jul 29, 2019
8dd084e
Added support for SetData(object) when object is System.Array
Nucs Jul 29, 2019
e83f8c7
Fixed SetData(IArraySlice) to work properly with sliced destinition.
Nucs Jul 29, 2019
c705702
Added various CopyTo methods to UnmanagedStorage.
Nucs Jul 29, 2019
2b2c097
Added UnmanagedStorage.Copyto to NDArray.
Nucs Jul 29, 2019
3497c39
Added NDArray.typecode
Nucs Jul 29, 2019
5a30937
Added public unsafe methods for NDArray under property NDArray.Unsafe
8000 Nucs Jul 29, 2019
b779864
Fixed compilation due to minor errors
Nucs Jul 29, 2019
e2b24b6
renamed regen array supported_currently_supported to supported_dtypes…
Nucs Jul 29, 2019
88752ab
Moved all iterators from NumSharp.Backend to NumSharp namespace.
Nucs Jul 29, 2019
fb2b175
Added NDIterator.size field
Nucs Jul 29, 2019
228a2f0
Added System.Runtime.CompilerServices.Unsafe package.
Nucs Jul 29, 2019
d95260f
Removed unused nuget references.
Nucs Jul 29, 2019
e74fdba
Removed unused projects
Nucs Jul 29, 2019
db95da7
Change System.Runtime.CompilerServices.Unsafe to 4.5.2
Nucs Jul 29, 2019
ec366e6
Implement mgrid
JetstreamRoySprowl Jul 30, 2019
1746106
Implement missing dimension reshape, incomplete implementation of amax
JetstreamRoySprowl Jul 30, 2019
1a9c50e
string workround.
Oceania2018 Jul 31, 2019
d3ced0d
perf-ops for NDArray.Equals impl
Nucs Jul 31, 2019
9f58b25
swapped between NDArray.mgrid and np.mgrid
Nucs Jul 31, 2019
7818bff
Added docs for np.mgrid[...]
Nucs Jul 31, 2019
258d0a8
Redirected all nd.reshape to use inference of -1 shape.
Nucs Jul 31, 2019
47fdda5
Added unit tests for nd.reshape incl. -1 indice support.
Nucs Jul 31, 2019
60d4361
Revamped np.amax and np.amin
Nucs Jul 31, 2019
981d6e2
Merge pull request #323 from JetstreamRoySprowl/unmanaged-bytes-storage
Nucs Jul 31, 2019
424ea20
Added support for np.arange negative step
Nucs Jul 31, 2019
c2101f1
Fixed nd.reshape(...) guards
Nucs Jul 31, 2019
a83a3f6
Added Arrays.Insert and Arrays.AppendAt
Nucs Jul 31, 2019
6c2ed8f
Added DefaultEngine.Broadcast(NDArray[])
Nucs Jul 31, 2019
a715f90
Fixed NDArray alias constructors.
Nucs Jul 31, 2019
0a8fb3c
Added support for most cases of ndarray[NDArray[]]
Nucs Jul 31, 2019
f5f4ff4
Fixed ToString in some cases of char dtype
Nucs Jul 31, 2019
3fd99a8
C# code generator in Python for generating unit test cases
JetstreamRoySprowl Jul 31, 2019
f3031cf
Cleaned up Default.Broadcast(...)
Nucs Jul 31, 2019
5c4160a
Merge pull request #324 from JetstreamRoySprowl/unmanaged-bytes-storage
Nucs Jul 31, 2019
6ca68a9
fixed broadcasting of sliced arrays
henon Aug 1, 2019
9cc6892
Revamped pooling for scalar values
Nucs Aug 1, 2019
d937668
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Aug 1, 2019
53ec765
Minor perf-op to UnmanagedMemoryBlock
Nucs Aug 1, 2019
981995e
Removed redundant casts in np.amax and np.amin
Nucs Aug 1, 2019
f222f70
Fixed compilation
Nucs Aug 1, 2019
897bbc7
Fixed compilation for unit tests and benchmark proj.
Nucs Aug 1, 2019
bb9b9b8
Added np.argmax, np.argmin
Nucs Aug 1, 2019
070b1b4
Revamped np.prod
Nucs Aug 1, 2019
0889bbb
Fixed np.prod return type resolve
Nucs Aug 1, 2019
0e3a753
Implement exp()
JetstreamRoySprowl Aug 1, 2019
7076e8a
Add a sliced unit test to exp()
JetstreamRoySprowl Aug 1, 2019
244ba5b
Merge pull request #327 from JetstreamRoySprowl/unmanaged-bytes-storage
Nucs Aug 1, 2019
2cae565
Added optimized Converts.ChangeType(object, NPTypeCode)
Nucs Aug 1, 2019
7610aef
Added DecimalEx.Abs(...)
Nucs Aug 1, 2019
83b0358
Fixed NDArray.prod accidently being static
Nucs Aug 1, 2019
a3b2cc7
Added np.std, more performance optimization and bug fixes
Nucs Aug 2, 2019
7a60a99
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Aug 2, 2019
5dbc79a
Fixed reshaping
Nucs Aug 2, 2019
6daf944
Fixed memory corruption due to shared static strides array.
Nucs Aug 2, 2019
e93fdcf
Added np.var
Nucs Aug 2, 2019
67382ef
Minor file renames and location change
Nucs Aug 2, 2019
85ebd5e
Make FromMultiDimArray and FromJaggedArray static
JetstreamRoySprowl Aug 2, 2019
a5f08c8
Merge pull request #328 from JetstreamRoySprowl/unmanaged-bytes-storage
Nucs Aug 2, 2019
d2db945
Merge branch 'unmanaged-bytes-storage' of https://github.com/SciSharp…
Nucs Aug 2, 2019
bf39adc
Minor perfops in np.concatenate
Nucs Aug 2, 2019
3d91111
Implement hstack
JetstreamRoySprowl Aug 2, 2019
ed01638
Added np.atleast_1d, np.atleast_2d, np.atleast_3d
Nucs Aug 2, 2019
a096212
Fixed documentation, added guards and perf-opped NDArray.hstack
Nucs Aug 2, 2019
338eb6f
Made np.asanyarray dtype argument as default null.
Nucs Aug 2, 2019
9584e37
Removed IComparable<Shape>, IComparable from Shape.cs
Nucs Aug 2, 2019
8a540d6
Optimization in NDArray.Equals and np.are_equal
Nucs Aug 2, 2019
2bce2fd
Added fluent assertion extension for NDArray and Shape.
Nucs Aug 2, 2019
aae7c4b
Added significant optimization by avoiding np's slice when memory-sli…
Nucs Aug 2, 2019
84c7dee
Added handle case in slicing when all slices are select-all.
Nucs Aug 2, 2019
8fa41dc
Allow negative axis spec on expand_dims
JetstreamRoySprowl Aug 3, 2019
be33b39
Implement VStack
JetstreamRoySprowl Aug 3, 2019
e4dd045
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
JetstreamRoySprowl Aug 3, 2019
acbd861
Added todo for StackedMemoryPool
Nucs Aug 3, 2019
af80dab
Added dstack, added np.atleast_nd to dstack,vstack and hstack
Nucs Aug 3, 2019
3e9d770
Added null check in NDArray.Equals
Nucs Aug 3, 2019
f939e85
Revamped np.hstack, np.vstack and np.dstack
Nucs Aug 3, 2019
2162fdd
Added np.stack
Nucs Aug 3, 2019
305d8f8
Added np.abs, np.sqrt, np.tan/h, np.sin/h, np.cos/h
Nucs Aug 3, 2019
c43ed94
reshaping of slices and slicing of reshaped slices
henon Aug 3, 2019
189c07f
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Aug 3, 2019
f57ecda
Changed NDOffsetIncrementor to accept only Shape.
Nucs Aug 3, 2019
8c71631
Fixed compilation of unittests
Nucs Aug 3, 2019
82931a4
Fixed np.sum's return type resolving
Nucs Aug 3, 2019
77765e3
Fixed Iterators benchmark
Nucs Aug 3, 2019
f4813ae
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Aug 3, 2019
97eea40
Shape.IsRecursive: minor change
henon Aug 3, 2019
f55ffe0
Merge remote-tracking branch 'origin/unmanaged-bytes-storage' into un…
henon Aug 3, 2019
8fa797d
NDOffsetIncrementor: added slicing support
henon Aug 3, 2019
6be85fb
Added np.cumsum
Nucs Aug 3, 2019
18c09b4
Fixed compilation
Nucs Aug 3, 2019
f54feba
Merge branch 'unmanaged-bytes-storage' into pr/331
Nucs Aug 3, 2019
191c795
Fixed GetView() when all slices are Slice.All
Nucs Aug 3, 2019
188a3a0
NDArray.ToString(): minor change
Nucs Aug 3, 2019
fbc04ea
slicing: fixed a bug with reshaped slices
henon Aug 3, 2019
5740e34
NDIterator: minor change
henon Aug 3, 2019
1acf965
Added support for negative coordinates get and removed NDArray.GetDat…
Nucs Aug 3, 2019
7accaf3
Changed any internal methods/fields/properties to protected internal
Nucs Aug 3, 2019
0d67d50
added The Ultimate SliceReshapedSlicedReshapedSlicedArray test
henon Aug 3, 2019
c5310cd
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Aug 3, 2019
2dc35c0
Merge remote-tracking branch 'origin/unmanaged-bytes-storage' into un…
henon Aug 3, 2019
570490f
Merge remote-tracking branch 'upstream/unmanaged-bytes-storage' into …
henon Aug 3, 2019
b62104c
Revert "NDIterator: minor change"
henon Aug 3, 2019
569ea62
Shape.GetSubshape uses Shape.GetOffset
henon Aug 3, 2019
8af8112
Shape: fixed ExpandDimensions for sliced shapes
henon Aug 3, 2019
41a7f98
Shape: fixed ExpandDimensions for sliced shapes (added numpy proof)
henon Aug 3, 2019
e8712ad
fixed merge breakage in NDArray.GetNDArrays
henon Aug 3, 2019
e56c3e9
fixed merge breakage in NDArray.GetNDArrays
henon Aug 3, 2019
d458dba
moved slice notation tests to be with the other Shape and Slice tests
henon Aug 5, 2019
91fe77c
Slice: implemented handling of negative indices
henon Aug 5, 2019
139224c
slicing: added tests for negative indexing
henon Aug 5, 2019
fa11725
Broadcast slice (#335)
Nucs Aug 6, 2019
48a9959
Fixed merging mistake in SliceDef
Nucs Aug 6, 2019
6925360
Fixed #334
Nucs Aug 6, 2019
3fe6720
Added np.reshape_unsafe that allows reshaping of broadcasted shapes.
Nucs Aug 6, 2019
45867b2
Major cleanup and moving files around
Nucs Aug 6, 2019
d6077a3
Removed unused using directives.
Nucs Aug 6, 2019
15b538d
Added Eli Belash to authors list
Nucs Aug 6, 2019
9014e30
Merge branch 'master' into unmanaged-bytes-storage
Nucs Aug 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revamped np.random.rand to support slicing
  • Loading branch information
Nucs committed Jul 23, 2019
commit 4ad8b9f13aa94c72b65a132c7ddea88c9643b977
16 changes: 10 additions & 6 deletions src/NumSharp.Core/RandomSampling/np.random.rand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ public NDArray rand(params int[] size)
/// </summary>
public NDArray rand(Shape shape)
{
NDArray ndArray = new NDArray(typeof(double), shape);
ArraySlice<double> numArray = ndArray.Data<double>();
for (int index = 0; index < ndArray.size; ++index)
NDArray ret = new NDArray(typeof(double), shape, false);

unsafe
{
numArray[index] = randomizer.NextDouble();
var addr = (double*)ret.Address;
var incr = new NDIndexArrayIncrementor(ref shape);
do
{
*(addr + shape.GetIndexInShape(incr.Index)) = randomizer.NextDouble();
} while (incr.Next() != null);
}

ndArray.ReplaceData(numArray);
return ndArray;
return ret;
}

/// <summary>
Expand Down
0