problems_mortar_3d.jl: rename function contains to approx_in (#86)

* problems_mortar_3d.jl: rename function contains to approx_in

See issue #85. `contains` is now renamed to `approx_in`. I also
switched argument order, so this function is now called in a same
way function `in()`. Usage example:

    julia> P = Vector[[1.0, 1.0], [2.0, 2.0]]
    2-element Array{Array{T,1},1}:
     [1.0,1.0]
     [2.0,2.0]

    julia> q = [1.0, 1.0] + eps(Float64)
    2-element Array{Float64,1}:
     1.0
     1.0

    julia> in(q, P)
    false

    julia> approx_in(q, P)
    true

Also added docstring and usage example.

* Removed `importall base` from code
This commit is contained in:
Jukka Aho
2017-02-01 10:42:31 +02:00
committed by Tero Frondelius
parent c307c1482c
commit bb06b151cb
7 changed files with 40 additions and 26 deletions
+7 -7
View File
@@ -89,12 +89,12 @@ function length(f::DCTI)
return 1
end
function Base.:*(c::Number, f::DCTI)
function *(c::Number, f::DCTI)
return c*f.data
end
""" Kind of spatial interpolation of DCTI. """
function Base.:*(N::Matrix, f::DCTI)
function *(N::Matrix, f::DCTI)
@assert length(N) == 1
return N[1]*f.data
end
@@ -179,11 +179,11 @@ function start(field::DVTI)
return 1
end
function Base.:+(f1::DVTI, f2::DVTI)
function +(f1::DVTI, f2::DVTI)
return DVTI(f1.data + f2.data)
end
function Base.:-(f1::DVTI, f2::DVTI)
function -(f1::DVTI, f2::DVTI)
return DVTI(f1.data - f2.data)
end
@@ -192,20 +192,20 @@ function update!(field::DVTI, data::Union{Vector, Dict})
end
""" Take scalar product of DVTI and constant T. """
function Base.:*(T::Number, field::DVTI)
function *(T::Number, field::DVTI)
return DVTI(T*field.data)
end
""" Take dot product of DVTI field and vector T. Vector length must match to the
field length and this can be used mainly for interpolation purposes, i.e., u = ∑ Nᵢuᵢ.
"""
function Base.:*(T::Vector, f::DVTI)
function *(T::Vector, f::DVTI)
@assert length(T) <= length(f)
return sum([T[i]*f[i] for i=1:length(T)])
end
""" Take outer product of DVTI field and matrix T. """
function Base.:*(T::Matrix, f::DVTI)
function *(T::Matrix, f::DVTI)
n, m = size(T)
return sum([kron(T[:,i], f[i]') for i=1:m])'
end