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


C++ Complex::b方法代码示例

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


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

示例1: compute

Complex<T> HyperbolicCosine::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
  if (c.b() == 0) {
    return Complex<T>::Float(std::cosh(c.a()));
  }
  Complex<T> e = Complex<T>::Float(M_E);
  Complex<T> exp1 = Power::compute(e, c);
  Complex<T> exp2 = Power::compute(e, Complex<T>::Cartesian(-c.a(), -c.b()));
  Complex<T> sum = Addition::compute(exp1, exp2);
  return Division::compute(sum, Complex<T>::Float(2));
}
开发者ID:Tilka,项目名称:epsilon,代码行数:10,代码来源:hyperbolic_cosine.cpp

示例2:

Complex<T> Division::compute(const Complex<T> c, const Complex<T> d) {
  /* We want to avoid multiplies in the middle of the calculation that could
   * overflow.
   * aa, ab, ba, bb, min, max = |d.a| <= |d.b| ? (c.a, c.b, -c.a, c.b, d.a, d.b)
   *    : (c.b, c.a, c.b, -c.a, d.b, d.a)
   * c    c.a+c.b*i   d.a-d.b*i   1/max    (c.a+c.b*i) * (d.a-d.b*i) / max
   * - == --------- * --------- * ----- == -------------------------------
   * d    d.a+d.b*i   d.a-d.b*i   1/max    (d.a+d.b*i) * (d.a-d.b*i) / max
   *      (c.a*d.a - c.a*d.b*i + c.b*i*d.a - c.b*i*d.b*i) / max
   *   == -----------------------------------------------------
   *      (d.a*d.a - d.a*d.b*i + d.b*i*d.a - d.b*i*d.b*i) / max
   *      (c.a*d.a - c.b*d.b*i^2 + c.b*d.b*i - c.a*d.a*i) / max
   *   == -----------------------------------------------------
   *                  (d.a*d.a - d.b*d.b*i^2) / max
   *      (c.a*d.a/max + c.b*d.b/max) + (c.b*d.b/max - c.a*d.a/max)*i
   *   == -----------------------------------------------------------
   *                         d.a^2/max + d.b^2/max
   *      aa*min/max + ab*max/max   bb*min/max + ba*max/max
   *   == ----------------------- + -----------------------*i
   *       min^2/max + max^2/max     min^2/max + max^2/max
   *       min/max*aa + ab     min/max*bb + ba
   *   == ----------------- + -----------------*i
   *      min/max*min + max   min/max*min + max
   * |min| <= |max| => |min/max| <= 1
   *                => |min/max*x| <= |x|
   *                => |min/max*x+y| <= |x|+|y|
   * So the calculation is guaranteed to not overflow until the last divides as
   * long as none of the input values have the representation's maximum exponent.
   * Plus, the method does not propagate any error on real inputs: temp = 0,
   * norm = d.a and then result = c.a/d.a. */
  T aa = c.a(), ab = c.b(), ba = -aa, bb = ab;
  T min = d.a(), max = d.b();
  if (std::fabs(max) < std::fabs(min)) {
    T temp = min;
    min = max;
    max = temp;
    temp = aa;
    aa = ab;
    ab = temp;
    temp = ba;
    ba = bb;
    bb = temp;
  }
  T temp = min/max;
  T norm = temp*min + max;
  return Complex<T>::Cartesian((temp*aa + ab) / norm, (temp*bb + ba) / norm);
}
开发者ID:toholio,项目名称:epsilon,代码行数:47,代码来源:division.cpp

示例3: assert

Complex<T> ArcSine::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
  assert(angleUnit != AngleUnit::Default);
  if (c.b() != 0) {
    return Complex<T>::Float(NAN);
  }
  T result = std::asin(c.a());
  if (angleUnit == AngleUnit::Degree) {
    return Complex<T>::Float(result*180/M_PI);
  }
  return Complex<T>::Float(result);
}
开发者ID:Tilka,项目名称:epsilon,代码行数:11,代码来源:arc_sine.cpp

示例4:

Complex<T> HyperbolicArcSine::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
  if (c.b() != 0) {
    return Complex<T>::Float(NAN);
  }
  return Complex<T>::Float(std::asinh(c.a()));
}
开发者ID:Tilka,项目名称:epsilon,代码行数:6,代码来源:hyperbolic_arc_sine.cpp

示例5:

Complex<T> NaperianLogarithm::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
  if (c.b() != 0) {
    return Complex<T>::Float(NAN);
  }
  return Complex<T>::Float(std::log(c.a()));
}
开发者ID:Tilka,项目名称:epsilon,代码行数:6,代码来源:naperian_logarithm.cpp


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