/* cw_c subroutine * Constant Wave computation * * Copyright (C) 2007-2009 Alan Layec * * This file is part of modnumlib. * * modnumlib is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * modnumlib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with modnumlib; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ /* REVISION HISTORY : * $Log$ */ #include <math.h> #include "modnum_lib.h" /* cw_c : routine de calcul d'une onde à fréquence constante (1 ou 2 composantes) * * Entrées : * n : longueur des vecteurs (scalaire) * m : nombre de vecteurs (scalaire) * ampl : amplitude de l'onde (vecteur de taille m) * fs : fréquence de l'onde (vecteur de taille m) * phi : phase à l'origine (vecteur de taille m) * ts : pas d'échantillonnage (scalaire) * ti : temps initial (scalaire) * opt : option de la routine (1:cos, 2:sin, 3:cos et sin) * (scalaire) * * Sorties : * y1 : matrice n,m de sortie composante réelle * y2 : matrice n,m de sortie composante imaginaire * * Dépendances : * math.h * */ void cw_c(int *n, int *m, double *ampl, double *fs, double *phi, \ double *ti, double *ts, int *opt, double *y1, double *y2) { /*déclaration*/ int i,j; switch (*opt) { /*cos*/ case 1 : for (j=0;j<(*m);j++) { for (i=0;i<(*n);i++) { y1[j*(*n)+i]=ampl[j]*cos(2*M_PI*fs[j]*((*ti)+i*(*ts)) + phi[j]); } } break; /*sin*/ case 2 : for (j=0;j<(*m);j++) { for (i=0;i<(*n);i++) { y2[j*(*n)+i]=ampl[j]*sin(2*M_PI*fs[j]*((*ti)+i*(*ts)) + phi[j]); } } break; /*cmplx*/ case 3 : for (j=0;j<(*m);j++) { for (i=0;i<(*n);i++) { y1[j*(*n)+i]=ampl[j]*cos(2*M_PI*fs[j]*((*ti)+i*(*ts)) + phi[j]); y2[j*(*n)+i]=ampl[j]*sin(2*M_PI*fs[j]*((*ti)+i*(*ts)) + phi[j]); } } break; } return; }