LORENE
des_coef.C
1/* Basic routine for plot of spectral coefficients.
2 *
3 * (see file graphique.h for the documentation).
4 */
5
6/*
7 * Copyright (c) 1999-2001 Eric Gourgoulhon
8 *
9 * This file is part of LORENE.
10 *
11 * LORENE is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28
29
30
31/*
32 * $Id: des_coef.C,v 1.6 2016/12/05 16:18:06 j_novak Exp $
33 * $Log: des_coef.C,v $
34 * Revision 1.6 2016/12/05 16:18:06 j_novak
35 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36 *
37 * Revision 1.5 2014/10/13 08:53:21 j_novak
38 * Lorene classes and functions now belong to the namespace Lorene.
39 *
40 * Revision 1.4 2014/10/06 15:16:04 j_novak
41 * Modified #include directives to use c++ syntax.
42 *
43 * Revision 1.3 2008/08/19 06:42:00 j_novak
44 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
45 * cast-type operations, and constant strings that must be defined as const char*
46 *
47 * Revision 1.2 2002/10/16 14:36:57 j_novak
48 * Reorganization of #include instructions of standard C++, in order to
49 * use experimental version 3 of gcc.
50 *
51 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
52 * LORENE
53 *
54 * Revision 1.2 1999/12/20 10:57:17 eric
55 * Modif commentaires.
56 *
57 * Revision 1.1 1999/12/10 12:14:37 eric
58 * Initial revision
59 *
60 *
61 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coef.C,v 1.6 2016/12/05 16:18:06 j_novak Exp $
62 *
63 */
64
65
66// C++ headers:
67#include"headcpp.h"
68
69// C headers:
70#include <cmath>
71
72// PGPLOT headers:
73#include <cpgplot.h>
74
75namespace Lorene {
76//******************************************************************************
77
78void des_coef(const double* cf, int n, double pzero,
79 const char* nomx, const char* nomy, const char* title, const char* device,
80 int newgraph, int nxpage, int nypage) {
81
82 float xdes[2], ydes[2] ;
83
84 double pzerol = log10(pzero) ;
85 ydes[0] = float(pzerol) ;
86
87 // Figure frame
88 // ------------
89
90 double xmin = - 1 ;
91 double xmax = n ;
92 double ymin = pzerol ;
93 double ymax = pzerol ;
94
95 for (int i=0; i<n; i++) {
96 double yl = log10(fabs(cf[i])) ;
97 if ( yl > ymax ) ymax = yl ;
98 }
99 double yamp = ymax - ymin ;
100 ymax = ymax + 0.05 * yamp ;
101 ymin = ymin - 0.05 * yamp ;
102
103 if (ymax <= pzerol) ymax = 2*pzerol ; // assure que le cadre existe
104
105 // Graphics display
106 // ----------------
107
108 if ( (newgraph == 1) || (newgraph == 3) ) {
109
110 if (device == 0x0) device = "?" ;
111
112 int ier = cpgbeg(0, device, nxpage, nypage) ;
113 if (ier != 1) {
114 cout << "des_coef: problem in opening PGPLOT display !" << endl ;
115 }
116
117 }
118
119 // Taille des caracteres:
120 float size = float(1.3) ;
121 cpgsch(size) ;
122
123 // Epaisseur des traits:
124 int lepais = 1 ;
125 cpgslw(lepais) ;
126
127 // Fonte axes: caracteres romains:
128 cpgscf(2) ;
129
130 // Figure frame
131 float xmin1 = float(xmin) ;
132 float xmax1 = float(xmax) ;
133 float ymin1 = float(ymin) ;
134 float ymax1 = float(ymax) ;
135 cpgenv(xmin1, xmax1, ymin1, ymax1, 0, 0 ) ;
136 cpglab(nomx, nomy, title) ;
137
138 // Drawing of vertical lines to represent the coefficients
139 for (int i=0; i<n; i++) {
140 int lstyle ;
141 xdes[0] = float( i ) ;
142 xdes[1] = xdes[0] ;
143 if ( fabs(cf[i]) < pzero ) {
144 ydes[1] = float(pzerol) ;
145 lstyle = 1 ;
146 }
147 else {
148 ydes[1] = float( log10(fabs(cf[i])) ) ;
149 if (cf[i] < 0) lstyle = 2 ;
150 else lstyle = 1 ;
151 }
152 cpgsls(lstyle) ; // line en trait plein (lstyle=1)
153 // ou pointilles (lstyle=2)
154 cpgline(2, xdes, ydes) ;
155 }
156
157 cpgsls(1) ; // restitution de la valeur par defaut
158
159 // Closing the graphical output
160 // ----------------------------
161
162 if ( (newgraph == 2) || (newgraph == 3) ) {
163 cpgend() ;
164 }
165
166}
167
168
169}
Cmp log10(const Cmp &)
Basis 10 logarithm.
Definition cmp_math.C:325
Lorene prototypes.
Definition app_hor.h:67