当前位置: 首页>>代码示例>>C++>>正文


C++ std::fmod方法代码示例

本文整理汇总了C++中std::fmod方法的典型用法代码示例。如果您正苦于以下问题:C++ std::fmod方法的具体用法?C++ std::fmod怎么用?C++ std::fmod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std的用法示例。


在下文中一共展示了std::fmod方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paintPage

void DotTemplate::paintPage(QPainter *painter, const QRectF &rect)
{
    const double step = mm(5);
    const double size = mm(m_dotSize);
    const double shiftX = (fmod(rect.width(), step) + step - size) / 2;
    const double shiftY = (fmod(rect.height(), step) + step - size) / 2;

    pagePen.setWidthF(mm(pagePenWidth()));
    painter->setPen(pagePen);
    painter->drawRect(rect);

    QRect point(0, 0, size, size);
    painter->setPen(Qt::NoPen);
    painter->setBrush(Qt::lightGray);

    const double fillWidth = rect.x() + rect.width() - shiftX;
    const double fillHeight = rect.y() + rect.height() - shiftY;
    for (double y = rect.y() + shiftY; y < fillHeight; y += step)
    {
        for (double x = rect.x() + shiftX; x < fillWidth; x += step)
        {
            point.moveTo(x, y);
            painter->drawEllipse(point);
        }
    }
}
开发者ID:akazantsev,项目名称:notegen,代码行数:26,代码来源:dottemplate.cpp

示例2: transitdirect

 // an alternate version of transit to deal with longitudes in the direct
 // problem.
 static inline int transitdirect(real lon1, real lon2) {
   using std::fmod;
   // We want to compute exactly
   //   int(floor(lon2 / 360)) - int(floor(lon1 / 360))
   // Since we only need the parity of the result we can use std::remquo but
   // this is buggy with g++ 4.8.3 and requires C++11.  So instead we do
   lon1 = fmod(lon1, real(720)); lon2 = fmod(lon2, real(720));
   return ( ((lon2 >= 0 && lon2 < 360) || lon2 < -360 ? 0 : 1) -
            ((lon1 >= 0 && lon1 < 360) || lon1 < -360 ? 0 : 1) );
 }
开发者ID:JanEicken,项目名称:MA,代码行数:12,代码来源:PolygonArea.hpp

示例3: fmod

 inline
 fvar<T>
 fmod(const fvar<T>& x1, double x2) {
   using std::fmod;
   if (unlikely(is_nan(value_of(x1.val_))
                || is_nan(x2)))
     return fvar<T>(fmod(x1.val_, x2), NOT_A_NUMBER);
   else
     return fvar<T>(fmod(x1.val_, x2), x1.d_ / x2);
 }
开发者ID:stan-dev,项目名称:math,代码行数:10,代码来源:fmod.hpp

示例4: fmod

 inline
 fvar<T>
 fmod(const fvar<T>& x1, const double x2) {
   using std::fmod;
   using stan::math::value_of;
   if (unlikely(boost::math::isnan(value_of(x1.val_))
                || boost::math::isnan(x2)))
     return fvar<T>(fmod(x1.val_,x2),stan::math::NOT_A_NUMBER);
   else
     return fvar<T>(fmod(x1.val_, x2), x1.d_ / x2);
 }
开发者ID:javaosos,项目名称:stan,代码行数:11,代码来源:fmod.hpp

示例5: if

  void Rotation<T>::normalize()
  {
    using std::fmod;

    if (radians_ > pi)
    {
      radians_ = fmod(radians_ + pi, double_pi) - pi;
    }

    else if (radians_ < -pi)
    {
      radians_ = fmod(radians_ - pi, double_pi) + pi;
    }
  }
开发者ID:mnewhouse,项目名称:tselements,代码行数:14,代码来源:rotation.hpp

示例6: fmod

 inline
 fvar<typename stan::return_type<T1,T2>::type>
 fmod(const fvar<T1>& x1, const T2& x2) {
   using std::fmod;
   return fvar<typename stan::return_type<T1,T2>::type>(
     fmod(x1.val_, x2), x1.d_ / x2);
 }
开发者ID:danstowell,项目名称:stan,代码行数:7,代码来源:fmod.hpp

示例7: repeat

T repeat(T val, T min, T max)
{
	using std::fmod;
	T temp = fmod(val - min, max - min);
	if (temp < T{0}) temp += max - min;
	return temp + min;
}
开发者ID:JesseTG,项目名称:gml,代码行数:7,代码来源:util.hpp

示例8: fmod

string td3Math::mod(vector<vector<string> > operands)
{
    bool op1 = td3Utility::isFloat(operands.at(0).at(0));
    bool op2 = td3Utility::isFloat(operands.at(1).at(0));
    return td3Utility::toString(
               fmod( td3Utility::stof(operands.at(0).at(0)),
                     td3Utility::stof(operands.at(1).at(0))), op1 || op2);
}
开发者ID:xx3nvyxx,项目名称:td3,代码行数:8,代码来源:td3Math.cpp

示例9: transitdirect

    // an alternate version of transit to deal with longitudes in the direct
    // problem.
    static inline int transitdirect(real lon1, real lon2) {
      // We want to compute exactly
      //   int(floor(lon2 / 360)) - int(floor(lon1 / 360))
      // Since we only need the parity of the result we can use std::remquo;
      // but this is buggy with g++ 4.8.3 (glibc version < 2.22), see
      //   https://sourceware.org/bugzilla/show_bug.cgi?id=17569
      // and requires C++11.  So instead we do
#if GEOGRAPHICLIB_CXX11_MATH && GEOGRAPHICLIB_PRECISION != 4
      using std::remainder;
      lon1 = remainder(lon1, real(720)); lon2 = remainder(lon2, real(720));
      return ( (lon2 >= 0 && lon2 < 360 ? 0 : 1) -
               (lon1 >= 0 && lon1 < 360 ? 0 : 1) );
#else
      using std::fmod;
      lon1 = fmod(lon1, real(720)); lon2 = fmod(lon2, real(720));
      return ( ((lon2 >= 0 && lon2 < 360) || lon2 < -360 ? 0 : 1) -
               ((lon1 >= 0 && lon1 < 360) || lon1 < -360 ? 0 : 1) );
#endif
    }
开发者ID:NREL,项目名称:OpenStudio,代码行数:21,代码来源:PolygonArea.hpp

示例10: fmod

inline
quantity<Unit, Y>
fmod(const quantity<Unit,Y>& q1, const quantity<Unit,Y>& q2)
{
    using std::fmod;
    
    typedef quantity<Unit,Y> quantity_type;

    return quantity_type::from_value(fmod(q1.value(), q2.value()));
}
开发者ID:TheForum,项目名称:Earth-and-Beyond-server,代码行数:10,代码来源:cmath_boost_1_35.hpp

示例11: TEST

TEST(AgradFvar, fmod) {
  using stan::agrad::fvar;
  using std::fmod;
  using std::floor;

  fvar<double> x(2.0);
  fvar<double> y(3.0);
  x.d_ = 1.0;
  y.d_ = 2.0;

  fvar<double> a = fmod(x, y);
  EXPECT_FLOAT_EQ(fmod(2.0, 3.0), a.val_);
  EXPECT_FLOAT_EQ(1.0 * 1.0 + 2.0 * -floor(2.0 / 3.0), a.d_);

  double z = 4.0;
  double w = 3.0;

  fvar<double> e = fmod(x, z);
  EXPECT_FLOAT_EQ(fmod(2.0, 4.0), e.val_);
  EXPECT_FLOAT_EQ(1.0 / 4.0, e.d_);

  fvar<double> f = fmod(w, x);
  EXPECT_FLOAT_EQ(fmod(3.0, 2.0), f.val_);
  EXPECT_FLOAT_EQ(1.0 * -floor(3.0 / 2.0), f.d_);
 }
开发者ID:danstowell,项目名称:stan,代码行数:25,代码来源:fmod_test.cpp


注:本文中的std::fmod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。