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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
"""
QuantRS2-Core Python Bindings
This package provides Python bindings for the QuantRS2-Core quantum computing framework,
enabling seamless integration with Python ecosystem tools like NumPy, Jupyter, and
scientific computing libraries.
The QuantRS2-Core framework offers:
- Comprehensive quantum gate implementations
- Advanced quantum decomposition algorithms
- Variational quantum circuits with automatic differentiation
- Quantum sensor networks with distributed sensing capabilities
- Quantum internet simulation with global coverage
- Hardware-specific compilation and optimization
- Error correction and fault-tolerant computing
- Machine learning accelerated quantum algorithms
- Interactive Jupyter notebook visualization tools
- Comprehensive quantum algorithm complexity analysis
Example usage:
>>> import quantrs2_core as qrs
>>>
>>> # Create qubits
>>> q0 = qrs.QubitId(0)
>>> q1 = qrs.QubitId(1)
>>>
>>> # Create quantum gates
>>> h_gate = qrs.create_hadamard_gate(0)
>>> cnot_gate = qrs.create_cnot_gate(0, 1)
>>>
>>> # Get matrix representations
>>> h_matrix = h_gate.matrix()
>>> cnot_matrix = cnot_gate.matrix()
>>>
>>> # Create variational circuits
>>> circuit = qrs.VariationalCircuit(4)
>>> circuit.add_rotation_layer("x")
>>> circuit.add_entangling_layer()
>>>
>>> # Quantum decomposition
>>> import numpy as np
>>> unitary = np.eye(2, dtype=complex)
>>> decomp = qrs.decompose_single_qubit(unitary)
>>>
>>> # Quantum sensor networks
>>> network = qrs.QuantumSensorNetwork(12345)
>>> sensor_id = network.add_sensor("magnetometer", 37.7749, -122.4194)
>>> advantage = network.get_sensor_advantage()
>>>
>>> # Quantum internet
>>> internet = qrs.QuantumInternet()
>>> node_id = internet.add_quantum_node(40.7128, -74.0060, "datacenter")
>>> coverage = internet.get_coverage_percentage()
>>>
>>> # Jupyter visualization tools
>>> circuit_viz = qrs.QuantumCircuitVisualizer(3, "Bell State Circuit")
>>> circuit_viz.add_gate("H", [0], None, 0.99)
>>> circuit_viz.add_gate("CNOT", [0, 1], None, 0.95)
>>> html_output = circuit_viz.to_html() # For Jupyter notebook display
>>>
>>> # Quantum state visualization
>>> import numpy as np
>>> bell_state = np.array([1/np.sqrt(2), 0, 0, 1/np.sqrt(2)], dtype=complex)
>>> state_viz = qrs.QuantumStateVisualizer(bell_state)
>>> probabilities = state_viz.measurement_probabilities()
>>>
>>> # Quantum algorithm complexity analysis
>>> analyzer = qrs.QuantumComplexityAnalyzer("Grover Search")
>>> gates = [("H", [0], None), ("CNOT", [0, 1], None), ("X", [1], None)]
>>> analyzer.analyze_circuit(gates, "Grover", 1000)
>>> report = analyzer.get_analysis_report()
>>> scaling = analyzer.predict_scaling([2000, 4000, 8000])
>>> advantage = analyzer.quantum_advantage_analysis()
>>>
>>> # Real-time quantum system monitoring
>>> config = qrs.MonitoringConfig(monitoring_interval_secs=1.0, data_retention_hours=24.0)
>>> config.set_alert_thresholds(max_gate_error_rate=0.01, max_readout_error_rate=0.05, min_coherence_time_us=50.0)
>>> monitor = qrs.RealtimeMonitor(config)
>>> monitor.start_monitoring()
>>>
>>> # Get real-time metrics
>>> current_metrics = monitor.get_current_metrics(["gate_error_rate", "qubit_coherence_time"])
>>> stats = monitor.get_aggregated_stats("gate_error_rate")
>>> alerts = monitor.get_active_alerts()
>>> recommendations = monitor.get_optimization_recommendations()
>>> status = monitor.get_monitoring_status()
>>>
>>> # NumRS2 integration for high-performance arrays
>>> import numpy as np
>>>
>>> # Create NumRS2 arrays for quantum computations
>>> quantum_state = qrs.numrs2_zeros([4]) # 2-qubit quantum state
>>> gate_matrix = qrs.numrs2_ones([4, 4]) # 2-qubit gate matrix
>>>
>>> # Convert between NumPy and NumRS2
>>> numpy_array = np.array([[1+0j, 0], [0, 1+0j]], dtype=complex)
>>> numrs2_array = qrs.numpy_to_numrs2(numpy_array)
>>> back_to_numpy = numrs2_array.to_numpy()
>>>
>>> # High-performance quantum operations with NumRS2
>>> result = numrs2_array.matmul(numrs2_array) # Matrix multiplication
>>> transposed = numrs2_array.transpose() # Transpose operation
>>> reshaped = numrs2_array.reshape([2, 2]) # Reshape operation
For detailed documentation and examples, visit: https://docs.quantrs2.com
"""
# Import the core Rust module
# Package metadata
=
=
=
=
=
# Re-export main classes and functions for convenience
=
"""Print information about QuantRS2-Core"""
"""Get the version string"""
return