00001 /* 00002 libit - Library for basic source and channel coding functions 00003 Copyright (C) 2005-2005 Vivien Chappelier, Herve Jegou 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 /*------------------------------------------------------------*/ 00021 /** @file test_cplx.c Test program for complex numbers */ 00022 /*------------------------------------------------------------*/ 00023 00024 #include <it/cplx.h> 00025 #include <it/vec.h> 00026 #include <it/io.h> 00027 00028 int main () 00029 { 00030 cplx a = cplx (1.5, 2.5), b = cplx (1.7, 2.1), c; 00031 cvec C; 00032 00033 cimag (b) = 5.5; 00034 00035 it_printf ("a = %z\n", a); 00036 it_printf ("b = %z\n", b); 00037 it_printf ("a+b = %z\n", cadd (a, b)); 00038 c = cmul (a, b); 00039 it_printf ("a*b = %z\n", c); 00040 it_printf ("a*b = %z\n", cplx_I); 00041 it_printf ("(a*b)/b = %z\n", cdiv (c, b)); 00042 it_printf ("conj(a) = %z\n", cconj (a)); 00043 it_printf ("cmod(a) = %f\n", cnorm (a)); 00044 00045 C = cvec_new (6); 00046 C[0] = a; 00047 C[1] = b; 00048 C[2] = c; 00049 C[3] = cplx_I; 00050 C[4] = cplx_0; 00051 C[5] = cplx_1; 00052 it_printf ("C = $z\n", C); 00053 cvec_mul_by_real (C, 2); 00054 it_printf ("2*C = $z\n", C); 00055 00056 return 0; 00057 }
|
|