cmComplexTypes.h : Added complex arithmetic vector operations.

This commit is contained in:
kevin 2015-07-03 18:22:08 -04:00
parent b1ff1dfb07
commit f481f7f62a
2 changed files with 48 additions and 0 deletions

42
cmComplexTypes.c Normal file
View File

@ -0,0 +1,42 @@
void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplex_t* x0, const cmComplexR_t* x1, unsigned n )
{
unsigned i;
for(i=0; i<n; ++i)
{
cmReal_t ab = x0[i].r * x1[i].r;
cmReal_t bd = x0[i].i * x1[i].i;
cmReal_t bc = x0[i].i * x1[i].r;
cmReal_t ad = x0[i].r * x1[i].i;
y[i].r = ab - bd;
y[i].i = bc + ad;
}
}
void cmVOCR_Abs( cmReal_t* y, const cmComplexR_t* x, unsigned n )
{
for(i=0; i<n; ++i)
y[i] = cmAbsR(x[i]);
}
void cmVOCR_MultR_VV( cmComplexR_t* y, const cmReal_t* x, unsigned n )
{
unsigned i;
for(i=0; i<n; ++i)
{
y[i].r *= x[i];
y[i].i *= x[i];
}
}
void cmVOCR_DivR_VV( cmComplexR_t* y, const cmReal_t* x, unsigned n )
{
unsigned i;
for(i=0; i<n; ++i)
{
y[i].r /= x[i];
y[i].i /= x[i];
}
}

View File

@ -84,4 +84,10 @@
#endif #endif
void cmVOCR_MultVVV( cmComplexR_t* y, const cmComplexR_t* x0, const cmComplexR_t* x1, unsigned n );
void cmVOCR_Abs( cmReal_t* y, const cmComplexR_t* x, unsigned n );
void cmVOCR_MultVS( cmComplexR_t* y, cmReal_t v, unsigned n );
void cmVOCR_DivVS( cmComplexR_t* y, cmReal_t v, unsigned n );
#endif #endif