Skip to content
Open
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
51 changes: 26 additions & 25 deletions lib/node_modules/@stdlib/lapack/base/spttrf/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

var tape = require( 'tape' );
var Float32Array = require( '@stdlib/array/float32' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var spttrf = require( './../lib/ndarray.js' );


Expand All @@ -38,22 +37,14 @@
* @param {Object} t - test object
* @param {Collection} actual - actual values
* @param {Collection} expected - expected values
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;
function isApprox( t, actual, expected, ulp ) {
var i;

t.strictEqual( actual.length, expected.length, 'returns expected value' );
for ( i = 0; i < expected.length; i++ ) {
if ( actual[ i ] === expected[ i ] ) {
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
} else {
delta = abs( actual[ i ] - expected[ i ] );
tol = rtol * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValuef( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -100,14 +91,16 @@
}
});

tape( 'the function computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`', function test( t ) {

Check warning on line 94 in lib/node_modules/@stdlib/lapack/base/spttrf/test/test.ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "tridiagonal"
var expectedD;
var expectedE;
var info;
var ULP;
var D;
var E;
var N;

ULP = 26;
N = 3;

D = new Float32Array( [ 4.0, 5.0, 6.0 ] );
Expand All @@ -118,8 +111,8 @@

info = spttrf( N, D, 1, 0, E, 1, 0 );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 2.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

N = 7;

Expand All @@ -131,8 +124,8 @@

info = spttrf( N, D, 1, 0, E, 1, 0 );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 15.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );
Comment on lines +127 to +128

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is what we want. We want to inline the ULP diff which is appropriate for each case, not use some sort of generalized value which applies to all isApprox calls.


t.end();
});
Expand All @@ -141,10 +134,12 @@
var expectedD;
var expectedE;
var info;
var ULP;
var D;
var E;
var N;

ULP = 0;
N = 3;

D = new Float32Array( [ 0.0, 0.0, 4.0, 5.0, 6.0 ] );
Expand All @@ -155,8 +150,8 @@

info = spttrf( N, D, 1, 2, E, 1, 3 );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 2.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

t.end();
});
Expand All @@ -165,10 +160,12 @@
var expectedD;
var expectedE;
var info;
var ULP;
var D;
var E;
var N;

ULP = 0;
N = 3;

D = new Float32Array( [ 0.0, 0.0, 4.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0 ] );
Expand All @@ -179,8 +176,8 @@

info = spttrf( N, D, 3, 2, E, 2, 3 );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 2.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

t.end();
});
Expand All @@ -189,10 +186,12 @@
var expectedD;
var expectedE;
var info;
var ULP;
var D;
var E;
var N;

ULP = 0;
N = 3;

D = new Float32Array( [ 6.0, 0.0, 0.0, 5.0, 0.0, 0.0, 4.0 ] );
Expand All @@ -203,8 +202,8 @@

info = spttrf( N, D, -3, 6, E, 2, 3 );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 2.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

t.end();
});
Expand All @@ -213,10 +212,12 @@
var expectedD;
var expectedE;
var info;
var ULP;
var D;
var E;
var N;

ULP = 0;
N = 3;

D = new Float32Array( [ 6.0, 0.0, 0.0, 5.0, 0.0, 0.0, 4.0 ] );
Expand All @@ -227,8 +228,8 @@

info = spttrf( N, D, -3, 6, E, -2, 5 );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 2.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

t.end();
});
Expand Down
27 changes: 10 additions & 17 deletions lib/node_modules/@stdlib/lapack/base/spttrf/test/test.spttrf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

var tape = require( 'tape' );
var Float32Array = require( '@stdlib/array/float32' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var spttrf = require( './../lib/spttrf.js' );


Expand All @@ -38,22 +37,14 @@
* @param {Object} t - test object
* @param {Collection} actual - actual values
* @param {Collection} expected - expected values
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;
function isApprox( t, actual, expected, ulp ) {
var i;

t.strictEqual( actual.length, expected.length, 'returns expected value' );
for ( i = 0; i < expected.length; i++ ) {
if ( actual[ i ] === expected[ i ] ) {
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
} else {
delta = abs( actual[ i ] - expected[ i ] );
tol = rtol * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValuef( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand Down Expand Up @@ -100,14 +91,16 @@
}
});

tape( 'the function computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`', function test( t ) {

Check warning on line 94 in lib/node_modules/@stdlib/lapack/base/spttrf/test/test.spttrf.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "tridiagonal"
var expectedD;
var expectedE;
var info;
var ULP;
var D;
var E;
var N;

ULP = 26;
N = 3;

D = new Float32Array( [ 4.0, 5.0, 6.0 ] );
Expand All @@ -118,8 +111,8 @@

info = spttrf( N, D, E );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 2.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

N = 7;

Expand All @@ -131,8 +124,8 @@

info = spttrf( N, D, E );
t.strictEqual( info, 0, 'returns expected value' );
isApprox( t, D, expectedD, 15.0 );
isApprox( t, E, expectedE, 2.0 );
isApprox( t, D, expectedD, ULP );
isApprox( t, E, expectedE, ULP );

t.end();
});
Expand Down