Skip to content

Commit 5c783d7

Browse files
committed
feat: add lib
1 parent cbc4ab8 commit 5c783d7

File tree

3 files changed

+160
-0
lines changed

3 files changed

+160
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
24+
var format = require( '@stdlib/string/format' );
25+
var base = require( './base.js' );
26+
27+
28+
// MAIN //
29+
30+
/**
31+
* Returns last non-zero row of matrix `A`.
32+
*
33+
* @param {string} order - storage layout
34+
* @param {NonNegativeInteger} M - number of rows
35+
* @param {NonNegativeInteger} N - number of columns
36+
* @param {Float64Array} A - input matrix
37+
* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
38+
* @throws {TypeError} first argument must be a valid order
39+
* @returns {integer} index of last non-zero row
40+
*
41+
* @example
42+
* var Float64Array = require( '@stdlib/array/float64' );
43+
*
44+
* var out;
45+
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
46+
*
47+
* out = iladlr( 'row-major', 2, 2, A, 2 );
48+
* // returns 1
49+
*/
50+
function iladlr( order, M, N, A, LDA ) {
51+
var sa1;
52+
var sa2;
53+
if ( !isLayout( order ) ) {
54+
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
55+
}
56+
if ( order === 'column-major' ) {
57+
sa1 = 1;
58+
sa2 = LDA;
59+
} else { // order === 'row-major'
60+
sa1 = LDA;
61+
sa2 = 1;
62+
}
63+
return base( M, N, A, sa1, sa2, 0 );
64+
}
65+
66+
67+
// EXPORTS //
68+
69+
module.exports = iladlr;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
24+
var iladlr = require( './iladlr.js' );
25+
var ndarray = require( './ndarray.js' );
26+
27+
28+
// MAIN //
29+
30+
setReadOnly( iladlr, 'ndarray', ndarray );
31+
32+
33+
// EXPORTS //
34+
35+
module.exports = iladlr;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var base = require( './base.js' );
24+
25+
26+
// MAIN //
27+
28+
/**
29+
* Returns last non-zero row of matrix `A` using alternative indexing semantics.
30+
*
31+
* @name iladlr
32+
* @type {Function}
33+
* @param {NonNegativeInteger} M - number of rows
34+
* @param {NonNegativeInteger} N - number of columns
35+
* @param {Float64Array} A - input matrix
36+
* @param {integer} strideA1 - stride of the first dimension of `A`
37+
* @param {integer} strideA2 - stride of the second dimension of `A`
38+
* @param {NonNegativeInteger} offsetA - starting index for `A`
39+
* @throws {TypeError} first argument must be a valid order
40+
* @returns {integer} index of last non-zero row
41+
*
42+
* @example
43+
* var Float64Array = require( '@stdlib/array/float64' );
44+
*
45+
* var out;
46+
* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
47+
*
48+
* out = iladlr( 2, 2, A, 2, 1, 0 );
49+
* // returns 1
50+
*/
51+
var iladlr = base;
52+
53+
54+
// EXPORTS //
55+
56+
module.exports = iladlr;

0 commit comments

Comments
 (0)