Skip to content

feat: add math/base/special/sincosd #5837

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

Merged
merged 10 commits into from
Mar 7, 2025

Conversation

anandkaranubc
Copy link
Contributor

@anandkaranubc anandkaranubc commented Mar 7, 2025

Resolves None

Description

What is the purpose of this pull request?

This pull request:

  • Adds the JS and C implementation of the function to compute the sincos of x, where x is in degrees.

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves None

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

---
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: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - 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
---
---
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
---
---
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: na
  - task: lint_javascript_benchmarks
    status: na
  - 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: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: passed
  - task: lint_c_benchmarks
    status: passed
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Mar 7, 2025
@anandkaranubc
Copy link
Contributor Author

Reference implementation

@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 7, 2025

Coverage Report

Package Statements Branches Functions Lines
math/base/special/sincosd $\color{green}249/249$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}249/249$
$\color{green}+100.00\%$

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

@anandkaranubc
Copy link
Contributor Author

Also, the cephes and built-in math benchmarks have been removed because there is no implementation of sincosd in those libraries.

anandkaranubc and others added 2 commits March 6, 2025 23:05
---
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: 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: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - 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: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc anandkaranubc requested a review from gunjjoshi March 7, 2025 07:28
[ NaN, NaN ]


{{alias}}( x, out, stride, offset )
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{{alias}}( x, out, stride, offset )
{{alias}}.assign( x, out, stride, offset )

*
* var out = new Float64Array( 2 );
*
* var v = sincosd( out, 0.0 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* var v = sincosd( out, 0.0 );
* var v = sincosd.assign( 0.0, out, 1, 0 );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On it!

z = [ 0.0, 0.0 ];
v = sincosd( NaN, z, 1, 0 );
t.equal( v, z, 'returns output array' );
t.equal( isnan( v[0] ), true, 'returns NaN' );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t.equal( isnan( v[0] ), true, 'returns NaN' );
t.equal( isnan( v[0] ), true, 'returns expected value' );

Copy link
Member

Choose a reason for hiding this comment

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

@anandkaranubc Can you change this everywhere else in this file and in other test files too, if applicable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! On it right away! Thanks.

{
"name": "@stdlib/math/base/special/sincosd",
"version": "0.0.0",
"description": "Simultaneously compute the sine and cosine an angle measured in degrees.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Simultaneously compute the sine and cosine an angle measured in degrees.",
"description": "Simultaneously compute the sine and cosine of an angle measured in degrees.",


# sincosd

> Simultaneously compute the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] an angle measured in degrees.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> Simultaneously compute the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] an angle measured in degrees.
> Simultaneously compute the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of an angle measured in degrees.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, that's my fault. I will change it in all the files.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!


#### sincosd( x )

Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of a `number` (in degrees).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of a `number` (in degrees).
Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of an `angle` measured in degrees.


#### sincosd.assign( x, out, stride, offset )

Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of a `number` (in degrees) and assigns results to a provided output array.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of a `number` (in degrees) and assigns results to a provided output array.
Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of an `angle` measured in degrees and assigns results to a provided output array.


#### stdlib_base_sincosd( x, &sine, &cosine )

Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of a `number` (in degrees).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of a `number` (in degrees).
Simultaneously computes the [sine][@stdlib/math/base/special/sind] and [cosine][@stdlib/math/base/special/cosd] of an `angle` measured in degrees.

---
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: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - 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: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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: na
  - 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
---
@gunjjoshi
Copy link
Member

Thanks for working on this, @anandkaranubc!

@anandkaranubc
Copy link
Contributor Author

Thanks for working on this, @anandkaranubc!

@gunjjoshi, big thanks to you as well for your review and feedback! Appreciate it! 🙌

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Mar 7, 2025
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Mar 7, 2025
@stdlib-bot
Copy link
Contributor

PR Commit Message

feat: add `math/base/special/sincosd`

PR-URL: https://github.com/stdlib-js/stdlib/pull/5837

Co-authored-by: Gunj Joshi <[email protected]>
Co-authored-by: Karan Anand <[email protected]>
Co-authored-by: Karan Anand <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Gunj Joshi <[email protected]>
Signed-off-by: Gunj Joshi <[email protected]>

Please review the above commit message and make any necessary adjustments.

@Planeshifter Planeshifter merged commit 6d7317a into stdlib-js:develop Mar 7, 2025
29 checks passed
@anandkaranubc anandkaranubc deleted the feat/sincosd branch May 10, 2025 14:33
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. Ready To Merge A pull request which is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants