Skip to content

Commit

Permalink
prevent nan where log(rand) is calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Oct 5, 2022
1 parent 6203210 commit dc42951
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,10 @@ __device__ inline int launchnewphoton(MCXpos* p, MCXdir* v, Stokes* s, MCXtime*
if (gcfg->srctype == MCX_SRC_DISK) {
r = sqrtf(rand_uniform01(t) * fabs(gcfg->srcparam1.x * gcfg->srcparam1.x - gcfg->srcparam1.y * gcfg->srcparam1.y) + gcfg->srcparam1.y * gcfg->srcparam1.y);
} else if (fabs(gcfg->c0.w) < 1e-5f || fabs(gcfg->srcparam1.y) < 1e-5f) {
r = sqrtf(-0.5f * logf(rand_uniform01(t))) * gcfg->srcparam1.x;
r = sqrtf(0.5f * rand_next_scatlen(t)) * gcfg->srcparam1.x;
} else {
r = gcfg->srcparam1.x * gcfg->srcparam1.x * M_PI / gcfg->srcparam1.y; //Rayleigh range
r = sqrtf(-0.5f * logf(rand_uniform01(t)) * (1.f + (gcfg->c0.w * gcfg->c0.w / (r * r)))) * gcfg->srcparam1.x;
r = sqrtf(0.5f * rand_next_scatlen(t) * (1.f + (gcfg->c0.w * gcfg->c0.w / (r * r)))) * gcfg->srcparam1.x;
}

if ( v->z > -1.f + EPS && v->z < 1.f - EPS ) {
Expand Down Expand Up @@ -1283,7 +1283,7 @@ __device__ inline int launchnewphoton(MCXpos* p, MCXdir* v, Stokes* s, MCXtime*
float ang, stheta, ctheta, sphi, cphi;
ang = TWO_PI * rand_uniform01(t); //next arimuth angle
sincosf(ang, &sphi, &cphi);
ang = sqrtf(-2.f * logf(rand_uniform01(t))) * (1.f - 2.f * rand_uniform01(t)) * gcfg->srcparam1.x;
ang = sqrtf(2.f * rand_next_scatlen(t)) * (1.f - 2.f * rand_uniform01(t)) * gcfg->srcparam1.x;
sincosf(ang, &stheta, &ctheta);
rotatevector(v, stheta, ctheta, sphi, cphi);
canfocus = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/pybind11
Submodule pybind11 updated 79 files
+65 −61 .clang-tidy
+5 −3 .github/CONTRIBUTING.md
+0 −4 .github/dependabot.yml
+40 −23 .github/workflows/ci.yml
+1 −1 .github/workflows/configure.yml
+6 −4 .github/workflows/format.yml
+7 −5 .github/workflows/pip.yml
+3 −3 .github/workflows/upstream.yml
+14 −11 .pre-commit-config.yaml
+13 −0 CMakeLists.txt
+3 −0 docs/_static/css/custom.css
+0 −11 docs/_static/theme_overrides.css
+2 −2 docs/advanced/cast/custom.rst
+3 −3 docs/advanced/cast/stl.rst
+2 −2 docs/advanced/classes.rst
+2 −2 docs/advanced/pycpp/numpy.rst
+1 −1 docs/advanced/smart_ptrs.rst
+160 −12 docs/changelog.rst
+1 −1 docs/classes.rst
+6 −17 docs/conf.py
+ docs/pybind11-logo.png
+4 −3 docs/requirements.txt
+5 −3 include/pybind11/attr.h
+5 −5 include/pybind11/cast.h
+23 −30 include/pybind11/detail/class.h
+21 −2 include/pybind11/detail/common.h
+1 −1 include/pybind11/detail/init.h
+1 −0 include/pybind11/detail/internals.h
+0 −66 include/pybind11/detail/type_caster_base.h
+9 −3 include/pybind11/detail/typeid.h
+17 −6 include/pybind11/eigen.h
+56 −32 include/pybind11/embed.h
+2 −2 include/pybind11/functional.h
+1 −1 include/pybind11/iostream.h
+19 −8 include/pybind11/numpy.h
+44 −26 include/pybind11/pybind11.h
+338 −64 include/pybind11/pytypes.h
+6 −6 include/pybind11/stl.h
+16 −6 noxfile.py
+2 −1 pybind11/__init__.py
+8 −1 pybind11/__main__.py
+1 −1 pybind11/_version.py
+12 −0 pybind11/commands.py
+2 −1 setup.cfg
+1 −0 setup.py
+1 −0 tests/CMakeLists.txt
+14 −1 tests/conftest.py
+51 −0 tests/cross_module_interleaved_error_already_set.cpp
+68 −58 tests/extra_python_package/test_files.py
+25 −0 tests/pybind11_tests.cpp
+1 −1 tests/requirements.txt
+8 −2 tests/test_builtin_casters.cpp
+2 −2 tests/test_constants_and_functions.cpp
+7 −7 tests/test_custom_type_casters.cpp
+5 −2 tests/test_eigen.cpp
+7 −0 tests/test_eigen.py
+1 −1 tests/test_embed/CMakeLists.txt
+47 −2 tests/test_exceptions.cpp
+99 −3 tests/test_exceptions.py
+10 −1 tests/test_kwargs_and_defaults.cpp
+21 −9 tests/test_methods_and_attributes.py
+2 −0 tests/test_modules.cpp
+30 −0 tests/test_modules.py
+1 −1 tests/test_numpy_array.cpp
+1 −1 tests/test_numpy_dtypes.cpp
+1 −1 tests/test_numpy_vectorize.cpp
+183 −0 tests/test_pytypes.cpp
+129 −0 tests/test_pytypes.py
+2 −2 tests/test_smart_ptr.cpp
+15 −8 tests/test_stl.cpp
+2 −2 tests/test_tagbased_polymorphic.cpp
+2 −3 tests/test_virtual_functions.cpp
+21 −11 tools/FindPythonLibsNew.cmake
+23 −0 tools/JoinPaths.cmake
+7 −0 tools/pybind11.pc.in
+3 −1 tools/pybind11NewTools.cmake
+32 −11 tools/pybind11Tools.cmake
+2 −0 tools/setup_global.py.in
+2 −0 tools/setup_main.py.in

0 comments on commit dc42951

Please sign in to comment.