carray-gsl 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c8b74785542cb1662a05431117c483ed7a56e487
4
- data.tar.gz: 20c52d8cf11146d6109400b8fcb382e90d8a4b68
2
+ SHA256:
3
+ metadata.gz: '0427847b4968614e038e8396dde48bba089a7e65a47b0dc82bf6417cf6af9974'
4
+ data.tar.gz: 53a89928adbebaffa9b3e2b5f0f3c2ee29acd811d4ac086a96ab3399ffe45f0b
5
5
  SHA512:
6
- metadata.gz: 18f6da917bde79bc5eced98db907d046e99341f009835c739a56f5d97d9d92abcd2a84d7dfc9f9f8c058960bbd0e194456e5168bffd18ee76a1b3e3253695880
7
- data.tar.gz: b9798ba5a9feb0a873e38eaaebf110378346e09af57f0e69b5a9d13ca14f135a86fc70f0be58b5dcedd945939b9f4d7f6ea16fb1359185147b94d45a774fced4
6
+ metadata.gz: 6ab534743740183c20c0b94ffa053ebcac0738e74f9c43ee02da98ef5c40009d1b5bd1dfb57edc70446cc7b7838135aaf872453c90da59ea7de42a416c366b92
7
+ data.tar.gz: 82c77eadd821c234d1a568d4f3227c4eb0bfdd189417aaa3784e9333737b4a90339fec6ac8844ea4586de5b50c319a89ca4dcc1c650c07795c9165bf1770efa9
@@ -0,0 +1,17 @@
1
+ #
2
+ #
3
+ #
4
+
5
+ GEMSPEC = "carray-gsl.gemspec"
6
+
7
+ task :install do
8
+ spec = eval File.read(GEMSPEC)
9
+ system %{
10
+ gem build #{GEMSPEC}; gem install #{spec.full_name}.gem
11
+ }
12
+ end
13
+
14
+ require 'rspec/core/rake_task'
15
+ RSpec::Core::RakeTask.new
16
+
17
+
@@ -1,6 +1,6 @@
1
1
 
2
2
  Gem::Specification::new do |s|
3
- version = "1.0.0"
3
+ version = "1.1.0"
4
4
 
5
5
  files = Dir.glob("**/*") - [
6
6
  Dir.glob("carray*.gem"),
@@ -17,7 +17,8 @@ Gem::Specification::new do |s|
17
17
  s.email = ""
18
18
  s.homepage = 'https://github.com/himotoyoshi/carray-gsl'
19
19
  s.files = files
20
- s.extensions = [ "extconf.rb" ]
21
- s.has_rdoc = false
22
- s.required_ruby_version = ">= 1.8.1"
20
+ s.extensions = [ "ext/extconf.rb" ]
21
+ s.required_ruby_version = ">= 2.4.0"
22
+ s.add_runtime_dependency 'carray', '~> 1.4.0', '>=1.4.0'
23
+ s.add_runtime_dependency 'gsl', '~> 2.1.0.3', '>=2.1.0.3'
23
24
  end
@@ -0,0 +1,42 @@
1
+ require "carray-gsl"
2
+
3
+ class CArray
4
+
5
+ def mat_to_mat
6
+ Matrix[*self]
7
+ end
8
+
9
+ end
10
+
11
+ data = [
12
+ [1, 2],
13
+ [3, 4]
14
+ ]
15
+
16
+ mat = CA_DOUBLE(data)
17
+
18
+ out = mat.lu_decomp
19
+
20
+ p out
21
+
22
+ data = [
23
+ [1, 0],
24
+ [1.0/3.0,1]
25
+ ]
26
+ l = CA_DOUBLE(data).gm
27
+
28
+ data = [
29
+ [3, 4],
30
+ [0,2.0/3.0]
31
+ ]
32
+ u = CA_DOUBLE(data).gm
33
+
34
+ p out.upper
35
+ p out.lower
36
+
37
+ p l*u
38
+
39
+ __END__
40
+ require 'matrix'
41
+ a = Matrix[[1, 2], [3, 4]]
42
+ p a.lup.solve([3,-1])
@@ -0,0 +1,6 @@
1
+ require "carray-gsl"
2
+
3
+ x = CA_DOUBLE(0..1,0.1)
4
+ y = x**2
5
+
6
+ CAMath.graph(x,y)
@@ -0,0 +1,26 @@
1
+ require "carray-gsl"
2
+
3
+ f = GSL::Function.alloc { |x| Math::sin(x)/x }
4
+ p f.qag([0, 1])
5
+
6
+ include GSL
7
+
8
+ f = GSL::Function.alloc { |x|
9
+ pow(x,1.5)
10
+ }
11
+
12
+ printf ("f(x) = x^(3/2)\n");
13
+
14
+ x = 2.0
15
+ h = 1e-8
16
+ result, abserr = f.deriv_central(x, h)
17
+ printf("x = 2.0\n");
18
+ printf("f'(x) = %.12f +/- %.12f\n", result, abserr);
19
+ printf("exact = %.12f\n\n", 1.5 * Math::sqrt(2.0));
20
+
21
+ x = 0.0
22
+ result, abserr = Deriv.forward(f, x, h) # equivalent to f.deriv_forward(x, h)
23
+ printf("x = 0.0\n");
24
+ printf("f'(x) = %.10f +/- %.10f\n", result, abserr);
25
+ printf("exact = %.10f\n", 0.0);
26
+
@@ -26,7 +26,7 @@ rb_gsl_vector_ca (VALUE self)
26
26
  volatile VALUE obj, block;
27
27
  gsl_vector *v;
28
28
  int data_type;
29
- int32_t dim[2], dim0;
29
+ ca_size_t dim[2], dim0;
30
30
 
31
31
  Data_Get_Struct(self, gsl_vector, v);
32
32
 
@@ -44,7 +44,7 @@ rb_gsl_vector_ca (VALUE self)
44
44
  }
45
45
 
46
46
  if ( v->stride > 1 ) {
47
- int32_t start0, step0, count0;
47
+ ca_size_t start0, step0, count0;
48
48
  if ( rb_obj_is_kind_of(self, rb_cVectorCol) ||
49
49
  rb_obj_is_kind_of(self, rb_cVectorIntCol) ||
50
50
  rb_obj_is_kind_of(self, rb_cVectorComplexCol) ) {
@@ -168,7 +168,7 @@ rb_gsl_matrix_ca (VALUE self)
168
168
  volatile VALUE obj, block;
169
169
  gsl_matrix *v;
170
170
  int data_type;
171
- int32_t dim[2];
171
+ ca_size_t dim[2];
172
172
 
173
173
  Data_Get_Struct(self, gsl_matrix, v);
174
174
 
@@ -186,7 +186,7 @@ rb_gsl_matrix_ca (VALUE self)
186
186
  }
187
187
 
188
188
  if ( v->tda != v->size2 ) {
189
- int32_t start[2], step[2], count[2];
189
+ ca_size_t start[2], step[2], count[2];
190
190
  dim[0] = v->size1;
191
191
  dim[1] = v->tda;
192
192
  block = rb_carray_wrap_ptr(data_type, 2, dim, 0, NULL,
@@ -439,7 +439,7 @@ rb_camath_random_dir_2d (VALUE mod, VALUE vn)
439
439
  {
440
440
  CArray *cx, *cy;
441
441
  double *px, *py;
442
- int32_t elements = NUM2INT(vn), i;
442
+ ca_size_t elements = NUM2SIZE(vn), i;
443
443
  cx = carray_new(CA_DOUBLE, 1, &elements, 0, NULL);
444
444
  cy = carray_new(CA_DOUBLE, 1, &elements, 0, NULL);
445
445
  px = (double*) cx->ptr;
@@ -465,7 +465,7 @@ rb_camath_random_dir_3d (VALUE mod, VALUE vn)
465
465
  {
466
466
  CArray *cx, *cy, *cz;
467
467
  double *px, *py, *pz;
468
- int32_t elements = NUM2INT(vn), i;
468
+ ca_size_t elements = NUM2SIZE(vn), i;
469
469
  cx = carray_new(CA_DOUBLE, 1, &elements, 0, NULL);
470
470
  cy = carray_new(CA_DOUBLE, 1, &elements, 0, NULL);
471
471
  cz = carray_new(CA_DOUBLE, 1, &elements, 0, NULL);
@@ -499,7 +499,7 @@ rb_camath_random_dir_nd (VALUE mod, VALUE vn, VALUE vd)
499
499
  CArray **ca;
500
500
  double **p;
501
501
  double *pv;
502
- int32_t d = NUM2INT(vd), elements = NUM2INT(vn), k, i;
502
+ ca_size_t d = NUM2SIZE(vd), elements = NUM2SIZE(vn), k, i;
503
503
  if ( d < 0 ) {
504
504
  rb_raise(rb_eArgError, "dimension should be positive number");
505
505
  }
@@ -547,12 +547,12 @@ rb_camath_random_multinomial (VALUE mod,
547
547
  CArray **ca;
548
548
  unsigned int **pn;
549
549
  unsigned int *pv;
550
- int32_t elements, i, k, d, m;
551
- m = NUM2INT(vm);
550
+ ca_size_t elements, i, k, d, m;
551
+ m = NUM2SIZE(vm);
552
552
  if ( m <0 ) {
553
553
  rb_raise(rb_eArgError, "# of tries should be positive number");
554
554
  }
555
- elements = NUM2INT(vn);
555
+ elements = NUM2SIZE(vn);
556
556
  if ( elements < 0 ) {
557
557
  rb_raise(rb_eArgError, "elements should be positive number");
558
558
  }
@@ -571,7 +571,7 @@ rb_camath_random_multinomial (VALUE mod,
571
571
 
572
572
  ca_attach(cpk);
573
573
  for (i=0; i<elements; i++) {
574
- gsl_ran_multinomial(camath_gsl_rng, d, m, (double*)cpk->ptr, pv);
574
+ gsl_ran_multinomial(camath_gsl_rng, d, (unsigned int)m, (double*)cpk->ptr, pv);
575
575
  for (k=0; k<d; k++) {
576
576
  *(pn[k]) = pv[k];
577
577
  pn[k]++;
@@ -582,7 +582,7 @@ rb_camath_random_multinomial (VALUE mod,
582
582
  out = rb_ary_new();
583
583
  if ( elements == 1 ) {
584
584
  for (k=0; k<d; k++) {
585
- rb_ary_store(out, k, INT2NUM(*(unsigned int*)ca[k]->ptr));
585
+ rb_ary_store(out, k, UINT2NUM(*(unsigned int*)ca[k]->ptr));
586
586
  ca_free(ca[k]);
587
587
  }
588
588
  }
@@ -607,7 +607,7 @@ rb_camath_multinomial_pdf (VALUE mod,
607
607
  unsigned int **pn;
608
608
  unsigned int *pv;
609
609
  double *py;
610
- int32_t elements, i, k, d;
610
+ ca_size_t elements, i, k, d;
611
611
 
612
612
  Check_Type(vnk, T_ARRAY);
613
613
 
@@ -681,7 +681,7 @@ rb_camath_multinomial_lnpdf (VALUE mod,
681
681
  unsigned int **pn;
682
682
  unsigned int *pv;
683
683
  double *py;
684
- int32_t elements, i, k, d;
684
+ ca_size_t elements, i, k, d;
685
685
 
686
686
  Check_Type(vnk, T_ARRAY);
687
687
 
@@ -757,6 +757,8 @@ rb_camath_gsl_func_d_di(sf, airy_Ai_deriv_scaled);
757
757
  rb_camath_gsl_func_d_di(sf, airy_Bi_deriv_scaled);
758
758
  rb_camath_gsl_func_d_i(sf, airy_zero_Ai);
759
759
  rb_camath_gsl_func_d_i(sf, airy_zero_Bi);
760
+ rb_camath_gsl_func_d_i(sf, airy_zero_Ai_deriv);
761
+ rb_camath_gsl_func_d_i(sf, airy_zero_Bi_deriv);
760
762
 
761
763
  rb_camath_gsl_func_d_d(sf, bessel_J0);
762
764
  rb_camath_gsl_func_d_d(sf, bessel_J1);
@@ -805,6 +807,7 @@ rb_camath_gsl_func_d_dd(sf, bessel_Ynu);
805
807
  rb_camath_gsl_func_d_dd(sf, bessel_Inu);
806
808
  rb_camath_gsl_func_d_dd(sf, bessel_Inu_scaled);
807
809
  rb_camath_gsl_func_d_dd(sf, bessel_Knu);
810
+ rb_camath_gsl_func_d_dd(sf, bessel_lnKnu);
808
811
  rb_camath_gsl_func_d_dd(sf, bessel_Knu_scaled);
809
812
 
810
813
  rb_camath_gsl_func_d_i(sf, bessel_zero_J0);
@@ -821,6 +824,7 @@ rb_camath_gsl_func_d_iidd(sf, hydrogenicR);
821
824
  rb_camath_gsl_func_d_iiiiii(sf, coupling_3j);
822
825
  rb_camath_gsl_func_d_iiiiii(sf, coupling_6j);
823
826
 
827
+ /* not implemented : 9j symbols */
824
828
  /* rb_camath_gsl_func_d_iiiiiiiii(sf, coupling_9j); */
825
829
 
826
830
  rb_camath_gsl_func_d_d(sf, dawson);
@@ -833,7 +837,7 @@ rb_camath_gsl_func_d_d(sf, debye_5);
833
837
  rb_camath_gsl_func_d_d(sf, debye_6);
834
838
 
835
839
  rb_camath_gsl_func_d_d(sf, dilog);
836
- /* rb_camath_gsl_func_d_d(sf, complex_dilog); */
840
+ /* not implemented: rb_camath_gsl_func_d_d(sf, complex_dilog); */
837
841
 
838
842
  rb_camath_gsl_func_d_di(sf, ellint_Kcomp);
839
843
  rb_camath_gsl_func_d_di(sf, ellint_Ecomp);
@@ -841,7 +845,7 @@ rb_camath_gsl_func_d_ddi(sf, ellint_Pcomp);
841
845
  rb_camath_gsl_func_d_ddi(sf, ellint_F);
842
846
  rb_camath_gsl_func_d_ddi(sf, ellint_E);
843
847
  rb_camath_gsl_func_d_dddi(sf, ellint_P);
844
- rb_camath_gsl_func_d_dddi(sf, ellint_D);
848
+ rb_camath_gsl_func_d_ddi(sf, ellint_D);
845
849
  rb_camath_gsl_func_d_ddi(sf, ellint_RC);
846
850
  rb_camath_gsl_func_d_dddi(sf, ellint_RD);
847
851
  rb_camath_gsl_func_d_dddi(sf, ellint_RF);
@@ -850,18 +854,18 @@ rb_camath_gsl_func_d_ddddi(sf, ellint_RJ);
850
854
  rb_camath_gsl_func_ddd_dd(sf, elljac, _e);
851
855
 
852
856
  rb_camath_gsl_func_d_d(sf, erf);
853
- rb_camath_gsl_func_d_d(sf, erf_Z);
854
- rb_camath_gsl_func_d_d(sf, erf_Q);
855
857
  rb_camath_gsl_func_d_d(sf, erfc);
856
858
  rb_camath_gsl_func_d_d(sf, log_erfc);
859
+ rb_camath_gsl_func_d_d(sf, erf_Z);
860
+ rb_camath_gsl_func_d_d(sf, erf_Q);
857
861
  rb_camath_gsl_func_d_d(sf, hazard);
858
862
 
859
863
  /* rb_camath_gsl_func_d_dd(sf, exp); */
860
- /* rb_camath_gsl_func_d_dd(sf, exp_mult); */
861
- /* rb_camath_gsl_func_d_dd(sf, expm1); */
862
- /* rb_camath_gsl_func_d_dd(sf, exprel); */
863
- /* rb_camath_gsl_func_d_dd(sf, exprel_2); */
864
- /* rb_camath_gsl_func_d_dd(sf, exprel_n); */
864
+ rb_camath_gsl_func_d_dd(sf, exp_mult);
865
+ rb_camath_gsl_func_d_d(sf, expm1);
866
+ rb_camath_gsl_func_d_d(sf, exprel);
867
+ rb_camath_gsl_func_d_d(sf, exprel_2);
868
+ rb_camath_gsl_func_d_id(sf, exprel_n);
865
869
 
866
870
  rb_camath_gsl_func_d_d(sf, expint_E1);
867
871
  rb_camath_gsl_func_d_d(sf, expint_E2);
@@ -889,10 +893,6 @@ rb_camath_gsl_func_d_d(sf, lngamma);
889
893
  rb_camath_gsl_func_d_d(sf, gammastar);
890
894
  rb_camath_gsl_func_d_d(sf, gammainv);
891
895
 
892
- rb_camath_gsl_func_d_dd(sf, gamma_inc);
893
- rb_camath_gsl_func_d_dd(sf, gamma_inc_Q);
894
- rb_camath_gsl_func_d_dd(sf, gamma_inc_P);
895
-
896
896
  rb_camath_gsl_func_d_i(sf, fact);
897
897
  rb_camath_gsl_func_d_i(sf, doublefact);
898
898
  rb_camath_gsl_func_d_i(sf, lnfact);
@@ -901,6 +901,14 @@ rb_camath_gsl_func_d_ii(sf, choose);
901
901
  rb_camath_gsl_func_d_ii(sf, lnchoose);
902
902
  rb_camath_gsl_func_d_id(sf, taylorcoeff);
903
903
 
904
+ rb_camath_gsl_func_d_dd(sf, poch);
905
+ rb_camath_gsl_func_d_dd(sf, lnpoch);
906
+ rb_camath_gsl_func_d_dd(sf, pochrel);
907
+
908
+ rb_camath_gsl_func_d_dd(sf, gamma_inc);
909
+ rb_camath_gsl_func_d_dd(sf, gamma_inc_Q);
910
+ rb_camath_gsl_func_d_dd(sf, gamma_inc_P);
911
+
904
912
  rb_camath_gsl_func_d_dd(sf, beta);
905
913
  rb_camath_gsl_func_d_dd(sf, lnbeta);
906
914
  rb_camath_gsl_func_d_ddd(sf, beta_inc);
@@ -910,6 +918,19 @@ rb_camath_gsl_func_d_dd(sf, gegenpoly_2);
910
918
  rb_camath_gsl_func_d_dd(sf, gegenpoly_3);
911
919
  rb_camath_gsl_func_d_idd(sf, gegenpoly_n);
912
920
 
921
+ rb_camath_gsl_func_d_id(sf, hermite);
922
+ /* not implemented: herimite_series */
923
+ rb_camath_gsl_func_d_id(sf, hermite_prob);
924
+ /* not implemented: herimite_prob_series */
925
+ rb_camath_gsl_func_d_iid(sf, hermite_deriv);
926
+ rb_camath_gsl_func_d_iid(sf, hermite_prob_deriv);
927
+ rb_camath_gsl_func_d_id(sf, hermite_func);
928
+ rb_camath_gsl_func_d_id(sf, hermite_func_fast);
929
+ rb_camath_gsl_func_d_iid(sf, hermite_func_der);
930
+ rb_camath_gsl_func_d_ii(sf, hermite_zero);
931
+ rb_camath_gsl_func_d_ii(sf, hermite_prob_zero);
932
+ rb_camath_gsl_func_d_ii(sf, hermite_func_zero);
933
+
913
934
  rb_camath_gsl_func_d_dd(sf, hyperg_0F1);
914
935
  rb_camath_gsl_func_d_iid(sf, hyperg_1F1_int);
915
936
  rb_camath_gsl_func_d_ddd(sf, hyperg_1F1);
@@ -1185,7 +1206,7 @@ rb_camath_gsl_func_d_id(ran, logarithmic_pdf);
1185
1206
  void
1186
1207
  Init_carray_mathfunc_gsl ()
1187
1208
  {
1188
- uint32_t seed;
1209
+ unsigned long seed;
1189
1210
 
1190
1211
  camath_gsl_rng = gsl_rng_alloc(gsl_rng_mt19937);
1191
1212
 
@@ -1206,6 +1227,8 @@ Init_carray_mathfunc_gsl ()
1206
1227
  rb_define_camath_gsl_func2_(airy_Bi_deriv_scaled, 2);
1207
1228
  rb_define_camath_gsl_func2u(airy_zero_Ai, 1); /* not func2 */
1208
1229
  rb_define_camath_gsl_func2u(airy_zero_Bi, 1); /* not func2 */
1230
+ rb_define_camath_gsl_func2u(airy_zero_Ai_deriv, 1); /* not func2 */
1231
+ rb_define_camath_gsl_func2u(airy_zero_Bi_deriv, 1); /* not func2 */
1209
1232
 
1210
1233
  rb_define_camath_gsl_func2(bessel_J0, 1);
1211
1234
  rb_define_camath_gsl_func2(bessel_J1, 1);
@@ -1254,25 +1277,13 @@ Init_carray_mathfunc_gsl ()
1254
1277
  rb_define_camath_gsl_func2(bessel_Inu, 2);
1255
1278
  rb_define_camath_gsl_func2(bessel_Inu_scaled, 2);
1256
1279
  rb_define_camath_gsl_func2(bessel_Knu, 2);
1280
+ rb_define_camath_gsl_func2(bessel_lnKnu, 2);
1257
1281
  rb_define_camath_gsl_func2(bessel_Knu_scaled, 2);
1258
1282
 
1259
1283
  rb_define_camath_gsl_func2u(bessel_zero_J0, 1); /* not func2 */
1260
1284
  rb_define_camath_gsl_func2u(bessel_zero_J1, 1); /* not func2 */
1261
1285
  rb_define_camath_gsl_func2u(bessel_zero_Jnu, 2); /* not func2 */
1262
1286
 
1263
- rb_define_camath_gsl_func2(gamma, 1);
1264
- rb_define_camath_gsl_func2(lngamma, 1);
1265
- rb_define_camath_gsl_func2(gammastar, 1);
1266
- rb_define_camath_gsl_func2(gammainv, 1);
1267
-
1268
- rb_define_camath_gsl_func2(gamma_inc, 2);
1269
- rb_define_camath_gsl_func2(gamma_inc_P, 2);
1270
- rb_define_camath_gsl_func2(gamma_inc_Q, 2);
1271
-
1272
- rb_define_camath_gsl_func2(beta, 2);
1273
- rb_define_camath_gsl_func2(lnbeta, 2);
1274
- rb_define_camath_gsl_func2(beta_inc, 3);
1275
-
1276
1287
  rb_define_camath_gsl_func2(clausen, 1);
1277
1288
 
1278
1289
  rb_define_camath_gsl_func2(hydrogenicR_1, 2);
@@ -1306,14 +1317,6 @@ Init_carray_mathfunc_gsl ()
1306
1317
 
1307
1318
  rb_define_camath_gsl_func(elljac, 2); /* not func2 */
1308
1319
 
1309
- rb_define_camath_gsl_func2(fact, 1);
1310
- rb_define_camath_gsl_func2(doublefact, 1);
1311
- rb_define_camath_gsl_func2(lnfact, 1);
1312
- rb_define_camath_gsl_func2(lndoublefact, 1);
1313
- rb_define_camath_gsl_func2(choose, 2);
1314
- rb_define_camath_gsl_func2(lnchoose, 2);
1315
- rb_define_camath_gsl_func2(taylorcoeff, 2);
1316
-
1317
1320
  rb_define_camath_gsl_func2(erf, 1);
1318
1321
  rb_define_camath_gsl_func2(erf_Z, 1);
1319
1322
  rb_define_camath_gsl_func2(erf_Q, 1);
@@ -1321,6 +1324,12 @@ Init_carray_mathfunc_gsl ()
1321
1324
  rb_define_camath_gsl_func2(log_erfc, 1);
1322
1325
  rb_define_camath_gsl_func2(hazard, 1);
1323
1326
 
1327
+ rb_define_camath_gsl_func2(exp_mult, 2);
1328
+ rb_define_camath_gsl_func2(expm1, 1);
1329
+ rb_define_camath_gsl_func2(exprel, 1);
1330
+ rb_define_camath_gsl_func2(exprel_2, 1);
1331
+ rb_define_camath_gsl_func2(exprel_n, 2);
1332
+
1324
1333
  rb_define_camath_gsl_func2(expint_E1, 1);
1325
1334
  rb_define_camath_gsl_func2(expint_E2, 1);
1326
1335
  rb_define_camath_gsl_func2(expint_En, 2);
@@ -1342,11 +1351,49 @@ Init_carray_mathfunc_gsl ()
1342
1351
  rb_define_camath_gsl_func2(fermi_dirac_3half, 1);
1343
1352
  rb_define_camath_gsl_func2(fermi_dirac_inc_0, 2);
1344
1353
 
1354
+ rb_define_camath_gsl_func2(gamma, 1);
1355
+ rb_define_camath_gsl_func2(lngamma, 1);
1356
+ rb_define_camath_gsl_func2(gammastar, 1);
1357
+ rb_define_camath_gsl_func2(gammainv, 1);
1358
+
1359
+ rb_define_camath_gsl_func2(fact, 1);
1360
+ rb_define_camath_gsl_func2(doublefact, 1);
1361
+ rb_define_camath_gsl_func2(lnfact, 1);
1362
+ rb_define_camath_gsl_func2(lndoublefact, 1);
1363
+ rb_define_camath_gsl_func2(choose, 2);
1364
+ rb_define_camath_gsl_func2(lnchoose, 2);
1365
+ rb_define_camath_gsl_func2(taylorcoeff, 2);
1366
+
1367
+ rb_define_camath_gsl_func2(poch, 2);
1368
+ rb_define_camath_gsl_func2(lnpoch, 2);
1369
+ rb_define_camath_gsl_func2(pochrel, 2);
1370
+
1371
+ rb_define_camath_gsl_func2(gamma_inc, 2);
1372
+ rb_define_camath_gsl_func2(gamma_inc_P, 2);
1373
+ rb_define_camath_gsl_func2(gamma_inc_Q, 2);
1374
+
1375
+ rb_define_camath_gsl_func2(beta, 2);
1376
+ rb_define_camath_gsl_func2(lnbeta, 2);
1377
+ rb_define_camath_gsl_func2(beta_inc, 3);
1378
+
1345
1379
  rb_define_camath_gsl_func2(gegenpoly_1, 2);
1346
1380
  rb_define_camath_gsl_func2(gegenpoly_2, 2);
1347
1381
  rb_define_camath_gsl_func2(gegenpoly_3, 2);
1348
1382
  rb_define_camath_gsl_func2(gegenpoly_n, 3);
1349
1383
 
1384
+ rb_define_camath_gsl_func2(hermite, 2);
1385
+ rb_define_camath_gsl_func2(hermite_deriv, 3);
1386
+ rb_define_camath_gsl_func2(hermite_zero, 2);
1387
+
1388
+ rb_define_camath_gsl_func2(hermite_prob, 2);
1389
+ rb_define_camath_gsl_func2(hermite_prob_deriv, 3);
1390
+ rb_define_camath_gsl_func2(hermite_prob_zero, 2);
1391
+
1392
+ rb_define_camath_gsl_func2(hermite_func, 2);
1393
+ rb_define_camath_gsl_func2(hermite_func_fast, 2);
1394
+ rb_define_camath_gsl_func2(hermite_func_der, 3);
1395
+ rb_define_camath_gsl_func2(hermite_func_zero, 2);
1396
+
1350
1397
  rb_define_camath_gsl_func2(hyperg_0F1, 2);
1351
1398
  rb_define_camath_gsl_func2(hyperg_1F1_int, 3);
1352
1399
  rb_define_camath_gsl_func2(hyperg_1F1, 3);
@@ -21,7 +21,7 @@ $CFLAGS << " -Wall "
21
21
 
22
22
  if have_carray()
23
23
  if have_header("gsl/gsl_matrix.h") and have_gsl
24
- create_makefile("carray/carray_gsl")
24
+ create_makefile("carray_gsl")
25
25
  else
26
26
  open("Makefile", "w") { |io|
27
27
  io << "all:" << "\n"
@@ -1,2 +1,4 @@
1
- require "carray"
2
- require "carray/math/gsl"
1
+ require 'gsl'
2
+ require 'carray'
3
+ require 'carray_gsl'
4
+ require 'carray-gsl/core'
@@ -10,9 +10,6 @@
10
10
  #
11
11
  # ----------------------------------------------------------------------------
12
12
 
13
- require 'gsl'
14
- require 'carray'
15
- require 'carray/carray_gsl'
16
13
 
17
14
  module CA::GSL
18
15
  end
@@ -51,40 +48,40 @@ class CArray
51
48
  end
52
49
 
53
50
  [
54
- ["random_gaussian", ["sigma"]],
55
- ["random_ugaussian", []],
56
- ["random_gaussian_tail", ["a", "sigma"]],
57
- ["random_ugaussian_tail", ["a"]],
58
- ["random_exponential", ["mu"]],
59
- ["random_laplace", ["a"]],
60
- ["random_exppaw", ["a", "b"]],
61
- ["random_cauchy", ["a"]],
62
- ["random_rayleigh", ["sigma"]],
63
- ["random_rayleigh_tail", ["a", "sigma"]],
64
- ["random_landau", []],
65
- ["random_levy", ["c", "alpha"]],
66
- ["random_levy_skew", ["c", "alpha", "beta"]],
67
- ["random_gamma", ["a", "b"]],
68
- ["random_erlang", ["a", "n"]],
69
- ["random_flat", ["a", "b"]],
70
- ["random_lognormal", ["zeta", "sigma"]],
71
- ["random_chisq", ["nu"]],
72
- ["random_fdist", ["nu1", "nu2"]],
73
- ["random_tdist", ["nu"]],
74
- ["random_beta", ["a", "b"]],
75
- ["random_logistic", ["a"]],
76
- ["random_pareto", ["a", "b"]],
77
- ["random_weibull", ["a", "b"]],
78
- ["random_gumbel1", ["a", "b"]],
79
- ["random_gumbel2", ["a", "b"]],
80
- ["random_poisson", ["mu"]],
81
- ["random_bernoulli", ["p"]],
82
- ["random_binomial", ["p", "n"]],
83
- ["random_negative_binomial", ["p", "n"]],
84
- ["random_pascal", ["p", "n"]],
85
- ["random_geometric", ["p"]],
86
- ["random_hypergeometric", ["n1", "n2", "t"]],
87
- ["random_logarithmic", ["p"]],
51
+ ["random_gaussian", ["sigma"]],
52
+ ["random_ugaussian", []],
53
+ ["random_gaussian_tail", ["a", "sigma"]],
54
+ ["random_ugaussian_tail", ["a"]],
55
+ ["random_exponential", ["mu"]],
56
+ ["random_laplace", ["a"]],
57
+ ["random_exppaw", ["a", "b"]],
58
+ ["random_cauchy", ["a"]],
59
+ ["random_rayleigh", ["sigma"]],
60
+ ["random_rayleigh_tail", ["a", "sigma"]],
61
+ ["random_landau", []],
62
+ ["random_levy", ["c", "alpha"]],
63
+ ["random_levy_skew", ["c", "alpha", "beta"]],
64
+ ["random_gamma", ["a", "b"]],
65
+ ["random_erlang", ["a", "n"]],
66
+ ["random_flat", ["a", "b"]],
67
+ ["random_lognormal", ["zeta", "sigma"]],
68
+ ["random_chisq", ["nu"]],
69
+ ["random_fdist", ["nu1", "nu2"]],
70
+ ["random_tdist", ["nu"]],
71
+ ["random_beta", ["a", "b"]],
72
+ ["random_logistic", ["a"]],
73
+ ["random_pareto", ["a", "b"]],
74
+ ["random_weibull", ["a", "b"]],
75
+ ["random_gumbel1", ["a", "b"]],
76
+ ["random_gumbel2", ["a", "b"]],
77
+ ["random_poisson", ["mu"]],
78
+ ["random_bernoulli", ["p"]],
79
+ ["random_binomial", ["p", "n"]],
80
+ ["random_negative_binomial", ["p", "n"]],
81
+ ["random_pascal", ["p", "n"]],
82
+ ["random_geometric", ["p"]],
83
+ ["random_hypergeometric", ["n1", "n2", "t"]],
84
+ ["random_logarithmic", ["p"]],
88
85
  ].each do |name, parms|
89
86
  eval %{
90
87
  def #{name} (#{parms.join(",")})
@@ -100,19 +97,19 @@ class CArray
100
97
  attach {
101
98
  lu, perm, sign = *GSL::Linalg::LU.decomp(self.gm)
102
99
  out = lu.ca.m
103
- out.attribute[:A] = self.gm
104
- out.attribute[:LU] = lu
105
- out.attribute[:perm] = perm
106
- out.attribute[:sign] = sign
100
+ out.attribute["@A"] = self.gm
101
+ out.attribute["@LU"] = lu
102
+ out.attribute["@perm"] = perm
103
+ out.attribute["@sign"] = sign
107
104
  return out
108
105
  }
109
106
  end
110
107
 
111
108
  def lu_solve (b)
112
- if self.attribute[:LU]
109
+ if self["@LU"]
113
110
  CArray.attach(self, b) {
114
- lu = self.attribute[:LU]
115
- perm = self.attribute[:perm]
111
+ lu = self["@LU"]
112
+ perm = self["@perm"]
116
113
  return GSL::Linalg::LU.solve(lu, perm, b.gv).ca.v
117
114
  }
118
115
  else
@@ -124,9 +121,9 @@ class CArray
124
121
 
125
122
  def lu_refine (b, x)
126
123
  CArray.attach(self, b, x) {
127
- a = self.attribute[:A]
128
- lu = self.attribute[:LU]
129
- perm = self.attribute[:perm]
124
+ a = self["@A"]
125
+ lu = self["@LU"]
126
+ perm = self["@perm"]
130
127
  return GSL::Linalg::LU.refine(a, lu, perm, b.gv, x.gv).first.ca.v
131
128
  }
132
129
  end
@@ -147,8 +144,8 @@ class CArray
147
144
  attach {
148
145
  qr, tau = *GSL::Linalg::QR.decomp(self.gm)
149
146
  out = qr.ca.m
150
- out.attribute[:qr] = qr
151
- out.attribute[:tau] = tau
147
+ out["@qr"] = qr
148
+ out["@tau"] = tau
152
149
  return out
153
150
  }
154
151
  end
@@ -161,8 +158,8 @@ class CArray
161
158
 
162
159
  def qr_unpack
163
160
  attach {
164
- qr = self.attribute[:qr]
165
- tau = self.attribute[:tau]
161
+ qr = self["@qr"]
162
+ tau = self["@tau"]
166
163
  q, r = *GSL::Linalg::QR.unpack(qr, tau)
167
164
  return q.ca.m, r.ca.m
168
165
  }
@@ -185,7 +182,7 @@ class CArray
185
182
  attach {
186
183
  c = GSL::Linalg::Cholesky.decomp(self.gm)
187
184
  out = c.ca.m
188
- out.attribute[:cholesky] = c
185
+ out["@cholesky"] = c
189
186
  return out
190
187
  }
191
188
  end
@@ -591,15 +588,15 @@ module CAMath
591
588
 
592
589
  def lu_solve (lu, b)
593
590
  CArray.attach(lu, b) {
594
- perm = lu.attribute[:perm]
591
+ perm = lu["@perm"]
595
592
  return GSL::Linalg::LU.solve(lu.gm, perm, b.gv).ca.v
596
593
  }
597
594
  end
598
595
 
599
596
  def qr_solve (qr, b)
600
597
  CArray.attach(qr, b) {
601
- qrm = qr.attribute[:qr]
602
- tau = qr.attribute[:tau]
598
+ qrm = qr["@qr"]
599
+ tau = qr["@tau"]
603
600
  return GSL::Linalg::QR.solve(qrm, tau, b.gv).ca.v
604
601
  }
605
602
  end
@@ -612,7 +609,7 @@ module CAMath
612
609
 
613
610
  def cholesky_solve (c, b)
614
611
  CArray.attach(c, b) {
615
- cholesky = c.attribute[:cholesky]
612
+ cholesky = c["@cholesky"]
616
613
  return GSL::Linalg::Cholesky.solve(cholesky, b.gv).ca.v
617
614
  }
618
615
  end
@@ -687,7 +684,7 @@ class CAMatrix
687
684
 
688
685
  def upper
689
686
  attach {
690
- return self.gm.lower.ca.m
687
+ return self.gm.upper.ca.m
691
688
  }
692
689
  end
693
690
 
metadata CHANGED
@@ -1,32 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carray-gsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
12
- dependencies: []
13
- description: |2
14
- Extension for accessing Ruby/GSL with CArray
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: carray
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.4.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.4.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: gsl
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 2.1.0.3
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.1.0.3
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 2.1.0.3
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.1.0.3
53
+ description: " Extension for accessing Ruby/GSL with CArray\n"
15
54
  email: ''
16
55
  executables: []
17
56
  extensions:
18
- - extconf.rb
57
+ - ext/extconf.rb
19
58
  extra_rdoc_files: []
20
59
  files:
21
60
  - README.md
61
+ - Rakefile
22
62
  - carray-gsl.gemspec
23
- - carray_gsl.c
24
- - carray_mathfunc_gsl.c
25
- - extconf.rb
26
- - lib/autoload/autoload_math_gsl.rb
63
+ - examples/lu_decomp.rb
64
+ - examples/test_graph.rb
65
+ - examples/test_integ.rb
66
+ - ext/carray_gsl.c
67
+ - ext/carray_mathfunc_gsl.c
68
+ - ext/extconf.rb
27
69
  - lib/carray-gsl.rb
28
- - lib/math/gsl.rb
29
- - lib/math/interp/adapter_gsl_spline.rb
70
+ - lib/carray-gsl/core.rb
30
71
  homepage: https://github.com/himotoyoshi/carray-gsl
31
72
  licenses: []
32
73
  metadata: {}
@@ -38,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
38
79
  requirements:
39
80
  - - ">="
40
81
  - !ruby/object:Gem::Version
41
- version: 1.8.1
82
+ version: 2.4.0
42
83
  required_rubygems_version: !ruby/object:Gem::Requirement
43
84
  requirements:
44
85
  - - ">="
@@ -46,9 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
87
  version: '0'
47
88
  requirements: []
48
89
  rubyforge_project:
49
- rubygems_version: 2.6.4
90
+ rubygems_version: 2.7.7
50
91
  signing_key:
51
92
  specification_version: 4
52
93
  summary: Extension for accessing Ruby/GSL with CArray
53
94
  test_files: []
54
- has_rdoc: false
@@ -1,5 +0,0 @@
1
- module CA
2
- autoload :GSL, "carray/math/gsl"
3
- end
4
-
5
-
@@ -1,44 +0,0 @@
1
- #
2
- #
3
- #
4
-
5
- #
6
- # :type => type
7
- #
8
- # * "linear"
9
- # * "polynomial"
10
- # * "cspline"
11
- # * "cspline_periodic"
12
- # * "akima"
13
- # * "akima_periodic"
14
- #
15
-
16
- require "carray/math/interp"
17
- require "gsl"
18
-
19
- class CA::Interp::GSLSpline < CA::Interp::Adapter
20
-
21
- install_adapter "gsl:spline"
22
-
23
- def initialize (scales, value, options={})
24
- @y = value
25
- @x = scales
26
- type = options[:type] || "linear"
27
- CArray.attach(@x, @y) {
28
- @interp = GSL::Spline.alloc(type, @x.na, @y.na)
29
- }
30
- end
31
-
32
- def evaluate (x0)
33
- case x0
34
- when CArray
35
- return x0.attach { @interp.eval(x0.na).ca }
36
- else
37
- return @interp.eval(x0)
38
- end
39
- end
40
-
41
- alias grid evaluate
42
-
43
- end
44
-