All files dlasq1.js

100% Statements 74/74
100% Branches 2/2
100% Functions 1/1
100% Lines 74/74

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 752x 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 5x 5x 5x 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 base = require( './base.js' );
 
 
// MAIN //
 
/**
* Computes the singular values of a real `N-by-N` bi-diagonal matrix with diagonal `D` and off-diagonal `E`.
*
* ## Notes
*
* -   `D` should have `N` indexed elements. On entry, `D` contains the diagonal elements of the bi-diagonal matrix whose SVD is desired. On normal exit, `D` contains the singular values in decreasing order.
*
* -   `E` should have `N` indexed elements. On entry, elements E(1:N-1) contain the off-diagonal elements of the bi-diagonal matrix whose SVD is desired. On exit, E is overwritten.
*
* -   The function returns a status code:
*
*     -   `= 0`: successful exit.
*
*     -   `< 0`: if `INFO = -i`, the `i`-th argument had an illegal value.
*
*     -   `> 0`: the algorithm failed:
*         -   `= 1`, a split was marked by a positive value in `E`.
*         -   `= 2`, current block of `Z` not diagonalized after `100*N` iterations (in inner while loop). On exit, `D` and `E` represent a matrix with the same singular values which the calling subroutine could use to finish the computation, or even feed back into `DLASQ1`
*         -   `= 3`, termination criterion of outer while loop not met (program created more than `N` unreduced blocks)
*
* @param {integer} N - number of rows/columns in the matrix
* @param {Float64Array} D - the array with diagonal elements of the bi-diagonal matrix whose SVD is desired
* @param {Float64Array} E - the array with off-diagonal elements of the bi-diagonal matrix whose SVD is desired
* @param {Float64Array} WORK - workspace array (length >= 4*N)
* @returns {integer} status code
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var D = new Float64Array( [ 100, 50, 25 ] );
* var E = new Float64Array( [ 90, 40, 0 ] );
* var WORK = new Float64Array( 16 );
*
* var info = dlasq1( 3, D, E, WORK );
* // D => <Float64Array>[ ~139.377, ~56.064, ~15.997 ]
* // E => <Float64Array>[ 90, 40, 0 ]
* // WORK => <Float64Array>[ ~1.939e292, ~3.137e291, ~2.554e290, ~1.575e286, ~3.137e291, ~2.881e291, ~2.278e292, ~2.278e292, 7.0, ~2.667, 0.0, ~2.881e291, 0, 0, 0, 0 ]
* // info => 0
*/
function dlasq1( N, D, E, WORK ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point
	return base( N, D, 1, 0, E, 1, 0, WORK, 1, 0 );
}
 
 
// EXPORTS //
 
module.exports = dlasq1;