tioga 1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,144 @@
1
+ /* dtable.h */
2
+ /*
3
+ Copyright (C) 2004 Bill Paxton
4
+
5
+ This file is part of Dtable.
6
+
7
+ Dtable is free software; you can redistribute it and/or modify
8
+ it under the terms of the GNU General Library Public License as published
9
+ by the Free Software Foundation; either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Dtable is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Library General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Library General Public License
18
+ along with Dtable; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #ifndef __dtable_H__
23
+ #define __dtable_H__
24
+
25
+ #include <namespace.h>
26
+ #include <ruby.h>
27
+ #include "dvector.h"
28
+
29
+ /*======================================================================*/
30
+
31
+
32
+ PUBLIC void Init_Dtable();
33
+ PRIVATE VALUE Read_Dtable(VALUE dest, char *filename, int skip_lines);
34
+ PRIVATE double **Dtable_Ptr(VALUE dtable, long *num_cols, long *num_rows);
35
+
36
+ PRIVATE bool Is_Dtable(VALUE obj);
37
+
38
+ PRIVATE VALUE dtable_apply_math_op(VALUE source, double (*op)(double));
39
+ PRIVATE VALUE dtable_apply_math_op2(VALUE ary1, VALUE ary2, double (*op)(double, double));
40
+ PRIVATE VALUE dtable_apply_math_op_bang(VALUE ary, double (*op)(double));
41
+ PRIVATE VALUE dtable_apply_math_op2_bang(VALUE ary1, VALUE ary2, double (*op)(double, double));
42
+
43
+ PRIVATE VALUE dtable_dup(VALUE ary);
44
+ PRIVATE VALUE dtable_transpose(VALUE ary);
45
+ PRIVATE VALUE dtable_reverse_rows(VALUE ary);
46
+ PRIVATE VALUE dtable_reverse_cols(VALUE ary);
47
+ PRIVATE VALUE dtable_rotate_cw90(VALUE ary);
48
+ PRIVATE VALUE dtable_rotate_ccw90(VALUE ary);
49
+ PRIVATE VALUE dtable_num_cols(VALUE ary);
50
+ PRIVATE VALUE dtable_num_rows(VALUE ary);
51
+ PRIVATE VALUE dtable_min(VALUE ary);
52
+ PRIVATE VALUE dtable_max(VALUE ary);
53
+ PRIVATE VALUE dtable_minmax(VALUE ary);
54
+ PRIVATE VALUE dtable_row(VALUE ary, VALUE row_num);
55
+ PRIVATE VALUE dtable_column(VALUE ary, VALUE column_num);
56
+ PRIVATE VALUE dtable_set_row(VALUE ary, VALUE row_num, VALUE dvec);
57
+ PRIVATE VALUE dtable_set_column(VALUE ary, VALUE col_num, VALUE dvec);
58
+ PRIVATE VALUE dtable_clear(VALUE ary, VALUE val);
59
+ PRIVATE VALUE dtable_set(VALUE ary, VALUE val);
60
+ PRIVATE VALUE dtable_neg(VALUE ary);
61
+ PRIVATE VALUE dtable_abs(VALUE ary);
62
+ PRIVATE VALUE dtable_sin(VALUE ary);
63
+ PRIVATE VALUE dtable_cos(VALUE ary);
64
+ PRIVATE VALUE dtable_tan(VALUE ary);
65
+ PRIVATE VALUE dtable_asin(VALUE ary);
66
+ PRIVATE VALUE dtable_acos(VALUE ary);
67
+ PRIVATE VALUE dtable_atan(VALUE ary);
68
+ PRIVATE VALUE dtable_sinh(VALUE ary);
69
+ PRIVATE VALUE dtable_cosh(VALUE ary);
70
+ PRIVATE VALUE dtable_tanh(VALUE ary);
71
+ PRIVATE VALUE dtable_asinh(VALUE ary);
72
+ PRIVATE VALUE dtable_acosh(VALUE ary);
73
+ PRIVATE VALUE dtable_atanh(VALUE ary);
74
+ PRIVATE VALUE dtable_ceil(VALUE ary);
75
+ PRIVATE VALUE dtable_floor(VALUE ary);
76
+ PRIVATE VALUE dtable_round(VALUE ary);
77
+ PRIVATE VALUE dtable_exp(VALUE ary);
78
+ PRIVATE VALUE dtable_exp10(VALUE ary);
79
+ PRIVATE VALUE dtable_log(VALUE ary);
80
+ PRIVATE VALUE dtable_log10(VALUE ary);
81
+ PRIVATE VALUE dtable_inv(VALUE ary);
82
+ PRIVATE VALUE dtable_sqrt(VALUE ary);
83
+ PRIVATE VALUE dtable_neg_bang(VALUE ary);
84
+ PRIVATE VALUE dtable_abs_bang(VALUE ary);
85
+ PRIVATE VALUE dtable_sin_bang(VALUE ary);
86
+ PRIVATE VALUE dtable_cos_bang(VALUE ary);
87
+ PRIVATE VALUE dtable_tan_bang(VALUE ary);
88
+ PRIVATE VALUE dtable_asin_bang(VALUE ary);
89
+ PRIVATE VALUE dtable_acos_bang(VALUE ary);
90
+ PRIVATE VALUE dtable_atan_bang(VALUE ary);
91
+ PRIVATE VALUE dtable_sinh_bang(VALUE ary);
92
+ PRIVATE VALUE dtable_cosh_bang(VALUE ary);
93
+ PRIVATE VALUE dtable_tanh_bang(VALUE ary);
94
+ PRIVATE VALUE dtable_asinh_bang(VALUE ary);
95
+ PRIVATE VALUE dtable_acosh_bang(VALUE ary);
96
+ PRIVATE VALUE dtable_atanh_bang(VALUE ary);
97
+ PRIVATE VALUE dtable_ceil_bang(VALUE ary);
98
+ PRIVATE VALUE dtable_floor_bang(VALUE ary);
99
+ PRIVATE VALUE dtable_round_bang(VALUE ary);
100
+ PRIVATE VALUE dtable_exp_bang(VALUE ary);
101
+ PRIVATE VALUE dtable_exp10_bang(VALUE ary);
102
+ PRIVATE VALUE dtable_log_bang(VALUE ary);
103
+ PRIVATE VALUE dtable_log10_bang(VALUE ary);
104
+ PRIVATE VALUE dtable_inv_bang(VALUE ary);
105
+ PRIVATE VALUE dtable_sqrt_bang(VALUE ary);
106
+ PRIVATE VALUE dtable_trim(int argc, VALUE *argv, VALUE self);
107
+ PRIVATE VALUE dtable_safe_log(int argc, VALUE *argv, VALUE self);
108
+ PRIVATE VALUE dtable_safe_log10(int argc, VALUE *argv, VALUE self);
109
+ PRIVATE VALUE dtable_safe_inv(int argc, VALUE *argv, VALUE self);
110
+ PRIVATE VALUE dtable_safe_asin(VALUE ary);
111
+ PRIVATE VALUE dtable_safe_acos(VALUE ary);
112
+ PRIVATE VALUE dtable_safe_sqrt(VALUE ary);
113
+ PRIVATE VALUE dtable_atan2_bang(VALUE ary, VALUE arg);
114
+ PRIVATE VALUE dtable_modulo_bang(VALUE ary, VALUE arg);
115
+ PRIVATE VALUE dtable_remainder_bang(VALUE ary, VALUE arg);
116
+ PRIVATE VALUE dtable_trim_bang(int argc, VALUE *argv, VALUE self);
117
+ PRIVATE VALUE dtable_pow_bang(VALUE ary, VALUE arg);
118
+ PRIVATE VALUE dtable_as_exponent_of_bang(VALUE ary, VALUE arg);
119
+ PRIVATE VALUE dtable_safe_log_bang(int argc, VALUE *argv, VALUE self);
120
+ PRIVATE VALUE dtable_safe_log10_bang(int argc, VALUE *argv, VALUE self);
121
+ PRIVATE VALUE dtable_safe_inv_bang(int argc, VALUE *argv, VALUE self);
122
+ PRIVATE VALUE dtable_safe_sqrt_bang(VALUE ary);
123
+ PRIVATE VALUE dtable_safe_asin_bang(VALUE ary);
124
+ PRIVATE VALUE dtable_safe_acos_bang(VALUE ary);
125
+ PRIVATE VALUE dtable_add(VALUE ary, VALUE arg);
126
+ PRIVATE VALUE dtable_sub(VALUE ary, VALUE arg);
127
+ PRIVATE VALUE dtable_mul(VALUE ary, VALUE arg);
128
+ PRIVATE VALUE dtable_div(VALUE ary, VALUE arg);
129
+ PRIVATE VALUE dtable_mod(VALUE ary, VALUE arg);
130
+ PRIVATE VALUE dtable_remainder(VALUE ary, VALUE arg);
131
+ PRIVATE VALUE dtable_pow(VALUE ary, VALUE arg);
132
+ PRIVATE VALUE dtable_as_exponent_of(VALUE ary, VALUE arg);
133
+ PRIVATE VALUE dtable_atan2(VALUE ary, VALUE arg);
134
+ PRIVATE VALUE dtable_add_bang(VALUE ary, VALUE arg);
135
+ PRIVATE VALUE dtable_sub_bang(VALUE ary, VALUE arg);
136
+ PRIVATE VALUE dtable_mul_bang(VALUE ary, VALUE arg);
137
+ PRIVATE VALUE dtable_div_bang(VALUE ary, VALUE arg);
138
+ PRIVATE VALUE dtable_read(int argc, VALUE *argv, VALUE self);
139
+ PRIVATE VALUE dtable_at(VALUE ary, VALUE xloc, VALUE yloc);
140
+ PRIVATE VALUE dtable_aset(VALUE ary, VALUE xloc, VALUE yloc, VALUE val);
141
+ PRIVATE void dtable_store(VALUE ary, long i, long j, double v);
142
+
143
+ #endif /* __dtable_H__ */
144
+
@@ -0,0 +1,61 @@
1
+ /* Dvector.h */
2
+ /*
3
+ Copyright (C) 2005 Bill Paxton
4
+
5
+ Dvector is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU General Library Public License as published
7
+ by the Free Software Foundation; either version 2 of the License, or
8
+ (at your option) any later version.
9
+
10
+ Dvector is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Library General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Library General Public License
16
+ along with Dvector; if not, write to the Free Software
17
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ */
19
+
20
+ #ifndef __Dvector_H__
21
+ #define __Dvector_H__
22
+
23
+ /* this file has been heavily modified by Vincent Fourmond to take care
24
+ of the 'RCR330' scheme of exporting symbols
25
+ */
26
+
27
+ #include <symbols.h>
28
+ #include <stdbool.h>
29
+
30
+ /*======================================================================*/
31
+
32
+ /* functions for handling Dvectors: */
33
+
34
+ DECLARE_SYMBOL(double *, Dvector_Data_for_Read, (VALUE dvector, long *len_ptr));
35
+ /* returns pointer to the dvector's data (which may be shared) */
36
+ DECLARE_SYMBOL(double *, Dvector_Data_Copy, (VALUE dvector, long *len_ptr));
37
+ /* like Dvector_Data_for_Read, but returns pointer to a copy of the data */
38
+ DECLARE_SYMBOL(double *, Dvector_Data_for_Write,
39
+ (VALUE dvector, long *len_ptr));
40
+ DECLARE_SYMBOL(double *, Dvector_Data_Resize, (VALUE dvector, long new_len));
41
+ DECLARE_SYMBOL(double *, Dvector_Data_Replace,
42
+ (VALUE dvector, long len, double *data));
43
+ /* copies the data into the dvector */
44
+ DECLARE_SYMBOL(VALUE, Dvector_Create, (void));
45
+ DECLARE_SYMBOL(void, Dvector_Store_Double, (VALUE ary, long idx, double val));
46
+ /* pushes one element onto the vector */
47
+ DECLARE_SYMBOL(void, Dvector_Push_Double, (VALUE ary, double val));
48
+
49
+ /* functions for interpolation */
50
+ DECLARE_SYMBOL(double, c_dvector_spline_interpolate,
51
+ (double x, int n_pts_data, double *Xs, double *Ys,
52
+ double *Bs, double *Cs, double *Ds));
53
+ DECLARE_SYMBOL(double, c_dvector_linear_interpolate,
54
+ (int num_pts, double *xs, double *ys, double x));
55
+ DECLARE_SYMBOL(void, c_dvector_create_spline_interpolant,
56
+ (int n_pts_data, double *Xs, double *Ys,
57
+ bool start_clamped, double start_slope,
58
+ bool end_clamped, double end_slope,
59
+ double *As, double *Bs, double *Cs));
60
+ #endif /* __Dvector_H__ */
61
+
@@ -0,0 +1,4 @@
1
+ # Dtable installation file
2
+ require 'mkmf'
3
+
4
+ create_makefile 'Dobjects/Dtable'
@@ -0,0 +1,35 @@
1
+ /* dtable.h */
2
+ /*
3
+ Copyright (C) 2004 Bill Paxton
4
+
5
+ This file is part of Dtable.
6
+
7
+ Dtable is free software; you can redistribute it and/or modify
8
+ it under the terms of the GNU General Library Public License as published
9
+ by the Free Software Foundation; either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Dtable is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Library General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Library General Public License
18
+ along with Dtable; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+
22
+ #ifndef __dtable_H__
23
+ #define __dtable_H__
24
+
25
+ #include <symbols.h>
26
+
27
+ /*======================================================================*/
28
+
29
+
30
+ DECLARE_SYMBOL(VALUE, Read_Dtable,
31
+ (VALUE dest, char *filename, int skip_lines));
32
+ DECLARE_SYMBOL(double **, Dtable_Ptr,
33
+ (VALUE dtable, long *num_cols, long *num_rows));
34
+
35
+ #endif
@@ -0,0 +1,90 @@
1
+ # pre_ddata_extras.rb
2
+
3
+ # add arithmetic operators for Float and Fixnum with Dtable
4
+
5
+ class Float
6
+ alias :pre_ddata_add :+
7
+ def +(a)
8
+ if a.class == Dobjects::Dtable
9
+ a+self
10
+ else
11
+ pre_ddata_add(a)
12
+ end
13
+ end
14
+ alias :pre_ddata_sub :-
15
+ def -(a)
16
+ if a.class == Dobjects::Dtable
17
+ a.neg+self
18
+ else
19
+ pre_ddata_sub(a)
20
+ end
21
+ end
22
+ alias :pre_ddata_mult :*
23
+ def *(a)
24
+ if a.class == Dobjects::Dtable
25
+ a*self
26
+ else
27
+ pre_ddata_mult(a)
28
+ end
29
+ end
30
+ alias :pre_ddata_div :/
31
+ def /(a)
32
+ if a.class == Dobjects::Dtable
33
+ a.inv*self
34
+ else
35
+ pre_ddata_div(a)
36
+ end
37
+ end
38
+ alias :pre_ddata_pow :**
39
+ def **(a)
40
+ if a.class == Dobjects::Dtable
41
+ a.as_exponent_of(self)
42
+ else
43
+ pre_ddata_pow(a)
44
+ end
45
+ end
46
+ end
47
+
48
+ class Fixnum
49
+ alias :pre_ddata_add :+
50
+ def +(a)
51
+ if a.class == Dobjects::Dtable
52
+ a+self
53
+ else
54
+ pre_ddata_add(a)
55
+ end
56
+ end
57
+ alias :pre_ddata_sub :-
58
+ def -(a)
59
+ if a.class == Dobjects::Dtable
60
+ a.neg+self
61
+ else
62
+ pre_ddata_sub(a)
63
+ end
64
+ end
65
+ alias :pre_ddata_mult :*
66
+ def *(a)
67
+ if a.class == Dobjects::Dtable
68
+ a*self
69
+ else
70
+ pre_ddata_mult(a)
71
+ end
72
+ end
73
+ alias :pre_ddata_div :/
74
+ def /(a)
75
+ if a.class == Dobjects::Dtable
76
+ a.inv*self
77
+ else
78
+ pre_ddata_div(a)
79
+ end
80
+ end
81
+ alias :pre_ddata_pow :**
82
+ def **(a)
83
+ if a.class == Dobjects::Dtable
84
+ a.as_exponent_of(self)
85
+ else
86
+ pre_ddata_pow(a)
87
+ end
88
+ end
89
+ end
90
+
@@ -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 */