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


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

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


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

示例1: round

BOOST_UBLAS_INLINE
::std::complex<T> round(::std::complex<T> x)
{
	T r = (x.real() > 0.0) ? ::std::floor(x.real() + 0.5) : ::std::ceil(x.real() - 0.5);
	T i = (x.imag() > 0.0) ? ::std::floor(x.imag() + 0.5) : ::std::ceil(x.imag() - 0.5);

	return ::std::complex<T>(r,i);
}
开发者ID:sguazt,项目名称:boost-ublasx,代码行数:8,代码来源:round.hpp

示例2: fi

TEST_F(FourierIntegralTest, Test)
{
	FourierIntegral fi(2, 0, 1, 100);
	const std::complex<double> actual = fi.integrate(function);
	const std::complex<double> expected = (std::exp(std::complex<double>(0, 1)) - std::complex<double>(1,0)) / std::complex<double>(0,1);
	ASSERT_NEAR(expected.real(), actual.real(), 1E-8) << "real";
	ASSERT_NEAR(expected.imag(), actual.imag(), 1E-7) << "imag";
}
开发者ID:rilwen,项目名称:open-quantum-systems,代码行数:8,代码来源:FourierIntegralTest.cpp

示例3: AbsGeq

inline bool AbsGeq(
	const std::complex<double> &x,
	const std::complex<double> &y)
{	double xsq = x.real() * x.real() + x.imag() * x.imag();
	double ysq = y.real() * y.real() + y.imag() * y.imag();

	return xsq >= ysq;
}
开发者ID:barak,项目名称:CppAD-1,代码行数:8,代码来源:lu_factor.hpp

示例4: toStr

/***********************************************************************
 * Number format overloads
 **********************************************************************/
static QString toStr(const std::complex<qreal> num, const int)
{
    if (num.real() == 0.0 and num.imag() == 0.0) return "0";
    if (num.real() == 0.0) return QString::number(num.imag())+"j";
    if (num.imag() == 0.0) return QString::number(num.real());
    if (num.imag() < 0.0) return QString("%1%2j").arg(num.real()).arg(num.imag());
    return QString("%1+%2j").arg(num.real()).arg(num.imag());
}
开发者ID:m0x72,项目名称:pothos,代码行数:11,代码来源:LogicAnalyzerDisplay.cpp

示例5: assert

bool operator<=(const std::complex<ValueType> &lhs, const std::complex<ValueType> &rhs) {

  if (&lhs == &rhs)
    return true;

  assert(lhs.imag() == rhs.imag() && lhs.imag() == ValueType(0.0));

  return lhs.real() <= rhs.real();

}
开发者ID:georgeliao,项目名称:paralution_VBCSR,代码行数:10,代码来源:math_functions.cpp

示例6: getValue

double TwoDimensionalPlotPage::getValue(const std::complex<long double> val)
{
	switch(Phase)
	{
		case AmplitudePhaseType: return sqrt(val.real()*val.real() + val.imag()*val.imag());
		case PhasePhaseType: return atan2(val.imag(), val.real());
		case RealPhaseType: return val.real();
		case ImaginaryPhaseType: return val.imag();
	}
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:10,代码来源:twodimensionalplotpage.cpp

示例7: operator

	symbol_t operator()(const std::complex<int16_t> in) {
		const uint32_t real2 = in.real() * in.real();
		const uint32_t imag2 = in.imag() * in.imag();
		const uint32_t mag2 = real2 + imag2;

		const uint32_t mag2_attenuated = mag2 >> 3;	// Approximation of (-4.5dB)^2
		mag2_threshold = (uint64_t(mag2_threshold) * uint64_t(mag2_threshold_leak_factor)) >> 32;
		mag2_threshold = std::max(mag2_threshold, mag2_attenuated);
		const bool symbol = (mag2 > mag2_threshold);
		return symbol;
	}
开发者ID:ablanquart,项目名称:portapack-havoc,代码行数:11,代码来源:ook.hpp

示例8:

/***********************************************************************
 * Convert xx to items32 sc8 buffer
 **********************************************************************/
template <typename T> UHD_INLINE item32_t xx_to_item32_sc8_x1(
    const std::complex<T> &in0, const std::complex<T> &in1, const double scale_factor
){
    boost::uint8_t real0 = boost::int8_t(in0.real()*float(scale_factor));
    boost::uint8_t imag0 = boost::int8_t(in0.imag()*float(scale_factor));
    boost::uint8_t real1 = boost::int8_t(in1.real()*float(scale_factor));
    boost::uint8_t imag1 = boost::int8_t(in1.imag()*float(scale_factor));
    return
        (item32_t(real0) << 8) | (item32_t(imag0) << 0) |
        (item32_t(real1) << 24) | (item32_t(imag1) << 16)
    ;
}
开发者ID:iftahgil,项目名称:UHD-Mirror,代码行数:15,代码来源:convert_common.hpp

示例9: apply_unwrap

arma_hot
inline
typename T1::elem_type
op_cdot::apply_proxy(const T1& X, const T2& Y)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type            eT;
  typedef typename get_pod_type<eT>::result  T;
  
  typedef typename Proxy<T1>::ea_type ea_type1;
  typedef typename Proxy<T2>::ea_type ea_type2;
  
  const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) || (Proxy<T2>::prefer_at_accessor);
  
  if(prefer_at_accessor == false)
    {
    const Proxy<T1> PA(X);
    const Proxy<T2> PB(Y);
    
    const uword N = PA.get_n_elem();
    
    arma_debug_check( (N != PB.get_n_elem()), "cdot(): objects must have the same number of elements" );
    
    ea_type1 A = PA.get_ea();
    ea_type2 B = PB.get_ea();
    
    T val_real = T(0);
    T val_imag = T(0);
    
    for(uword i=0; i<N; ++i)
      {
      const std::complex<T> AA = A[i];
      const std::complex<T> BB = B[i];
      
      const T a = AA.real();
      const T b = AA.imag();
      
      const T c = BB.real();
      const T d = BB.imag();
      
      val_real += (a*c) + (b*d);
      val_imag += (a*d) - (b*c);
      }
    
    return std::complex<T>(val_real, val_imag);
    }
  else
    {
    return op_cdot::apply_unwrap( X, Y );
    }
  }
开发者ID:k8wells,项目名称:452p1,代码行数:52,代码来源:op_dot_meat.hpp

示例10: atan

std::complex<T> atan(const std::complex<T>& x)
{
   //
   // We're using the C99 definition here; atan(z) = -i atanh(iz):
   //
   if(x.real() == 0)
   {
      if(x.imag() == 1)
         return std::complex<T>(0, std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : static_cast<T>(HUGE_VAL));
      if(x.imag() == -1)
         return std::complex<T>(0, std::numeric_limits<T>::has_infinity ? -std::numeric_limits<T>::infinity() : -static_cast<T>(HUGE_VAL));
   }
   return ::boost::math::detail::mult_minus_i(::boost::math::atanh(::boost::math::detail::mult_i(x)));
}
开发者ID:3DJ,项目名称:ofxOgre,代码行数:14,代码来源:atan.hpp

示例11: pt

// Reconstruction d'un contour à partir de ses descripteurs de Fourier
std::vector<std::vector<cv::Point>> reconstruction ( std::vector<std::complex<double>> coeff, int N, int c_max, std::complex<double> z_moy, double scale) {
  int c_min = -c_max;
  std::vector<std::complex<double>> TC (N, 0);

  int debut = coeff.size() + c_min - 1;

  for (unsigned int i = debut; i < coeff.size(); ++i) {
    TC[i - debut] = (double) N * coeff[i];
  }

  for (int i = 0; i < c_max; ++i) {
    TC[N + c_min + i] = (double) N * coeff[i];
  }

  std::vector<std::complex<double>> z_fil;
  cv::dft(TC, z_fil, cv::DFT_INVERSE + cv::DFT_SCALE);

  z_fil.push_back(z_fil[0]);
  std::vector<cv::Point> z_fill;

  for (auto& i : z_fil) {
    cv::Point pt(scale * i.real() + z_moy.real(), scale * i.imag() + z_moy.imag());
    z_fill.push_back(pt);
  }

  std::vector<std::vector<cv::Point>> contour;
  contour.push_back(z_fill);

  return contour;
}
开发者ID:AlilouGh,项目名称:gesture_recognition,代码行数:31,代码来源:descripteur_fourier.cpp

示例12: safeConvert

 // No special checks for safe Convert
 static std::complex<float>  safeConvert( const std::complex<double> t )
   {
     float ret_r = Teuchos::as<float>( t.real() );
     float ret_i = Teuchos::as<float>( t.imag() );
     std::complex<float> ret (ret_r,  ret_i);
     return (ret);
   }
开发者ID:Tech-XCorp,项目名称:Trilinos,代码行数:8,代码来源:Amesos2_Basker_TypeMap.hpp

示例13: abs2

T abs2(std::complex<T> val)
{
	T re = val.real();
	T im = val.imag();

	return (re*re)+(im*im);
}
开发者ID:Axios-Engineering,项目名称:basic-components,代码行数:7,代码来源:exp_agc.cpp

示例14: get

 static void get(index_type i, vector_type* output, std::complex<float>& value)
 {
   vsip_cscalar_f cval;
   cval = vsip_cvget_f(output, i);
   value.real() = cval.r;
   value.imag() = cval.i;
 }
开发者ID:bambang,项目名称:vsipl,代码行数:7,代码来源:dot.cpp

示例15: add_complex_at

size_t EMData::add_complex_at(int x,int y,int z,const int &subx0,const int &suby0,const int &subz0,const int &fullnx,const int &fullny,const int &fullnz,const std::complex<float> &val) {
if (abs(x)>=fullnx/2 || abs(y)>fullny/2 || abs(z)>fullnz/2) return nxyz;
//if (x==0 && (y!=0 || z!=0)) add_complex_at(0,-y,-z,subx0,suby0,subz0,fullnx,fullny,fullnz,conj(val));
// complex conjugate insertion. Removed due to ambiguity with returned index
/*if (x==0&& (y!=0 || z!=0)) {
	int yy=y<=0?-y:fullny-y;
	int zz=z<=0?-z:fullnz-z;

	if (yy<suby0||zz<subz0||yy>=suby0+ny||zz>=subz0+nz) return nx*ny*nz;

	size_t idx=(yy-suby0)*nx+(zz-subz0)*nx*ny;
	rdata[idx]+=(float)val.real();
	rdata[idx+1]+=(float)-val.imag();
}*/
float cc=1.0;
if (x<0) {
	x*=-1;
	y*=-1;
	z*=-1;
	cc=-1.0;
}
if (y<0) y=fullny+y;
if (z<0) z=fullnz+z;

if (x<subx0||y<suby0||z<subz0||x>=subx0+nx||y>=suby0+ny||z>=subz0+nz) return nxyz;

size_t idx=(x-subx0)*2+(y-suby0)*(size_t)nx+(z-subz0)*(size_t)nx*ny;
rdata[idx]+=(float)val.real();
rdata[idx+1]+=cc*(float)val.imag();
return idx;
}
开发者ID:cpsemmens,项目名称:eman2,代码行数:31,代码来源:emdata_core.cpp


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