/* demodpsk_c subroutine * Phase Shift Keying demodulator * * 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" /* demodpsk_c routine de calcul de démodulation PSK * * Entrées : * n : dimension 1 des matrices d'entrée/sorties (scalaire) * m : dimension 2 des matrices d'entrée/sorties (scalaire) * ns : nombre d'états (scalaire) * i_c : vecteur de la composante I * q_c : vecteur de la composante Q * Sorties : * y : vecteur du numéro symbole * * dépendance : * math.h */ void demodpsk_c(int *n,int *m,int *ns,double *i_c,double *i_q,double*y) { /*Déclaration des variables*/ int i,l; double phi; for(l=0;l<(*m);l++) { for(i=0;i<(*n);i++) { /*Calcul de la phase*/ phi=atan2(-i_q[(*n)*l+i],i_c[(*n)*l+i]); if(phi<0) phi = phi + 2*M_PI; /*Calcul du numéro symbole*/ y[(*n)*l+i]=(int)(phi*(*ns)/(2*M_PI)); } } return; } /* demodpskv_c routine de calcul de démodulation PSK * * Entrées : * n : taille des vecteur originaux * m : nombre d'états (vecteur) * i_c : vecteur de la composante I * q_c : vecteur de la composante Q * Sorties : * y : vecteur du numéro symbole * * dépendance : * math.h */ void demodpskv_c(int *n,int *m,double *i_c,double *i_q,double*y) { /*Déclaration des variables*/ int i; double phi; for(i=0;i<(*n);i++) { /*Calcul de la phase*/ phi=atan2(-i_q[i],i_c[i]); if(phi<0) phi = phi + 2*M_PI; /*Calcul du numéro symbole*/ y[i]=(int)(phi*m[i]/(2*M_PI)); } return; }