q#量子编程语言_Q#简介-Microsoft的量子计算语言

q#量子编程语言

In this article, I’ll introduce you to Q# — the new programming language from Microsoft for quantum computing. We will cover Q# data types, expressions, and statements with the help of code snippets.

在本文中,我将向您介绍Q#,这是Microsoft用于量子计算的新编程语言。 我们将在代码片段的帮助下介绍Q#数据类型,表达式和语句。

先决条件 (Prerequisites)

For an overview of quantum computing, please visit my earlier article: An Introduction To Quantum Computing. There, I also describe how to install Quantum Development Kit (QDK) in Visual Studio 2017.

有关量子计算的概述,请访问我之前的文章: 《量子计算入门》 。 在那里,我还将介绍如何在Visual Studio 2017中安装Quantum Development Kit(QDK)。

什么是Q? (What is Q?)

According to Microsoft:

根据微软的说法:

Q# is a scalable, multi-paradigm, domain-specific programming language for quantum computing.

Q#是用于量子计算的可伸缩,多范式,特定领域的编程语言。

So, what do these terms actually mean? Let us dive into the details.

那么,这些术语实际上意味着什么? 让我们深入探讨细节。

  • Scalable

    可扩展

    Scalable Q# allows us to write code that can be executed on machines of varying computing abilities. We can use it to simulate a few Qubits on our local machine, or even thousands of Qubits for an enterprise level application.

    可扩展 Q#允许我们编写可以在各种计算能力的机器上执行的代码。 我们可以使用它来模拟本地计算机上的几个Qubit,或者用于企业级应用程序的数千个Qubit。

  • Multi-paradigm

    多范式

    Multi-paradigm Q# is a multi-paradigm programming language. It supports both functional and imperative programming styles. If you are new to programming paradigms, I suggest you refer here.

    多范式 Q#是一种多范式编程语言。 它支持功能性和命令式编程风格。 如果您不熟悉编程范例,建议您在这里参考。

  • Domain-specific

    特定领域

    Domain-specific Q# is a programming language for quantum computing. It is to be used for writing algorithms and code snippets that are executed on quantum processors.

    特定领域 Q#是用于量子计算的编程语言。 它用于编写在量子处理器上执行的算法和代码段。

Q开发入门 (Getting started with Q development)

This article will assume you have already installed QDK for Visual Studio 2017. If not, then you can check my earlier article for instructions.

本文将假定您已经安装了适用于Visual Studio 2017的QDK。如果未安装,则可以查看我之前的文章以获取说明。

After you have successfully installed QDK, we need to verify if Visual Studio 2017 has all the required dependencies installed for Q# development. For this, we will clone and execute the quantum sample programs from GitHub provided by Microsoft.

成功安装QDK后,我们需要验证Visual Studio 2017是否已安装Q#开发所需的所有依赖项。 为此,我们将从Microsoft提供的GitHub中克隆并执行量子示例程序。

Open VS 2017 and navigate to Team >> Manage Connections.

打开VS 2017并导航至团队>>管理连接。

Select Clone under Local Git Repositories and enter the URL: https://github.com/Microsoft/Quantum.git and click “Clone”.

在“本地Git存储库”下选择“克隆”,然后输入URL: https : //github.com/Microsoft/Quantum.git并单击“克隆”。

The repository will be cloned on your local computer and Visual Studio will switch to the Solution Explorer. It will display all the cloned libraries and samples.

该存储库将被克隆到您的本地计算机上,Visual Studio将切换到解决方案资源管理器。 它将显示所有克隆的库和样本。

Now, open QsharpLibraries.sln solution.

现在,打开QsharpLibraries.sln解决方案。

If you are prompted with the “Install Missing Features popup box, click “Install” to allow the installation of the necessary features. This will download and install F# and other tools used by some of the samples. Make sure that you are connected to the internet.

如果系统提示您“安装缺少的功能弹出框,请单击“安装”以允许安装必要的功能。 这将下载并安装某些示例使用的F#和其他工具。 确保您已连接到互联网。

To execute a sample program, right-click on the TeleportationSample project in “Samples > 0.Introduction folder” of QsharpLibraries solution, and then click on “Set as Startup Project” and press F5.

要执行示例程序,请右键单击QsharpLibrari es解决方案的“示例> 0.Introduction文件夹” 的<

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值