mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
update to snapshot spandsp-20080919.tar.gz
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9770 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* SpanDSP - a series of DSP components for telephony
|
||||
*
|
||||
* vector_float.c - Floating vector arithmetic routines.
|
||||
* complex_vector_float.c - Floating complex vector arithmetic routines.
|
||||
*
|
||||
* Written by Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: complex_vector_float.c,v 1.8 2008/07/02 14:48:25 steveu Exp $
|
||||
* $Id: complex_vector_float.c,v 1.10 2008/09/18 13:16:49 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -50,4 +50,84 @@
|
||||
#include "spandsp/vector_float.h"
|
||||
#include "spandsp/complex_vector_float.h"
|
||||
|
||||
complexf_t cvec_dot_prodf(const complexf_t x[], const complexf_t y[], int n)
|
||||
{
|
||||
int i;
|
||||
complexf_t z;
|
||||
|
||||
z = complex_setf(0.0f, 0.0f);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
|
||||
z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
|
||||
}
|
||||
return z;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
complex_t cvec_dot_prod(const complex_t x[], const complex_t y[], int n)
|
||||
{
|
||||
int i;
|
||||
complex_t z;
|
||||
|
||||
z = complex_set(0.0, 0.0);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
|
||||
z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
|
||||
}
|
||||
return z;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
#if defined(HAVE_LONG_DOUBLE)
|
||||
complexl_t cvec_dot_prodl(const complexl_t x[], const complexl_t y[], int n)
|
||||
{
|
||||
int i;
|
||||
complexl_t z;
|
||||
|
||||
z = complex_setl(0.0L, 0.0L);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
|
||||
z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
|
||||
}
|
||||
return z;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#endif
|
||||
|
||||
complexf_t cvec_circular_dot_prodf(const complexf_t x[], const complexf_t y[], int n, int pos)
|
||||
{
|
||||
complexf_t z;
|
||||
complexf_t z1;
|
||||
|
||||
z = cvec_dot_prodf(&x[pos], &y[0], n - pos);
|
||||
z1 = cvec_dot_prodf(&x[0], &y[n - pos], pos);
|
||||
z = complex_addf(&z, &z1);
|
||||
return z;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
void cvec_lmsf(const complexf_t x[], complexf_t y[], int n, const complexf_t *error)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
y[i].re += (x[i].im*error->im + x[i].re*error->re);
|
||||
y[i].im += (x[i].re*error->im - x[i].im*error->re);
|
||||
/* Leak a little to tame uncontrolled wandering */
|
||||
y[i].re *= 0.9999f;
|
||||
y[i].im *= 0.9999f;
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
void cvec_circular_lmsf(const complexf_t x[], complexf_t y[], int n, int pos, const complexf_t *error)
|
||||
{
|
||||
cvec_lmsf(&x[pos], &y[0], n - pos, error);
|
||||
cvec_lmsf(&x[0], &y[n - pos], pos, error);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
|
Reference in New Issue
Block a user