Skip to content

Commit b8c9d00

Browse files
committed
Remove similarmatrixtype
1 parent 26e6959 commit b8c9d00

3 files changed

Lines changed: 5 additions & 20 deletions

File tree

ext/TensorKitCUDAExt/TensorKitCUDAExt.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ using Random
2323
include("cutensormap.jl")
2424
include("truncation.jl")
2525

26-
TensorKit.similarmatrixtype(::Type{A}) where {T <: Number, M, A <: CuVector{T, M}} = CuMatrix{T, M}
27-
2826
function TensorKit._set_subblock!(data::TD, val) where {T, TD <: Union{<:CuMatrix{T}, <:StridedViews.StridedView{T, 4, <:CuArray{T}}}}
2927
@kernel function fill_subblock_kernel!(subblock, val)
3028
idx = @index(Global, Cartesian)

src/tensors/abstracttensor.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,6 @@ similarstoragetype(::Type{D}, ::Type{T}) where {D <: AbstractDict{<:Sector, <:Ab
122122
# default storage type for numbers
123123
similarstoragetype(::Type{T}) where {T <: Number} = Vector{T}
124124

125-
@doc """
126-
similarmatrixtype(T::Type{<:Number}) -> Matrix{T}
127-
similarmatrixtype(A::Type{T, <:DenseVector{T}}) -> Matrix{T}
128-
129-
For a given dense vector type `A` or number type `T`, compute an appropriate
130-
**matrix** storage type for tensors. This function is used internally for
131-
[`BraidingTensor`](@ref) to determine the output storage format for indexing
132-
and other operations with other tensor types.
133-
""" similarmatrixtype
134-
135-
similarmatrixtype(::Type{T}) where {T <: Number} = Matrix{T}
136-
similarmatrixtype(::Type{A}) where {T <: Number, A <: DenseVector{T}} = Matrix{T}
137-
138125
@doc """
139126
promote_storagetype([T], A, B, C...)
140127
promote_storagetype([T], TA, TB, TC...)

src/tensors/braidingtensor.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ end
135135
d = (dims(codomain(b), f₁.uncoupled)..., dims(domain(b), f₂.uncoupled)...)
136136
n1 = d[1] * d[2]
137137
n2 = d[3] * d[4]
138-
data_t = similarmatrixtype(storagetype(b))(undef, (n1, n2))
139-
data = sreshape(StridedView(data_t), d)
138+
data_parent = storagetype(b)(undef, prod(d))
139+
data = sreshape(StridedView(data_parent), d)
140140
fill!(data, zero(eltype(b)))
141141

142142
r = _braiding_factor(f₁, f₂, b.adjoint)
@@ -186,10 +186,10 @@ function block(b::BraidingTensor, s::Sector)
186186
m = blockdim(codomain(b), s)
187187
n = blockdim(domain(b), s)
188188

189-
m * n == 0 && return similarmatrixtype(storagetype(b))(undef, (m, n)) # s ∉ blocksectors(b)
189+
data = reshape(storagetype(b)(undef, m * n), (m, n))
190190

191-
data = similarmatrixtype(storagetype(b))(undef, (m, n))
192-
data = fill!(data, zero(eltype(b)))
191+
m * n == 0 && return data # s ∉ blocksectors(b)
192+
fill!(data, zero(eltype(b)))
193193

194194
if sectortype(b) === Trivial
195195
return _trivial_subblock!(data, b)

0 commit comments

Comments
 (0)