#pragma once #include "math.hpp" #include namespace matrix { template Type wrap_pi(Type x) { if (!isfinite(Type(x))) { return x; } while (x >= (Type)M_PI) { x -= (Type)(2.0 * M_PI); } while (x < (Type)(-M_PI)) { x += (Type)(2.0 * M_PI); } return x; } };