Skip to content

Commit

Permalink
Fix issue stdlib-js#225.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdaminraeisi committed Feb 4, 2022
1 parent a712830 commit 98b2e60
Show file tree
Hide file tree
Showing 15 changed files with 666 additions and 0 deletions.
76 changes: 76 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/sec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!--
@license Apache-2.0
Copyright (c) 2018 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

> Compute the [secant][secant] of a number.
<section class="usage">

## Usage

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

#### sec( x )

Computes the [secant][secant] of a `number` (in radians).

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

v = sec( 3.141592653589793/4.0 );
// returns ~1.4144

v = sec( -3.141592653589793/6.0 );
// returns ~1.1547

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

</section>

<!-- /.usage -->

<section class="examples">

## Examples

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

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

var x = linspace( 0.0, TWO_PI, 100 );

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

</section>

<!-- /.examples -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 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 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 / Math.cos( x ); // eslint-disable-line stdlib/no-builtin-math
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();
});
30 changes: 30 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/sec/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 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 TWO_PI = require( '@stdlib/constants/float64/two-pi' );
var sec = require( './../lib' );

var x = linspace( 0.0, TWO_PI, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( 'sec(%d) = %d', x[ i ], sec( x[ i ] ) );
}
46 changes: 46 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/sec/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 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 secant of a number.
*
* @module @stdlib/math/base/special/sec
*
* @example
* var sec = require( '@stdlib/math/base/special/sec' );
*
* var v = sec( 0.0 );
* // returns 1.0
*
* v = sec( 3.141592653589793/4.0 );
* // returns ~1.4144
*
* v = sec( -3.141592653589793/6.0 );
* // returns ~1.1547
*/

// MODULES //

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


// EXPORTS //

module.exports = sec;
69 changes: 69 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/sec/lib/sec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 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.
*
*
* ## Notice
*
* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_cos.c}. The implementation follows the original, but has been modified for JavaScript.
*
* ```text
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ```
*/

'use strict';

// MODULES //
var cos = require('@stdlib/math/base/special/cos/lib');

// MAIN //

/**
* Computes the secant of a number.
*
* @param {number} x - input value (in radians)
* @returns {number} secant
*
* @example
* var v = sec( 0.0 );
* // returns 1.0
*
* @example
* var v = sec( 3.141592653589793/4.0 );
* // returns ~1.4144
*
* @example
* var v = sec( -3.141592653589793/6.0 );
* // returns ~1.1547
*
* @example
* var v = sec( NaN );
* // returns NaN
*/
function sec( x ) {
return 1 / cos(x);
}


// EXPORTS //

module.exports = sec;
64 changes: 64 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/sec/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@stdlib/math/base/special/cos",
"version": "0.0.0",
"description": "Compute the cosine of a number.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
},
"contributors": [
{
"name": "The Stdlib Authors",
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
}
],
"main": "./lib",
"directories": {
"benchmark": "./benchmark",
"doc": "./docs",
"example": "./examples",
"lib": "./lib",
"scripts": "./scripts",
"test": "./test"
},
"types": "./docs/types",
"scripts": {},
"homepage": "https://github.com/stdlib-js/stdlib",
"repository": {
"type": "git",
"url": "git://github.com/stdlib-js/stdlib.git"
},
"bugs": {
"url": "https://github.com/stdlib-js/stdlib/issues"
},
"dependencies": {},
"devDependencies": {},
"engines": {
"node": ">=0.10.0",
"npm": ">2.7.0"
},
"os": [
"aix",
"darwin",
"freebsd",
"linux",
"macos",
"openbsd",
"sunos",
"win32",
"windows"
],
"keywords": [
"stdlib",
"stdmath",
"mathematics",
"math",
"math.cos",
"cos",
"cosine",
"trig",
"trigonometry",
"radians"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
julia 1.5
JSON 0.21

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 98b2e60

Please sign in to comment.