changeset 996:aa72f067e771 refactor/lazy_tensors

Rename file
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 18 Mar 2022 21:17:01 +0100
parents 1ba8a398af9c
children 20c376dffe84
files src/LazyTensors/LazyTensors.jl src/LazyTensors/lazy_tensor.jl src/LazyTensors/tensor_mapping.jl test/LazyTensors/lazy_tensor_test.jl test/LazyTensors/tensor_mapping_test.jl
diffstat 5 files changed, 93 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/src/LazyTensors/LazyTensors.jl	Fri Mar 18 21:14:47 2022 +0100
+++ b/src/LazyTensors/LazyTensors.jl	Fri Mar 18 21:17:01 2022 +0100
@@ -11,7 +11,7 @@
 export ⊗
 export SizeMismatch
 
-include("tensor_mapping.jl")
+include("lazy_tensor.jl")
 include("lazy_array.jl")
 include("lazy_tensor_operations.jl")
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/LazyTensors/lazy_tensor.jl	Fri Mar 18 21:17:01 2022 +0100
@@ -0,0 +1,80 @@
+export LazyTensor
+export apply
+export apply_transpose
+export range_dim, domain_dim
+export range_size, domain_size
+
+"""
+    LazyTensor{T,R,D}
+
+Describes a mapping of a `D` dimension tensor to an `R` dimension tensor.
+The action of the mapping is implemented through the method
+```julia
+    apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
+```
+
+The size of the range and domain that the operator works with should be returned by
+the functions
+```julia
+    range_size(::LazyTensor)
+    domain_size(::LazyTensor)
+```
+to allow querying for one or the other.
+
+Optionally the action of the transpose may be defined through
+```julia
+    apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
+```
+"""
+abstract type LazyTensor{T,R,D} end
+
+"""
+    apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
+
+Return the result of the mapping for a given index.
+"""
+function apply end
+
+"""
+    apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,R}, I::Vararg) where {R,D,T}
+
+Return the result of the transposed mapping for a given index.
+"""
+function apply_transpose end
+
+"""
+    range_dim(::LazyTensor)
+Return the dimension of the range space of a given mapping
+"""
+range_dim(::LazyTensor{T,R,D}) where {T,R,D} = R
+
+"""
+    domain_dim(::LazyTensor)
+Return the dimension of the domain space of a given mapping
+"""
+domain_dim(::LazyTensor{T,R,D}) where {T,R,D} = D
+
+
+"""
+    range_size(M::LazyTensor)
+
+Return the range size for the mapping.
+"""
+function range_size end
+
+"""
+    domain_size(M::LazyTensor)
+
+Return the domain size for the mapping.
+"""
+function domain_size end
+
+
+"""
+    eltype(::LazyTensor{T})
+
+The type of elements the LazyTensor acts on.
+"""
+Base.eltype(::LazyTensor{T}) where T = T
+
+# TODO: Think about boundschecking!
--- a/src/LazyTensors/tensor_mapping.jl	Fri Mar 18 21:14:47 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-export LazyTensor
-export apply
-export apply_transpose
-export range_dim, domain_dim
-export range_size, domain_size
-
-"""
-    LazyTensor{T,R,D}
-
-Describes a mapping of a `D` dimension tensor to an `R` dimension tensor.
-The action of the mapping is implemented through the method
-```julia
-    apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
-```
-
-The size of the range and domain that the operator works with should be returned by
-the functions
-```julia
-    range_size(::LazyTensor)
-    domain_size(::LazyTensor)
-```
-to allow querying for one or the other.
-
-Optionally the action of the transpose may be defined through
-```julia
-    apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
-```
-"""
-abstract type LazyTensor{T,R,D} end
-
-"""
-    apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
-
-Return the result of the mapping for a given index.
-"""
-function apply end
-
-"""
-    apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,R}, I::Vararg) where {R,D,T}
-
-Return the result of the transposed mapping for a given index.
-"""
-function apply_transpose end
-
-"""
-    range_dim(::LazyTensor)
-Return the dimension of the range space of a given mapping
-"""
-range_dim(::LazyTensor{T,R,D}) where {T,R,D} = R
-
-"""
-    domain_dim(::LazyTensor)
-Return the dimension of the domain space of a given mapping
-"""
-domain_dim(::LazyTensor{T,R,D}) where {T,R,D} = D
-
-
-"""
-    range_size(M::LazyTensor)
-
-Return the range size for the mapping.
-"""
-function range_size end
-
-"""
-    domain_size(M::LazyTensor)
-
-Return the domain size for the mapping.
-"""
-function domain_size end
-
-
-"""
-    eltype(::LazyTensor{T})
-
-The type of elements the LazyTensor acts on.
-"""
-Base.eltype(::LazyTensor{T}) where T = T
-
-# TODO: Think about boundschecking!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/LazyTensors/lazy_tensor_test.jl	Fri Mar 18 21:17:01 2022 +0100
@@ -0,0 +1,12 @@
+using Test
+using Sbplib.LazyTensors
+
+@testset "Generic Mapping methods" begin
+    struct DummyMapping{T,R,D} <: LazyTensor{T,R,D} end
+    LazyTensors.apply(m::DummyMapping{T,R,D}, v, I::Vararg{Any,R}) where {T,R,D} = :apply
+    @test range_dim(DummyMapping{Int,2,3}()) == 2
+    @test domain_dim(DummyMapping{Int,2,3}()) == 3
+    @test apply(DummyMapping{Int,2,3}(), zeros(Int, (0,0,0)),0,0) == :apply
+    @test eltype(DummyMapping{Int,2,3}()) == Int
+    @test eltype(DummyMapping{Float64,2,3}()) == Float64
+end
--- a/test/LazyTensors/tensor_mapping_test.jl	Fri Mar 18 21:14:47 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-using Test
-using Sbplib.LazyTensors
-
-@testset "Generic Mapping methods" begin
-    struct DummyMapping{T,R,D} <: LazyTensor{T,R,D} end
-    LazyTensors.apply(m::DummyMapping{T,R,D}, v, I::Vararg{Any,R}) where {T,R,D} = :apply
-    @test range_dim(DummyMapping{Int,2,3}()) == 2
-    @test domain_dim(DummyMapping{Int,2,3}()) == 3
-    @test apply(DummyMapping{Int,2,3}(), zeros(Int, (0,0,0)),0,0) == :apply
-    @test eltype(DummyMapping{Int,2,3}()) == Int
-    @test eltype(DummyMapping{Float64,2,3}()) == Float64
-end