ruby-mpfi 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +0,0 @@
1
- #ifndef _RUBY_MPFI_H_
2
- #define _RUBY_MPFI_H_
3
-
4
- #include <stdio.h>
5
- #include <ruby.h>
6
- #include <mpfr.h>
7
- #include <mpfi.h>
8
- #include <mpfi_io.h>
9
- #include "func_mpfi_extention.h"
10
- #include "ruby_mpfr.h"
11
-
12
- typedef __mpfi_struct MPFI;
13
-
14
- VALUE r_mpfi_class, r_mpfi_math;;
15
-
16
- #define r_mpfi_make_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfi_class, MPFI, 0, r_mpfi_free, c_var); }
17
- #define r_mpfi_make_struct_init(ruby_var, c_var) { r_mpfi_make_struct(ruby_var, c_var); mpfi_init(c_var); }
18
- #define r_mpfi_make_struct_init2(ruby_var, c_var, prec) { r_mpfi_make_struct(ruby_var, c_var); mpfi_init2(c_var, prec); }
19
- #define r_mpfi_get_struct(c_var, ruby_var) { Data_Get_Struct(ruby_var, MPFI, c_var); }
20
-
21
- #define r_mpfi_temp_alloc(c_var) { c_var=ALLOC_N(MPFI, 1); }
22
- #define r_mpfi_temp_alloc_init(c_var) { r_mpfi_temp_alloc(c_var); mpfi_init(c_var); }
23
- #define r_mpfi_temp_alloc_init2(c_var, prec) { r_mpfi_temp_alloc(c_var); mpfi_init2(c_var, prec); }
24
- #define r_mpfi_temp_free(c_var) { mpfi_clear(c_var); free(c_var); }
25
-
26
- #define r_mpfi_left_ptr(c_var) (&((c_var)->left))
27
- #define r_mpfi_right_ptr(c_var) (&((c_var)->right))
28
-
29
- void r_mpfi_free(void *ptr);
30
- VALUE r_mpfi_make_new_fi_obj(MPFI *ptr);
31
- VALUE r_mpfi_new_fi_obj(VALUE obj);
32
- void r_mpfi_set_robj(MPFI *ptr, VALUE obj);
33
-
34
- int r_mpfi_subdivision2(int num, MPFI *ret, mpfi_t x);
35
-
36
- void r_mpfi_set_function_state(int num);
37
- VALUE r_mpfi_get_function_state(VALUE self);
38
-
39
- void r_mpfi_load_string(MPFI *ptr_s, const char *dump);
40
- char *r_mpfi_dump_to_string(MPFI *ptr_s);
41
-
42
- #endif /* _RUBY_MPFI_H_ */
@@ -1,44 +0,0 @@
1
- #ifndef _RUBY_MPFR_H_
2
- #define _RUBY_MPFR_H_
3
-
4
- #include <ruby.h>
5
- #include <mpfr.h>
6
- #include <stdio.h>
7
-
8
- typedef __mpfr_struct MPFR;
9
-
10
- VALUE r_mpfr_class, r_mpfr_math;
11
-
12
- #define r_mpfr_make_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfr_class, MPFR, 0, r_mpfr_free, c_var); }
13
- #define r_mpfr_make_struct_init(ruby_var, c_var) { r_mpfr_make_struct(ruby_var, c_var); mpfr_init(c_var); }
14
- #define r_mpfr_make_struct_init2(ruby_var, c_var, prec) { r_mpfr_make_struct(ruby_var, c_var); mpfr_init2(c_var, prec); }
15
- #define r_mpfr_get_struct(c_var, ruby_var) { Data_Get_Struct(ruby_var, MPFR, c_var); }
16
-
17
- #define r_mpfr_temp_alloc(var) { var=ALLOC_N(MPFR, 1); }
18
- #define r_mpfr_temp_alloc_init(var) { r_mpfr_temp_alloc(var); mpfr_init(var); }
19
- #define r_mpfr_temp_alloc_init2(var, prec) { r_mpfr_temp_alloc(var); mpfr_init2(var, prec); }
20
- #define r_mpfr_temp_free(var) { mpfr_clear(var); free(var); }
21
-
22
- #define r_mpfr_check_number(c_val) { if(mpfr_number_p(c_val) == 0) rb_raise(rb_eArgError, "Not an ordinary number."); }
23
- #define r_mpfr_check_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) <= 0) rb_raise(rb_eArgError, "Not a positive number."); }
24
- #define r_mpfr_check_non_negative_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) < 0) rb_raise(rb_eArgError, "Not a non negative number."); }
25
- #define r_mpfr_check_negative_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) >= 0) rb_raise(rb_eArgError, "Not a negative number."); }
26
- #define r_mpfr_check_non_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) > 0) rb_raise(rb_eArgError, "Not a non positive number."); }
27
-
28
- void r_mpfr_free(void *ptr);
29
- VALUE r_mpfr_make_new_fr_obj(MPFR *ptr);
30
- VALUE r_mpfr_make_new_fr_obj2(MPFR *ptr, int prec);
31
- VALUE r_mpfr_new_fr_obj(VALUE obj);
32
- void r_mpfr_set_robj(MPFR *ptr, VALUE obj, mp_rnd_t rnd);
33
- VALUE r_mpfr_robj_to_mpfr(VALUE obj, int argc, VALUE *argv);
34
-
35
- mp_rnd_t r_mpfr_rnd_from_value(VALUE rnd);
36
- mp_rnd_t r_mpfr_rnd_from_optional_argument(int min, int max, int argc, VALUE *argv);
37
- mp_rnd_t r_mpfr_prec_from_optional_argument(int min, int max, int argc, VALUE *argv);
38
- void r_mpfr_get_rnd_prec_from_optional_arguments(mp_rnd_t *rnd, mp_prec_t *prec, int min, int max, int argc, VALUE *argv);
39
-
40
- char *r_mpfr_dump_to_string(MPFR *ptr_s);
41
- void r_mpfr_load_string(MPFR *ptr_s, const char *dump);
42
-
43
- #endif /* _RUBY_MPFR_H_ */
44
-
@@ -1,72 +0,0 @@
1
- #include <stdio.h>
2
- #include <ruby.h>
3
- #include <mpfr.h>
4
- #include "ruby_mpfr.h"
5
-
6
- typedef struct __MPFRMatrix{
7
- int row, column, size;
8
- MPFR *data;
9
- } MPFRMatrix;
10
-
11
- /*
12
- 1 2 3
13
- 4 5 6
14
-
15
- row = 2
16
- column = 3
17
- size = 6
18
- MPFR *data 1 4 2 5 3 6
19
-
20
- (i, j) element => data + i + row * j
21
- 0 <= i < 2, 0 <= j < 3
22
- */
23
-
24
- #define r_mpfr_make_matrix_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfr_matrix, MPFRMatrix, 0, r_mpfr_matrix_free, c_var); }
25
- #define r_mpfr_get_matrix_struct(c_var, ruby_var) { Data_Get_Struct(ruby_var, MPFRMatrix, c_var); }
26
-
27
- #define r_mpfr_make_square_matrix_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfr_square_matrix, MPFRMatrix, 0, r_mpfr_matrix_free, c_var); }
28
- #define r_mpfr_make_col_vector_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfr_col_vector, MPFRMatrix, 0, r_mpfr_matrix_free, c_var); }
29
- #define r_mpfr_make_row_vector_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfr_row_vector, MPFRMatrix, 0, r_mpfr_matrix_free, c_var); }
30
-
31
- #define r_mpfr_matrix_temp_alloc_init(c_var, i, j) { c_var = ALLOC_N(MPFRMatrix, 1); mpfr_matrix_init(c_var, i, j); }
32
- #define r_mpfr_matrix_temp_free(c_var) { mpfr_matrix_clear(c_var); free(c_var); }
33
-
34
- #define mpfr_matrix_get_ptr(matrix, i) (matrix->data + i)
35
- #define mpfr_matrix_get_element(matrix, i, j) (matrix->data + i + matrix->row * j)
36
-
37
- void mpfr_matrix_clear(MPFRMatrix *mat);
38
- void mpfr_matrix_init(MPFRMatrix *mat, int row, int column);
39
- void mpfr_matrix_set_zeros(MPFRMatrix *mat);
40
- void mpfr_matrix_set_element(MPFRMatrix *mat, int row, int col, MPFR *a);
41
- void mpfr_matrix_set(MPFRMatrix *new, MPFRMatrix *x);
42
- void mpfr_matrix_swap(MPFRMatrix *x, MPFRMatrix *y);
43
-
44
- void mpfr_matrix_row(MPFRMatrix *new, MPFRMatrix *x, int row);
45
- void mpfr_matrix_column(MPFRMatrix *new, MPFRMatrix *x, int column);
46
- void mpfr_matrix_transpose(MPFRMatrix *new, MPFRMatrix *x);
47
- void mpfr_matrix_neg(MPFRMatrix *new, MPFRMatrix *x);
48
-
49
- int mpfr_matrix_equal_p(MPFRMatrix *x, MPFRMatrix *y);
50
- void mpfr_matrix_add(MPFRMatrix *new, MPFRMatrix *x, MPFRMatrix *y);
51
- void mpfr_matrix_sub(MPFRMatrix *new, MPFRMatrix *x, MPFRMatrix *y);
52
- void mpfr_matrix_mul(MPFRMatrix *new, MPFRMatrix *x, MPFRMatrix *y);
53
- void mpfr_matrix_mul_scalar(MPFRMatrix *new, MPFRMatrix *x, MPFR *scalar);
54
- void mpfr_matrix_div_scalar(MPFRMatrix *new, MPFRMatrix *x, MPFR *scalar);
55
- void mpfr_matrix_inner_product(MPFR *pr, MPFRMatrix *x, MPFRMatrix *y);
56
- void mpfr_matrix_vector_distance(MPFR *distance, MPFRMatrix *x, MPFRMatrix *y);
57
- void mpfr_matrix_vector_norm(MPFR *norm, MPFRMatrix *x);
58
- void mpfr_matrix_max_norm(MPFR *norm, MPFRMatrix *x);
59
-
60
- void mpfr_col_vector_init(MPFRMatrix *mat, int row);
61
- void mpfr_row_vector_init(MPFRMatrix *mat, int column);
62
- int mpfr_vector_normalize(MPFRMatrix *new, MPFRMatrix *x);
63
- int mpfr_vector_set_length(MPFRMatrix *new, MPFRMatrix *x, MPFR *l);
64
- void mpfr_vector_midpoint(MPFRMatrix *new, MPFRMatrix *x, MPFRMatrix *y);
65
- void mpfr_vector_dividing_point(MPFRMatrix *new, MPFRMatrix *x, MPFRMatrix *y, MPFR *div);
66
-
67
- int mpfr_square_matrix_lu_decomp (MPFRMatrix *ret, int *indx, MPFRMatrix *x);
68
- void mpfr_square_matrix_determinant(MPFR *det, MPFRMatrix *x);
69
- void mpfr_square_matrix_qr_decomp(MPFRMatrix *q, MPFRMatrix *r, MPFRMatrix *x);
70
- void mpfr_square_matrix_identity(MPFRMatrix *id);
71
-
72
-
@@ -1,42 +0,0 @@
1
- #ifndef _RUBY_MPFI_H_
2
- #define _RUBY_MPFI_H_
3
-
4
- #include <stdio.h>
5
- #include <ruby.h>
6
- #include <mpfr.h>
7
- #include <mpfi.h>
8
- #include <mpfi_io.h>
9
- #include "func_mpfi_extention.h"
10
- #include "ruby_mpfr.h"
11
-
12
- typedef __mpfi_struct MPFI;
13
-
14
- VALUE r_mpfi_class, r_mpfi_math;;
15
-
16
- #define r_mpfi_make_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfi_class, MPFI, 0, r_mpfi_free, c_var); }
17
- #define r_mpfi_make_struct_init(ruby_var, c_var) { r_mpfi_make_struct(ruby_var, c_var); mpfi_init(c_var); }
18
- #define r_mpfi_make_struct_init2(ruby_var, c_var, prec) { r_mpfi_make_struct(ruby_var, c_var); mpfi_init2(c_var, prec); }
19
- #define r_mpfi_get_struct(c_var, ruby_var) { Data_Get_Struct(ruby_var, MPFI, c_var); }
20
-
21
- #define r_mpfi_temp_alloc(c_var) { c_var=ALLOC_N(MPFI, 1); }
22
- #define r_mpfi_temp_alloc_init(c_var) { r_mpfi_temp_alloc(c_var); mpfi_init(c_var); }
23
- #define r_mpfi_temp_alloc_init2(c_var, prec) { r_mpfi_temp_alloc(c_var); mpfi_init2(c_var, prec); }
24
- #define r_mpfi_temp_free(c_var) { mpfi_clear(c_var); free(c_var); }
25
-
26
- #define r_mpfi_left_ptr(c_var) (&((c_var)->left))
27
- #define r_mpfi_right_ptr(c_var) (&((c_var)->right))
28
-
29
- void r_mpfi_free(void *ptr);
30
- VALUE r_mpfi_make_new_fi_obj(MPFI *ptr);
31
- VALUE r_mpfi_new_fi_obj(VALUE obj);
32
- void r_mpfi_set_robj(MPFI *ptr, VALUE obj);
33
-
34
- int r_mpfi_subdivision2(int num, MPFI *ret, mpfi_t x);
35
-
36
- void r_mpfi_set_function_state(int num);
37
- VALUE r_mpfi_get_function_state(VALUE self);
38
-
39
- void r_mpfi_load_string(MPFI *ptr_s, const char *dump);
40
- char *r_mpfi_dump_to_string(MPFI *ptr_s);
41
-
42
- #endif /* _RUBY_MPFI_H_ */
@@ -1,44 +0,0 @@
1
- #ifndef _RUBY_MPFR_H_
2
- #define _RUBY_MPFR_H_
3
-
4
- #include <ruby.h>
5
- #include <mpfr.h>
6
- #include <stdio.h>
7
-
8
- typedef __mpfr_struct MPFR;
9
-
10
- VALUE r_mpfr_class, r_mpfr_math;
11
-
12
- #define r_mpfr_make_struct(ruby_var, c_var) { ruby_var = Data_Make_Struct(r_mpfr_class, MPFR, 0, r_mpfr_free, c_var); }
13
- #define r_mpfr_make_struct_init(ruby_var, c_var) { r_mpfr_make_struct(ruby_var, c_var); mpfr_init(c_var); }
14
- #define r_mpfr_make_struct_init2(ruby_var, c_var, prec) { r_mpfr_make_struct(ruby_var, c_var); mpfr_init2(c_var, prec); }
15
- #define r_mpfr_get_struct(c_var, ruby_var) { Data_Get_Struct(ruby_var, MPFR, c_var); }
16
-
17
- #define r_mpfr_temp_alloc(var) { var=ALLOC_N(MPFR, 1); }
18
- #define r_mpfr_temp_alloc_init(var) { r_mpfr_temp_alloc(var); mpfr_init(var); }
19
- #define r_mpfr_temp_alloc_init2(var, prec) { r_mpfr_temp_alloc(var); mpfr_init2(var, prec); }
20
- #define r_mpfr_temp_free(var) { mpfr_clear(var); free(var); }
21
-
22
- #define r_mpfr_check_number(c_val) { if(mpfr_number_p(c_val) == 0) rb_raise(rb_eArgError, "Not an ordinary number."); }
23
- #define r_mpfr_check_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) <= 0) rb_raise(rb_eArgError, "Not a positive number."); }
24
- #define r_mpfr_check_non_negative_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) < 0) rb_raise(rb_eArgError, "Not a non negative number."); }
25
- #define r_mpfr_check_negative_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) >= 0) rb_raise(rb_eArgError, "Not a negative number."); }
26
- #define r_mpfr_check_non_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) > 0) rb_raise(rb_eArgError, "Not a non positive number."); }
27
-
28
- void r_mpfr_free(void *ptr);
29
- VALUE r_mpfr_make_new_fr_obj(MPFR *ptr);
30
- VALUE r_mpfr_make_new_fr_obj2(MPFR *ptr, int prec);
31
- VALUE r_mpfr_new_fr_obj(VALUE obj);
32
- void r_mpfr_set_robj(MPFR *ptr, VALUE obj, mp_rnd_t rnd);
33
- VALUE r_mpfr_robj_to_mpfr(VALUE obj, int argc, VALUE *argv);
34
-
35
- mp_rnd_t r_mpfr_rnd_from_value(VALUE rnd);
36
- mp_rnd_t r_mpfr_rnd_from_optional_argument(int min, int max, int argc, VALUE *argv);
37
- mp_rnd_t r_mpfr_prec_from_optional_argument(int min, int max, int argc, VALUE *argv);
38
- void r_mpfr_get_rnd_prec_from_optional_arguments(mp_rnd_t *rnd, mp_prec_t *prec, int min, int max, int argc, VALUE *argv);
39
-
40
- char *r_mpfr_dump_to_string(MPFR *ptr_s);
41
- void r_mpfr_load_string(MPFR *ptr_s, const char *dump);
42
-
43
- #endif /* _RUBY_MPFR_H_ */
44
-
@@ -1,13 +0,0 @@
1
- #ifndef RUBY_GMP_MATRIX
2
- #define RUBY_GMP_MATRIX
3
-
4
- #include "func_mpfr_matrix.h"
5
-
6
- VALUE r_mpfr_matrix, r_mpfr_square_matrix, r_mpfr_col_vector, r_mpfr_row_vector, r_mpfr_vector_module;
7
-
8
- void r_mpfr_matrix_free(void *ptr);
9
-
10
- void r_mpfr_matrix_suitable_matrix_init (VALUE *other, MPFRMatrix **ptr_other, int row, int column);
11
- VALUE r_mpfr_matrix_robj(MPFRMatrix *x);
12
-
13
- #endif
data/tasks/extconf.rake DELETED
@@ -1,36 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run 'make realclean' for extended libraries"
18
- task "ext:realclean" do
19
- Dir.glob("ext/**/Makefile").each do |path|
20
- system("cd #{File.dirname(path)}; make realclean")
21
- end
22
- end
23
-
24
- desc "Run 'make clean' for extended libraries"
25
- task "ext:clean" do
26
- Dir.glob("ext/**/Makefile").each do |path|
27
- system("cd #{File.dirname(path)}; make clean")
28
- end
29
- end
30
-
31
- desc "Run 'make realclean' for extended libraries"
32
- task 'ext:make' do
33
- Dir.glob("ext/**/extconf.rb").each do |path|
34
- system("cd #{File.dirname(path)}; ruby extconf.rb && make")
35
- end
36
- end