Skip to content

Commit

Permalink
Merge pull request #39 from mschauer/matmul
Browse files Browse the repository at this point in the history
fix matmul
  • Loading branch information
SimonDanisch committed Sep 18, 2015
2 parents 4615086 + 60a6955 commit 66d9c63
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,20 @@ end
# Matrix
(*){T, M, N, O, K}(a::FixedMatrix{M, N, T}, b::FixedMatrix{O, K, T}) = throw(DimensionMismatch("$N != $O in $(typeof(a)) and $(typeof(b))"))

@generated function (*){T, M, N, K}(a::Mat{M, N, T}, b::Mat{N, K, T})
expr = [
:(tuple(
$([:( dot(row(a, $k), column(b, $m)) ) for k=1:K]...)
))
for m=1:M]
quote
$(Expr(:boundscheck, false))
Mat(tuple($(expr...)))
end

@generated function *{T, M, N}(a::Mat{M, N, T}, b::Vec{N,T})
expr = [:(dot(row(a, $i), b.(1))) for i=1:M]
return quote
$(Expr(:boundscheck, false))
Vec($(expr...))
end
end
@generated function *{T, M, N, R}(a::Mat{M, N, T}, b::Mat{N, R, T})
expr = Expr(:tuple, [Expr(:tuple, [:(dot(row(a, $i), column(b,$j))) for i in 1:M]...) for j in 1:R]...)
return quote
$(Expr(:boundscheck, false))
Mat($(expr))
end
end

@generated function (*){T, FSV <: FixedVector, R, C}(a::Mat{R, C, T}, b::FSV)
Expand Down

0 comments on commit 66d9c63

Please sign in to comment.