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
data/split/namespace.h ADDED
@@ -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,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'Tioga/tioga_ui.rb'
3
+
4
+
data/split/symbols.c ADDED
@@ -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
+ }
data/split/symbols.h ADDED
@@ -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,6 @@
1
+ test.data
2
+ 0 1 2 3
3
+ -9 8 7 6
4
+ 0.1 -1.1 2.2 -3.3
5
+ 0.126933 0.302696 0.700303 -1.03798
6
+ 0.1904 0.322089 0.744037 -0.984045
@@ -0,0 +1 @@
1
+ 0.10000000+001 -0.63188067-104 -0.20107803+002 1E0
@@ -0,0 +1,101 @@
1
+ 23 3
2
+ 0 0.286477 0.603729 -1.08582
3
+ 0.0634665 0.290788 0.653458 -1.07284
4
+ 0 -1.1 2.2 -3.3
5
+ 0.126933 0.302696 0.700303 -1.03798
6
+ 0.1904 0.322089 0.744037 -0.984045
7
+ 0.253866 0.348769 0.784447 -0.914921
8
+ 0.317333 0.382438 0.821343 -0.834875
9
+ 0.380799 0.422669 0.85455 -0.747997
10
+ 0.444266 0.468879 0.883916 -0.657877
11
+ 0.507732 0.520296 0.90931 -0.567498
12
+ 0.571199 0.575921 0.930622 -0.479272
13
+ 0.634665 0.634495 0.947765 -0.395142
14
+ 0.698132 0.694464 0.960675 -0.3167
15
+ 0.761598 0.753955 0.969311 -0.245308
16
+ 0.825065 0.810764 0.973655 -0.182211
17
+ 0.888531 0.862358 0.973714 -0.128624
18
+ 0.951998 0.905904 0.969515 -0.0858351
19
+ 1.01546 0.938327 0.96111 -0.0552914
20
+ 1.07893 0.956398 0.948574 -0.0387219
21
+ 1.1424 0.956874 0.932001 -0.0382904
22
+ 1.20586 0.936664 0.91151 -0.0568315
23
+ 1.26933 0.893059 0.887236 -0.0982393
24
+ 1.3328 0.823979 0.859336 -0.168167
25
+ 1.39626 0.728269 0.827985 -0.275415
26
+ 1.45973 0.605995 0.793372 -0.435061
27
+ 1.5232 0.458732 0.755706 -0.676879
28
+ 1.58666 0.289821 0.715206 -1.07574
29
+ 1.65013 0.104532 0.672107 -1.96146
30
+ 1.7136 -0.0898792 0.626654 -2.09263
31
+ 1.77706 -0.284282 0.579102 -1.0925
32
+ 1.84053 -0.467981 0.529712 -0.659541
33
+ 1.904 -0.62926 0.478755 -0.402339
34
+ 1.96746 -0.756151 0.426504 -0.242782
35
+ 2.03093 -0.837439 0.373237 -0.154093
36
+ 2.0944 -0.863825 0.319231 -0.127147
37
+ 2.15786 -0.829179 0.264766 -0.162703
38
+ 2.22133 -0.731738 0.210116 -0.271289
39
+ 2.28479 -0.575102 0.155555 -0.480509
40
+ 2.34826 -0.368835 0.101351 -0.866332
41
+ 2.41173 -0.128489 0.0477643 -1.78224
42
+ 2.47519 0.1251 -0.00495156 -1.80546
43
+ 2.53866 0.367332 -0.0565527 -0.869878
44
+ 2.60213 0.572175 -0.106806 -0.484941
45
+ 2.66559 0.715158 -0.15549 -0.291195
46
+ 2.72906 0.77675 -0.202396 -0.219436
47
+ 2.79253 0.745684 -0.247329 -0.25489
48
+ 2.85599 0.621689 -0.29011 -0.412853
49
+ 2.91946 0.417058 -0.330574 -0.759605
50
+ 2.98293 0.156524 -0.368572 -1.61082
51
+ 3.04639 -0.124905 -0.403973 -1.80681
52
+ 3.10986 -0.386187 -0.436663 -0.826402
53
+ 3.17333 -0.586239 -0.466544 -0.46385
54
+ 3.23679 -0.690906 -0.493537 -0.321162
55
+ 3.30026 -0.679757 -0.517579 -0.335292
56
+ 3.36373 -0.551336 -0.538628 -0.517167
57
+ 3.42719 -0.325495 -0.556656 -0.974908
58
+ 3.49066 -0.0417951 -0.571653 -2.7575
59
+ 3.55413 0.246405 -0.583627 -1.21669
60
+ 3.61759 0.481614 -0.592602 -0.6346
61
+ 3.68106 0.614085 -0.598616 -0.423542
62
+ 3.74452 0.613487 -0.601726 -0.424388
63
+ 3.80799 0.47755 -0.601999 -0.64196
64
+ 3.87146 0.235052 -0.599518 -1.25766
65
+ 3.93492 -0.0584959 -0.59438 -2.46562
66
+ 3.99839 -0.332444 -0.586691 -0.956558
67
+ 4.06186 -0.517883 -0.576569 -0.571535
68
+ 4.12532 -0.565922 -0.564143 -0.494486
69
+ 4.18879 -0.462435 -0.54955 -0.669896
70
+ 4.25226 -0.234505 -0.532934 -1.25969
71
+ 4.31572 0.0544649 -0.514446 -2.52762
72
+ 4.37919 0.32097 -0.494243 -0.987067
73
+ 4.44266 0.485363 -0.472487 -0.627865
74
+ 4.50612 0.496851 -0.449341 -0.607546
75
+ 4.56959 0.351455 -0.424973 -0.908257
76
+ 4.63306 0.0960696 -0.39955 -2.03478
77
+ 4.69652 -0.184411 -0.37324 -1.46841
78
+ 4.75999 -0.394267 -0.34621 -0.808416
79
+ 4.82346 -0.460204 -0.318626 -0.674097
80
+ 4.88692 -0.359033 -0.290649 -0.889728
81
+ 4.95039 -0.128725 -0.262439 -1.78065
82
+ 5.01385 0.143147 -0.234149 -1.68841
83
+ 5.07732 0.351261 -0.205929 -0.908737
84
+ 5.14079 0.41374 -0.17792 -0.766543
85
+ 5.20425 0.306526 -0.150261 -1.02706
86
+ 5.26772 0.0757187 -0.123078 -2.24152
87
+ 5.33119 -0.179423 -0.096495 -1.49223
88
+ 5.39465 -0.347867 -0.0706236 -0.91717
89
+ 5.45812 -0.355939 -0.0455687 -0.897245
90
+ 5.52159 -0.202159 -0.0214262 -1.38861
91
+ 5.58505 0.0397937 0.00171714 -2.8001
92
+ 5.64852 0.253889 0.0237839 -1.1907
93
+ 5.71199 0.336949 0.0447058 -0.944868
94
+ 5.77545 0.250192 0.0644241 -1.20345
95
+ 5.83892 0.0405176 0.0828894 -2.78445
96
+ 5.90239 -0.18169 0.100061 -1.48132
97
+ 5.96585 -0.299364 0.115909 -1.0476
98
+ 6.02932 -0.25159 0.13041 -1.19861
99
+ 6.09279 -0.0681354 0.143551 -2.33316
100
+ 6.15625 0.145564 0.155327 -1.67387
101
+ 6.21972 0.267255 0.16574 -1.14614
@@ -0,0 +1,221 @@
1
+ # tc_Dtable.rb
2
+
3
+ require 'Dobjects/Dtable'
4
+ require 'test/unit'
5
+
6
+ class TestDtable < Test::Unit::TestCase
7
+
8
+ include Dobjects
9
+
10
+ def read_data # do this first to read in the test.data array
11
+ return if @arr != nil
12
+ @num_cols = 4; @num_rows = 5
13
+ @arr = Dtable.new(@num_cols, @num_rows)
14
+ dir = File.dirname(__FILE__)
15
+ if dir.empty?
16
+ file = "dtable_test.data"
17
+ else
18
+ file = "#{dir}/dtable_test.data"
19
+ end
20
+ @arr.read(file, 1) # skip the first line
21
+ assert_equal(@num_cols, @arr.num_cols)
22
+ assert_equal(@num_rows, @arr.num_rows)
23
+ end
24
+
25
+ def test_at
26
+ read_data
27
+ assert_equal(7, @arr.at(1,2))
28
+ assert_equal(0.1, @arr.at(2,0))
29
+ assert_equal(-1.1, @arr.at(2,1))
30
+ assert_equal(2.2, @arr[2,2])
31
+ assert_equal(-3.3, @arr[2,3])
32
+ tmp = @arr[3,2]
33
+ @arr[3,2] = 1e3
34
+ assert_equal(1e3, @arr[3,2])
35
+ @arr[3,2] = tmp
36
+ assert_equal(tmp, @arr[3,2])
37
+ end
38
+
39
+ def test_array_ops
40
+ read_data
41
+ @ar2 = @arr.dup
42
+ @num_rows.times do |i|
43
+ @num_cols.times do |j|
44
+ assert_equal(@arr[i,j], @ar2[i,j])
45
+ end
46
+ end
47
+ assert_equal(@num_rows, @arr.num_rows)
48
+ @num_rows.times do |i|
49
+ @num_cols.times do |j|
50
+ assert_equal(@arr[i,j], @ar2[i,j])
51
+ end
52
+ end
53
+ last_row = @num_rows - 1
54
+ last_col = @num_cols - 1
55
+ @arr[0,0] = 0
56
+ @arr[0,last_col] = 1
57
+ @arr[last_row,0] = 2
58
+ @arr[last_row,last_col] = 3
59
+ @ar2 = @arr.transpose
60
+ assert_equal(@num_cols, @ar2.num_rows)
61
+ assert_equal(@num_rows, @ar2.num_cols)
62
+ assert_equal(@ar2[0,0], 0)
63
+ assert_equal(@ar2[last_col,0], 1)
64
+ assert_equal(@ar2[0,last_row], 2)
65
+ assert_equal(@ar2[last_col,last_row], 3)
66
+ @num_rows.times do |i|
67
+ @num_cols.times do |j|
68
+ assert_equal(@arr[i,j], @ar2[j,i])
69
+ end
70
+ end
71
+ @ar2 = @arr.reverse_rows
72
+ assert_equal(@num_cols, @ar2.num_cols)
73
+ assert_equal(@num_rows, @ar2.num_rows)
74
+ assert_equal(@ar2[0,0], 2)
75
+ assert_equal(@ar2[0,last_col], 3)
76
+ assert_equal(@ar2[last_row,0], 0)
77
+ assert_equal(@ar2[last_row,last_col], 1)
78
+ @num_rows.times do |i|
79
+ @num_cols.times do |j|
80
+ assert_equal(@arr[i,j], @ar2[last_row-i,j])
81
+ end
82
+ end
83
+ @ar2 = @arr.reverse_cols
84
+ assert_equal(@num_cols, @ar2.num_cols)
85
+ assert_equal(@num_rows, @ar2.num_rows)
86
+ assert_equal(@ar2[0,0], 1)
87
+ assert_equal(@ar2[0,last_col], 0)
88
+ assert_equal(@ar2[last_row,0], 3)
89
+ assert_equal(@ar2[last_row,last_col], 2)
90
+ @num_rows.times do |i|
91
+ @num_cols.times do |j|
92
+ assert_equal(@arr[i,j], @ar2[i,last_col-j])
93
+ end
94
+ end
95
+ @ar2 = @arr.rotate_ccw90
96
+ assert_equal(@num_cols, @ar2.num_rows)
97
+ assert_equal(@num_rows, @ar2.num_cols)
98
+ assert_equal(@ar2[0,0], 1)
99
+ assert_equal(@ar2[0,last_row], 3)
100
+ assert_equal(@ar2[last_col,0], 0)
101
+ assert_equal(@ar2[last_col,last_row], 2)
102
+ @ar2 = @arr.rotate_cw90
103
+ assert_equal(@num_cols, @ar2.num_rows)
104
+ assert_equal(@num_rows, @ar2.num_cols)
105
+ assert_equal(@ar2[0,0], 2)
106
+ assert_equal(@ar2[0,last_row], 0)
107
+ assert_equal(@ar2[last_col,0], 3)
108
+ assert_equal(@ar2[last_col,last_row], 1)
109
+ @ar2.set(-1)
110
+ @num_rows.times do |i|
111
+ @num_cols.times do |j|
112
+ assert_equal(-1, @ar2[j,i])
113
+ end
114
+ end
115
+ assert_equal(-9, @arr.min)
116
+ assert_equal(8, @arr.max)
117
+ assert_equal(2, @arr.min_gt(1))
118
+ assert_equal(7, @arr.max_lt(8))
119
+ end
120
+
121
+ def test_math_ops
122
+ read_data
123
+ @ar2 = @arr + 2
124
+ @num_rows.times do |i|
125
+ @num_cols.times do |j|
126
+ assert_equal(@arr[i,j]+2, @ar2[i,j])
127
+ end
128
+ end
129
+ @ar2 = 2 * @arr
130
+ @num_rows.times do |i|
131
+ @num_cols.times do |j|
132
+ assert_equal(2 * @arr[i,j], @ar2[i,j])
133
+ end
134
+ end
135
+ @ar2 = @arr.floor
136
+ @num_rows.times do |i|
137
+ @num_cols.times do |j|
138
+ assert_equal(@arr[i,j].floor, @ar2[i,j])
139
+ end
140
+ end
141
+ @ar2 = @arr.pow(3)
142
+ @num_rows.times do |i|
143
+ @num_cols.times do |j|
144
+ assert_equal(@arr[i,j].pow(3), @ar2[i,j])
145
+ end
146
+ end
147
+ @ar2 = @arr.safe_log10
148
+ @num_rows.times do |i|
149
+ @num_cols.times do |j|
150
+ assert_equal(@arr[i,j].safe_log10, @ar2[i,j])
151
+ end
152
+ end
153
+ end
154
+
155
+ def test_bang_ops
156
+ read_data
157
+ @ar2 = @arr.dup.abs!.safe_sqrt!
158
+ @num_rows.times do |i|
159
+ @num_cols.times do |j|
160
+ assert_equal(@arr[i,j].abs.safe_sqrt, @ar2[i,j])
161
+ end
162
+ end
163
+ end
164
+
165
+ def test_dvec_ops
166
+ read_data
167
+ @row1 = @arr.row(1)
168
+ assert_equal(@num_cols, @row1.size)
169
+ @num_cols.times do |j|
170
+ assert_equal(@arr[1,j], @row1[j])
171
+ end
172
+ @col1 = @arr.column(1)
173
+ assert_equal(@num_rows, @col1.size)
174
+ @num_rows.times do |i|
175
+ assert_equal(@arr[i,1], @col1[i])
176
+ end
177
+ @arr.set_row(2,@row1)
178
+ @num_cols.times do |j|
179
+ assert_equal(@arr[2,j], @row1[j])
180
+ end
181
+ @arr.set_column(2,@col1)
182
+ @num_rows.times do |i|
183
+ assert_equal(@arr[i,2], @col1[i])
184
+ end
185
+ end
186
+
187
+ def test_marshal
188
+ t = Dtable.new(3,4)
189
+ t[1,1] = 1.2
190
+ t[3,2] = 2.5
191
+
192
+ str = Marshal.dump(t)
193
+ tbis = Marshal.restore(str)
194
+ assert_equal(t.num_rows, tbis.num_rows)
195
+ i = 0
196
+ while i < t.num_rows
197
+ assert_equal(t.row(i), tbis.row(i))
198
+ i += 1
199
+ end
200
+ end
201
+
202
+ end
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+