# Timing Clebsch-Gordan-coefficients calls in Julia (beating c++ again)

**URL:** <https://discourse.julialang.org/t/timing-clebsch-gordan-coefficients-calls-in-julia-beating-c-again/32736>\
**Category:** Numerics\
**Created:** [December 27, 2019, 7:54am UTC](https://discourse.julialang.org/t/timing-clebsch-gordan-coefficients-calls-in-julia-beating-c-again/32736 "2019-12-27T07:54:27Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![misha\_mikhasenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/misha_mikhasenko/32/5060_2.png) [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Post date:** [December 27, 2019, 7:47pm UTC](https://discourse.julialang.org/t/timing-clebsch-gordan-coefficients-calls-in-julia-beating-c-again/32736/3 "2019-12-27T19:47:07Z")

</div>

Hi Steven, these are great suggestions!  
The amount of zeros is ≈ 17%, and 14% are equal to 1.0. I tried to exclude obviosly-trivial Clebsches in the `rand_clebsch()` function (+fixed a typo).

Just checked the other suggestions:

- type stability + `logfact2` gives 1-2 μs gain
- `@inbounds` removes extra 2-4 μs for the same tests.

Not so much, but still cool. Thanks a lot for pointing out!

Did you notice if I am doing something wrong with `SymPy` calls? My colleagues running tensorflow used to calculate both the Clebsch-Gordan coefficientss and the Wigner d using the `sympy.physics.wigner`. It is hard to believe that the call time which they are working with is x1000. I have not benchmarked it thoroughly, tho.

---

_[View the full topic](https://discourse.julialang.org/t/timing-clebsch-gordan-coefficients-calls-in-julia-beating-c-again/32736)._
