All files ndarray.js

100% Statements 84/84
100% Branches 6/6
100% Functions 1/1
100% Lines 84/84

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 852x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 67x 67x 13x 13x 67x 13x 13x 41x 41x 67x 2x 2x 2x 2x 2x  
/**
* @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.
*/
 
'use strict';
 
// MODULES //
 
var format = require( '@stdlib/string/format' );
var isStorage = require( './is_storage.js' );
var isDirection = require( './is_direction.js' );
var base = require( './base.js' );
 
 
// MAIN //
 
/**
* Forms the triangular factor T of a real block reflector H of order N, which is defined as a product of K elementary reflectors using alternative indexing semantics.
*
* ## Notes
*
* -   If `direct` = 'forward', `H = H(1) H(2) . . . H(k)` and `T` is upper triangular.
* -   If `direct` = 'backward', `H = H(k) . . . H(2) H(1)` and `T` is lower triangular.
* -   If `storev` = 'columnwise', the vector which defines the elementary reflector `H(i)` is stored in the i-th column of the array `V`, and `H  =  I - V * T * V**T`.
* -   If `storev` = 'rowwise', the vector which defines the elementary reflector `H(i)` is stored in the i-th row of the array `V`, and `H  =  I - V**T * T * V`.
*
* @param {string} direct - specifies the order in which the elementary reflectors are multiplied to form the block reflector `H`
* @param {string} storev - specifies how the vectors which define the elementary reflectors are stored
* @param {NonNegativeInteger} N - order of the block reflector `H`
* @param {NonNegativeInteger} K - order of the triangular factor `T` (the number of elementary reflectors)
* @param {Float64Array} V - matrix of reflector vectors
* @param {integer} strideV1 - stride of first dimension of `V`
* @param {integer} strideV2 - stride of second dimension of `V`
* @param {NonNegativeInteger} offsetV - starting index for `V`
* @param {Float64Array} TAU - array of scalar factors of the elementary reflector `H(i)`
* @param {integer} strideTAU - stride length for `TAU`
* @param {NonNegativeInteger} offsetTAU - starting index for `TAU`
* @param {Float64Array} T - output triangular matrix
* @param {integer} strideT1 - stride of first dimension of `T`
* @param {integer} strideT2 - stride of second dimension of `T`
* @param {NonNegativeInteger} offsetT - starting index for `T`
* @throws {TypeError} first argument must be a valid direction
* @throws {TypeError} second argument must be a valid storage layout
* @returns {Float64Array} `T`
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var V = new Float64Array( [ 1.0, 0.2, 0.3, -0.4, 0.5, 0.0, 1.0, -0.6, 0.7, -0.8, 0.0, 0.0, 1.0, 0.9, 1.1 ] );
* var TAU = new Float64Array( [ 1.2, 0.7, 1.5 ] );
* var T = new Float64Array( 9 );
*
* dlarft( 'forward', 'rowwise', 5, 3, V, 5, 1, 0, TAU, 1, 0, T, 3, 1, 0 );
* // T => <Float64Array>[ ~1.2, ~0.5544, ~-0.17514, 0.0, 0.7, 0.8925, 0.0, 0.0, 1.5 ]
*/
function dlarft( direct, storev, N, K, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ) { // eslint-disable-line max-len, max-params
	if ( !isDirection( direct ) ) {
		throw new TypeError( format( 'invalid argument. Second argument must be a direction. Value: `%s`.', direct ) );
	}
	if ( !isStorage( storev ) ) {
		throw new TypeError( format( 'invalid argument. Third argument must be a valid storage layout. Value: `%s`.', storev ) );
	}
	base( direct, storev, N, K, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ); // eslint-disable-line max-len
	return T;
}
 
 
// EXPORTS //
 
module.exports = dlarft;