Skip to content

Commit

Permalink
Use typeof not eltype, and Type not DataType
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffFessler committed Jan 1, 2023
1 parent 1e6c851 commit 00e7172
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cauchy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ function _cauchy_check(x, y)
allunique(y) || @warn("y elements should be unique")
end

function _cauchy_eltype(Tx::DataType, Ty::DataType)
T = eltype(one(Tx) + one(Ty))
return T <: Integer ? Rational{T} : eltype(1 / one(T))
function _cauchy_type(Tx::Type{<:Number}, Ty::Type{<:Number})
T = typeof(oneunit(Tx) + oneunit(Ty))
return T <: Integer ? Rational{T} : typeof(1 / oneunit(T))
end

"""
Expand Down Expand Up @@ -60,7 +60,7 @@ struct Cauchy{T,X,Y} <: AbstractMatrix{T}
Base.require_one_based_indexing(x)
Base.require_one_based_indexing(y)
_cauchy_check(x, y)
T = _cauchy_eltype(Tx, Ty)
T = _cauchy_type(Tx, Ty)
return new{T,typeof(x),typeof(y)}(x, y)
end
end
Expand Down

0 comments on commit 00e7172

Please sign in to comment.