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


C++ ComplexNumber类代码示例

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


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

示例1: reset

void reset(double r1, double i1,ComplexNumber&a, ComplexNumber&c)
{
	a.setReal(r1);
	a.setImag(i1);
	c.setReal(0);
	c.setImag(0);
};
开发者ID:efebozkir,项目名称:Automated-Plant-Recognition,代码行数:7,代码来源:ComplexNumber.cpp

示例2: getReal

 ComplexNumber ComplexNumber::operator +(const ComplexNumber& other)
 {
     ComplexNumber c;
     c.real = getReal() + other.getReal();
     c.imag = getImag() + other.getImag();
     return c;
 }
开发者ID:onursezer,项目名称:CSE241-Object-Oriented-Programming,代码行数:7,代码来源:ComplexNumber.cpp

示例3: ComplexNumber

ComplexNumber ComplexNumber::operator*(const ComplexNumber& z) const
{
	return ComplexNumber(mRealPart * z.GetRealPart()
						 - mImaginaryPart * z.GetImaginaryPart(),
						 mImaginaryPart * z.GetRealPart()
						 + mRealPart * z.GetImaginaryPart());
}
开发者ID:islijepcevic,项目名称:ProgrammingConcepts_noEclipse,代码行数:7,代码来源:ComplexNumber.cpp

示例4: if

 bool ComplexNumber::operator <(ComplexNumber& other)
 {
     if(getReal() < other.getReal())
         return true;
     else if(getReal() == other.getReal())
         return (getImag() < other.getImag());
 }
开发者ID:onursezer,项目名称:CSE241-Object-Oriented-Programming,代码行数:7,代码来源:ComplexNumber.cpp

示例5: TEST

TEST(Zhiltsov_Max_ComplexNumberTest, LimitingValueAddition_Correct) {
    const ComplexNumber z(std::numeric_limits<double>::max(), 0);

    ComplexNumber sum = z + z;

    EXPECT_TRUE(std::isinf(sum.getRe()));
}
开发者ID:1995konstantin,项目名称:devtools-course-practice-1,代码行数:7,代码来源:test_zhiltsov_max_complex_number.cpp

示例6: exp

ComplexNumber Exponential::eval(const ComplexNumber z) const {
    ComplexNumber exponent = lambda * z;

    double exp_re = exp(exponent.real()) * cos(exponent.imag());
    double exp_im = exp(exponent.real()) * sin(exponent.imag());

    ComplexNumber w (exp_re, exp_im);
    return coefficient * w;
}
开发者ID:p-patil,项目名称:Domain-Coloring,代码行数:9,代码来源:functions.cpp

示例7: pow

// Override.
// (r * exp(i * theta))^(a + bi) = r^(a + bi) * exp(i * theta * a - theta * b)
//    = (r^a * exp(-theta * b)) * (r^b * exp(theta * a))^i
ComplexNumber Power::eval(const ComplexNumber z) const {
    double r = z.mag(), theta = z.angle();
    double a = exponent.real(), b = exponent.imag();

    double coeff = pow(r, a) * exp(-theta * b);
    ComplexNumber w = iPower(pow(r, b) * exp(theta * a));

    ComplexNumber v (coeff * w.real(), coeff * w.imag());
    return v;
}
开发者ID:p-patil,项目名称:Domain-Coloring,代码行数:13,代码来源:functions.cpp

示例8: ln_z

// Override.
// ln(z) = ln(|r|) + i * theta, where z = r * e^(i * theta)
// log_z(w) = ln(w) * log_z(e) = ln(w) * 1 / (ln(r) + i * theta), where z = r * e^(i * theta).
ComplexNumber Logarithm::eval(const ComplexNumber z) const {
    ComplexNumber argument = z + lambda;
    ComplexNumber ln_z (log(argument.mag()), argument.angle());

    if (base == exp(1)) {
        return coefficient * ln_z;
    } else {
        ComplexNumber one (1, 0);
        ComplexNumber log_base (log(base.mag()), base.angle());
        return coefficient * ln_z * (one / log_base);
    }
}
开发者ID:p-patil,项目名称:Domain-Coloring,代码行数:15,代码来源:functions.cpp

示例9:

ComplexNumber operator*( ComplexNumber& first,  ComplexNumber& second) {
    ComplexNumber c;
    
    double newRe=(first.Re()*second.Re())-(first.Im()*second.Im());
    double newIm=(first.Re()*second.Im())+(first.Im()*second.Re());
    
    c.setRe(newRe);
    c.setIm(newIm);
    
    return c;
}
开发者ID:YuyaOguchi,项目名称:Cpp_Complex_Numbers,代码行数:11,代码来源:ComplexNumber.cpp

示例10: main

int main(){
    long real1,imaginary1,real2,imaginary2;

    scanf("%ld%ld",&real1,&imaginary1);
    ComplexNumber a={real1,imaginary1};

    scanf("%ld%ld",&real2,&imaginary2);
    ComplexNumber b={real2,imaginary2};

    ComplexNumber c;
    c.saberi(a,b);
    c.oduzmi(a,b);
    c.pomnozi(a,b);
    c.podeli(a,b);

    return 0;
}
开发者ID:sbakic,项目名称:Algorithms,代码行数:17,代码来源:main.cpp

示例11: autoReplot

//
// re-calculate frequency response
//
void Plot::setDamp( double damping )
{
    const bool doReplot = autoReplot();
    setAutoReplot( false );

    const int ArraySize = 200;

    double frequency[ArraySize];
    double amplitude[ArraySize];
    double phase[ArraySize];

    // build frequency vector with logarithmic division
    logSpace( frequency, ArraySize, 0.01, 100 );

    int i3 = 1;
    double fmax = 1;
    double amax = -1000.0;

    for ( int i = 0; i < ArraySize; i++ )
    {
        double f = frequency[i];
        const ComplexNumber g =
            ComplexNumber( 1.0 ) / ComplexNumber( 1.0 - f * f, 2.0 * damping * f );

        amplitude[i] = 20.0 * log10( qSqrt( g.real() * g.real() + g.imag() * g.imag() ) );
        phase[i] = qAtan2( g.imag(), g.real() ) * ( 180.0 / M_PI );

        if ( ( i3 <= 1 ) && ( amplitude[i] < -3.0 ) )
            i3 = i;
        if ( amplitude[i] > amax )
        {
            amax = amplitude[i];
            fmax = frequency[i];
        }

    }

    double f3 = frequency[i3] - ( frequency[i3] - frequency[i3 - 1] )
        / ( amplitude[i3] - amplitude[i3 -1] ) * ( amplitude[i3] + 3 );

    showPeak( fmax, amax );
    show3dB( f3 );
    showData( frequency, amplitude, phase, ArraySize );

    setAutoReplot( doReplot );

    replot();
}
开发者ID:iclosure,项目名称:jdataanalyse,代码行数:51,代码来源:plot.cpp

示例12: setAll

 ComplexNumber::ComplexNumber(const ComplexNumber& orig) {
   setAll(orig.getReal(), orig.m_imag);
 }
开发者ID:hmenn,项目名称:GTU-2015-CSE241-OOP-HW,代码行数:3,代码来源:ComplexNumber.cpp

示例13: add

ComplexNumber ComplexNumber::add(const ComplexNumber& c1,const ComplexNumber& c2){
    //std::cout << __PRETTY_FUNCTION__ << std::endl;
    ComplexNumber sum = c1;
    sum.add(c2);
    return sum;
}
开发者ID:DevCodeOne,项目名称:WS_1617,代码行数:6,代码来源:complexnumber.cpp

示例14:

bool operator==(const ComplexNumber& c1, const ComplexNumber& c2){
    if ((c1.Real()==c2.Real())&(c1.Imag()==c2.Imag())) return true;
    return false;
}
开发者ID:DevCodeOne,项目名称:WS_1617,代码行数:4,代码来源:complexnumber.cpp

示例15:

// Checking if not Equal
bool operator!=(const ComplexNumber & lhs, const ComplexNumber & rhs) {
    if(lhs.equals(rhs)) return false;
    return true;
}
开发者ID:karayala,项目名称:-CPP--CS368-P4,代码行数:5,代码来源:ComplexNumber.cpp


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