Commit f307decb authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Add of_eltype method

parent bfcd96d0
......@@ -16,6 +16,8 @@ module Geometry
export
find_aligned_boxes
using ..Tao: of_eltype
using Printf
using TwoDimensional, ArrayTools
......
......@@ -74,6 +74,18 @@ to_float(types::Type{<:Real}...) = float(promote_type(types...))
to_float(T::Type{<:AbstractFloat}) = T
to_float(::Type{<:Integer}) = Float64
"""
of_eltype(T, A)
yields an object similar to `A` but with elements of type `T`. If the elements
of `A` are laready of the requeste type, `A` is returned, not a copy.
"""
of_eltype(::Type{T}, A::AbstractArray{T}) where {T} = A
of_eltype(::Type{T}, A::AbstractArray) where {T} = copyto!(similar(A, T), A)
#------------------------------------------------------------------------------
# LAYOUT
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment