Skip to content
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

feat: add math/base/special/acotd #1785

Merged
merged 8 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add math/base/special/acotd
  • Loading branch information
the-r3aper7 committed Mar 9, 2024
commit 4631aeef98fb06befe4d6f426c359892e84eb7a7
100 changes: 100 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/acotd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!--

@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.

-->

# acotd

> Compute the [arccotangent][arccotangent] in degree of a double-precision floating-point number.

<section class="usage">

## Usage

```javascript
var acotd = require( '@stdlib/math/base/special/acotd' );
```

#### acotd( x )

Computes the [arccotangent][arccotangent] (in degree) of a double-precision floating-point number.

```javascript
var sqrt = require( '@stdlib/math/base/special/sqrt' );
var v = acotd( 0.0 );
// returns 90.0

v = acotd( sqrt( 3 ) );
// returns ~30.0

v = acotd( 1 );
// returns 45.0

v = acotd( sqrt( 3 ) / 3 );
// returns ~60.0

v = acotd( NaN );
// returns NaN
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var linspace = require( '@stdlib/array/base/linspace' );

var x = linspace( -1.0, 1.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( acotd( 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">

[arccotangent]: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
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 acotd = 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 = acotd( 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();
});
26 changes: 26 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/acotd/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

{{alias}}( x )
Computes the arccotangent of a double-precision floating-point number.

Parameters
----------
x: number
Input value.

Returns
-------
y: number
Arccotangent (in degree).

Examples
--------
> var y = {{alias}}( 0.0 )
90.0
> y = {{alias}}( {{alias:@stdlib/constants/float64/pi}}/6.0 )
~62.36
> y = {{alias}}( NaN )
NaN

See Also
--------

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 arccotangent (in degree) of a double-precision floating-point number.
*
* @param x - input value
* @returns arccotangent (in degree)
*
* @example
* var v = acotd( 0.0 );
* // returns 90.0
*
* @example
* var v = acotd( Math.sqrt(3) );
* // returns ~30.0
*
* @example
* var v = acotd( 1 );
* // returns 45.0
*
* @example
* var v = acotd( Math.sqrt(3) / 3 );
* // returns ~60.0
*
* @example
* var v = acotd( NaN );
* // returns NaN
*/
declare function acotd( x: number ): number;


// EXPORTS //

export = acotd;
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 acotd = require( './index' );


// TESTS //

// The function returns a number...
{
acotd( 3 ); // $ExpectType number
}

// The compiler throws an error if the function is provided a value other than a number...
{
acotd( true ); // $ExpectError
acotd( false ); // $ExpectError
acotd( null ); // $ExpectError
acotd( undefined ); // $ExpectError
acotd( '5' ); // $ExpectError
acotd( [] ); // $ExpectError
acotd( {} ); // $ExpectError
acotd( ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided insufficient arguments...
{
acotd(); // $ExpectError
}
29 changes: 29 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/acotd/examples/index.js
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 acotd = require( './../lib' );

var x = linspace( -1.0, 1.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( 'acotd(%d) = %d', x[ i ], acotd( x[ i ] ) );
}
53 changes: 53 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/acotd/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @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 arccotangent (in degree) of a double-precision floating-point number.
*
* @module @stdlib/math/base/special/acotd
*
* @example
* var acotd = require( '@stdlib/math/base/special/acotd' );
*
* var v = acotd( 0.0 );
* // returns 90.0
*
* v = acotd( Math.sqrt( 3 ) );
* // returns ~30.0
*
* v = acotd( 1 );
* // returns 45.0
*
* v = acotd( Math.sqrt( 3 ) / 3 );
* // returns ~60.0
*
* v = acotd( NaN );
* // returns NaN
*/


// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading
Loading