Skip to content

Commit

Permalink
made typle stable mat from array creation work again
Browse files Browse the repository at this point in the history
moving around Mat declaration to work around JuliaLang/julia#12814
  • Loading branch information
SimonDanisch committed Sep 1, 2015
1 parent e02becf commit e9bbbfb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
22 changes: 18 additions & 4 deletions src/FixedSizeArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions src/functors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e9bbbfb

Please sign in to comment.