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/tand #1771

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
101 changes: 101 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/tand/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!--

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

-->

# tand

> Computes the [tangent][trigonometric-functions] of an angle measured in degrees.

<section class="intro">

</section>

<section class="usage">

## Usage

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

#### tand( x )

Evaluates the [tangent][trigonometric-functions] of `x` (in degrees).

```javascript
var v = tand( 0.0 );
// returns 0

v = tand( 60.0 );
// returns ~1.73

v = tand( 90.0 );
// returns Infinity

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

</section>

<!-- /.usage -->

<section class="examples">

## Examples

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

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

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

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

[trigonometric-functions]: https://en.wikipedia.org/wiki/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 tand = 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()*10.0 ) - 5.0;
y = tand( 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 lib/node_modules/@stdlib/math/base/special/tand/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

{{alias}}( x )
Computes the tangent of an angle measured in degrees.

Parameters
----------
x: number
Input value (in degrees).

Returns
-------
y: number
Tangent.

Examples
--------
> var y = {{alias}}( 0.0 )
0.0
> y = {{alias}}( 90.0 )
Infinity
> y = {{alias}}( 60.0 )
~1.73
> y = {{alias}}( NaN )
NaN

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* @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 tangent of an angle measured in degrees
*
* @param x - input value (in degrees)
* @returns tangent
*
* @example
* var v = tand( 0.0 );
* // returns 0
Planeshifter marked this conversation as resolved.
Show resolved Hide resolved
*
* @example
* var v = tand( 60.0 );
* // returns ~1.73
*
* @example
* var v = tand( 90.0 );
* // returns Infinity
*
* @example
* var v = tand( NaN );
* // returns NaN
*/
declare function tand( x: number ): number;


// EXPORTS //

export = tand;
44 changes: 44 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/tand/docs/types/test.ts
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 tand = require( './index' );


// TESTS //

// The function returns a number...
{
tand( 60.0 ); // $ExpectType number
}

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

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

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

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( 'tand(%d) = %d', x[ i ], tand( x[ i ] ) );
}
49 changes: 49 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/tand/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @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 of an angle measured in degrees.
*
* @module @stdlib/math/base/special/tand
*
* @example
* var tand = require( '@stdlib/math/base/special/tand' );
*
* var v = tand( 0.0 );
* // returns 0
Planeshifter marked this conversation as resolved.
Show resolved Hide resolved
*
* v = tand( 90.0 );
* // returns Infinity
*
* v = tand( 60.0 );
* // returns ~1.73
*
* v = tand( NaN );
* // returns NaN
*/

// MODULES //

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


// EXPORTS //

module.exports = main;
Loading
Loading