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
93 changes: 93 additions & 0 deletions lib/node_modules/@stdlib/blas/base/igamax/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 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

/// <reference types="@stdlib/types"/>

import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';

/**
* Input array.
*/
type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;

/**
* Interface describing `igamax`.
*/
interface Routine {
/**
* Finds the index of the first element having the maximum absolute value.
*
* @param N - number of indexed elements
* @param x - input array
* @param strideX - stride length for `x`
* @returns index value
*
* @example
* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
*
* var idx = igamax( x.length, x, 1 );
* // returns 4
*/
( N: number, x: InputArray, strideX: number ): number;

/**
* Finds the index of the first element having the maximum absolute value using alternative indexing semantics.
*
* @param N - number of indexed elements
* @param x - input array
* @param strideX - stride length for `x`
* @param offsetX - starting index for `x`
* @returns index value
*
* @example
* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
*
* var idx = igamax.ndarray( x.length, x, 1, 0 );
* // returns 4
*/
ndarray( N: number, x: InputArray, strideX: number, offsetX: number ): number;
}

/**
* Finds the index of the first element having the maximum absolute value.
*
* @param N - number of indexed elements
* @param x - input array
* @param strideX - stride length for `x`
* @returns index value
*
* @example
* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
*
* var idx = igamax( x.length, x, 1 );
* // returns 4
*
* @example
* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
*
* var idx = igamax.ndarray( x.length, x, 1, 0 );
* // returns 4
*/
declare var igamax: Routine;


// EXPORTS //

export = igamax;
160 changes: 160 additions & 0 deletions lib/node_modules/@stdlib/blas/base/igamax/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 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.
*/

import AccessorArray = require( '@stdlib/array/base/accessor' );
import igamax = require( './index' );


// TESTS //

// The function returns a number...
{
const x = new Float64Array( 10 );

igamax( x.length, x, 1 ); // $ExpectType number
igamax( x.length, new AccessorArray( x ), 1 ); // $ExpectType number
}

// The compiler throws an error if the function is provided a first argument which is not a number...
{
const x = new Float64Array( 10 );

igamax( '10', x, 1 ); // $ExpectError
igamax( true, x, 1 ); // $ExpectError
igamax( false, x, 1 ); // $ExpectError
igamax( null, x, 1 ); // $ExpectError
igamax( undefined, x, 1 ); // $ExpectError
igamax( [], x, 1 ); // $ExpectError
igamax( {}, x, 1 ); // $ExpectError
igamax( ( x: number ): number => x, x, 1 ); // $ExpectError
}

// The compiler throws an error if the function is provided a second argument which is not a numeric array...
{
const x = new Float64Array( 10 );

igamax( x.length, 10, 1 ); // $ExpectError
igamax( x.length, '10', 1 ); // $ExpectError
igamax( x.length, true, 1 ); // $ExpectError
igamax( x.length, false, 1 ); // $ExpectError
igamax( x.length, null, 1 ); // $ExpectError
igamax( x.length, undefined, 1 ); // $ExpectError
igamax( x.length, [ '1' ], 1 ); // $ExpectError
igamax( x.length, {}, 1 ); // $ExpectError
igamax( x.length, ( x: number ): number => x, 1 ); // $ExpectError
}

// The compiler throws an error if the function is provided a third argument which is not a number...
{
const x = new Float64Array( 10 );

igamax( x.length, x, '10' ); // $ExpectError
igamax( x.length, x, true ); // $ExpectError
igamax( x.length, x, false ); // $ExpectError
igamax( x.length, x, null ); // $ExpectError
igamax( x.length, x, undefined ); // $ExpectError
igamax( x.length, x, [] ); // $ExpectError
igamax( x.length, x, {} ); // $ExpectError
igamax( x.length, x, ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
const x = new Float64Array( 10 );

igamax(); // $ExpectError
igamax( x.length ); // $ExpectError
igamax( x.length, x ); // $ExpectError
igamax( x.length, x, 1, 10 ); // $ExpectError
}

// Attached to main export is an `ndarray` method which returns a number...
{
const x = new Float64Array( 10 );

igamax.ndarray( x.length, x, 1, 0 ); // $ExpectType number
igamax.ndarray( x.length, new AccessorArray( x ), 1, 0 ); // $ExpectType number
}

// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
{
const x = new Float64Array( 10 );

igamax.ndarray( '10', x, 1, 0 ); // $ExpectError
igamax.ndarray( true, x, 1, 0 ); // $ExpectError
igamax.ndarray( false, x, 1, 0 ); // $ExpectError
igamax.ndarray( null, x, 1, 0 ); // $ExpectError
igamax.ndarray( undefined, x, 1, 0 ); // $ExpectError
igamax.ndarray( [], x, 1, 0 ); // $ExpectError
igamax.ndarray( {}, x, 1, 0 ); // $ExpectError
igamax.ndarray( ( x: number ): number => x, x, 1, 0 ); // $ExpectError
}

// The compiler throws an error if the `ndarray` method is provided a second argument which is not a numeric array...
{
const x = new Float64Array( 10 );

igamax.ndarray( x.length, 10, 1, 0 ); // $ExpectError
igamax.ndarray( x.length, '10', 1, 0 ); // $ExpectError
igamax.ndarray( x.length, true, 1, 0 ); // $ExpectError
igamax.ndarray( x.length, false, 1, 0 ); // $ExpectError
igamax.ndarray( x.length, null, 1, 0 ); // $ExpectError
igamax.ndarray( x.length, undefined, 1, 0 ); // $ExpectError
igamax.ndarray( x.length, [ '1' ], 1, 0 ); // $ExpectError
igamax.ndarray( x.length, {}, 1, 0 ); // $ExpectError
igamax.ndarray( x.length, ( x: number ): number => x, 1, 0 ); // $ExpectError
}

// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number...
{
const x = new Float64Array( 10 );

igamax.ndarray( x.length, x, '10', 0 ); // $ExpectError
igamax.ndarray( x.length, x, true, 0 ); // $ExpectError
igamax.ndarray( x.length, x, false, 0 ); // $ExpectError
igamax.ndarray( x.length, x, null, 0 ); // $ExpectError
igamax.ndarray( x.length, x, undefined, 0 ); // $ExpectError
igamax.ndarray( x.length, x, [], 0 ); // $ExpectError
igamax.ndarray( x.length, x, {}, 0 ); // $ExpectError
igamax.ndarray( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError
}

// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
{
const x = new Float64Array( 10 );

igamax.ndarray( x.length, x, 1, '10' ); // $ExpectError
igamax.ndarray( x.length, x, 1, true ); // $ExpectError
igamax.ndarray( x.length, x, 1, false ); // $ExpectError
igamax.ndarray( x.length, x, 1, null ); // $ExpectError
igamax.ndarray( x.length, x, 1, undefined ); // $ExpectError
igamax.ndarray( x.length, x, 1, [] ); // $ExpectError
igamax.ndarray( x.length, x, 1, {} ); // $ExpectError
igamax.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
{
const x = new Float64Array( 10 );

igamax.ndarray(); // $ExpectError
igamax.ndarray( x.length ); // $ExpectError
igamax.ndarray( x.length, x ); // $ExpectError
igamax.ndarray( x.length, x, 1 ); // $ExpectError
igamax.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError
}