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


C++ Complex::Im方法代码示例

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


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

示例1: Complex

const Complex operator+(Complex const& _cl, Complex const& _cr)
{
	double re = _cl.Re() + _cr.Re();
	double im = _cl.Im() + _cr.Im();

	return Complex(re, im);
}
开发者ID:scoido,项目名称:HUHFractal,代码行数:7,代码来源:Complex.cpp

示例2: test_SamplePHCurve

void test_SamplePHCurve() {
    cout << "TEST	: test_SamplePHCurve()" << endl;

    // Create a PHCurve interpolator from the PH curve coefficients
    // for an arc connecting the three points {(-1,1),(0,2),(1,1)}
    PH5Curve<PH5TYPE> ph(ph_arc());

    PH5TYPE vMax = 100; // maximum velocity (mm/s)
    PH5TYPE tvMax = 0.01; // time to achieve maximum velocity (seconds)
    PH5TYPE vIn = 0; // initial velocity (mm/s)
    PH5TYPE vCruise = vMax; // cruising velocity (mm/s)
    PH5TYPE vOut = 0; // final velocity (mm/s)

    // Create a quintic feedrate for traversing the above curve smoothly
    PHFeed<PH5TYPE> phf(ph, vMax, tvMax, vIn, vOut, vCruise);

    int16_t N = 100; // number of points to interpolate
    PH5TYPE E = 0; // interpolation normalized parametric state [0,1]

    // Generate a set of points using PH feed rate along PH curve
    cout << "X,Y" << endl;
    for (PH5TYPE tPoint = 0; tPoint <= N; tPoint++) {
        E = phf.Ekt(E, tPoint / N);
        Complex<PH5TYPE> point = ph.r(E);
        cout << point.Re() << "," << point.Im() << endl;
    }

    cout << "TEST	:   test_SamplePHCurve() OK " << endl;
}
开发者ID:firepick1,项目名称:ph5,代码行数:29,代码来源:test.cpp

示例3: FnBac

void Threads::FnBac(const Complex & cpx, int *res) const
{
	int iter =0;
	Complex tmpp;
	Complex tmp;
	Complex tmpn(cpx);
	for (iter = 0; tmpn.Abs2() < 4  &&  iter < maxIter ;iter++){
		tmp = tmpn;
		tmpn = tmp * tmp + tmpp.Re() + tmpp.Im() + julia_c;
		tmpp = tmp;
	}
	*res = iter;
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:13,代码来源:Threads.cpp

示例4:

Complex Complex::operator*(Complex& theComplex)
{
	this->real = (this->real)*(theComplex.Re())-(this->imaginary)*(theComplex.Im());
	this->imaginary = (this->real)*(theComplex.Im()) + (theComplex.Re())*(this->imaginary);
	return *this;
}
开发者ID:mirgee,项目名称:exercises,代码行数:6,代码来源:complex.cpp

示例5: test_Complex

void test_Complex() {
    cout << "TEST	: test_Complex()" << endl;

    Complex<PH5TYPE> c1(1, 2);
    ASSERTEQUAL(c1.Re(), 1);
    ASSERTEQUAL(c1.Im(), 2);

    Complex<PH5TYPE> c5(3, 4);
    ASSERTEQUAL(5, c5.modulus());

    Complex<PH5TYPE> c15 = c1 + c5;
    ASSERT(c15 == Complex<PH5TYPE>(4, 6));
    ASSERT(c1 + 1 == Complex<PH5TYPE>(2, 2));

    Complex<PH5TYPE> c13(1, 3);
    Complex<PH5TYPE> c24(2, 4);
    Complex<PH5TYPE> c1324 = c13 - c24;
    ASSERT((c13 - c24) == Complex<PH5TYPE>(-1, -1));
    ASSERT((c24 - c13) == Complex<PH5TYPE>(1, 1));
    ASSERT((c13 - 1) == Complex<PH5TYPE>(0, 3));

    ASSERT((c13 * c24) == Complex<PH5TYPE>(1 * 2 - 3 * 4, 1 * 4 + 3 * 2));
    ASSERT((c24 * c13) == Complex<PH5TYPE>(1 * 2 - 3 * 4, 1 * 4 + 3 * 2));
    ASSERT((c13 * 2) == Complex<PH5TYPE>(2, 6));

    ASSERT(c13.conj() == Complex<PH5TYPE>(1, -3));

    Complex<PH5TYPE> cr = c13.recip();
    PH5TYPE epsilon = 0.000001;
    ASSERTEQUALT(cr.Re(), 0.1, epsilon);
    ASSERTEQUALT(cr.Im(), -0.3, epsilon);
    Complex<PH5TYPE> crr = cr.recip();
    ASSERTEQUALT(crr.Re(), 1, epsilon);
    ASSERTEQUALT(crr.Im(), 3, epsilon);

    Complex<PH5TYPE> c13div24 = c13 / c24;
    ASSERTEQUALT(c13div24.Re(), 0.7, epsilon);
    ASSERTEQUALT(c13div24.Im(), 0.1, epsilon);

    Complex<PH5TYPE> sum1;
    sum1.add(c13);
    ASSERT(sum1 == Complex<PH5TYPE>(1, 3));
    sum1.add(c24);
    ASSERT(sum1 == Complex<PH5TYPE>(3, 7));

    ASSERT(Complex<PH5TYPE>(25).sqrt() == Complex<PH5TYPE>(5));
    ASSERT(Complex<PH5TYPE>(-1).sqrt() == Complex<PH5TYPE>(0, 1));
    ASSERT(Complex<PH5TYPE>(3, 4).sqrt() == Complex<PH5TYPE>(2, 1));

    ASSERTEQUALS("0", Complex<PH5TYPE>().stringify().c_str());
    ASSERTEQUALS("1", Complex<PH5TYPE>(1).stringify().c_str());
    ASSERTEQUALS("i", Complex<PH5TYPE>(0, 1).stringify().c_str());
    ASSERTEQUALS("-i", Complex<PH5TYPE>(0, -1).stringify().c_str());
    ASSERTEQUALS("2i", Complex<PH5TYPE>(0, 2).stringify().c_str());
    ASSERTEQUALS("-2i", Complex<PH5TYPE>(0, -2).stringify().c_str());
    ASSERTEQUALS("1+i", Complex<PH5TYPE>(1, 1).stringify().c_str());
    ASSERTEQUALS("1-i", Complex<PH5TYPE>(1, -1).stringify().c_str());
    ASSERTEQUALS("1+2i", Complex<PH5TYPE>(1, 2).stringify().c_str());
    ASSERTEQUALS("1-2i", Complex<PH5TYPE>(1, -2).stringify().c_str());
    ASSERTEQUALS("1.2-5.7i", Complex<PH5TYPE>(1.2345, -5.6789).stringify(1).c_str());
    ASSERTEQUALS("1.0+1.0i", Complex<PH5TYPE>(0.99, 0.99).stringify(1).c_str());
    ASSERTEQUALS("1.0-1.0i", Complex<PH5TYPE>(0.99, -0.99).stringify(1).c_str());
    ASSERTEQUALS("0.99-0.99i", Complex<PH5TYPE>(0.99, -0.99).stringify(2).c_str());

    c13.assertEqualT(Complex<PH5TYPE>(1.0009, 2.9991), 0.001);
    cout << "TEST	:   test_Complex() OK" << endl;
}
开发者ID:firepick1,项目名称:ph5,代码行数:67,代码来源:test.cpp


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