tioga 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/Tioga_README +372 -0
  2. data/lgpl.txt +504 -0
  3. data/split/Dtable/defs.h +33 -0
  4. data/split/Dtable/dtable.c +1928 -0
  5. data/split/Dtable/dtable_intern.h +144 -0
  6. data/split/Dtable/dvector.h +61 -0
  7. data/split/Dtable/extconf.rb +4 -0
  8. data/split/Dtable/include/dtable.h +35 -0
  9. data/split/Dtable/lib/Dtable_extras.rb +90 -0
  10. data/split/Dtable/namespace.h +47 -0
  11. data/split/Dtable/safe_double.h +104 -0
  12. data/split/Dtable/symbols.c +92 -0
  13. data/split/Dtable/symbols.h +52 -0
  14. data/split/Dvector/defs.h +33 -0
  15. data/split/Dvector/dvector.c +5486 -0
  16. data/split/Dvector/dvector_intern.h +142 -0
  17. data/split/Dvector/extconf.rb +4 -0
  18. data/split/Dvector/include/dvector.h +61 -0
  19. data/split/Dvector/lib/Dvector_extras.rb +328 -0
  20. data/split/Dvector/lib/Numeric_extras.rb +134 -0
  21. data/split/Dvector/namespace.h +47 -0
  22. data/split/Dvector/safe_double.h +104 -0
  23. data/split/Dvector/symbols.c +92 -0
  24. data/split/Dvector/symbols.h +52 -0
  25. data/split/Flate/defs.h +33 -0
  26. data/split/Flate/extconf.rb +19 -0
  27. data/split/Flate/flate.c +156 -0
  28. data/split/Flate/flate_intern.h +97 -0
  29. data/split/Flate/include/flate.h +98 -0
  30. data/split/Flate/namespace.h +47 -0
  31. data/split/Flate/safe_double.h +104 -0
  32. data/split/Flate/symbols.c +92 -0
  33. data/split/Flate/symbols.h +52 -0
  34. data/split/Function/defs.h +33 -0
  35. data/split/Function/dvector.h +61 -0
  36. data/split/Function/extconf.rb +4 -0
  37. data/split/Function/function.c +988 -0
  38. data/split/Function/joint_qsort.c +258 -0
  39. data/split/Function/lib/Function_extras.rb +44 -0
  40. data/split/Function/namespace.h +47 -0
  41. data/split/Function/safe_double.h +104 -0
  42. data/split/Function/symbols.c +92 -0
  43. data/split/Function/symbols.h +52 -0
  44. data/split/Tioga/axes.c +774 -0
  45. data/split/Tioga/defs.h +33 -0
  46. data/split/Tioga/dtable.h +35 -0
  47. data/split/Tioga/dvector.h +61 -0
  48. data/split/Tioga/extconf.rb +4 -0
  49. data/split/Tioga/figures.c +672 -0
  50. data/split/Tioga/figures.h +855 -0
  51. data/split/Tioga/flate.h +98 -0
  52. data/split/Tioga/init.c +524 -0
  53. data/split/Tioga/lib/Arcs_and_Circles.rb +64 -0
  54. data/split/Tioga/lib/ColorConstants.rb +274 -0
  55. data/split/Tioga/lib/Colorbars.rb +10 -0
  56. data/split/Tioga/lib/Colormaps.rb +105 -0
  57. data/split/Tioga/lib/Coordinate_Conversions.rb +194 -0
  58. data/split/Tioga/lib/Creating_Paths.rb +94 -0
  59. data/split/Tioga/lib/Doc.rb +91 -0
  60. data/split/Tioga/lib/Executive.rb +515 -0
  61. data/split/Tioga/lib/FigMkr.rb +2224 -0
  62. data/split/Tioga/lib/FigureConstants.rb +125 -0
  63. data/split/Tioga/lib/Figures_and_Plots.rb +268 -0
  64. data/split/Tioga/lib/Images.rb +278 -0
  65. data/split/Tioga/lib/Legends.rb +190 -0
  66. data/split/Tioga/lib/MarkerConstants.rb +122 -0
  67. data/split/Tioga/lib/Markers.rb +129 -0
  68. data/split/Tioga/lib/Page_Frame_Bounds.rb +567 -0
  69. data/split/Tioga/lib/Rectangles.rb +94 -0
  70. data/split/Tioga/lib/Shading.rb +100 -0
  71. data/split/Tioga/lib/Special_Paths.rb +307 -0
  72. data/split/Tioga/lib/Strokes.rb +129 -0
  73. data/split/Tioga/lib/TeX_Text.rb +454 -0
  74. data/split/Tioga/lib/TexPreamble.rb +358 -0
  75. data/split/Tioga/lib/Titles_and_Labels.rb +306 -0
  76. data/split/Tioga/lib/Transparency.rb +89 -0
  77. data/split/Tioga/lib/Using_Paths.rb +164 -0
  78. data/split/Tioga/lib/Utils.rb +74 -0
  79. data/split/Tioga/lib/X_and_Y_Axes.rb +749 -0
  80. data/split/Tioga/lib/irb_tioga.rb +122 -0
  81. data/split/Tioga/lib/tioga.rb +1 -0
  82. data/split/Tioga/lib/tioga_ui.rb +5 -0
  83. data/split/Tioga/lib/tioga_ui_cmds.rb +793 -0
  84. data/split/Tioga/makers.c +989 -0
  85. data/split/Tioga/mk_tioga_sty.rb +53 -0
  86. data/split/Tioga/namespace.h +47 -0
  87. data/split/Tioga/pdf_font_dicts.c +18253 -0
  88. data/split/Tioga/pdfcolor.c +486 -0
  89. data/split/Tioga/pdfcoords.c +505 -0
  90. data/split/Tioga/pdffile.c +342 -0
  91. data/split/Tioga/pdfimage.c +536 -0
  92. data/split/Tioga/pdfpath.c +914 -0
  93. data/split/Tioga/pdfs.h +229 -0
  94. data/split/Tioga/pdftext.c +443 -0
  95. data/split/Tioga/safe_double.h +104 -0
  96. data/split/Tioga/symbols.c +92 -0
  97. data/split/Tioga/symbols.h +52 -0
  98. data/split/Tioga/texout.c +380 -0
  99. data/split/defs.h +33 -0
  100. data/split/extconf.rb +107 -0
  101. data/split/mkmf2.rb +1612 -0
  102. data/split/namespace.h +47 -0
  103. data/split/safe_double.h +104 -0
  104. data/split/scripts/tioga +4 -0
  105. data/split/symbols.c +92 -0
  106. data/split/symbols.h +52 -0
  107. data/tests/dtable_test.data +6 -0
  108. data/tests/dvector_read_test.data +1 -0
  109. data/tests/dvector_test.data +101 -0
  110. data/tests/tc_Dtable.rb +221 -0
  111. data/tests/tc_Dvector.rb +791 -0
  112. data/tests/tc_FMkr.rb +162 -0
  113. data/tests/tc_Flate.rb +45 -0
  114. data/tests/tc_Function.rb +111 -0
  115. data/tests/ts_Tioga.rb +38 -0
  116. metadata +163 -0
@@ -0,0 +1,134 @@
1
+ # Numeric_extras.rb
2
+
3
+ # add some Numeric methods
4
+
5
+ class Numeric
6
+
7
+ # Math functions
8
+
9
+ def acos
10
+ Math.acos(self)
11
+ end
12
+
13
+ def acosh
14
+ Math.acosh(self)
15
+ end
16
+
17
+ def asin
18
+ Math.asin(self)
19
+ end
20
+
21
+ def asinh
22
+ Math.asinh(self)
23
+ end
24
+
25
+ def atan
26
+ Math.atan(self)
27
+ end
28
+
29
+ def atanh
30
+ Math.atanh(self)
31
+ end
32
+
33
+ def atan2(n)
34
+ Math.atan2(self,n)
35
+ end
36
+
37
+ def cos
38
+ Math.cos(self)
39
+ end
40
+
41
+ def cosh
42
+ Math.cosh(self)
43
+ end
44
+
45
+ def exp
46
+ Math.exp(self)
47
+ end
48
+
49
+ def log
50
+ Math.log(self)
51
+ end
52
+
53
+ def log10
54
+ Math.log10(self)
55
+ end
56
+
57
+ def sin
58
+ Math.sin(self)
59
+ end
60
+
61
+ def sinh
62
+ Math.sinh(self)
63
+ end
64
+
65
+ def sqrt
66
+ Math.sqrt(self)
67
+ end
68
+
69
+ def tan
70
+ Math.tan(self)
71
+ end
72
+
73
+ def tanh
74
+ Math.tanh(self)
75
+ end
76
+
77
+ def neg
78
+ -self
79
+ end
80
+
81
+ def exp10
82
+ 10**self
83
+ end
84
+
85
+ def inv
86
+ 1/self
87
+ end
88
+
89
+ def trim(cutoff=1e-6)
90
+ (self.abs < cutoff)? 0.0 : self
91
+ end
92
+
93
+ def pow(y)
94
+ self**y
95
+ end
96
+
97
+ def raised_to(y)
98
+ self**y
99
+ end
100
+
101
+ def as_exponent_of(y)
102
+ y**self
103
+ end
104
+
105
+ def safe_log(cutoff=1e-99)
106
+ ((self > cutoff)? self : cutoff).log
107
+ end
108
+
109
+ def safe_log10(cutoff=1e-99)
110
+ ((self > cutoff)? self : cutoff).log10
111
+ end
112
+
113
+ def safe_inv(cutoff=1e-99)
114
+ (self.abs > cutoff)? 1/self : (self > 0)? 1/cutoff : -1/cutoff
115
+ end
116
+
117
+ def safe_sqrt
118
+ (self > 0.0)? self.sqrt : 0.0
119
+ end
120
+
121
+ def safe_asin
122
+ ((self > 1.0)? 1.0 : (self < -1.0)? -1.0 : self).asin
123
+ end
124
+
125
+ def safe_acos
126
+ ((self > 1.0)? 1.0 : (self < -1.0)? -1.0 : self).acos
127
+ end
128
+
129
+ def mod(y)
130
+ self.modulo(y)
131
+ end
132
+
133
+
134
+ end
@@ -0,0 +1,47 @@
1
+ /* namespace.h: an attempt at rationalizing shared objects
2
+ namespace use.
3
+
4
+ Copyright (C) 2006 Vincent Fourmond
5
+
6
+ This program is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Library Public License as published
8
+ by the Free Software Foundation; either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Library General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Library General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #ifndef _NAMESPACE_H
22
+ #define _NAMESPACE_H
23
+
24
+ /* This header file provides two OS-specific macros for the definition of
25
+ extern symbols:
26
+
27
+ * PUBLIC, which has to be used to mark objects that will be used
28
+ outside the module
29
+
30
+ * PRIVATE, for symbols which are "extern" but intern to the module
31
+
32
+ Please don't add "extern" after the PRIVATE or PUBLIC declaration
33
+ as this would break compilation on Darwin.
34
+ */
35
+
36
+ #ifdef __APPLE__
37
+ # define PRIVATE __private_extern__
38
+ # define PUBLIC
39
+ #elif __GNUC__ >= 4 /* we have the visibility attribute */
40
+ # define PRIVATE __attribute__ ((visibility ("hidden")))
41
+ # define PUBLIC __attribute__ ((visibility ("default")))
42
+ #else /* not really good */
43
+ # define PRIVATE
44
+ # define PUBLIC
45
+ #endif /* __APPLE__ and __GNU_C_ >= 4*/
46
+
47
+ #endif
@@ -0,0 +1,104 @@
1
+ /**********************************************************************
2
+
3
+ safe_double.h: small abstraction for storing double without endianess
4
+ problems
5
+
6
+ Copyright (C) 2006 Vincent Fourmond
7
+
8
+ This program is free software; you can redistribute it and/or modify
9
+ it under the terms of the GNU General Library Public License as published
10
+ by the Free Software Foundation; either version 2 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Library General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Library General Public License
19
+ along with this program; if not, write to the Free Software
20
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+
22
+ **********************************************************************/
23
+
24
+ /* This file provides two functions: store_double and get_double, which
25
+ can be used in a 'safe' way to store doubles and retrive them
26
+ in a hopefully platform-independent form. However, it just
27
+ stores it without regards to that if ieee754.h isn't found...
28
+ */
29
+
30
+ #ifndef _DOUBLE_H
31
+ #define _DOUBLE_H
32
+
33
+ #define STORE_LOWER_BYTE(a,p) do {\
34
+ *(p++) = (a) & 0xFF; (a) >>= 8; }\
35
+ while(0)
36
+ #define STORE_UNSIGNED(a,p) for(i = 0; i < 4; i++) STORE_LOWER_BYTE(a,p);
37
+ #define GET_UNSIGNED(a,p) do { a = 0; for(i = 0; i < 4; i++) \
38
+ (a) |= *(p++) << (i * 8); } while (0)
39
+
40
+ #ifdef HAVE_IEEE754_H
41
+ #include <ieee754.h>
42
+
43
+
44
+ static inline void store_double(double a, unsigned char * p)
45
+ {
46
+ unsigned int tmp;
47
+ int i;
48
+ union ieee754_double d;
49
+ d.d = a;
50
+ /* we store it with lower bytes firts */
51
+ tmp = d.ieee.mantissa1;
52
+ STORE_UNSIGNED(tmp, p);
53
+ tmp = d.ieee.negative << 31 |
54
+ d.ieee.exponent << 20 |
55
+ d.ieee.mantissa0;
56
+ STORE_UNSIGNED(tmp, p);
57
+ }
58
+
59
+
60
+ static inline double get_double(const unsigned char * p)
61
+ {
62
+ unsigned int tmp;
63
+ int i;
64
+ union ieee754_double d;
65
+ GET_UNSIGNED(tmp, p);
66
+ d.ieee.mantissa1 = tmp;
67
+ GET_UNSIGNED(tmp, p);
68
+ d.ieee.mantissa0 = tmp & 0xFFFFF;
69
+ d.ieee.exponent = (tmp >> 20) & 0x7FF;
70
+ d.ieee.negative = (tmp >> 31) & 0x1;
71
+ return d.d;
72
+ }
73
+
74
+ #else
75
+
76
+ union basic_double{
77
+ double d;
78
+ struct {
79
+ unsigned int a:32;
80
+ unsigned int b:32;
81
+ } i;
82
+ };
83
+
84
+ static inline void store_double(double a, unsigned char * p)
85
+ {
86
+ union basic_double d;
87
+ int i;
88
+ d.d = a;
89
+ STORE_UNSIGNED(d.i.a, p);
90
+ STORE_UNSIGNED(d.i.b, p);
91
+ }
92
+
93
+ static inline double get_double(const unsigned char * p)
94
+ {
95
+ union basic_double d;
96
+ int i;
97
+ GET_UNSIGNED(d.i.a, p);
98
+ GET_UNSIGNED(d.i.b, p);
99
+ return d.d;
100
+ }
101
+
102
+ #endif /* HAVE_IEEE754_H */
103
+
104
+ #endif /* _DOUBLE_H */
@@ -0,0 +1,92 @@
1
+ /*
2
+ Copyright (C) 2006 Vincent Fourmond
3
+
4
+ Symbols is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Library Public License as published
6
+ by the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+
9
+ Symbols is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Library General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Library General Public License
15
+ along with Dvector; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+ */
18
+
19
+
20
+ /* Simple code for sharing C symbols across different Ruby libraries */
21
+
22
+ #include <ruby.h>
23
+ #include <intern.h>
24
+
25
+ #include <namespace.h>
26
+
27
+
28
+ /* MV stands for Module Variable */
29
+ #define MV_SYMBOLS "@_exported_C_symbols"
30
+ /* modified to use instance variables instead of global class variables:
31
+ this way, children don't overwrite the parent's export table
32
+ */
33
+
34
+
35
+ /* makes sure that the hash is registered for the given
36
+ module and returns it */
37
+ static VALUE get_symbol_hash(VALUE module)
38
+ {
39
+ VALUE hash;
40
+ ID mv_id = rb_intern(MV_SYMBOLS);
41
+ if(RTEST(rb_ivar_defined(module, mv_id)))
42
+ {
43
+ hash = rb_ivar_get(module, mv_id);
44
+ Check_Type(hash, T_HASH);
45
+ return hash;
46
+ }
47
+ else
48
+ {
49
+ /* module variable uninitialized, we need to make sure it's here */
50
+ hash = rb_hash_new();
51
+ rb_ivar_set(module, mv_id, hash);
52
+ return hash;
53
+ }
54
+ }
55
+
56
+ /* registers a symbol in the given module. This one is the internal
57
+ function */
58
+ PRIVATE void rb_export_symbol(VALUE module, const char * symbol_name,
59
+ void * symbol)
60
+ {
61
+ VALUE hash = get_symbol_hash(module);
62
+ rb_hash_aset(hash, rb_str_new2(symbol_name),LONG2NUM((long) symbol));
63
+ }
64
+
65
+ PRIVATE void * rb_import_symbol_no_raise(VALUE module,
66
+ const char * symbol_name)
67
+ {
68
+ VALUE hash = rb_iv_get(module, MV_SYMBOLS);
69
+ if(TYPE(hash) != T_HASH)
70
+ return NULL; /* doesn't fail, but the importing module
71
+ should definitely check the return value. Beware
72
+ of segfaults ! */
73
+ VALUE symbol = rb_hash_aref(hash, rb_str_new2(symbol_name));
74
+
75
+ if(TYPE(symbol) == T_FIXNUM || TYPE(symbol) == T_BIGNUM)
76
+ return (void *) NUM2LONG(symbol);
77
+ return NULL;
78
+ }
79
+
80
+ /* same as before, but raises something is the return value is NULL,
81
+ which is probably best as a default behavior*/
82
+ PRIVATE void * rb_import_symbol(VALUE module, const char * symbol_name)
83
+ {
84
+ void * symbol = rb_import_symbol_no_raise(module, symbol_name);
85
+ if(symbol)
86
+ return symbol;
87
+ /* we get the name of the module: */
88
+ VALUE module_name = rb_funcall(module, rb_intern("to_s"), 0);
89
+ rb_raise(rb_eRuntimeError, "The symbol %s was not found in "
90
+ "module %s", symbol_name,
91
+ rb_string_value_cstr(&module_name));
92
+ }
@@ -0,0 +1,52 @@
1
+ #ifndef _SYMBOLS_H
2
+ #define _SYMBOLS_H
3
+
4
+ #include <ruby.h>
5
+ /* A small layer for exporting and importing symbols from
6
+ a compiled module */
7
+
8
+ #include <namespace.h>
9
+
10
+
11
+ PRIVATE void rb_export_symbol(VALUE module, const char * symbol_name,
12
+ void * symbol);
13
+ PRIVATE void * rb_import_symbol(VALUE module, const char * symbol_name);
14
+ PRIVATE void * rb_import_symbol_no_raise(VALUE module,
15
+ const char * symbol_name);
16
+
17
+ /* a shortcut for exporting something with the same name */
18
+ #define RB_EXPORT_SYMBOL(module, name) \
19
+ rb_export_symbol(module, #name, name)
20
+
21
+ /* A shortcut for getting a symbol */
22
+
23
+ #define DECLARE_SYMBOL(ret_type,name,args) \
24
+ typedef ret_type (*rb_export_##name##_type) args;\
25
+ PRIVATE rb_export_##name##_type name
26
+
27
+ #define IMPLEMENT_SYMBOL(name)\
28
+ PRIVATE rb_export_##name##_type name = 0;
29
+
30
+ #define RB_IMPORT_SYMBOL(module, name) \
31
+ name = (rb_export_##name##_type) rb_import_symbol(module, #name)
32
+
33
+
34
+ /* These three macro enable a simple use of function declaration: this way,
35
+ you can type in a header file that is used by the importer:
36
+
37
+ DECLARE_SYMBOL(int, biniou, (int, int));
38
+
39
+ in one file of the importer code, you write
40
+
41
+ IMPLEMENT_SYMBOL(biniou);
42
+
43
+ and in the Init_... function, you write:
44
+
45
+ RB_IMPORT_SYMBOL(module, biniou);
46
+
47
+ and you can just use biniou as if it was a function declared as
48
+ usual in the header file
49
+ */
50
+ #endif
51
+
52
+
@@ -0,0 +1,33 @@
1
+ /**********************************************************************
2
+
3
+ defs.h:
4
+ some definitions that are used everywhere and that depend on some
5
+ HAVE_* macros.
6
+
7
+ Copyright (C) 2006 Vincent Fourmond
8
+
9
+ This program is free software; you can redistribute it and/or modify
10
+ it under the terms of the GNU General Library Public License as published
11
+ by the Free Software Foundation; either version 2 of the License, or
12
+ (at your option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU Library General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Library General Public License
20
+ along with this program; if not, write to the Free Software
21
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
+
23
+ **********************************************************************/
24
+
25
+
26
+ #ifdef HAVE_ISNAN
27
+ /* we use isnan and isinf, which are much faster than the workaround */
28
+ #define is_okay_number(x) (! isnan(x) && ! isinf(x))
29
+ #else
30
+ #define is_okay_number(x) ((x) - (x) == 0.0)
31
+ #define isnan(x) ((x) != (x))
32
+ /* yes, as funny as it may look NaN != NaN, and that's the only one */
33
+ #endif