Skip to content

Instantly share code, notes, and snippets.

@corba777
Created December 23, 2019 00:28
Show Gist options
  • Save corba777/0abb42ed9d47b7d0decac6d0d2187afb to your computer and use it in GitHub Desktop.
Save corba777/0abb42ed9d47b7d0decac6d0d2187afb to your computer and use it in GitHub Desktop.
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