Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/quadrature/quadrature.jl @ 333:01b851161018 refactor/combine_to_one_package
Start converting to one package by moving all the files to their correct location
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Fri, 25 Sep 2020 13:06:02 +0200 |
| parents | SbpOperators/src/quadrature/quadrature.jl@9cc5d1498b2d |
| children | 0844069ab5ff |
comparison
equal
deleted
inserted
replaced
| 332:535f1bff4bcc | 333:01b851161018 |
|---|---|
| 1 export Quadrature | |
| 2 """ | |
| 3 Quadrature{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} | |
| 4 | |
| 5 Implements the quadrature operator `Q` of Dim dimension as a TensorMapping | |
| 6 The multi-dimensional tensor operator consists of a tuple of 1D DiagonalInnerProduct H | |
| 7 tensor operators. | |
| 8 """ | |
| 9 struct Quadrature{Dim,T<:Real,M} <: TensorOperator{T,Dim} | |
| 10 H::NTuple{Dim,DiagonalInnerProduct{T,M}} | |
| 11 end | |
| 12 | |
| 13 LazyTensors.domain_size(Q::Quadrature{Dim}, range_size::NTuple{Dim,Integer}) where {Dim} = range_size | |
| 14 | |
| 15 function LazyTensors.apply(Q::Quadrature{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {T,Dim} | |
| 16 error("not implemented") | |
| 17 end | |
| 18 | |
| 19 function LazyTensors.apply(Q::Quadrature{1,T}, v::AbstractVector{T}, I::Index) where T | |
| 20 @inbounds q = apply(Q.H[1], v , I) | |
| 21 return q | |
| 22 end | |
| 23 | |
| 24 function LazyTensors.apply(Q::Quadrature{2,T}, v::AbstractArray{T,2}, I::Index, J::Index) where T | |
| 25 # Quadrature in x direction | |
| 26 @inbounds vx = view(v, :, Int(J)) | |
| 27 @inbounds qx = apply(Q.H[1], vx , I) | |
| 28 # Quadrature in y-direction | |
| 29 @inbounds vy = view(v, Int(I), :) | |
| 30 @inbounds qy = apply(Q.H[2], vy, J) | |
| 31 return qx*qy | |
| 32 end | |
| 33 | |
| 34 LazyTensors.apply_transpose(Q::Quadrature{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {Dim,T} = LazyTensors.apply(Q,v,I...) |
