/*
* @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 an operation.
*/
dims?: ArrayLike;
}
/**
* Interface defining options.
*/
interface Options extends BaseOptions {
/**
* Output array data type.
*/
dtype?: DataType;
}
/**
* Interface defining constructor options.
*/
interface ConstructorOptions {
/**
* Boolean specifying whether the order of element traversal must match the memory layout of an input ndarray.
*/
strictTraversalOrder?: boolean;
}
/**
* Strided function.
*
* @param arrays - input ndarrays
* @param options - function options
* @returns result
*/
type Unary = ( arrays: [ typedndarray, typedndarray ], options?: unknown ) => typedndarray;
/**
* Strided function.
*
* @param arrays - input ndarrays
* @param options - function options
* @returns result
*/
type UnaryWithAdditionalArrays = ( arrays: [ typedndarray, typedndarray, ...Array> ], options?: unknown ) => typedndarray;
/**
* Base dispatch table.
*/
interface BaseDispatchTable {
/**
* Default strided function.
*/
default: Unary | UnaryWithAdditionalArrays;
}
/**
* Dispatch table.
*/
interface DispatchTable extends BaseDispatchTable {
/**
* One-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures.
*/
types: ArrayLike;
/**
* List of strided functions which are specific to specialized input and output ndarray argument signatures.
*/
fcns: ArrayLike | UnaryWithAdditionalArrays>;
}
/**
* Dispatch policies.
*/
interface Policies {
/**
* Output data type policy.
*/
output: OutputPolicy;
/**
* Input ndarray casting policy.
*/
casting: InputCastingPolicy;
}
/**
* Class for applying a strided function to an input ndarray.
*/
declare class UnaryStrided1dDispatch {
/**
* Constructor for applying a strided function to an input ndarray.
*
* @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
* @param options - function options
* @returns instance
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray2array = require( './../../../../to-array' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var y = cumax.apply( x );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*/
constructor( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, policies: Policies, options?: ConstructorOptions );
/**
* Applies a strided function to a provided input ndarray.
*
* @param x - input ndarray
* @param args - function options and additional ndarray arguments
* @returns output ndarray
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray2array = require( './../../../../to-array' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var y = cumax.apply( x );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*/
apply( x: 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 `x` interacts 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.
/**
* Applies a strided function to a provided input ndarray and assigns results to a provided output ndarray.
*
* @param x - input ndarray
* @param out - output ndarray
* @param options - function options
* @returns output ndarray
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray2array = require( './../../../../to-array' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 0.0, 0.0, 0.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var out = cumax.assign( x, y );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*
* var bool = ( out === y );
* // returns true
*/
assign = OutputArray>( x: InputArray, out: V, options?: BaseOptions ): V;
/**
* Applies a strided function to a provided input ndarray and assigns results to a provided output ndarray.
*
* @param x - input ndarray
* @param y - additional ndarray argument
* @param args - output ndarray, additional ndarray arguments, and function options
* @returns output ndarray
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray2array = require( './../../../../to-array' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var ybuf = [ 0.0, 0.0, 0.0 ];
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
*
* var out = cumax.assign( x, y );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*
* var bool = ( out === y );
* // returns true
*/
assign = OutputArray>( x: InputArray, y: InputArray | V, ...args: Array | V | BaseOptions> ): V;
}
/**
* Interface defining a constructor which is both "newable" and "callable".
*/
interface UnaryStrided1dDispatchConstructor {
/**
* Constructor for applying a strided function to an input ndarray.
*
* @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
* @param options - function options
* @returns instance
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray2array = require( './../../../../to-array' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var y = cumax.apply( x );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*/
new( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, policies: Policies, options?: ConstructorOptions ): UnaryStrided1dDispatch;
/**
* Constructor for applying a strided function to an input ndarray.
*
* @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
* @param options - function options
* @returns instance
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( './../../../../dtypes' );
* var ndarray2array = require( './../../../../to-array' );
* var ndarray = require( './../../../../base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var y = cumax.apply( x );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*/
( table: DispatchTable | BaseDispatchTable, idtypes: ArrayLike>, odtypes: ArrayLike, policies: Policies, options?: ConstructorOptions ): UnaryStrided1dDispatch;
}
/**
* Constructor for applying a strided function to an input ndarray.
*
* @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
* @param options - function options
* @returns instance
*
* @example
* var base = require( '@stdlib/stats/base/ndarray/cumax' );
* var dtypes = require( '@stdlib/ndarray/dtypes' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
*
* var idt = dtypes( 'real_and_generic' );
* var odt = idt;
* var policies = {
* 'output': 'same',
* 'casting': 'none'
* };
*
* var table = {
* 'default': base
* };
* var cumax = new UnaryStrided1dDispatch( table, [ idt ], odt, policies );
*
* var xbuf = [ -1.0, 2.0, -3.0 ];
* var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
*
* var y = cumax.apply( x );
* // returns
*
* var arr = ndarray2array( y );
* // returns [ -1.0, 2.0, 2.0 ]
*/
declare var ctor: UnaryStrided1dDispatchConstructor;
// eslint-doctest-alias: UnaryStrided1dDispatch
// EXPORTS //
export = ctor;