Skip to content

Commit ccad131

Browse files
authored
Remove auto allocating feature (#105)
1 parent e7b8ad8 commit ccad131

4 files changed

Lines changed: 2 additions & 94 deletions

File tree

Project.toml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
11
name = "ITensorBase"
22
uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
33
authors = ["ITensor developers <support@itensor.org> and contributors"]
4-
version = "0.4.4"
4+
version = "0.4.5"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
88
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
9-
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
10-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11-
MapBroadcast = "ebd9b9da-f48d-417c-9660-449667d60261"
129
NamedDimsArrays = "60cbd0c0-df58-4cb7-918c-6f5607b73fde"
1310
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1411
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
15-
UnallocatedArrays = "43c9e47c-e622-40fb-bf18-a09fc8c466b6"
16-
UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d"
17-
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
1812

1913
[compat]
2014
Accessors = "0.1.39"
2115
ConstructionBase = "1.6.0"
22-
FillArrays = "1.13"
23-
LinearAlgebra = "1.10"
24-
MapBroadcast = "0.1.5"
2516
NamedDimsArrays = "0.13"
2617
Random = "1.10"
2718
TensorAlgebra = "0.3, 0.4, 0.5, 0.6"
28-
UnallocatedArrays = "0.1.1"
29-
UnspecifiedTypes = "0.1.1"
30-
VectorInterface = "0.5"
3119
julia = "1.10"
3220

3321
[workspace]

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ q, r = qr(a, (i,))
6363
@test q * r a
6464
````
6565

66-
Automatic allocation
67-
68-
````julia
69-
a = ITensor(i, j)
70-
a[j[1], i[2]] = 1 + 2im
71-
eltype(a) == Complex{Int}
72-
@test a[i[2], j[1]] == 1 + 2im
73-
````
74-
7566
---
7667

7768
*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*

examples/README.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,3 @@ d = a + a′
6262
@test a aligndims(a, (j, i))
6363
q, r = qr(a, (i,))
6464
@test q * r a
65-
66-
# Automatic allocation
67-
a = ITensor(i, j)
68-
a[j[1], i[2]] = 1 + 2im
69-
eltype(a) == Complex{Int}
70-
@test a[i[2], j[1]] == 1 + 2im

src/abstractitensor.jl

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using MapBroadcast: Mapped
21
using NamedDimsArrays: NamedDimsArrays, AbstractNamedDimsArray, NamedDimsArray, denamed,
32
dimnames, inds, mapinds
43

@@ -8,52 +7,7 @@ NamedDimsArrays.nameddimsconstructor(::Type{<:IndexName}) = ITensor
87

98
Base.ndims(::Type{<:AbstractITensor}) = Any
109

11-
using FillArrays: Zeros
12-
using UnallocatedArrays: UnallocatedZeros, allocate
13-
using UnspecifiedTypes: UnspecifiedZero
14-
15-
# TODO: Make this more general, maybe with traits `is_unallocated`
16-
# and `is_eltype_unspecified`.
17-
function specify_eltype(a::Zeros{UnspecifiedZero}, elt::Type)
18-
return Zeros{elt}(axes(a))
19-
end
20-
specify_eltype(a::AbstractArray, elt::Type) = a
21-
22-
# TODO: Use `adapt` to reach down into the storage.
23-
function specify_eltype!(a::AbstractITensor, elt::Type)
24-
setdenamed!(a, specify_eltype(denamed(a), elt))
25-
return a
26-
end
27-
28-
# Assume it is allocated.
29-
allocate!(a::AbstractArray) = a
30-
31-
# TODO: Use `adapt` to reach down into the storage.
32-
function allocate!(a::AbstractITensor)
33-
setdenamed!(a, allocate(denamed(a)))
34-
return a
35-
end
36-
37-
unallocatable(a::AbstractITensor) = NamedDimsArray(a)
38-
39-
function setindex_allocatable!(a::AbstractArray, value, I...)
40-
allocate!(specify_eltype!(a, typeof(value)))
41-
# TODO: Maybe use `@interface interface(a) a[I...] = value`?
42-
unallocatable(a)[I...] = value
43-
return a
44-
end
45-
46-
# TODO: Combine these by using `Base.to_indices`.
47-
function Base.setindex!(a::AbstractITensor, value, I::Int...)
48-
setindex_allocatable!(a, value, I...)
49-
return a
50-
end
51-
function Base.setindex!(a::AbstractITensor, value, I::AbstractNamedInteger...)
52-
setindex_allocatable!(a, value, I...)
53-
return a
54-
end
55-
56-
mutable struct ITensor <: AbstractITensor
10+
struct ITensor <: AbstractITensor
5711
parent::AbstractArray
5812
inds
5913
function ITensor(parent::AbstractArray, dims)
@@ -72,22 +26,3 @@ end
7226
function ITensor(parent::AbstractArray)
7327
return ITensor(parent, ())
7428
end
75-
76-
using Accessors: @set
77-
setdenamed(a::ITensor, denamed) = (@set a.parent = denamed)
78-
setdenamed!(a::ITensor, denamed) = (a.parent = denamed)
79-
80-
function ITensor(elt::Type, I1::Index, I_rest::Index...)
81-
I = (I1, I_rest...)
82-
# TODO: Use `FillArrays.Zeros`.
83-
return ITensor(zeros(elt, length.(denamed.(I))...), I)
84-
end
85-
86-
function ITensor(I1::Index, I_rest::Index...)
87-
I = (I1, I_rest...)
88-
return ITensor(Zeros{UnspecifiedZero}(length.(denamed.(I))...), I)
89-
end
90-
91-
function ITensor()
92-
return ITensor(Zeros{UnspecifiedZero}(), ())
93-
end

0 commit comments

Comments
 (0)