-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kmp5/feature/FieldTypes' of github.com:kmp5VT/ITensors.…
…jl into kmp5/feature/FieldTypes
- Loading branch information
Showing
30 changed files
with
398 additions
and
85 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ authors = ["Matthew Fishman <[email protected]>"] | |
version = "0.2.22" | ||
|
||
[deps] | ||
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" | ||
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" | ||
|
@@ -17,6 +18,7 @@ GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" | |
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" | ||
InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" | ||
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" | ||
|
@@ -42,7 +44,9 @@ NDTensorsOctavianExt = "Octavian" | |
NDTensorsTBLISExt = "TBLIS" | ||
|
||
[compat] | ||
Accessors = "0.1.33" | ||
Adapt = "3.7" | ||
ArrayLayouts = "1.4" | ||
BlockArrays = "0.16" | ||
Compat = "4.9" | ||
Dictionaries = "0.3.5" | ||
|
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
5 changes: 5 additions & 0 deletions
5
...SparseArrays/src/BlockArraysSparseArrayInterfaceExt/BlockArraysSparseArrayInterfaceExt.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,5 @@ | ||
using ..SparseArrayInterface: SparseArrayInterface, nstored | ||
|
||
function SparseArrayInterface.nstored(a::AbstractBlockArray) | ||
return sum(b -> nstored(b), blocks(a)) | ||
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
5 changes: 5 additions & 0 deletions
5
NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray/broadcast.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,5 @@ | ||
using Base.Broadcast: Broadcast | ||
|
||
function Broadcast.BroadcastStyle(arraytype::Type{<:BlockSparseArrayLike}) | ||
return BlockSparseArrayStyle{ndims(arraytype)}() | ||
end |
42 changes: 42 additions & 0 deletions
42
NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray/map.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,42 @@ | ||
using ArrayLayouts: LayoutArray | ||
|
||
# Map | ||
function Base.map!(f, a_dest::AbstractArray, a_srcs::Vararg{BlockSparseArrayLike}) | ||
blocksparse_map!(f, a_dest, a_srcs...) | ||
return a_dest | ||
end | ||
|
||
function Base.copy!(a_dest::AbstractArray, a_src::BlockSparseArrayLike) | ||
blocksparse_copy!(a_dest, a_src) | ||
return a_dest | ||
end | ||
|
||
function Base.copyto!(a_dest::AbstractArray, a_src::BlockSparseArrayLike) | ||
blocksparse_copyto!(a_dest, a_src) | ||
return a_dest | ||
end | ||
|
||
# Fix ambiguity error | ||
function Base.copyto!(a_dest::LayoutArray, a_src::BlockSparseArrayLike) | ||
blocksparse_copyto!(a_dest, a_src) | ||
return a_dest | ||
end | ||
|
||
function Base.permutedims!(a_dest::AbstractArray, a_src::BlockSparseArrayLike, perm) | ||
blocksparse_permutedims!(a_dest, a_src, perm) | ||
return a_dest | ||
end | ||
|
||
function Base.mapreduce(f, op, as::Vararg{BlockSparseArrayLike}; kwargs...) | ||
return blocksparse_mapreduce(f, op, as...; kwargs...) | ||
end | ||
|
||
# TODO: Why isn't this calling `mapreduce` already? | ||
function Base.iszero(a::BlockSparseArrayLike) | ||
return blocksparse_iszero(a) | ||
end | ||
|
||
# TODO: Why isn't this calling `mapreduce` already? | ||
function Base.isreal(a::BlockSparseArrayLike) | ||
return blocksparse_isreal(a) | ||
end |
63 changes: 63 additions & 0 deletions
63
...src/lib/BlockSparseArrays/src/abstractblocksparsearray/wrappedabstractblocksparsearray.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,63 @@ | ||
using Adapt: WrappedArray | ||
|
||
const WrappedAbstractBlockSparseArray{T,N,A} = WrappedArray{ | ||
T,N,<:AbstractBlockSparseArray,<:AbstractBlockSparseArray{T,N} | ||
} | ||
|
||
const BlockSparseArrayLike{T,N} = Union{ | ||
<:AbstractBlockSparseArray{T,N},<:WrappedAbstractBlockSparseArray{T,N} | ||
} | ||
|
||
# BlockArrays `AbstractBlockArray` interface | ||
BlockArrays.blocks(a::BlockSparseArrayLike) = blocksparse_blocks(a) | ||
|
||
blocktype(a::BlockSparseArrayLike) = eltype(blocks(a)) | ||
|
||
# TODO: Use `parenttype` from `Unwrap`. | ||
blockstype(arraytype::Type{<:WrappedAbstractBlockSparseArray}) = parenttype(arraytype) | ||
|
||
blocktype(arraytype::Type{<:BlockSparseArrayLike}) = eltype(blockstype(arraytype)) | ||
|
||
function Base.setindex!(a::BlockSparseArrayLike{<:Any,N}, value, I::BlockIndex{N}) where {N} | ||
blocksparse_setindex!(a, value, I) | ||
return a | ||
end | ||
|
||
function Base.setindex!(a::BlockSparseArrayLike{<:Any,N}, value, I::Block{N}) where {N} | ||
blocksparse_setindex!(a, value, I) | ||
return a | ||
end | ||
|
||
# Fix ambiguity error | ||
function Base.setindex!(a::BlockSparseArrayLike{<:Any,1}, value, I::Block{1}) | ||
blocksparse_setindex!(a, value, I) | ||
return a | ||
end | ||
|
||
# `BlockArrays` interface | ||
# TODO: Is this needed if `blocks` is defined? | ||
function BlockArrays.viewblock(a::BlockSparseArrayLike{<:Any,N}, I::Block{N,Int}) where {N} | ||
return blocksparse_viewblock(a, I) | ||
end | ||
|
||
# Needed by `BlockArrays` matrix multiplication interface | ||
function Base.similar( | ||
arraytype::Type{<:BlockSparseArrayLike}, axes::Tuple{Vararg{BlockedUnitRange}} | ||
) | ||
return similar(arraytype, eltype(arraytype), axes) | ||
end | ||
|
||
# Needed by `BlockArrays` matrix multiplication interface | ||
function Base.similar( | ||
arraytype::Type{<:BlockSparseArrayLike}, elt::Type, axes::Tuple{Vararg{BlockedUnitRange}} | ||
) | ||
# TODO: Make generic for GPU! Use `blocktype`. | ||
return BlockSparseArray{elt}(undef, axes) | ||
end | ||
|
||
function Base.similar( | ||
a::BlockSparseArrayLike, elt::Type, axes::Tuple{Vararg{BlockedUnitRange}} | ||
) | ||
# TODO: Make generic for GPU! Use `blocktype`. | ||
return BlockSparseArray{eltype(a)}(undef, axes) | ||
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
Oops, something went wrong.