vectorbase::GetAmplitude

Description

Get the amplitude (modulus) of the complex vector.

Syntax

int GetAmplitude( vector & vAmplitude )

Parameters

vAmplitude
[output] vector containing amplitude(modulus) of this Complex vector

Return

Returns 0 on success and -1 on failure.

Examples

EX1

void vectorbase_GetAmplitude_ex1()
{
    vector<complex> vecC = {1+2i, 3+4i, 5+6i, 7+8i};
    vector vecAmp;
    vecC.GetAmplitude(vecAmp);
    for (int ii = 0; ii < vecAmp.GetSize(); ii++)
        printf("%0.2f ",vecAmp[ii]);
    // Result:
    //        vecAmp = {2.24, 5.00, 7.81, 10.63};
}

Remark

Get the amplitude (modulus) of the complex vector. Causes a runtime error if the underlying base type of the vector is not complex.

See Also

vectorbase::GetReal, vectorbase::GetImaginary, vectorbase::GetPhase, vectorbase::Conjugate, vectorbase::MakeComplex

header to Include

origin.h