Comments (7)
Also apologies I'm busy and on the road at the moment, so I'm missing all the fun. But should have some time for this in a few days.
from neutrallandscapes.jl.
Oops
from neutrallandscapes.jl.
@gottacatchenall used a solution where he allocated a temporary square array big enough to hold the non-square one - might make sense to choose the same approach in the two places?
from neutrallandscapes.jl.
@mkborregaard I agree - @gottacatchenall is this already a function that @rafaqz can re-use?
from neutrallandscapes.jl.
not quite, i check the size via
function _landscape!(mat, alg::Union{DiamondSquare, MidpointDisplacement}; kw...) where {IT <: Integer}
rightSize::Bool = _isPowerOfTwo(size(mat)[1]-1) && _isPowerOfTwo(size(mat)[2]-1)
dsMat = mat
if !rightSize
dim1, dim2 = size(mat)
smallestContainingLattice::Int = 2^ceil(log2(max(dim1, dim2))) + 1
@warn "$alg cannot be run on the input dimensions ($dim1 x $dim2),
and will instead run on the next smallest valid size ($smallestContainingLattice x $smallestContainingLattice).
This can slow performance as it involves additional memory allocation."
dsMat = zeros(smallestContainingLattice, smallestContainingLattice)
end
_diamondsquare!(dsMat, alg)
mat .= dsMat[1:size(mat)[1], 1:size(mat)[2]]
end
which enforeces it must be square but has the additional condition that the size must be (2^n)+1
, although this could be implemented in to something more general like
function _landscape!(mat, alg)
matPointer = mat
if !rightSize(mat, alg)
# allocation correct size matrix to matPointer
end
mat[:] .= matPointer[1:size(mat)[1], 1:size(mat)[2]]
end
from neutrallandscapes.jl.
Thats what happens already, I just messed it up somehow
from neutrallandscapes.jl.
This was closed via faaeed5
from neutrallandscapes.jl.
Related Issues (17)
- Problem with wavesurface
- two abstract types of landscape makers HOT 1
- Progress on landscape makers HOT 21
- Euclidean Distance Transform HOT 9
- code organisation HOT 2
- Add voronoi grid HOT 13
- DiamondSquare and MidpointDisplacement are not rescaled HOT 2
- DiamondSquare warning? HOT 2
- Readme organisation HOT 1
- Tag? HOT 18
- TagBot trigger issue HOT 16
- MethodError: no method matching NearestNeighborCluster(::Float64) HOT 6
- NearestNeighborCluser is broken with :queen HOT 2
- [RFC] adding methods for temporal change in neutral landscapes HOT 3
- `normalize` can't handle NaNs HOT 3
- HaltonSequences is misbehaving HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neutrallandscapes.jl.