當前位置: 首頁>>代碼示例>>C++>>正文


C++ std::cosh方法代碼示例

本文整理匯總了C++中std::cosh方法的典型用法代碼示例。如果您正苦於以下問題:C++ std::cosh方法的具體用法?C++ std::cosh怎麽用?C++ std::cosh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在std的用法示例。


在下文中一共展示了std::cosh方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: name

    simd_chyperbolic_tester<T, N, A>::simd_chyperbolic_tester(const std::string& n)
        : name(n)
    {
        using std::sinh;
        using std::cosh;
        using std::tanh;
        using std::asinh;
        using std::acosh;
        using std::atanh;
        size_t nb_input = N * 10000;
        input.resize(nb_input);
        sinh_res.resize(nb_input);
        cosh_res.resize(nb_input);
        tanh_res.resize(nb_input);
        asinh_res.resize(nb_input);
        acosh_input.resize(nb_input);
        acosh_res.resize(nb_input);
        atanh_input.resize(nb_input);
        atanh_res.resize(nb_input);

        for (size_t i = 0; i < nb_input; ++i)
        {
            input[i] = value_type(real_value_type(-1.5) + i * real_value_type(3) / nb_input,
                                  real_value_type(-1.3) + i * real_value_type(2.5) / nb_input);
            sinh_res[i] = sinh(input[i]);
            cosh_res[i] = cosh(input[i]);
            tanh_res[i] = tanh(input[i]);
            asinh_res[i] = asinh(input[i]);
            acosh_input[i] = value_type(real_value_type(1.) + i * real_value_type(3) / nb_input,
                                        real_value_type(1.2) + i * real_value_type(2.7) / nb_input);
            acosh_res[i] = acosh(acosh_input[i]);
            atanh_input[i] = value_type(real_value_type(-0.95) + i * real_value_type(1.9) / nb_input,
                                        real_value_type(-0.94) + i * real_value_type(1.8) / nb_input);
            atanh_res[i] = atanh(atanh_input[i]);
        }
    }
開發者ID:jmabille,項目名稱:nxsimd,代碼行數:36,代碼來源:xsimd_chyperbolic_test.hpp

示例2: TEST

TEST(AgradFwdCosh,Fvar) {
  using stan::math::fvar;
  using std::sinh;
  using std::cosh;

  fvar<double> x(0.5,1.0);

  fvar<double> a = cosh(x);
  EXPECT_FLOAT_EQ(cosh(0.5), a.val_);
  EXPECT_FLOAT_EQ(sinh(0.5), a.d_);

  fvar<double> y(-1.2,1.0);

  fvar<double> b = cosh(y);
  EXPECT_FLOAT_EQ(cosh(-1.2), b.val_);
  EXPECT_FLOAT_EQ(sinh(-1.2), b.d_);

  fvar<double> c = cosh(-x);
  EXPECT_FLOAT_EQ(cosh(-0.5), c.val_);
  EXPECT_FLOAT_EQ(-sinh(-0.5), c.d_);
}
開發者ID:alyst,項目名稱:math,代碼行數:21,代碼來源:cosh_test.cpp

示例3: TEST

TEST(AgradFvar, cosh) {
  using stan::agrad::fvar;
  using std::sinh;
  using std::cosh;

  fvar<double> x(0.5);
  x.d_ = 1.0;

  fvar<double> a = cosh(x);
  EXPECT_FLOAT_EQ(cosh(0.5), a.val_);
  EXPECT_FLOAT_EQ(sinh(0.5), a.d_);

  fvar<double> y(-1.2);
  y.d_ = 1.0;

  fvar<double> b = cosh(y);
  EXPECT_FLOAT_EQ(cosh(-1.2), b.val_);
  EXPECT_FLOAT_EQ(sinh(-1.2), b.d_);

  fvar<double> c = cosh(-x);
  EXPECT_FLOAT_EQ(cosh(-0.5), c.val_);
  EXPECT_FLOAT_EQ(-sinh(-0.5), c.d_);
}
開發者ID:danstowell,項目名稱:stan,代碼行數:23,代碼來源:cosh_test.cpp

示例4: test_simd_chyperbolic

    bool test_simd_chyperbolic(std::ostream& out, T& tester)
    {
        using tester_type = T;
        using vector_type = typename tester_type::vector_type;
        using value_type = typename tester_type::value_type;
        using res_type = typename tester_type::res_type;

        vector_type input;
        vector_type vres;
        res_type res(tester.input.size());

        bool success = true;
        bool tmp_success = true;

        std::string val_type = value_type_name<vector_type>();
        std::string shift = std::string(val_type.size(), '-');
        std::string name = tester.name;
        std::string name_shift = std::string(name.size(), '-');
        std::string dash(8, '-');
        std::string space(8, ' ');

        out << dash << name_shift << '-' << shift << dash << std::endl;
        out << space << name << " " << val_type << std::endl;
        out << dash << name_shift << '-' << shift << dash << std::endl
            << std::endl;

        std::string topic = "sinh  : ";
        for (size_t i = 0; i < tester.input.size(); i += tester.size)
        {
            tester.load_vec(input, tester.input, i);
            vres = sinh(input);
            tester.store_vec(vres, res, i);
        }
        tmp_success = check_almost_equal(topic, res, tester.sinh_res, out);
        success = success && tmp_success;
        success &= check_almost_equal(topic, xsimd::sinh(tester.input[0]), tester.sinh_res[0], out);

        topic = "cosh  : ";
        for (size_t i = 0; i < tester.input.size(); i += tester.size)
        {
            tester.load_vec(input, tester.input, i);
            vres = cosh(input);
            tester.store_vec(vres, res, i);
        }
        tmp_success = check_almost_equal(topic, res, tester.cosh_res, out);
        success = success && tmp_success;
        success &= check_almost_equal(topic, xsimd::cosh(tester.input[0]), tester.cosh_res[0], out);

        topic = "tanh  : ";
        for (size_t i = 0; i < tester.input.size(); i += tester.size)
        {
            tester.load_vec(input, tester.input, i);
            vres = tanh(input);
            tester.store_vec(vres, res, i);
        }
        tmp_success = check_almost_equal(topic, res, tester.tanh_res, out);
        success = success && tmp_success;
        success &= check_almost_equal(topic, xsimd::tanh(tester.input[0]), tester.tanh_res[0], out);

        topic = "asinh : ";
        for (size_t i = 0; i < tester.input.size(); i += tester.size)
        {
            tester.load_vec(input, tester.input, i);
            vres = asinh(input);
            tester.store_vec(vres, res, i);
        }
        tmp_success = check_almost_equal(topic, res, tester.asinh_res, out);
        success = success && tmp_success;
        success &= check_almost_equal(topic, xsimd::asinh(tester.input[0]), tester.asinh_res[0], out);

        topic = "acosh : ";
        for (size_t i = 0; i < tester.acosh_input.size(); i += tester.size)
        {
            tester.load_vec(input, tester.acosh_input, i);
            vres = acosh(input);
            tester.store_vec(vres, res, i);
        }
        tmp_success = check_almost_equal(topic, res, tester.acosh_res, out);
        success = success && tmp_success;
        success &= check_almost_equal(topic, xsimd::acosh(tester.acosh_input[0]), tester.acosh_res[0], out);

        topic = "atanh : ";
        for (size_t i = 0; i < tester.atanh_input.size(); i += tester.size)
        {
            tester.load_vec(input, tester.atanh_input, i);
            vres = atanh(input);
            tester.store_vec(vres, res, i);
        }
        tmp_success = check_almost_equal(topic, res, tester.atanh_res, out);
        success = success && tmp_success;
        success &= check_almost_equal(topic, xsimd::atanh(tester.atanh_input[0]), tester.atanh_res[0], out);

        return success;
    }
開發者ID:jmabille,項目名稱:nxsimd,代碼行數:94,代碼來源:xsimd_chyperbolic_test.hpp

示例5: cosh

 inline T0
 operator()(const T0& arg1) const {
   return cosh(arg1);
 }
開發者ID:alyst,項目名稱:math,代碼行數:4,代碼來源:cosh_test.cpp

示例6: Dsinh

 static inline real Dsinh(real x, real y) {
   using std::sinh; using std::cosh;
   real d = (x - y) / 2;
   return cosh((x + y) / 2) * (d ? sinh(d) / d : 1);
 }
開發者ID:DavidFCrouse,項目名稱:Tracker-Component-Library,代碼行數:5,代碼來源:Rhumb.hpp


注:本文中的std::cosh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。