I wanted to call the constructor of composite type WeightedPool1D but I tried both WeightedPool1D(mask) and WeightedPool1D{Float64}(mask) but it did not work.
Thanks!
Julia version: 1.6.1
My code:
# creating composite type
struct WeightedPool1D{T}
n::Int
c::Int
mask::Matrix{Bool}
weight::Matrix{T}
function WeightedPool1D(mask::Matrix{Bool}) where T
c, n = size(mask)
weight = randn(T, c, n) / n
new{T}(n, c, mask, weight)
end
end
# create argument
mask = zeros(Bool, 3, 3)
Calling w = WeightedPool1D(mask) gives the error
julia> w = WeightedPool1D(mask)
ERROR: UndefVarError: T not defined
Calling w = WeightedPool1D{Float64}(mask) gives the error
julia> w = WeightedPool1D{Float64}(mask)
ERROR: MethodError: no method matching WeightedPool1D{Float64}(::Matrix{Bool})