Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 29, 2024
1 parent bd28072 commit 1ebb1d3
Show file tree
Hide file tree
Showing 40 changed files with 26,711 additions and 1 deletion.
50 changes: 49 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,40 @@

<!-- /.package -->

<section class="package" id="math-base-special-sec-unreleased">

#### [@stdlib/math/base/special/sec](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/sec)

<details>

<section class="features">

##### Features

- [`ed4c8d6`](https://github.com/stdlib-js/stdlib/commit/ed4c8d65a020d119c4baa1eb6716751c75cf8a07) - add support for secant functionality `math/base/special/sec` [(#3027)](https://github.com/stdlib-js/stdlib/pull/3027)

</section>

<!-- /.features -->

<section class="issues">

##### Closed Issues

This release closes the following issue:

[#225](https://github.com/stdlib-js/stdlib/issues/225)

</section>

<!-- /.issues -->

</details>

</section>

<!-- /.package -->

<section class="package" id="math-base-special-xlogyf-unreleased">

#### [@stdlib/math/base/special/xlogyf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/xlogyf)
Expand All @@ -520,13 +554,26 @@

<!-- /.packages -->

<section class="issues">

### Closed Issues

This release closes the following issue:

[#225](https://github.com/stdlib-js/stdlib/issues/225)

</section>

<!-- /.issues -->

<section class="contributors">

### Contributors

A total of 6 people contributed to this release. Thank you to the following contributors:
A total of 7 people contributed to this release. Thank you to the following contributors:

- Aayush Khanna
- AbhijitRaut04
- Aman Bhansali
- Athan Reines
- Ayaka
Expand All @@ -543,6 +590,7 @@ A total of 6 people contributed to this release. Thank you to the following cont

<details>

- [`ed4c8d6`](https://github.com/stdlib-js/stdlib/commit/ed4c8d65a020d119c4baa1eb6716751c75cf8a07) - **feat:** add support for secant functionality `math/base/special/sec` [(#3027)](https://github.com/stdlib-js/stdlib/pull/3027) _(by AbhijitRaut04, Athan Reines, Philipp Burckhardt)_
- [`b18921a`](https://github.com/stdlib-js/stdlib/commit/b18921a136da2755efccfd6ae23c8b3f5aaa8f4a) - **feat:** add `math/base/special/acosdf` [(#3015)](https://github.com/stdlib-js/stdlib/pull/3015) _(by Aayush Khanna, Athan Reines)_
- [`60522bf`](https://github.com/stdlib-js/stdlib/commit/60522bfc0b5574d348301e788400178156731024) - **docs:** fix operator [(#3039)](https://github.com/stdlib-js/stdlib/pull/3039) _(by Gunj Joshi)_
- [`84b8294`](https://github.com/stdlib-js/stdlib/commit/84b8294c2d5494ff5eaaa2652dda81671e728068) - **feat:** add `math/base/special/nanmaxf` [(#3035)](https://github.com/stdlib-js/stdlib/pull/3035) _(by Gunj Joshi, Athan Reines)_
Expand Down
193 changes: 193 additions & 0 deletions base/special/sec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
<!--
@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.
-->

# Secant

> Evaluate the [secant][trigonometric-functions] of a number.
<section class="intro">

</section>

<section class="usage">

## Usage

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

## sec( x )

Evaluates the [secant][trigonometric-functions] of `x` (in radians).

```javascript
var v = sec( 0.0 );
// returns 1.0

v = sec( 3.141592653589793/2.0 );
// returns 16331239353195370.0

v = sec( -3.141592653589793/3.0 );
// returns ~1.9999999999999996

v = sec( 3.141592653589793/3.0 );
// returns ~1.9999999999999996

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

</section>

<!-- /.usage -->

<section class="examples">

## Examples

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

```javascript
var linspace = require( '@stdlib/array/base/linspace' );
var PI = require( '@stdlib/constants/float64/pi' );
var sec = require( '@stdlib/math/base/special/sec' );

var x = linspace( -PI/2.0, PI/2.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( sec( x[ i ] ) );
}
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/math/base/special/sec.h"
```

#### stdlib_base_sec( x )

Evaluates the [secant][trigonometric-functions] of `x` (in radians).

```c
double out = stdlib_base_sec( 0.0 );
// returns 1.0

out = stdlib_base_cos( 3.141592653589793 / 2.0 );
// returns 6.123233995736766e-17
```

The function accepts the following arguments:

- **x**: `[in] double` input value.

```c
double stdlib_base_sec( const double x );
```
</section>
<!-- /.usage -->
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
<section class="notes">
</section>
<!-- /.notes -->
<!-- C API usage examples. -->
<section class="examples">
### Examples
```c
#include "stdlib/math/base/special/sec.h"
#include <stdio.h>
int main( void ) {
const double x[] = { 0.523, 0.785, 1.047, 3.14 };
double y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_sec( x[ i ] );
printf( "sec(%lf) = %lf\n", x[ i ], y );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- 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 -->
73 changes: 73 additions & 0 deletions base/special/sec/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @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 cos = require( './../../../../base/special/cos' );
var pkg = require( './../package.json' ).name;
var sec = 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() * 20.0) - 10.0;
y = sec( 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();
});

bench( pkg + '::built-in', function benchmark( b ) {
var x;
var y;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = (randu() * 20.0) - 10.0;
y = 1.0 / cos( 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();
});
Loading

0 comments on commit 1ebb1d3

Please sign in to comment.