Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Type parameterized by a parameterized type

76 views
Skip to first unread message

David van Leeuwen

unread,
Dec 14, 2014, 9:43:26 AM12/14/14
to juli...@googlegroups.com

Hello, 

In this PR I proposed to change the type definitions of the factorization matrix types such that the main container type change form Matrix to AbstractMatrix.  

Intuitively, I would have wanted to specify such parametrization as:
type Factortype{T,S<:AbstractMatrix{T}} <: Factorization{T}
  factor::S
end
but the parser doesn't know of the T yet in `AbstractMatrix{T}`.  

Is there a chance Julia would support such a construction in the future?  

My approach in the end is the construction
type Factortype{T,S<:AbstractMatrix} <: Factorization{T}
    factor::S
    Factortype(f::AbstractMatrix{T}) = new(f)
end
Factortype{T}(f::AbstractMatrix{T}) = Factortype{T,typeof(f)}(f)
which is a little cumbersome, and from my own experience in trying to generalize all factorization types to have AbstractMatrix containers, quite typo-prone.  
Cheers, 

---david

Avik Sengupta

unread,
Dec 14, 2014, 10:05:53 AM12/14/14
to juli...@googlegroups.com
Yeah, that's not possible yet. See https://github.com/JuliaLang/julia/issues/3766 for a discussion.
Reply all
Reply to author
Forward
0 new messages