Skip to content

feat: add fft/base/fftpack/costi#13200

Open
gunjjoshi wants to merge 6 commits into
stdlib-js:developfrom
gunjjoshi:costi
Open

feat: add fft/base/fftpack/costi#13200
gunjjoshi wants to merge 6 commits into
stdlib-js:developfrom
gunjjoshi:costi

Conversation

@gunjjoshi

@gunjjoshi gunjjoshi commented Jun 29, 2026

Copy link
Copy Markdown
Member

Resolves stdlib-js/metr-issue-tracker#831.

Description

What is the purpose of this pull request?

This pull request:

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding
  • Code Review and debugging

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

Used gpt-5.1-codex-mini to review the package which was initially implemented manually, by copying over a similar package (fft/base/fftpack/cosqi) and modifying it.


@stdlib-js/reviewers

Gunj Joshi added 2 commits June 30, 2026 00:22
---
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_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - 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: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: passed
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - 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_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - 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: passed
  - 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
---
@gunjjoshi gunjjoshi requested a review from a team June 29, 2026 18:58
@gunjjoshi gunjjoshi added Feature Issue or pull request for adding a new feature. METR Pull request associated with the METR project. labels Jun 29, 2026
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jun 29, 2026
@gunjjoshi

Copy link
Copy Markdown
Member Author

The CI tests should pass once #13170 is merged. Marking this PR as a draft PR until then.

@gunjjoshi gunjjoshi marked this pull request as draft June 29, 2026 19:05
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jun 29, 2026
gunjjoshi and others added 3 commits July 6, 2026 18:39
---
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_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - 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: passed
  - 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: passed
  - task: lint_license_headers
    status: passed
---
@kgryte kgryte marked this pull request as ready for review July 7, 2026 01:06
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jul 7, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

@kgryte kgryte removed the Needs Review A pull request which needs code review. label Jul 7, 2026
iw = offsetW;
for ( i = 1; i < ns2; i++ ) {
fk += 1.0;
sc = sincos( fk * dt );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to be using sincos.assign here with a WORKSPACE buffer. Otherwise, you are allocating a new 2-element array for each invocation. It is okay to write to this temporary workspace given that you need to multiply the factors by two. Otherwise, write directly to workspace and then do workspace[ j ] *= 2.0.

If you do the latter, cache the index computations. But also, why are you doing both addition and multiplication for indices? You should be doing iw += strideW. For the other index, define a separate iw variable and do iwc -= strideW, since it seems like you are decrementing the pointer.

In short, I suggest making your pointer arithmetic logic cleaner.

* ↓ ↓ ↓ ↓
* | sine/cosine table | scratch/workspace | twiddle factors | radix factor table |
* ↑ ↑ ↑ ↑
* i = 0 ... N ... 2N-1 ... 3N-2 ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it me, or does this table layout feel off? I feel like the scratch/workspace should start at 2N not 2N-1 and the radix factor table at 3N, not 3N-2. Otherwise, you don't need 3N+34 elements; you only need 3N+32 elements. I get that we are passing N-1 to rffti, so that is where the alignment issues come from, but it is still a bit odd to my eye.

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left initial comments.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. METR Pull request associated with the METR project. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add fft/base/fftpack/costi

3 participants