/*************************************************************************** * Copyright (C) 2009 by Douglas Castro * * douglas@ime.unicamp.br * * * * This program 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "normas.h" double erro_norma_l1(double vetexa[], double vetapr[], int ncf, double cvol) { double norm = 0.0; int i; for(i = 0;i < ncf;i++) { norm += fabs(vetexa[i]-vetapr[i]); } //fprintf(stderr, "contra prova norma = %f\n",cvol*norm); return cvol*norm; } double vol_cel_folha_malha_uniforme(int d, int niv, double xmin[], double xmax[]) { int i; double vol = 1.0; for(i=0;ifil[0] == NULL) == (r->fil[1] == NULL)); if(r==NULL){return;} if(r->fil[0] == NULL) { int i = *pos; double sum = *soma; sum += fabs(vetexa[i] - r->fval); *soma = sum; i += 1; *pos = i; //fprintf(stderr,"pos = %d soma = %f\n",*pos,*soma); return; } int qual; for(qual=0;qual<2;qual++) erro_norma_l1_v2(vetexa, r->fil[qual], pos, soma); } double norma_inf(double vetexa[], double vetapr[],int niv) { int comp = (int) pow(2,niv-1)/*(sizeof vetexa)/sizeof(double)*/; double norm = 0.0; int i; for(i = comp-1;i >= 0;i--) { double aux = fabs(vetexa[i]-vetapr[i]); if(aux > norm) { norm = aux; } } fprintf(stderr, "contra prova norma = %f\n",norm); return norm; } double erro_l1_analitica_numerica(double vetexa[],double vetunif[], int ncf) { int i; double soma = 0.0; for(i=0;i