Skip to content

Commit

Permalink
fixing vector*matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 22, 2012
1 parent 3c3e0ae commit 0dfbc8a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
14 changes: 1 addition & 13 deletions j/linalg.j
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,8 @@ function (*){T,S}(A::AbstractMatrix{T}, B::AbstractVector{S})
return C
end

# TODO: support transposed arguments
function (*){T,S}(A::AbstractVector{S}, B::AbstractMatrix{T})
nA = size(A, 1)
nB = size(B, 2)
R = promote_type(T,S)
C = Array(R, nB)
for j = 1:nB
s = zero(R)
for i = 1:nA
s += A[i] * B[i, j]
end
C[j] = s
end
return C
return reshape(A,length(A),1)*B
end

# TODO: support transposed arguments
Expand Down
22 changes: 0 additions & 22 deletions j/linalg_blas.j
Original file line number Diff line number Diff line change
Expand Up @@ -284,25 +284,3 @@ function (*){T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T}
zero(T), Y, 1)
return Y
end

# TODO: support transposed arguments
function (*){T<:Union(Float64,Float32,Complex128,Complex64)}(X::StridedVector{T},
A::StridedMatrix{T})
nX = size(X, 1)
(mA, nA) = size(A)

if mA != nX; error("*: argument shapes do not match"); end

if stride(A, 1) != 1
return invoke(*, (AbstractVector, AbstractMatrix), X, A)
end

# Result array does not need to be initialized as long as beta==0
Y = Array(T, nA)

_jl_blas_gemv("T", mA, nA,
one(T), A, stride(A, 2),
X, stride(X, 1),
zero(T), Y, 1)
return Y
end

0 comments on commit 0dfbc8a

Please sign in to comment.