⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmath.cct

📁 TGFF省城程序
💻 CCT
字号:
// Copyright 2000 by Robert Dick.// All rights reserved./*###########################################################################*/template <typename T, typename P>T ring_mod(T a, P period) {	RASSERT(period > 0);	if (a >= 0) {		return a % period;	} else {		return ((a + 1) % period) + period - 1;	}}/*===========================================================================*/template <typename P>unsigned ring_mod(unsigned a, P period) {	RASSERT(period > 0);	return a % period;}/*===========================================================================*/template <typename P>unsigned long ring_mod(unsigned long a, P period) {	RASSERT(period > 0);	return a % period;}/*===========================================================================*/template <typename P>double ring_mod(double a, P period) {	RASSERT(period > 0);	return (a >= 0) ? fmod(a, period) : fmod(a + 1, period) + period - 1;}/*===========================================================================*/template <typename P>float ring_mod(float a, P period) {	RASSERT(period > 0);	return (a >= 0) ? fmod(a, period) : fmod(a + 1, period) + period - 1;}/*###########################################################################*/template <typename T, typename P>T interval_round(T a, P period) {	RASSERT(period > 0);	return a >= 0 ? ((2 * a + period) / (2 * period)) * period :	  ((2 * a + 1 - period) / (2 * period)) * period;}/*===========================================================================*/template <typename P>double interval_round(double a, P period) {	RASSERT(period > 0);	double ret = rint(a / period) * period;	if (ret == -0.0) {		ret = 0.0;	}	return ret;}/*===========================================================================*/template <typename P>float interval_round(float a, P period) {	RASSERT(period > 0);	double ret = rint(a / period) * period;	if (ret == -0.0) {		ret = 0.0;	}	return ret;}/*===========================================================================*/template<typename D>D clip(const D & x, D low, D high) {	return min(max(x, low), high);}/*===========================================================================*/template <typename T>bool isfinite(const T & a) {	return a < std::numeric_limits<T>::infinity() &&		a > -std::numeric_limits<T>::infinity();}/*###########################################################################*/inline const MathVecMathVec::operator+(const MathVec & a) const {	return MathVec(*this) += a;}inline const MathVecMathVec::operator+(const MathVec::value_type & a) const {	return MathVec(*this) += a;}inline const MathVecMathVec::operator-(const MathVec & a) const {	return MathVec(*this) -= a;}inline const MathVecMathVec::operator-(const MathVec::value_type & a) const {	return MathVec(*this) -= a;}inline const MathVecMathVec::operator/(const MathVec & a) const {	return MathVec(*this) /= a;}inline const MathVecMathVec::operator/(const MathVec::value_type & a) const {	return MathVec(*this) /= a;}inline const MathVecflat_mul(const MathVec & a, const MathVec & b) {	return MathVec(a).flat_mul(b);}inline const MathVecflat_mul(const MathVec & a,const MathVec::value_type & b) {	return MathVec(a).flat_mul(b);}template <typename T>T rnlimits<T>::smallest() {	return super::is_integer ? super::min() : -super::max();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -