Skip to content

Instantly share code, notes, and snippets.

View PhilipVinc's full-sized avatar
🎯
Solving problems...

Filippo Vicentini PhilipVinc

🎯
Solving problems...
View GitHub Profile
#!/bin/bash
SOURCE_DIR=/home/niklas/
TARGET_DIR=/media/Backup/FileBackup
EXCLUDE_FILE=/home/niklas/rsync_excludelist
rsync -avP --exclude-from=${EXCLUDE_FILE} --delete-excluded --delete --stats ${SOURCE_DIR} ${TARGET_DIR}
# add log entry to target dir
LOGFILE="$TARGET_DIR/backup_log"
DATE=$(date)
echo "Last backup on $DATE" >> $LOGFILE
class C(object):
def __init__(self, i, n):
self.i = i
self.n = n
self.psi0 = []
self.tlist = []
def qubit_integrate(self, epsilon, delta, g1, g2, solver):
import qutip
using DifferentialEquations
L = 4;
U=0.1; Δ=0.1; J=0.45; F=1.57;
u₀ = fill(0.2+0.2im, L, 1);
Jmat = J.*(diagm(linspace(1,1,L-1),1)+diagm(linspace(1,1,L-1),-1));
function ff(dα,α,p,t)
dα[:] = (-im*(Δ - U*(α .* conj(α) - 1.0)) - 1/2.0).*α + im*F -im.*(Jmat*α);
end
function gg(dα, α, p, t)
using Distributed, Random
addprocs(3)
@everywhere module Test
using Distributed, Random
# My custom weight class, a vector with a couple of views into itself
struct Weights{T} <: AbstractVector{T}
weights::Vector{T}
a::AbstractVector{T}
@PhilipVinc
PhilipVinc / ast_plotting.jl
Last active March 7, 2019 19:44
Create a MetaGraphs description of the AST of a function and displays it
using LightGraphs, MetaGraphs, GraphPlot, DataStructures
# Create the structures I need...
function create_graph()
mg = MetaDiGraph(DiGraph())
stack = Stack{Any}()
ssastack = Stack{Any}()
# Add a dictionary holding all global references
set_prop!(mg, :global_refs, Dict())
@PhilipVinc
PhilipVinc / minresqlp.jl
Created March 13, 2019 11:20
Minres-QLP
export minresqlp_iterable, minresqlp, minresqlp!
using Printf
import LinearAlgebra: BLAS.axpy!, givensAlgorithm
import Base: iterate
mutable struct MINRESQLPIterable{matT, solT, vecT <: DenseVector, shiftT<: Number, realT <: Real}
A::matT
shift::shiftT
skew_hermitian::Bool
x::solT
@PhilipVinc
PhilipVinc / test_read.jl
Last active July 5, 2019 16:14
Read data from tensor board back into Julia
using TensorBoardLogger, Logging, ValueHistories
function read_event(f::IOStream)
header = read(f, 8)
crc_header = read(f, 4)
# check
crc_header_ck = reinterpret(UInt8, UInt32[TensorBoardLogger.masked_crc32c(header)])
@assert crc_header == crc_header_ck
@PhilipVinc
PhilipVinc / zygote_crash.jl
Created September 19, 2019 18:26
Zygote crashes trying to convert complex to float.
using Zygote
using LinearAlgebra, Statistics
# Create a state of index i
function make_state(i, Nsites)
@assert i<=2^Nsites && i>0
i = i-1
v = Zygote.Buffer(zeros(ComplexF64, Nsites))
for j=1:Nsites
i, loc = divrem(i,2)
@PhilipVinc
PhilipVinc / QuantumOptics.jl
Last active September 25, 2019 13:14
Benchmark QuantumOptics.jl
module QuantumOptics
using TimerOutputs
to = TimerOutput()
@timeit to "using" using SparseArrays, LinearAlgebra
export bases, Basis, GenericBasis, CompositeBasis, basis,
tensor, ⊗, permutesystems, @samebases,
states, StateVector, Bra, Ket, basisstate, norm,
using UnsafeArrays
struct ThreadsCommunicator{A,B,C}
status::A
passthrough::B
nthreads::C
end
function ThreadsCommunicator()
return ThreadsCommunicator(