@@ -305,14 +305,14 @@ end
305305
306306using NDTensors. TypeParameterAccessors: set_eltype, type_parameters, specify_type_parameters
307307"""
308- ITensor([ElT::Type, ]A::Array , inds)
309- ITensor([ElT::Type, ]A::Array , inds::Index...)
308+ ITensor([ElT::Type, ]A::AbstractArray , inds)
309+ ITensor([ElT::Type, ]A::AbstractArray , inds::Index...)
310310
311- itensor([ElT::Type, ]A::Array , inds)
312- itensor([ElT::Type, ]A::Array , inds::Index...)
311+ itensor([ElT::Type, ]A::AbstractArray , inds)
312+ itensor([ElT::Type, ]A::AbstractArray , inds::Index...)
313313
314- Construct an ITensor from an Array `A` and indices `inds`.
315- The ITensor will be a view of the Array data if possible (if
314+ Construct an ITensor from an AbstractArray `A` and indices `inds`.
315+ The ITensor will be a view of the AbstractArray data if possible (if
316316no conversion to a different element type is necessary).
317317
318318If specified, the ITensor will have element type `ElT`.
@@ -389,13 +389,13 @@ function ITensor(eltype::Type{<:Number}, A::AbstractArray{<:Number}, is...; kwar
389389end
390390
391391# For now, it's not well defined to construct an ITensor without indices
392- # from a non-zero dimensional Array
392+ # from a non-zero dimensional AbstractArray
393393function ITensor (
394394 as:: AliasStyle , eltype:: Type{<:Number} , A:: AbstractArray{<:Number} ; kwargs...
395395)
396396 if length (A) > 1
397397 error (
398- " Trying to create an ITensor without any indices from Array $A of dimensions $(size (A)) . Cannot construct an ITensor from an Array with more than one element without any indices." ,
398+ " Trying to create an ITensor without any indices from $( typeof (A)) $A of dimensions $(size (A)) . Cannot construct an ITensor from an $( typeof (A)) with more than one element without any indices." ,
399399 )
400400 end
401401 return ITensor (eltype, A[]; kwargs... )
@@ -448,8 +448,8 @@ diag_itensor(is::Indices) = diag_itensor(Float64, is)
448448diag_itensor (is... ) = diag_itensor (indices (is... ))
449449
450450"""
451- diag_itensor([ElT::Type, ]v::Vector , inds...)
452- diagitensor([ElT::Type, ]v::Vector , inds...)
451+ diag_itensor([ElT::Type, ]v::AbstractVector , inds...)
452+ diagitensor([ElT::Type, ]v::AbstractVector , inds...)
453453
454454Make a sparse ITensor with non-zero elements only along the diagonal.
455455In general, the diagonal elements will be those stored in `v` and
@@ -467,29 +467,31 @@ The version `diagitensor` might output an ITensor whose storage data
467467is an alias of the input vector data in order to minimize operations.
468468"""
469469function diag_itensor (
470- as:: AliasStyle , eltype:: Type{<:Number} , v:: Vector {<:Number} , is:: Indices
470+ as:: AliasStyle , eltype:: Type{<:Number} , v:: AbstractVector {<:Number} , is:: Indices
471471)
472472 length (v) ≠ mindim (is) && error (
473473 " Length of vector for diagonal must equal minimum of the dimension of the input indices" ,
474474 )
475- data = Vector { eltype} (as, v)
475+ data = set_eltype ( typeof (v), eltype) (as, v)
476476 return itensor (Diag (data), is)
477477end
478478
479- function diag_itensor (as:: AliasStyle , eltype:: Type{<:Number} , v:: Vector{<:Number} , is... )
479+ function diag_itensor (
480+ as:: AliasStyle , eltype:: Type{<:Number} , v:: AbstractVector{<:Number} , is...
481+ )
480482 return diag_itensor (as, eltype, v, indices (is... ))
481483end
482484
483- function diag_itensor (as:: AliasStyle , v:: Vector , is... )
485+ function diag_itensor (as:: AliasStyle , v:: AbstractVector , is... )
484486 return diag_itensor (as, eltype (v), v, is... )
485487end
486488
487- function diag_itensor (as:: AliasStyle , v:: Vector {<:RealOrComplex{Int}} , is... )
489+ function diag_itensor (as:: AliasStyle , v:: AbstractVector {<:RealOrComplex{Int}} , is... )
488490 return diag_itensor (AllowAlias (), float (eltype (v)), v, is... )
489491end
490492
491- diag_itensor (v:: Vector {<:Number} , is... ) = diag_itensor (NeverAlias (), v, is... )
492- function diag_itensor (eltype:: Type{<:Number} , v:: Vector {<:Number} , is... )
493+ diag_itensor (v:: AbstractVector {<:Number} , is... ) = diag_itensor (NeverAlias (), v, is... )
494+ function diag_itensor (eltype:: Type{<:Number} , v:: AbstractVector {<:Number} , is... )
493495 return diag_itensor (NeverAlias (), eltype, v, is... )
494496end
495497
0 commit comments