1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// This code is part of Cqlib.
//
// (C) Copyright China Telecom Quantum Group 2026
//
// This code is licensed under the Apache License, Version 2.0. You may
// obtain a copy of this license in the LICENSE.txt file in the root directory
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
//
// Any modifications or derivative works of this code must retain this
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.
//! Quantum Ansatz library for variational quantum algorithms.
//!
//! This module provides parameterized quantum circuit templates (ansatze) commonly
//! used in variational quantum algorithms such as VQE (Variational Quantum Eigensolver),
//! QAOA (Quantum Approximate Optimization Algorithm), and Quantum Machine Learning.
//!
//! # Core Concepts
//!
//! An **ansatz** is a parameterized quantum circuit that serves as a trial wavefunction
//! or feature map. The parameters are optimized iteratively by a classical optimizer
//! to minimize a cost function (e.g., the expectation value of a Hamiltonian).
//!
//! # Module Structure
//!
//! - [`traits`]: Defines the core [`Ansatz`] trait that all ansatze implement.
//! - [`two_local`]: Hardware-efficient ansatze with alternating rotation and entanglement layers.
//! - [`facades`]: Convenient constructors for common ansatz patterns (RealAmplitudes, EfficientSU2).
//! - [`feature_map`]: Data encoding circuits, including [`BasisEncoding`], [`AngleEncoding`],
//! [`ZFeatureMap`], [`IQPFeatureMap`], [`ZZFeatureMap`], and [`PauliFeatureMap`].
//! - [`layers`]: Layer-style templates, including [`BasicEntanglerLayers`] and
//! [`StronglyEntanglingLayers`].
//! - [`hamiltonian_evolution`]: Hamiltonian time-evolution ansatz utilities.
//! - [`qaoa`]: The Quantum Approximate Optimization Algorithm ansatz.
//!
//! # Example
//!
//! ```
//! use cqlib_core::circuit::ansatz::{Ansatz, TwoLocal, EntanglementTopology};
//!
//! // Create a TwoLocal ansatz with 3 qubits, linear entanglement
//! let ansatz = TwoLocal::new(3)
//! .reps(2)
//! .entanglement(EntanglementTopology::Linear);
//!
//! // Build the parameterized circuit
//! let circuit = ansatz.build_circuit("theta").unwrap();
//!
//! // The ansatz has a fixed number of parameters
//! assert_eq!(ansatz.num_parameters(), 9); // 3 qubits * 3 layers
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use QAOAAnsatz;
pub use Ansatz;
pub use ;