Skip to content

Commit

Permalink
Changes for GSL-1.13.
Browse files Browse the repository at this point in the history
Runs OK, but left some tests.



git-svn-id: http://rb-gsl.rubyforge.org/svn/trunk/rb-gsl@106 6e764f74-f39f-46f8-8c54-8307d62afe8d
  • Loading branch information
ytsunesada committed Sep 15, 2009
1 parent 0792d86 commit a7c1fbe
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 59 deletions.
2 changes: 0 additions & 2 deletions examples/const/hoge.txt

This file was deleted.

3 changes: 1 addition & 2 deletions ext/complex.c
Expand Up @@ -962,10 +962,9 @@ void Init_gsl_complex(VALUE module)
rb_define_singleton_method(cgsl_complex, "arccoth", rb_gsl_complex_arccoth, -1); rb_define_singleton_method(cgsl_complex, "arccoth", rb_gsl_complex_arccoth, -1);


/***/ /***/
rb_define_method(cgsl_complex, "sqrt", rb_gsl_complex_sqrt, -1);
rb_define_method(cgsl_complex, "pow", rb_gsl_complex_pow, -1); rb_define_method(cgsl_complex, "pow", rb_gsl_complex_pow, -1);
rb_define_method(cgsl_complex, "pow_real", rb_gsl_complex_pow_real, -1); rb_define_method(cgsl_complex, "pow_real", rb_gsl_complex_pow_real, -1);
rb_define_method(cgsl_complex, "exp", rb_gsl_complex_exp, -1);


rb_define_method(cgsl_complex, "exp", rb_gsl_complex_exp, -1); rb_define_method(cgsl_complex, "exp", rb_gsl_complex_exp, -1);
rb_define_method(cgsl_complex, "log", rb_gsl_complex_log, -1); rb_define_method(cgsl_complex, "log", rb_gsl_complex_log, -1);
Expand Down
5 changes: 5 additions & 0 deletions ext/const.c
Expand Up @@ -188,6 +188,7 @@ static void rb_gsl_const_cgs(VALUE module)
rb_define_const(module, "RYDBERG", rb_float_new(GSL_CONST_CGS_RYDBERG)); rb_define_const(module, "RYDBERG", rb_float_new(GSL_CONST_CGS_RYDBERG));
rb_define_const(module, "BOHR_MAGNETON", rb_define_const(module, "BOHR_MAGNETON",
rb_float_new(GSL_CONST_CGS_BOHR_MAGNETON)); rb_float_new(GSL_CONST_CGS_BOHR_MAGNETON));

rb_define_const(module, "NUCLEAR_MAGNETON", rb_define_const(module, "NUCLEAR_MAGNETON",
rb_float_new(GSL_CONST_CGS_NUCLEAR_MAGNETON)); rb_float_new(GSL_CONST_CGS_NUCLEAR_MAGNETON));
rb_define_const(module, "ELECTRON_MAGNETIC_MOMENT", rb_define_const(module, "ELECTRON_MAGNETIC_MOMENT",
Expand Down Expand Up @@ -515,8 +516,10 @@ static void rb_gsl_const_cgs(VALUE module)
rb_define_const(module, "MASS_PROTON", rb_float_new(GSL_CONST_CGSM_MASS_PROTON)); rb_define_const(module, "MASS_PROTON", rb_float_new(GSL_CONST_CGSM_MASS_PROTON));
rb_define_const(module, "MASS_NEUTRON", rb_float_new(GSL_CONST_CGSM_MASS_NEUTRON)); rb_define_const(module, "MASS_NEUTRON", rb_float_new(GSL_CONST_CGSM_MASS_NEUTRON));
rb_define_const(module, "RYDBERG", rb_float_new(GSL_CONST_CGSM_RYDBERG)); rb_define_const(module, "RYDBERG", rb_float_new(GSL_CONST_CGSM_RYDBERG));

rb_define_const(module, "BOHR_MAGNETON", rb_define_const(module, "BOHR_MAGNETON",
rb_float_new(GSL_CONST_CGSM_BOHR_MAGNETON)); rb_float_new(GSL_CONST_CGSM_BOHR_MAGNETON));

rb_define_const(module, "NUCLEAR_MAGNETON", rb_define_const(module, "NUCLEAR_MAGNETON",
rb_float_new(GSL_CONST_CGSM_NUCLEAR_MAGNETON)); rb_float_new(GSL_CONST_CGSM_NUCLEAR_MAGNETON));
rb_define_const(module, "ELECTRON_MAGNETIC_MOMENT", rb_define_const(module, "ELECTRON_MAGNETIC_MOMENT",
Expand Down Expand Up @@ -599,7 +602,9 @@ static void rb_gsl_const_cgs(VALUE module)
rb_float_new(GSL_CONST_CGSM_ELECTRON_CHARGE)); rb_float_new(GSL_CONST_CGSM_ELECTRON_CHARGE));
rb_define_const(module, "ELECTRON_CHARGE_ESU", rb_define_const(module, "ELECTRON_CHARGE_ESU",
rb_float_new(GSL_CONST_CGSM_ELECTRON_CHARGE*GSL_CONST_CGSM_SPEED_OF_LIGHT)); rb_float_new(GSL_CONST_CGSM_ELECTRON_CHARGE*GSL_CONST_CGSM_SPEED_OF_LIGHT));
#ifndef GSL_1_13_LATER
rb_define_const(module, "GAUSS", rb_float_new(GSL_CONST_CGSM_GAUSS)); rb_define_const(module, "GAUSS", rb_float_new(GSL_CONST_CGSM_GAUSS));
#endif
rb_define_const(module, "STILB", rb_float_new(GSL_CONST_CGSM_STILB)); rb_define_const(module, "STILB", rb_float_new(GSL_CONST_CGSM_STILB));
rb_define_const(module, "LUMEN", rb_float_new(GSL_CONST_CGSM_LUMEN)); rb_define_const(module, "LUMEN", rb_float_new(GSL_CONST_CGSM_LUMEN));
rb_define_const(module, "LUX", rb_float_new(GSL_CONST_CGSM_LUX)); rb_define_const(module, "LUX", rb_float_new(GSL_CONST_CGSM_LUX));
Expand Down
2 changes: 1 addition & 1 deletion ext/eigen.c
Expand Up @@ -2180,7 +2180,7 @@ void Init_gsl_eigen(VALUE module)
rb_gsl_eigen_symmv, -1); rb_gsl_eigen_symmv, -1);
rb_define_module_function(mgsl_eigen, "herm", rb_define_module_function(mgsl_eigen, "herm",
rb_gsl_eigen_herm, -1); rb_gsl_eigen_herm, -1);
rb_define_module_function(mgsl_eigen, "herm", rb_define_module_function(mgsl_eigen, "hermv",
rb_gsl_eigen_hermv, -1); rb_gsl_eigen_hermv, -1);


rb_define_module_function(module, "eigen_symm", rb_define_module_function(module, "eigen_symm",
Expand Down
4 changes: 1 addition & 3 deletions ext/linalg_complex.c
Expand Up @@ -709,8 +709,6 @@ void Init_gsl_linalg_complex(VALUE module)
rb_define_singleton_method(mgsl_linalg_complex_chol, "decomp", rb_gsl_linalg_cholesky_decomp, -1); rb_define_singleton_method(mgsl_linalg_complex_chol, "decomp", rb_gsl_linalg_cholesky_decomp, -1);
rb_define_method(cgsl_matrix_complex, "cholesky_decomp", rb_gsl_linalg_cholesky_decomp, -1); rb_define_method(cgsl_matrix_complex, "cholesky_decomp", rb_gsl_linalg_cholesky_decomp, -1);
rb_define_singleton_method(mgsl_linalg_complex_chol, "solve", rb_gsl_linalg_cholesky_solve, -1); rb_define_singleton_method(mgsl_linalg_complex_chol, "solve", rb_gsl_linalg_cholesky_solve, -1);
rb_define_method(cgsl_matrix_complex, "cholesky_solve", rb_gsl_linalg_cholesky_solve, -1);

rb_define_method(cgsl_matrix_complex, "cholesky_solve", rb_gsl_linalg_cholesky_solve, -1); rb_define_method(cgsl_matrix_complex, "cholesky_solve", rb_gsl_linalg_cholesky_solve, -1);
rb_define_method(cgsl_matrix_complex_C, "solve", rb_gsl_linalg_cholesky_solve, -1); rb_define_method(cgsl_matrix_complex_C, "solve", rb_gsl_linalg_cholesky_solve, -1);
rb_define_singleton_method(mgsl_linalg_complex_chol, "svx", rb_gsl_linalg_cholesky_svx, -1); rb_define_singleton_method(mgsl_linalg_complex_chol, "svx", rb_gsl_linalg_cholesky_svx, -1);
Expand All @@ -722,7 +720,7 @@ void Init_gsl_linalg_complex(VALUE module)
rb_gsl_linalg_complex_householder_transform, -1); rb_gsl_linalg_complex_householder_transform, -1);
rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform", rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform",
rb_gsl_linalg_complex_householder_transform, -1); rb_gsl_linalg_complex_householder_transform, -1);
rb_define_method(cgsl_vector, "householder_transform", rb_define_method(cgsl_vector_complex, "householder_transform",
rb_gsl_linalg_complex_householder_transform, -1); rb_gsl_linalg_complex_householder_transform, -1);


rb_define_singleton_method(mgsl_linalg_complex, "householder_hm", rb_define_singleton_method(mgsl_linalg_complex, "householder_hm",
Expand Down
2 changes: 0 additions & 2 deletions ext/matrix_source.c
Expand Up @@ -2553,8 +2553,6 @@ void FUNCTION(Init_gsl_matrix,init)(VALUE module)
rb_define_method(GSL_TYPE(cgsl_matrix), "+@", rb_define_method(GSL_TYPE(cgsl_matrix), "+@",
FUNCTION(rb_gsl_matrix,uplus), 0); FUNCTION(rb_gsl_matrix,uplus), 0);


rb_define_method(GSL_TYPE(cgsl_matrix), "power",
FUNCTION(rb_gsl_matrix,power), 1);


/*****/ /*****/
rb_define_method(GSL_TYPE(cgsl_matrix), "submatrix", rb_define_method(GSL_TYPE(cgsl_matrix), "submatrix",
Expand Down
2 changes: 1 addition & 1 deletion ext/multifit.c
Expand Up @@ -1808,7 +1808,7 @@ void Init_gsl_multifit(VALUE module)
rb_define_method(cgsl_multifit_fdfsolver, "name", rb_gsl_multifit_fdfsolver_name, 0); rb_define_method(cgsl_multifit_fdfsolver, "name", rb_gsl_multifit_fdfsolver_name, 0);
rb_define_method(cgsl_multifit_fdfsolver, "iterate", rb_gsl_multifit_fdfsolver_iterate, 0); rb_define_method(cgsl_multifit_fdfsolver, "iterate", rb_gsl_multifit_fdfsolver_iterate, 0);
rb_define_method(cgsl_multifit_fdfsolver, "position", rb_gsl_multifit_fdfsolver_position, 0); rb_define_method(cgsl_multifit_fdfsolver, "position", rb_gsl_multifit_fdfsolver_position, 0);
rb_define_alias(cgsl_multifit_fdfsolver, "x", "position"); // rb_define_alias(cgsl_multifit_fdfsolver, "x", "position");
rb_define_method(cgsl_multifit_fdfsolver, "print_state", rb_gsl_multifit_fdfsolver_print_state, 1); rb_define_method(cgsl_multifit_fdfsolver, "print_state", rb_gsl_multifit_fdfsolver_print_state, 1);
rb_define_method(cgsl_multifit_fdfsolver, "fdf", rb_gsl_multifit_fdfsolver_fdf, 0); rb_define_method(cgsl_multifit_fdfsolver, "fdf", rb_gsl_multifit_fdfsolver_fdf, 0);
rb_define_method(cgsl_multifit_fdfsolver, "test_delta", rb_gsl_multifit_fdfsolver_test_delta, 2); rb_define_method(cgsl_multifit_fdfsolver, "test_delta", rb_gsl_multifit_fdfsolver_test_delta, 2);
Expand Down
1 change: 0 additions & 1 deletion ext/permutation.c
Expand Up @@ -531,7 +531,6 @@ void Init_gsl_permutation(VALUE module)
rb_define_singleton_method(cgsl_permutation, "calloc", rb_gsl_permutation_calloc, 1); rb_define_singleton_method(cgsl_permutation, "calloc", rb_gsl_permutation_calloc, 1);
rb_define_method(cgsl_permutation, "size", rb_gsl_permutation_size, 0); rb_define_method(cgsl_permutation, "size", rb_gsl_permutation_size, 0);
rb_define_method(cgsl_permutation, "init", rb_gsl_permutation_init, 0); rb_define_method(cgsl_permutation, "init", rb_gsl_permutation_init, 0);
rb_define_method(cgsl_permutation, "print", rb_gsl_permutation_print, 0);
rb_define_method(cgsl_permutation, "inspect", rb_gsl_permutation_inspect, 0); rb_define_method(cgsl_permutation, "inspect", rb_gsl_permutation_inspect, 0);
rb_define_method(cgsl_permutation, "to_s", rb_gsl_permutation_to_s, 0); rb_define_method(cgsl_permutation, "to_s", rb_gsl_permutation_to_s, 0);
rb_define_method(cgsl_permutation, "get", rb_gsl_permutation_get, -1); rb_define_method(cgsl_permutation, "get", rb_gsl_permutation_get, -1);
Expand Down
2 changes: 1 addition & 1 deletion ext/poly_source.c
Expand Up @@ -1793,7 +1793,7 @@ void FUNCTION(Init_gsl_poly,init)(VALUE module)
#endif #endif


#ifdef BASE_DOUBLE #ifdef BASE_DOUBLE
rb_define_singleton_method(cgsl_poly, "eval", rb_gsl_poly_eval_singleton, 2); // rb_define_singleton_method(cgsl_poly, "eval", rb_gsl_poly_eval_singleton, 2);
rb_define_method(cgsl_poly, "to_i", rb_gsl_poly_to_i, 0); rb_define_method(cgsl_poly, "to_i", rb_gsl_poly_to_i, 0);
#ifdef GSL_1_11_LATER #ifdef GSL_1_11_LATER
rb_define_singleton_method(cgsl_poly, "complex_eval", rb_gsl_poly_eval_singleton, 2); rb_define_singleton_method(cgsl_poly, "complex_eval", rb_gsl_poly_eval_singleton, 2);
Expand Down
2 changes: 1 addition & 1 deletion ext/vector_complex.c
Expand Up @@ -2055,7 +2055,7 @@ void Init_gsl_vector_complex(VALUE module)
rb_define_method(cgsl_vector_complex, "coerce", rb_gsl_vector_complex_coerce, 1); rb_define_method(cgsl_vector_complex, "coerce", rb_gsl_vector_complex_coerce, 1);


/* 2.Aug.2004 */ /* 2.Aug.2004 */
rb_define_singleton_method(cgsl_vector, "inner_product", rb_gsl_vector_complex_inner_product, -1); rb_define_singleton_method(cgsl_vector_complex, "inner_product", rb_gsl_vector_complex_inner_product, -1);
rb_define_singleton_method(cgsl_vector_complex, "dot", rb_gsl_vector_complex_inner_product, -1); rb_define_singleton_method(cgsl_vector_complex, "dot", rb_gsl_vector_complex_inner_product, -1);
rb_define_method(cgsl_vector_complex, "inner_product", rb_gsl_vector_complex_inner_product, -1); rb_define_method(cgsl_vector_complex, "inner_product", rb_gsl_vector_complex_inner_product, -1);
/* rb_define_alias(cgsl_vector_complex, "dot", "inner_product");*/ /* rb_define_alias(cgsl_vector_complex, "dot", "inner_product");*/
Expand Down
12 changes: 0 additions & 12 deletions ext/vector_double.c
Expand Up @@ -839,16 +839,6 @@ static VALUE rb_gsl_vector_plot2(int argc, VALUE *argv, VALUE obj)
return Qtrue; return Qtrue;
} }


static VALUE rb_gsl_vector_sqrt(VALUE obj)
{
gsl_vector *v = NULL, *vnew = NULL;
size_t i;
Data_Get_Vector(obj, v);
vnew = gsl_vector_alloc(v->size);
for (i = 0; i < v->size; i++) gsl_vector_set(vnew, i, sqrt(gsl_vector_get(v, i)));
return Data_Wrap_Struct(VECTOR_ROW_COL(obj), 0, gsl_vector_free, vnew);
}

static VALUE rb_gsl_vector_normalize(int argc, VALUE *argv, VALUE obj) static VALUE rb_gsl_vector_normalize(int argc, VALUE *argv, VALUE obj)
{ {
gsl_vector *v = NULL, *vnew = NULL; gsl_vector *v = NULL, *vnew = NULL;
Expand Down Expand Up @@ -1399,8 +1389,6 @@ void Init_gsl_vector(VALUE module)


/*****/ /*****/


rb_define_method(cgsl_vector, "sqrt", rb_gsl_vector_sqrt, 0);

rb_define_method(cgsl_vector, "normalize", rb_gsl_vector_normalize, -1); rb_define_method(cgsl_vector, "normalize", rb_gsl_vector_normalize, -1);
rb_define_method(cgsl_vector, "normalize!", rb_gsl_vector_normalize_bang, -1); rb_define_method(cgsl_vector, "normalize!", rb_gsl_vector_normalize_bang, -1);


Expand Down
4 changes: 2 additions & 2 deletions tests/gsl_test.rb
Expand Up @@ -40,7 +40,7 @@ def test_factor(result, expected, factor, desc)
end end
end end


def test_factor2(result, expected, factor, desc) def test_factor2(result, expected, factor, desc)
status = nil status = nil
if result == expected if result == expected
status = false status = false
Expand All @@ -59,7 +59,7 @@ def test_factor2(result, expected, factor, desc)
printf("FAIL: #{desc} (%.18g observed vs %.18g expected)\n", result, expected) printf("FAIL: #{desc} (%.18g observed vs %.18g expected)\n", result, expected)
end end
end end

def test_rel(result, expected, relerr, desc) def test_rel(result, expected, relerr, desc)
status = nil status = nil
if isnan?(result) or isnan?(expected) if isnan?(result) or isnan?(expected)
Expand Down
31 changes: 0 additions & 31 deletions tests/linalg/cholesky.rb
Expand Up @@ -18,34 +18,3 @@
a = c.lower a = c.lower
test2(a == c_exp, "#{m.class}#cholesky_decomp") test2(a == c_exp, "#{m.class}#cholesky_decomp")
test2((a*a.trans) == m, "#{m.class}#cholesky_decomp") test2((a*a.trans) == m, "#{m.class}#cholesky_decomp")

require("test/unit")
class CholeskyTest < Test::Unit::TestCase
Data7 = GSL::Vector.alloc(66,0, 0,64, 126,63, 124,-62, 61,-61, 60,60, 0,-59,
0,-64, 65,0, 62,-124, -61,-122, -60,-60, 59,-59, -58,0,
126,-63, 62,124, 308,0, 180,-240, 59,-177, 174,58, -57,
-114,
124,62, -61,122, 180,240, 299,0, 174,-58, 57,171, 56,-112,
61,61, -60,60, 59,177, 174,58, 119,0, 0,112, 55,-55,
60,-60, 59,59, 174,-58, 57,-171, 0,-112, 116,0, -54,-54,
0,59, -58,0, -57,114, 56,112, 55,55, -54,54, 60,0).to_complex2.matrix_view(7, 7)
Data7_sol = GSL::Vector.alloc(-0.524944196428570,0.209123883928571,
1.052873883928572,0.712444196428571,
0.117568824404762,0.443191964285714,
0.412862723214286,-0.356696428571429,
0.815931919642858,-0.265820312500000,
0.777929687500000,0.119484747023810,
1.058733258928571,-0.132087053571429).to_complex2
RHS = GSL::Vector.alloc(1, 2, 3, 4, 5, 6, 7).to_complex
def test_linalg_complex_cholesky_solve
c = GSL::Linalg::Complex::Cholesky::decomp(Data7)
x = GSL::Linalg::Complex::Cholesky::solve(c, RHS)
assert_equal(x, Data7_sol)
end
def test_linalg_complex_cholesky_svx
c = GSL::Linalg::Complex::Cholesky::decomp(Data7)
x = RHS.clone
GSL::Linalg::Complex::Cholesky::svx(c, x)
assert_equal(x, Data7_sol)
end
end

0 comments on commit a7c1fbe

Please sign in to comment.