From c91feb01b273b3227aac79ce10090b393731c18a Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Thu, 23 Jun 2016 11:26:38 -0700 Subject: [PATCH] Remove `transpose(x) = x` fallback, instead `error`'ing. Patch up a few missing `transpose` methods and correct a test that failed for lack of a `transpose` method. --- base/char.jl | 2 ++ base/operators.jl | 2 +- base/strings/basic.jl | 2 ++ test/linalg/matmul.jl | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/base/char.jl b/base/char.jl index 52aa1492e2f862..e28217dc8c10ad 100644 --- a/base/char.jl +++ b/base/char.jl @@ -32,6 +32,8 @@ in(x::Char, y::Char) = x == y ==(x::Char, y::Char) = UInt32(x) == UInt32(y) isless(x::Char, y::Char) = UInt32(x) < UInt32(y) +transpose(c::Char) = c + const hashchar_seed = 0xd4d64234 hash(x::Char, h::UInt) = hash_uint64(((UInt64(x)+hashchar_seed)<<32) $ UInt64(h)) diff --git a/base/operators.jl b/base/operators.jl index 6570a14e3e6127..5b8ec3d5490718 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -293,7 +293,7 @@ fldmod1{T<:Real}(x::T, y::T) = (fld1(x,y), mod1(x,y)) fldmod1{T<:Integer}(x::T, y::T) = (fld1(x,y), mod1(x,y)) # transpose -transpose(x) = x +transpose(x) = error("transpose not implemented for $(typeof(x)).") ctranspose(x) = conj(transpose(x)) conj(x) = x diff --git a/base/strings/basic.jl b/base/strings/basic.jl index 7308123929a073..3beeae923cdc13 100644 --- a/base/strings/basic.jl +++ b/base/strings/basic.jl @@ -101,6 +101,8 @@ function length(s::AbstractString) end end +transpose(s::AbstractString) = s + ## string comparison functions ## function cmp(a::AbstractString, b::AbstractString) diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index 53d1368506e956..769ce7f0cb1c25 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -320,8 +320,9 @@ end immutable RootInt i::Int end -import Base: *, promote_op +import Base: *, transpose, promote_op (*)(x::RootInt, y::RootInt) = x.i*y.i +transpose(x::RootInt) = x promote_op(::typeof(*), ::Type{RootInt}, ::Type{RootInt}) = Int a = [RootInt(3)]