Skip to content

Commit f49687d

Browse files
committed
feat: add the JS implementation
--- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - 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 ---
1 parent c27f143 commit f49687d

File tree

2 files changed

+137
-0
lines changed
  • lib/node_modules/@stdlib/math/base/special/chebyshev-t-polynomial/lib

2 files changed

+137
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
/**
22+
* Evaluate the Chebyshev polynomial of the first kind for a degree `n` at a value `x`.
23+
*
24+
* @module @stdlib/math/base/special/chebyshev-t-polynomial
25+
*
26+
* @example
27+
* var chebyshevtpoly = require( '@stdlib/math/base/special/chebyshev-t-polynomial' );
28+
*
29+
* var y = chebyshevtpoly( 0.0, 0.5 );
30+
* // returns -4.0
31+
*
32+
* y = chebyshevtpoly( 1.0, -0.5 );
33+
* // returns 10.0
34+
*
35+
* y = chebyshevtpoly( 5.0, 0.5 );
36+
* // returns 0.0
37+
*
38+
* y = chebyshevtpoly( 2.5, 0.5 );
39+
* // returns NaN
40+
*
41+
* y = chebyshevtpoly( -1.0, 0.5 );
42+
* // returns NaN
43+
*
44+
* y = chebyshevtpoly( NaN, 1.0 );
45+
* // returns NaN
46+
*
47+
* y = chebyshevtpoly( 1.0, NaN );
48+
* // returns NaN
49+
*/
50+
51+
// MODULES //
52+
53+
var main = require( './main.js' );
54+
55+
56+
// EXPORTS //
57+
58+
module.exports = main;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
24+
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
25+
var hyp2f1 = require( '@stdlib/math/base/special/hyp2f1' );
26+
27+
28+
// MAIN //
29+
30+
/**
31+
* Evaluates the Chebyshev polynomial of the first kind for a degree `n` at a value `x`.
32+
*
33+
* @param {NonNegativeNumber} n - degree of the polynomial
34+
* @param {number} x - input value
35+
* @returns {number} polynomial value
36+
*
37+
* @example
38+
* var y = chebyshevtpoly( 0.0, 0.5 );
39+
* // returns 1.0
40+
*
41+
* @example
42+
* var y = chebyshevtpoly( 1.0, -0.5 );
43+
* // returns -0.5
44+
*
45+
* @example
46+
* var y = chebyshevtpoly( 5.0, 0.5 );
47+
* // returns 0.5
48+
*
49+
* @example
50+
* var y = chebyshevtpoly( 2.5, 0.5 );
51+
* // returns NaN
52+
*
53+
* @example
54+
* var y = chebyshevtpoly( -1.0, 0.5 );
55+
* // returns NaN
56+
*
57+
* @example
58+
* var y = chebyshevtpoly( NaN, 1.0 );
59+
* // returns NaN
60+
*
61+
* @example
62+
* var y = chebyshevtpoly( 1.0, NaN );
63+
* // returns NaN
64+
*/
65+
function chebyshevtpoly( n, x ) {
66+
if (
67+
isnan( x ) ||
68+
!isInteger( n ) ||
69+
n < 0.0
70+
) {
71+
return NaN;
72+
}
73+
return hyp2f1( -n, n, 0.5, 0.5*(1-x) );
74+
}
75+
76+
77+
// EXPORTS //
78+
79+
module.exports = chebyshevtpoly;

0 commit comments

Comments
 (0)