Skip to content

Commit fe66127

Browse files
committed
chore: generate acosd
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: skipped - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: missing_dependencies - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent bc812da commit fe66127

36 files changed

+3835
-3
lines changed

lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/README__md.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ console.log( ndarray2array( y ) );
212212

213213
<section class="links">
214214

215-
[{{PKG}}]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40{{PKG_LINK_SUFFIX}}
215+
[@stdlib/math/base/special/{{ALIAS}}]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40{{PKG_LINK_SUFFIX}}
216216

217217
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
218218

lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function jsExampleResults2x2EnvVar( values, functionAlias ) {
164164
v = values[ i ];
165165
results = func( v );
166166
results = round( results * 100 ) / 100; // Rounding results to 2 decimal places
167-
vals.push( results.toString() );
167+
vals.push( '~' + results.toString() );
168168
}
169169
topRow = join( slice( vals, 0, 2 ), ', ' );
170170
bottomRow = join( slice( vals, 2, 4 ), ', ' );
@@ -396,7 +396,7 @@ function main() {
396396
// for ( i = 0; i < dataKeys.length; i++ ) {
397397

398398
// dataKey = dataKeys[ i ];
399-
dataKey = '@stdlib/math/base/special/abs';
399+
dataKey = '@stdlib/math/base/special/acosd';
400400
o = DATA[ dataKey ];
401401
alias = o.alias;
402402
console.log( 'Processing function: %s...', alias ); // eslint-disable-line no-console

lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/scaffold.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ pkg_link_suffix=${PKG_LINK_SUFFIX:-''}
130130

131131
## COMPUTED VARIABLES ##
132132

133+
# Converts from camel case to a underscored delineated string.
134+
#
135+
# $1 - string to convert
136+
camelcase_to_snakecase() {
137+
echo "$1" | sed 's/\([^A-Z]\)\([A-Z]\)/\1_\2/g' | sed 's/\([A-Z]\)\([A-Z]\)\([^A-Z]\)/\1_\2\3/g' | tr '[:upper:]' '[:lower:]'
138+
}
139+
140+
# Convert the alias to snakecase:
141+
alias_snakecase=$(camelcase_to_snakecase "${alias}")
142+
133143
# Define the destination package alias:
134144
pkg_alias="${alias_snakecase//_/-}"
135145

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# acosd
22+
23+
> Compute the [arccosine][@stdlib/math/base/special/acosd] for each element in an [ndarray][@stdlib/ndarray/ctor].
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var acosd = require( '@stdlib/math/special/acosd' );
41+
```
42+
43+
#### acosd( x\[, options] )
44+
45+
Computes the [arccosine][@stdlib/math/base/special/acosd] for each element in an [ndarray][@stdlib/ndarray/ctor].
46+
47+
```javascript
48+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
49+
var array = require( '@stdlib/ndarray/array' );
50+
51+
var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] );
52+
var y = acosd( x );
53+
// returns <ndarray>
54+
55+
var arr = ndarray2array( y );
56+
// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ]
57+
```
58+
59+
The function accepts the following arguments:
60+
61+
- **x**: input [ndarray][@stdlib/ndarray/ctor].
62+
- **options**: function options (_optional_).
63+
64+
The function accepts the following options:
65+
66+
- **dtype**: output ndarray [data type][@stdlib/ndarray/dtypes]. Must be a real-valued or generic [data type][@stdlib/ndarray/dtypes].
67+
- **order**: output ndarray [order][@stdlib/ndarray/orders] (i.e., memory layout).
68+
69+
By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [data type][@stdlib/ndarray/dtypes] determined by the function's output data type [policy][@stdlib/ndarray/output-dtype-policies]. To override the default behavior, set the `dtype` option.
70+
71+
```javascript
72+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
73+
var array = require( '@stdlib/ndarray/array' );
74+
var getDType = require( '@stdlib/ndarray/dtype' );
75+
76+
var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] );
77+
var y = acosd( x, {
78+
'dtype': 'generic'
79+
});
80+
// returns <ndarray>
81+
82+
var dt = getDType( y );
83+
// returns 'generic'
84+
85+
var arr = ndarray2array( y );
86+
// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ]
87+
```
88+
89+
By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having the same [order][@stdlib/ndarray/orders] as the input [ndarray][@stdlib/ndarray/ctor]. To return an [ndarray][@stdlib/ndarray/ctor] having a specific memory layout irrespective of the memory layout of the input [ndarray][@stdlib/ndarray/ctor], set the `order` option.
90+
91+
```javascript
92+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
93+
var array = require( '@stdlib/ndarray/array' );
94+
var getOrder = require( '@stdlib/ndarray/order' );
95+
96+
var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] );
97+
var y = acosd( x, {
98+
'order': 'column-major'
99+
});
100+
// returns <ndarray>
101+
102+
var ord = getOrder( y );
103+
// returns 'column-major'
104+
105+
var arr = ndarray2array( y );
106+
// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ]
107+
```
108+
109+
#### acosd.assign( x, y )
110+
111+
Computes the [arccosine][@stdlib/math/base/special/acosd] for each element in an [ndarray][@stdlib/ndarray/ctor] and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].
112+
113+
```javascript
114+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
115+
var array = require( '@stdlib/ndarray/array' );
116+
117+
var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] );
118+
var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] );
119+
120+
var out = acosd.assign( x, y );
121+
// returns <ndarray>
122+
123+
var bool = ( out === y );
124+
// returns true
125+
126+
var arr = ndarray2array( out );
127+
// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ]
128+
```
129+
130+
The function accepts the following arguments:
131+
132+
- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape of the output [ndarray][@stdlib/ndarray/ctor].
133+
- **y**: output [ndarray][@stdlib/ndarray/ctor].
134+
135+
The function supports broadcasting an input [ndarray][@stdlib/ndarray/ctor] to the shape of the output [ndarray][@stdlib/ndarray/ctor] without performing a physical copy of the input [ndarray][@stdlib/ndarray/ctor]'s underlying data.
136+
137+
```javascript
138+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
139+
var zeros = require( '@stdlib/ndarray/zeros' );
140+
var array = require( '@stdlib/ndarray/array' );
141+
142+
// Create a 2x2 input ndarray:
143+
var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] );
144+
145+
// Create a 2x2x2 output ndarray:
146+
var y = zeros( [ 2, 2, 2 ] );
147+
148+
var out = acosd.assign( x, y );
149+
// returns <ndarray>
150+
151+
var arr = ndarray2array( out );
152+
// returns [ [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ], [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] ]
153+
```
154+
155+
</section>
156+
157+
<!-- /.usage -->
158+
159+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
160+
161+
<section class="notes">
162+
163+
## Notes
164+
165+
- The output data type [policy][@stdlib/ndarray/output-dtype-policies] only applies to the main function and specifies that, by default, the function must return an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. For the `assign` method, the output [ndarray][@stdlib/ndarray/ctor] is allowed to have any supported output [data type][@stdlib/ndarray/dtypes].
166+
167+
</section>
168+
169+
<!-- /.notes -->
170+
171+
<!-- Package usage examples. -->
172+
173+
<section class="examples">
174+
175+
## Examples
176+
177+
<!-- eslint no-undef: "error" -->
178+
179+
```javascript
180+
var random = require( '@stdlib/random/uniform' );
181+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
182+
var acosd = require( '@stdlib/math/special/acosd' );
183+
184+
var x = random( [ 5, 5 ], -1.0, 1.0 );
185+
console.log( ndarray2array( x ) );
186+
187+
var y = acosd( x );
188+
console.log( ndarray2array( y ) );
189+
```
190+
191+
</section>
192+
193+
<!-- /.examples -->
194+
195+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
196+
197+
<section class="references">
198+
199+
</section>
200+
201+
<!-- /.references -->
202+
203+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
204+
205+
<section class="related">
206+
207+
</section>
208+
209+
<!-- /.related -->
210+
211+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
212+
213+
<section class="links">
214+
215+
[@stdlib/math/base/special/acosd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/acosd
216+
217+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
218+
219+
[@stdlib/ndarray/orders]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/orders
220+
221+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes
222+
223+
[@stdlib/ndarray/output-dtype-policies]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/output-dtype-policies
224+
225+
[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/broadcast-shapes
226+
227+
</section>
228+
229+
<!-- /.links -->
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var bench = require( '@stdlib/bench' );
26+
var random = require( '@stdlib/random/uniform' );
27+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var pow = require( '@stdlib/math/base/special/pow' );
29+
var getData = require( '@stdlib/ndarray/data-buffer' );
30+
var format = require( '@stdlib/string/format' );
31+
var pkg = require( './../package.json' ).name;
32+
var acosd = require( './../lib/main.js' );
33+
34+
35+
// VARIABLES //
36+
37+
var DTYPES = [
38+
'float64',
39+
'float32',
40+
'generic'
41+
];
42+
43+
44+
// FUNCTIONS //
45+
46+
/**
47+
* Creates a benchmark function.
48+
*
49+
* @private
50+
* @param {PositiveInteger} size - array size
51+
* @param {string} dtype - data type
52+
* @returns {Function} benchmark function
53+
*/
54+
function createBenchmark( size, dtype ) {
55+
var x = random( [ size ], -1.0, 1.0, {
56+
'dtype': dtype
57+
});
58+
return benchmark;
59+
60+
/**
61+
* Benchmark function.
62+
*
63+
* @private
64+
* @param {Benchmark} b - benchmark instance
65+
*/
66+
function benchmark( b ) {
67+
var y;
68+
var i;
69+
70+
b.tic();
71+
for ( i = 0; i < b.iterations; i++ ) {
72+
y = acosd( x );
73+
if ( typeof y !== 'object' ) {
74+
b.fail( 'should return an ndarray' );
75+
}
76+
}
77+
b.toc();
78+
if ( isnan( getData( y )[ i%size ] ) ) {
79+
b.fail( 'should not return NaN' );
80+
}
81+
b.pass( 'benchmark finished' );
82+
b.end();
83+
}
84+
}
85+
86+
87+
// MAIN //
88+
89+
/**
90+
* Main execution sequence.
91+
*
92+
* @private
93+
*/
94+
function main() {
95+
var size;
96+
var min;
97+
var max;
98+
var dt;
99+
var f;
100+
var i;
101+
var j;
102+
103+
min = 1; // 10^min
104+
max = 6; // 10^max
105+
106+
for ( j = 0; j < DTYPES.length; j++ ) {
107+
dt = DTYPES[ j ];
108+
for ( i = min; i <= max; i++ ) {
109+
size = pow( 10, i );
110+
f = createBenchmark( size, dt );
111+
bench( format( '%s:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), f );
112+
}
113+
}
114+
}
115+
116+
main();

0 commit comments

Comments
 (0)