quantrs2_symengine_pure/
lib.rs

1// Allow HashMap without generic hasher for simpler API
2#![allow(clippy::implicit_hasher)]
3
4//! # QuantRS2 SymEngine Pure
5//!
6//! A pure Rust symbolic mathematics library for quantum computing.
7//!
8//! This crate provides symbolic computation capabilities without any C/C++ dependencies,
9//! using [egg](https://egraphs-good.github.io/) for e-graph based simplification and
10//! optimization.
11//!
12//! ## Features
13//!
14//! - **Pure Rust**: No C/C++ dependencies, fully portable
15//! - **Symbolic Expressions**: Create and manipulate symbolic mathematical expressions
16//! - **Automatic Differentiation**: Compute symbolic gradients and Hessians
17//! - **E-Graph Optimization**: Advanced expression simplification via equality saturation
18//! - **Quantum Computing**: Specialized support for quantum gates, operators, and states
19//! - **SciRS2 Integration**: Seamless integration with the SciRS2 scientific computing ecosystem
20//!
21//! ## Quick Start
22//!
23//! ```rust,ignore
24//! use quantrs2_symengine_pure::Expression;
25//!
26//! // Create symbolic expressions
27//! let x = Expression::symbol("x");
28//! let y = Expression::symbol("y");
29//!
30//! // Perform operations
31//! let expr = x.clone() * x.clone() + x.clone() * 2.0 * y.clone() + y.clone() * y.clone();
32//! let expanded = expr.expand();
33//!
34//! // Compute derivatives
35//! let dx = expr.diff(&x);
36//!
37//! println!("Expression: {}", expr);
38//! println!("Derivative wrt x: {}", dx);
39//! ```
40//!
41//! ## Policy Compliance
42//!
43//! This crate follows the QuantRS2 policies:
44//! - **Pure Rust Policy**: No C/C++/Fortran dependencies
45//! - **SciRS2 Policy**: Uses `scirs2_core` for complex numbers, arrays, and random generation
46//! - **COOLJAPAN Policy**: Uses `oxicode` for serialization (not bincode)
47//! - **No unwrap Policy**: All fallible operations return Result types
48
49pub mod cache;
50pub mod diff;
51pub mod error;
52pub mod eval;
53pub mod expr;
54pub mod matrix;
55pub mod ops;
56pub mod optimization;
57pub mod parser;
58pub mod pattern;
59pub mod quantum;
60pub mod scirs2_bridge;
61pub mod serialize;
62pub mod simplify;
63
64// Re-export main types
65pub use error::{SymEngineError, SymEngineResult};
66pub use expr::Expression;
67pub use matrix::SymbolicMatrix;
68
69// Re-export SciRS2 types for convenience (following SciRS2 POLICY)
70pub use scirs2_core::Complex64;
71
72/// Library version
73pub const VERSION: &str = env!("CARGO_PKG_VERSION");
74
75/// Check if the library is available (always true for pure Rust implementation)
76#[must_use]
77pub const fn is_available() -> bool {
78    true
79}
80
81/// Check if this is the pure Rust implementation
82#[must_use]
83pub const fn is_pure_rust() -> bool {
84    true
85}