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
28char des_coef_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coef.C,v 1.5 2014/10/13 08:53:21 j_novak Exp $" ;
29
30
31/*
32 * $Id: des_coef.C,v 1.5 2014/10/13 08:53:21 j_novak Exp $
33 * $Log: des_coef.C,v $
34 * Revision 1.5 2014/10/13 08:53:21 j_novak
35 * Lorene classes and functions now belong to the namespace Lorene.
36 *
37 * Revision 1.4 2014/10/06 15:16:04 j_novak
38 * Modified #include directives to use c++ syntax.
39 *
40 * Revision 1.3 2008/08/19 06:42:00 j_novak
41 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
42 * cast-type operations, and constant strings that must be defined as const char*
43 *
44 * Revision 1.2 2002/10/16 14:36:57 j_novak
45 * Reorganization of #include instructions of standard C++, in order to
46 * use experimental version 3 of gcc.
47 *
48 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
49 * LORENE
50 *
51 * Revision 1.2 1999/12/20 10:57:17 eric
52 * Modif commentaires.
53 *
54 * Revision 1.1 1999/12/10 12:14:37 eric
55 * Initial revision
56 *
57 *
58 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coef.C,v 1.5 2014/10/13 08:53:21 j_novak Exp $
59 *
60 */
61
62
63// C++ headers:
64#include"headcpp.h"
65
66// C headers:
67#include <cmath>
68
69// PGPLOT headers:
70#include <cpgplot.h>
71
72namespace Lorene {
73//******************************************************************************
74
75void des_coef(const double* cf, int n, double pzero,
76 const char* nomx, const char* nomy, const char* title, const char* device,
77 int newgraph, int nxpage, int nypage) {
78
79 float xdes[2], ydes[2] ;
80
81 double pzerol = log10(pzero) ;
82 ydes[0] = float(pzerol) ;
83
84 // Figure frame
85 // ------------
86
87 double xmin = - 1 ;
88 double xmax = n ;
89 double ymin = pzerol ;
90 double ymax = pzerol ;
91
92 for (int i=0; i<n; i++) {
93 double yl = log10(fabs(cf[i])) ;
94 if ( yl > ymax ) ymax = yl ;
95 }
96 double yamp = ymax - ymin ;
97 ymax = ymax + 0.05 * yamp ;
98 ymin = ymin - 0.05 * yamp ;
99
100 if (ymax <= pzerol) ymax = 2*pzerol ; // assure que le cadre existe
101
102 // Graphics display
103 // ----------------
104
105 if ( (newgraph == 1) || (newgraph == 3) ) {
106
107 if (device == 0x0) device = "?" ;
108
109 int ier = cpgbeg(0, device, nxpage, nypage) ;
110 if (ier != 1) {
111 cout << "des_coef: problem in opening PGPLOT display !" << endl ;
112 }
113
114 }
115
116 // Taille des caracteres:
117 float size = float(1.3) ;
118 cpgsch(size) ;
119
120 // Epaisseur des traits:
121 int lepais = 1 ;
122 cpgslw(lepais) ;
123
124 // Fonte axes: caracteres romains:
125 cpgscf(2) ;
126
127 // Figure frame
128 float xmin1 = float(xmin) ;
129 float xmax1 = float(xmax) ;
130 float ymin1 = float(ymin) ;
131 float ymax1 = float(ymax) ;
132 cpgenv(xmin1, xmax1, ymin1, ymax1, 0, 0 ) ;
133 cpglab(nomx, nomy, title) ;
134
135 // Drawing of vertical lines to represent the coefficients
136 for (int i=0; i<n; i++) {
137 int lstyle ;
138 xdes[0] = float( i ) ;
139 xdes[1] = xdes[0] ;
140 if ( fabs(cf[i]) < pzero ) {
141 ydes[1] = float(pzerol) ;
142 lstyle = 1 ;
143 }
144 else {
145 ydes[1] = float( log10(fabs(cf[i])) ) ;
146 if (cf[i] < 0) lstyle = 2 ;
147 else lstyle = 1 ;
148 }
149 cpgsls(lstyle) ; // line en trait plein (lstyle=1)
150 // ou pointilles (lstyle=2)
151 cpgline(2, xdes, ydes) ;
152 }
153
154 cpgsls(1) ; // restitution de la valeur par defaut
155
156 // Closing the graphical output
157 // ----------------------------
158
159 if ( (newgraph == 2) || (newgraph == 3) ) {
160 cpgend() ;
161 }
162
163}
164
165
166}
Cmp log10(const Cmp &)
Basis 10 logarithm.
Definition cmp_math.C:322
void des_coef(const double *cf, int n, double pzero, const char *nomx, const char *nomy, const char *title, const char *device=0x0, int newgraph=3, int nxpage=1, int nypage=1)
Basic routine for drawing spectral coefficients.
Lorene prototypes.
Definition app_hor.h:64