-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some operations do not work although they (probably) should #153
Comments
The issue here is that M = ones(Rational{Int},3,3)
v = ones(Int,3)
LinearOperator(M)*v # works The issue is not due to julia> promote_type(Rational, Int)
Real
julia> promote_type(Rational{Int}, Int)
Rational{Int64} |
Regarding the more general issue
The default Julia promotion rules should apply here: julia> M = ones(Float32, 3, 3)
3×3 Array{Float32,2}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
julia> v = ones(Float64, 3)
3-element Array{Float64,1}:
1.0
1.0
1.0
julia> M * v
3-element Array{Float64,1}:
3.0
3.0
3.0 Is there any additional operation involved? |
Many thanks for your explanation.
Abel Siqueira <notifications@github.com> schrieb am Mo., 5. Okt. 2020,
17:00:
… The issue here is that Rational does not provide enough information. It
should be Rational{Int} instead:
M = ones(Rational{Int},3,3)
v = ones(Int,3)LinearOperator(M)*v # works
The issue is not due to LinearOperators but due to the promotion rules:
julia> promote_type(Rational, Int)
Real
julia> promote_type(Rational{Int}, Int)
Rational{Int64}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#153 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALJDHECQ7TFIOVCHU764Y3LSJHNRJANCNFSM4SEZDWCA>
.
|
In MatrixEquations.jl the operation exits with error for a Lyapunov
operator of type Float32 and vector of type Float64.
Abel Siqueira <notifications@github.com> schrieb am Mo., 5. Okt. 2020,
17:07:
… Regarding the more general issue
...underlying matrices of a certain element type T (say T = Float32). The
vector v can have any element type T1 (say T1 = Float64) such that it can
be still converted to the element type T, without error. In this case, the
result M*v would have element type T...
The default Julia promotion rules should apply here:
julia> M = ones(Float32, 3, 3)
3×3 Array{Float32,2}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
julia> v = ones(Float64, 3)
3-element Array{Float64,1}:
1.0
1.0
1.0
julia> M * v
3-element Array{Float64,1}:
3.0
3.0
3.0
Is there any additional operation involved?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#153 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALJDHEBZGED4FNBSBHY7UUDSJHOL3ANCNFSM4SEZDWCA>
.
|
The following code illustrates this issue:
The execution of this code produces:
I wonder what is the right approach in determining the type of the elements of the result of an operation
M*v
. For example, in my concrete case,M
is an inverse operator to solve a matrix equation, with the underlying matrices of a certain element typeT
(sayT = Float32
). The vectorv
can have any element typeT1
(sayT1 = Float64
) such that it can be still converted to the element typeT
, without error. In this case, the resultM*v
would have element typeT
, which would be, for me, the desirable type. Still note that forM
a matrix, the result ofM*v
has element typeT
(and notT1
), which involves a conversion ofM
(generally not desirable in my case).The text was updated successfully, but these errors were encountered: