當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。