Mercurial > repos > public > sbplib_julia
comparison src/Grids/equidistant_grid.jl @ 1686:b996c35dd647 feature/grids/manifolds
Simplify equidistan_grid(::Number,::Number,::Int)
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 21 Aug 2024 19:12:28 +0200 |
parents | 4aa0973bffb0 |
children | a4c52ae93b11 |
comparison
equal
deleted
inserted
replaced
1685:4aa0973bffb0 | 1686:b996c35dd647 |
---|---|
120 equidistant_grid(limit_lower::Number, limit_upper::Number, size::Int) | 120 equidistant_grid(limit_lower::Number, limit_upper::Number, size::Int) |
121 | 121 |
122 Constructs a 1D equidistant grid. | 122 Constructs a 1D equidistant grid. |
123 """ | 123 """ |
124 function equidistant_grid(limit_lower::Number, limit_upper::Number, size::Int) | 124 function equidistant_grid(limit_lower::Number, limit_upper::Number, size::Int) |
125 if any(size .<= 0) | 125 if size <= 0 |
126 throw(DomainError("size must be postive")) | 126 throw(DomainError("size must be postive")) |
127 end | 127 end |
128 | 128 |
129 if any(limit_upper.-limit_lower .<= 0) | 129 if limit_upper-limit_lower <= 0 |
130 throw(DomainError("side length must be postive")) | 130 throw(DomainError("side length must be postive")) |
131 end | 131 end |
132 | |
132 return EquidistantGrid(range(limit_lower, limit_upper, length=size)) # TBD: Should it use LinRange instead? | 133 return EquidistantGrid(range(limit_lower, limit_upper, length=size)) # TBD: Should it use LinRange instead? |
133 end | 134 end |
134 | 135 |
135 | 136 |
136 equidistant_grid(hb::HyperBox, dims::Vararg{Int}) = equidistant_grid(hb.a, hb.b, dims...) | 137 equidistant_grid(hb::HyperBox, dims::Vararg{Int}) = equidistant_grid(hb.a, hb.b, dims...) |