Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/complex_vector_int.c @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * complex_vector_int.c - Integer complex vector arithmetic routines. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2006 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: complex_vector_int.c,v 1.9 2009/07/12 09:23:09 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if defined(HAVE_CONFIG_H) | |
| 31 #include "config.h" | |
| 32 #endif | |
| 33 | |
| 34 #include <inttypes.h> | |
| 35 #include <stdlib.h> | |
| 36 #include <stdio.h> | |
| 37 #include <string.h> | |
| 38 #if defined(HAVE_TGMATH_H) | |
| 39 #include <tgmath.h> | |
| 40 #endif | |
| 41 #if defined(HAVE_MATH_H) | |
| 42 #include <math.h> | |
| 43 #endif | |
| 44 #include <assert.h> | |
| 45 | |
| 46 #include "floating_fudge.h" | |
| 47 #include "mmx_sse_decs.h" | |
| 48 | |
| 49 #include "spandsp/telephony.h" | |
| 50 #include "spandsp/logging.h" | |
| 51 #include "spandsp/complex.h" | |
| 52 #include "spandsp/vector_int.h" | |
| 53 #include "spandsp/complex_vector_int.h" | |
| 54 | |
| 55 SPAN_DECLARE(complexi32_t) cvec_dot_prodi16(const complexi16_t x[], const complexi16_t y[], int n) | |
| 56 { | |
| 57 int i; | |
| 58 complexi32_t z; | |
| 59 | |
| 60 z = complex_seti32(0, 0); | |
| 61 for (i = 0; i < n; i++) | |
| 62 { | |
| 63 z.re += ((int32_t) x[i].re*(int32_t) y[i].re - (int32_t) x[i].im*(int32_t) y[i].im); | |
| 64 z.im += ((int32_t) x[i].re*(int32_t) y[i].im + (int32_t) x[i].im*(int32_t) y[i].re); | |
| 65 } | |
| 66 return z; | |
| 67 } | |
| 68 /*- End of function --------------------------------------------------------*/ | |
| 69 | |
| 70 SPAN_DECLARE(complexi32_t) cvec_dot_prodi32(const complexi32_t x[], const complexi32_t y[], int n) | |
| 71 { | |
| 72 int i; | |
| 73 complexi32_t z; | |
| 74 | |
| 75 z = complex_seti32(0, 0); | |
| 76 for (i = 0; i < n; i++) | |
| 77 { | |
| 78 z.re += (x[i].re*y[i].re - x[i].im*y[i].im); | |
| 79 z.im += (x[i].re*y[i].im + x[i].im*y[i].re); | |
| 80 } | |
| 81 return z; | |
| 82 } | |
| 83 /*- End of function --------------------------------------------------------*/ | |
| 84 | |
| 85 SPAN_DECLARE(complexi32_t) cvec_circular_dot_prodi16(const complexi16_t x[], const complexi16_t y[], int n, int pos) | |
| 86 { | |
| 87 complexi32_t z; | |
| 88 complexi32_t z1; | |
| 89 | |
| 90 z = cvec_dot_prodi16(&x[pos], &y[0], n - pos); | |
| 91 z1 = cvec_dot_prodi16(&x[0], &y[n - pos], pos); | |
| 92 z = complex_addi32(&z, &z1); | |
| 93 return z; | |
| 94 } | |
| 95 /*- End of function --------------------------------------------------------*/ | |
| 96 | |
| 97 SPAN_DECLARE(void) cvec_lmsi16(const complexi16_t x[], complexi16_t y[], int n, const complexi16_t *error) | |
| 98 { | |
| 99 int i; | |
| 100 | |
| 101 for (i = 0; i < n; i++) | |
| 102 { | |
| 103 y[i].re += (int16_t) (((int32_t) x[i].im*(int32_t) error->im + (int32_t) x[i].re*(int32_t) error->re) >> 12); | |
| 104 y[i].im += (int16_t) (((int32_t) x[i].re*(int32_t) error->im - (int32_t) x[i].im*(int32_t) error->re) >> 12); | |
| 105 } | |
| 106 } | |
| 107 /*- End of function --------------------------------------------------------*/ | |
| 108 | |
| 109 SPAN_DECLARE(void) cvec_circular_lmsi16(const complexi16_t x[], complexi16_t y[], int n, int pos, const complexi16_t *error) | |
| 110 { | |
| 111 cvec_lmsi16(&x[pos], &y[0], n - pos, error); | |
| 112 cvec_lmsi16(&x[0], &y[n - pos], pos, error); | |
| 113 } | |
| 114 /*- End of function --------------------------------------------------------*/ | |
| 115 /*- End of file ------------------------------------------------------------*/ |
