Skip to content

Add some tests and missing float operations to NDArrat#85

Merged
Quafadas merged 2 commits into
mainfrom
floatop_plug
Apr 12, 2026
Merged

Add some tests and missing float operations to NDArrat#85
Quafadas merged 2 commits into
mainfrom
floatop_plug

Conversation

@Quafadas

Copy link
Copy Markdown
Owner

No description provided.

@Quafadas

Copy link
Copy Markdown
Owner Author

@copilot The unaryOps general path all do double to float and back conversions.

Why? Is this necessary? If it’s necessary, can we fold it inline into the general ops helper to aid performance?

… general path ops

Agent-Logs-Url: https://github.com/Quafadas/vecxt/sessions/9ef2fbc7-eb3a-431a-b25c-61b0589dcf55

Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

@copilot The unaryOps general path all do double to float and back conversions.

Why? Is this necessary? If it’s necessary, can we fold it inline into the general ops helper to aid performance?

The explicit .toDouble calls were redundant — Java/Scala widens Float to Double implicitly when calling transcendental functions like Math.exp, Math.log, etc. (since the JVM only provides double-precision versions of those). The .toFloat at the end is still necessary to store the result back into a Float array.

For Math.abs, Java has a float overload (Math.abs(float) → float), so no conversion is needed at all.

Fixed in fb45462:

  • Made unaryOpGeneral inline with inline f: Float => Float (matching the existing flatUnaryOp pattern), so the function body gets inlined at each call site instead of going through a virtual dispatch
  • Removed all redundant .toDouble calls from the general-path lambdas

@Quafadas Quafadas merged commit 71552ea into main Apr 12, 2026
7 checks passed
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.

2 participants