/* intsym_c subroutine * Symbol discrete integrator * * 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 <stdlib.h> #include <stdio.h> #include "modnum_lib.h" /* intsym_c routine de calcul d'intégration symbole * * Entrées : * n : dimension 1 des matrices d'entrée/sortie (scalaire) * m : dimension 2 des matrices d'entrée/sortie (scalaire) * nech : nombre d'échantillons par symbole (scalaire) * step : pas d'intégration (scalaire) * u : matrice à intégrer par colonne (matrice de taille n,m) * * Sorties : * y : matrice intégrée (de taille n,m) * * Entrée/Sortie : * z : échantillon matrice (vecteur de taille m,2) * init_c : valeur initiale du compteur (vecteur de taille m) * */ void intsym_c(int *n,int *m,int *nech,int *init_c,double *step,double *u,double *y,double *z) { /*Déclaration des variables compteurs*/ int i,l; int count; int ind_y; /*pour tous les échantillons du vecteur d'entrée*/ for(l=0;l<(*m);l++) { /*récupère valeur initiale*/ count=init_c[l]; ind_y = (*n)*l; for(i=0;i<(*n);i++) { if(i==(count-1)) { /* remise à zéro */ count += *nech; y[ind_y+i]=0.; } else if(i==0) { /* integration + z */ y[ind_y+i]=2./(*step)*(u[ind_y+i]+z[l])+z[(*m)+l]; } else { /* integration + y-1 */ y[ind_y+i]=2./(*step)*(u[ind_y+i]+u[ind_y+i-1])+y[ind_y+i-1]; } if(i==(*n)-1) { /* z mémorisé */ z[l]=u[ind_y+i]; z[(*m)+l]=y[ind_y+i]; } } init_c[l]=Abs(count-(*n)); } return; } void intsymi_c(int *n,int *m,int *nech,int *init_c,double *step,int *u,double *y,double *z) { /*Déclaration des variables compteurs*/ int i,l; int count; int ind_y; /*pour tous les échantillons du vecteur d'entrée*/ for(l=0;l<(*m);l++) { /*récupère valeur initiale*/ count=init_c[l]; ind_y = (*n)*l; for(i=0;i<(*n);i++) { if(i==(count-1)) { /* remise à zéro */ count += *nech; y[ind_y+i]=0.; } else if(i==0) { /* integration + z */ y[ind_y+i]=2./(*step)*(u[ind_y+i]+z[l])+z[(*m)+l]; } else { /* integration + y-1 */ y[ind_y+i]=2./(*step)*(u[ind_y+i]+u[ind_y+i-1])+y[ind_y+i-1]; } if(i==(*n)-1) { /* z mémorisé */ z[l]=u[ind_y+i]; z[(*m)+l]=y[ind_y+i]; } } init_c[l]=Abs(count-(*n)); } return; } void intsymy_c(int *n,int *m,int *nech,int *init_c,double *step,double *u,double *y,double *z) { /*Déclaration des variables compteurs*/ int i,l; int count; int ind_y; /*pour tous les échantillons du vecteur d'entrée*/ for(l=0;l<(*m);l++) { /*récupère valeur initiale*/ count=init_c[l]; ind_y = (*n)*l; for(i=0;i<(*n);i++) { if(i==(count-1)) { /* remise à zéro */ count += *nech; y[ind_y+i]=0.; } else if(i==0) { /* integration + z */ y[ind_y+i]=2./(*step)*(u[ind_y+i]+z[l])+z[(*m)+l]; } else { /* integration + y-1 */ y[ind_y+i]=2./(*step)*(u[ind_y+i]+u[ind_y+i-1])+y[ind_y+i-1]; } } } return; } void intsymz_c(int *n,int *m,double *u,double *y,double *z) { /*Déclaration des variables compteurs*/ int l; int ind_y; /*pour tous les échantillons du vecteur d'entrée*/ for(l=0;l<(*m);l++) { ind_y = (*n)*l; z[l]=u[ind_y+(*n)-1]; z[(*m)+l]=y[ind_y+(*n)-1]; } return; }