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


C++ complex::real方法代码示例

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


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

示例1:

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

示例2:

	/* https://github.com/AE9RB/fftbench/blob/master/cxlr.hpp
	 * Nice trick from AE9RB (David Turnbull) to get compiler to produce simpler
	 * fma (fused multiply-accumulate) instead of worrying about NaN handling
	 */
	inline complex<float>
	operator*(const complex<float>& v1, const complex<float>& v2) {
		return complex<float> {
			v1.real() * v2.real() - v1.imag() * v2.imag(),
			v1.real() * v2.imag() + v1.imag() * v2.real()
		};
	}
开发者ID:Patrizzio64,项目名称:portapack-havoc,代码行数:11,代码来源:dsp_fft.hpp

示例3: cmp1

int cmp1(complex<double> a,complex<double> b)
{
	if(a.real()==b.real())
		return a.imag()<=b.imag();
	else
		return a.real()<b.real();
}
开发者ID:ranban282,项目名称:algorithms,代码行数:7,代码来源:10245.cpp

示例4: integrate

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

示例5: cmp

bool cmp(const complex <int>  &a, const complex <int>  &b)
{
	if(a.imag()==b.imag())
		return a.real()<b.real();
	else
		return a.imag()<b.imag();
}
开发者ID:ranban282,项目名称:algorithms,代码行数:7,代码来源:bak_11072.cpp

示例6: 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

示例7: operator

 bool operator()(const complex<double>& lhs, const complex<double>& rhs) {
   if (norm(lhs) != norm(rhs)) {
     return norm(lhs) < norm(rhs);
   } else if (lhs.real() != rhs.real()) {
     return lhs.real() < rhs.real();
   } else {
     return lhs.imag() < rhs.imag();
   }
 }
开发者ID:zhihongzeng2002,项目名称:cppcoding,代码行数:9,代码来源:Gaussian_primes.cpp

示例8: 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

示例9: 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

示例10: recursiveColor

double recursiveColor(complex<double> complexNum, complex<double> constant, int iterations)
{
	if(iterations == maxIterations)
		return double(iterations);
	if(sqrt(complexNum.real() * complexNum.real() + complexNum.imag() * complexNum.imag()) > 2)
		return double(iterations);
	else
	{
		complexNum = complex<double>(complexNum.real() * complexNum.real() - (complexNum.imag() * complexNum.imag()) + constant.real(), 2 * complexNum.real() * complexNum.imag() + constant.imag());
		return recursiveColor(complexNum, constant, ++iterations);
	}
}
开发者ID:wallstop,项目名称:FractalGen,代码行数:12,代码来源:FractalRenderer.cpp

示例11: 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

示例12: 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

示例13: 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

示例14: num_to_string

	string num_to_string(const complex<T>& num, int pad=0){
		string ret;
		// both components non-zero
		if(num.real()!=0 && num.imag()!=0){
			// don't add "+" in the middle if imag is negative and will start with "-"
			string ret=num_to_string(num.real(),/*pad*/0)+(num.imag()>0?"+":"")+num_to_string(num.imag(),/*pad*/0)+"j";
			if(pad==0 || (int)ret.size()>=pad) return ret;
			return string(pad-ret.size(),' ')+ret; // left-pad with spaces
		}
		// only imaginary is non-zero: skip the real part, and decrease padding to accomoadate the trailing "j"
		if(num.imag()!=0){
			return num_to_string(num.imag(),/*pad*/pad>0?pad-1:0)+"j";
		}
		// non-complex (zero or not)
		return num_to_string(num.real(),pad);
	}
开发者ID:asford,项目名称:minieigen,代码行数:16,代码来源:common.hpp

示例15:

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


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