diff --git a/src/FixedSizeArrays.jl b/src/FixedSizeArrays.jl index 8dfe31a..47a4fdd 100644 --- a/src/FixedSizeArrays.jl +++ b/src/FixedSizeArrays.jl @@ -9,12 +9,12 @@ include("core.jl") include("functors.jl") include("constructors.jl") include("mapreduce.jl") -include("indexing.jl") -include("ops.jl") -include("array_of_fixedsize.jl") -include("conversion.jl") # put them here due to #JuliaLang/julia#12814 +# needs to be befor indexing and ops, but after constructors +immutable Mat{Row, Column, T} <: FixedMatrix{Row, Column, T} + _::NTuple{Column, NTuple{Row, T}} +end # most common FSA types immutable Vec{N, T} <: FixedVector{N, T} _::NTuple{N, T} @@ -23,6 +23,20 @@ immutable Point{N, T} <: FixedVector{N, T} _::NTuple{N, T} end +include("indexing.jl") +include("ops.jl") +include("array_of_fixedsize.jl") +include("conversion.jl") + + +function show{R,C,T}(io::IO, m::Mat{R,C,T}) + println(io, typeof(m), "(") + for i=1:R + println(io, " ", join(row(m, i), " ")) + end + println(io, ")") +end + export FixedArray export FixedVector export FixedMatrix diff --git a/src/core.jl b/src/core.jl index ffe7d1f..1ca121f 100644 --- a/src/core.jl +++ b/src/core.jl @@ -50,14 +50,4 @@ next(A::FixedArray, state::Integer) = (A[state], state+1) done(A::FixedArray, state::Integer) = length(A) < state -immutable Mat{Row, Column, T} <: FixedMatrix{Row, Column, T} - _::NTuple{Column, NTuple{Row, T}} -end -function show{R,C,T}(io::IO, m::Mat{R,C,T}) - println(io, typeof(m), "(") - for i=1:R - println(io, " ", join(row(m, i), " ")) - end - println(io, ")") -end diff --git a/src/functors.jl b/src/functors.jl index d9dedd4..9a4a48b 100644 --- a/src/functors.jl +++ b/src/functors.jl @@ -52,9 +52,7 @@ immutable RowFunctor{M} mat::M end call(r::RowFunctor, i::Int) = row(r.mat, i) -function ctranspose{R, C, T}(a::Mat{R, C, T}) - Mat(ntuple(RowFunctor(a), Val{R})) -end + immutable SetindexFunctor{T <: FixedArray, V, N} <: Func{1} diff --git a/src/mapreduce.jl b/src/mapreduce.jl index 077d6a0..db2a292 100644 --- a/src/mapreduce.jl +++ b/src/mapreduce.jl @@ -6,9 +6,9 @@ function reduce{FSA <: FixedArray}(f::Func{2}, a::FSA) end red end -function Base.reduce{R,C,T}(f::Base.Func{2}, a::Mat{R,C,T}) +function Base.reduce(f::Base.Func{2}, a::FixedMatrix) red = reduce(f, a.(1)[1]) - @inbounds for i=2:C + @inbounds for i=2:size(a, 2) red = f(red, reduce(f, a.(1)[i])) end red diff --git a/src/ops.jl b/src/ops.jl index e005e7e..21e3315 100644 --- a/src/ops.jl +++ b/src/ops.jl @@ -61,6 +61,9 @@ for op in binaryOps end) end +function ctranspose{R, C, T}(a::Mat{R, C, T}) + Mat(ntuple(RowFunctor(a), Val{R})) +end dot{T <: FixedArray}(a::T, b::T) = sum(a.*b)