Closed wmwv closed 6 years ago
Wasn't handling negative curvature correctly. Switch to use complex cmplx.Sqrt
, cmplx.Sinh
.
Performance:
goos: darwin
goarch: amd64
pkg: github.com/wmwv/cosmo
BenchmarkMathSqrt-16 2000000000 0.27 ns/op
BenchmarkMathSinh-16 200000000 8.48 ns/op
BenchmarkMathSinhSqrt-16 200000000 8.55 ns/op
BenchmarkComplexSqrt-16 500000000 3.79 ns/op
BenchmarkComplexSinh-16 100000000 12.2 ns/op
BenchmarkComplexSinhSqrt-16 50000000 26.6 ns/op
The code SinhSqrt
tests are mocking up the code in question, which compares a (1/Sqrt(x))*Sinh(Sqrt(x))
. The performance difference is substantial in a relative sense: 8.55 ns/op vs. 26.6 ns/op.
But in an absolute sense, the LambdaComovingDistance
calculation takes ~750 ns, and the WCDMComovingdistance
and WACDMComovingDistance
calculations take ~200 microseconds. The 18 ns taken by a final wrapping with complex
numbers of the distance calculation is negligible.
Went with the cases written out separately for Ok0<0; Ok0==0; Ok0>0
, but the performance gains are trivial.
Merged to master.
The
WCDM.ComovingDistance
is currently wrong for Nonflat LCDM cases.wcdm.go
lambdacdm.go
,wacdm.go
as well.