pgplot 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/demo/pgdemo15.rb ADDED
@@ -0,0 +1,78 @@
1
+ require 'narray'
2
+ require 'pgplot'
3
+ include NMath
4
+ include Pgplot
5
+ #-----------------------------------------------------------------------
6
+ # Demonstration program for PGPLOT vector field plot.
7
+ #
8
+ # Program to demonstrate the use of PGVECT along with
9
+ # PGCONB by illustrating the flow around a cylinder with circulation.
10
+ #-----------------------------------------------------------------------
11
+ twopi = 2*Math::PI
12
+ blank = -1.0e10
13
+ # number of points in the x and y directions
14
+ nx = 31
15
+ ny = 31
16
+ # cylinder radius
17
+ a = 1.0
18
+ # circulation strength
19
+ gamma = 2.0
20
+ # freestream velocity
21
+ vinf = 1.0
22
+ # max and min x and y
23
+ xmax = 3.0*a
24
+ xmin = -3.0*a
25
+ ymax = 3.0*a
26
+ ymin = -3.0*a
27
+ # point spacing
28
+ dx = (xmax-xmin)/(nx-1)
29
+ dy = (ymax-ymin)/(ny-1)
30
+ # compute the stream function, Cp, and u and v velocities
31
+ a2 = a**2
32
+ x = NArray.sfloat(nx,1).indgen!*dx + xmin
33
+ y = NArray.sfloat(1,ny).indgen!*dy + ymin
34
+ r2 = x**2 + y**2
35
+ r2[(r2.eq 0).where] = 1e-10
36
+ psi = vinf * y * (1-a2/r2) + gamma/twopi*0.5*log(r2/a)
37
+ u = vinf * (1 + a2/r2 - 2*a2*(x/r2)**2) + gamma/twopi * y/r2
38
+ v = vinf * x * (-2*a2*y/r2**2) + gamma/twopi * x/r2
39
+ cp = 1 - (u**2+v**2)/vinf**2
40
+ idx = (r2 < a2).where
41
+ u[idx] =
42
+ v[idx] = blank
43
+ #
44
+ # start drawing
45
+ #
46
+ pgbeg
47
+ pgenv( x[0], x[-1], y[0], y[-1], 1 )
48
+ pgiden
49
+ pglab('X','Y','Flow About a Cylinder with Circulation')
50
+ #
51
+ # contour plot of the stream function (streamlines)
52
+ #
53
+ tr = [ x[0]-dx, dx, 0.0, y[0]-dy, 0.0, dy ]
54
+ level = [ 1.0, 0.5, 0.0, -0.5, -1.0 ]
55
+ pgcont( psi, level, tr )
56
+ #
57
+ # draw cylinder
58
+ #
59
+ pgbbuf
60
+ pgsci(0)
61
+ pgsfs(1)
62
+ pgcirc(0.0, 0.0, a*1.1)
63
+ pgsfs(2)
64
+ pgsci(14)
65
+ pgcirc(0.0, 0.0, a)
66
+ pgsci(1)
67
+ pgebuf
68
+ #
69
+ # vector plot
70
+ #
71
+ pgsah(2, 45.0, 0.7)
72
+ pgsch(0.3)
73
+ tr = [ x[0], dx, 0.0, y[0], 0.0, dy ]
74
+ pgvect( u[1..-2,1..-2], v[1..-2,1..-2], 0.0, 0, tr, -1.0e10 )
75
+ pgsch(1.0)
76
+ #
77
+ # finish
78
+ #
data/demo/pgdemo3.rb ADDED
@@ -0,0 +1,188 @@
1
+ require 'narray'
2
+ require 'pgplot'
3
+ include Pgplot
4
+ include NMath
5
+
6
+ def main
7
+ exit unless pgbeg('?',1,1)
8
+ print " Routine PGCONT\n"
9
+ pgex31
10
+ print " Routine PGCONS\n"
11
+ pgex32
12
+ print " Routine PGCONB\n"
13
+ pgex33
14
+ print " Routine PGCONT with PGCONL labels\n"
15
+ pgex36
16
+ #print " Routine PGCONX with arrow labels\n"
17
+ #pgex37
18
+ #print " Routine PGCONX\n"
19
+ #pgex34
20
+ print " Routine PGCONF\n"
21
+ pgexx1
22
+ pgend
23
+ end
24
+
25
+ # ====== Utility ======
26
+
27
+ class PgLinestyle
28
+ attr_accessor :width
29
+ attr_accessor :color
30
+ attr_accessor :style
31
+
32
+ def initialize(opt=nil)
33
+ @width = 1
34
+ @color = 1
35
+ @style = 1
36
+ if opt.is_a?(Hash)
37
+ @width = opt[:width] || @width
38
+ @width = opt['width'] || @width
39
+ @color = opt[:color] || @color
40
+ @color = opt['color'] || @color
41
+ @style = opt[:style] || @style
42
+ @style = opt['style'] || @style
43
+ end
44
+ end
45
+
46
+ def set
47
+ pgslw @width
48
+ pgsci @color
49
+ pgsls @style
50
+ end
51
+ end # class PgLinestyle
52
+
53
+ NC=21
54
+ Pgline_default = PgLinestyle.new
55
+ $sty = (1..NC).collect{|i|
56
+ if i<10
57
+ x = PgLinestyle.new(:width =>1, :color =>2, :style =>2)
58
+ else
59
+ x = PgLinestyle.new(:width =>1, :color =>3, :style =>1)
60
+ end
61
+ if i%5==0
62
+ x.width = 5
63
+ end
64
+ x
65
+ }
66
+ i = NArray.sfloat(40,1).indgen!(1)
67
+ j = NArray.sfloat(1,40).indgen!(1)
68
+ $f = cos( 0.3*sqrt(i*2)-0.4*j/3 ) * cos( 0.4*i/3 ) + (i-j)/40.0
69
+ $lv = NArray.sfloat(NC).indgen!*($f.max-$f.min)/NC+$f.min
70
+ #NArray.span($f.minmax,NC)
71
+
72
+ # ====== Exsample routine ======
73
+
74
+ def pgex31
75
+ pgpage
76
+ pgsvp(0.05,0.95,0.05,0.95)
77
+ pgswin(1.0,40.0,1.0,40.0)
78
+ pgbox('bcts',0.0,0,'bcts',0.0,0)
79
+ pgmtxt('t',1.0,0.0,0.0,'Contouring using PGCONT')
80
+ pgbbuf
81
+ for i in 0...NC
82
+ $sty[i].set
83
+ pgcont $f, $lv[i]
84
+ end
85
+ Pgline_default.set
86
+ pgebuf
87
+ end
88
+
89
+ def pgex32
90
+ pgpage
91
+ pgsvp(0.05,0.95,0.05,0.95)
92
+ pgswin(1.0,40.0,1.0,40.0)
93
+ pgbox('bcts',0.0,0,'bcts',0.0,0)
94
+ pgmtxt('t',1.0,0.0,0.0,'Contouring using PGCONS')
95
+ pgbbuf
96
+ for i in 0...NC
97
+ $sty[i].set
98
+ pgcons $f, $lv[i]
99
+ end
100
+ Pgline_default.set
101
+ pgebuf
102
+ end
103
+
104
+ def pgex33
105
+ pgpage
106
+ pgsvp(0.05,0.95,0.05,0.95)
107
+ pgswin(1.0,40.0,1.0,40.0)
108
+ pgbox('bcts',0.0,0,'bcts',0.0,0)
109
+ pgmtxt('t',1.0,0.0,0.0,'Contouring using PGCONB')
110
+ pgbbuf
111
+
112
+ blank = -65536.0
113
+
114
+ f = $f.dup
115
+ i = NArray.sfloat(40,1).indgen!(1)
116
+ j = NArray.sfloat(1,40).indgen!(1)
117
+ r = sqrt((i-20.5)**2 + (j-20.5)**2)
118
+ idx = ((r>20).or(r<3.0)).where
119
+ f[idx] = blank
120
+ pgsci 1
121
+ pgpt( (i+NArray.int(1,40))[idx], (j+NArray.int(40,1))[idx], 1 )
122
+
123
+ for i in 0...NC
124
+ $sty[i].set
125
+ pgconb f, $lv[i], blank
126
+ end
127
+ Pgline_default.set
128
+ pgebuf
129
+ end
130
+
131
+ def pgex36
132
+ pgpage
133
+ pgsvp(0.05,0.95,0.05,0.95)
134
+ pgswin(1.0,40.0,1.0,40.0)
135
+ pgbox('bcts',0.0,0,'bcts',0.0,0)
136
+ pgmtxt('t',1.0,0.0,0.0,'Contouring using PGCONT and PGCONL labels')
137
+ pgbbuf
138
+
139
+ for i in 0...NC
140
+ $sty[i].set
141
+ pgcons $f, $lv[i]
142
+ end
143
+ pgslw 1
144
+ pgsls 1
145
+ 1.step(20,2) {|i|
146
+ pgsci $sty[i].color
147
+ pgconl $f,$lv[i],"%2i"%(i+1),16,8
148
+ }
149
+ Pgline_default.set
150
+ pgebuf
151
+ end
152
+
153
+ def pgexx1
154
+ nx=ny=51
155
+ c = [3.0, 3.2, 3.5, 3.6, 3.766413, 4.0 ,5.0, 10.0, 100.0]
156
+ xmin =-2.0
157
+ xmax = 2.0
158
+ ymin =-2.0
159
+ ymax = 2.0
160
+ mu = 0.3
161
+ dx = (xmax-xmin)/(nx-1)
162
+ dy = (ymax-ymin)/(ny-1)
163
+ tr = [xmin-dx, dx, 0.0, ymin-dy, 0.0, dy]
164
+ x = tr[0] + NArray.sfloat(nx,1).indgen!(1)*tr[1]
165
+ y = tr[3] + NArray.sfloat(1,ny).indgen!(1)*tr[5]
166
+ z = (1.0-mu)*(2.0/sqrt((x-mu)**2+y**2)+(x-mu)**2+y**2) +
167
+ mu*(2.0/sqrt((x+1.0-mu)**2+y**2)+(x+1.0-mu)**2+y**2)
168
+
169
+ pgpage
170
+ pgvstd
171
+ pgwnad(xmin, xmax, ymin, ymax)
172
+ pgsfs(1)
173
+ for i in 0..c.size-2
174
+ r = 0.5+0.5*(i-1)/(c.size-1)
175
+ pgscr(i+10, r, r, r)
176
+ pgsci(i+10)
177
+ pgconf(z,c[i]..c[i+1],tr)
178
+ end
179
+ pgsci(3)
180
+ pgcont(z,c,tr)
181
+ pgsci(1)
182
+ pgsch(0.6)
183
+ pgbox('bctsin',1.0,10,'bctsinv',1.0,10)
184
+ pgsch(1.0)
185
+ pgmtxt('t',1.0,0.0,0.0,'Contour filling using PGCONF')
186
+ end
187
+
188
+ main
data/demo/pgdemo4.rb ADDED
@@ -0,0 +1,80 @@
1
+ require 'narray'
2
+ require 'pgplot'
3
+ include Pgplot
4
+ include NMath
5
+
6
+ def setvp
7
+ pgsvp(0.0, 1.0, 0.0, 1.0)
8
+ vpx1, vpx2, vpy1, vpy2 = pgqvp(1)
9
+ d = [vpx2-vpx1, vpy2-vpy1].min/40.0
10
+ vpx1 = vpx1 + 5.0*d
11
+ vpx2 = vpx2 - 2.0*d
12
+ vpy1 = vpy1 + 8.0*d
13
+ vpy2 = vpy2 - 2.0*d
14
+ pgvsiz(vpx1, vpx2, vpy1, vpy2)
15
+ end
16
+
17
+ def palett contra,bright
18
+ rl =[-0.5, 0.0, 0.17, 0.33, 0.50, 0.67, 0.83, 1.0, 1.7]
19
+ rr =[ 0.0, 0.0, 0.0, 0.0, 0.6, 1.0, 1.0, 1.0, 1.0]
20
+ rg =[ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.6, 0.0, 1.0]
21
+ rb =[ 0.0, 0.3, 0.8, 1.0, 0.3, 0.0, 0.0, 0.0, 1.0]
22
+ pgctab(rl, rr, rg, rb)
23
+ end
24
+
25
+ exit if pgopen('?') < 1
26
+ printf "PGPLOT device type: %s\n", pgqinf('TYPE')
27
+ c1,c2 = pgqcir()
28
+ printf "Number of color indices used for image: %d\n", nc=[0,c2-c1+1].max
29
+ exit if nc<8
30
+
31
+ nx = 64
32
+ ny = 64
33
+ x = NArray.sfloat(nx,1).indgen!(1)
34
+ y = NArray.sfloat(1,ny).indgen!(1)
35
+ f = cos( sqrt(x*(80.0/nx))*0.6 - y*16.0/(3.0*ny) ) *
36
+ cos( x*16.0/(3.0*nx) ) +
37
+ (x/nx - y/ny) + sin(sqrt(x**2+y**2))*0.05
38
+
39
+ pgpage
40
+ setvp
41
+ pgwnad(0.0, 1.0+nx, 0.0, 1.0+ny)
42
+ bright = 0.5
43
+ contra = 1.0
44
+ palett(contra, bright)
45
+ pgimag(f)
46
+ pgmtxt('t',1.0,0.0,0.0,'PGIMAG, PGWEDG, and PGCTAB')
47
+ pgsch(0.6)
48
+ pgbox('bcntsi',0.0,0,'bcntsiv',0.0,0)
49
+ pgmtxt('b',3.0,1.0,1.0,'pixel number')
50
+ pgwedg('BI', 4.0, 5.0, f.min,f.max, 'pixel value')
51
+ pgsch(1.0)
52
+
53
+ angle = 120.0/57.29578
54
+ c = cos(angle)
55
+ s = sin(angle)
56
+ tr = NArray[ -c-s, 2.0*c/nx, 2.0*s/ny,
57
+ -c+s, -2.0*s/nx, 2.0*c/ny ]
58
+
59
+ pgpage
60
+ setvp
61
+ pgwnad(-1.0, 1.0, -1.0, 1.0)
62
+ pgsci(1)
63
+ bright = 0.5
64
+ contra = 1.0
65
+ palett(contra, bright)
66
+ pgimag(f,nil,tr)
67
+ pgsci(1)
68
+
69
+ pgcont(f,NArray.sfloat(21).indgen!*(f.max-f.min)/21+f.min, tr)
70
+ pgsls(1)
71
+ pgslw(1)
72
+ pgsci(1)
73
+ #outlin(1,mxi,1,mxj,tr)
74
+ pgmtxt('t',1.0,0.0,0.0,'PGIMAG, PGCONT and PGWEDG')
75
+ pgsch(0.6)
76
+ pgbox('bctsn',0.0,0,'bctsn',0.0,0)
77
+ pgwedg('BI', 4.0, 5.0, f.min, f.max, 'pixel value')
78
+ pgsch(1.0)
79
+
80
+ pgclos
data/demo/pgdemo9.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'narray'
2
+ require 'pgplot'
3
+ include Pgplot
4
+ include NMath
5
+
6
+ n=64
7
+ ncol=32
8
+ nlev=9
9
+
10
+ pgbeg
11
+
12
+ i = NArray.sfloat(n,1).indgen!(1)
13
+ j = NArray.sfloat(1,n).indgen!(1)
14
+ f = cos(0.6*sqrt(i*2)-(0.4/3)*j) * cos((0.4/3)*i) + (i-j)/n
15
+ fmin = f.min
16
+ fmax = f.max
17
+
18
+ ia = (f-fmin)/(fmax-fmin)*(ncol-1)+16
19
+
20
+ ci1,ci2 = pgqcol
21
+ if ci2 < 15+ncol
22
+ raise 'This program requires a device with at least %d colors'%(15+ncol)
23
+ end
24
+
25
+ pgpage
26
+ pgscr(0, 0.0, 0.3, 0.2)
27
+ pgsvp(0.05,0.95,0.05,0.95)
28
+ pgwnad(0.0, 1.0, 0.0, 1.0)
29
+
30
+ for i in 1..ncol
31
+ r = 0.8*(i-1)/(ncol-1) + 0.2
32
+ g = 2.0*(i-1-ncol/2)/(ncol-1)
33
+ g = 0 if g<0
34
+ b = 0.2 + 0.4*(ncol-i)/ncol
35
+ pgscr(i+15, r, g, b)
36
+ end
37
+
38
+ pgpixl(ia,0,1,0,1)
39
+ pgsci(1)
40
+ pgmtxt('t',1.0,0.0,0.0,'Test of PGPIXL')
41
+ pgbox('bcnts',0.0,0,'bcnts',0.0,0)
42
+
43
+ clev = NArray.sfloat(nlev).indgen!(1) * ((fmax-fmin)/nlev) + fmin
44
+ pgcont(f, clev, NArray[-1.0, 1, 0, -1, 0, 1]/(n-1))
data/ext/cogen.rb ADDED
@@ -0,0 +1,158 @@
1
+ # cogen.rb : Code generation script for Ruby/PGPLOT
2
+ #
3
+ # Copyright (c) 2000,2001 Masahiro TANAKA <masa@ir.isas.ac.jp>
4
+ #
5
+ # This program is free software.
6
+ # You can distribute/modify this program
7
+ # under the same terms as Ruby itself.
8
+ # NO WARRANTY.
9
+
10
+ $pgfuncs = %w(
11
+
12
+ pgend::
13
+ pgbbuf::
14
+ pgebuf::
15
+ pgpage::
16
+ pgpap:1,1:
17
+ pgupdt::
18
+ pgpanl:1,1:
19
+ pgclos::
20
+
21
+ pgbox:2,1,0,2,1,0:
22
+ pgtbox:2,1,0,2,1,0:
23
+ pgvsiz:1,1,1,1:
24
+ pgvstd::
25
+ pgwnad:1,1,1,1:
26
+ pgsubp:0,0:
27
+
28
+ pgwedg:2,1,1,1,1,2:
29
+
30
+ # Draw Funcs
31
+ pgdraw:1,1:
32
+ pgmove:1,1:
33
+ pgrect:1,1,1,1:
34
+ pgarro:1,1,1,1:
35
+ pgcirc:1,1,1:
36
+ pgpt1:1,1,0:
37
+ pgerr1:0,1,1,1,1:
38
+ pglab:2,2,2:
39
+ pgptxt:1,1,1,1,2:
40
+ pgtext:1,1,2:
41
+ pgmtxt:2,1,1,1,2:
42
+ pgetxt::
43
+
44
+ pgiden::
45
+ pgldev::
46
+ pgsave::
47
+ pgunsa::
48
+ pgeras::
49
+
50
+ # Set Funcs
51
+ pgsch:1:
52
+ pgscf:0:
53
+ pgsci:0:
54
+ pgsfs:0:
55
+ pgsls:0:
56
+ pgslw:0:
57
+ pgsclp:0:
58
+ pgsitf:0:
59
+ pgslct:0:
60
+ pgstbg:0:
61
+ pgscr:0,1,1,1:
62
+ pgshls:0,1,1,1:
63
+ pgsah:0,1,1:
64
+ pgscrl:1,1:
65
+ pgscir:0,0:
66
+ pgscrn:0,2:0
67
+ pgshs:1,1,1:
68
+ pgsvp:1,1,1,1:
69
+ pgswin:1,1,1,1:
70
+
71
+ # Query Funcs
72
+ pgqch::1
73
+ pgqcf::0
74
+ pgqci::0
75
+ pgqcs:0:1,1
76
+ pgqfs::0
77
+ pgqls::0
78
+ pgqlw::0
79
+ pgqclp::0
80
+ pgqid::0
81
+ pgqitf::0
82
+ pgqndt::0
83
+ pgqtbg::0
84
+ pgqcr:0:1,1,1
85
+ pgqvp:0:1,1,1,1
86
+ pgqwin::1,1,1,1
87
+ pgqcol::0,0
88
+ pgqcir::0,0
89
+ pgqpos::1,1
90
+ pgqvsz:0:1,1,1,1
91
+
92
+ ).grep(/:.*:/).collect{|i| i.split(":",3)}
93
+
94
+
95
+ def pgfuncgen(name, inp, out)
96
+ inp = inp.split(",").collect{|i| i.to_i}
97
+ out = out.split(",").collect{|i| i.to_i}
98
+ ninp = inp.size
99
+ nout = out.size
100
+ # int->0, float->1
101
+ val2 = ["NUM2INT","NUM2DBL","StringValuePtr"]
102
+ type = ["int","float",nil]
103
+ conv = ["INT2NUM","rb_float_new",nil]
104
+ # Initialize Array
105
+ prot = ["VALUE obj"]
106
+ pass = []
107
+ vars = []
108
+ retn = []
109
+ inp.each_with_index { |i,x|
110
+ prot << "VALUE arg#{x}"
111
+ pass << "#{val2[i]}(arg#{x})"
112
+ }
113
+ out.each_with_index { |i,x|
114
+ vars << "#{type[i]} var#{x};"
115
+ pass << "&var#{x}"
116
+ retn << "#{conv[i]}(var#{x})"
117
+ }
118
+ if nout==0 then
119
+ retn = "Qtrue";
120
+ elsif nout>1 then
121
+ retn = "rb_ary_new3(#{nout},"+retn.join(",")+")"
122
+ else
123
+ retn = retn.join("")
124
+ end
125
+
126
+ vars = vars.join("")
127
+ prot = prot.join(",")
128
+ pass = pass.join(",")
129
+
130
+ return "
131
+ static VALUE
132
+ rb_pgplot_#{name}(#{prot})
133
+ {
134
+ #{vars}
135
+ c#{name}(#{pass});
136
+ return #{retn};
137
+ }
138
+ "
139
+ end
140
+
141
+
142
+ def cogen_pgplot
143
+ fin = open("rb_pgplot.c.in","r")
144
+ fout = open("rb_pgplot.c","w")
145
+ while l = fin.gets
146
+ if /--- auto-generated funcs will be placed here ---/ =~ l
147
+ $pgfuncs.each{|x| fout.print pgfuncgen(*x)}
148
+ elsif /--- auto-generated defs will be placed here ---/ =~ l
149
+ $pgfuncs.each{|x|
150
+ n = x[1].split(",").size
151
+ fout.print " rb_define_module_function(mPgplot,\"#{x[0]}\",rb_pgplot_#{x[0]},#{n});\n"}
152
+ else
153
+ fout.print
154
+ end
155
+ end
156
+ end
157
+
158
+ cogen_pgplot
data/ext/depend ADDED
@@ -0,0 +1,4 @@
1
+ rb_pgplot.c: rb_pgplot.c.in cogen.rb
2
+ $(RUBY) cogen.rb
3
+
4
+ rb_pgplot.o: rb_pgplot.c $(hdrdir)/ruby.h
data/ext/extconf.rb ADDED
@@ -0,0 +1,124 @@
1
+ # extconf.rb : Configure script for Ruby/PGPLOT
2
+ #
3
+ # Copyright (c) 2000,2001 Masahiro TANAKA <masa@ir.isas.ac.jp>
4
+ #
5
+ # This program is free software.
6
+ # You can distribute/modify this program
7
+ # under the same terms as Ruby itself.
8
+ # NO WARRANTY.
9
+ #
10
+ # usage: ruby extconf.rb [configure options]
11
+
12
+ # Narray is now Gem based, so require rubygems
13
+ # so that we can use Gem class to find narray.
14
+ require "mkmf"
15
+
16
+ #$DEBUG = true
17
+
18
+ # configure options:
19
+ # --with-x11-dir=path
20
+ # --with-x11-include=path
21
+ # --with-x11-lib=path
22
+ dir_config("x11")
23
+
24
+ # configure options:
25
+ # --with-pgplot-dir=path
26
+ # --with-pgplot-include=path
27
+ # --with-pgplot-lib=path
28
+ dir_config("pgplot")
29
+
30
+ # Otherwise you can also specify:
31
+ # --with-opt-dir=path
32
+ # --with-opt-include=path
33
+ # --with-opt-lib=path
34
+
35
+ # Check PGPLOT Header
36
+ exit unless have_header("cpgplot.h")
37
+
38
+ def find_dir_w_file(d,h)
39
+ g = Dir.glob(RbConfig.expand(d+"/"+h))
40
+ File.dirname(g.last) if g and !g.empty?
41
+ end
42
+
43
+ def find_dir_in_gemspec
44
+ begin
45
+ require 'rubygems'
46
+ if gemspec=Gem::Specification.find_by_path('narray')
47
+ return File.join(gemspec.full_gem_path, gemspec.require_path)
48
+ end
49
+ rescue
50
+ end
51
+ nil
52
+ end
53
+
54
+ # Check NArray
55
+ gems_dir="$(rubylibprefix)/gems/$(ruby_version)/gems/"
56
+ narray_d="narray-0.[56].*"
57
+ narray_h="narray.h"
58
+ if narray_h_dir =
59
+ find_dir_in_gemspec ||
60
+ find_dir_w_file("../"+narray_d,narray_h) ||
61
+ find_dir_w_file(gems_dir+narray_d,narray_h) ||
62
+ find_dir_w_file(CONFIG['sitearchdir'],narray_h) ||
63
+ find_dir_w_file(CONFIG['archdir'],narray_h)
64
+ $CPPFLAGS = " -I#{narray_h_dir} " + $CPPFLAGS
65
+ end
66
+ exit unless have_header("narray.h")
67
+
68
+ if RUBY_PLATFORM =~ /cygwin|mingw/
69
+ $LDFLAGS = " -L#{CONFIG['sitearchdir']} "+$LDFLAGS
70
+ exit unless have_library("narray","na_make_object")
71
+ end
72
+
73
+ # Check FORTRAN Libraries
74
+ #
75
+ # SUN WorkShop FORTRAN 77 compiler ver5.0
76
+ # configure options: --with-sunws
77
+ if with_config("sunws")
78
+ $libs = "-lM77 -lsunmath "+$libs
79
+ exit unless find_library("F77", "f77_init", "/opt/SUNWspro/lib")
80
+ $defs.push "-DSPARC_FORTRAN"
81
+ #
82
+ # GNU FORTRAN v4
83
+ elsif have_library("gfortran")
84
+ $CFLAGS = "-Wall "+$CFLAGS
85
+ $defs.push "-DGNU_FORTRAN"
86
+ #
87
+ # GNU FORTRAN v3
88
+ elsif have_library("g77")
89
+ $CFLAGS = "-Wall "+$CFLAGS
90
+ $defs.push "-DGNU_FORTRAN"
91
+ else
92
+ puts "failed"
93
+ exit
94
+ end
95
+
96
+ # Check GrWin Library (for cygwin (and mingw32?))
97
+ # configure options: --with-grwin
98
+ if with_config("grwin")
99
+ #$LDFLAGS = "-Wl,--subsystem,console "+$LDFLAGS
100
+ if RUBY_PLATFORM =~ /cygwin|mingw/
101
+ $libs += " -mwindows"
102
+ end
103
+ exit unless have_library("GrWin", "GWinit")
104
+ end
105
+ #
106
+ # Check X11 Library
107
+ have_library("X11", "XOpenDisplay")
108
+
109
+ # Check PNG Library
110
+ libs_save = $libs
111
+ $libs = append_library($libs, "z")
112
+ if !have_library("png","png_create_write_struct")
113
+ $libs = libs_save
114
+ end
115
+
116
+ # Check PGPLOT Library
117
+ $libs = append_library($libs, "pgplot")
118
+ exit unless find_library( "cpgplot", "cpgbeg", "/usr/lib",
119
+ "/usr/local/lib", "/usr/local/pgplot" )
120
+
121
+ $objs = %w(rb_pgplot.o kwarg.o)
122
+
123
+ # Generate Makefile
124
+ create_makefile("pgplot")