Debian Codegraph @

C++/Source/Diff/diff_x2dsdx2.C

raw
1 /*
2 * Methods for the class Diff_x2dsdx2
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 char diff_x2dsdx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_x2dsdx2.C,v 1.4 2014/10/13 08:52:51 j_novak Exp $" ;
29
30 /*
31 * $Id: diff_x2dsdx2.C,v 1.4 2014/10/13 08:52:51 j_novak Exp $
32 * $Log: diff_x2dsdx2.C,v $
33 * Revision 1.4 2014/10/13 08:52:51 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.3 2014/10/06 15:13:05 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.2 2007/12/11 15:28:11 jl_cornou
40 * Jacobi(0,2) polynomials partially implemented
41 *
42 * Revision 1.1 2005/01/10 16:34:52 j_novak
43 * New class for 1D mono-domain differential operators.
44 *
45 *
46 * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_x2dsdx2.C,v 1.4 2014/10/13 08:52:51 j_novak Exp $
47 *
48 */
49
50 // C headers
51 #include <cassert>
52 #include <cstdlib>
53
54 // Lorene headers
55 #include "diff.h"
56 #include "proto.h"
57
58 namespace Lorene {
59 void mult2_xp1_1d(int, double**, int) ;
60
61 namespace {
62 int nap = 0 ;
63 Matrice* tab[MAX_BASE*Diff::max_points] ;
64 int nr_done[Diff::max_points] ;
65 }
66
67 Diff_x2dsdx2::Diff_x2dsdx2(int base_r, int nr) : Diff(base_r, nr) {
68 initialize() ;
69 }
70
71 Diff_x2dsdx2::Diff_x2dsdx2(const Diff_x2dsdx2& diff_in) : Diff(diff_in) {
72 assert (nap != 0) ;
73 }
74
75 Diff_x2dsdx2::~Diff_x2dsdx2() {}
76
77 void Diff_x2dsdx2::initialize() {
78 if (nap == 0) {
79 for (int i=0; i<max_points; i++) {
80 nr_done[i] = -1 ;
81 for (int j=0; j<MAX_BASE; j++)
82 tab[j*max_points+i] = 0x0 ;
83 }
84 nap = 1 ;
85 }
86 return ;
87 }
88
89 void Diff_x2dsdx2::operator=(const Diff_x2dsdx2& diff_in) {
90 assert (nap != 0) ;
91 Diff::operator=(diff_in) ;
92
93 }
94
95 const Matrice& Diff_x2dsdx2::get_matrice() const {
96
97 bool done = false ;
98 int indice ;
99 for (indice =0; indice<max_points; indice++) {
100 if (nr_done[indice] == npoints) {
101 if (tab[base*max_points + indice] != 0x0) done = true ;
102 break ;
103 }
104 if (nr_done[indice] == -1)
105 break ;
106 }
107 if (!done) { //The computation must be done ...
108 if (indice == max_points) {
109 cerr << "Diff_x2dsdx2::get_matrice() : no space left!!" << '\n'
110 << "The value of Diff.max_points must be increased..." << endl ;
111 abort() ;
112 }
113 nr_done[indice] = npoints ;
114 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
115 Matrice& resu = *tab[base*max_points + indice] ;
116 resu.set_etat_qcq() ;
117
118 double* vect = new double[npoints] ;
119 double* cres = new double[npoints] ;
120 for (int i=0; i<npoints; i++) {
121 for (int j=0; j<npoints; j++)
122 vect[j] = 0. ;
123 vect[i] = 1. ;
124 d2sdx2_1d(npoints, &vect, base << TRA_R) ;
125 if (base == R_CHEBU) {
126 mult2_xm1_1d_cheb(npoints, vect, cres) ;
127 for (int j=0; j<npoints; j++)
128 resu.set(j,i) = cres[j] ;
129 }
130 else if (base == R_JACO02) {
131 mult2_xp1_1d(npoints, &vect, base << TRA_R) ;
132 for (int j=0; j<npoints; j++)
133 resu.set(j,i)= vect[j] ;
134 }
135 else {
136 multx2_1d(npoints, &vect, base << TRA_R) ;
137 for (int j=0; j<npoints; j++)
138 resu.set(j,i) = vect[j] ;
139 }
140 }
141 delete [] vect ;
142 delete [] cres ;
143 }
144
145 return *tab[base*max_points + indice] ;
146 }
147
148 ostream& Diff_x2dsdx2::operator>>(ostream& ost) const {
149
150 ost << " x^2 d2 / dx2 " << endl ;
151 return ost ;
152
153 }
154 }