From 4c3b919ccf75e64df1a59a9efac35f1130d772e5 Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Fri, 25 Sep 2026 09:03:52 +0530 Subject: [PATCH 1/3] feat: add float16 dtype support to ndarray/base/slice-assign --- .../base/slice-assign/benchmark/benchmark.js | 84 +++++++++++++++++++ .../base/slice-assign/docs/types/index.d.ts | 63 +++++++++++++- .../base/slice-assign/docs/types/test.ts | 2 + .../ndarray/base/slice-assign/test/test.js | 21 ++++- 4 files changed, 168 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/slice-assign/benchmark/benchmark.js index e104dbeed21d..45494431c65d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/benchmark/benchmark.js @@ -46,6 +46,7 @@ bench( format( '%s::0d,base', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -53,6 +54,7 @@ bench( format( '%s::0d,base', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [], 'row-major' ), baseZeros( 'float32', [], 'row-major' ), + baseZeros( 'float16', [], 'row-major' ), baseZeros( 'int32', [], 'row-major' ), baseZeros( 'complex128', [], 'row-major' ), baseZeros( 'generic', [], 'row-major' ) @@ -88,6 +90,7 @@ bench( format( '%s::0d,non-base', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -96,6 +99,7 @@ bench( format( '%s::0d,non-base', pkg ), function benchmark( b ) { y = [ zeros( [], { 'dtype': 'float64' } ), zeros( [], { 'dtype': 'float32' } ), + zeros( [], { 'dtype': 'float16' } ), zeros( [], { 'dtype': 'int32' } ), zeros( [], { 'dtype': 'complex128' } ), zeros( [], { 'dtype': 'generic' } ) @@ -132,6 +136,7 @@ bench( format( '%s::1d,base', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 2 ], 'row-major' ), baseEmpty( 'float32', [ 2 ], 'row-major' ), + baseEmpty( 'float16', [ 2 ], 'row-major' ), baseEmpty( 'int32', [ 2 ], 'row-major' ), baseEmpty( 'complex128', [ 2 ], 'row-major' ), baseEmpty( 'generic', [ 2 ], 'row-major' ) @@ -139,6 +144,7 @@ bench( format( '%s::1d,base', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2 ], 'row-major' ), baseZeros( 'float32', [ 2 ], 'row-major' ), + baseZeros( 'float16', [ 2 ], 'row-major' ), baseZeros( 'int32', [ 2 ], 'row-major' ), baseZeros( 'complex128', [ 2 ], 'row-major' ), baseZeros( 'generic', [ 2 ], 'row-major' ) @@ -174,6 +180,7 @@ bench( format( '%s::1d,non-base', pkg ), function benchmark( b ) { values = [ empty( [ 2 ], { 'dtype': 'float64' } ), empty( [ 2 ], { 'dtype': 'float32' } ), + empty( [ 2 ], { 'dtype': 'float16' } ), empty( [ 2 ], { 'dtype': 'int32' } ), empty( [ 2 ], { 'dtype': 'complex128' } ), empty( [ 2 ], { 'dtype': 'generic' } ) @@ -182,6 +189,7 @@ bench( format( '%s::1d,non-base', pkg ), function benchmark( b ) { y = [ zeros( [ 2 ], { 'dtype': 'float64' } ), zeros( [ 2 ], { 'dtype': 'float32' } ), + zeros( [ 2 ], { 'dtype': 'float16' } ), zeros( [ 2 ], { 'dtype': 'int32' } ), zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2 ], { 'dtype': 'generic' } ) @@ -218,6 +226,7 @@ bench( format( '%s::1d,base,reduced', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -225,6 +234,7 @@ bench( format( '%s::1d,base,reduced', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2 ], 'row-major' ), baseZeros( 'float32', [ 2 ], 'row-major' ), + baseZeros( 'float16', [ 2 ], 'row-major' ), baseZeros( 'int32', [ 2 ], 'row-major' ), baseZeros( 'complex128', [ 2 ], 'row-major' ), baseZeros( 'generic', [ 2 ], 'row-major' ) @@ -260,6 +270,7 @@ bench( format( '%s::1d,non-base,reduced', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -268,6 +279,7 @@ bench( format( '%s::1d,non-base,reduced', pkg ), function benchmark( b ) { y = [ zeros( [ 2 ], { 'dtype': 'float64' } ), zeros( [ 2 ], { 'dtype': 'float32' } ), + zeros( [ 2 ], { 'dtype': 'float16' } ), zeros( [ 2 ], { 'dtype': 'int32' } ), zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2 ], { 'dtype': 'generic' } ) @@ -304,6 +316,7 @@ bench( format( '%s::1d,base,broadcasted', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -311,6 +324,7 @@ bench( format( '%s::1d,base,broadcasted', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2 ], 'row-major' ), baseZeros( 'float32', [ 2 ], 'row-major' ), + baseZeros( 'float16', [ 2 ], 'row-major' ), baseZeros( 'int32', [ 2 ], 'row-major' ), baseZeros( 'complex128', [ 2 ], 'row-major' ), baseZeros( 'generic', [ 2 ], 'row-major' ) @@ -346,6 +360,7 @@ bench( format( '%s::1d,non-base,broadcasted', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -354,6 +369,7 @@ bench( format( '%s::1d,non-base,broadcasted', pkg ), function benchmark( b ) { y = [ zeros( [ 2 ], { 'dtype': 'float64' } ), zeros( [ 2 ], { 'dtype': 'float32' } ), + zeros( [ 2 ], { 'dtype': 'float16' } ), zeros( [ 2 ], { 'dtype': 'int32' } ), zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2 ], { 'dtype': 'generic' } ) @@ -390,6 +406,7 @@ bench( format( '%s::1d,base,out-of-bounds', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 1 ], 'row-major' ), baseEmpty( 'float32', [ 1 ], 'row-major' ), + baseEmpty( 'float16', [ 1 ], 'row-major' ), baseEmpty( 'int32', [ 1 ], 'row-major' ), baseEmpty( 'complex128', [ 1 ], 'row-major' ), baseEmpty( 'generic', [ 1 ], 'row-major' ) @@ -397,6 +414,7 @@ bench( format( '%s::1d,base,out-of-bounds', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2 ], 'row-major' ), baseZeros( 'float32', [ 2 ], 'row-major' ), + baseZeros( 'float16', [ 2 ], 'row-major' ), baseZeros( 'int32', [ 2 ], 'row-major' ), baseZeros( 'complex128', [ 2 ], 'row-major' ), baseZeros( 'generic', [ 2 ], 'row-major' ) @@ -432,6 +450,7 @@ bench( format( '%s::1d,non-base,out-of-bounds', pkg ), function benchmark( b ) { values = [ empty( [ 1 ], { 'dtype': 'float64' } ), empty( [ 1 ], { 'dtype': 'float32' } ), + empty( [ 1 ], { 'dtype': 'float16' } ), empty( [ 1 ], { 'dtype': 'int32' } ), empty( [ 1 ], { 'dtype': 'complex128' } ), empty( [ 1 ], { 'dtype': 'generic' } ) @@ -439,6 +458,7 @@ bench( format( '%s::1d,non-base,out-of-bounds', pkg ), function benchmark( b ) { y = [ zeros( [ 2 ], { 'dtype': 'float64' } ), zeros( [ 2 ], { 'dtype': 'float32' } ), + zeros( [ 2 ], { 'dtype': 'float16' } ), zeros( [ 2 ], { 'dtype': 'int32' } ), zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2 ], { 'dtype': 'generic' } ) @@ -475,6 +495,7 @@ bench( format( '%s::2d,base', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 2, 2 ], 'row-major' ), baseEmpty( 'float32', [ 2, 2 ], 'row-major' ), + baseEmpty( 'float16', [ 2, 2 ], 'row-major' ), baseEmpty( 'int32', [ 2, 2 ], 'row-major' ), baseEmpty( 'complex128', [ 2, 2 ], 'row-major' ), baseEmpty( 'generic', [ 2, 2 ], 'row-major' ) @@ -482,6 +503,7 @@ bench( format( '%s::2d,base', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2 ], 'row-major' ) @@ -517,6 +539,7 @@ bench( format( '%s::2d,non-base', pkg ), function benchmark( b ) { values = [ empty( [ 2, 2 ], { 'dtype': 'float64' } ), empty( [ 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2 ], { 'dtype': 'float16' } ), empty( [ 2, 2 ], { 'dtype': 'int32' } ), empty( [ 2, 2 ], { 'dtype': 'complex128' } ), empty( [ 2, 2 ], { 'dtype': 'generic' } ) @@ -524,6 +547,7 @@ bench( format( '%s::2d,non-base', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2 ], { 'dtype': 'generic' } ) @@ -560,6 +584,7 @@ bench( format( '%s::2d,base,reduced', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -567,6 +592,7 @@ bench( format( '%s::2d,base,reduced', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2 ], 'row-major' ) @@ -602,6 +628,7 @@ bench( format( '%s::2d,non-base,reduced', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -609,6 +636,7 @@ bench( format( '%s::2d,non-base,reduced', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2 ], { 'dtype': 'generic' } ) @@ -645,6 +673,7 @@ bench( format( '%s::2d,base,broadcasted', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -652,6 +681,7 @@ bench( format( '%s::2d,base,broadcasted', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2 ], 'row-major' ) @@ -687,6 +717,7 @@ bench( format( '%s::2d,non-base,broadcasted', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -694,6 +725,7 @@ bench( format( '%s::2d,non-base,broadcasted', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2 ], { 'dtype': 'generic' } ) @@ -730,6 +762,7 @@ bench( format( '%s::2d,base,out-of-bounds', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 1, 1 ], 'row-major' ), baseEmpty( 'float32', [ 1, 1 ], 'row-major' ), + baseEmpty( 'float16', [ 1, 1 ], 'row-major' ), baseEmpty( 'int32', [ 1, 1 ], 'row-major' ), baseEmpty( 'complex128', [ 1, 1 ], 'row-major' ), baseEmpty( 'generic', [ 1, 1 ], 'row-major' ) @@ -737,6 +770,7 @@ bench( format( '%s::2d,base,out-of-bounds', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2 ], 'row-major' ) @@ -772,6 +806,7 @@ bench( format( '%s::2d,non-base,out-of-bounds', pkg ), function benchmark( b ) { values = [ empty( [ 1, 1 ], { 'dtype': 'float64' } ), empty( [ 1, 1 ], { 'dtype': 'float32' } ), + empty( [ 1, 1 ], { 'dtype': 'float16' } ), empty( [ 1, 1 ], { 'dtype': 'int32' } ), empty( [ 1, 1 ], { 'dtype': 'complex128' } ), empty( [ 1, 1 ], { 'dtype': 'generic' } ) @@ -779,6 +814,7 @@ bench( format( '%s::2d,non-base,out-of-bounds', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2 ], { 'dtype': 'generic' } ) @@ -815,6 +851,7 @@ bench( format( '%s::3d,base', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 2, 2, 2 ], 'row-major' ), baseEmpty( 'float32', [ 2, 2, 2 ], 'row-major' ), + baseEmpty( 'float16', [ 2, 2, 2 ], 'row-major' ), baseEmpty( 'int32', [ 2, 2, 2 ], 'row-major' ), baseEmpty( 'complex128', [ 2, 2, 2 ], 'row-major' ), baseEmpty( 'generic', [ 2, 2, 2 ], 'row-major' ) @@ -822,6 +859,7 @@ bench( format( '%s::3d,base', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) @@ -857,6 +895,7 @@ bench( format( '%s::3d,non-base', pkg ), function benchmark( b ) { values = [ empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2, 2 ], { 'dtype': 'float16' } ), empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -864,6 +903,7 @@ bench( format( '%s::3d,non-base', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -900,6 +940,7 @@ bench( format( '%s::3d,base,reduced', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -907,6 +948,7 @@ bench( format( '%s::3d,base,reduced', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) @@ -942,6 +984,7 @@ bench( format( '%s::3d,non-base,reduced', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -949,6 +992,7 @@ bench( format( '%s::3d,non-base,reduced', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -985,6 +1029,7 @@ bench( format( '%s::3d,base,broadcasted', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -992,6 +1037,7 @@ bench( format( '%s::3d,base,broadcasted', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) @@ -1027,6 +1073,7 @@ bench( format( '%s::3d,non-base,broadcasted', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -1034,6 +1081,7 @@ bench( format( '%s::3d,non-base,broadcasted', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1070,6 +1118,7 @@ bench( format( '%s::3d,base,out-of-bounds', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 1, 1, 1 ], 'row-major' ), baseEmpty( 'float32', [ 1, 1, 1 ], 'row-major' ), + baseEmpty( 'float16', [ 1, 1, 1 ], 'row-major' ), baseEmpty( 'int32', [ 1, 1, 1 ], 'row-major' ), baseEmpty( 'complex128', [ 1, 1, 1 ], 'row-major' ), baseEmpty( 'generic', [ 1, 1, 1 ], 'row-major' ) @@ -1077,6 +1126,7 @@ bench( format( '%s::3d,base,out-of-bounds', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2 ], 'row-major' ) @@ -1112,6 +1162,7 @@ bench( format( '%s::3d,non-base,out-of-bounds', pkg ), function benchmark( b ) { values = [ empty( [ 1, 1, 1 ], { 'dtype': 'float64' } ), empty( [ 1, 1, 1 ], { 'dtype': 'float32' } ), + empty( [ 1, 1, 1 ], { 'dtype': 'float16' } ), empty( [ 1, 1, 1 ], { 'dtype': 'int32' } ), empty( [ 1, 1, 1 ], { 'dtype': 'complex128' } ), empty( [ 1, 1, 1 ], { 'dtype': 'generic' } ) @@ -1119,6 +1170,7 @@ bench( format( '%s::3d,non-base,out-of-bounds', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1155,6 +1207,7 @@ bench( format( '%s::4d,base', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), + baseEmpty( 'float16', [ 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) @@ -1162,6 +1215,7 @@ bench( format( '%s::4d,base', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) @@ -1197,6 +1251,7 @@ bench( format( '%s::4d,non-base', pkg ), function benchmark( b ) { values = [ empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2, 2, 2 ], { 'dtype': 'float16' } ), empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1204,6 +1259,7 @@ bench( format( '%s::4d,non-base', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1240,6 +1296,7 @@ bench( format( '%s::4d,base,reduced', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -1247,6 +1304,7 @@ bench( format( '%s::4d,base,reduced', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) @@ -1282,6 +1340,7 @@ bench( format( '%s::4d,non-base,reduced', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -1289,6 +1348,7 @@ bench( format( '%s::4d,non-base,reduced', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1325,6 +1385,7 @@ bench( format( '%s::4d,base,broadcasted', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -1332,6 +1393,7 @@ bench( format( '%s::4d,base,broadcasted', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) @@ -1367,6 +1429,7 @@ bench( format( '%s::4d,non-base,broadcasted', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -1374,6 +1437,7 @@ bench( format( '%s::4d,non-base,broadcasted', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1410,6 +1474,7 @@ bench( format( '%s::4d,base,out-of-bounds', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'float32', [ 1, 1, 1, 1 ], 'row-major' ), + baseEmpty( 'float16', [ 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'int32', [ 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'complex128', [ 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'generic', [ 1, 1, 1, 1 ], 'row-major' ) @@ -1417,6 +1482,7 @@ bench( format( '%s::4d,base,out-of-bounds', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' ) @@ -1452,6 +1518,7 @@ bench( format( '%s::4d,non-base,out-of-bounds', pkg ), function benchmark( b ) { values = [ empty( [ 1, 1, 1, 1 ], { 'dtype': 'float64' } ), empty( [ 1, 1, 1, 1 ], { 'dtype': 'float32' } ), + empty( [ 1, 1, 1, 1 ], { 'dtype': 'float16' } ), empty( [ 1, 1, 1, 1 ], { 'dtype': 'int32' } ), empty( [ 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), empty( [ 1, 1, 1, 1 ], { 'dtype': 'generic' } ) @@ -1459,6 +1526,7 @@ bench( format( '%s::4d,non-base,out-of-bounds', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1495,6 +1563,7 @@ bench( format( '%s::5d,base', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), + baseEmpty( 'float16', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseEmpty( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) @@ -1502,6 +1571,7 @@ bench( format( '%s::5d,base', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) @@ -1537,6 +1607,7 @@ bench( format( '%s::5d,non-base', pkg ), function benchmark( b ) { values = [ empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float16' } ), empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1544,6 +1615,7 @@ bench( format( '%s::5d,non-base', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1580,6 +1652,7 @@ bench( format( '%s::5d,base,reduced', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -1587,6 +1660,7 @@ bench( format( '%s::5d,base,reduced', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) @@ -1622,6 +1696,7 @@ bench( format( '%s::5d,non-base,reduced', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -1629,6 +1704,7 @@ bench( format( '%s::5d,non-base,reduced', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1665,6 +1741,7 @@ bench( format( '%s::5d,base,broadcasted', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [], 'row-major' ), baseEmpty( 'float32', [], 'row-major' ), + baseEmpty( 'float16', [], 'row-major' ), baseEmpty( 'int32', [], 'row-major' ), baseEmpty( 'complex128', [], 'row-major' ), baseEmpty( 'generic', [], 'row-major' ) @@ -1672,6 +1749,7 @@ bench( format( '%s::5d,base,broadcasted', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) @@ -1707,6 +1785,7 @@ bench( format( '%s::5d,non-base,broadcasted', pkg ), function benchmark( b ) { values = [ empty( [], { 'dtype': 'float64' } ), empty( [], { 'dtype': 'float32' } ), + empty( [], { 'dtype': 'float16' } ), empty( [], { 'dtype': 'int32' } ), empty( [], { 'dtype': 'complex128' } ), empty( [], { 'dtype': 'generic' } ) @@ -1714,6 +1793,7 @@ bench( format( '%s::5d,non-base,broadcasted', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) @@ -1750,6 +1830,7 @@ bench( format( '%s::5d,base,out-of-bounds', pkg ), function benchmark( b ) { values = [ baseEmpty( 'float64', [ 1, 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'float32', [ 1, 1, 1, 1, 1 ], 'row-major' ), + baseEmpty( 'float16', [ 1, 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'int32', [ 1, 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'complex128', [ 1, 1, 1, 1, 1 ], 'row-major' ), baseEmpty( 'generic', [ 1, 1, 1, 1, 1 ], 'row-major' ) @@ -1757,6 +1838,7 @@ bench( format( '%s::5d,base,out-of-bounds', pkg ), function benchmark( b ) { y = [ baseZeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ), + baseZeros( 'float16', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ), baseZeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' ) @@ -1792,6 +1874,7 @@ bench( format( '%s::5d,non-base,out-of-bounds', pkg ), function benchmark( b ) { values = [ empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float64' } ), empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float32' } ), + empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'float16' } ), empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'int32' } ), empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ), empty( [ 1, 1, 1, 1, 1 ], { 'dtype': 'generic' } ) @@ -1799,6 +1882,7 @@ bench( format( '%s::5d,non-base,out-of-bounds', pkg ), function benchmark( b ) { y = [ zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/index.d.ts index 3a777912cbdd..3b9d3816a94a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; +import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, float16ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; import { MultiSlice } from '@stdlib/types/slice'; /** @@ -145,6 +145,67 @@ declare function sliceAssign( x: ndarray, y: float64ndarray, s: MultiSlice, stri */ declare function sliceAssign( x: ndarray, y: float32ndarray, s: MultiSlice, strict: boolean ): float32ndarray; +/** +* Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. +* +* ## Notes +* +* - The input array must be broadcast compatible with the output array view to which elements will be assigned. +* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). +* +* @param x - input array +* @param y - output array +* @param s - multi-slice object for the output array +* @param strict - boolean indicating whether to enforce strict bounds checking +* @returns output array +* +* @example +* var Slice = require( '@stdlib/slice/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var typedarray = require( '@stdlib/array/typed' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var ndzeros = require( '@stdlib/ndarray/zeros' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* // Define an input array: +* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float16' ); +* var shape = [ 3, 2 ]; +* var strides = [ 2, 1 ]; +* var offset = 0; +* +* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' ); +* // returns +* +* var sh = x.shape; +* // returns [ 3, 2 ] +* +* var arr = ndarray2array( x ); +* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* // Define an output array: +* var y = ndzeros( [ 2, 3, 2 ], { +* 'dtype': x.dtype +* }); +* +* // Create a slice: +* var s0 = null; +* var s1 = new Slice( null, null, -1 ); +* var s2 = new Slice( null, null, -1 ); +* var s = new MultiSlice( s0, s1, s2 ); +* // returns +* +* // Perform assignment: +* var out = sliceAssign( x, y, s, false ); +* // returns +* +* var bool = ( out === y ); +* // returns true +* +* arr = ndarray2array( y ); +* // returns [ [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ], [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] ] +*/ +declare function sliceAssign( x: ndarray, y: float16ndarray, s: MultiSlice, strict: boolean ): float16ndarray; + /** * Assigns element values from a broadcasted input ndarray to corresponding elements in an output ndarray view. * diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts index d4ee4ceb5e51..c0b8127461b1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts @@ -32,6 +32,7 @@ import sliceAssign = require( './index' ); sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, false ); // $ExpectType float64ndarray sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, false ); // $ExpectType float32ndarray + sliceAssign( zeros( sh ), empty( 'float16', sh, order ), s, false ); // $ExpectType float16ndarray sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, false ); // $ExpectType complex128ndarray sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, false ); // $ExpectType complex64ndarray sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, false ); // $ExpectType int32ndarray @@ -44,6 +45,7 @@ import sliceAssign = require( './index' ); sliceAssign( zeros( sh ), empty( 'float64', sh, order ), s, true ); // $ExpectType float64ndarray sliceAssign( zeros( sh ), empty( 'float32', sh, order ), s, true ); // $ExpectType float32ndarray + sliceAssign( zeros( sh ), empty( 'float16', sh, order ), s, true ); // $ExpectType float16ndarray sliceAssign( zeros( sh ), empty( 'complex128', sh, order ), s, true ); // $ExpectType complex128ndarray sliceAssign( zeros( sh ), empty( 'complex64', sh, order ), s, true ); // $ExpectType complex64ndarray sliceAssign( zeros( sh ), empty( 'int32', sh, order ), s, true ); // $ExpectType int32ndarray diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js b/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js index f04bd064fe5b..1047a59c8646 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js @@ -170,6 +170,7 @@ tape( 'in non-strict mode, the function does not set element values when a slice values = [ zeros( [ 1 ], { 'dtype': 'float64' } ), zeros( [ 1, 1 ], { 'dtype': 'float32' } ), + zeros( [ 1, 1 ], { 'dtype': 'float16' } ), zeros( [ 1, 1, 1 ], { 'dtype': 'int32' } ), zeros( [ 1, 1, 1, 1 ], { 'dtype': 'uint32' } ), zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) @@ -179,6 +180,7 @@ tape( 'in non-strict mode, the function does not set element values when a slice slices = [ new MultiSlice( 10 ), new MultiSlice( null, s ), + new MultiSlice( null, s ), new MultiSlice( s, null, null ), new MultiSlice( s, s, null, null ), new MultiSlice( 0, null, null, null, 10 ) @@ -248,6 +250,7 @@ tape( 'the function throws an error if provided an input array having a data typ x = [ zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2 ], { 'dtype': 'int32' } ), + zeros( [ 2, 2 ], { 'dtype': 'int16' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'int32' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'uint8' } ) ]; @@ -255,6 +258,7 @@ tape( 'the function throws an error if provided an input array having a data typ values = [ zeros( [ 2 ], { 'dtype': 'float64' } ), zeros( [ 2, 2 ], { 'dtype': 'float32' } ), + zeros( [ 2, 2 ], { 'dtype': 'float16' } ), zeros( [ 2, 2, 2 ], { 'dtype': 'uint32' } ), zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) ]; @@ -262,6 +266,7 @@ tape( 'the function throws an error if provided an input array having a data typ slices = [ new MultiSlice( null ), new MultiSlice( null, null ), + new MultiSlice( null, null ), new MultiSlice( null, null, null ), new MultiSlice( null, null, null, null ) ]; @@ -345,6 +350,7 @@ tape( 'if all output array dimensions are reduced, the function supports assigni x = [ scalar2ndarray( 100, 'float64', 'row-major' ), scalar2ndarray( 50, 'float32', 'row-major' ), + scalar2ndarray( 50, 'float16', 'row-major' ), scalar2ndarray( 200, 'int32', 'row-major' ), scalar2ndarray( 300, 'uint32', 'row-major' ) ]; @@ -358,6 +364,10 @@ tape( 'if all output array dimensions are reduced, the function supports assigni 'shape': [ 2, 2, 2 ], 'dtype': 'float32' }), + array( typedarray( zeroTo( 8 ), 'float16' ), { + 'shape': [ 2, 2, 2 ], + 'dtype': 'float16' + }), array( typedarray( zeroTo( 2 ), 'int32' ), { 'shape': [ 2 ], 'dtype': 'int32' @@ -370,6 +380,7 @@ tape( 'if all output array dimensions are reduced, the function supports assigni idx = [ [ 0, 1 ], [ 0, 1, 0 ], + [ 0, 1, 0 ], [ 0 ], [ 0, 1, 0, 1 ] ]; @@ -377,11 +388,13 @@ tape( 'if all output array dimensions are reduced, the function supports assigni MultiSlice.apply( null, idx[ 0 ] ), MultiSlice.apply( null, idx[ 1 ] ), MultiSlice.apply( null, idx[ 2 ] ), - MultiSlice.apply( null, idx[ 3 ] ) + MultiSlice.apply( null, idx[ 3 ] ), + MultiSlice.apply( null, idx[ 4 ] ) ]; expected = [ 100, 50, + 50, 200, 300 ]; @@ -1380,6 +1393,7 @@ tape( 'the function supports safely casting input array elements to the data typ s = new MultiSlice( null ); x = [ + scalar2ndarray( 10, 'float16', 'row-major' ), scalar2ndarray( 10, 'float32', 'row-major' ), scalar2ndarray( 10, 'int8', 'row-major' ), scalar2ndarray( 10, 'uint16', 'row-major' ), @@ -1387,6 +1401,7 @@ tape( 'the function supports safely casting input array elements to the data typ scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) ]; values = [ + zeros( [ 2 ], { 'dtype': 'float32' } ), zeros( [ 2 ], { 'dtype': 'float64' } ), zeros( [ 2 ], { 'dtype': 'int16' } ), zeros( [ 2 ], { 'dtype': 'uint32' } ), @@ -1397,6 +1412,7 @@ tape( 'the function supports safely casting input array elements to the data typ [ 10, 10 ], [ 10, 10 ], [ 10, 10 ], + [ 10, 10 ], [ 10, 10, 10, 10 ], [ 3, 5, 3, 5 ] ]; @@ -1437,13 +1453,16 @@ tape( 'the function supports downcasting floating-point input array elements to x = [ scalar2ndarray( 10, 'float64', 'row-major' ), + scalar2ndarray( 10, 'float32', 'row-major' ), scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) ]; values = [ zeros( [ 2 ], { 'dtype': 'float32' } ), + zeros( [ 2 ], { 'dtype': 'float16' } ), zeros( [ 2 ], { 'dtype': 'complex64' } ) ]; expected = [ + [ 10, 10 ], [ 10, 10 ], [ 3, 5, 3, 5 ] ]; From 8bf34a864f51d494d1f128141b8ffafa11fbedbb Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Fri, 25 Sep 2026 13:31:05 +0530 Subject: [PATCH 2/3] chore: fix lint errors in test.ts and test.js --- .../ndarray/base/slice-assign/docs/types/test.ts | 2 +- .../ndarray/base/slice-assign/test/test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts index c0b8127461b1..ee801eed7123 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/docs/types/test.ts @@ -69,7 +69,7 @@ import sliceAssign = require( './index' ); sliceAssign( null, y, s, false ); // $ExpectError sliceAssign( [], y, s, false ); // $ExpectError sliceAssign( {}, y, s, false ); // $ExpectError - sliceAssign( ( x: number ): number => y, y, s, false ); // $ExpectError + sliceAssign( ( x: number ): number => x, y, s, false ); // $ExpectError sliceAssign( '10', y, s, true ); // $ExpectError sliceAssign( 10, y, s, true ); // $ExpectError diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js b/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js index 1047a59c8646..d5139032a2ff 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js @@ -167,6 +167,8 @@ tape( 'in non-strict mode, the function does not set element values when a slice x = scalar2ndarray( 3, 'uint8', 'row-major' ); + /* eslint-disable stdlib/line-closing-bracket-spacing */ + values = [ zeros( [ 1 ], { 'dtype': 'float64' } ), zeros( [ 1, 1 ], { 'dtype': 'float32' } ), @@ -176,6 +178,8 @@ tape( 'in non-strict mode, the function does not set element values when a slice zeros( [ 1, 1, 1, 1, 1 ], { 'dtype': 'complex128' } ) ]; + /* eslint-enable stdlib/line-closing-bracket-spacing */ + s = new Slice( 10, 20, 1 ); slices = [ new MultiSlice( 10 ), @@ -247,6 +251,8 @@ tape( 'the function throws an error if provided an input array having a data typ var x; var i; + /* eslint-disable stdlib/line-closing-bracket-spacing */ + x = [ zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2, 2 ], { 'dtype': 'int32' } ), @@ -263,6 +269,8 @@ tape( 'the function throws an error if provided an input array having a data typ zeros( [ 2, 2, 2, 2 ], { 'dtype': 'int8' } ) ]; + /* eslint-enable stdlib/line-closing-bracket-spacing */ + slices = [ new MultiSlice( null ), new MultiSlice( null, null ), @@ -1400,6 +1408,8 @@ tape( 'the function supports safely casting input array elements to the data typ scalar2ndarray( 10, 'float64', 'row-major' ), scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) ]; + /* eslint-disable stdlib/line-closing-bracket-spacing */ + values = [ zeros( [ 2 ], { 'dtype': 'float32' } ), zeros( [ 2 ], { 'dtype': 'float64' } ), @@ -1408,6 +1418,8 @@ tape( 'the function supports safely casting input array elements to the data typ zeros( [ 2 ], { 'dtype': 'complex128' } ), zeros( [ 2 ], { 'dtype': 'complex128' } ) ]; + + /* eslint-enable stdlib/line-closing-bracket-spacing */ expected = [ [ 10, 10 ], [ 10, 10 ], @@ -1456,11 +1468,15 @@ tape( 'the function supports downcasting floating-point input array elements to scalar2ndarray( 10, 'float32', 'row-major' ), scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) ]; + /* eslint-disable stdlib/line-closing-bracket-spacing */ + values = [ zeros( [ 2 ], { 'dtype': 'float32' } ), zeros( [ 2 ], { 'dtype': 'float16' } ), zeros( [ 2 ], { 'dtype': 'complex64' } ) ]; + + /* eslint-enable stdlib/line-closing-bracket-spacing */ expected = [ [ 10, 10 ], [ 10, 10 ], From cc6a77952c631b643bc84b7dc7694f20ea8470ac Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Fri, 25 Sep 2026 13:40:13 +0530 Subject: [PATCH 3/3] chore: fix JavaScript lint errors in test.js --- .../@stdlib/ndarray/base/slice-assign/test/test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js b/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js index d5139032a2ff..f74732a9c801 100644 --- a/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/slice-assign/test/test.js @@ -1408,6 +1408,7 @@ tape( 'the function supports safely casting input array elements to the data typ scalar2ndarray( 10, 'float64', 'row-major' ), scalar2ndarray( new Complex64( 3.0, 5.0 ), 'complex64', 'row-major' ) ]; + /* eslint-disable stdlib/line-closing-bracket-spacing */ values = [ @@ -1420,6 +1421,7 @@ tape( 'the function supports safely casting input array elements to the data typ ]; /* eslint-enable stdlib/line-closing-bracket-spacing */ + expected = [ [ 10, 10 ], [ 10, 10 ], @@ -1468,6 +1470,7 @@ tape( 'the function supports downcasting floating-point input array elements to scalar2ndarray( 10, 'float32', 'row-major' ), scalar2ndarray( new Complex128( 3.0, 5.0 ), 'complex128', 'row-major' ) ]; + /* eslint-disable stdlib/line-closing-bracket-spacing */ values = [ @@ -1477,6 +1480,7 @@ tape( 'the function supports downcasting floating-point input array elements to ]; /* eslint-enable stdlib/line-closing-bracket-spacing */ + expected = [ [ 10, 10 ], [ 10, 10 ],