Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Temporarily change of dot to old version for complex types as complex…

… return does not work on 32 bit machines. Add tests for matrix and vector multiplication.
  • Loading branch information...
commit 2ad96bd8a09ef86f8eef771f7b32848f9fda40d5 1 parent beb277b
Andreas Noack andreasnoack authored
Showing with 6 additions and 1 deletion.
  1. +1 −1  base/matmul.jl
  2. +5 −0 test/linalg.jl
2  base/matmul.jl
View
@@ -36,7 +36,7 @@ diagmm(b::Vector, A::Matrix) =
# Dot products
-dot{T<:BLAS.BlasFloat}(x::Vector{T}, y::Vector{T}) = BLAS.dot(x, y)
+dot{T<:Union(Float32, Float64)}(x::Vector{T}, y::Vector{T}) = BLAS.dot(x, y)
function dot{T<:BLAS.BlasFloat, TI<:Integer}(x::Vector{T}, rx::Union(Range1{TI},Range{TI}), y::Vector{T}, ry::Union(Range1{TI},Range{TI}))
length(rx) != length(ry) ? error("Ranges should be of same length") : true
if min(rx) < 1 || max(rx) > length(x) || min(ry) < 1 || max(ry) > length(y)
5 test/linalg.jl
View
@@ -118,6 +118,11 @@ for elty in (Float32, Float64, Complex64, Complex128)
a = convert(Matrix{elty}, a)
b = convert(Matrix{elty}, b)
+ # Matrix and vector multiplication
+ @assert_approx_eq b'b convert(Matrix{elty}, [3 0; 0 2])
+ @assert_approx_eq b'b[:,1] convert(Vector{elty}, [3, 0])
+ @assert_approx_eq dot(b[:,1], b[:,1]) convert(elty, 3.0)
+
# Least squares
x = a[:,1:2]\b[:,1] # Vector rhs
@assert_approx_eq ((a[:,1:2]*x-b[:,1])'*(a[:,1:2]*x-b[:,1]))[1] convert(elty, 2.546616541353384)
Please sign in to comment.
Something went wrong with that request. Please try again.