Skip to content
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: ITensorQuantumOperatorDefinitions.jl bug report
about: Create a bug report to help us improve ITensorQuantumOperatorDefinitions.jl
name: QuantumOperatorDefinitions.jl bug report
about: Create a bug report to help us improve QuantumOperatorDefinitions.jl
title: "[BUG] YOUR SHORT DESCRIPTION OF THE BUG HERE"
labels: ["bug"]
assignees: ''
Expand Down Expand Up @@ -55,8 +55,8 @@ If you provided a minimal code that demonstrates the bug or unexpected behavior,
julia> versioninfo()
[YOUR OUTPUT HERE]
```
- Output from `using Pkg; Pkg.status("ITensorQuantumOperatorDefinitions")`:
- Output from `using Pkg; Pkg.status("QuantumOperatorDefinitions")`:
```julia
julia> using Pkg; Pkg.status("ITensorQuantumOperatorDefinitions")
julia> using Pkg; Pkg.status("QuantumOperatorDefinitions")
[YOUR OUTPUT HERE]
```
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: ITensorQuantumOperatorDefinitions.jl feature request
about: Suggest an idea for ITensorQuantumOperatorDefinitions.jl
name: QuantumOperatorDefinitions.jl feature request
about: Suggest an idea for QuantumOperatorDefinitions.jl
title: "[ENHANCEMENT] YOUR SHORT DESCRIPTION OF THE FEATURE REQUEST HERE"
labels: ["enhancement"]
assignees: ''
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Please give a summary of the tests that you added to verify your changes.

# Checklist:

- [ ] My code follows the style guidelines of this project. Please run `using JuliaFormatter; format(".")` in the base directory of the repository (`~/.julia/dev/ITensorQuantumOperatorDefinitions`) to format your code according to our style guidelines.
- [ ] My code follows the style guidelines of this project. Please run `using JuliaFormatter; format(".")` in the base directory of the repository (`~/.julia/dev/QuantumOperatorDefinitions`) to format your code according to our style guidelines.
- [ ] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have added tests that verify the behavior of the changes I made.
Expand Down
10 changes: 3 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
name = "ITensorQuantumOperatorDefinitions"
uuid = "fd9b415b-e710-4e2a-b407-cba023081494"
name = "QuantumOperatorDefinitions"
uuid = "826dd319-6fd5-459a-a990-3a4f214664bf"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.1.2"
version = "0.1.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ITensorBase = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
ChainRulesCore = "1.25.1"
ITensorBase = "0.1.8"
LinearAlgebra = "1.10"
julia = "1.10"
80 changes: 43 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ITensorQuantumOperatorDefinitions.jl
# QuantumOperatorDefinitions.jl

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/ITensorQuantumOperatorDefinitions.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/ITensorQuantumOperatorDefinitions.jl/dev/)
[![Build Status](https://github.com/ITensor/ITensorQuantumOperatorDefinitions.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/ITensorQuantumOperatorDefinitions.jl/actions/workflows/Tests.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/ITensor/ITensorQuantumOperatorDefinitions.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/ITensorQuantumOperatorDefinitions.jl)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/QuantumOperatorDefinitions.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/QuantumOperatorDefinitions.jl/dev/)
[![Build Status](https://github.com/ITensor/QuantumOperatorDefinitions.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/QuantumOperatorDefinitions.jl/actions/workflows/Tests.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/ITensor/QuantumOperatorDefinitions.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/QuantumOperatorDefinitions.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

Expand All @@ -26,50 +26,56 @@ if you want to use SSH credentials, which can make it so you don't have to enter
Then, the package can be added as usual through the package manager:

```julia
julia> Pkg.add("ITensorQuantumOperatorDefinitions")
julia> Pkg.add("QuantumOperatorDefinitions")
```

## Examples

````julia
using ITensorBase: ITensor, Index, tags
using ITensorQuantumOperatorDefinitions:
OpName, SiteType, StateName, ValName, op, siteind, siteinds, state, val
using QuantumOperatorDefinitions: OpName, SiteType, StateName, ⊗, controlled, op, state
using LinearAlgebra: Diagonal
using SparseArrays: SparseMatrixCSC, SparseVector
using Test: @test
````

States and operators as Julia arrays
@test state("0") == [1, 0]
@test state("1") == [0, 1]

````julia
@test val(ValName("Up"), SiteType("S=1/2")) == 1
@test val(ValName("Dn"), SiteType("S=1/2")) == 2
@test state(StateName("Up"), SiteType("S=1/2")) == [1, 0]
@test state(StateName("Dn"), SiteType("S=1/2")) == [0, 1]
@test op(OpName("X"), SiteType("S=1/2")) == [0 1; 1 0]
@test op(OpName("Z"), SiteType("S=1/2")) == [1 0; 0 -1]
````
@test state(Float32, "0") == [1, 0]
@test eltype(state(Float32, "1")) === Float32

Index constructors
@test Vector(StateName("0")) == [1, 0]
@test Vector(StateName("1")) == [0, 1]

````julia
@test siteind("S=1/2") isa Index
@test Int(length(siteind("S=1/2"))) == 2
@test "S=1/2" in tags(siteind("S=1/2"))
@test siteinds("S=1/2", 4) isa Vector{<:Index}
@test length(siteinds("S=1/2", 4)) == 4
@test all(s -> "S=1/2" in tags(s), siteinds("S=1/2", 4))
````
@test Vector{Float32}(StateName("0")) == [1, 0]
@test eltype(Vector{Float32}(StateName("0"))) === Float32

States and operators as ITensors
@test state(SparseVector, "0") == [1, 0]
@test state(SparseVector, "0") isa SparseVector

````julia
s = Index(2, "S=1/2")
@test val(s, "Up") == 1
@test val(s, "Dn") == 2
@test state("Up", s) == ITensor([1, 0], (s,))
@test state("Dn", s) == ITensor([0, 1], (s,))
@test op("X", s) == ITensor([0 1; 1 0], (s', s))
@test op("Z", s) == ITensor([1 0; 0 -1], (s', s))
@test state("0", 3) == [1, 0, 0]
@test state("1", 3) == [0, 1, 0]
@test state("2", 3) == [0, 0, 1]

@test Vector(StateName("0"), 3) == [1, 0, 0]
@test Vector(StateName("1"), 3) == [0, 1, 0]
@test Vector(StateName("2"), 3) == [0, 0, 1]

@test op("X") == [0 1; 1 0]
@test op("Y") == [0 -im; im 0]
@test op("Z") == [1 0; 0 -1]

@test op("Z") isa Diagonal

@test op(Float32, "X") == [0 1; 1 0]
@test eltype(op(Float32, "X")) === Float32
@test op(SparseMatrixCSC, "X") == [0 1; 1 0]
@test op(SparseMatrixCSC, "X") isa SparseMatrixCSC

@test Matrix(OpName("X")) == [0 1; 1 0]
@test Matrix(OpName("Y")) == [0 -im; im 0]
@test Matrix(OpName("Z")) == [1 0; 0 -1]

@test Matrix(OpName("Rx"; θ=π / 3)) ≈ [sin(π / 3) -cos(π / 3)*im; -cos(π / 3)*im sin(π / 3)]
````

---
Expand Down
2 changes: 1 addition & 1 deletion benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ITensorQuantumOperatorDefinitions
using QuantumOperatorDefinitions
using BenchmarkTools

SUITE = BenchmarkGroup()
Expand Down
4 changes: 2 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ITensorBase = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
ITensorQuantumOperatorDefinitions = "fd9b415b-e710-4e2a-b407-cba023081494"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
QuantumOperatorDefinitions = "826dd319-6fd5-459a-a990-3a4f214664bf"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
14 changes: 7 additions & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
using ITensorQuantumOperatorDefinitions: ITensorQuantumOperatorDefinitions
using QuantumOperatorDefinitions: QuantumOperatorDefinitions
using Documenter: Documenter, DocMeta, deploydocs, makedocs

DocMeta.setdocmeta!(
ITensorQuantumOperatorDefinitions,
QuantumOperatorDefinitions,
:DocTestSetup,
:(using ITensorQuantumOperatorDefinitions);
:(using QuantumOperatorDefinitions);
recursive=true,
)

include("make_index.jl")

makedocs(;
modules=[ITensorQuantumOperatorDefinitions],
modules=[QuantumOperatorDefinitions],
authors="ITensor developers <[email protected]> and contributors",
sitename="ITensorQuantumOperatorDefinitions.jl",
sitename="QuantumOperatorDefinitions.jl",
format=Documenter.HTML(;
canonical="https://ITensor.github.io/ITensorQuantumOperatorDefinitions.jl",
canonical="https://ITensor.github.io/QuantumOperatorDefinitions.jl",
edit_link="main",
assets=String[],
),
pages=["Home" => "index.md", "Reference" => "reference.md"],
)

deploydocs(;
repo="github.com/ITensor/ITensorQuantumOperatorDefinitions.jl",
repo="github.com/ITensor/QuantumOperatorDefinitions.jl",
devbranch="main",
push_preview=true,
)
6 changes: 3 additions & 3 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Literate: Literate
using ITensorQuantumOperatorDefinitions: ITensorQuantumOperatorDefinitions
using QuantumOperatorDefinitions: QuantumOperatorDefinitions

Literate.markdown(
joinpath(pkgdir(ITensorQuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(ITensorQuantumOperatorDefinitions), "docs", "src");
joinpath(pkgdir(QuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(QuantumOperatorDefinitions), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
)
6 changes: 3 additions & 3 deletions docs/make_readme.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Literate: Literate
using ITensorQuantumOperatorDefinitions: ITensorQuantumOperatorDefinitions
using QuantumOperatorDefinitions: QuantumOperatorDefinitions

Literate.markdown(
joinpath(pkgdir(ITensorQuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(ITensorQuantumOperatorDefinitions));
joinpath(pkgdir(QuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(QuantumOperatorDefinitions));
flavor=Literate.CommonMarkFlavor(),
name="README",
)
2 changes: 1 addition & 1 deletion docs/src/reference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reference

```@autodocs
Modules = [ITensorQuantumOperatorDefinitions]
Modules = [QuantumOperatorDefinitions]
```
4 changes: 2 additions & 2 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[deps]
ITensorBase = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
ITensorQuantumOperatorDefinitions = "fd9b415b-e710-4e2a-b407-cba023081494"
QuantumOperatorDefinitions = "826dd319-6fd5-459a-a990-3a4f214664bf"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
81 changes: 48 additions & 33 deletions examples/README.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# # ITensorQuantumOperatorDefinitions.jl
# # QuantumOperatorDefinitions.jl
#
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/ITensorQuantumOperatorDefinitions.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/ITensorQuantumOperatorDefinitions.jl/dev/)
# [![Build Status](https://github.com/ITensor/ITensorQuantumOperatorDefinitions.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/ITensorQuantumOperatorDefinitions.jl/actions/workflows/Tests.yml?query=branch%3Amain)
# [![Coverage](https://codecov.io/gh/ITensor/ITensorQuantumOperatorDefinitions.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/ITensorQuantumOperatorDefinitions.jl)
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/QuantumOperatorDefinitions.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/QuantumOperatorDefinitions.jl/dev/)
# [![Build Status](https://github.com/ITensor/QuantumOperatorDefinitions.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/QuantumOperatorDefinitions.jl/actions/workflows/Tests.yml?query=branch%3Amain)
# [![Coverage](https://codecov.io/gh/ITensor/QuantumOperatorDefinitions.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/QuantumOperatorDefinitions.jl)
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

Expand Down Expand Up @@ -31,38 +31,53 @@ julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")

#=
```julia
julia> Pkg.add("ITensorQuantumOperatorDefinitions")
julia> Pkg.add("QuantumOperatorDefinitions")
```
=#

# ## Examples

using ITensorBase: ITensor, Index, tags
using ITensorQuantumOperatorDefinitions:
OpName, SiteType, StateName, ValName, op, siteind, siteinds, state, val
using QuantumOperatorDefinitions: OpName, SiteType, StateName, ⊗, controlled, op, state
using LinearAlgebra: Diagonal
using SparseArrays: SparseMatrixCSC, SparseVector
using Test: @test

# States and operators as Julia arrays
@test val(ValName("Up"), SiteType("S=1/2")) == 1
@test val(ValName("Dn"), SiteType("S=1/2")) == 2
@test state(StateName("Up"), SiteType("S=1/2")) == [1, 0]
@test state(StateName("Dn"), SiteType("S=1/2")) == [0, 1]
@test op(OpName("X"), SiteType("S=1/2")) == [0 1; 1 0]
@test op(OpName("Z"), SiteType("S=1/2")) == [1 0; 0 -1]

# Index constructors
@test siteind("S=1/2") isa Index
@test Int(length(siteind("S=1/2"))) == 2
@test "S=1/2" in tags(siteind("S=1/2"))
@test siteinds("S=1/2", 4) isa Vector{<:Index}
@test length(siteinds("S=1/2", 4)) == 4
@test all(s -> "S=1/2" in tags(s), siteinds("S=1/2", 4))

# States and operators as ITensors
s = Index(2, "S=1/2")
@test val(s, "Up") == 1
@test val(s, "Dn") == 2
@test state("Up", s) == ITensor([1, 0], (s,))
@test state("Dn", s) == ITensor([0, 1], (s,))
@test op("X", s) == ITensor([0 1; 1 0], (s', s))
@test op("Z", s) == ITensor([1 0; 0 -1], (s', s))
@test state("0") == [1, 0]
@test state("1") == [0, 1]

@test state(Float32, "0") == [1, 0]
@test eltype(state(Float32, "1")) === Float32

@test Vector(StateName("0")) == [1, 0]
@test Vector(StateName("1")) == [0, 1]

@test Vector{Float32}(StateName("0")) == [1, 0]
@test eltype(Vector{Float32}(StateName("0"))) === Float32

@test state(SparseVector, "0") == [1, 0]
@test state(SparseVector, "0") isa SparseVector

@test state("0", 3) == [1, 0, 0]
@test state("1", 3) == [0, 1, 0]
@test state("2", 3) == [0, 0, 1]

@test Vector(StateName("0"), 3) == [1, 0, 0]
@test Vector(StateName("1"), 3) == [0, 1, 0]
@test Vector(StateName("2"), 3) == [0, 0, 1]

@test op("X") == [0 1; 1 0]
@test op("Y") == [0 -im; im 0]
@test op("Z") == [1 0; 0 -1]

@test op("Z") isa Diagonal

@test op(Float32, "X") == [0 1; 1 0]
@test eltype(op(Float32, "X")) === Float32
@test op(SparseMatrixCSC, "X") == [0 1; 1 0]
@test op(SparseMatrixCSC, "X") isa SparseMatrixCSC

@test Matrix(OpName("X")) == [0 1; 1 0]
@test Matrix(OpName("Y")) == [0 -im; im 0]
@test Matrix(OpName("Z")) == [1 0; 0 -1]

@test Matrix(OpName("Rx"; θ=π / 3)) ≈ [sin(π / 3) -cos(π / 3)*im; -cos(π / 3)*im sin(π / 3)]
29 changes: 0 additions & 29 deletions src/ITensorQuantumOperatorDefinitions.jl

This file was deleted.

10 changes: 0 additions & 10 deletions src/ITensorQuantumOperatorDefinitionsChainRulesCoreExt.jl

This file was deleted.

Loading
Loading