diff --git a/NDTensors/Project.toml b/NDTensors/Project.toml index 6a559b114e..7a42286b83 100644 --- a/NDTensors/Project.toml +++ b/NDTensors/Project.toml @@ -1,7 +1,7 @@ name = "NDTensors" uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" authors = ["Matthew Fishman "] -version = "0.3.64" +version = "0.3.65" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" @@ -73,15 +73,15 @@ HDF5 = "0.14, 0.15, 0.16, 0.17" HalfIntegers = "1" InlineStrings = "1" JLArrays = "0.1, 0.2" -LinearAlgebra = "<0.0.1, 1.6" +LinearAlgebra = "<0.0.1, 1.10" MacroTools = "0.5" MappedArrays = "0.4" Metal = "1" Octavian = "0.3" PackageExtensionCompat = "1" -Random = "<0.0.1, 1.6" +Random = "<0.0.1, 1.10" SimpleTraits = "0.9.4" -SparseArrays = "<0.0.1, 1.6" +SparseArrays = "<0.0.1, 1.10" SplitApplyCombine = "1.2.2" StaticArrays = "0.12, 1.0" Strided = "2" diff --git a/NDTensors/src/blocksparse/blockoffsets.jl b/NDTensors/src/blocksparse/blockoffsets.jl index 24d179aa22..93bf9bd0d5 100644 --- a/NDTensors/src/blocksparse/blockoffsets.jl +++ b/NDTensors/src/blocksparse/blockoffsets.jl @@ -1,3 +1,5 @@ +using SparseArrays: SparseArrays + # # BlockOffsets # @@ -57,7 +59,7 @@ function offset(bofs::BlockOffsets{N}, block::Block{N}) where {N} return bofs[block] end -function nnz(bofs::BlockOffsets, inds) +function SparseArrays.nnz(bofs::BlockOffsets, inds) _nnz = 0 nnzblocks(bofs) == 0 && return _nnz for block in eachnzblock(bofs) diff --git a/NDTensors/src/blocksparse/blocksparsetensor.jl b/NDTensors/src/blocksparse/blocksparsetensor.jl index ce515e4c00..f367de836c 100644 --- a/NDTensors/src/blocksparse/blocksparsetensor.jl +++ b/NDTensors/src/blocksparse/blocksparsetensor.jl @@ -1,3 +1,4 @@ +using SparseArrays: nnz using .TypeParameterAccessors: similartype # diff --git a/NDTensors/src/blocksparse/similar.jl b/NDTensors/src/blocksparse/similar.jl index 5a8395b1a7..5ef594c1c4 100644 --- a/NDTensors/src/blocksparse/similar.jl +++ b/NDTensors/src/blocksparse/similar.jl @@ -1,3 +1,4 @@ +using SparseArrays: nnz using .TypeParameterAccessors: similartype # NDTensors.similar diff --git a/NDTensors/src/dense/densetensor.jl b/NDTensors/src/dense/densetensor.jl index 8e938cc387..119934bdfa 100644 --- a/NDTensors/src/dense/densetensor.jl +++ b/NDTensors/src/dense/densetensor.jl @@ -1,3 +1,5 @@ +using SparseArrays: nnz + # # DenseTensor (Tensor using Dense storage) # diff --git a/NDTensors/src/dense/tensoralgebra/contract.jl b/NDTensors/src/dense/tensoralgebra/contract.jl index 10b13d14ca..60db4e9a22 100644 --- a/NDTensors/src/dense/tensoralgebra/contract.jl +++ b/NDTensors/src/dense/tensoralgebra/contract.jl @@ -1,3 +1,5 @@ +using SparseArrays: nnz + function contraction_output(tensor1::DenseTensor, tensor2::DenseTensor, indsR) tensortypeR = contraction_output_type(typeof(tensor1), typeof(tensor2), indsR) return NDTensors.similar(tensortypeR, indsR) diff --git a/NDTensors/src/empty/empty.jl b/NDTensors/src/empty/empty.jl index 3aeda04710..4aab974e0b 100644 --- a/NDTensors/src/empty/empty.jl +++ b/NDTensors/src/empty/empty.jl @@ -1,3 +1,4 @@ +using SparseArrays: SparseArrays using .TypeParameterAccessors: TypeParameterAccessors, set_eltype, similartype # @@ -66,7 +67,7 @@ isempty(::EmptyStorage) = true nnzblocks(::EmptyStorage) = 0 -nnz(::EmptyStorage) = 0 +SparseArrays.nnz(::EmptyStorage) = 0 function conj(::AllowAlias, S::EmptyStorage) return S diff --git a/NDTensors/src/tensor/tensor.jl b/NDTensors/src/tensor/tensor.jl index ee330d7d25..45dd96fa43 100644 --- a/NDTensors/src/tensor/tensor.jl +++ b/NDTensors/src/tensor/tensor.jl @@ -1,3 +1,5 @@ +using SparseArrays: SparseArrays, nnz + """ Tensor{StoreT,IndsT} @@ -307,7 +309,7 @@ eachnzblock(T::Tensor) = eachnzblock(storage(T)) blockoffsets(T::Tensor) = blockoffsets(storage(T)) nnzblocks(T::Tensor) = nnzblocks(storage(T)) -nnz(T::Tensor) = nnz(storage(T)) +SparseArrays.nnz(T::Tensor) = nnz(storage(T)) nblocks(T::Tensor) = nblocks(inds(T)) blockdims(T::Tensor, block) = blockdims(inds(T), block) blockdim(T::Tensor, block) = blockdim(inds(T), block) diff --git a/NDTensors/src/tensorstorage/tensorstorage.jl b/NDTensors/src/tensorstorage/tensorstorage.jl index fdbbab7167..92d7b50418 100644 --- a/NDTensors/src/tensorstorage/tensorstorage.jl +++ b/NDTensors/src/tensorstorage/tensorstorage.jl @@ -1,3 +1,5 @@ +using SparseArrays: SparseArrays + abstract type TensorStorage{ElT} <: AbstractVector{ElT} end data(S::TensorStorage) = S.data @@ -98,6 +100,6 @@ nzblocks(T::TensorStorage) = nzblocks(blockoffsets(T)) eachnzblock(T::TensorStorage) = eachnzblock(blockoffsets(T)) nnzblocks(S::TensorStorage) = length(blockoffsets(S)) -nnz(S::TensorStorage) = length(S) +SparseArrays.nnz(S::TensorStorage) = length(S) offset(S::TensorStorage, block) = offset(blockoffsets(S), block) diff --git a/Project.toml b/Project.toml index ec4584bc2f..9f8c267534 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensors" uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" authors = ["Matthew Fishman ", "Miles Stoudenmire "] -version = "0.7.5" +version = "0.7.6" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -20,6 +20,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Requires = "ae029012-a4dd-5104-9daa-d747884805df" SerializedElementArrays = "d3ce8812-9567-47e9-a7b5-65a6d70a3065" SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" @@ -46,14 +47,15 @@ DocStringExtensions = "0.9.3" Functors = "0.2, 0.3, 0.4, 0.5" HDF5 = "0.14, 0.15, 0.16, 0.17" IsApprox = "0.1, 1, 2" -LinearAlgebra = "1.6" +LinearAlgebra = "1.10" NDTensors = "0.3.34" -Pkg = "1.6" -Printf = "1.6" -Random = "1.6" +Pkg = "1.10" +Printf = "1.10" +Random = "1.10" Requires = "1.1" SerializedElementArrays = "0.1" SimpleTraits = "0.9.4" +SparseArrays = "<0.0.1, 1.10" StaticArrays = "0.12, 1.0" Strided = "1.1, 2" TimerOutputs = "0.5.5" diff --git a/src/itensor.jl b/src/itensor.jl index e092cf12da..3a0c6c7cf4 100644 --- a/src/itensor.jl +++ b/src/itensor.jl @@ -1,3 +1,4 @@ +using NDTensors: NDTensors, nnz using .TagSets: TagSets, hastags, replacetags # Private inner constructor @@ -852,7 +853,11 @@ hasqns(T::Union{Tensor,ITensor}) = hasqns(inds(T)) eachnzblock(T::ITensor) = eachnzblock(tensor(T)) -nnz(T::ITensor) = nnz(tensor(T)) +# TODO: Switch this to `SparseArrays.nnz`, it is written +# this way for backwards compatibility since older versions +# of NDTensors had their own `NDTensors.nnz` function +# that didn't overload `SparseArrays.nnz`. +NDTensors.nnz(T::ITensor) = nnz(tensor(T)) nblocks(T::ITensor, args...) = nblocks(tensor(T), args...)