-
-
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
ac3852e
commit 024f9f8
Showing
14 changed files
with
666 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,104 @@ | ||
<!-- | ||
@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. | ||
--> | ||
|
||
# atand | ||
|
||
> Compute the [arctangent][arctangent] in degrees of a double-precision floating-point number. | ||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var atand = require( '@stdlib/math/base/special/atand' ); | ||
``` | ||
|
||
#### atand( x ) | ||
|
||
Computes the [arctangent][arctangent] (in degrees) of a double-precision floating-point number. | ||
|
||
```javascript | ||
var sqrt = require( '@stdlib/math/base/special/sqrt' ); | ||
var v = atand( 0.0 ); | ||
// returns 0.0 | ||
|
||
v = atand( 0.5 ); | ||
// returns ~26.57 | ||
|
||
v = atand( 1.0 / sqrt( 3.0 ) ); | ||
// returns ~30.0 | ||
|
||
v = atand( 1.0 ); | ||
// returns 45.0 | ||
|
||
v = atand( Infinity ); | ||
// returns 90.0 | ||
|
||
v = atand( NaN ); | ||
// returns NaN | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var linspace = require( '@stdlib/array/base/linspace' ); | ||
var atand = require( '@stdlib/math/base/special/atand' ); | ||
|
||
var x = linspace( -1.0, 1.0, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( atand( 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"> | ||
|
||
[arctangent]: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions | ||
|
||
<!-- <related-links> --> | ||
|
||
<!-- </related-links> --> | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
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( './../../../../base/assert/is-nan' ); | ||
var pkg = require( './../package.json' ).name; | ||
var atand = 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 = atand( 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(); | ||
}); |
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,27 @@ | ||
|
||
{{alias}}( x ) | ||
Computes the arctangent (in degrees) of a double-precision floating-point | ||
number. | ||
|
||
Parameters | ||
---------- | ||
x: number | ||
Input value. | ||
|
||
Returns | ||
------- | ||
y: number | ||
Arctangent (in degrees). | ||
|
||
Examples | ||
-------- | ||
> var y = {{alias}}( 0.0 ) | ||
0.0 | ||
> y = {{alias}}( {{alias:@stdlib/constants/float64/pi}}/6.0 ) | ||
~27.64 | ||
> y = {{alias}}( NaN ) | ||
NaN | ||
|
||
See Also | ||
-------- | ||
|
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 arctangent (in degrees) of a double-precision floating-point number. | ||
* | ||
* @param x - input value | ||
* @returns arctangent (in degrees) | ||
* | ||
* @example | ||
* var v = atand( 0.0 ); | ||
* // returns 0.0 | ||
* | ||
* @example | ||
* var v = atand( 0.5 ); | ||
* // returns ~26.57 | ||
* | ||
* @example | ||
* var v = atand( 1 / Math.sqrt( 3 ) ); | ||
* // returns ~30.0 | ||
* | ||
* @example | ||
* var v = atand( 1 ); | ||
* // returns 45.0 | ||
* | ||
* @example | ||
* var v = atand( Infinity ); | ||
* // returns 90.0 | ||
* | ||
* @example | ||
* var v = atand( NaN ); | ||
* // returns NaN | ||
*/ | ||
declare function atand( x: number ): number; | ||
|
||
|
||
// EXPORTS // | ||
|
||
export = atand; |
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 atand = require( './index' ); | ||
|
||
|
||
// TESTS // | ||
|
||
// The function returns a number... | ||
{ | ||
atand( 0.5 ); // $ExpectType number | ||
} | ||
|
||
// The compiler throws an error if the function is provided a value other than a number... | ||
{ | ||
atand( true ); // $ExpectError | ||
atand( false ); // $ExpectError | ||
atand( null ); // $ExpectError | ||
atand( undefined ); // $ExpectError | ||
atand( '5' ); // $ExpectError | ||
atand( [] ); // $ExpectError | ||
atand( {} ); // $ExpectError | ||
atand( ( x: number ): number => x ); // $ExpectError | ||
} | ||
|
||
// The compiler throws an error if the function is provided insufficient arguments... | ||
{ | ||
atand(); // $ExpectError | ||
} |
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 atand = require( './../lib' ); | ||
|
||
var x = linspace( -1.0, 1.0, 100 ); | ||
|
||
var i; | ||
for ( i = 0; i < x.length; i++ ) { | ||
console.log( 'atand(%d) = %d', x[ i ], atand( 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,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 tangent (in degrees) of a double-precision floating-point number. | ||
* | ||
* @module @stdlib/math/base/special/atand | ||
* | ||
* @example | ||
* var atand = require( '@stdlib/math/base/special/atand' ); | ||
* | ||
* var v = atand( 0.0 ); | ||
* // returns 0.0 | ||
* | ||
* var v = atand( 0.5 ); | ||
* // returns ~26.57 | ||
* | ||
* var v = atand( 1.0 / Math.sqrt( 3.0 ) ); | ||
* // returns ~30.0 | ||
* | ||
* var v = atand( 1.0 ); | ||
* // returns 45.0 | ||
* | ||
* var v = atand( Infinity ); | ||
* // returns 90.0 | ||
* | ||
* var v = atand( NaN ); | ||
* // returns NaN | ||
*/ | ||
|
||
// MODULES // | ||
|
||
var main = require( './main.js' ); | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = main; |
Oops, something went wrong.