tioga 1.9 → 1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Tioga_README +186 -142
- data/split/Dtable/dtable.c +68 -0
- data/split/Dtable/dvector.h +13 -5
- data/split/Dvector/dvector.c +179 -10
- data/split/Dvector/dvector_intern.h +12 -0
- data/split/Dvector/include/dvector.h +13 -5
- data/split/Dvector/lib/Dvector_extras.rb +19 -0
- data/split/Function/dvector.h +13 -5
- data/split/Tioga/axes.c +100 -16
- data/split/Tioga/dvector.h +13 -5
- data/split/Tioga/figures.c +2 -0
- data/split/Tioga/figures.h +18 -0
- data/split/Tioga/init.c +9 -0
- data/split/Tioga/lib/FigMkr.rb +55 -41
- data/split/Tioga/pdfcolor.c +61 -0
- data/split/Tioga/wrappers.c +11 -0
- data/split/Tioga/wrappers.h +5 -0
- data/tests/Icon_Test.pdf +0 -0
- metadata +32 -28
data/Tioga_README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
This is the README for the Tioga kernel, version 1.
|
1
|
+
This is the README for the Tioga kernel, version 1.10, March 7, 2009.
|
2
2
|
|
3
|
-
Copyright (C) 2005, 2006, 2007, 2008 Bill Paxton
|
4
|
-
Copyright (C) 2007, 2008 Vincent Fourmond, Taro Sato
|
3
|
+
Copyright (C) 2005, 2006, 2007, 2008, 2009 Bill Paxton
|
4
|
+
Copyright (C) 2007, 2008, 2009 Vincent Fourmond, Taro Sato
|
5
5
|
|
6
6
|
This file is part of Tioga.
|
7
7
|
|
@@ -21,68 +21,44 @@ This is the README for the Tioga kernel, version 1.8, April 4, 2008.
|
|
21
21
|
|
22
22
|
<< What's new >>
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
It is now possible to use directly a HLS image using 'color_space' =
|
31
|
-
'HLS' as argument to show_image.
|
32
|
-
|
33
|
-
A new ticks placement algorithm was written. You can benefit from it
|
34
|
-
by saying t.vincent_or_bill = true.
|
35
|
-
|
36
|
-
You can now use the optional argument to show_legend to draw a
|
37
|
-
background (or anything else) to a legend. The information given to
|
38
|
-
the callback will only be accurate if t.measure_legends = true. See
|
39
|
-
samples/plots.rb
|
40
|
-
(Legend_Inside_with_Background_using_legend_background) for more
|
41
|
-
information. Accordingly, you can use legend_text_width to know the
|
42
|
-
legend's text maximal width.
|
43
|
-
|
44
|
-
A new utility function was written, show_grid, that draws a grid
|
45
|
-
according to major and optionally minor ticks of the current axes.
|
46
|
-
|
47
|
-
show_marker can now take arrays for 'marker' and 'color', and cycles
|
48
|
-
through them while plotting.
|
49
|
-
|
50
|
-
Some top-level convenience functions have been added:
|
51
|
-
FigureMaker.exec, FigureMaker.make_pdf,
|
52
|
-
FigureMaker.def_enter_page_function, FigureMaker.page_style that work
|
53
|
-
on the default FigureMaker.
|
24
|
+
Version 1.11 brings in a few new features. First, it is now
|
25
|
+
possible to set the color of axis tick labels - if you love pink axes,
|
26
|
+
you can them fully in Pink, now ;-) ! Check out the
|
27
|
+
x/yaxis_labels_color= accessors. The show_axis/axis_info functions
|
28
|
+
have been updated accordingly, and are now complete.
|
54
29
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
And all corresponding demonstrations in the samples/ directory !
|
30
|
+
Second, a new interpolation function for monotonic interpolations
|
31
|
+
has been added to Dvector (check out the Sampled_pm_cubics sample in
|
32
|
+
samples/plots/plots.rb).
|
59
33
|
|
60
34
|
|
61
35
|
<< Quick Installation of Tioga >>
|
62
36
|
|
63
|
-
Are you feeling lucky? If so, try QUICK_INSTALL. This simply
|
64
|
-
the steps for you that are described below. The install needs to
|
65
|
-
files to the ruby directory. On the Mac, this probably
|
66
|
-
the whole thing with a 'sudo'. For Linux, you
|
67
|
-
Once you've taken care of that, just run the
|
68
|
-
keep your fingers crossed.
|
37
|
+
Are you feeling lucky? If so, try QUICK_INSTALL. This simply
|
38
|
+
does the steps for you that are described below. The install needs to
|
39
|
+
copy some files to the ruby directory. On the Mac, this probably
|
40
|
+
means you need to do the whole thing with a 'sudo'. For Linux, you
|
41
|
+
may have to become root. Once you've taken care of that, just run the
|
42
|
+
QUICK_INSTALL script and keep your fingers crossed.
|
69
43
|
|
70
44
|
You now have the option to run HOME_INSTALL instead, which will
|
71
45
|
install the files to your home directory (no root privileges
|
72
46
|
needed). You just need to set your RUBYLIB environment variable as
|
73
47
|
reminded at the end of the file.
|
74
48
|
|
75
|
-
Please check that there are 0 failures and 0 errors at the end of
|
76
|
-
Then, in your favorite PDF previewer, open the newly
|
77
|
-
and compare it to the prebuilt
|
78
|
-
If it all seems to
|
49
|
+
Please check that there are 0 failures and 0 errors at the end of
|
50
|
+
the test. Then, in your favorite PDF previewer, open the newly
|
51
|
+
created 'tests/Icon_Test.pdf' and compare it to the prebuilt
|
52
|
+
'samples/Icon.pdf'. They should be very similar! If it all seems to
|
53
|
+
be working, go directly to the << Documentation >> section below.
|
79
54
|
|
80
55
|
|
81
56
|
<< Step-by-Step Installation >>
|
82
57
|
|
83
|
-
To get Tioga running, you need to have a working Ruby, a C
|
84
|
-
make, and pdflaxtex. Assuming you've got all that (more
|
85
|
-
connect to the Tioga directory that you just
|
58
|
+
To get Tioga running, you need to have a working Ruby, a C
|
59
|
+
compiler, make, and pdflaxtex. Assuming you've got all that (more
|
60
|
+
later if you don't), connect to the Tioga directory that you just
|
61
|
+
unpacked and do the following:
|
86
62
|
|
87
63
|
[ this has been changed, be careful ! ]
|
88
64
|
|
@@ -92,29 +68,35 @@ connect to the Tioga directory that you just unpacked and do the following:
|
|
92
68
|
make install
|
93
69
|
|
94
70
|
This creates the Makefile, runs it, and finally does the actual
|
95
|
-
installation. The "make install" needs to copy some files to the ruby
|
96
|
-
On the Mac, this probably means you need to do the whole
|
97
|
-
For Linux, you may have to become root.
|
71
|
+
installation. The "make install" needs to copy some files to the ruby
|
72
|
+
directory. On the Mac, this probably means you need to do the whole
|
73
|
+
thing inside a 'sudo'. For Linux, you may have to become root.
|
98
74
|
|
99
|
-
Note that on Linux, the make will compile all the source files. On
|
100
|
-
the tar file includes precompiled versions of everything, so
|
101
|
-
have anything to do. That's okay. Do the whole
|
75
|
+
Note that on Linux, the make will compile all the source files. On
|
76
|
+
the Mac, the tar file includes precompiled versions of everything, so
|
77
|
+
the make won't have anything to do. That's okay. Do the whole
|
78
|
+
sequence anyway just to be safe.
|
102
79
|
|
103
80
|
You now have another option to install: if you replace the line
|
81
|
+
|
104
82
|
ruby extconf.rb
|
83
|
+
|
105
84
|
with
|
85
|
+
|
106
86
|
ruby extconf.rb --home
|
107
|
-
|
108
|
-
|
109
|
-
|
87
|
+
|
88
|
+
it will install the files to your home directory, namely
|
89
|
+
~/lib/ruby. You don't need root privileges to do that, but make sure
|
90
|
+
that you set RUBYLIB=~/lib/ruby somewhere, so that ruby can find it.
|
110
91
|
|
111
92
|
|
112
93
|
|
113
94
|
|
114
95
|
<< Checking The Installation >>
|
115
96
|
|
116
|
-
To make sure at least something works of out the newly installed
|
117
|
-
change directory to your new Tioga folder. Then enter this to
|
97
|
+
To make sure at least something works of out the newly installed
|
98
|
+
stuff, change directory to your new Tioga folder. Then enter this to
|
99
|
+
the shell:
|
118
100
|
|
119
101
|
cd tests
|
120
102
|
ruby ts_Tioga.rb
|
@@ -138,12 +120,14 @@ This should produce something like the following if the install worked:
|
|
138
120
|
|
139
121
|
55 tests, 647 assertions, 0 failures, 0 errors
|
140
122
|
|
141
|
-
[the numbers here are not up-to-date, tests are added everytime a
|
142
|
-
is likely the numbers you see are greater - it
|
123
|
+
[the numbers here are not up-to-date, tests are added everytime a
|
124
|
+
feature is added, so it is likely the numbers you see are greater - it
|
125
|
+
means we're actually working ;-) !]
|
143
126
|
|
144
|
-
These tests ensure that Tioga is accessible and that some of the basic
|
145
|
-
Don't skip the visual check of the newly created
|
146
|
-
If that's ok, there's a good chance your
|
127
|
+
These tests ensure that Tioga is accessible and that some of the basic
|
128
|
+
stuff is working. Don't skip the visual check of the newly created
|
129
|
+
file 'tests/Icon_Test.pdf'. If that's ok, there's a good chance your
|
130
|
+
installation is up and running.
|
147
131
|
|
148
132
|
The next step is to do the tutorial found in the documentation.
|
149
133
|
|
@@ -179,12 +163,12 @@ an email if you'd like a tar file of the images.
|
|
179
163
|
|
180
164
|
<< Open Source >>
|
181
165
|
|
182
|
-
You are welcome to take the Tioga source and do what you want with
|
183
|
-
(within the bounds of the GNU license of course). But don't even
|
184
|
-
asking for support from me for debugging your new stuff!
|
185
|
-
with my own bugs to keep me busy endlessly! But
|
186
|
-
please do let me know so I can try to
|
187
|
-
the fix along with the bug!
|
166
|
+
You are welcome to take the Tioga source and do what you want with
|
167
|
+
it (within the bounds of the GNU license of course). But don't even
|
168
|
+
think about asking for support from me for debugging your new stuff!
|
169
|
+
I have enough trouble with my own bugs to keep me busy endlessly! But
|
170
|
+
if it looks like a bug in Tioga, please do let me know so I can try to
|
171
|
+
fix it. Or even better, let me know the fix along with the bug!
|
188
172
|
|
189
173
|
|
190
174
|
----------------------------------
|
@@ -206,69 +190,121 @@ Here are the old release messages:
|
|
206
190
|
|
207
191
|
--------------------------
|
208
192
|
|
209
|
-
Version 1.
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
193
|
+
Version 1.10 is a minor bug-fix release, the most important one
|
194
|
+
being that save_legend_info now draws markers with the proper line
|
195
|
+
style.
|
196
|
+
|
197
|
+
In addition, a patch was provided by Benjamin ter Kuile
|
198
|
+
<bterkuile@gmail.com> to ease (and quicken) the interpolation of
|
199
|
+
non-uniform 3D-data unto a uniform grid. Thanks !
|
200
|
+
|
201
|
+
--------------------------
|
202
|
+
|
203
|
+
Version 1.9:
|
204
|
+
|
205
|
+
zlib's source has been included again to fix compilation problems on
|
206
|
+
MacOS. The embedded copy will only be used if tioga does not manage to
|
207
|
+
link to the system one.
|
208
|
+
|
209
|
+
It is now possible to use directly a HLS image using 'color_space' =
|
210
|
+
'HLS' as argument to show_image.
|
211
|
+
|
212
|
+
A new ticks placement algorithm was written. You can benefit from it
|
213
|
+
by saying t.vincent_or_bill = true.
|
214
|
+
|
215
|
+
You can now use the optional argument to show_legend to draw a
|
216
|
+
background (or anything else) to a legend. The information given to
|
217
|
+
the callback will only be accurate if t.measure_legends = true. See
|
218
|
+
samples/plots.rb
|
219
|
+
(Legend_Inside_with_Background_using_legend_background) for more
|
220
|
+
information. Accordingly, you can use legend_text_width to know the
|
221
|
+
legend's text maximal width.
|
222
|
+
|
223
|
+
A new utility function was written, show_grid, that draws a grid
|
224
|
+
according to major and optionally minor ticks of the current axes.
|
225
|
+
|
226
|
+
show_marker can now take arrays for 'marker' and 'color', and cycles
|
227
|
+
through them while plotting.
|
228
|
+
|
229
|
+
Some top-level convenience functions have been added:
|
230
|
+
FigureMaker.exec, FigureMaker.make_pdf,
|
231
|
+
FigureMaker.def_enter_page_function, FigureMaker.page_style that work
|
232
|
+
on the default FigureMaker.
|
233
|
+
|
234
|
+
show_plot_without_clipping, obviously a non-clipping version of
|
235
|
+
show_plot.
|
236
|
+
|
237
|
+
And all corresponding demonstrations in the samples/ directory !
|
238
|
+
|
239
|
+
--------------------------
|
240
|
+
|
241
|
+
Version 1.8 is essentially a cleanup/bug fix release. Tioga now
|
242
|
+
compiles with hardly any warnings, thanks to the work by Taro
|
243
|
+
Sato. show_axis can now take a hash instead of a simple location, and
|
244
|
+
can draw axes basically anywhere. See the axes_fun function in
|
245
|
+
samples/plots/plots.rb and show_axis documentation. Few bugs were
|
246
|
+
fixed, in particular the position of ticks with
|
247
|
+
ticks_inside/ticks_outside, and the installation via Rubygems which
|
248
|
+
was broken for such a long time we are ashamed of it.
|
217
249
|
|
218
250
|
|
219
251
|
--------------------------
|
220
252
|
|
221
|
-
Version 1.7 adds an option in legends for markers without any
|
222
|
-
just call save_legend_info with 'line_type' => 'None' in
|
223
|
-
the marker information. It is also now possible to give a
|
224
|
-
to show_marker. The value of the arg can be either
|
225
|
-
or simply the legend text in which case defaults
|
226
|
-
the rest. There is an example of this in
|
227
|
-
in the Legend_Outside figure.
|
253
|
+
Version 1.7 adds an option in legends for markers without any
|
254
|
+
line; just call save_legend_info with 'line_type' => 'None' in
|
255
|
+
addition to the marker information. It is also now possible to give a
|
256
|
+
'legend' argument to show_marker. The value of the arg can be either
|
257
|
+
a legend dictionary or simply the legend text in which case defaults
|
258
|
+
will be supplied for the rest. There is an example of this in
|
259
|
+
samples/plots.rb in the Legend_Outside figure.
|
228
260
|
|
229
261
|
It saw a very significant improvement in that you can now query
|
230
|
-
the exact size of a text typeset by LaTeX, with the function
|
231
|
-
have a look at its documentation, and at the
|
232
|
-
Text_size_with_rotation samples in
|
262
|
+
the exact size of a text typeset by LaTeX, with the function
|
263
|
+
text_size. Please have a look at its documentation, and at the
|
264
|
+
Text_size and Text_size_with_rotation samples in
|
265
|
+
samples/figures/figures.rb.
|
233
266
|
|
234
|
-
The code base was quite moved around so as to facilitate work on a
|
235
|
-
Python version that would share as much code as possible with the Ruby
|
236
|
-
this should not bring user-visible changes (apart, maybe, from
|
237
|
-
problems, but we hope not).
|
267
|
+
The code base was quite moved around so as to facilitate work on a
|
268
|
+
Python version that would share as much code as possible with the Ruby
|
269
|
+
one; this should not bring user-visible changes (apart, maybe, from
|
270
|
+
compilation problems, but we hope not).
|
238
271
|
|
239
272
|
Some bug fixes, including potential stack overflows (unprotected
|
240
|
-
snprintfs), and some new methods of Function. Dvector.fancy_read has
|
241
|
-
reimplemented in C and benchmarked: it should be around three
|
242
|
-
than before.
|
273
|
+
snprintfs), and some new methods of Function. Dvector.fancy_read has
|
274
|
+
been reimplemented in C and benchmarked: it should be around three
|
275
|
+
times faster than before.
|
243
276
|
|
244
277
|
Code should now compile cleanly with Ruby 1.9.
|
245
278
|
|
246
279
|
--------------------------
|
247
280
|
|
248
|
-
|
249
|
-
both axes. Previously Tioga assumed that every major tick mark
|
250
|
-
label. Now the i'th major tick on the axis gets a label
|
251
|
-
mod(i+j,k)==0 where j is the phase and k is the frequency.
|
252
|
-
frequency is naturally 1 so that every major tick gets a
|
253
|
-
The full names for these attributes are
|
254
|
-
xaxis_numeric_label_phase, and similar
|
281
|
+
Version 1.6 adds numeric label "frequency" and "phase" attributes
|
282
|
+
for both axes. Previously Tioga assumed that every major tick mark
|
283
|
+
got a numeric label. Now the i'th major tick on the axis gets a label
|
284
|
+
only if mod(i+j,k)==0 where j is the phase and k is the frequency.
|
285
|
+
The default frequency is naturally 1 so that every major tick gets a
|
286
|
+
label. The full names for these attributes are
|
287
|
+
xaxis_numeric_label_frequency, xaxis_numeric_label_phase, and similar
|
288
|
+
for yaxis.
|
255
289
|
|
256
290
|
--------------------------
|
257
291
|
|
258
|
-
|
259
|
-
will be short. Remember how I killed off the Mac GUI last
|
260
|
-
was one user who couldn't live without it --
|
261
|
-
|
262
|
-
|
263
|
-
it
|
292
|
+
Version 1.5 is mainly Vincent's work, so my part of this release
|
293
|
+
message will be short. Remember how I killed off the Mac GUI last
|
294
|
+
time? Turns out there was one user who couldn't live without it --
|
295
|
+
me! So it's back, but I'm still not making any promises about keeping
|
296
|
+
it alive if Apple does something stupid in coming releases. If you're
|
297
|
+
interested in playing with it in spite of that warning, it's available
|
298
|
+
from my website (http://theory.kitp.ucsb.edu/~paxton/Tioga-1.5.dmg).
|
264
299
|
|
265
300
|
Cheers, Bill
|
266
301
|
|
267
|
-
|
268
|
-
tutorial, which now has local links to images. So the
|
269
|
-
tarball (though the -without-images
|
270
|
-
|
271
|
-
|
302
|
+
[Vincent] Version 1.5 has seen a not-so-small change inthe
|
303
|
+
structure of the tutorial, which now has local links to images. So the
|
304
|
+
images are now included in the tarball (though the -without-images
|
305
|
+
don't have them, for those who have sparse disk space or
|
306
|
+
bandwidth). To get a local copy of the tutorial, just run rdoc and
|
307
|
+
then link doc/images to images using the following commands:
|
272
308
|
|
273
309
|
cd doc; ln -s ../images .
|
274
310
|
|
@@ -279,38 +315,46 @@ doesn't run pdflatex (used by ctioga)
|
|
279
315
|
* a Function#derivative method has been added, that does what you think it
|
280
316
|
does.
|
281
317
|
|
282
|
-
The C code has been heavily tweaked to prevent segfaults on some
|
283
|
-
architectures/distributions, and some samples were added, notably one
|
284
|
-
insets (I'll let you find it !).
|
318
|
+
The C code has been heavily tweaked to prevent segfaults on some
|
319
|
+
architectures/distributions, and some samples were added, notably one
|
320
|
+
for insets (I'll let you find it !).
|
285
321
|
|
286
322
|
Cheers, Vincent
|
287
323
|
|
288
324
|
--------------------------
|
289
325
|
|
290
|
-
|
291
|
-
Please take a moment to go through the new
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
browser
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
326
|
+
Version 1.4 is a major overhaul with particular emphasis on the
|
327
|
+
tioga user interface. Please take a moment to go through the new
|
328
|
+
section of the tutorial titled, CommandLine. It gives a detailed
|
329
|
+
discussion of the new tioga command line interface that replaces
|
330
|
+
irb_tioga and the old mac gui. There is a also new small
|
331
|
+
drag-and-drop application for the Mac called "Tioga Droplet" that
|
332
|
+
takes any file dropped on it and sends it to the new tioga command
|
333
|
+
line interface to have a portfolio created and displayed. There is
|
334
|
+
also a browser-based viewer called Vtioga that JJ Fleck has developed
|
335
|
+
that uses command line tioga to create pdfs, converts them to png's,
|
336
|
+
and displays them in a browser page using Ruby on Rails. And Vincent
|
337
|
+
Fourmond has of course been continuing his development of Ctioga. So
|
338
|
+
there are now several nice options available for tioga user
|
339
|
+
interfaces. [BTW: The old mac gui for tioga is now an orphan; I've
|
340
|
+
decided I can't commit to giving it the amount of attention it seems
|
341
|
+
to need to stay healthy! The current upheaval in the user interface
|
342
|
+
area is a result of my decision that things needed to get simpler. If
|
343
|
+
you've become hopelessly addicted to the old mac gui, I'll happily let
|
344
|
+
you adopt it. Just let me know, and it's yours to maintain and
|
345
|
+
develop as long as your sanity lasts.]
|
346
|
+
|
347
|
+
If you take a look in tioga/samples/plots, you will find a new
|
348
|
+
item: plot_styles.rb. Do you like to use a sans-serif font for your
|
349
|
+
plots? Then 'require plot_styles.rb' in your plot file, 'include
|
350
|
+
MyPlotStyles' in your plot class (the module defined in
|
351
|
+
plot_styles.rb), and call the 'sans_serif_style' method at the
|
352
|
+
beginning of your plot definition (or from your enter_page function,
|
353
|
+
or from your plot class initialization method). Curious about what
|
354
|
+
tioga attributes there are for dealing with the appearance of plots?
|
355
|
+
Scan through the set_default_plot_style method in plot_styles.rb.
|
356
|
+
Want a style that's not in plot_styles.rb? Great! Write it yourself,
|
357
|
+
and share it with the rest of us by sending a message to tioga-users!
|
314
358
|
|
315
359
|
Additionnally, some more classical functionalities have been added:
|
316
360
|
* show_arrow now allows to specify a 'line_style' and justification for
|
data/split/Dtable/dtable.c
CHANGED
@@ -1745,6 +1745,72 @@ VALUE dtable_load(VALUE klass, VALUE str)
|
|
1745
1745
|
return ret;
|
1746
1746
|
}
|
1747
1747
|
|
1748
|
+
/* The following function has been written by Benjamin ter Kuile <bterkuile@gmail.com> */
|
1749
|
+
|
1750
|
+
PRIVATE
|
1751
|
+
/*
|
1752
|
+
* call-seq:
|
1753
|
+
* dtable.interpolate(Xs, Ys, nx, ny, x_start, x_end, y_start, y_end) -> a_dtable
|
1754
|
+
*
|
1755
|
+
* Returns a copy of _dtable_ with the values interpolated given the proper X and Y axis to create a uniform spaced result in the X- and Y
|
1756
|
+
* direction consisting of nx- and ny values for each direction.
|
1757
|
+
*/ VALUE dtable_interpolate(VALUE ary, VALUE x_vec, VALUE y_vec, VALUE nx_val, VALUE ny_val, VALUE xstart_val, VALUE xend_val, VALUE ystart_val, VALUE yend_val)
|
1758
|
+
{
|
1759
|
+
Dtable *d = Get_Dtable(ary);
|
1760
|
+
int nx = NUM2DBL(rb_Integer(nx_val));
|
1761
|
+
int ny = NUM2DBL(rb_Integer(ny_val));
|
1762
|
+
int i, j, num_cols = d->num_cols, num_rows = d->num_rows, last_row = num_rows - 1;
|
1763
|
+
|
1764
|
+
long xsrc_len, ysrc_len;
|
1765
|
+
double *xsrc = Dvector_Data_for_Read(x_vec, &xsrc_len);
|
1766
|
+
double *ysrc = Dvector_Data_for_Read(y_vec, &ysrc_len);
|
1767
|
+
if(xsrc_len != num_cols) rb_raise(rb_eArgError, "Number of x values (%d) do not match the number of columns (%d)", xsrc_len, num_cols);
|
1768
|
+
if(ysrc_len != num_rows) rb_raise(rb_eArgError, "Number of y values (%d) do not match the number of rows (%d)", ysrc_len, num_rows);
|
1769
|
+
VALUE new = dtable_init(dtable_alloc(cDtable), nx, ny);
|
1770
|
+
Dtable *d2 = Get_Dtable(new);
|
1771
|
+
double **src, **dest;
|
1772
|
+
xstart_val = rb_Float(xstart_val);
|
1773
|
+
double xstart = NUM2DBL(rb_Float(xstart_val));
|
1774
|
+
if(xstart < xsrc[0]) rb_raise(rb_eArgError, "The start x value %g is smaller than the bound (%g)", xstart, xsrc[0]);
|
1775
|
+
double xend = NUM2DBL(rb_Float(xend_val));
|
1776
|
+
if(xend > xsrc[xsrc_len-1]) rb_raise(rb_eArgError, "The end x value %g is bigger than the bound (%g)", xend, xsrc[xsrc_len-1]);
|
1777
|
+
double ystart = NUM2DBL(rb_Float(ystart_val));
|
1778
|
+
if(ystart < ysrc[0]) rb_raise(rb_eArgError, "The start y value %g is smaller than the bound (%g)", ystart, ysrc[0]);
|
1779
|
+
double yend = NUM2DBL(rb_Float(yend_val));
|
1780
|
+
if(yend > ysrc[ysrc_len-1]) rb_raise(rb_eArgError, "The end y value %g is bigger than the bound (%g)", yend, ysrc[ysrc_len-1]);
|
1781
|
+
double dx = (xend-xstart)/(nx-1);
|
1782
|
+
double dy = (yend-ystart)/(ny-1);
|
1783
|
+
double xcurrent = xstart;
|
1784
|
+
double ycurrent = ystart;
|
1785
|
+
double intvalue;
|
1786
|
+
int isrc = 1;
|
1787
|
+
int jsrc = 1;
|
1788
|
+
src = d->ptr; dest = d2->ptr;
|
1789
|
+
for (i = 1; i < ny+1; i++) {
|
1790
|
+
while(ysrc[isrc] < ycurrent && ycurrent < ysrc[ysrc_len-1]){
|
1791
|
+
isrc++;
|
1792
|
+
}
|
1793
|
+
for (j = 1; j < nx+1; j++) {
|
1794
|
+
while(xsrc[jsrc] < xcurrent && xcurrent < xsrc[xsrc_len-1]){
|
1795
|
+
jsrc++;
|
1796
|
+
}
|
1797
|
+
intvalue = (
|
1798
|
+
( src[isrc-1][jsrc-1]*(ysrc[isrc]-ycurrent)*(xsrc[jsrc]-xcurrent)) +
|
1799
|
+
( src[isrc][jsrc - 1] * (ycurrent - ysrc[isrc - 1]) * (xsrc[jsrc] - xcurrent) ) +
|
1800
|
+
( src[isrc - 1][jsrc] * (ysrc[isrc] - ycurrent) * (xcurrent - xsrc[jsrc - 1]) ) +
|
1801
|
+
( src[isrc][jsrc] * (ycurrent - ysrc[isrc - 1]) * (xcurrent - xsrc[jsrc - 1]) )
|
1802
|
+
);
|
1803
|
+
intvalue = intvalue / ( (ysrc[isrc] - ysrc[isrc - 1]) * (xsrc[jsrc] - xsrc[jsrc - 1]) );
|
1804
|
+
dest[i-1][j-1] = intvalue;
|
1805
|
+
xcurrent += dx;
|
1806
|
+
}
|
1807
|
+
xcurrent = xstart;
|
1808
|
+
jsrc = 1;
|
1809
|
+
ycurrent += dy;
|
1810
|
+
}
|
1811
|
+
return new;
|
1812
|
+
}
|
1813
|
+
|
1748
1814
|
/*
|
1749
1815
|
* Document-class: Dobjects::Dtable
|
1750
1816
|
*
|
@@ -1901,6 +1967,8 @@ PUBLIC void Init_Dtable() {
|
|
1901
1967
|
rb_define_method(cDtable, "safe_asin!", dtable_safe_asin_bang, 0);
|
1902
1968
|
rb_define_method(cDtable, "safe_acos!", dtable_safe_acos_bang, 0);
|
1903
1969
|
|
1970
|
+
rb_define_method(cDtable, "interpolate", dtable_interpolate, 8);
|
1971
|
+
|
1904
1972
|
/* Marshal : */
|
1905
1973
|
rb_define_method(cDtable, "_dump", dtable_dump, 1);
|
1906
1974
|
rb_define_singleton_method(cDtable, "_load", dtable_load, 1);
|