forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
776f925
commit a712830
Showing
15 changed files
with
665 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,75 @@ | ||
<!-- | ||
@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. | ||
--> | ||
|
||
# cosecant | ||
|
||
> Compute the [cosecant][cosecant] of a number. | ||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var csc = require( '@stdlib/math/base/special/csc' ); | ||
``` | ||
|
||
#### csc( x ) | ||
|
||
Computes the [cosecant][cosecant] of a `number` (in radians). | ||
|
||
```javascript | ||
var v = csc( 0.0 ); | ||
// returns ~Infinity | ||
|
||
v = csc( 3.141592653589793/2.0 ); | ||
// returns ~1.0 | ||
|
||
v = csc( -3.141592653589793/6.0 ); | ||
// returns ~-2.0 | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var linspace = require( '@stdlib/array/base/linspace' ); | ||
var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); | ||
var csc = require( '@stdlib/math/base/special/csc' ); | ||
|
||
var x = linspace( 0.0, TWO_PI, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( csc( x[ i ] ) ); | ||
} | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
72 changes: 72 additions & 0 deletions
72
lib/node_modules/@stdlib/math/base/special/csc/benchmark/benchmark.js
This file contains 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,72 @@ | ||
/** | ||
* @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 bench = require( '@stdlib/bench' ); | ||
var randu = require( '@stdlib/random/base/randu' ); | ||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var pkg = require( './../package.json' ).name; | ||
var csc = require( './../lib' ); | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg, function benchmark( b ) { | ||
var x; | ||
var y; | ||
var i; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
x = ( randu()*20.0 ) - 10.0; | ||
y = csc( x ); | ||
if ( isnan( y ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( y ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::built-in', function benchmark( b ) { | ||
var x; | ||
var y; | ||
var i; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
x = ( randu()*20.0 ) - 10.0; | ||
y = 1 / Math.sin( x ); // eslint-disable-line stdlib/no-builtin-math | ||
if ( isnan( y ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( y ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
30 changes: 30 additions & 0 deletions
30
lib/node_modules/@stdlib/math/base/special/csc/examples/index.js
This file contains 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,30 @@ | ||
/** | ||
* @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'; | ||
|
||
var linspace = require( '@stdlib/array/base/linspace' ); | ||
var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); | ||
var csc = require( './../lib' ); | ||
|
||
var x = linspace( 0.0, TWO_PI, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( 'csc(%d) = %d', x[ i ], csc( x[ i ] ) ); | ||
} |
This file contains 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,72 @@ | ||
/** | ||
* @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. | ||
* | ||
* | ||
* ## Notice | ||
* | ||
* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_sin.c}. The implementation follows the original, but has been modified for JavaScript. | ||
* | ||
* ```text | ||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
* | ||
* Developed at SunPro, a Sun Microsystems, Inc. business. | ||
* Permission to use, copy, modify, and distribute this | ||
* software is freely granted, provided that this notice | ||
* is preserved. | ||
* ``` | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
var sin = require('@stdlib/math/base/special/sin/lib'); | ||
|
||
// MAIN // | ||
|
||
/** | ||
* Computes the csc of a number. | ||
* | ||
* ## Method | ||
* csc(x) = 1 / sin(x) | ||
* | ||
* @param {number} x - input value (in radians) | ||
* @returns {number} csc | ||
* | ||
* @example | ||
* var v = csc( 0.0 ); | ||
* // returns ~Infinity | ||
* | ||
* @example | ||
* var v = csc( 3.141592653589793/2.0 ); | ||
* // returns ~1.0 | ||
* | ||
* @example | ||
* var v = csc( -3.141592653589793/6.0 ); | ||
* // returns ~-2.0 | ||
* | ||
* @example | ||
* var v = csc( NaN ); | ||
* // returns NaN | ||
*/ | ||
function csc( x ) { | ||
return 1 / sin( x ); | ||
} | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = csc; |
49 changes: 49 additions & 0 deletions
49
lib/node_modules/@stdlib/math/base/special/csc/lib/index.js
This file contains 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,49 @@ | ||
/** | ||
* @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'; | ||
|
||
/** | ||
* Compute the csc of a number. | ||
* | ||
* @module @stdlib/math/base/special/csc | ||
* | ||
* @example | ||
* var csc = require( '@stdlib/math/base/special/csc' ); | ||
* | ||
* var v = csc( 0.0 ); | ||
* // returns ~Infinity | ||
* | ||
* v = csc( 3.141592653589793/2.0 ); | ||
* // returns ~1.0 | ||
* | ||
* v = csc( -3.141592653589793/6.0 ); | ||
* // returns ~-2.0 | ||
* | ||
* v = csc( NaN ); | ||
* // returns NaN | ||
*/ | ||
|
||
// MODULES // | ||
|
||
var csc = require( '@stdlib/math/base/special/csc/lib/csc' ); | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = csc; |
64 changes: 64 additions & 0 deletions
64
lib/node_modules/@stdlib/math/base/special/csc/package.json
This file contains 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,64 @@ | ||
{ | ||
"name": "@stdlib/math/base/special/sin", | ||
"version": "0.0.0", | ||
"description": "Compute the sine of a number.", | ||
"license": "Apache-2.0", | ||
"author": { | ||
"name": "The Stdlib Authors", | ||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "The Stdlib Authors", | ||
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors" | ||
} | ||
], | ||
"main": "./lib", | ||
"directories": { | ||
"benchmark": "./benchmark", | ||
"doc": "./docs", | ||
"example": "./examples", | ||
"lib": "./lib", | ||
"test": "./test" | ||
}, | ||
"types": "./docs/types", | ||
"scripts": {}, | ||
"homepage": "https://github.com/stdlib-js/stdlib", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/stdlib-js/stdlib.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/stdlib-js/stdlib/issues" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"engines": { | ||
"node": ">=0.10.0", | ||
"npm": ">2.7.0" | ||
}, | ||
"os": [ | ||
"aix", | ||
"darwin", | ||
"freebsd", | ||
"linux", | ||
"macos", | ||
"openbsd", | ||
"sunos", | ||
"win32", | ||
"windows" | ||
], | ||
"keywords": [ | ||
"stdlib", | ||
"stdmath", | ||
"mathematics", | ||
"math", | ||
"math.sin", | ||
"sin", | ||
"sine", | ||
"trig", | ||
"trigonometry", | ||
"radians", | ||
"angle" | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/REQUIRE
This file contains 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,2 @@ | ||
julia 1.5 | ||
JSON 0.21 |
1 change: 1 addition & 0 deletions
1
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/huge_negative.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/huge_positive.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/large_negative.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/large_positive.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/medium_negative.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
lib/node_modules/@stdlib/math/base/special/csc/test/fixtures/julia/medium_positive.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.