Skip to content

Commit

Permalink
Remove transpose(x) = x fallback, instead error'ing. Patch up a f…
Browse files Browse the repository at this point in the history
…ew missing `transpose` methods and correct a test that failed for lack of a `transpose` method.
  • Loading branch information
Sacha0 committed Jul 3, 2016
1 parent d9fecbf commit 70af44c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions base/char.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) = throw(ArgumentError("transpose not implemented for $(typeof(x)). Consider permutedims."))
ctranspose(x) = conj(transpose(x))
conj(x) = x

Expand Down
2 changes: 2 additions & 0 deletions base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ function length(s::AbstractString)
end
end

transpose(s::AbstractString) = s

## string comparison functions ##

function cmp(a::AbstractString, b::AbstractString)
Expand Down
3 changes: 2 additions & 1 deletion test/linalg/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 70af44c

Please sign in to comment.