Skip to content

feat: add support for computing the derivative of cardinal sine (cosc) #3122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 69 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
3bd783f
cosc
RiyaChy072 Nov 16, 2024
a00350f
basic index.js file
RiyaChy072 Nov 16, 2024
9e4fb42
added example file
RiyaChy072 Nov 16, 2024
ec5adcb
added makefile inside example folder
RiyaChy072 Nov 16, 2024
a9b0dca
git commit -m "added benchmark folder"
RiyaChy072 Nov 16, 2024
61bdb50
"deleted benchmark"
RiyaChy072 Nov 16, 2024
4dbbcbd
added benchmark.native.js file
RiyaChy072 Nov 16, 2024
df17998
added benchmark.c file
RiyaChy072 Nov 16, 2024
281b664
added makefile inside native folder
RiyaChy072 Nov 16, 2024
383a46d
Markfile
RiyaChy072 Nov 16, 2024
b2262e3
added cosc.h file
RiyaChy072 Nov 16, 2024
e71fa67
added cosc.h file
RiyaChy072 Nov 16, 2024
8094f83
added src file
RiyaChy072 Nov 16, 2024
435f5d4
added addon.c file
RiyaChy072 Nov 16, 2024
ac8d206
added makefile inside src
RiyaChy072 Nov 16, 2024
3a5ce44
added main.c and Makefile
RiyaChy072 Nov 16, 2024
8f43f70
added test file
RiyaChy072 Nov 16, 2024
8063c8c
added test.native.js
RiyaChy072 Nov 16, 2024
bff2f49
added binding.gyp file
RiyaChy072 Nov 16, 2024
61326c6
added binding.gyp file
RiyaChy072 Nov 16, 2024
1244639
added include.gypi file
RiyaChy072 Nov 16, 2024
3577eed
added include.gypi
RiyaChy072 Nov 16, 2024
f16cdd5
"added manifest.json file"
RiyaChy072 Nov 16, 2024
637b54f
Merge branch 'stdlib-js:develop' into derivative-of-cardinal-sine
RiyaChy072 Nov 17, 2024
a7e1419
Merge remote-tracking branch 'upstream/develop' into derivative-of-ca…
stdlib-bot Nov 18, 2024
3d6fbfb
"added README file"
RiyaChy072 Nov 18, 2024
e7ce6a0
Merge branch 'derivative-of-cardinal-sine' of https://github.com/Riya…
RiyaChy072 Nov 18, 2024
8911d84
"added benchmark.js"
RiyaChy072 Nov 18, 2024
4212a00
"added index.js inside examples"
RiyaChy072 Nov 18, 2024
9c5c475
"added test.js"
RiyaChy072 Nov 18, 2024
a52bf3c
"added data.json"
RiyaChy072 Nov 18, 2024
12a250d
added large negative json
RiyaChy072 Nov 18, 2024
b8c0821
added json file
RiyaChy072 Nov 18, 2024
ac9e19c
added json
RiyaChy072 Nov 18, 2024
b1d4355
added require
RiyaChy072 Nov 18, 2024
8a823b2
"added require"
RiyaChy072 Nov 18, 2024
8ca19ed
"added runner.jl"
RiyaChy072 Nov 18, 2024
fd554fe
"added tiny negative json"
RiyaChy072 Nov 18, 2024
56d93d8
"added tiny positive json"
RiyaChy072 Nov 18, 2024
68a161f
"added package.json"
RiyaChy072 Nov 18, 2024
3b85eec
"added repl.txt"
RiyaChy072 Nov 18, 2024
c2c97d1
"added package"
RiyaChy072 Nov 18, 2024
86d0eee
"added index.d.ts"
RiyaChy072 Nov 18, 2024
c0ba73e
"added test.ts"
RiyaChy072 Nov 18, 2024
224c819
"added benchmark.py"
RiyaChy072 Nov 18, 2024
ffdc830
"fixed spacing conventions"
RiyaChy072 Nov 22, 2024
2aa082b
"rectified mistake"
RiyaChy072 Nov 22, 2024
fb22f5d
"added space"
RiyaChy072 Nov 22, 2024
865c8c3
chore: update copyright years
stdlib-bot Nov 22, 2024
ea11a36
"added space"
RiyaChy072 Nov 22, 2024
3e2e301
Merge branch 'derivative-of-cardinal-sine' of https://github.com/Riya…
RiyaChy072 Nov 22, 2024
d6ecae7
Merge branch 'stdlib-js:develop' into derivative-of-cardinal-sine
RiyaChy072 Nov 22, 2024
f8b10ff
"fixed some issues"
RiyaChy072 Nov 23, 2024
520ce51
Merge branch 'derivative-of-cardinal-sine' of https://github.com/Riya…
RiyaChy072 Nov 23, 2024
6fba45c
"made changes"
RiyaChy072 Nov 23, 2024
7d4d17b
"added change"
RiyaChy072 Nov 28, 2024
ec814c0
"updated fixture"
RiyaChy072 Nov 29, 2024
d4ee9c4
"updated json data"
RiyaChy072 Nov 29, 2024
ea93a54
"updated large positive"
RiyaChy072 Nov 30, 2024
19883d7
"fixed large positive"
RiyaChy072 Nov 30, 2024
c87b701
"updated data"
RiyaChy072 Nov 30, 2024
383889c
"added changes"
RiyaChy072 Nov 30, 2024
3aeae28
"added changes"
RiyaChy072 Nov 30, 2024
d90a967
"added changes"
RiyaChy072 Dec 11, 2024
e0e03fa
"added changes"
RiyaChy072 Dec 11, 2024
b824901
"added changes"
RiyaChy072 Dec 11, 2024
e1d2d50
"added changes"
RiyaChy072 Dec 11, 2024
98258a0
"fixed issues"
RiyaChy072 Dec 27, 2024
f808932
"fixed benchmark"
RiyaChy072 Dec 27, 2024
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
89 changes: 89 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/cosc/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 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 sinpi = require( '@stdlib/math/base/special/sinpi' );
var cospi=require('@stdlib/math/base/special/cospi');
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isInfinite = require( '@stdlib/math/base/assert/is-infinite' );
var PI = require( '@stdlib/constants/float64/pi' );


// MAIN //

/**
* Computes the normalized derivative of cardinal sine of a number.
*
* ## Method
*
* For \\( x \neq 0 \\), the normalized derivative of cardinal sine is calculated as
*
* ```tex
* \operatorname{cosc}(x) = \frac{{\operatorname{cos}(\pi x)}-\frac{\operatorname{sin}(\pi x)}{\pi x}}{x}.
* ```
*
* ## Special Cases
*
* ```tex
* \begin{align*}
* \operatorname{cosc}(0) &= 0 & \\
* \operatorname{cosc}(\infty) &= 0 & \\
* \operatorname{cosc}(-\infty) &= 0 & \\
* \operatorname{cosc}(\mathrm{NaN}) &= \mathrm{NaN}
* \end{align*}
* ```
*
* @param {number} x - input value
* @returns {number} derivative of cardinal sine
*
* @example
* var v = cosc( 0.5 );
* // returns ~-1.273
*
* @example
* var v = cosc( -1.2 );
* // returns ~-0.544
*
* @example
* var v = cosc( 0.0 );
* // returns 0.0
*
* @example
* var v = cosc( NaN );
* // returns NaN
*/
function cosc( x ) {
if ( isnan( x ) ) {
return NaN;
}
if ( isInfinite( x ) ) {
return 0.0;
}
if ( x === 0.0 ) {
return 0.0;
}
return (cospi( x ) - (sinpi( x )/(PI*x))) / x;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return (cospi( x ) - (sinpi( x )/(PI*x))) / x;
return ( cospi( x ) - ( sinpi( x ) / ( PI*x ) ) ) / x;

}


// EXPORTS //

module.exports = cosc;
58 changes: 58 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/cosc/lib/native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 addon = require( './../src/addon.node' );


// MAIN //

/**
* Computes the normalized derivative of cardinal sine of a number.
*
* @private
* @param {number} x - input value
* @returns {number} derivative of cardinal sine
*
* @example
* var v = cosc( 0.5 );
* // returns ~-1.273
*
* @example
* var v = cosc( -1.2 );
* // returns ~0.544
*
* @example
* var v = cosc( 0.0 );
* // returns 0.0
*
* @example
* var v = cosc( NaN );
* // returns NaN
*/
function cosc( x ) {
return addon( x );
}


// EXPORTS //

module.exports = cosc;
Loading