number 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/real_bounds.c ADDED
@@ -0,0 +1,57 @@
1
+ #include "number.h"
2
+
3
+ void real_bounds_free (RealBounds* bounds)
4
+ {
5
+ if (bounds)
6
+ {
7
+ if (bounds->min)
8
+ {
9
+ real_free(bounds->min);
10
+ }
11
+
12
+ if (bounds->max)
13
+ {
14
+ real_free(bounds->max);
15
+ }
16
+
17
+ free(bounds);
18
+ bounds = NULL;
19
+ }
20
+ }
21
+
22
+ void real_bounds_update (RealBounds* bounds, Real* real, int closed)
23
+ {
24
+ int min_cmp;
25
+ int max_cmp;
26
+
27
+ if (!bounds->min || (min_cmp = real_cmp(bounds->min, real)) != -1)
28
+ {
29
+ real_free(bounds->min);
30
+
31
+ bounds->min = (Real*)real_dup(real);
32
+ bounds->min_closed = (min_cmp) ? closed : bounds->min_closed || closed;
33
+ }
34
+
35
+ if (!bounds->max || (max_cmp = real_cmp(bounds->max, real)) != 1)
36
+ {
37
+ real_free(bounds->max);
38
+
39
+ bounds->max = (Real*)real_dup(real);
40
+ bounds->max_closed = (max_cmp) ? closed : bounds->max_closed || closed;
41
+ }
42
+
43
+ real_free(real);
44
+ }
45
+
46
+ RealBounds* real_bounds_new ()
47
+ {
48
+ RealBounds* bounds;
49
+ bounds = malloc(sizeof(RealBounds));
50
+
51
+ if (bounds == NULL)
52
+ {
53
+ return NULL;
54
+ }
55
+
56
+ memset(bounds, 0, sizeof(RealBounds));
57
+ }
data/ext/round.c ADDED
@@ -0,0 +1,46 @@
1
+ #include "number.h"
2
+
3
+ Complex* complex_round (Complex* complex)
4
+ {
5
+ return (Complex*)complex_new((Interval*)interval_round(complex->re), (Interval*)interval_round(complex->im));
6
+ }
7
+
8
+ Complex* complex_round_c_c (Complex* complex)
9
+ {
10
+ return (Complex*)complex_new((Interval*)interval_round_ceiling(complex->re), (Interval*)interval_round_ceiling(complex->im));
11
+ }
12
+
13
+ Complex* complex_round_c_f (Complex* complex)
14
+ {
15
+ return (Complex*)complex_new((Interval*)interval_round_floor(complex->re), (Interval*)interval_round_ceiling(complex->im));
16
+ }
17
+
18
+ Complex* complex_round_f_c (Complex* complex)
19
+ {
20
+ return (Complex*)complex_new((Interval*)interval_round_ceiling(complex->re), (Interval*)interval_round_floor(complex->im));
21
+ }
22
+
23
+ Complex* complex_round_f_f (Complex* complex)
24
+ {
25
+ return (Complex*)complex_new((Interval*)interval_round_floor(complex->re), (Interval*)interval_round_floor(complex->im));
26
+ }
27
+
28
+ Complex* complex_round_i_i (Complex* complex)
29
+ {
30
+ return (Complex*)complex_new((Interval*)interval_round_infinity(complex->re), (Interval*)interval_round_infinity(complex->im));
31
+ }
32
+
33
+ Complex* complex_round_i_o (Complex* complex)
34
+ {
35
+ return (Complex*)complex_new((Interval*)interval_round_infinity(complex->re), (Interval*)interval_round_origin(complex->im));
36
+ }
37
+
38
+ Complex* complex_round_o_i (Complex* complex)
39
+ {
40
+ return (Complex*)complex_new((Interval*)interval_round_origin(complex->re), (Interval*)interval_round_infinity(complex->im));
41
+ }
42
+
43
+ Complex* complex_round_o_o (Complex* complex)
44
+ {
45
+ return (Complex*)complex_new((Interval*)interval_round_origin(complex->re), (Interval*)interval_round_origin(complex->im));
46
+ }
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: number
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.9.0
6
+ platform: ruby
7
+ authors:
8
+ - Jesse Sielaff
9
+ - Dane Hillard
10
+ - Trek Glowacki
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2011-07-15 00:00:00 Z
16
+ dependencies: []
17
+
18
+ description: The Number gem is intended to be a drop-in replacement for Ruby's Numeric classes when arbitrary-precision complex interval calculations are warranted. The basis of the arbitrary-precision calculations is the GNU MP, MPFR, and MPC libraries.
19
+ email: jesse.sielaff@gmail.com
20
+ executables: []
21
+
22
+ extensions:
23
+ - ext/extconf.rb
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - ext/bounds.c
28
+ - ext/compare.c
29
+ - ext/complex.c
30
+ - ext/decompose.c
31
+ - ext/extconf.rb
32
+ - ext/interval.c
33
+ - ext/number.c
34
+ - ext/number.h
35
+ - ext/real.c
36
+ - ext/real_bounds.c
37
+ - ext/round.c
38
+ homepage:
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ - ext
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.9.2
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ requirements:
60
+ - GMP
61
+ - MPFR
62
+ - MPC
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.1
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: An arbitrary-precision complex interval number library for Ruby.
68
+ test_files: []
69
+