-
Couldn't load subscription status.
- Fork 0
Add ndims type parameter to AbstractArrayInterface
#42
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
Changes from 6 commits
fbb9192
3011bfc
741c75c
70f82e1
ecd8379
d9faf8c
1942bdd
51fbbb1
2c34966
a2ab28d
8c3705b
ce0ee30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| name = "DerivableInterfaces" | ||
| uuid = "6c5e35bf-e59e-4898-b73c-732dcc4ba65f" | ||
| authors = ["ITensor developers <[email protected]> and contributors"] | ||
| version = "0.4.5" | ||
| version = "0.5.0" | ||
|
|
||
| [deps] | ||
| Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,16 @@ export concatenate | |
|
|
||
| using Base: promote_eltypeof | ||
| using ..DerivableInterfaces: | ||
| DerivableInterfaces, AbstractInterface, interface, zero!, arraytype | ||
| DerivableInterfaces, AbstractArrayInterface, interface, zero!, arraytype | ||
|
|
||
| unval(x) = x | ||
| unval(::Val{x}) where {x} = x | ||
|
|
||
| set_interface_ndims(::Type{Nothing}, ::Val{N}) where {N} = nothing | ||
| function set_interface_ndims(Interface::Type{<:AbstractArrayInterface}, ::Val{N}) where {N} | ||
| return Interface(Val(N)) | ||
| end | ||
|
|
||
| function _Concatenated end | ||
|
|
||
| """ | ||
|
|
@@ -42,25 +47,31 @@ function _Concatenated end | |
| Lazy representation of the concatenation of various `Args` along `Dims`, in order to provide | ||
| hooks to customize the implementation. | ||
| """ | ||
| struct Concatenated{Interface,Dims,Args<:Tuple} | ||
| struct Concatenated{Interface<:Union{AbstractArrayInterface,Nothing},Dims,Args<:Tuple} | ||
| interface::Interface | ||
| dims::Val{Dims} | ||
| args::Args | ||
| global @inline function _Concatenated( | ||
| interface::Interface, dims::Val{Dims}, args::Args | ||
| ) where {Interface,Dims,Args<:Tuple} | ||
| ) where {Interface<:Union{AbstractArrayInterface,Nothing},Dims,Args<:Tuple} | ||
| return new{Interface,Dims,Args}(interface, dims, args) | ||
| end | ||
| end | ||
|
|
||
| function Concatenated(interface::Union{Nothing,AbstractInterface}, dims::Val, args::Tuple) | ||
| function Concatenated(interface::Nothing, dims::Val, args::Tuple) | ||
| return _Concatenated(interface, dims, args) | ||
| end | ||
| function Concatenated(interface::AbstractArrayInterface, dims::Val, args::Tuple) | ||
| N = cat_ndims(dims, args...) | ||
| return _Concatenated(typeof(interface)(Val(N)), dims, args) | ||
| end | ||
| function Concatenated(dims::Val, args::Tuple) | ||
| return Concatenated(interface(args...), dims, args) | ||
| N = cat_ndims(dims, args...) | ||
| return _Concatenated(typeof(interface(args...))(Val(N)), dims, args) | ||
| end | ||
| function Concatenated{Interface}(dims::Val, args::Tuple) where {Interface} | ||
| return Concatenated(Interface(), dims, args) | ||
| N = cat_ndims(dims, args...) | ||
| return _Concatenated(set_interface_ndims(Interface, Val(N)), dims, args) | ||
|
||
| end | ||
|
|
||
| dims(::Concatenated{<:Any,D}) where {D} = D | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.