-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLinearFunction_ForwardAndTranspose.jl
49 lines (41 loc) · 1.33 KB
/
LinearFunction_ForwardAndTranspose.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Example for building JOLI operator having functions
# defining action for forward and transpose mapping
#
# we will use plain matrix to fake the actions
using JOLI
# forward function
function fwd(A::AbstractMatrix,vin::AbstractVector,RDT::DataType)
vout=A*vin
return jo_convert(RDT,vout)
end
# transpose function
function fwdT(A::AbstractMatrix,vin::AbstractVector,RDT::DataType)
vout=transpose(A)*vin
return jo_convert(RDT,vout)
end
# define matrix for mapping functions
a=rand(ComplexF32,3,3)
# define JOLI operator with desired domain and range using
# using joLinearFunctionFwdT constructor
# note forced dropping imaginary part for transpose/adjoint operators
A=joLinearFunctionFwd_T(3,3,
v->fwd(a,v,ComplexF64),v->fwdT(a,v,Float32),
Float32,ComplexF64;name="my_A")
show(A)
# disable warining for implicit inacurate conversions - use only after debugging your code
jo_convert_warn_set(false)
# display elements of the operator
println("forward: A")
show(A); display(elements(A)); println()
println("transpose: transpose(A)")
show(transpose(A)); display(elements(transpose(A))); println()
println("adjoint: A'")
show(A'); display(elements(A')); println()
println("conjugate: conj(A)")
show(conj(A)); display(elements(conj(A))); println()
# multiply by vector
x=rand(Float32,3)
y=A*x
println("y: ",y)
xx=A'*y
println("xx: ",xx)