Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optimizations for UniversalKriging #3

Merged
merged 5 commits into from
May 24, 2015
Merged

Conversation

rth
Copy link
Contributor

@rth rth commented Apr 20, 2015

Following explanations in the feature request #2, this PR reintroduces code from v1.0.0 (3bf98a1) for UniversalKriging where it is computed with a loop.

In the version 3bf98a1, in every loop an A matrix is defined together with a second member b and the system is A x = b then solved with np.linalg.solve.

This PR, just factorizes the matrix definition outside of the python loop, and computes it's inverse. The x vector can be obtained by A^(-1) b, which is much faster once we have inverted the matrix. This result in (a) reducing the required RAM, compared to the all vectorized version (b) speed up the code by a factor of ~15 (for nx=100, ny=200, n=100).

Everything is defined in the cexecute function, alongside the original execute function. A typical use would be,

 z, ss = UK.cexecute('grid', gridx, gridy, backend='python')

There are some additional tests in tests.py to check that both versions give the same output (although this might need to be tested more).

Edit:

Added a vectorized pure python version (without the loop), that is ~4-6x faster, but requires more RAM (e.g. 6 GB of RAM for nx=1000, ny=1000, npt=100). It can be accessed through,

 z, ss = UK.cexecute('grid', gridx, gridy, backend='vectorized')

@rth rth changed the title Optimisations for UniversalKriging Optimizations for UniversalKriging Apr 21, 2015
bsmurphy added a commit that referenced this pull request May 24, 2015
Optimizations for UniversalKriging
@bsmurphy bsmurphy merged commit d9b45a8 into GeoStat-Framework:master May 24, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants