Skip to content

feat: implement approximate equality of tensors with floating point scalars (#137)#182

Open
dlyongemallo wants to merge 1 commit intozxcalc:masterfrom
dlyongemallo:tensor_float_eq
Open

feat: implement approximate equality of tensors with floating point scalars (#137)#182
dlyongemallo wants to merge 1 commit intozxcalc:masterfrom
dlyongemallo:tensor_float_eq

Conversation

@dlyongemallo
Copy link

@dlyongemallo dlyongemallo commented Oct 19, 2025

No description provided.

Copilot AI review requested due to automatic review settings October 19, 2025 22:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements approximate equality comparison for tensors containing floating-point scalars to handle rounding errors in quantum circuit computations. This addresses numerical precision issues where mathematically equivalent operations may produce slightly different floating-point results.

  • Replaces exact tensor equality with approximate equality using the approx crate
  • Adds AbsDiffEq trait import and enables the "approx" feature for ndarray
  • Includes a test demonstrating floating-point tolerance for equivalent circuits with different computation paths

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
quizx/src/equality.rs Updated tensor comparison to use approximate equality with default epsilon tolerance
quizx/Cargo.toml Added "approx" feature to ndarray dependency to enable approximate equality traits

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


use crate::circuit::Circuit;
use crate::graph::GraphLike;
use crate::scalar::Scalar4;
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

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

[nitpick] The Scalar4 import is used only for default_epsilon(). Consider making the epsilon configurable as a parameter to equal_graph_tensor to allow callers to specify their own tolerance levels based on their precision requirements.

Copilot uses AI. Check for mistakes.
@dlyongemallo dlyongemallo changed the title implement approximate equality of tensors with floating point scalars fix: implement approximate equality of tensors with floating point scalars (#137) Oct 20, 2025
@dlyongemallo dlyongemallo changed the title fix: implement approximate equality of tensors with floating point scalars (#137) feat: implement approximate equality of tensors with floating point scalars (#137) Nov 9, 2025
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