• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ complex类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

complex<typename boost::units::subtract_typeof_helper<X,Y>::type>
operator-(const complex<X>& x,const complex<Y>& y)
{
    typedef typename boost::units::subtract_typeof_helper<X,Y>::type    type;
    
    return complex<type>(x.real()-y.real(),x.imag()-y.imag());
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:7,代码来源:complex.cpp


示例2: conj

void EMLTracker::integrate(complex<double> in)
{
    localReplica.tick();

    // First bring the signal level of the input to the same as the
    // local replicas
    in *= baseGain;

    complex<double> carrier = localReplica.getCarrier();
    complex<double> code = localReplica.getCode() ? plusOne : minusOne;

    // mix in the carrier local replica
    complex<double> m0 = in * conj(carrier);

    // and sum them up.. (yea, the conj of the codes should be a NoOp)
    code = conj(code);
    early.process(m0, code);
    prompt.process(m0, code);
    late.process(m0, code);

    // Update our sums for normalizing things...
    complex<double> lr = conj(carrier) * code;
    inSumSq += in.real()*in.real() + in.imag()*in.imag();
    lrSumSq += lr.real()*lr.real() + lr.imag()*lr.imag();
}
开发者ID:renyu310,项目名称:ossim-svn,代码行数:25,代码来源:EMLTracker.cpp


示例3:

complex complex::operator *(complex x)
{
    complex y;
    y.Re=Re*x.take_Re()-Im*x.take_Im();
    y.Im=Re*x.take_Im()+Im*x.take_Re();
    return y;
}
开发者ID:intuitionofmind,项目名称:graphene,代码行数:7,代码来源:function_class.cpp


示例4: exponentialIntegral

/** Implement Exponential Integral function, E1(z), based on formulaes in
 *Abramowitz and Stegun (A&S)
 *  In fact this implementation returns exp(z)*E1(z) where z is a complex number
 *
 *  @param z :: input
 *  @return exp(z)*E1(z)
 */
complex<double> exponentialIntegral(const complex<double> &z) {
  double z_abs = abs(z);

  if (z_abs == 0.0) {
    // Basically function is infinite in along the real axis for this case
    return complex<double>(std::numeric_limits<double>::max(), 0.0);
  } else if (z_abs < 10.0) // 10.0 is a guess based on formula 5.1.55 (no idea
                           // how good it really is)
  {
    // use formula 5.1.11 in A&S. rewrite last term in 5.1.11 as
    // x*sum_n=0 (-1)^n x^n / (n+1)*(n+1)! and then calculate the
    // terms in the sum recursively
    complex<double> z1(1.0, 0.0);
    complex<double> z2(1.0, 0.0);
    for (int i = 1; i <= 100; i++) // is max of 100 here best?
    {
      z2 = -static_cast<double>(i) * (z2 * z) / ((i + 1.0) * (i + 1.0));
      z1 += z2;
      if (abs(z2) < 1.0E-10 * abs(z1))
        break; // i.e. if break loop if little change to term added
    }
    return exp(z) * (-log(z) - M_EULER + z * z1);
  } else {
    // use formula 5.1.22 in A&S. See discussion page 231
    complex<double> z1(0.0, 0.0);
    for (int i = 20; i >= 1; i--) // not sure if 20 is always sensible?
      z1 = static_cast<double>(i) / (1.0 + static_cast<double>(i) / (z + z1));
    complex<double> retVal = 1.0 / (z + z1);
    if (z.real() <= 0.0 && z.imag() == 0.0)
      retVal -= exp(z) * complex<double>(0.0, 1.0) * M_PI; // see formula 5.1.7
    return retVal;
  }
}
开发者ID:DanNixon,项目名称:mantid,代码行数:40,代码来源:SpecialFunctionHelper.cpp


示例5: cos

complex<double> cos(complex<double> x) { 
  double cosh(double x);
  double cos(double x);
  double r = cosh(x.imag())*cos(x.real());
  double i = sinh(x.imag())*sin(x.real());
  return(complex<double>(r,i));
}
开发者ID:mbillingr,项目名称:tools4bci-unibuild,代码行数:7,代码来源:spuc_math.cpp


示例6: MPI_Barrier

complex<Float> Comms::GlobalSum(complex<Float> z)
{

  if (!initialized) { Initialize(); }

#ifdef USE_MPI
  Float sendbuf[2];
  Float recvbuf[2];

  sendbuf[0] = z.real();
  sendbuf[1] = z.imag();

  MPI_Barrier(MPI_COMM_WORLD);

#ifdef USE_SINGLE
  MPI_Reduce( sendbuf, recvbuf, 2, MPI_FLOAT, MPI_SUM, 0, MPI_COMM_WORLD );
#endif
#ifdef USE_DOUBLE
  MPI_Reduce( sendbuf, recvbuf, 2, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD );
#endif
#ifdef USE_LONG_DOUBLE
  MPI_Reduce( sendbuf, recvbuf, 2, MPI_LONG_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD );
#endif

  return complex<Float>(recvbuf[0], recvbuf[1]);
#else
  return z;
#endif

}
开发者ID:mgendres,项目名称:nrCPS,代码行数:30,代码来源:sysfunc.C


示例7: write_mandel

void write_mandel(std::string name, int x, int y)
{
  GIF_image gif(x, y);

  for(int i=0; i<256;i++)
  {
	  gif.setColor(i, i, i, (char)255);
  }

  for (int i = 0; i < y; i++) 
  { 
    for (int j = 0; j < x; j++) 
    {
      complex<double> c(c1.real()+j*(c2-c1).real()/X, c1.imag()+i*(c2-c1).imag()/Y);
      complex<double> z = 0;
      int iter = 0;
      
      while (abs(z) < 2 && iter < MAX_ITER) 
      {
		z = z*z+c;
		iter++;
      }
      gif.setPixel(j, i, ((MAX_ITER-iter)*255)/40);
    }
  }
  
  gif.writeToFile(name.c_str());
}
开发者ID:deneb42,项目名称:lemme,代码行数:28,代码来源:mandelbrot.cpp


示例8:

complex operator- (const complex& c1, const complex& c2)
{
    double res_re = c1.get_re() - c2.get_re();
    double res_im = c1.get_im() - c2.get_im();
    complex res{res_re, res_im};

    return res;
}
开发者ID:DoubleDi,项目名称:cmc-msu-tasks,代码行数:8,代码来源:03.cpp


示例9: pow

complex<Y> 
pow(const complex<Y>& x,const Y& y)
{
    std::complex<Y> tmp(x.real(),x.imag());
    
    tmp = std::pow(tmp,y);
    
    return complex<Y>(tmp.real(),tmp.imag());
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:9,代码来源:complex.cpp


示例10: value

 static type value(const complex<quantity<Unit,Y> >& x)  
 { 
     const complex<value_type>   tmp =
         root<static_rational<N,D> >(complex<Y>(x.real().value(),
                                                x.imag().value()));
     
     return type(quantity_type::from_value(tmp.real()),
                quantity_type::from_value(tmp.imag()));
 }
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:9,代码来源:complex.cpp


示例11: complexAdd

complex<double> complexAdd(complex<double> x1, complex<double> x2)
{
    int x1_real = int(x1.real());
    int x2_real = int(x2.real());
    int x1_imag = int(x1.imag());
    int x2_imag = int(x2.imag());
    int r1 = int(bitset<16>(x1_real+x2_real).to_ulong());
    int r2 = int(bitset<16>(x1_imag+x2_imag).to_ulong());
    return complex<double>(double(r1), double(r2));
}
开发者ID:congminhthanh,项目名称:HAsim-RV32I,代码行数:10,代码来源:matrixGen.cpp


示例12: switch

QTextStream& operator<<(QTextStream& ts, KCValue value)
{
    ts << value.type();
    switch (value.type()) {
    case KCValue::Empty:   break;

    case KCValue::Boolean:
        ts << ": ";
        if (value.asBoolean()) ts << "TRUE";
        else ts << "FALSE"; break;

    case KCValue::Integer:
        ts << ": " << value.asInteger(); break;

    case KCValue::Float:
        ts << ": " << (double) numToDouble(value.asFloat()); break;

    case KCValue::Complex: {
        const complex<KCNumber> complex(value.asComplex());
        ts << ": " << (double) numToDouble(complex.real());
        if (complex.imag() >= 0.0)
            ts << '+';
        ts << (double) numToDouble(complex.imag()) << 'i';
        break;
    }

    case KCValue::String:
        ts << ": " << value.asString(); break;

    case KCValue::Array: {
        ts << ": {" << value.asString();
        const int cols = value.columns();
        const int rows = value.rows();
        for (int row = 0; row < rows; ++row) {
            for (int col = 0; col < cols; ++col) {
                ts << value.element(col, row);
                if (col < cols - 1)
                    ts << ';';
            }
            if (row < rows - 1)
                ts << '|';
        }
        ts << '}';
        break;
    }

    case KCValue::Error:
        ts << '(' << value.errorMessage() << ')'; break;

    default: break;
    }
    return ts;
}
开发者ID:KDE,项目名称:koffice,代码行数:53,代码来源:KCValue.cpp


示例13: fmtvalue

std::string fmtvalue(std::true_type, const complex<T>& x)
{
    std::string restr = as_string(fmt<'g', number_width, number_precision>(x.real()));
    if (restr.size() > number_width)
        restr = as_string(fmt<'g', number_width, number_precision_short>(x.real()));

    std::string imstr = as_string(fmt<'g', -1, number_precision>(std::abs(x.imag())));
    if (imstr.size() > number_width)
        imstr = as_string(fmt<'g', -1, number_precision_short>(std::abs(x.imag())));

    return restr + (x.imag() < T(0) ? "-" : "+") + padleft(number_width, imstr + "j");
}
开发者ID:straurichard,项目名称:kfr,代码行数:12,代码来源:tostring.hpp


示例14: complexdeflation

/* Complex root forward deflation.
 */
static int complexdeflation( const register int n, double a[], const complex<double> z )
   {
   register int i;
   double r, u;

   r = -2.0 * z.real();
   u = z.real() * z.real() + z.imag() * z.imag();
   a[ 1 ] -= r * a[ 0 ];
   for( i = 2; i < n - 1; i++ )
      a[ i ] = a[ i ] - r * a[ i - 1 ] - u * a[ i - 2 ];

   return n - 2;
}
开发者ID:gbrault,项目名称:firtool,代码行数:15,代码来源:newton_real.cpp


示例15: sum_to_all

complex<long double> sum_to_all(complex<long double> in) {
  complex<long double> out = in;
#ifdef HAVE_MPI
  if (MPI_LONG_DOUBLE == MPI_DATATYPE_NULL) {
    complex<double> dout;
    dout = sum_to_all(complex<double>(double(in.real()), double(in.imag())));
    out = complex<long double>(dout.real(), dout.imag());
  }
  else
    MPI_Allreduce(&in,&out,2,MPI_LONG_DOUBLE,MPI_SUM,mycomm);
#endif
  return out;
}
开发者ID:Arthur-Thijssen,项目名称:MEEP-actt,代码行数:13,代码来源:mympi.cpp


示例16: sendToTransmissionSolver

void transmissioncom::sendToTransmissionSolver(complex value)
{
  uint8_t data[sizeof(double)*2];
  double realPart=value.Re();
  double imagineryPart=value.Im();
  memcpy(&data,&realPart,sizeof(double));
  memcpy(&data[sizeof(double)],&imagineryPart,sizeof(double));
  
  OBJECT *hdr = OBJECTHDR(this);
  Message *msg=new Message(hdr->name,this->connectedBus,gl_globalclock,(uint8_t*)data,sizeof(double)*2);
  msg->setDelayThroughComm(false);
  myinterface->send(msg);
}
开发者ID:GridOPTICS,项目名称:FNCS-gridlab-d,代码行数:13,代码来源:transmission_interface.cpp


示例17: complexMultiply

complex<double> complexMultiply(complex<double> x1, complex<double> x2)
{
    int x1_real = int(x1.real());
    int x2_real = int(x2.real());
    int x1_imag = int(x1.imag());
    int x2_imag = int(x2.imag());
    int r1 = int(bitset<16>(x1_real*x2_real).to_ulong());
    int r2 = int(bitset<16>(x1_imag*x2_imag).to_ulong());
    int r3 = int(bitset<16>(x1_real*x2_imag).to_ulong());
    int r4 = int(bitset<16>(x1_imag*x2_real).to_ulong());
    int m_real = int(bitset<16>(r1-r2).to_ulong());
    int m_imag = int(bitset<16>(r3+r4).to_ulong());
    return complex<double>(double(m_real), double(m_imag));
}
开发者ID:congminhthanh,项目名称:HAsim-RV32I,代码行数:14,代码来源:matrixGen.cpp


示例18: setZeroPolePairs

void Biquad::setZeroPolePairs(const complex<double> &zero, const complex<double> &pole)
{
    double b0 = 1;
    double b1 = -2 * zero.real();

    double zeroMag = abs(zero);
    double b2 = zeroMag * zeroMag;

    double a1 = -2 * pole.real();

    double poleMag = abs(pole);
    double a2 = poleMag * poleMag;
    setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
}
开发者ID:meshula,项目名称:LabSound,代码行数:14,代码来源:Biquad.cpp


示例19: put

  void put(index_type i, complex<T> val)
  {
    assert(this->format_ != no_user_format);

    if (this->format_ == array_format)
      this->u_.data_[i] = val;
    else if (this->format_ == interleaved_format)
    {
      this->u_.split_.real_[2*i+0] = val.real();
      this->u_.split_.real_[2*i+1] = val.imag();
    }
    else // if (format_ == split_format)
    {
      this->u_.split_.real_[i] = val.real();
      this->u_.split_.imag_[i] = val.imag();
    }
  }
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:17,代码来源:user_storage.hpp


示例20: determine_frequency

double microturbine::determine_frequency(complex power_out){
	//double Kx = 3 * Rinternal / 3.14159;
	//used linear approximation which does better job than textbook equation...
	//assumes power in W
	double f = power_out.Mag() * 1.5 + 55000;\
	f = f/60;
	return f;
}
开发者ID:AMFIRNAS,项目名称:wso2-gridlabd,代码行数:8,代码来源:microturbine.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ concurrent_queue类代码示例发布时间:2022-05-31
下一篇:
C++ communicator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap