blob: e3c068056ddbb699cdd49dfa29f6aa53a89d762a [file]
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2026 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Author: hellston20a@gmail.com (H S Helson Go)
#ifndef CERES_PUBLIC_CONSTANTS_H_
#define CERES_PUBLIC_CONSTANTS_H_
// TODO(HSHelson): This header should no longer be necessary once C++20's
// <numbers> (e.g. std::numbers::pi_v) becomes usable
// The constants are computed using mpmath by the following shell command:
//
// python3 - <<EOF
// from mpmath import mp
// mp.dps = 64
// print(mp.pi)
// print(mp.sqrt(3))
// EOF
namespace ceres::constants {
// π
template <typename T>
inline constexpr T pi_v(
3.141592653589793238462643383279502884197169399375105820974944592L);
inline constexpr double pi = pi_v<double>;
// √3
template <typename T>
inline constexpr T sqrt_3_v(
1.732050807568877293527446341505872366942805253810380628055806979L);
inline constexpr double sqrt_3 = sqrt_3_v<double>;
} // namespace ceres::constants
#endif // CERES_PUBLIC_CONSTANTS_H_