-
-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #1786 Closes: #39 --------- Signed-off-by: Sai Srikar Dumpeti <[email protected]> Signed-off-by: Philipp Burckhardt <[email protected]> Co-authored-by: stdlib-bot <[email protected]> Co-authored-by: Philipp Burckhardt <[email protected]> Reviewed-by: Philipp Burckhardt <[email protected]>
- Loading branch information
1 parent
665c735
commit bb6ac7e
Showing
14 changed files
with
667 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
lib/node_modules/@stdlib/math/base/special/cscd/README.md
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,103 @@ | ||
<!-- | ||
@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. | ||
--> | ||
|
||
# cscd | ||
|
||
> Compute the [cosecant][cosecant] of a degree. | ||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var cscd = require( '@stdlib/math/base/special/cscd' ); | ||
``` | ||
|
||
#### cscd( x ) | ||
|
||
Computes the [cosecant][cosecant] of `x` (in degrees). | ||
|
||
```javascript | ||
var v = cscd( 30 ); | ||
// returns ~2.0 | ||
|
||
v = cscd( 45 ); | ||
// returns ~1.41 | ||
|
||
v = cscd( 60 ); | ||
// returns ~1.15 | ||
|
||
v = cscd( 90 ); | ||
// returns 1.0 | ||
|
||
v = cscd( 0 ); | ||
// returns Infinity | ||
|
||
v = cscd( NaN ); | ||
// returns NaN | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var linspace = require( '@stdlib/array/base/linspace' ); | ||
var cscd = require( '@stdlib/math/base/special/cscd' ); | ||
|
||
var x = linspace( 1.1, 5.1, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( cscd( x[ i ] ) ); | ||
} | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
||
<section class="related"> | ||
|
||
</section> | ||
|
||
<!-- /.related --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
[cosecant]: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions | ||
|
||
<!-- <related-links> --> | ||
|
||
<!-- </related-links> --> | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
51 changes: 51 additions & 0 deletions
51
lib/node_modules/@stdlib/math/base/special/cscd/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,51 @@ | ||
/** | ||
* @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 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 cscd = 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()*2.0 ) + 1.0; | ||
y = cscd( 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(); | ||
}); |
28 changes: 28 additions & 0 deletions
28
lib/node_modules/@stdlib/math/base/special/cscd/docs/repl.txt
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,28 @@ | ||
|
||
{{alias}}( x ) | ||
Computes the cosecant of a degree. | ||
|
||
Parameters | ||
---------- | ||
x: number | ||
Input value (in degrees). | ||
|
||
Returns | ||
------- | ||
y: number | ||
Cosecant. | ||
|
||
Examples | ||
-------- | ||
> var y = {{alias}}( 1.0 ) | ||
~57.30 | ||
> y = {{alias}}( {{alias:@stdlib/constants/float64/pi}} ) | ||
~18.25 | ||
> y = {{alias}}( -{{alias:@stdlib/constants/float64/pi}} ) | ||
~-18.25 | ||
> y = {{alias}}( NaN ) | ||
NaN | ||
|
||
See Also | ||
-------- | ||
|
56 changes: 56 additions & 0 deletions
56
lib/node_modules/@stdlib/math/base/special/cscd/docs/types/index.d.ts
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,56 @@ | ||
/* | ||
* @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. | ||
*/ | ||
|
||
// TypeScript Version: 4.1 | ||
|
||
/** | ||
* Computes the cosecant of a degree. | ||
* | ||
* @param x - input value (in degrees) | ||
* @returns cosecant | ||
* | ||
* @example | ||
* var v = cscd( 30 ); | ||
* // returns ~2.0 | ||
* | ||
* @example | ||
* var v = cscd( 45 ); | ||
* // returns ~1.41 | ||
* | ||
* @example | ||
* var v = cscd( 60 ); | ||
* // returns ~1.15 | ||
* | ||
* @example | ||
* var v = cscd( 90 ); | ||
* // returns 1.0 | ||
* | ||
* @example | ||
* var v = cscd( 0 ); | ||
* // returns Infinity | ||
* | ||
* @example | ||
* var v = cscd( NaN ); | ||
* // returns NaN | ||
*/ | ||
declare function cscd( x: number ): number; | ||
|
||
|
||
// EXPORTS // | ||
|
||
export = cscd; |
44 changes: 44 additions & 0 deletions
44
lib/node_modules/@stdlib/math/base/special/cscd/docs/types/test.ts
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,44 @@ | ||
/* | ||
* @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. | ||
*/ | ||
|
||
import cscd = require( './index' ); | ||
|
||
|
||
// TESTS // | ||
|
||
// The function returns a number... | ||
{ | ||
cscd( 8 ); // $ExpectType number | ||
} | ||
|
||
// The compiler throws an error if the function is provided a value other than a number... | ||
{ | ||
cscd( true ); // $ExpectError | ||
cscd( false ); // $ExpectError | ||
cscd( null ); // $ExpectError | ||
cscd( undefined ); // $ExpectError | ||
cscd( '5' ); // $ExpectError | ||
cscd( [] ); // $ExpectError | ||
cscd( {} ); // $ExpectError | ||
cscd( ( x: number ): number => x ); // $ExpectError | ||
} | ||
|
||
// The compiler throws an error if the function is provided insufficient arguments... | ||
{ | ||
cscd(); // $ExpectError | ||
} |
29 changes: 29 additions & 0 deletions
29
lib/node_modules/@stdlib/math/base/special/cscd/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,29 @@ | ||
/** | ||
* @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'; | ||
|
||
var linspace = require( '@stdlib/array/base/linspace' ); | ||
var cscd = require( './../lib' ); | ||
|
||
var x = linspace( 1.1, 5.1, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( 'cscd(%d) = %d', x[ i ], cscd( x[ i ] ) ); | ||
} |
55 changes: 55 additions & 0 deletions
55
lib/node_modules/@stdlib/math/base/special/cscd/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,55 @@ | ||
/** | ||
* @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'; | ||
|
||
/** | ||
* Compute the cosecant of a degree. | ||
* | ||
* @module @stdlib/math/base/special/cscd | ||
* | ||
* @example | ||
* var cscd = require( '@stdlib/math/base/special/cscd' ); | ||
* | ||
* var v = cscd( 30 ); | ||
* // returns ~2.0 | ||
* | ||
* var v = cscd( 45 ); | ||
* // returns ~1.41 | ||
* | ||
* var v = cscd( 60 ); | ||
* // returns ~1.15 | ||
* | ||
* var v = cscd( 90 ); | ||
* // returns 1.0 | ||
* | ||
* var v = cscd( 0 ); | ||
* // returns Infinity | ||
* | ||
* var v = cscd( NaN ); | ||
* // returns NaN | ||
*/ | ||
|
||
// MODULES // | ||
|
||
var main = require( './main.js' ); | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = main; |
Oops, something went wrong.
bb6ac7e
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.
Coverage Report
The above coverage report was generated for the changes in this push.