Created
December 23, 2019 00:28
-
-
Save corba777/0abb42ed9d47b7d0decac6d0d2187afb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open DiffSharp.AD.Float64 | |
open Microsoft.Quantum.Simulation; | |
open Microsoft.Quantum.Simulation.Core; | |
open Microsoft.Quantum.Simulation.Common; | |
open Microsoft.Quantum.Simulation.Simulators; | |
open DiffSharp.Quantum.AD.Float64 | |
[<EntryPoint>] | |
let main argv = | |
use qsim=new QuantumSimulator() | |
let circ(args:DV):D= | |
let cirq=qsim.Get<IAdjointable,Quantum.VariationalQuantumCircuits.Circuit>() | |
let res= DVQ.Expval(qsim,cirq,[|Pauli.PauliZ;Pauli.PauliZ|],2L) args | |
res | |
let args=DV [|Math.PI/4.0; 0.7|] | |
let r= circ(args) | |
let cost(args:DV) :D= | |
let res= circ args | |
D.Sin(D.Abs(res)) - D 1.0 | |
let dcost= grad cost | |
let dr= dcost (args) | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment