Skip to content

refactor(rust): use ndarray's built-in generator functions#7

Merged
CodeWithKyrian merged 1 commit intomainfrom
refactor/use-ndarray-generators
Mar 22, 2026
Merged

refactor(rust): use ndarray's built-in generator functions#7
CodeWithKyrian merged 1 commit intomainfrom
refactor/use-ndarray-generators

Conversation

@CodeWithKyrian
Copy link
Copy Markdown
Contributor

This PR refactors the FFI generator functions (linspace, logspace, geomspace) to use ndarray's built-in Array methods instead of manual implementations.

Motivation and Context

The manual implementations of these generator functions were duplicating logic that ndarray already provides with optimized and well-tested implementations. By switching to ndarray's built-in methods, we reduce code complexity, improve maintainability, and ensure consistent behavior with upstream ndarray.

What's Changed

  • Updated linspace.rs to use Array::linspace() with adjusted stop value for endpoint=false
  • Updated logspace.rs to use Array::logspace()
  • Updated geomspace.rs to use Array::geomspace() with Option handling
  • Removed manual iteration and special-case handling for num=1 in all three generators

Breaking Changes

None. The FFI interface and PHP API remain unchanged.

Replace manual implementations of linspace, logspace, and geomspace with ndarray's Array::linspace, Array::logspace, and Array::geomspace methods.This leverages ndarray's optimized and well-tested implementations while simplifying our FFI code.
@CodeWithKyrian CodeWithKyrian merged commit 7642835 into main Mar 22, 2026
14 checks passed
@CodeWithKyrian CodeWithKyrian deleted the refactor/use-ndarray-generators branch March 22, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant