File: des_coef.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (166 lines) | stat: -rw-r--r-- 4,436 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
/* Basic routine for plot of spectral coefficients.
 *
 * (see file graphique.h for the documentation).
 */

/*
 *   Copyright (c) 1999-2001 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
 *
 */


char 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 $" ;


/*
 * $Id: des_coef.C,v 1.5 2014/10/13 08:53:21 j_novak Exp $
 * $Log: des_coef.C,v $
 * Revision 1.5  2014/10/13 08:53:21  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.4  2014/10/06 15:16:04  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.3  2008/08/19 06:42:00  j_novak
 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
 * cast-type operations, and constant strings that must be defined as const char*
 *
 * Revision 1.2  2002/10/16 14:36:57  j_novak
 * Reorganization of #include instructions of standard C++, in order to
 * use experimental version 3 of gcc.
 *
 * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
 * LORENE
 *
 * Revision 1.2  1999/12/20  10:57:17  eric
 * Modif commentaires.
 *
 * Revision 1.1  1999/12/10  12:14:37  eric
 * Initial revision
 *
 *
 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coef.C,v 1.5 2014/10/13 08:53:21 j_novak Exp $
 *
 */


// C++ headers:
#include"headcpp.h"

// C headers:
#include <cmath>

// PGPLOT headers:
#include <cpgplot.h>

namespace Lorene {
//******************************************************************************
 
void des_coef(const double* cf, int n, double pzero,
	      const char* nomx, const char* nomy, const char* title, const char* device, 
	      int newgraph, int nxpage, int nypage) {

    float xdes[2], ydes[2] ;

    double pzerol = log10(pzero) ; 
    ydes[0] = float(pzerol) ; 

    // Figure frame
    // ------------

    double xmin = - 1 ; 
    double xmax = n ; 
    double ymin = pzerol ; 
    double ymax = pzerol ; 
    
    for (int i=0; i<n; i++) {
	double yl = log10(fabs(cf[i])) ;
	if ( yl > ymax ) ymax = yl ; 
    }
    double yamp = ymax - ymin ;
    ymax = ymax + 0.05 * yamp ; 
    ymin = ymin - 0.05 * yamp ; 
    
    if (ymax <= pzerol) ymax = 2*pzerol ;   // assure que le cadre existe
    
    // Graphics display
    // ----------------

    if ( (newgraph == 1) || (newgraph == 3) ) {

	if (device == 0x0) device = "?" ; 
   
	int ier = cpgbeg(0, device, nxpage, nypage) ;
	if (ier != 1) {
	cout << "des_coef: problem in opening PGPLOT display !" << endl ;
	}

    }

    // Taille des caracteres:
    float size = float(1.3) ;
    cpgsch(size) ;
    
    // Epaisseur des traits:
    int lepais = 1 ; 
    cpgslw(lepais) ;
    
    // Fonte axes: caracteres romains:
    cpgscf(2) ;

    // Figure frame
    float xmin1 = float(xmin) ; 
    float xmax1 = float(xmax) ; 
    float ymin1 = float(ymin) ; 
    float ymax1 = float(ymax) ; 
    cpgenv(xmin1, xmax1, ymin1, ymax1, 0, 0 ) ; 
    cpglab(nomx, nomy, title) ;
    
    // Drawing of vertical lines to represent the coefficients
    for (int i=0; i<n; i++) {
	int lstyle ; 
	xdes[0] = float( i ) ;
	xdes[1] = xdes[0] ;
	if ( fabs(cf[i]) < pzero ) {
	    ydes[1] = float(pzerol) ; 
	    lstyle = 1 ; 
	}
	else {
	    ydes[1] = float( log10(fabs(cf[i])) ) ;
	    if (cf[i] < 0) lstyle = 2 ; 
	    else lstyle = 1 ; 
	}
	cpgsls(lstyle) ;	// line en trait plein (lstyle=1) 
			        //   ou pointilles (lstyle=2)
	cpgline(2, xdes, ydes) ; 
    }
       
    cpgsls(1) ;	    // restitution de la valeur par defaut 
    
    // Closing the graphical output
    // ----------------------------

    if ( (newgraph == 2) || (newgraph == 3) ) {    
	cpgend() ; 
    }
    
}


}