摘要:是一個(gè)多量子位的量子計(jì)算機(jī)模擬器玩具,用行的所編寫(xiě)。這段代碼可以讓你輕松了解量子計(jì)算機(jī)如何遵循線性代數(shù)來(lái)計(jì)算的主要代碼來(lái)自如果你對(duì)用所寫(xiě)的高效高性能的硬件量子計(jì)算模擬器有興趣,可以點(diǎn)擊來(lái)查看更多內(nèi)容。
簡(jiǎn)評(píng):讓你更輕松地明白,量子計(jì)算機(jī)如何遵循線性代數(shù)計(jì)算的。
這是個(gè) GItHub 項(xiàng)目,可以簡(jiǎn)單了解一下。
qusim.py 是一個(gè)多量子位的量子計(jì)算機(jī)模擬器(玩具?),用 150 行的 python 所編寫(xiě)。
這段代碼可以讓你輕松了解量子計(jì)算機(jī)如何遵循線性代數(shù)來(lái)計(jì)算的!
from QuSim import QuantumRegister ############################################# # Introduction # ############################################# # Here Will Be A Few Example of Different # # Quantum States / Algorithms, So You Can # # Get A Feel For How The Module Works, and # # Some Algorithmic Ideas # ############################################# ############################################# # Quantum Measurement # ############################################# # This experiment will prepare 2 states, of a # Single qubit, and of 5 qubits, and will just # Measure them OneQubit = QuantumRegister(1) # New Quantum Register of 1 Qubit print("One Qubit: " + OneQubit.measure()) # Should Print "One Qubit: 0" FiveQubits = QuantumRegister(5) # New Quantum Register of 5 Qubits # Should Print "Five Qubits: 00000" print("Five Qubits: " + FiveQubits.measure()) ############################################# # Swap 2 Qubits # ############################################# # Here, We Will Apply a Pauli-X Gate / NOT Gate # To the first qubit, and then after the algorithm, # it will be swapped to the second qubit. Swap = QuantumRegister(2) # New Quantum Register of 2 qubits Swap.applyGate("X", 1) # Apply The NOT Gate. If Measured Now, it should be 10 # Start the swap algorithm Swap.applyGate("CNOT", 1, 2) Swap.applyGate("H", 1) Swap.applyGate("H", 2) Swap.applyGate("CNOT", 1, 2) Swap.applyGate("H", 1) Swap.applyGate("H", 2) Swap.applyGate("CNOT", 1, 2) # End the swap algorithm print("SWAP: |" + Swap.measure() + ">") # Measure the State, Should be 01 ############################################# # Fair Coin Flip # ############################################# # Shown in this "Experiment", is a so called "Fair Coin Flip", # Where a state will be prepared, that has an equal chance of # Flipping to Each Possible State. to do this, the Hadamard # Gate will be used. # New Quantum Register of 1 Qubit (As a coin has only 2 states) FairCoinFlip = QuantumRegister(1) # If measured at this point, it should be |0> # Apply the hadamard gate, now theres an even chance of measuring 0 or 1 FairCoinFlip.applyGate("H", 1) # Now, the state will be measured, flipping the state to # either 0 or 1. If its 0, we will say "Heads", or if its # 1, we will say "Tails" FairCoinFlipAnswer = FairCoinFlip.measure() # Now its flipped, so we can test if FairCoinFlipAnswer == "0": print("FairCoinFlip: Heads") elif FairCoinFlipAnswer == "1": print("FairCoinFlip: Tails") ############################################# # CNOT Gate # ############################################# # In this experiment, 4 states will be prepared, {00, 01, 10, 11} # And then the same CNOT Gate will be run on them, # To Show The Effects of the CNOT. The Target Qubit will be 2, and the control 1 # New Quantum Register of 2 Qubits, done 4 times. # If any are measured at this time, the result will be 00 ZeroZero = QuantumRegister(2) ZeroOne = QuantumRegister(2) OneZero = QuantumRegister(2) OneOne = QuantumRegister(2) # Now prepare Each Into The State Based On Their Name # ZeroZero Will be left, as thats the first state anyway ZeroOne.applyGate("X", 2) OneZero.applyGate("X", 1) OneOne.applyGate("X", 1) OneOne.applyGate("X", 2) # Now, a CNOT Will Be Applied To Each. ZeroZero.applyGate("CNOT", 1, 2) ZeroOne.applyGate("CNOT", 1, 2) OneZero.applyGate("CNOT", 1, 2) OneOne.applyGate("CNOT", 1, 2) # Print the results. print("CNOT on 00: |" + ZeroZero.measure() + ">") print("CNOT on 01: |" + ZeroOne.measure() + ">") print("CNOT on 10: |" + OneZero.measure() + ">") print("CNOT on 11: |" + OneOne.measure() + ">")
主要代碼來(lái)自:corbett/QuantumComputing.
如果你對(duì)用 RUST 所寫(xiě)的高效、高性能的硬件量子計(jì)算模擬器有興趣,可以點(diǎn)擊 QCGPU 來(lái)查看更多內(nèi)容。
GITHUB 地址:adamisntdead/QuSimPy
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/45554.html
摘要:一個(gè)量子計(jì)算過(guò)程完成,而其中最關(guān)鍵的就是這枚玻璃片。最大規(guī)模是此次金賢敏團(tuán)隊(duì)發(fā)布的光量子芯片的一個(gè)關(guān)鍵詞。所謂模擬量子計(jì)算機(jī),就是指專(zhuān)用量子計(jì)算機(jī)。5月15日,金賢敏教授展示制備的芯片。新華社記者 丁汀攝一個(gè)個(gè)肉眼看不見(jiàn)的單光子穿過(guò)透明的玻璃片,幾秒之后,顯示屏幕上呈現(xiàn)出單光子的二維量子行走演化結(jié)果。一個(gè)量子計(jì)算過(guò)程完成,而其中最關(guān)鍵的就是這枚玻璃片。在燈光下,從某個(gè)角度看去,這枚完全透明的...
摘要:橡樹(shù)嶺國(guó)家實(shí)驗(yàn)室的研究人員通過(guò)使用基于的方法,將數(shù)千個(gè)網(wǎng)絡(luò)劃分開(kāi),在超過(guò)個(gè)上運(yùn)行,從而進(jìn)行大規(guī)模深度學(xué)習(xí)。神經(jīng)元裝置,特別是那些像橡樹(shù)嶺國(guó)家實(shí)驗(yàn)室開(kāi)發(fā)的脈沖神經(jīng)網(wǎng)絡(luò),,可以卸載一些包含時(shí)間序列元素神經(jīng)網(wǎng)絡(luò)。 橡樹(shù)嶺國(guó)家實(shí)驗(yàn)室圖從系統(tǒng)的架構(gòu)的復(fù)雜性上來(lái)講,摩爾定律很難對(duì)其適用。盡管如此,過(guò)去兩年來(lái),我們一直在迎來(lái)了新一輪針對(duì)深度學(xué)習(xí)和其他專(zhuān)業(yè)工作的新架構(gòu)熱潮,并涌現(xiàn)出FPGA、更快的GPU,以...
摘要:截至年月,全國(guó)已有個(gè)省區(qū)市發(fā)布了人工智能規(guī)劃,其中個(gè)制定了具體的產(chǎn)業(yè)規(guī)模發(fā)展目標(biāo)。年我國(guó)企業(yè)相繼發(fā)布人工智能芯片。五大數(shù)據(jù)發(fā)展情況在促進(jìn)大數(shù)據(jù)發(fā)展行動(dòng)綱要等政策的指 showImg(http://upload-images.jianshu.io/upload_images/13825820-5b1886a2a4a6c96f.jpg?imageMogr2/auto-orient/stri...
摘要:據(jù)阿里云官方消息報(bào)道,兩次理論計(jì)算機(jī)最高獎(jiǎng)哥德?tīng)柂?jiǎng)得主匈牙利裔美國(guó)計(jì)算機(jī)科學(xué)家馬里奧塞格德入職阿里巴巴達(dá)摩院位于西雅圖的阿里云量子實(shí)驗(yàn)室。據(jù)阿里云官方消息報(bào)道,兩次理論計(jì)算機(jī)最高獎(jiǎng)哥德?tīng)柂?jiǎng)得主、匈牙利裔美國(guó)計(jì)算機(jī)科學(xué)家馬里奧·塞格德(Mario Szegedy)入職阿里巴巴達(dá)摩院位于西雅圖的阿里云量子實(shí)驗(yàn)室(AQL)。馬里奧·塞格德出生于盛產(chǎn)科學(xué)家的國(guó)度匈牙利,研究領(lǐng)域包括量子計(jì)算和計(jì)算復(fù)雜...
摘要:但問(wèn)題是這一切的改變究竟是怎么發(fā)生的月中下旬,在西雅圖地區(qū)難得的艷陽(yáng)高照里,我受邀前往微軟雷德蒙德總部,近距離探尋微軟轉(zhuǎn)型的秘密。微軟在年公司上市前幾周,搬到現(xiàn)在的雷德蒙德總部。談完戰(zhàn)略轉(zhuǎn)型,再來(lái)聊聊微軟轉(zhuǎn)型的第二場(chǎng)戰(zhàn)役文化變革。為什么是微軟?3月26日,伴隨著史上最軟發(fā)布會(huì)的落幕,蘋(píng)果市值蒸發(fā)100億美元,總市值再次低于9000億美元,這意味著,他們將全球市值第一的王座再次讓給微軟。我相信...
閱讀 1565·2021-10-25 09:44
閱讀 2926·2021-09-04 16:48
閱讀 1543·2019-08-30 15:44
閱讀 2475·2019-08-30 15:44
閱讀 1731·2019-08-30 15:44
閱讀 2816·2019-08-30 14:14
閱讀 2964·2019-08-30 13:00
閱讀 2143·2019-08-30 11:09