Skip to content

Instantly share code, notes, and snippets.

View mtfishman's full-sized avatar

Matt Fishman mtfishman

View GitHub Profile
@mtfishman
mtfishman / Project.toml
Last active February 11, 2025 23:49
Automatically update the IntegrationTest.yml workflow
[deps]
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
RegistryInstances = "2792f1a3-b283-48e8-9a74-f99dce5104f3"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
@mtfishman
mtfishman / KroneckerIndexing.jl
Last active January 25, 2025 21:58
Kronecker indexing
module KroneckerIndexing
using Kronecker: Kronecker, ⊗
kronecker_arguments(a::AbstractArray) = Kronecker.getmatrices(a)
struct KroneckerIndex
A::Int
B::Int
end
@mtfishman
mtfishman / prepend_explicit_usings.jl
Created January 14, 2025 18:42
Prepend explicit using statements to files in a package that is set up using implicit usings
using ExplicitImports: explicit_imports
using SplitApplyCombine: group
function prepend_line(file, string)
f = open(file, "r+")
buf = IOBuffer()
write(buf, string * "\n")
write(buf, f)
seekstart(buf)
seekstart(f)
@mtfishman
mtfishman / gist:45f0b1e6d26605522a903d30efeca4f7
Created November 21, 2024 00:53
ITensor `PkgTemplates.template`
function template(; user, authors)
@eval begin
using PkgTemplates
default_git_ignore() = [
"*.o",
"*.swp",
".tmp",
"Manifest.toml",
"docs/build/",
".DS_Store",
@mtfishman
mtfishman / small_set_operations.jl
Last active January 19, 2022 19:01
Faster implementations of Julia set operations for small sets, by avoiding converting to `Set`
_setdiff(s) = Base.copymutable(s)
_setdiff(s, itrs...) = _setdiff!(Base.copymutable(s), itrs...)
function _setdiff!(s, itrs...)
for x in itrs
_setdiff!(s, x)
end
return s
end
function _setdiff!(s, itr)
isempty(s) && return s
@mtfishman
mtfishman / models.jl
Created June 16, 2021 15:38
Models for ITensors.jl
using ITensors
# A type that specifies the model. Used
# for dispatch on functions `mpo` and
# `localham_term`.
struct Model{model} end
Model(s::AbstractString) = Model{Symbol(s)}()
# For notation:
@mtfishman
mtfishman / directsum.cc
Last active April 14, 2019 19:45
Partial direct sum in ITensor (as defined in https://arxiv.org/abs/1405.7786)
#include "itensor/all.h"
using namespace itensor;
IQIndex
directSum(IQIndex const& i, IQIndex const& j, Args const& args = Args::global())
{
auto name = args.getString("IndexName","sum");
#ifdef DEBUG
if( i.dir() != j.dir() ) Error("In directSum(IQIndex, IQIndex), input indices must have same arrow direction");