Skip to content

Commit e9bbbfb

Browse files
committed
made typle stable mat from array creation work again
moving around Mat declaration to work around JuliaLang/julia#12814
1 parent e02becf commit e9bbbfb

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

src/FixedSizeArrays.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ include("core.jl")
99
include("functors.jl")
1010
include("constructors.jl")
1111
include("mapreduce.jl")
12-
include("indexing.jl")
13-
include("ops.jl")
14-
include("array_of_fixedsize.jl")
15-
include("conversion.jl")
1612

1713
# put them here due to #JuliaLang/julia#12814
14+
# needs to be befor indexing and ops, but after constructors
15+
immutable Mat{Row, Column, T} <: FixedMatrix{Row, Column, T}
16+
_::NTuple{Column, NTuple{Row, T}}
17+
end
1818
# most common FSA types
1919
immutable Vec{N, T} <: FixedVector{N, T}
2020
_::NTuple{N, T}
@@ -23,6 +23,20 @@ immutable Point{N, T} <: FixedVector{N, T}
2323
_::NTuple{N, T}
2424
end
2525

26+
include("indexing.jl")
27+
include("ops.jl")
28+
include("array_of_fixedsize.jl")
29+
include("conversion.jl")
30+
31+
32+
function show{R,C,T}(io::IO, m::Mat{R,C,T})
33+
println(io, typeof(m), "(")
34+
for i=1:R
35+
println(io, " ", join(row(m, i), " "))
36+
end
37+
println(io, ")")
38+
end
39+
2640
export FixedArray
2741
export FixedVector
2842
export FixedMatrix

src/core.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,4 @@ next(A::FixedArray, state::Integer) = (A[state], state+1)
5050
done(A::FixedArray, state::Integer) = length(A) < state
5151

5252

53-
immutable Mat{Row, Column, T} <: FixedMatrix{Row, Column, T}
54-
_::NTuple{Column, NTuple{Row, T}}
55-
end
5653

57-
function show{R,C,T}(io::IO, m::Mat{R,C,T})
58-
println(io, typeof(m), "(")
59-
for i=1:R
60-
println(io, " ", join(row(m, i), " "))
61-
end
62-
println(io, ")")
63-
end

src/functors.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ immutable RowFunctor{M}
5252
mat::M
5353
end
5454
call(r::RowFunctor, i::Int) = row(r.mat, i)
55-
function ctranspose{R, C, T}(a::Mat{R, C, T})
56-
Mat(ntuple(RowFunctor(a), Val{R}))
57-
end
55+
5856

5957

6058
immutable SetindexFunctor{T <: FixedArray, V, N} <: Func{1}

src/mapreduce.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ function reduce{FSA <: FixedArray}(f::Func{2}, a::FSA)
66
end
77
red
88
end
9-
function Base.reduce{R,C,T}(f::Base.Func{2}, a::Mat{R,C,T})
9+
function Base.reduce(f::Base.Func{2}, a::FixedMatrix)
1010
red = reduce(f, a.(1)[1])
11-
@inbounds for i=2:C
11+
@inbounds for i=2:size(a, 2)
1212
red = f(red, reduce(f, a.(1)[i]))
1313
end
1414
red

src/ops.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ for op in binaryOps
6161
end)
6262
end
6363

64+
function ctranspose{R, C, T}(a::Mat{R, C, T})
65+
Mat(ntuple(RowFunctor(a), Val{R}))
66+
end
6467

6568
dot{T <: FixedArray}(a::T, b::T) = sum(a.*b)
6669

0 commit comments

Comments
 (0)