comparison spandsp-0.0.6pre17/tests/complex_tests.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.c
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2008 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 General Public License version 2, as
14 * 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 General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * 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_tests.c,v 1.2 2009/01/28 03:41:27 steveu Exp $
26 */
27
28 /*! \page complex_tests_page Complex arithmetic tests
29 \section complex_tests_page_sec_1 What does it do?
30
31 \section complex_tests_page_sec_2 How is it used?
32 */
33
34 #if defined(HAVE_CONFIG_H)
35 #include "config.h"
36 #endif
37
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <fcntl.h>
41 #include <string.h>
42 #if defined(HAVE_TGMATH_H)
43 #include <tgmath.h>
44 #endif
45 #if defined(HAVE_MATH_H)
46 #include <math.h>
47 #endif
48 #include "floating_fudge.h"
49 #include <assert.h>
50
51 #include "spandsp.h"
52
53 int main(int argc, char *argv[])
54 {
55 complexf_t fa;
56 complexf_t fb;
57 complexf_t fz;
58 complexi16_t i16a;
59 complexi16_t i16b;
60 complexi16_t i16z;
61 #if 0
62 complexi32_t i32a;
63 complexi32_t i32b;
64 complexi32_t i32z;
65 #endif
66
67 fa = complex_setf(0.5f, 0.25f);
68 fb = complex_setf(0.25f, 0.5f);
69 fz = complex_mulf(&fa, &fb);
70 printf("(%f, %f) * (%f, %f) => (%f, %f)\n", fa.re, fa.im, fb.re, fb.im, fz.re, fz.im);
71
72 i16a = complex_seti16(16383, 8191);
73 i16b = complex_seti16(8191, 16383);
74 i16z = complex_mul_q1_15(&i16a, &i16b);
75 printf("(%f, %f) * (%f, %f) => (%f, %f)\n", i16a.re/32768.0, i16a.im/32768.0, i16b.re/32768.0, i16b.im/32768.0, i16z.re/32768.0, i16z.im/32768.0);
76
77 printf("Tests passed.\n");
78 return 0;
79 }
80 /*- End of function --------------------------------------------------------*/
81 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.