feat: implement approximate equality of tensors with floating point scalars (#137)#182
feat: implement approximate equality of tensors with floating point scalars (#137)#182dlyongemallo wants to merge 1 commit intozxcalc:masterfrom
Conversation
There was a problem hiding this comment.
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
approxcrate - Adds
AbsDiffEqtrait 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; |
There was a problem hiding this comment.
[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.
No description provided.