-
-
Notifications
You must be signed in to change notification settings - Fork 869
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
RiyaChy072
wants to merge
69
commits into
stdlib-js:develop
Choose a base branch
from
RiyaChy072:derivative-of-cardinal-sine
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
3bd783f
cosc
RiyaChy072 a00350f
basic index.js file
RiyaChy072 9e4fb42
added example file
RiyaChy072 ec5adcb
added makefile inside example folder
RiyaChy072 a9b0dca
git commit -m "added benchmark folder"
RiyaChy072 61bdb50
"deleted benchmark"
RiyaChy072 4dbbcbd
added benchmark.native.js file
RiyaChy072 df17998
added benchmark.c file
RiyaChy072 281b664
added makefile inside native folder
RiyaChy072 383a46d
Markfile
RiyaChy072 b2262e3
added cosc.h file
RiyaChy072 e71fa67
added cosc.h file
RiyaChy072 8094f83
added src file
RiyaChy072 435f5d4
added addon.c file
RiyaChy072 ac8d206
added makefile inside src
RiyaChy072 3a5ce44
added main.c and Makefile
RiyaChy072 8f43f70
added test file
RiyaChy072 8063c8c
added test.native.js
RiyaChy072 bff2f49
added binding.gyp file
RiyaChy072 61326c6
added binding.gyp file
RiyaChy072 1244639
added include.gypi file
RiyaChy072 3577eed
added include.gypi
RiyaChy072 f16cdd5
"added manifest.json file"
RiyaChy072 637b54f
Merge branch 'stdlib-js:develop' into derivative-of-cardinal-sine
RiyaChy072 a7e1419
Merge remote-tracking branch 'upstream/develop' into derivative-of-ca…
stdlib-bot 3d6fbfb
"added README file"
RiyaChy072 e7ce6a0
Merge branch 'derivative-of-cardinal-sine' of https://github.com/Riya…
RiyaChy072 8911d84
"added benchmark.js"
RiyaChy072 4212a00
"added index.js inside examples"
RiyaChy072 9c5c475
"added test.js"
RiyaChy072 a52bf3c
"added data.json"
RiyaChy072 12a250d
added large negative json
RiyaChy072 b8c0821
added json file
RiyaChy072 ac9e19c
added json
RiyaChy072 b1d4355
added require
RiyaChy072 8a823b2
"added require"
RiyaChy072 8ca19ed
"added runner.jl"
RiyaChy072 fd554fe
"added tiny negative json"
RiyaChy072 56d93d8
"added tiny positive json"
RiyaChy072 68a161f
"added package.json"
RiyaChy072 3b85eec
"added repl.txt"
RiyaChy072 c2c97d1
"added package"
RiyaChy072 86d0eee
"added index.d.ts"
RiyaChy072 c0ba73e
"added test.ts"
RiyaChy072 224c819
"added benchmark.py"
RiyaChy072 ffdc830
"fixed spacing conventions"
RiyaChy072 2aa082b
"rectified mistake"
RiyaChy072 fb22f5d
"added space"
RiyaChy072 865c8c3
chore: update copyright years
stdlib-bot ea11a36
"added space"
RiyaChy072 3e2e301
Merge branch 'derivative-of-cardinal-sine' of https://github.com/Riya…
RiyaChy072 d6ecae7
Merge branch 'stdlib-js:develop' into derivative-of-cardinal-sine
RiyaChy072 f8b10ff
"fixed some issues"
RiyaChy072 520ce51
Merge branch 'derivative-of-cardinal-sine' of https://github.com/Riya…
RiyaChy072 6fba45c
"made changes"
RiyaChy072 7d4d17b
"added change"
RiyaChy072 ec814c0
"updated fixture"
RiyaChy072 d4ee9c4
"updated json data"
RiyaChy072 ea93a54
"updated large positive"
RiyaChy072 19883d7
"fixed large positive"
RiyaChy072 c87b701
"updated data"
RiyaChy072 383889c
"added changes"
RiyaChy072 3aeae28
"added changes"
RiyaChy072 d90a967
"added changes"
RiyaChy072 e0e03fa
"added changes"
RiyaChy072 b824901
"added changes"
RiyaChy072 e1d2d50
"added changes"
RiyaChy072 98258a0
"fixed issues"
RiyaChy072 f808932
"fixed benchmark"
RiyaChy072 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
lib/node_modules/@stdlib/math/base/special/cosc/lib/main.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = cosc; |
58 changes: 58 additions & 0 deletions
58
lib/node_modules/@stdlib/math/base/special/cosc/lib/native.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.