/*
* @license Apache-2.0
*
* Copyright (c) 2025 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// TypeScript Version: 4.1
///
import { ArrayLike } from '@stdlib/types/array';
import { OutputPolicy, InputCastingPolicy, DataType, typedndarray } from '@stdlib/types/ndarray';
/**
* Input array.
*/
type InputArray = typedndarray;
/**
* Output array.
*/
type OutputArray = typedndarray;
/**
* Interface defining "base" options.
*/
interface BaseOptions {
/**
* List of dimensions over which to perform a reduction.
*/
dims?: ArrayLike;
}
/**
* Interface defining options.
*/
interface Options extends BaseOptions {
/**
* Output array data type.
*/
dtype?: DataType;
/**
* Boolean indicating whether the reduced dimensions should be included in the returned array as singleton dimensions. Default: `false`.
*/
keepdims?: boolean;
}
/**
* Strided reduction function.
*
* @param arrays - input ndarrays
* @param options - function options
* @returns result
*/
type Binary = ( arrays: [ typedndarray, typedndarray ], options?: unknown ) => U;
/**
* Strided reduction function.
*
* @param arrays - input ndarrays
* @param options - function options
* @returns result
*/
type BinaryWithAdditionalArrays = ( arrays: [ typedndarray, typedndarray, ...Array> ], options?: unknown ) => U;
/**
* Base dispatch table.
*/
interface BaseDispatchTable {
/**
* Default strided reduction function.
*/
default: Binary | BinaryWithAdditionalArrays;
}
/**
* Dispatch table.
*/
interface DispatchTable extends BaseDispatchTable {
/**
* One-dimensional list of ndarray data types describing specialized input ndarray argument signatures.
*/
types: ArrayLike;
/**
* List of strided reduction functions which are specific to specialized input ndarray argument signatures.
*/
fcns: ArrayLike | BinaryWithAdditionalArrays>;
}
/**
* Dispatch policies.
*/
interface Policies {
/**
* Output data type policy.
*/
output: OutputPolicy;
/**
* Input ndarray casting policy.
*/
casting: InputCastingPolicy;
}
/**
* Class for performing a reduction on two input ndarrays.
*/
declare class BinaryStrided1dDispatch {
/**
* Constructor for performing a reduction on two input ndarrays.
*
* @param table - dispatch table
* @param idtypes - list containing lists of supported input data types for each ndarray argument
* @param odtypes - list of supported output data types
* @param policies - dispatch policies
* @returns instance
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var z = dot.apply( x, y );
* // returns [ -5.0 ]
*/
constructor( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, policies: Policies );
/**
* Performs a reduction on two provided input ndarrays.
*
* @param x - first input ndarray
* @param y - second input ndarray
* @param args - function options and additional ndarray arguments
* @returns output ndarray
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var z = dot.apply( x, y );
* // returns [ -5.0 ]
*/
apply( x: InputArray, y: InputArray, ...args: Array | Options> ): OutputArray; // NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how the input ndarrays interact with output data type policy and whether that policy has been overridden by `options.dtype`. In principle, as well, based on the policy, it is possible to know more exactly which `InputArray` types are actually allowed.
/**
* Performs a reduction on two provided input ndarrays and assigns results to a provided output ndarray.
*
* @param x - first input ndarray
* @param y - second input ndarray
* @param out - output ndarray
* @param options - function options
* @returns output ndarray
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var zbuf = [ 0.0 ];
* var z = new ndarray( 'generic', zbuf, [], [ 0 ], 0, 'row-major' );
*
* var out = dot.assign( x, y, z );
* // returns [ -5.0 ]
*
* var bool = ( out === z );
* // returns true
*/
assign = OutputArray>( x: InputArray, y: InputArray, out: V, options?: BaseOptions ): V;
/**
* Performs a reduction on two provided input ndarrays and assigns results to a provided output ndarray.
*
* @param x - first input ndarray
* @param y - second input ndarray
* @param z - additional ndarray argument
* @param args - output ndarray, additional ndarray arguments, and function options
* @returns output ndarray
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var zbuf = [ 0.0 ];
* var z = new ndarray( 'generic', zbuf, [], [ 0 ], 0, 'row-major' );
*
* var out = dot.assign( x, y, z );
* // returns [ -5.0 ]
*
* var bool = ( out === z );
* // returns true
*/
assign = OutputArray>( x: InputArray, y: InputArray, z: InputArray | V, ...args: Array | V | BaseOptions> ): V;
}
/**
* Interface defining a constructor which is both "newable" and "callable".
*/
interface BinaryStrided1dDispatchConstructor {
/**
* Constructor for performing a reduction on two input ndarrays.
*
* @param table - dispatch table
* @param idtypes - list containing lists of supported input data types for each ndarray argument
* @param odtypes - list of supported output data types
* @param policies - dispatch policies
* @returns instance
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var z = dot.apply( x, y );
* // returns [ -5.0 ]
*/
new( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, policies: Policies ): BinaryStrided1dDispatch;
/**
* Constructor for performing a reduction on two input ndarrays.
*
* @param table - dispatch table
* @param idtypes - list containing lists of supported input data types for each ndarray argument
* @param odtypes - list of supported output data types
* @param policies - dispatch policies
* @returns instance
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var z = dot.apply( x, y );
* // returns [ -5.0 ]
*/
( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, policies: Policies ): BinaryStrided1dDispatch;
}
/**
* Constructor for performing a reduction on two input ndarrays.
*
* @param table - dispatch table
* @param idtypes - list containing lists of supported input data types for each ndarray argument
* @param odtypes - list of supported output data types
* @param policies - dispatch policies
* @returns instance
*
* @example
* var base = require( '@stdlib/blas/base/ndarray/gdot' );
* var dtypes = require( '@stdlib/ndarray/dtypes' );
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'promoted',
* 'casting': 'promoted'
* };
*
* var table = {
* 'default': base
* };
* var dot = new BinaryStrided1dDispatch( table, [ idt, idt ], odt, policies );
*
* var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var z = dot.apply( x, y );
* // returns [ -5.0 ]
*/
declare var ctor: BinaryStrided1dDispatchConstructor;
// EXPORTS //
export = ctor;
// eslint-doctest-alias: BinaryStrided1dDispatch