Your constructor is returning the RHS of the last assignment in that 
statement block — the passed coef_ vector.  Simply amending your 
constructor to return `x` makes this behave as you expect.

type FIR{in_t, coef_t}
    in::Vector{in_t}
    coef::Vector{coef_t}
    FIR (in_::Vector{in_t}, coef_::Vector{coef_t}) = (x=new(); x.in = zeros(
in_t, size (in_)); x.coef = coef_; x)
end


On Wednesday, July 30, 2014 11:01:06 AM UTC-4, Neal Becker wrote:
>
> As a learning exercise, I am trying to code a simple FIR filter. 
> As a start, it has 2 fields and a constructor: 
>
> type FIR{in_t, coef_t} 
>     in::Vector{in_t} 
>     coef::Vector{coef_t} 
>     FIR (in_::Vector{in_t}, coef_::Vector{coef_t}) = (x=new(); x.in = 
> zeros(in_t, size (in_)); x.coef = coef_;) 
> end 
>
> w = zeros (Float64, 10) 
> f = FIR{Float64,Float64}(w,w) 
>
> This code executes, but seems very confused: 
> julia> typeof(f) 
> Array{Float64,1} 
>
> Huh?  I expected "f" to be of type FIR{Float64,Float64}.  Clearly I'm 
> doing 
> something very wrong. 
>
>

Reply via email to