Skip to content

Conversation

@0PrashantYadav0
Copy link
Member

@0PrashantYadav0 0PrashantYadav0 commented Mar 5, 2025

Resolves None.

Description

What is the purpose of this pull request?

This pull request:

  • added base implementation for math/base/special/acoshf
  • added benchmark, example and test.
  • added docs and C-implementation.

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@0PrashantYadav0 0PrashantYadav0 marked this pull request as draft March 5, 2025 19:00
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Mar 5, 2025
@0PrashantYadav0
Copy link
Member Author

Depend on #5803

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@Planeshifter Planeshifter added the Potential Duplicate There might be another pull request resolving the same issue. label Mar 15, 2025
@Planeshifter
Copy link
Member

⚠️ Tracking Issue Closure Warning ⚠️

I noticed your PR description contains closing keywords ("Resolves", "Closes", or "Fixes") referencing a "Tracking Issue".

Why this matters:
Tracking issues should typically remain open until all related sub-issues are completed. GitHub automatically closes issues with such closing keywords when the PR is merged.

Required action:
Use "Progresses:" or "Ref:" instead to reference the tracking issue without automatically closing it.

Thank you for your contribution to the project!

@stdlib-bot stdlib-bot removed the Potential Duplicate There might be another pull request resolving the same issue. label Apr 19, 2025
@kgryte
Copy link
Member

kgryte commented Dec 4, 2025

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Dec 4, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Dec 4, 2025
@kgryte kgryte marked this pull request as ready for review December 4, 2025 08:01
@kgryte
Copy link
Member

kgryte commented Dec 4, 2025

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. bot: In Progress Pull request is currently awaiting automation. and removed bot: In Progress Pull request is currently awaiting automation. labels Dec 4, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Dec 4, 2025

Coverage Report

Package Statements Branches Functions Lines
math/base/special/acoshf $\color{red}224/226$
$\color{green}+0.00%$
$\color{red}13/14$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{red}224/226$
$\color{green}+0.00%$

The above coverage report was generated for the changes in this PR.

Comment on lines 32 to 34
var opts = {
'skip': ( typeof Math.acoshf !== 'function' ) // eslint-disable-line stdlib/no-builtin-math
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed. JavaScript does not have Math.acoshf

var y;
var i;

x = uniform( 100, 1.0, 100.0 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing opts argument.

Should be changed to:

    x = uniform( 100, 1.0, 100.0, {
        'dtype': 'float32'
    });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for benchmark.native.js

Comment on lines 76 to 84
/**
* Generates a random number on the interval [0,1).
*
* @return random number
*/
static float rand_float( void ) {
int r = rand();
return (float)r / ( (float)RAND_MAX + 1.0f );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have moved away from using rand_float in our benchmarks. We use this instead:

/**
* Generates a random number on the interval [min,max).
*
* @param min    minimum value (inclusive)
* @param max    maximum value (exclusive)
* @return       random number
*/
static float random_uniform( const float min, const float max ) {
    float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
    return min + ( v*(max-min) );
}

Comment on lines 98 to 100
for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 100.0f*rand_float() ) + 1.0f;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 21 to 29
var linspace = require( '@stdlib/array/base/linspace' );
var acoshf = require( './../lib' );

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

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( 'acoshf( %d ) = %d', x[ i ], acoshf( x[ i ] ) );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use @stdlib/console/log-each-map instead? The above coding structure is outdated now.

Reference: https://github.com/0PrashantYadav0/stdlib/blob/a8785515d4aab7c059e0d1c45e62f656404e5f45/lib/node_modules/%40stdlib/math/base/special/log1pf/examples/index.js#L21-L30


// VARIABLES //

var HUGE = 1 << 28; // 2**28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var HUGE = f32( 1 << 28 ); // 2**28

var t;
var s;
x = f32( x );
if ( isnanf( x ) || x < 1.0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ( isnanf( x ) || x < f32( 1.0 ) ) {

This applies to all the numbers below too. Like 0.0, 1.0, 2.0, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 98 to 99
var s;
x = f32( x );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	var s;

	x = f32( x );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a space between the variable declarations and rest of the code makes it a bit cleaner :)

Comment on lines 65 to 75
```javascript
var linspace = require( '@stdlib/array/base/linspace' );
var acoshf = require( '@stdlib/math/base/special/acoshf' );

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be updated accordingly.

Comment on lines 173 to 180
* * *

## See Also

- <span class="package-name">[`@stdlib/math/base/special/acos`][@stdlib/math/base/special/acos]</span><span class="delimiter">: </span><span class="description">compute the arccosine of a double-precision floating-point number.</span>
- <span class="package-name">[`@stdlib/math/base/special/asinh`][@stdlib/math/base/special/asinh]</span><span class="delimiter">: </span><span class="description">compute the hyperbolic arcsine of a double-precision floating-point number.</span>
- <span class="package-name">[`@stdlib/math/base/special/atanh`][@stdlib/math/base/special/atanh]</span><span class="delimiter">: </span><span class="description">compute the hyperbolic arctangent of a double-precision floating-point number.</span>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove these as these get automatically populated, through our automation scripts.

Comment on lines 193 to 197
[@stdlib/math/base/special/acos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/acos

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

[@stdlib/math/base/special/atanh]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/atanh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for these.

Signed-off-by: Nakul Krishnakumar <[email protected]>
Updated the benchmark for acoshf to use float32 dtype and removed the built-in benchmark.

Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
@anandkaranubc
Copy link
Contributor

/stdlib lint-autofix

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Dec 5, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Dec 5, 2025
anandkaranubc and others added 8 commits December 4, 2025 21:28
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Signed-off-by: Nakul Krishnakumar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants