Skip to content

Commit 89b7e76

Browse files
committed
test: complete all tests
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 95bd130 commit 89b7e76

File tree

1 file changed

+200
-0
lines changed

1 file changed

+200
-0
lines changed

lib/node_modules/@stdlib/lapack/base/dgttrf/test/test.ndarray.js

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,206 @@ tape( 'the function performs the `LU` factorization of a real tri diagonal matri
164164
t.end();
165165
});
166166

167+
tape( 'the function supports providing positive strides', function test( t ) {
168+
var expectedIPIV;
169+
var expectedDU2;
170+
var expectedDU;
171+
var expectedDL;
172+
var expectedD;
173+
var info;
174+
var IPIV;
175+
var DU2;
176+
var DU;
177+
var DL;
178+
var D;
179+
var N;
180+
181+
N = 3;
182+
183+
DL = new Float64Array( [ 1.0, 9999.0, 1.0 ] );
184+
D = new Float64Array( [ 2.0, 9999.0, 3.0, 9999.0, 1.0 ] );
185+
DU = new Float64Array( [ 1.0, 9999.0, 1.0 ] );
186+
DU2 = new Float64Array( 2 * (N-2) );
187+
IPIV = new Int32Array( 2 * N );
188+
189+
expectedDL = new Float64Array( [ 0.5, 9999.0, 0.4 ] );
190+
expectedD = new Float64Array( [ 2.0, 9999.0, 2.5, 9999.0, 0.6 ] );
191+
expectedDU = new Float64Array( [ 1.0, 9999.0, 1.0 ] );
192+
expectedDU2 = new Float64Array( [ 0.0, 0.0 ] );
193+
expectedIPIV = new Int32Array( [ 0, 0, 1, 0, 2, 0 ] );
194+
195+
info = dgttrf( N, DL, 2, 0, D, 2, 0, DU, 2, 0, DU2, 2, 0, IPIV, 2, 0 );
196+
t.strictEqual( info, 0, 'returns expected value' );
197+
t.deepEqual( IPIV, expectedIPIV, 'returns expected value' );
198+
isApprox( t, D, expectedD, 1.0 );
199+
isApprox( t, DU, expectedDU, 1.0 );
200+
isApprox( t, DU2, expectedDU2, 1.0 );
201+
isApprox( t, DL, expectedDL, 1.0 );
202+
203+
N = 9;
204+
205+
DL = new Float64Array( [ 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0, 9999.0, 3.0 ] ); // eslint-disable-line max-len
206+
D = new Float64Array( [ 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0, 9999.0, 1.0 ] ); // eslint-disable-line max-len
207+
DU = new Float64Array( [ 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0, 9999.0, 4.0 ] ); // eslint-disable-line max-len
208+
DU2 = new Float64Array( 2 * (N-2) );
209+
IPIV = new Int32Array( 2 * N );
210+
211+
expectedDL = new Float64Array( [ 0.3333333333333333, 9999.0, 0.8181818181818182, 9999.0, 0.6969696969696969, 9999.0, 0.9082568807339449, 9999.0, 0.8493506493506494, 9999.0, -0.7991341991341993, 9999.0, 0.6251127548259066, 9999.0, -0.3327319742618318 ] ); // eslint-disable-line max-len
212+
expectedD = new Float64Array( [ 3.0, 9999.0, 3.6666666666666665, 9999.0, 3.0, 9999.0, 3.3030303030303032, 9999.0, 3.5321100917431192, 9999.0, 3.0, 9999.0, 4.7991341991341994, 9999.0, 3.0, 9999.0, 4.3327319742618320 ] ); // eslint-disable-line max-len
213+
expectedDU = new Float64Array( [ 1.0, 9999.0, -1.3333333333333333, 9999.0, 1.0, 9999.0, -2.7878787878787876, 9999.0, 4.0, 9999.0, 1.0, 9999.0, 3.1965367965367970, 9999.0, 1.0 ] ); // eslint-disable-line max-len
214+
expectedDU2 = new Float64Array( [ 4.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len
215+
expectedIPIV = new Int32Array( [ 1, 0, 1, 0, 3, 0, 3, 0, 4, 0, 6, 0, 6, 0, 8, 0, 8, 0 ] ); // eslint-disable-line max-len
216+
217+
info = dgttrf( N, DL, 2, 0, D, 2, 0, DU, 2, 0, DU2, 2, 0, IPIV, 2, 0 );
218+
t.strictEqual( info, 0, 'returns expected value' );
219+
t.deepEqual( IPIV, expectedIPIV, 'returns expected value' );
220+
isApprox( t, D, expectedD, 1.0 );
221+
isApprox( t, DU, expectedDU, 1.0 );
222+
isApprox( t, DU2, expectedDU2, 1.0 );
223+
isApprox( t, DL, expectedDL, 1.0 );
224+
225+
t.end();
226+
});
227+
228+
tape( 'the function supports providing negative strides', function test( t ) {
229+
var expectedIPIV;
230+
var expectedDU2;
231+
var expectedDU;
232+
var expectedDL;
233+
var expectedD;
234+
var info;
235+
var IPIV;
236+
var DU2;
237+
var DU;
238+
var DL;
239+
var D;
240+
var N;
241+
242+
N = 3;
243+
244+
DL = new Float64Array( [ 1.0, 1.0 ] );
245+
D = new Float64Array( [ 1.0, 3.0, 2.0 ] );
246+
DU = new Float64Array( [ 1.0, 1.0 ] );
247+
DU2 = new Float64Array( N-2 );
248+
IPIV = new Int32Array( N );
249+
250+
expectedDL = new Float64Array( [ 0.4, 0.5 ] );
251+
expectedD = new Float64Array( [ 0.6, 2.5, 2.0 ] );
252+
expectedDU = new Float64Array( [ 1.0, 1.0 ] );
253+
expectedDU2 = new Float64Array( [ 0.0 ] );
254+
expectedIPIV = new Int32Array( [ 2, 1, 0 ] );
255+
256+
info = dgttrf( N, DL, -1, 1, D, -1, 2, DU, -1, 1, DU2, -1, 0, IPIV, -1, 2 );
257+
t.strictEqual( info, 0, 'returns expected value' );
258+
t.deepEqual( IPIV, expectedIPIV, 'returns expected value' );
259+
isApprox( t, D, expectedD, 1.0 );
260+
isApprox( t, DU, expectedDU, 1.0 );
261+
isApprox( t, DU2, expectedDU2, 1.0 );
262+
isApprox( t, DL, expectedDL, 1.0 );
263+
264+
t.end();
265+
});
266+
267+
tape( 'the function supports providing mixed strides', function test( t ) {
268+
var expectedIPIV;
269+
var expectedDU2;
270+
var expectedDU;
271+
var expectedDL;
272+
var expectedD;
273+
var info;
274+
var IPIV;
275+
var DU2;
276+
var DU;
277+
var DL;
278+
var D;
279+
var N;
280+
281+
N = 3;
282+
283+
DL = new Float64Array( [ 1.0, 1.0 ] );
284+
D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
285+
DU = new Float64Array( [ 1.0, 1.0 ] );
286+
DU2 = new Float64Array( N-2 );
287+
IPIV = new Int32Array( N );
288+
289+
expectedDL = new Float64Array( [ 0.4, 0.5 ] );
290+
expectedD = new Float64Array( [ 2.0, 2.5, 0.6 ] );
291+
expectedDU = new Float64Array( [ 1.0, 1.0 ] );
292+
expectedDU2 = new Float64Array( [ 0.0 ] );
293+
expectedIPIV = new Int32Array( [ 0, 1, 2 ] );
294+
295+
info = dgttrf( N, DL, -1, 1, D, 1, 0, DU, -1, 1, DU2, -1, 0, IPIV, 1, 0 );
296+
t.strictEqual( info, 0, 'returns expected value' );
297+
t.deepEqual( IPIV, expectedIPIV, 'returns expected value' );
298+
isApprox( t, D, expectedD, 1.0 );
299+
isApprox( t, DU, expectedDU, 1.0 );
300+
isApprox( t, DU2, expectedDU2, 1.0 );
301+
isApprox( t, DL, expectedDL, 1.0 );
302+
303+
t.end();
304+
});
305+
306+
tape( 'the function supports providing index offsets', function test( t ) {
307+
var expectedIPIV;
308+
var expectedDU2;
309+
var expectedDU;
310+
var expectedDL;
311+
var expectedD;
312+
var info;
313+
var IPIV;
314+
var DU2;
315+
var DU;
316+
var DL;
317+
var D;
318+
var N;
319+
320+
N = 3;
321+
322+
DL = new Float64Array( [ 9999.0, 1.0, 1.0 ] );
323+
D = new Float64Array( [ 9999.0, 2.0, 3.0, 1.0 ] );
324+
DU = new Float64Array( [ 9999.0, 1.0, 1.0 ] );
325+
DU2 = new Float64Array( N-2 + 1 );
326+
IPIV = new Int32Array( N + 1 );
327+
328+
expectedDL = new Float64Array( [ 9999.0, 0.5, 0.4 ] );
329+
expectedD = new Float64Array( [ 9999.0, 2.0, 2.5, 0.6 ] );
330+
expectedDU = new Float64Array( [ 9999.0, 1.0, 1.0 ] );
331+
expectedDU2 = new Float64Array( [ 0.0, 0.0 ] );
332+
expectedIPIV = new Int32Array( [ 0, 0, 1, 2 ] );
333+
334+
info = dgttrf( N, DL, 1, 1, D, 1, 1, DU, 1, 1, DU2, 1, 1, IPIV, 1, 1 );
335+
t.strictEqual( info, 0, 'returns expected value' );
336+
t.deepEqual( IPIV, expectedIPIV, 'returns expected value' );
337+
isApprox( t, D, expectedD, 1.0 );
338+
isApprox( t, DU, expectedDU, 1.0 );
339+
isApprox( t, DU2, expectedDU2, 1.0 );
340+
isApprox( t, DL, expectedDL, 1.0 );
341+
342+
N = 9;
343+
344+
DL = new Float64Array( [ 9999.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] );
345+
D = new Float64Array( [ 9999.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); // eslint-disable-line max-len
346+
DU = new Float64Array( [ 9999.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] );
347+
DU2 = new Float64Array( N-2 + 1 );
348+
IPIV = new Int32Array( N + 1 );
349+
350+
expectedDL = new Float64Array( [ 9999.0, 0.3333333333333333, 0.8181818181818182, 0.6969696969696969, 0.9082568807339449, 0.8493506493506494, -0.7991341991341993, 0.6251127548259066, -0.3327319742618318 ] ); // eslint-disable-line max-len
351+
expectedD = new Float64Array( [ 9999.0, 3.0, 3.6666666666666665, 3.0, 3.3030303030303032, 3.5321100917431192, 3.0, 4.7991341991341994, 3.0, 4.3327319742618320 ] ); // eslint-disable-line max-len
352+
expectedDU = new Float64Array( [ 9999.0, 1.0, -1.3333333333333333, 1.0, -2.7878787878787876, 4.0, 1.0, 3.1965367965367970, 1.0 ] ); // eslint-disable-line max-len
353+
expectedDU2 = new Float64Array( [ 0.0, 4.0, 0.0, 4.0, 0.0, 0.0, 4.0, 0.0 ] ); // eslint-disable-line max-len
354+
expectedIPIV = new Int32Array( [ 0, 1, 1, 3, 3, 4, 6, 6, 8, 8 ] );
355+
356+
info = dgttrf( N, DL, 1, 1, D, 1, 1, DU, 1, 1, DU2, 1, 1, IPIV, 1, 1 );
357+
t.strictEqual( info, 0, 'returns expected value' );
358+
t.deepEqual( IPIV, expectedIPIV, 'returns expected value' );
359+
isApprox( t, D, expectedD, 1.0 );
360+
isApprox( t, DU, expectedDU, 1.0 );
361+
isApprox( t, DU2, expectedDU2, 1.0 );
362+
isApprox( t, DL, expectedDL, 1.0 );
363+
364+
t.end();
365+
});
366+
167367
tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) {
168368
var expectedIPIV;
169369
var expectedDU2;

0 commit comments

Comments
 (0)