Skip to content

Commit b73b479

Browse files
committed
added displacement
1 parent 9b4e3dc commit b73b479

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/calculus/AffineAdd.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ function permute(T::AffineAdd{L,D,S}, p::AbstractVector{Int}) where {L,D,S}
9292
return AffineAdd(A,T.d,S)
9393
end
9494

95-
95+
displacement(A::AffineAdd{L,D,true}) where {L,D} = A.d+displacement(A.A)
96+
displacement(A::AffineAdd{L,D,false}) where {L,D} = -A.d+displacement(A.A)

src/calculus/Sum.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,4 @@ function permute(S::Sum{M,N}, p::AbstractVector{Int}) where {M,N}
116116
AA = ([permute(A,p) for A in S.A]...)
117117
return Sum(AA,S.bufC,S.bufD[p],M,N)
118118
end
119+

src/properties.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export ndoms,
1616
is_full_column_rank,
1717
is_sliced,
1818
diag_AcA,
19-
diag_AAc
19+
diag_AAc,
20+
displacement
2021

2122

2223
"""
@@ -267,6 +268,32 @@ true
267268
"""
268269
is_sliced(L::AbstractOperator) = false
269270

271+
"""
272+
`displacement(A::AbstractOperator)`
273+
274+
Returns the displacement of the operator.
275+
276+
```julia
277+
julia> A = AffineAdd(Eye(4),[1.;2.;3.;4.])
278+
I+d ℝ^4 -> ℝ^4
279+
280+
julia> displacement(A)
281+
4-element Array{Float64,1}:
282+
1.0
283+
2.0
284+
3.0
285+
4.0
286+
287+
```
288+
"""
289+
function displacement(S::AbstractOperator)
290+
d = S*blockzeros(domainType(S),size(S,2))
291+
if all(y -> y == d[1], d )
292+
return d[1]
293+
else
294+
return d
295+
end
296+
end
270297

271298
import Base: convert
272299
function convert(::Type{T}, dom::Type, dim_in::Tuple, L::T) where {T <: AbstractOperator}

0 commit comments

Comments
 (0)