LORENE
ope_poisson_pseudo_1d_cl.C
1/*
2 * Copyright (c) 2004 Philippe Grandclement
3 *
4 * This file is part of LORENE.
5 *
6 * LORENE is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * LORENE is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with LORENE; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21char ope_poisson_pseudo_1d_cl_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_cl.C,v 1.3 2014/10/13 08:53:35 j_novak Exp $" ;
22
23/*
24 * $Id: ope_poisson_pseudo_1d_cl.C,v 1.3 2014/10/13 08:53:35 j_novak Exp $
25 * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_cl.C,v 1.3 2014/10/13 08:53:35 j_novak Exp $
26 *
27 */
28#include <cmath>
29#include <cstdlib>
30
31#include "proto.h"
32#include "ope_elementary.h"
33
34// Version Matrice --> Matrice
35namespace Lorene {
36Matrice _cl_poisson_pseudo_1d_pas_prevu (const Matrice & so) {
37 cout << "Combinaison lineaire pas prevu..." << endl ;
38 abort() ;
39 exit(-1) ;
40 return so;
41}
42
43
44 //-------------------
45 //-- R_CHEB ------
46 //-------------------
47
48Matrice _cl_poisson_pseudo_1d_r_cheb (const Matrice &source) {
49
50 int n = source.get_dim(0) ;
51 assert (n == source.get_dim(1)) ;
52
53 Matrice barre(source) ;
54 int dirac = 1 ;
55 for (int i=0 ; i<n-2 ; i++) {
56 for (int j=0 ; j<n ; j++)
57 barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
58 /(i+1) ;
59 if (i==0) dirac = 0 ;
60 }
61
62 Matrice res(barre) ;
63 for (int i=0 ; i<n-4 ; i++)
64 for (int j=0 ; j<n ; j++)
65 res.set(i, j) = barre(i, j)-barre(i+2, j) ;
66
67 return res ;
68}
69
70
71 //-------------------
72 //-- R_CHEBP -----
73 //-------------------
74
75
76Matrice _cl_poisson_pseudo_1d_r_chebp (const Matrice &source) {
77
78 int n = source.get_dim(0) ;
79 assert (n == source.get_dim(1)) ;
80
81 Matrice barre(source) ;
82
83 int dirac = 1 ;
84 for (int i=0 ; i<n-2 ; i++) {
85 for (int j=0 ; j<n ; j++)
86 barre.set(i, j) = (1+dirac)*source(i, j)-source(i+2, j) ;
87 if (i==0) dirac = 0 ;
88 }
89
90 Matrice tilde(barre) ;
91 for (int i=0 ; i<n-4 ; i++)
92 for (int j=0 ; j<n ; j++)
93 tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
94
95 Matrice res(tilde) ;
96 for (int i=0 ; i<n-4 ; i++)
97 for (int j=0 ; j<n ; j++)
98 res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
99
100 return res ;
101}
102
103 //-------------------
104 //-- R_CHEBI -----
105 //-------------------
106
107
108Matrice _cl_poisson_pseudo_1d_r_chebi (const Matrice &source) {
109 int n = source.get_dim(0) ;
110 assert (n == source.get_dim(1)) ;
111
112 Matrice barre(source) ;
113
114 for (int i=0 ; i<n-2 ; i++)
115 for (int j=0 ; j<n ; j++)
116 barre.set(i, j) = source(i, j)-source(i+2, j) ;
117
118 Matrice tilde(barre) ;
119 for (int i=0 ; i<n-4 ; i++)
120 for (int j=0 ; j<n ; j++)
121 tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
122
123 Matrice res(tilde) ;
124 for (int i=0 ; i<n-4 ; i++)
125 for (int j=0 ; j<n ; j++)
126 res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
127
128 return res ;
129}
130
132 if (ope_mat == 0x0)
133 do_ope_mat() ;
134
135 if (ope_cl != 0x0)
136 delete ope_cl ;
137
138 // Routines de derivation
139 static Matrice (*cl_poisson_pseudo_1d[MAX_BASE])(const Matrice&);
140 static int nap = 0 ;
141
142 // Premier appel
143 if (nap==0) {
144 nap = 1 ;
145 for (int i=0 ; i<MAX_BASE ; i++) {
146 cl_poisson_pseudo_1d[i] = _cl_poisson_pseudo_1d_pas_prevu ;
147 }
148 // Les routines existantes
149 cl_poisson_pseudo_1d[R_CHEBP >> TRA_R] = _cl_poisson_pseudo_1d_r_chebp ;
150 cl_poisson_pseudo_1d[R_CHEBI >> TRA_R] = _cl_poisson_pseudo_1d_r_chebi ;
151 cl_poisson_pseudo_1d[R_CHEB >> TRA_R] = _cl_poisson_pseudo_1d_r_cheb ;
152 }
153 ope_cl = new Matrice(cl_poisson_pseudo_1d[base_r](*ope_mat)) ;
154}
155
156
157}
Time evolution with partial storage (*** under development ***).
Definition evolution.h:371
Matrix handling.
Definition matrice.h:152
int get_dim(int i) const
Returns the dimension of the matrix.
Definition matrice.C:260
Matrice * ope_mat
Pointer on the matrix representation of the operator.
int base_r
Radial basis of decomposition.
Matrice * ope_cl
Pointer on the banded-matrix of the operator.
virtual void do_ope_cl() const
Computes the banded-matrix of the operator.
virtual void do_ope_mat() const
Computes the matrix of the operator.
#define MAX_BASE
Nombre max. de bases differentes.
#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
Lorene prototypes.
Definition app_hor.h:64