本文整理汇总了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);
}
示例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";
}
示例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;
}
示例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());
}
示例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();
}
示例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();
}
}
示例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;
}
示例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)
;
}
示例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 );
}
}
示例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)));
}
示例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;
}
示例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);
}
示例13: abs2
T abs2(std::complex<T> val)
{
T re = val.real();
T im = val.imag();
return (re*re)+(im*im);
}
示例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;
}
示例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;
}