23char comb_lin_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin.C,v 1.10 2014/10/13 08:53:28 j_novak Exp $" ;
118#include "type_parite.h"
137Matrice _cl_pas_prevu (
const Matrice &source,
int l,
double echelle,
int puis) {
138 cout <<
"Combinaison lineaire pas prevu..." << endl ;
139 cout <<
"Source : " << source << endl ;
140 cout <<
"l : " << l << endl ;
141 cout <<
"dzpuis : " << puis << endl ;
142 cout <<
"Echelle : " << echelle << endl ;
153Matrice _cl_r_cheb (
const Matrice &source,
int l,
double echelle,
int) {
154 int n = source.
get_dim(0) ;assert (n == source.get_dim(1)) ;
157 const int nmax = 200 ;
158 static Matrice* tab[nmax] ;
159 static int nb_dejafait = 0 ;
160 static int l_dejafait[nmax] ;
161 static int nr_dejafait[nmax] ;
162 static double vieux_echelle = 0 ;
165 if (vieux_echelle != echelle) {
166 for (
int i=0 ; i<nb_dejafait ; i++) {
168 nr_dejafait[i] = -1 ;
172 vieux_echelle = echelle ;
178 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
179 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
184 if (nb_dejafait >= nmax) {
185 cout <<
"_cl_r_cheb : trop de matrices" << endl ;
190 l_dejafait[nb_dejafait] = l ;
191 nr_dejafait[nb_dejafait] = n ;
193 Matrice barre(source) ;
195 for (
int i=0 ; i<n-2 ; i++) {
196 for (
int j=i ; j<(n>(i+7)? i+7 : n) ; j++)
197 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
199 if (i==0) dirac = 0 ;
203 for (
int i=0 ; i<n-4 ; i++)
204 for (
int j=i ; j<(n>(i+5)? i+5 : n) ; j++)
205 res.set(i, j) = barre(i, j)-barre(i+2, j) ;
206 tab[nb_dejafait] =
new Matrice(res) ;
213 return *tab[indice] ;
221Matrice _cl_r_jaco02 (
const Matrice &source,
int l,
double echelle,
int) {
222 int n = source.
get_dim(0) ;assert (n == source.get_dim(1)) ;
225 const int nmax = 200 ;
226 static Matrice* tab[nmax] ;
227 static int nb_dejafait = 0 ;
228 static int l_dejafait[nmax] ;
229 static int nr_dejafait[nmax] ;
230 static double vieux_echelle = 0 ;
233 if (vieux_echelle != echelle) {
234 for (
int i=0 ; i<nb_dejafait ; i++) {
236 nr_dejafait[i] = -1 ;
240 vieux_echelle = echelle ;
246 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
247 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
252 if (nb_dejafait >= nmax) {
253 cout <<
"_cl_r_jaco02 : trop de matrices" << endl ;
258 l_dejafait[nb_dejafait] = l ;
259 nr_dejafait[nb_dejafait] = n ;
261 Matrice barre(source) ;
262 for (
int i=0 ; i<n ; i++) {
263 for (
int j=i ; j<n ; j++)
264 barre.set(i, j) = source(i, j) ;
268 for (
int i=0 ; i<n ; i++)
269 for (
int j=i ; j<n ; j++)
270 res.set(i, j) = barre(i, j);
271 tab[nb_dejafait] =
new Matrice(res) ;
278 return *tab[indice] ;
287Matrice _cl_r_chebp (
const Matrice &source,
int l,
double,
int) {
290 assert (n == source.get_dim(1)) ;
292 const int nmax = 200 ;
293 static Matrice* tab[nmax] ;
294 static int nb_dejafait = 0 ;
295 static int l_dejafait[nmax] ;
296 static int nr_dejafait[nmax] ;
301 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
302 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
307 if (nb_dejafait >= nmax) {
308 cout <<
"_cl_r_chebp : trop de matrices" << endl ;
313 l_dejafait[nb_dejafait] = l ;
314 nr_dejafait[nb_dejafait] = n ;
316 Matrice barre(source) ;
319 for (
int i=0 ; i<n-2 ; i++) {
320 for (
int j=0 ; j<n ; j++)
321 barre.set(i, j) = (1+dirac)*source(i, j)-source(i+2, j) ;
322 if (i==0) dirac = 0 ;
325 Matrice tilde(barre) ;
326 for (
int i=0 ; i<n-4 ; i++)
327 for (
int j=0 ; j<n ; j++)
328 tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
331 for (
int i=0 ; i<n-4 ; i++)
332 for (
int j=0 ; j<n ; j++)
333 res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
334 tab[nb_dejafait] =
new Matrice(res) ;
341 return *tab[indice] ;
349Matrice _cl_r_chebi (
const Matrice &source,
int l,
double,
int) {
351 assert (n == source.get_dim(1)) ;
354 const int nmax = 200 ;
355 static Matrice* tab[nmax] ;
356 static int nb_dejafait = 0 ;
357 static int l_dejafait[nmax] ;
358 static int nr_dejafait[nmax] ;
363 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
364 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
369 if (nb_dejafait >= nmax) {
370 cout <<
"_cl_r_chebi : trop de matrices" << endl ;
375 l_dejafait[nb_dejafait] = l ;
376 nr_dejafait[nb_dejafait] = n ;
378 Matrice barre(source) ;
380 for (
int i=0 ; i<n-2 ; i++)
381 for (
int j=0 ; j<n ; j++)
382 barre.set(i, j) = source(i, j)-source(i+2, j) ;
384 Matrice tilde(barre) ;
385 for (
int i=0 ; i<n-4 ; i++)
386 for (
int j=0 ; j<n ; j++)
387 tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
390 for (
int i=0 ; i<n-4 ; i++)
391 for (
int j=0 ; j<n ; j++)
392 res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
393 tab[nb_dejafait] =
new Matrice(res) ;
400 return *tab[indice] ;
406Matrice _cl_r_chebu (
const Matrice &source,
int l,
double,
int puis) {
408 assert (n == source.get_dim(1)) ;
415 res = _cl_r_chebu_cinq(source, l) ;
418 res = _cl_r_chebu_quatre(source, l) ;
421 res = _cl_r_chebu_trois (source, l) ;
424 res = _cl_r_chebu_deux(source, l) ;
436Matrice _cl_r_chebu_quatre (
const Matrice &source,
int l) {
438 assert (n == source.get_dim(1)) ;
441 const int nmax = 200 ;
442 static Matrice* tab[nmax] ;
443 static int nb_dejafait = 0 ;
444 static int l_dejafait[nmax] ;
445 static int nr_dejafait[nmax] ;
450 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
451 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
456 if (nb_dejafait >= nmax) {
457 cout <<
"_cl_r_chebu_quatre : trop de matrices" << endl ;
462 l_dejafait[nb_dejafait] = l ;
463 nr_dejafait[nb_dejafait] = n ;
465 Matrice barre(source) ;
468 for (
int i=0 ; i<n-2 ; i++) {
469 for (
int j=0 ; j<n ; j++)
470 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
471 if (i==0) dirac = 0 ;
474 Matrice tilde(barre) ;
475 for (
int i=0 ; i<n-4 ; i++)
476 for (
int j=0 ; j<n ; j++)
477 tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
479 Matrice prime(tilde) ;
480 for (
int i=0 ; i<n-4 ; i++)
481 for (
int j=0 ; j<n ; j++)
482 prime.set(i, j) = (tilde(i, j)-tilde(i+1, j)) ;
485 for (
int i=0 ; i<n-4 ; i++)
486 for (
int j=0 ; j<n ; j++)
487 res.set(i, j) = (prime(i, j)-prime(i+2, j)) ;
488 tab[nb_dejafait] =
new Matrice(res) ;
495 return *tab[indice] ;
499Matrice _cl_r_chebu_trois (
const Matrice &source,
int l) {
501 assert (n == source.get_dim(1)) ;
504 const int nmax = 200 ;
505 static Matrice* tab[nmax] ;
506 static int nb_dejafait = 0 ;
507 static int l_dejafait[nmax] ;
508 static int nr_dejafait[nmax] ;
513 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
514 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
519 if (nb_dejafait >= nmax) {
520 cout <<
"_cl_r_chebu_trois : trop de matrices" << endl ;
525 l_dejafait[nb_dejafait] = l ;
526 nr_dejafait[nb_dejafait] = n ;
528 Matrice barre(source) ;
531 for (
int i=0 ; i<n-2 ; i++) {
532 for (
int j=0 ; j<n ; j++)
533 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
534 if (i==0) dirac = 0 ;
537 Matrice tilde(barre) ;
538 for (
int i=0 ; i<n-4 ; i++)
539 for (
int j=0 ; j<n ; j++)
540 tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
543 for (
int i=0 ; i<n-4 ; i++)
544 for (
int j=0 ; j<n ; j++)
545 res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
547 tab[nb_dejafait] =
new Matrice(res) ;
554 return *tab[indice] ;
559Matrice _cl_r_chebu_deux (
const Matrice &source,
int l) {
561 assert (n == source.get_dim(1)) ;
564 const int nmax = 200 ;
565 static Matrice* tab[nmax] ;
566 static int nb_dejafait = 0 ;
567 static int l_dejafait[nmax] ;
568 static int nr_dejafait[nmax] ;
573 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
574 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
579 if (nb_dejafait >= nmax) {
580 cout <<
"_cl_r_chebu_deux : trop de matrices" << endl ;
585 l_dejafait[nb_dejafait] = l ;
586 nr_dejafait[nb_dejafait] = n ;
588 Matrice barre(source) ;
591 for (
int i=0 ; i<n-2 ; i++) {
592 for (
int j=0 ; j<n ; j++)
593 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
594 if (i==0) dirac = 0 ;
597 Matrice tilde(barre) ;
598 for (
int i=0 ; i<n-4 ; i++)
599 for (
int j=0 ; j<n ; j++)
600 tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
603 for (
int i=0 ; i<n-4 ; i++)
604 for (
int j=0 ; j<n ; j++)
605 res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
612 return *tab[indice] ;
617Matrice _cl_r_chebu_cinq (
const Matrice &source,
int l) {
619 assert (n == source.get_dim(1)) ;
622 const int nmax = 200 ;
623 static Matrice* tab[nmax] ;
624 static int nb_dejafait = 0 ;
625 static int l_dejafait[nmax] ;
626 static int nr_dejafait[nmax] ;
631 for (
int conte=0 ; conte<nb_dejafait ; conte ++)
632 if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
637 if (nb_dejafait >= nmax) {
638 cout <<
"_cl_r_chebu_cinq : trop de matrices" << endl ;
643 l_dejafait[nb_dejafait] = l ;
644 nr_dejafait[nb_dejafait] = n ;
646 Matrice barre(source) ;
649 for (
int i=0 ; i<n-2 ; i++) {
650 for (
int j=0 ; j<n ; j++)
651 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
652 if (i==0) dirac = 0 ;
655 Matrice tilde(barre) ;
656 for (
int i=0 ; i<n-4 ; i++)
657 for (
int j=0 ; j<n ; j++)
658 tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
661 for (
int i=0 ; i<n-4 ; i++)
662 for (
int j=0 ; j<n ; j++)
663 res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
674 return *tab[indice] ;
681Matrice combinaison (
const Matrice &source,
int l,
double echelle,
int puis,
int base_r) {
684 static Matrice (*combinaison[
MAX_BASE])(
const Matrice &, int, double, int) ;
691 combinaison[i] = _cl_pas_prevu ;
701 Matrice res(combinaison[base_r](source, l, echelle, puis)) ;
710Tbl _cl_pas_prevu (
const Tbl &source,
int puis) {
711 cout <<
"Combinaison lineaire pas prevue..." << endl ;
712 cout <<
"source : " << &source << endl ;
713 cout <<
"dzpuis : " << puis << endl ;
725Tbl _cl_r_cheb (
const Tbl &source,
int) {
727 int n = source.get_dim(0) ;
730 for (
int i=0 ; i<n-2 ; i++) {
731 barre.set(i) = ((1+dirac)*source(i)-source(i+2))
733 if (i==0) dirac = 0 ;
737 for (
int i=0 ; i<n-4 ; i++)
738 res.set(i) = barre(i)-barre(i+2) ;
747Tbl _cl_r_jaco02 (
const Tbl &source,
int) {
749 int n = source.get_dim(0) ;
751 for (
int i=0 ; i<n ; i++) {
752 barre.set(i) = source(i) ;
756 for (
int i=0 ; i<n ; i++)
757 res.set(i) = barre(i);
766Tbl _cl_r_chebp (
const Tbl &source,
int) {
768 int n = source.get_dim(0) ;
771 for (
int i=0 ; i<n-2 ; i++) {
772 barre.set(i) = (1+dirac)*source(i)-source(i+2) ;
773 if (i==0) dirac = 0 ;
777 for (
int i=0 ; i<n-4 ; i++)
778 tilde.set(i) = barre(i)-barre(i+2) ;
781 for (
int i=0 ; i<n-4 ; i++)
782 res.set(i) = tilde(i)-tilde(i+1) ;
792Tbl _cl_r_chebi (
const Tbl &source,
int) {
794 int n = source.get_dim(0) ;
796 for (
int i=0 ; i<n-2 ; i++)
797 barre.set(i) = source(i)-source(i+2) ;
800 for (
int i=0 ; i<n-4 ; i++)
801 tilde.set(i) = barre(i)-barre(i+2) ;
804 for (
int i=0 ; i<n-4 ; i++)
805 res.set(i) = tilde(i)-tilde(i+1) ;
815Tbl _cl_r_chebu (
const Tbl &source,
int puis) {
823 res = _cl_r_chebu_cinq(source) ;
826 res = _cl_r_chebu_quatre(source) ;
829 res = _cl_r_chebu_trois (source) ;
832 res = _cl_r_chebu_deux(source) ;
843Tbl _cl_r_chebu_quatre (
const Tbl &source) {
845 int n = source.get_dim(0) ;
848 for (
int i=0 ; i<n-2 ; i++) {
849 barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
850 if (i==0) dirac = 0 ;
854 for (
int i=0 ; i<n-4 ; i++)
855 tilde.set(i) = (barre(i)-barre(i+2)) ;
858 for (
int i=0 ; i<n-4 ; i++)
859 prime.set(i) = (tilde(i)-tilde(i+1)) ;
862 for (
int i=0 ; i<n-4 ; i++)
863 res.set(i) = (prime(i)-prime(i+2)) ;
868Tbl _cl_r_chebu_trois (
const Tbl &source) {
870 int n = source.get_dim(0) ;
873 for (
int i=0 ; i<n-2 ; i++) {
874 barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
875 if (i==0) dirac = 0 ;
879 for (
int i=0 ; i<n-4 ; i++)
880 tilde.set(i) = (barre(i)-barre(i+2)) ;
883 for (
int i=0 ; i<n-4 ; i++)
884 res.set(i) = (tilde(i)+tilde(i+1)) ;
890Tbl _cl_r_chebu_deux (
const Tbl &source) {
892 int n = source.get_dim(0) ;
895 for (
int i=0 ; i<n-2 ; i++) {
896 barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
897 if (i==0) dirac = 0 ;
901 for (
int i=0 ; i<n-4 ; i++)
902 tilde.set(i) = (barre(i)-barre(i+2)) ;
905 for (
int i=0 ; i<n-4 ; i++)
906 res.set(i) = (tilde(i)+tilde(i+1)) ;
911Tbl _cl_r_chebu_cinq (
const Tbl &source) {
913 int n = source.get_dim(0) ;
916 for (
int i=0 ; i<n-2 ; i++) {
917 barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
918 if (i==0) dirac = 0 ;
922 for (
int i=0 ; i<n-4 ; i++)
923 tilde.set(i) = (barre(i)-barre(i+2)) ;
926 for (
int i=0 ; i<n-4 ; i++)
927 res.set(i) = (tilde(i)+tilde(i+1)) ;
936Tbl combinaison (
const Tbl &source,
int puis,
int base_r) {
939 static Tbl (*combinaison[
MAX_BASE])(
const Tbl &, int) ;
946 combinaison[i] = _cl_pas_prevu ;
956 Tbl res(combinaison[base_r](source, puis)) ;
int get_dim(int i) const
Returns the dimension of the matrix.
#define MAX_BASE
Nombre max. de bases differentes.
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
#define R_CHEBI
base de Cheb. impaire (rare) seulement
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
#define R_CHEB
base de Chebychev ordinaire (fin)
#define R_CHEBP
base de Cheb. paire (rare) seulement