-
-
Notifications
You must be signed in to change notification settings - Fork 870
feat: add math/base/special/acosd
#1782
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
14e5519
feat: add math/base/special/acosd
saisrikardumpeti 3668700
feat: add math/base/special/acosd
saisrikardumpeti 534155e
Update README.md
saisrikardumpeti f9843d6
Update test.js
saisrikardumpeti a6c8102
Update main.js
saisrikardumpeti 9727da7
feat: add math/base/special/acosd
saisrikardumpeti 1012d35
Apply suggestions from code review
Planeshifter 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
108 changes: 108 additions & 0 deletions
108
lib/node_modules/@stdlib/math/base/special/acosd/README.md
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,108 @@ | ||
<!-- | ||
|
||
@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. | ||
|
||
--> | ||
|
||
# acosd | ||
|
||
> Compute the [arccosine][arccosine] in degrees of a double-precision floating-point number. | ||
|
||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var acosd = require( '@stdlib/math/base/special/acosd' ); | ||
``` | ||
|
||
#### acosd( x ) | ||
|
||
Computes the [arccosine][arccosine] (in degrees) of a double-precision floating-point number. | ||
|
||
```javascript | ||
var sqrt = require( '@stdlib/math/base/special/sqrt' ); | ||
var v = acosd( 0.0 ); | ||
// returns 90.0 | ||
|
||
v = acosd( 0.5 ); | ||
// returns ~60.0 | ||
|
||
v = acosd( sqrt( 2 ) / 2 ); | ||
// returns ~45.0 | ||
|
||
v = acosd( sqrt( 3 ) / 2 ); | ||
// returns ~30.0 | ||
|
||
v = acosd( NaN ); | ||
// returns NaN | ||
``` | ||
|
||
The domain of `x` is restricted to `[-1,1]`. If `|x| > 1`, the function returns `NaN`. | ||
|
||
```javascript | ||
var v = acosd( -3.14 ); | ||
// returns NaN | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var linspace = require( '@stdlib/array/base/linspace' ); | ||
var acosd = require( '@stdlib/math/base/special/acosd' ); | ||
|
||
var x = linspace( -1.0, 1.0, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( acosd( 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"> | ||
|
||
[arccosine]: 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/acosd/benchmark/benchmark.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,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 acosd = 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 = acosd( 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/acosd/docs/repl.txt
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,28 @@ | ||
|
||
{{alias}}( x ) | ||
Computes the arccosine of a double-precision floating-point number. | ||
|
||
If `|x| > 1`, the function returns `NaN`. | ||
|
||
Parameters | ||
---------- | ||
x: number | ||
Input value. | ||
|
||
Returns | ||
------- | ||
y: number | ||
Arccosine (in degrees). | ||
|
||
Examples | ||
-------- | ||
> var y = {{alias}}( 0.0 ) | ||
90.0 | ||
> y = {{alias}}( {{alias:@stdlib/constants/float64/pi}}/6.0 ) | ||
~58.43 | ||
> y = {{alias}}( NaN ) | ||
NaN | ||
|
||
See Also | ||
-------- | ||
|
52 changes: 52 additions & 0 deletions
52
lib/node_modules/@stdlib/math/base/special/acosd/docs/types/index.d.ts
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,52 @@ | ||
/* | ||
* @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 arccosine (in degrees) of a double-precision floating-point number. | ||
* | ||
* @param x - input value | ||
* @returns arccosine (in degrees) | ||
* | ||
* @example | ||
* var v = acosd( 0.0 ); | ||
* // returns 0.0 | ||
* | ||
* @example | ||
* var v = acosd( 0.5 ); | ||
* // returns ~60.0 | ||
* | ||
* @example | ||
* var v = acosd( Math.sqrt( 2 ) / 2 ); | ||
* // returns ~45.0 | ||
* | ||
* @example | ||
* var v = acosd( Math.sqrt( 3 ) / 2 ); | ||
* // returns ~30.0 | ||
* | ||
* @example | ||
* var v = acosd( NaN ); | ||
* // returns NaN | ||
*/ | ||
declare function acosd( x: number ): number; | ||
|
||
|
||
// EXPORTS // | ||
|
||
export = acosd; |
44 changes: 44 additions & 0 deletions
44
lib/node_modules/@stdlib/math/base/special/acosd/docs/types/test.ts
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,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 acosd = require( './index' ); | ||
|
||
|
||
// TESTS // | ||
|
||
// The function returns a number... | ||
{ | ||
acosd( 0.5 ); // $ExpectType number | ||
} | ||
|
||
// The compiler throws an error if the function is provided a value other than a number... | ||
{ | ||
acosd( true ); // $ExpectError | ||
acosd( false ); // $ExpectError | ||
acosd( null ); // $ExpectError | ||
acosd( undefined ); // $ExpectError | ||
acosd( '5' ); // $ExpectError | ||
acosd( [] ); // $ExpectError | ||
acosd( {} ); // $ExpectError | ||
acosd( ( x: number ): number => x ); // $ExpectError | ||
} | ||
|
||
// The compiler throws an error if the function is provided insufficient arguments... | ||
{ | ||
acosd(); // $ExpectError | ||
} |
29 changes: 29 additions & 0 deletions
29
lib/node_modules/@stdlib/math/base/special/acosd/examples/index.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,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 acosd = require( './../lib' ); | ||
|
||
var x = linspace( -1.0, 1.0, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( 'acosd(%d) = %d', x[ i ], acosd( x[ i ] ) ); | ||
} |
52 changes: 52 additions & 0 deletions
52
lib/node_modules/@stdlib/math/base/special/acosd/lib/index.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,52 @@ | ||
/** | ||
* @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 arccosine (in degrees) of a double-precision floating-point number. | ||
* | ||
* @module @stdlib/math/base/special/acosd | ||
* | ||
* @example | ||
* var acosd = require( '@stdlib/math/base/special/acosd' ); | ||
* | ||
* var v = acosd( 0.0 ); | ||
* // returns 90.0 | ||
* | ||
* var v = acosd( 0.5 ); | ||
* // returns ~60.0 | ||
* | ||
* var v = acosd( Math.sqrt( 2 ) / 2 ); | ||
* // returns ~45.0 | ||
* | ||
* var v = acosd( Math.sqrt( 3 ) / 2 ); | ||
* // returns ~30.0 | ||
* | ||
* var v = acosd( NaN ); | ||
* // returns NaN | ||
*/ | ||
|
||
// MODULES // | ||
|
||
var main = require( './main.js' ); | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = main; |
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.
Uh oh!
There was an error while loading. Please reload this page.