diff --git a/NDTensors/src/NDTensors.jl b/NDTensors/src/NDTensors.jl index 20af697b8c..8756e46055 100644 --- a/NDTensors/src/NDTensors.jl +++ b/NDTensors/src/NDTensors.jl @@ -70,6 +70,7 @@ include("dims.jl") include("tensor/set_types.jl") include("tensor/similar.jl") include("tensor/permutedims.jl") +include("tensor/linearalgebra.jl") include("adapt.jl") include("tensoralgebra/generic_tensor_operations.jl") include("tensoralgebra/contraction_logic.jl") diff --git a/NDTensors/src/dense/linearalgebra/decompositions.jl b/NDTensors/src/dense/linearalgebra/decompositions.jl index 1e81114419..70009e6aaa 100644 --- a/NDTensors/src/dense/linearalgebra/decompositions.jl +++ b/NDTensors/src/dense/linearalgebra/decompositions.jl @@ -1,4 +1,3 @@ - Strided.StridedView(T::DenseTensor) = StridedView(convert(Array, T)) function drop_singletons(::Order{N}, labels, dims) where {N} @@ -40,7 +39,7 @@ end # qr decomposition of an order-n tensor according to # positions Lpos and Rpos -function LinearAlgebra.qr( +function qr( T::DenseTensor{<:Number,N,IndsT}, Lpos::NTuple{NL,Int}, Rpos::NTuple{NR,Int}; kwargs... ) where {N,IndsT,NL,NR} M = permute_reshape(T, Lpos, Rpos) diff --git a/NDTensors/src/exports.jl b/NDTensors/src/exports.jl index 427f220e10..8e91f52019 100644 --- a/NDTensors/src/exports.jl +++ b/NDTensors/src/exports.jl @@ -3,14 +3,12 @@ export insertblock!!, setindex, setindex!!, - # blocksparse/blockdims.jl BlockDims, blockdim, blockdims, nblocks, blockindex, - # blocksparse/blocksparse.jl # Types Block, @@ -49,7 +47,6 @@ export matrix, outer, permutedims!!, - ql, read, vector, write, @@ -78,5 +75,15 @@ export ind, store, + # truncate.jl + truncate!, + # linearalgebra.jl - qr + eigs, + entropy, + polar, + ql, + random_orthog, + random_unitary, + Spectrum, + truncerror diff --git a/NDTensors/src/linearalgebra/linearalgebra.jl b/NDTensors/src/linearalgebra/linearalgebra.jl index 255ddbeb32..cab3f7e057 100644 --- a/NDTensors/src/linearalgebra/linearalgebra.jl +++ b/NDTensors/src/linearalgebra/linearalgebra.jl @@ -1,5 +1,3 @@ -export eigs, entropy, polar, random_orthog, random_unitary, Spectrum, svd, truncerror - # # Linear Algebra of order 2 NDTensors # @@ -380,10 +378,13 @@ function eigen( return D, V, spec end +# NDTensors.qr function qr(T::DenseTensor{<:Any,2}; positive=false, kwargs...) qxf = positive ? qr_positive : qr return qx(qxf, T; kwargs...) end + +# NDTensors.ql function ql(T::DenseTensor{<:Any,2}; positive=false, kwargs...) qxf = positive ? ql_positive : ql return qx(qxf, T; kwargs...) diff --git a/NDTensors/src/tensor/linearalgebra.jl b/NDTensors/src/tensor/linearalgebra.jl new file mode 100644 index 0000000000..33722ce49a --- /dev/null +++ b/NDTensors/src/tensor/linearalgebra.jl @@ -0,0 +1,7 @@ +function LinearAlgebra.qr(T::Tensor; kwargs...) + return qr(T; kwargs...) +end + +function LinearAlgebra.svd(T::Tensor; kwargs...) + return svd(T; kwargs...) +end diff --git a/NDTensors/src/truncate.jl b/NDTensors/src/truncate.jl index ad04aa2bbc..50629dd8ec 100644 --- a/NDTensors/src/truncate.jl +++ b/NDTensors/src/truncate.jl @@ -1,5 +1,3 @@ -export truncate! - function truncate!!(P::AbstractArray; kwargs...) return truncate!!(leaf_parenttype(P), P; kwargs...) end diff --git a/NDTensors/test/linearalgebra.jl b/NDTensors/test/linearalgebra.jl index 1ffda564ab..b80fc38b8f 100644 --- a/NDTensors/test/linearalgebra.jl +++ b/NDTensors/test/linearalgebra.jl @@ -1,6 +1,7 @@ using NDTensors using LinearAlgebra using Test + if "cuda" in ARGS || "all" in ARGS using CUDA end