当前位置: 首页>>代码示例>>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;未经允许,请勿转载。