File: grid.h

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 26,444 kB
  • ctags: 13,953
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (347 lines) | stat: -rw-r--r-- 10,793 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
 * Declaration of class Grid and derived classes
 */

/*
 *   Copyright (c) 2005 Eric Gourgoulhon
 *
 *   This file is part of LORENE.
 *
 *   LORENE 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.
 *
 *   LORENE 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 LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

/*
 * $Id: grid.h,v 1.1 2005/11/14 01:56:58 e_gourgoulhon Exp $
 * $Log: grid.h,v $
 * Revision 1.1  2005/11/14 01:56:58  e_gourgoulhon
 * First version
 *
 *
 * $Header: /cvsroot/Lorene/School05/Monday/grid.h,v 1.1 2005/11/14 01:56:58 e_gourgoulhon Exp $
 *
 */


#ifndef __GRID_H_ 
#define __GRID_H_ 

            //----------------------------------//
            //          class Grid              //
            //----------------------------------//

/** Set of nodes in the interval [-1,1]. \ingroup (grid)
 *
 */
class Grid {

    // Data : 
    // -----
    protected:
        const int nn ; ///< \e N = number of nodes - 1
        double* xx ;  ///< Values of the nodes (pointer to an array of size \c nn+1) 

    // Constructors - Destructor
    // -------------------------
    public:
        /** Standard constructor.
         *  @param nb_nodes number of nodes 
         *  @param xi array of size \c nb_nodes containing the abscissas of the nodes
         */
	Grid(int nb_nodes, double* xi) ;
        
	Grid(const Grid& ) ;		///< Copy constructor
        
    protected:
        /** Constructor to be used only by derived classes (hence protected)
         *  @param nb_nodes number of nodes 
         */
        Grid(int nb_nodes) ;
         
    public:
	virtual ~Grid() ;			///< Destructor
 
    // Mutators / assignment
    // ---------------------
    public:
	/// Assignment to another Grid
	void operator=(const Grid&) ;	
	
    // Accessors
    // ---------
    public:
        int n() const ; ///< returns \e N, i.e. the number of nodes - 1

        double operator()(int i) const ; ///< returns value of node no. \c i

        /** Graphical display of the node points.
        *
        *  @param color color of the points (drawn as small circles) : 
        *      \li 0 : black (background)
        *      \li 1 : white (default)
        *      \li 2 : red
        *      \li 3 : green
        *      \li 4 : blue
        *      \li 5 : cyan
        *      \li 6 : magenta
        *      \li 7 : yellow
        *      \li 8 : orange
        *      \li 9 : green + yellow
        *      \li 10 : green + cyan
        *      \li 11 : blue + cyan
        *      \li 12 : blue + magenta
        *      \li 13 : red + magenta
        *      \li 14 : dark gray 
        *      \li 15 : light gray
        *  @param nfig index of the figure (in the range [0,99])
        *  to be used for the plot: if this figure does not exist, 
        *    it will be created with the device name \c device  provided by the last
        *      argument. 
        *  @param ymin lower bound on y of the graphical window (used only if a new 
        *      figure must be created)
        *  @param ymax upper bound on y of the graphical window (used only if a new 
        *      figure must be created)
        *  @param title title of the figure (used only if a new figure must be created)
        *  @param label_y y legend of the figure (used only if a new 
        *      figure must be created)
        *  @param device type of graphical device (default value = 0x0, will result in
        *  interactive choice) (used only if a new 
        *      figure must be created)
        */
        void plot(int color = 1, int nfig = 0, double ymin = -1., 
                  double ymax = 1., const char* title = 0x0, 
                  const char* label_y = 0x0, const char* device = 0x0) const ;
                        
    // Computation
    // -----------
    public: 
        /** Lagrange polynomials (characteristic polynomials).
         *  The Lagrange polynomial no. \e i is the unique polynomial 
         *  \f$\ell_i(x)\f$ of degree \e N such that 
         *  \f$\ell_i(x_{j})=\delta_{ij}\f$. It is also called \e cardinal
         *  \e polynomial associated with the node \f$x_i\f$
         *  @param i number of Lagrange polynomial \f$\ell_i\f$
         *  @param x point \e x in [-1,1] where the Lagrange polynomial is to 
         *      be evaluated
         *  @return value of \f$\ell_i(x)\f$
         */
        double lagrange(int i, double x) const ; 
         
        /** Nodal polynomial. 
         * The nodal polynomoal is the unique polynomial of degree \e N + 1
         *  and leading coefficient 1, the roots of which are the \e N +1 nodes
         *  \f$x_i\f$.
         *
         *  @param x point \e x in [-1,1] where the Lagrange polynomial is to 
         *      be evaluated
         *  @return value of the nodal polynomial at \e x
         */
        double nodal_polynomial(double x) const ; 
          
        /** Interpolation of a given function at the nodes
         *
         *  @param (*f)(double) function to be interpolated         
         *  @param x point \e x in [-1,1] where the interpolating polynomial
         *    associated with the nodes \f$x_i\f$ is to evaluated
         *  @return value of the interpolating polynomial at \e x       
         */
        double interpole(double (*f)(double), double x) const ;  
        
        /// Computes (an approximate value of) the Lebesgue constant
        double lebesgue_constant() const ; 
    
};

/// Display of an object of class \c Grid
ostream& operator<<(ostream& , const Grid& ) ;	


            //----------------------------------//
            //          class Grid_uniform      //
            //----------------------------------//



/** Uniform sampling of the interval [-1,1]. \ingroup (grid)
 *
 */
class Grid_uniform : public Grid {

    // Constructors - Destructor
    // -------------------------
    public:
        /** Standard constructor.
         *  @param nb_nodes number of nodes 
         */
	Grid_uniform(int nb_nodes) ;
        
	Grid_uniform(const Grid_uniform& ) ;		///< Copy constructor
        
	virtual ~Grid_uniform() ;			///< Destructor
 
    // Mutators / assignment
    // ---------------------
    public:
	/// Assignment to another Grid_uniform
	void operator=(const Grid_uniform&) ;	
	
                       
};

/// Display of an object of class \c Grid_uniform
ostream& operator<<(ostream& , const Grid_uniform& ) ;	


            //----------------------------------//
            //    class Grid_Legendre_Gauss    //
            //----------------------------------//


/** Legendre Gauss nodes in the interval [-1,1]. \ingroup (grid)
 *
 */
class Grid_Legendre_Gauss : public Grid {

    // Constructors - Destructor
    // -------------------------
    public:
        /** Standard constructor.
         *  @param nb_nodes number of nodes 
         */
        Grid_Legendre_Gauss(int nb_nodes) ;
        
        Grid_Legendre_Gauss(const Grid_Legendre_Gauss& ) ;	///< Copy constructor
        
	    virtual ~Grid_Legendre_Gauss() ;			///< Destructor
 
    // Mutators / assignment
    // ---------------------
    public:
	    /// Assignment to another Grid_Legendre_Gauss
	    void operator=(const Grid_Legendre_Gauss&) ;	
	
                       
};

/// Display of an object of class \c Grid_Legendre_Gauss
ostream& operator<<(ostream& , const Grid_Legendre_Gauss& ) ;	


            //----------------------------------//
            //     class Grid_Legendre_GL      //
            //----------------------------------//


/** Legendre Gauss-Lobatto nodes in the interval [-1,1]. \ingroup (grid)
 *
 */
class Grid_Legendre_GL : public Grid {

    // Constructors - Destructor
    // -------------------------
    public:
        /** Standard constructor.
         *  @param nb_nodes number of nodes 
         */
        Grid_Legendre_GL(int nb_nodes) ;
        
        Grid_Legendre_GL(const Grid_Legendre_GL& ) ;	///< Copy constructor
        
	    virtual ~Grid_Legendre_GL() ;			///< Destructor
 
    // Mutators / assignment
    // ---------------------
    public:
	    /// Assignment to another Grid_Legendre_GL
	    void operator=(const Grid_Legendre_GL&) ;	
	
                       
};

/// Display of an object of class \c Grid_Legendre_GL
ostream& operator<<(ostream& , const Grid_Legendre_GL& ) ;	



            //----------------------------------//
            //    class Grid_Chebyshev_Gauss    //
            //----------------------------------//


/** Chebyshev Gauss nodes in the interval [-1,1]. \ingroup (grid)
 *
 */
class Grid_Chebyshev_Gauss : public Grid {

    // Constructors - Destructor
    // -------------------------
    public:
        /** Standard constructor.
         *  @param nb_nodes number of nodes 
         */
        Grid_Chebyshev_Gauss(int nb_nodes) ;
        
        Grid_Chebyshev_Gauss(const Grid_Chebyshev_Gauss& ) ;	///< Copy constructor
        
	    virtual ~Grid_Chebyshev_Gauss() ;			///< Destructor
 
    // Mutators / assignment
    // ---------------------
    public:
	    /// Assignment to another Grid_Chebyshev_Gauss
	    void operator=(const Grid_Chebyshev_Gauss&) ;	
	
                       
};

/// Display of an object of class \c Grid_Chebyshev_Gauss
ostream& operator<<(ostream& , const Grid_Chebyshev_Gauss& ) ;	


            //----------------------------------//
            //     class Grid_Chebyshev_GL      //
            //----------------------------------//


/** Chebyshev Gauss-Lobatto nodes in the interval [-1,1]. \ingroup (grid)
 *
 */
class Grid_Chebyshev_GL : public Grid {

    // Constructors - Destructor
    // -------------------------
    public:
        /** Standard constructor.
         *  @param nb_nodes number of nodes 
         */
        Grid_Chebyshev_GL(int nb_nodes) ;
        
        Grid_Chebyshev_GL(const Grid_Chebyshev_GL& ) ;	///< Copy constructor
        
	    virtual ~Grid_Chebyshev_GL() ;			///< Destructor
 
    // Mutators / assignment
    // ---------------------
    public:
	    /// Assignment to another Grid_Chebyshev_GL
	    void operator=(const Grid_Chebyshev_GL&) ;	
	
                       
};

/// Display of an object of class \c Grid_Chebyshev_GL
ostream& operator<<(ostream& , const Grid_Chebyshev_GL& ) ;	

#endif