Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
量子计算机编程:从入门到实践
by
Eric R. Johnston
,
Nicholas Harrigan
,
Mercedes Gimeno-Segovia
July 2021
Beginner to intermediate
274 pages
7h 10m
Chinese
Posts & Telecom Press
Content preview from
量子计算机编程:从入门到实践
量子算术与逻辑
|
79
示例代码
请在
http://oreilly-qc.github.io?p=5-3
上运行本示例。
示例
5-3
有趣的算术
// a += b * b
a
.
addSquared
(
b
);
如图
5-10
所示,执行
a += b * b
将把
b
的平方值与
a
相加。
图
5-10
所示的电路通过重复加法来执行乘法运算,它以
b
中的量子比特为
条件。
对本例来说,可逆性是重要的考虑因素。如果天真地尝试实现
b = b * b
,很快就会发现
没有合适的可逆运算组合,这是因为总会丢失符号位。然而,实现
a += b * b
就可以了,
因为逆转它就会得到
a -= b * b
。
5.6
更多量子运算
现在我们已经有了量子版本的算术电路,可以尝试其他的一些玩法。
5.6.1
量子条件执行
在传统计算机上,如果设置了
if
语句,那么在进行条件判断后会执行逻辑。在判断期间,
CPU
将读取条件值并判断是否执行逻辑。对于
QPU
,由于一个值可能处于既被设置又不
被设置的叠加态,因此以该值为条件的运算可能既执行又不执行。我们可以在更高的层面
上运用这种思想,从而有条件地在叠加态下执行大量数字逻辑。
以图
5-11
为例,对应的程序如示例
5-4
所示。该程序使记为
b
的三量子比特寄存器自增,
但前提是另一个三量子比特寄存器
a
中的整数值处于一定的范围内。通过初始化
a
,使其
处于
|
1
⟩
和
|
5
⟩
的叠加态,最终使
b
处于既自增又不自增的叠加态。
图
5-11
:条件执行
80
|
第
5
章
示例代码
请在
http://oreilly-qc.github.io?p=5-4
上运行本示例。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
JAVASCRIPT之美|聽頂尖程式設計師闡述他們的思維
Anton Kovalyov
Go程序设计语言
艾伦A. A.多诺万, 布莱恩W. 柯尼汉
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
监控运维实践:原则与策略
Mike Julian
Publisher Resources
ISBN: 9787115566355