Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name = "BlockSparseArrays"
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.2.2"
version = "0.2.3"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
Derive = "a07dfc7f-7d04-4eb5-84cc-a97f051f655a"
DerivableInterfaces = "6c5e35bf-e59e-4898-b73c-732dcc4ba65f"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
MapBroadcast = "ebd9b9da-f48d-417c-9660-449667d60261"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
Expand All @@ -30,18 +30,19 @@ Adapt = "4.1.1"
Aqua = "0.8.9"
ArrayLayouts = "1.10.4"
BlockArrays = "1.2.0"
Derive = "0.3.1"
DerivableInterfaces = "0.3.7"
Dictionaries = "0.4.3"
GPUArraysCore = "0.1.0"
GradedUnitRanges = "0.1.0"
LabelledNumbers = "0.1.0"
LinearAlgebra = "1.10"
MacroTools = "0.5.13"
MapBroadcast = "0.1.5"
SparseArraysBase = "0.2.2"
SplitApplyCombine = "1.2.3"
TensorAlgebra = "0.1.0"
TypeParameterAccessors = "0.2.0"
Test = "1.10"
TypeParameterAccessors = "0.2.0"
julia = "1.10"

[extras]
Expand Down
7 changes: 0 additions & 7 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
9 changes: 0 additions & 9 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using BlockSparseArrays:
BlockSparseMatrix,
BlockSparseVector,
block_merge
using Derive: @interface
using DerivableInterfaces: @interface
using GradedUnitRanges:
GradedUnitRanges,
AbstractGradedUnitRange,
Expand Down
2 changes: 1 addition & 1 deletion src/abstractblocksparsearray/cat.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Derive: @interface, interface
using DerivableInterfaces: @interface, interface

# TODO: Define with `@derive`.
function Base.cat(as::AnyAbstractBlockSparseArray...; dims)
Expand Down
2 changes: 1 addition & 1 deletion src/abstractblocksparsearray/map.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ArrayLayouts: LayoutArray
using BlockArrays: blockisequal
using Derive: @interface, interface
using DerivableInterfaces: @interface, interface
using LinearAlgebra: Adjoint, Transpose
using SparseArraysBase: SparseArraysBase, SparseArrayStyle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using BlockArrays:
blockedrange,
mortar,
unblock
using Derive: Derive, @interface
using DerivableInterfaces: DerivableInterfaces, @interface
using SplitApplyCombine: groupcount
using TypeParameterAccessors: similartype

Expand All @@ -22,7 +22,9 @@ const AnyAbstractBlockSparseArray{T,N} = Union{
<:AbstractBlockSparseArray{T,N},<:WrappedAbstractBlockSparseArray{T,N}
}

Derive.interface(::Type{<:AnyAbstractBlockSparseArray}) = BlockSparseArrayInterface()
function DerivableInterfaces.interface(::Type{<:AnyAbstractBlockSparseArray})
return BlockSparseArrayInterface()
end

# a[1:2, 1:2]
function Base.to_indices(
Expand Down
2 changes: 1 addition & 1 deletion src/blocksparsearray/blocksparsearray.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BlockArrays: BlockArrays, Block, BlockedUnitRange, blockedrange, blocklength
using Derive: @interface
using DerivableInterfaces: @interface
using Dictionaries: Dictionary
using SparseArraysBase: SparseArrayDOK

Expand Down
2 changes: 1 addition & 1 deletion src/blocksparsearrayinterface/arraylayouts.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ArrayLayouts: ArrayLayouts, Dot, MatMulMatAdd, MatMulVecAdd, MulAdd
using BlockArrays: BlockArrays, BlockLayout, muladd!
using Derive: @interface
using DerivableInterfaces: @interface
using SparseArraysBase: SparseLayout
using LinearAlgebra: LinearAlgebra, dot, mul!

Expand Down
6 changes: 4 additions & 2 deletions src/blocksparsearrayinterface/blocksparsearrayinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
blocklengths,
blocks,
findblockindex
using Derive: Derive, @interface, DefaultArrayInterface
using DerivableInterfaces: DerivableInterfaces, @interface, DefaultArrayInterface
using LinearAlgebra: Adjoint, Transpose
using SparseArraysBase:
AbstractSparseArrayInterface,
Expand Down Expand Up @@ -43,7 +43,9 @@
abstract type AbstractBlockSparseArrayInterface <: AbstractSparseArrayInterface end

# TODO: Also support specifying the `blocktype` along with the `eltype`.
Derive.arraytype(::AbstractBlockSparseArrayInterface, T::Type) = BlockSparseArray{T}
function DerivableInterfaces.arraytype(::AbstractBlockSparseArrayInterface, T::Type)
return BlockSparseArray{T}

Check warning on line 47 in src/blocksparsearrayinterface/blocksparsearrayinterface.jl

View check run for this annotation

Codecov / codecov/patch

src/blocksparsearrayinterface/blocksparsearrayinterface.jl#L46-L47

Added lines #L46 - L47 were not covered by tests
end

struct BlockSparseArrayInterface <: AbstractBlockSparseArrayInterface end

Expand Down
16 changes: 10 additions & 6 deletions src/blocksparsearrayinterface/broadcast.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Base.Broadcast: BroadcastStyle, AbstractArrayStyle, DefaultArrayStyle, Broadcasted
using BroadcastMapConversion: map_function, map_args
using Derive: Derive, @interface
using MapBroadcast: Mapped
using DerivableInterfaces: DerivableInterfaces, @interface

abstract type AbstractBlockSparseArrayStyle{N} <: AbstractArrayStyle{N} end

Derive.interface(::Type{<:AbstractBlockSparseArrayStyle}) = BlockSparseArrayInterface()
function DerivableInterfaces.interface(::Type{<:AbstractBlockSparseArrayStyle})
return BlockSparseArrayInterface()
end

struct BlockSparseArrayStyle{N} <: AbstractBlockSparseArrayStyle{N} end

Expand All @@ -30,16 +32,18 @@ end

function Base.similar(bc::Broadcasted{<:BlockSparseArrayStyle}, elt::Type)
# TODO: Make sure this handles GPU arrays properly.
return similar(first(map_args(bc)), elt, combine_axes(axes.(map_args(bc))...))
m = Mapped(bc)
return similar(first(m.args), elt, combine_axes(axes.(m.args)...))
end

# Broadcasting implementation
# TODO: Delete this in favor of `Derive` version.
# TODO: Delete this in favor of `DerivableInterfaces` version.
function Base.copyto!(
dest::AbstractArray{<:Any,N}, bc::Broadcasted{BlockSparseArrayStyle{N}}
) where {N}
# convert to map
# flatten and only keep the AbstractArray arguments
@interface interface(bc) map!(map_function(bc), dest, map_args(bc)...)
m = Mapped(bc)
@interface interface(bc) map!(m.f, dest, m.args...)
return dest
end
10 changes: 6 additions & 4 deletions src/blocksparsearrayinterface/cat.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using BlockArrays: AbstractBlockedUnitRange, blockedrange, blocklengths
using Derive: Derive, @interface, cat!
using DerivableInterfaces: DerivableInterfaces, @interface, cat!
using SparseArraysBase: SparseArraysBase

# TODO: Maybe move to `DeriveBlockArraysExt`.
# TODO: Maybe move to `DerivableInterfacesBlockArraysExt`.
# TODO: Handle dual graded unit ranges, for example in a new `SparseArraysBaseGradedUnitRangesExt`.
function Derive.axis_cat(a1::AbstractBlockedUnitRange, a2::AbstractBlockedUnitRange)
function DerivableInterfaces.axis_cat(

Check warning on line 7 in src/blocksparsearrayinterface/cat.jl

View check run for this annotation

Codecov / codecov/patch

src/blocksparsearrayinterface/cat.jl#L7

Added line #L7 was not covered by tests
a1::AbstractBlockedUnitRange, a2::AbstractBlockedUnitRange
)
return blockedrange(vcat(blocklengths(a1), blocklengths(a2)))
end

@interface ::AbstractBlockSparseArrayInterface function Derive.cat!(
@interface ::AbstractBlockSparseArrayInterface function DerivableInterfaces.cat!(

Check warning on line 13 in src/blocksparsearrayinterface/cat.jl

View check run for this annotation

Codecov / codecov/patch

src/blocksparsearrayinterface/cat.jl#L13

Added line #L13 was not covered by tests
a_dest::AbstractArray, as::AbstractArray...; dims
)
cat!(blocks(a_dest), blocks.(as)...; dims)
Expand Down
4 changes: 0 additions & 4 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2"
Derive = "a07dfc7f-7d04-4eb5-84cc-a97f051f655a"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Expand All @@ -20,4 +17,3 @@ Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
SymmetrySectors = "f8a8ad64-adbc-4fce-92f7-ffe2bb36a86e"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
Loading