Skip to content

Commit

Permalink
feat: add other files
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranavchiku committed Sep 2, 2024
1 parent d363531 commit 45f9026
Show file tree
Hide file tree
Showing 11 changed files with 939 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/lapack/base/iladlr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var out = iladlr( 'row-major', 2, 2, A1, 2 );
// out => 1
```

#### iladlr.ndarray( M, N, A, strideA1, strideA2, offsetA )
#### iladlr.ndarray( M, N, A, sa1, sa2, oa )

Returns last non-zero row of matrix `A` using alternative indexing semantics.

Expand Down
97 changes: 97 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @license Apache-2.0
*
* 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.
* 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.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var floor = require( '@stdlib/math/base/special/floor' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
var iladlr = require( './../lib/iladlr.js' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var A = uniform( len * len, -100.0, 100.0, options );
return benchmark;

function benchmark( b ) {
var out;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = iladlr( 'row-major', len, len, A, len );
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = floor( pow( pow( 10, i ), 0.5 ) );
f = createBenchmark( len );
bench( pkg+':order=row-major,len='+len, f );
}
}

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @license Apache-2.0
*
* 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.
* 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.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var floor = require( '@stdlib/math/base/special/floor' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
var iladlr = require( './../lib/ndarray.js' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var A = uniform( len * len, -100.0, 100.0, options );
return benchmark;

function benchmark( b ) {
var out;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = iladlr( len, len, A, len, 1, 0 );
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = floor( pow( pow( 10, i ), 0.5 ) );
f = createBenchmark( len );
bench( pkg+':ndarray:order=row-major,len='+len, f );
}
}

main();
108 changes: 108 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* @license Apache-2.0
*
* 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.
* 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 { Layout } from '@stdlib/types/blas';

/**
* Interface describing `iladlr`.
*/
interface Routine {
/**
* Returns last non-zero row of matrix `A`.
*
* @param order - storage layout
* @param M - number of rows
* @param N - number of columns
* @param A - input matrix
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
* @returns index of last non-zero row
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var out;
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
*
* out = iladlr( 'row-major', 2, 2, A, 2 );
* // returns 1
*/
( order: Layout, M: number, N: number, A: Float64Array, LDA: number ): number;

/**
* Returns last non-zero row of matrix `A` using alternative indexing semantics.
*
* @name iladlr.ndarray
* @type {Function}
* @param M - number of rows
* @param N - number of columns
* @param A - input matrix
* @param strideA1 - stride of the first dimension of `A`
* @param strideA2 - stride of the second dimension of `A`
* @param offsetA - starting index for `A`
* @returns index of last non-zero row
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var out;
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
*
* out = iladlr.ndarray( 2, 2, A, 2, 1, 0 );
* // returns 1
*/
ndarray( M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): number;
}

/**
* Returns last non-zero row of matrix `A`.
*
* @param order - storage layout
* @param M - number of rows
* @param N - number of columns
* @param A - input matrix
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
* @returns index of last non-zero row
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var out;
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
*
* out = iladlr( 'row-major', 2, 2, A, 2 );
* // returns 1
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var out;
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
*
* out = iladlr.ndarray( 2, 2, A, 2, 1, 0 );
* // returns 1
*/
declare var iladlr: Routine;


// EXPORTS //

export = iladlr;
Loading

0 comments on commit 45f9026

Please sign in to comment.