Comments (8)
Pow(x, -0.5)
is in fact implemented as 1/Sqrt(x)
in math.pow.go
func pow(x, y float64) float64 {
[...]
case y == -0.5:
return 1 / Sqrt(x)
from cosmo.
E(z)
is 8 ns/call
Einv(z)
defined as return 1/cos.E(z)
is 13 ns/call
Explicitly writing out Einv(z)
with Math.Pow([...], -0.5)
is 14 ns/call.
Defining a test Einv(z)
incorrectly as just return cos.E(z)
is 11 ns/call.
from cosmo.
A ComovingDistance
call is painful. It's 1.6 ms for one redshift.
And looping through 10,000 redshifts is 1.4 seconds! 1000x larger.
Python astropy.cosmology
takes a similar amount of time for the same calculation. 1.7 s for N=10,000. 11 s for N=100,000 + N=10,000.
import numpy as np
import astropy.cosmology
cosmo = astropy.cosmology.FlatLambdaCDM(H0=70, Om0=0.3)
N = 10000
z = np.arange(N) + 0.001
cosmo.comoving_distance(z)
N = 100000
z = np.arange(N) + 0.001
cosmo.comoving_distance(z)
from cosmo.
So that's consistent. I was just hoping to do better because the astropy.cosmology
implementation has always seemed really slow.
from cosmo.
Setting Gaussian quadrature n points to 1,000 preserves abs tolerance in distances of 1e-6 in Mpc and 1e-8 in distance modulus for the tested range of 0<z<3
. Decrease from former value of 10,000 speeds of individual calculation by 10, as expected.
But the large N=10,000 redshift points loops are still at ~1.4 seconds. There are perhaps residual overheads I should look into further.
from cosmo.
If I test for looping over E(z)
, I get 85,000 ns, which is exactly in line with the 7-9 ns for the individual * N=10,000.
from cosmo.
Using a switch
to avoid a math.Pow
for w=-1
shaves 3 ns off the 8 ns runtime of E(z)
.
from cosmo.
math.Sin
vs. math.Sinh
doesn't matter
from cosmo.
Related Issues (20)
- Rename `Cosmology` interface to `FLRW`. HOT 1
- Rewrite example tests and test test more clearly
- Increase testing by rewriting test runner HOT 1
- Add benchmarks for wcdm, wacdm
- Check and correct test cases for wcdm_test, wacdm_test HOT 2
- Revise documentation to make godoc page readable and efficient
- Write luminosity distance test for non-flat LambdaCDM HOT 1
- Remove Evec code.
- Remove LookbackTimeIntegrate from FLRW interface
- Make *OM, *OL, *Integrate implementation functions private HOT 1
- Explore using type conversion for special cases HOT 3
- Remove unused Tcmb0
- Shift table-based tests to struct with name, cos, exp
- Change argument order to put H0 first. HOT 1
- Write String method to represent object values nicely. HOT 1
- Fix broken `WCDM.ComovingDistance` for Nonflat LCDM cases HOT 4
- Add Ok0() method HOT 1
- Clean up godoc.org presentation. HOT 2
- Satisfy golint HOT 1
- Test de Sitter (Om, Ol = 0, 1) cosmologies
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 cosmo.