Precompute scalar derivatives in Jet elementary functions Compute cbrt(f) using a single cbrt(f.a) call with f.v / (3 * r * r), avoiding both the second cbrt evaluation and f.a * f.a overflow or underflow at extreme magnitudes. Precompute the scalar derivative factor in erf(x) and erfc(x) using a compile-time constant for 2 / sqrt(pi) before multiplying x.v so Eigen evaluates a single scalar-vector product instead of scaling x.v twice. Parenthesize (T(1.0) / log(T(10.0))) / f.a in log10 and (T(1.0) / log(T(2.0))) / f.a in log2 so the reciprocal constant folds at compile time, and use T(0.5) / tmp in sqrt. Standardize on floating-point T(...) constants and left-multiplication by scalar derivatives across elementary functions in jet.h. Benchmark (Apple M1 Pro): ---------------------------------------------------------------------- Benchmark Before After Change ---------------------------------------------------------------------- Cbrt<3>/1000 11.7 us 7.29 us -37.7% Cbrt<10>/1000 15.9 us 11.5 us -27.6% Cbrt<32>/1000 29.9 us 25.7 us -14.0% Erf<3>/1000 23.8 us 21.1 us -11.3% Erf<32>/1000 39.9 us 32.8 us -17.8% Erfc<3>/1000 23.1 us 20.2 us -12.6% Erfc<32>/1000 39.8 us 32.7 us -17.8% Sqrt<15>/1000 4.50 us 4.38 us -2.7% Sqrt<32>/1000 12.5 us 12.4 us -0.8% ---------------------------------------------------------------------- Change-Id: I2a4ceebad76cbb0eddc42be6368872a9e5543b70
Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It is a feature rich, mature and performant library which has been used in production at Google since 2010. Ceres Solver can solve two kinds of problems.
Please see ceres-solver.org for more information.