-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into GradedUnitRangeDual
- Loading branch information
Showing
18 changed files
with
118 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "NDTensors" | ||
uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" | ||
authors = ["Matthew Fishman <[email protected]>"] | ||
version = "0.3.49" | ||
version = "0.3.52" | ||
|
||
[deps] | ||
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using .TypeParameterAccessors: similartype | ||
|
||
# | ||
# BlockSparseTensor (Tensor using BlockSparse storage) | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
NDTensors/src/lib/TypeParameterAccessors/src/base/similartype.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
`set_indstype` should be overloaded for | ||
types with structured dimensions, | ||
like `OffsetArrays` or named indices | ||
(such as ITensors). | ||
""" | ||
function set_indstype(arraytype::Type{<:AbstractArray}, dims::Tuple) | ||
return set_ndims(arraytype, length(dims)) | ||
end | ||
|
||
function similartype(arraytype::Type{<:AbstractArray}, eltype::Type, dims::Tuple) | ||
return similartype(similartype(arraytype, eltype), dims) | ||
end | ||
|
||
@traitfn function similartype( | ||
arraytype::Type{ArrayT}, eltype::Type | ||
) where {ArrayT; !IsWrappedArray{ArrayT}} | ||
return set_eltype(arraytype, eltype) | ||
end | ||
|
||
@traitfn function similartype( | ||
arraytype::Type{ArrayT}, dims::Tuple | ||
) where {ArrayT; !IsWrappedArray{ArrayT}} | ||
return set_indstype(arraytype, dims) | ||
end | ||
|
||
function similartype(arraytype::Type{<:AbstractArray}, dims::Base.DimOrInd...) | ||
return similartype(arraytype, dims) | ||
end | ||
|
||
function similartype(arraytype::Type{<:AbstractArray}) | ||
return similartype(arraytype, eltype(arraytype)) | ||
end | ||
|
||
## Wrapped arrays | ||
@traitfn function similartype( | ||
arraytype::Type{ArrayT}, eltype::Type | ||
) where {ArrayT; IsWrappedArray{ArrayT}} | ||
return similartype(unwrap_array_type(arraytype), eltype) | ||
end | ||
|
||
@traitfn function similartype( | ||
arraytype::Type{ArrayT}, dims::Tuple | ||
) where {ArrayT; IsWrappedArray{ArrayT}} | ||
return similartype(unwrap_array_type(arraytype), dims) | ||
end | ||
|
||
# This is for uniform `Diag` storage which uses | ||
# a Number as the data type. | ||
# TODO: Delete this when we change to using a | ||
# `FillArray` instead. This is a stand-in | ||
# to make things work with the current design. | ||
function similartype(numbertype::Type{<:Number}) | ||
return numbertype | ||
end | ||
|
||
# Instances | ||
function similartype(array::AbstractArray, eltype::Type, dims...) | ||
return similartype(typeof(array), eltype, dims...) | ||
end | ||
similartype(array::AbstractArray, eltype::Type) = similartype(typeof(array), eltype) | ||
similartype(array::AbstractArray, dims...) = similartype(typeof(array), dims...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
NDTensors/src/lib/TypeParameterAccessors/test/test_similartype.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@eval module $(gensym()) | ||
using Test: @test, @test_broken, @testset | ||
using LinearAlgebra: Adjoint | ||
using NDTensors.TypeParameterAccessors: similartype | ||
@testset "TypeParameterAccessors similartype" begin | ||
@test similartype(Array, Float64, (2, 2)) == Matrix{Float64} | ||
# TODO: Is this a good definition? Probably it should be left unspecified. | ||
@test similartype(Array) == Array{Any} | ||
@test similartype(Array, Float64) == Array{Float64} | ||
@test similartype(Array, (2, 2)) == Matrix | ||
@test similartype(Adjoint{Float32,Matrix{Float32}}, Float64, (2, 2, 2)) == | ||
Array{Float64,3} | ||
@test similartype(Adjoint{Float32,Matrix{Float32}}, Float64) == Matrix{Float64} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "ITensors" | ||
uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" | ||
authors = ["Matthew Fishman <[email protected]>", "Miles Stoudenmire <[email protected]>"] | ||
version = "0.7.1" | ||
version = "0.7.3" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|