Skip to content

Commit a8caa48

Browse files
authored
Rewrite (#9)
1 parent a4ab687 commit a8caa48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1024
-891
lines changed

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
name = "NamedDimsArrays"
22
uuid = "60cbd0c0-df58-4cb7-918c-6f5607b73fde"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.1.0"
4+
version = "0.2.0"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
9+
Derive = "a07dfc7f-7d04-4eb5-84cc-a97f051f655a"
910
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10-
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
1111
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12-
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
12+
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
1313
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
1414
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
1515

1616
[compat]
1717
Adapt = "4.1.1"
18-
BroadcastMapConversion = "0.1"
18+
BroadcastMapConversion = "0.1.2"
19+
Derive = "0.3.6"
1920
LinearAlgebra = "1.10"
20-
NestedPermutedDimsArrays = "0.1"
2121
Random = "1.10"
22-
SparseArraysBase = "0.1"
22+
SimpleTraits = "0.9.4"
2323
TensorAlgebra = "0.1"
24-
TypeParameterAccessors = "0.1"
24+
TypeParameterAccessors = "0.2"
2525
julia = "1.10"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ julia> Pkg.add("NamedDimsArrays")
3232
## Examples
3333

3434
````julia
35-
using NamedDimsArrays: align, dimnames, named, unname
35+
using NamedDimsArrays: aligndims, dename, dimnames, named
3636
using TensorAlgebra: contract
3737

3838
# Named dimensions
@@ -53,11 +53,11 @@ na2 = randn(j, k)
5353
na_dest = contract(na1, na2)
5454

5555
@show issetequal(dimnames(na_dest), ("i", "k"))
56-
# `unname` removes the names and returns an `Array`
57-
@show unname(na_dest, (i, k)) unname(na1) * unname(na2)
56+
# `dename` removes the names and returns an `Array`
57+
@show dename(na_dest, (i, k)) dename(na1) * dename(na2)
5858

5959
# Permute dimensions (like `ITensors.permute`)
60-
na1 = align(na1, (j, i))
60+
na1 = aligndims(na1, (j, i))
6161
@show na1[i => 1, j => 2] == na1[2, 1]
6262
````
6363

TODO.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- `svd`, `eigen` (including tensor versions)
2+
- `reshape`, `vec`
3+
- `swapdimnames`
4+
- `mapdimnames(f, a::AbstractNamedDimsArray)` (rename `replacedimnames(f, a)` to `mapdimnames(f, a)`, or have both?)
5+
- `cat` (define `CatName` as a combination of the input names?).
6+
- `canonize`/`flatten_array_wrappers` (https://github.com/mcabbott/NamedPlus.jl/blob/v0.0.5/src/permute.jl#L207)
7+
- `nameddims(PermutedDimsArray(a, perm), dimnames)` -> `nameddims(a, dimnames[invperm(perm)])`
8+
- `nameddims(transpose(a), dimnames)` -> `nameddims(a, reverse(dimnames))`
9+
- `Transpose(nameddims(a, dimnames))` -> `nameddims(a, reverse(dimnames))`
10+
- etc.
11+
- `MappedName(old_name, name)`, acts like `Name(name)` but keeps track of the old name.
12+
- `namedmap(a, ::Pair...)`: `namedmap(named(randn(2, 2, 2, 2), i, j, k, l), i => k, j => l)`
13+
represents that the names map back and forth to each other for the sake of `transpose`,
14+
`tr`, `eigen`, etc. Operators are generally `namedmap(named(randn(2, 2), i, i'), i => i')`.
15+
- `prime(:i) = PrimedName(:i)`, `prime(:i, 2) = PrimedName(:i, 2)`, `prime(prime(:i)) = PrimedName(:i, 2)`,
16+
`Name(:i)' = prime(:i)`, etc.
17+
- `transpose`/`adjoint` based on `swapdimnames` and `MappedName(old_name, new_name)`.
18+
- `adjoint` could make use of a lazy `ConjArray`.
19+
- `transpose(a, dimname1 => dimname1′, dimname2 => dimname2′)` like `https://github.com/mcabbott/NamedPlus.jl`.
20+
- Same as `replacedims(a, dimname1 => dimname1′, dimname1′ => dimname1, dimname2 => dimname2′, dimname2′ => dimname2)`.
21+
- `transpose(f, a)` like the function form of `replace`.
22+
- `tr` based on `MappedName(old_name, name)`.
23+
- Slicing: `nameddims(a, "i", "j")[1:2, 1:2] = nameddims(a[1:2, 1:2], Name(named(1:2, "i")), Name(named(1:2, "j")))`, i.e.
24+
the parent gets sliced and the new dimensions names are the named slice.
25+
- Should `NamedDimsArray` store the named axes rather than just the dimension names?
26+
- Should `NamedDimsArray` have special axes types so that `axes(nameddims(a, "i", "j")) == axes(nameddims(a', "j", "i"))`?

examples/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[deps]
22
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
33
NamedDimsArrays = "60cbd0c0-df58-4cb7-918c-6f5607b73fde"
4-
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
54
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
65
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
76
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

examples/README.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ julia> Pkg.add("NamedDimsArrays")
3737

3838
# ## Examples
3939

40-
using NamedDimsArrays: align, dimnames, named, unname
40+
using NamedDimsArrays: aligndims, dename, dimnames, named
4141
using TensorAlgebra: contract
4242

4343
## Named dimensions
@@ -58,9 +58,9 @@ na2 = randn(j, k)
5858
na_dest = contract(na1, na2)
5959

6060
@show issetequal(dimnames(na_dest), ("i", "k"))
61-
## `unname` removes the names and returns an `Array`
62-
@show unname(na_dest, (i, k)) unname(na1) * unname(na2)
61+
## `dename` removes the names and returns an `Array`
62+
@show dename(na_dest, (i, k)) dename(na1) * dename(na2)
6363

6464
## Permute dimensions (like `ITensors.permute`)
65-
na1 = align(na1, (j, i))
65+
na1 = aligndims(na1, (j, i))
6666
@show na1[i => 1, j => 2] == na1[2, 1]

ext/NamedDimsArraysAdaptExt/NamedDimsArraysAdaptExt.jl

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/NamedDimsArraysAdaptExt/adapt_structure.jl

Lines changed: 0 additions & 6 deletions
This file was deleted.

ext/NamedDimsArraysSparseArraysBaseExt/NamedDimsArraysSparseArraysBaseExt.jl

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/NamedDimsArraysSparseArraysBaseExt/densearray.jl

Lines changed: 0 additions & 8 deletions
This file was deleted.

ext/NamedDimsArraysTensorAlgebraExt/NamedDimsArraysTensorAlgebraExt.jl

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)