LORENE
diff_sx2.C
1/*
2 * Methods for the class Diff_sx2
3 *
4 * (see file diff.h for documentation).
5 *
6 */
7
8/*
9 * Copyright (c) 2005 Jerome Novak
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28
29
30/*
31 * $Id: diff_sx2.C,v 1.5 2016/12/05 16:17:50 j_novak Exp $
32 * $Log: diff_sx2.C,v $
33 * Revision 1.5 2016/12/05 16:17:50 j_novak
34 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35 *
36 * Revision 1.4 2014/10/13 08:52:51 j_novak
37 * Lorene classes and functions now belong to the namespace Lorene.
38 *
39 * Revision 1.3 2014/10/06 15:13:05 j_novak
40 * Modified #include directives to use c++ syntax.
41 *
42 * Revision 1.2 2007/12/11 15:28:11 jl_cornou
43 * Jacobi(0,2) polynomials partially implemented
44 *
45 * Revision 1.1 2005/01/10 16:34:52 j_novak
46 * New class for 1D mono-domain differential operators.
47 *
48 *
49 * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_sx2.C,v 1.5 2016/12/05 16:17:50 j_novak Exp $
50 *
51 */
52
53// C headers
54#include <cassert>
55#include <cstdlib>
56
57// Lorene headers
58#include "diff.h"
59#include "proto.h"
60
61namespace Lorene {
62void sxp12_1d(int, double**, int) ;
63
64
65namespace {
66 int nap = 0 ;
68 int nr_done[Diff::max_points] ;
69}
70
71Diff_sx2::Diff_sx2(int base_r, int nr) : Diff(base_r, nr) {
72 initialize() ;
73 assert (base != R_CHEB) ;
74}
75
76Diff_sx2::Diff_sx2(const Diff_sx2& diff_in) : Diff(diff_in) {
77 assert (nap != 0) ;
78 assert (base != R_CHEB) ;
79}
80
82
84 if (nap == 0) {
85 for (int i=0; i<max_points; i++) {
86 nr_done[i] = -1 ;
87 for (int j=0; j<MAX_BASE; j++)
88 tab[j*max_points+i] = 0x0 ;
89 }
90 nap = 1 ;
91 }
92 return ;
93}
94
95void Diff_sx2::operator=(const Diff_sx2& diff_in) {
96 assert (nap != 0) ;
97 Diff::operator=(diff_in) ;
98
99}
100
102
103 bool done = false ;
104 int indice ;
105 for (indice =0; indice<max_points; indice++) {
106 if (nr_done[indice] == npoints) {
107 if (tab[base*max_points + indice] != 0x0) done = true ;
108 break ;
109 }
110 if (nr_done[indice] == -1)
111 break ;
112 }
113 if (!done) { //The computation must be done ...
114 if (indice == max_points) {
115 cerr << "Diff_sx2::get_matrice() : no space left!!" << '\n'
116 << "The value of Diff.max_points must be increased..." << endl ;
117 abort() ;
118 }
119 nr_done[indice] = npoints ;
120 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
121 Matrice& resu = *tab[base*max_points + indice] ;
122 resu.set_etat_qcq() ;
123
124 double* vect = new double[npoints] ;
125 for (int i=0; i<npoints; i++) {
126 for (int j=0; j<npoints; j++)
127 vect[j] = 0. ;
128 vect[i] = 1. ;
129 if (base == R_JACO02) {
130 sxp12_1d(npoints, &vect, base << TRA_R) ;
131 for (int j=0; j<npoints; j++)
132 resu.set(j,i) = vect[j] ;
133 }
134 else {
135 sx2_1d(npoints, &vect, base << TRA_R) ;
136 for (int j=0; j<npoints; j++)
137 resu.set(j,i) = vect[j] ;
138 }
139 }
140 delete [] vect ;
141 }
142
143 return *tab[base*max_points + indice] ;
144}
145
146ostream& Diff_sx2::operator>>(ostream& ost) const {
147
148 ost << " Division by x^2 " << endl ;
149 return ost ;
150
151}
152}
Diff_sx2(int base_r, int nr)
Standard constructor.
Definition diff_sx2.C:71
void initialize()
Initializes arrays.
Definition diff_sx2.C:83
void operator=(const Diff_sx2 &)
Assignment to another Diff_sx2.
Definition diff_sx2.C:95
virtual const Matrice & get_matrice() const
Returns the matrix associated with the operator.
Definition diff_sx2.C:101
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition diff_sx2.C:146
virtual ~Diff_sx2()
Destructor.
Definition diff_sx2.C:81
int npoints
Number of coefficients.
Definition diff.h:75
void operator=(const Diff &)
Assignment to another Diff.
Definition diff.C:78
Diff(int base_r, int nr)
Standard constructor.
Definition diff.C:64
static const int max_points
Maximal number of matrices stored per base.
Definition diff.h:71
int base
Base in radial direction.
Definition diff.h:74
Matrix handling.
Definition matrice.h:152
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition matrice.C:178
double & set(int j, int i)
Read/write of a particuliar element.
Definition matrice.h:277
#define MAX_BASE
Nombre max. de bases differentes.
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
#define TRA_R
Translation en R, used for a bitwise shift (in hex).
#define R_CHEB
base de Chebychev ordinaire (fin)
Lorene prototypes.
Definition app_hor.h:67