Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,13 +25,15 @@ var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' );
var resolve = require( '@stdlib/strided/base/dtype-resolve-enum' );
var reinterpretComplex64 = require( '@stdlib/strided/base/reinterpret-complex64' );
var reinterpretComplex128 = require( '@stdlib/strided/base/reinterpret-complex128' );
var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' );
var format = require( '@stdlib/string/format' );


// VARIABLES //

var COMPLEX64 = resolve( 'complex64' );
var COMPLEX128 = resolve( 'complex128' );
var BOOLEAN = resolve( 'bool' );


// MAIN //
Expand Down Expand Up @@ -139,6 +141,8 @@ function dispatch( addon, fallback ) {
viewX = reinterpretComplex64( x, 0 );
} else if ( dtypeX === COMPLEX128 ) {
viewX = reinterpretComplex128( x, 0 );
} else if ( dtypeX === BOOLEAN ) {
viewX = reinterpretBoolean( x, 0 );
} else {
viewX = x;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,6 +26,7 @@ var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).is
var resolve = require( '@stdlib/strided/base/dtype-resolve-enum' );
var reinterpretComplex64 = require( '@stdlib/strided/base/reinterpret-complex64' );
var reinterpretComplex128 = require( '@stdlib/strided/base/reinterpret-complex128' );
var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' );
var offsetView = require( '@stdlib/strided/base/offset-view' );
var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
var format = require( '@stdlib/string/format' );
Expand All @@ -35,6 +36,7 @@ var format = require( '@stdlib/string/format' );

var COMPLEX64 = resolve( 'complex64' );
var COMPLEX128 = resolve( 'complex128' );
var BOOLEAN = resolve( 'bool' );


// MAIN //
Expand Down Expand Up @@ -150,6 +152,8 @@ function dispatch( addon, fallback ) {
viewX = reinterpretComplex64( x, offsetX );
} else if ( dtypeX === COMPLEX128 ) {
viewX = reinterpretComplex128( x, offsetX );
} else if ( dtypeX === BOOLEAN ) {
viewX = reinterpretBoolean( x, offsetX );
} else {
viewX = offsetView( x, offsetX );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,8 +25,10 @@ var noop = require( '@stdlib/utils/noop' );
var Float64Array = require( '@stdlib/array/float64' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );
var isFloat32Array = require( '@stdlib/assert/is-float32array' );
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
var isUint8Array = require( '@stdlib/assert/is-uint8array' );
var resolve = require( '@stdlib/strided/base/dtype-resolve-enum' );
var dispatch = require( './../lib' );

Expand Down Expand Up @@ -123,6 +125,31 @@ tape( 'the function returns a function which dispatches to an addon function whe
}
});

tape( 'the function supports boolean arrays (bool)', function test( t ) {
var f;
var x;

f = dispatch( addon, fallback );

x = new BooleanArray( 2 );
f( x.length, 'bool', x, 1 );

t.end();

function addon( N, dx, ax, sx ) {
t.ok( true, 'called addon' );
t.strictEqual( N, x.length, 'returns expected value' );
t.strictEqual( dx, resolve( 'bool' ), 'returns expected value' );
t.strictEqual( isUint8Array( ax ), true, 'returns expected value' );
t.strictEqual( ax.buffer, x.buffer, 'returns expected value' );
t.strictEqual( sx, 1, 'returns expected value' );
}

function fallback() {
t.ok( false, 'called fallback' );
}
});

tape( 'the function supports complex number typed arrays (complex64)', function test( t ) {
var f;
var x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,8 +25,10 @@ var noop = require( '@stdlib/utils/noop' );
var Float64Array = require( '@stdlib/array/float64' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );
var isFloat32Array = require( '@stdlib/assert/is-float32array' );
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
var isUint8Array = require( '@stdlib/assert/is-uint8array' );
var resolve = require( '@stdlib/strided/base/dtype-resolve-enum' );
var dispatch = require( './../lib/ndarray.js' );

Expand Down Expand Up @@ -159,6 +161,31 @@ tape( 'the function returns a function which dispatches to an addon function whe
}
});

tape( 'the function supports boolean arrays (bool)', function test( t ) {
var f;
var x;

f = dispatch( addon, fallback );

x = new BooleanArray( 2 );
f( x.length, 'bool', x, 1, 0 );

t.end();

function addon( N, dx, ax, sx ) {
t.ok( true, 'called addon' );
t.strictEqual( N, x.length, 'returns expected value' );
t.strictEqual( dx, resolve( 'bool' ), 'returns expected value' );
t.strictEqual( isUint8Array( ax ), true, 'returns expected value' );
t.strictEqual( ax.buffer, x.buffer, 'returns expected value' );
t.strictEqual( sx, 1, 'returns expected value' );
}

function fallback() {
t.ok( false, 'called fallback' );
}
});

tape( 'the function supports complex number typed arrays (complex64)', function test( t ) {
var f;
var x;
Expand Down