-
Notifications
You must be signed in to change notification settings - Fork 2
define TensorAlgebra.matricize
#95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9e1c646
adapt to matricize
ogauthe 6404059
clean imports
ogauthe d466ca5
Bump to TensorAlgebra v0.3 in test/Project.toml
mtfishman 4b8a894
adapt to permuteblockeddims
ogauthe 6c2204b
add regression test
ogauthe 72b2573
bump TensorAlgebra version
ogauthe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 = "BlockSparseArrays" | ||
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" | ||
authors = ["ITensor developers <[email protected]> and contributors"] | ||
version = "0.4.1" | ||
version = "0.4.2" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|
@@ -40,7 +40,7 @@ MacroTools = "0.5.13" | |
MapBroadcast = "0.1.5" | ||
SparseArraysBase = "0.5" | ||
SplitApplyCombine = "1.2.3" | ||
TensorAlgebra = "0.2.4" | ||
TensorAlgebra = "0.3.2" | ||
Test = "1.10" | ||
TypeParameterAccessors = "0.2.0, 0.3" | ||
julia = "1.10" | ||
|
30 changes: 21 additions & 9 deletions
30
ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl
This file contains hidden or 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,21 +1,33 @@ | ||
module BlockSparseArraysTensorAlgebraExt | ||
|
||
using BlockArrays: AbstractBlockedUnitRange | ||
using BlockSparseArrays: AbstractBlockSparseArray, blockreshape | ||
using TensorAlgebra: TensorAlgebra, FusionStyle, BlockReshapeFusion | ||
using TensorAlgebra: | ||
TensorAlgebra, | ||
BlockedTrivialPermutation, | ||
BlockedTuple, | ||
FusionStyle, | ||
ReshapeFusion, | ||
fuseaxes | ||
|
||
TensorAlgebra.FusionStyle(::AbstractBlockedUnitRange) = BlockReshapeFusion() | ||
struct BlockReshapeFusion <: FusionStyle end | ||
|
||
function TensorAlgebra.fusedims( | ||
::BlockReshapeFusion, a::AbstractArray, axes::AbstractUnitRange... | ||
function TensorAlgebra.FusionStyle(::Type{<:AbstractBlockSparseArray}) | ||
return BlockReshapeFusion() | ||
end | ||
|
||
function TensorAlgebra.matricize( | ||
::BlockReshapeFusion, a::AbstractArray, biperm::BlockedTrivialPermutation{2} | ||
) | ||
return blockreshape(a, axes) | ||
new_axes = fuseaxes(axes(a), biperm) | ||
return blockreshape(a, new_axes) | ||
end | ||
|
||
function TensorAlgebra.splitdims( | ||
::BlockReshapeFusion, a::AbstractArray, axes::AbstractUnitRange... | ||
function TensorAlgebra.unmatricize( | ||
::BlockReshapeFusion, | ||
m::AbstractMatrix, | ||
blocked_axes::BlockedTuple{2,<:Any,<:Tuple{Vararg{AbstractUnitRange}}}, | ||
) | ||
return blockreshape(a, axes) | ||
return blockreshape(m, Tuple(blocked_axes)...) | ||
end | ||
|
||
end |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.