Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Nov 27, 2024
1 parent d19466a commit 42011fe
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,34 @@ julia> Pkg.add("https://github.com/ITensor/NamedDimsArrays.jl")
## Examples

````julia
using NamedDimsArrays: NamedDimsArrays
````
using NamedDimsArrays: align, dimnames, named, unname
using TensorAlgebra: contract

# Named dimensions
i = named(2, "i")
j = named(2, "j")
k = named(2, "k")

# Arrays with named dimensions
na1 = randn(i, j)
na2 = randn(j, k)

@show dimnames(na1) == ("i", "j")

Examples go here.
# Indexing
@show na1[j => 2, i => 1] == na1[1, 2]

# Tensor contraction
na_dest = contract(na1, na2)

@show issetequal(dimnames(na_dest), ("i", "k"))
# `unname` removes the names and returns an `Array`
@show unname(na_dest, (i, k)) unname(na1) * unname(na2)

# Permute dimensions (like `ITensors.permute`)
na1 = align(na1, (j, i))
@show na1[i => 1, j => 2] == na1[2, 1]
````

---

Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NamedDimsArrays = {path = ".."}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
Expand Down
7 changes: 7 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
[deps]
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
NamedDimsArrays = "60cbd0c0-df58-4cb7-918c-6f5607b73fde"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NamedDimsArrays = {path = ".."}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NamedDimsArrays = {path = ".."}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
Expand Down

0 comments on commit 42011fe

Please sign in to comment.