chakravala / AbstractTensors.jl
Showing 1 of 2 files from the diff.
Other files ignored by Codecov
Project.toml has changed.

@@ -124,12 +124,19 @@
Loading
124 124
Base.@pure valuetype(::T) where T<:Number = T
125 125
#Base.@pure valuetype(::T) where T<:TensorAlgebra{V,𝕂} where V where 𝕂 = 𝕂
126 126
127 -
function Base.isapprox(a::S,b::T) where {S<:TensorAlgebra,T<:TensorAlgebra}
128 -
    rtol = Base.rtoldefault(valuetype(a), valuetype(b), 0)
129 -
    LinearAlgebra.norm(Base.:-(a,b))≤rtol*max(LinearAlgebra.norm(a),LinearAlgebra.norm(b))
127 +
Base.real(::Type{T}) where T<:TensorAlgebra = real(valuetype(T))
128 +
Base.rtoldefault(::Type{T}) where T<:TensorAlgebra = Base.rtoldefault(valuetype(T))
129 +
function Base.isapprox(a::S,b::T;atol::Real=0,rtol::Real=Base.rtoldefault(a,b,atol),nans::Bool=false,norm::Function=LinearAlgebra.norm) where {S<:TensorAlgebra,T<:TensorAlgebra}
130 +
    x,y = norm(a),norm(b)
131 +
    (isfinite(x) && isfinite(y) && norm(Base.:-(a,b))≤max(atol,rtol*max(x,y))) || (nans && isnan(x) && isnan(y))
130 132
end
131 -
function Base.isapprox(a::S,b::T) where {S<:TensorGraded,T<:TensorGraded}
132 -
    Manifold(a)==Manifold(b) && (rank(a)==rank(b) ? AbstractTensors.:≈(norm(a),norm(b)) : (isnull(a) && isnull(b)))
133 +
function Base.isapprox(a::S,b::T;atol::Real=0,rtol::Real=Base.rtoldefault(a,b,atol),nans::Bool=false,norm::Function=LinearAlgebra.norm) where {S<:TensorGraded,T<:TensorGraded}
134 +
    Manifold(a)==Manifold(b) && if rank(a)==rank(b)
135 +
        x,y = norm(a),norm(b)
136 +
        (isfinite(x) && isfinite(y) && norm(Base.:-(a,b))≤max(atol,rtol*max(x,y))) || (nans && isnan(x) && isnan(y))
137 +
    else
138 +
        isnull(a) && isnull(b)
139 +
    end
133 140
end
134 141
135 142
# universal vector space interopability, abstract tensor form evaluation, contraction
Files Coverage
src 7.54%
Project Totals (2 files) 7.54%