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
using BenchmarkTools | |
abstract type AbstrType end | |
struct ConcrType1 <: AbstrType; x::Int; end | |
struct ConcrType2 <: AbstrType; x::Int; end | |
@noinline f(a::ConcrType1)::Int = a.x | |
@noinline f(a::ConcrType2)::Int = a.x | |
n = 1_000_000 |
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
using LinearAlgebra, BenchmarkTools | |
using LinearAlgebra: RealHermSymComplexHerm | |
import Base: cis | |
cis(H::RealHermSymComplexHerm) = cis!(Matrix{complex(eltype(H))}(H),copy(H)) | |
cis!(H::RealHermSymComplexHerm) = cis!(Matrix{complex(eltype(H))}(H),H) | |
function cis!(R::Matrix{<:Complex},H::RealHermSymComplexHerm) | |
# First decompose H into U*Λ*Uᴴ | |
Λ,U = eigen!(H) | |
# Calculate the imaginary exponential of each eigenvalue and multiply |
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
module SymmetricSparseTests | |
using BenchmarkTools | |
import Base: Symmetric, *, A_mul_B!, LinAlg.checksquare | |
function Symmetric(A::SparseMatrixCSC, uplo::Symbol=:U) | |
checksquare(A) | |
Symmetric{eltype(A), typeof(A)}(A, Base.LinAlg.char_uplo(uplo)) # preserve A | |
end | |
(*)(A::Symmetric{TA,SparseMatrixCSC{TA,S}}, x::StridedVecOrMat{Tx}) where {TA,S,Tx} = A_mul_B(A, x) |
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
# Punchout measurement example | |
using Schrodinger | |
const n = 4 # number of qubit states | |
const N = 5 # number of cavity fock states | |
function JC_gen(fc=5, Ej=14, Ec=0.4, ϕ=0) | |
ωc = fc * 2π # cavity frequency | |
Ej′ = Ej*abs(cos(π*ϕ)) # Biased Ej | |
ωq = √(8*Ej′*Ec)*2π # transmon "base" frequency |
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
using BenchmarkTools | |
const ⊗ = kron | |
const ħ = 1.054571800E-34 # in Joules*seconds, 2014 CODATA | |
const ln2 = 0.6931471805599453 | |
function liouvillian(H) | |
Id = eye(H) | |
return -1im/ħ * (Id⊗H - H.'⊗Id) | |
end | |
function gaussian(x,w) | |
return exp(-4ln2*(x/w)^2) |
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
using ProfileView, Gadfly | |
function TFIM_1D_PBC(N,J,H) | |
# Hilbert Space Dimension | |
dim = 2^N | |
# Hamiltonian Matrix | |
ham = zeros(dim,dim) | |
# Build the diagonal part of the Hamiltonian | |
# First loop through the hilbert space | |
for bra in 0:dim-1 |
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
using DataFrames | |
using Gadfly | |
using PyCall | |
@pyimport timeit | |
include("tfim_1D_OBC.jl") | |
# Max number of sites, large values might run out of memory | |
maxN = 15 | |
# Time python code |