pspline 5.0.3 → 5.0.4

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
2
  SHA1:
3
- metadata.gz: cb96468c596ae7908fdd735008f4a5a22a68a56b
4
- data.tar.gz: 7239450009f59fcda3844416ec1a7b575e8aa2ad
3
+ metadata.gz: dd676129ee15c3a24f0aba8101aa3c4e2f0a6ac1
4
+ data.tar.gz: 28632b037254bcef8dee32470ee0ab513864e21f
5
5
  SHA512:
6
- metadata.gz: a4e07bd3ba5932852d9bdcfa5ec22b7b1826a276b5830b3dab7f639f2a6fd51a9dbdf48c6faacd33cc3a7e4c9298777df5159834095b412210988a26510faf14
7
- data.tar.gz: 78858c5c8f9ca31ee18551cfee1877a165ba909ec60f5dbedb3c338398f912224cb372fdc6bd998333edc05b2ce851780d0711ea5f657922087385c86ff6d32e
6
+ metadata.gz: b029fa56366d6557ae1d97fc2f9f4124b393b9c35afe0ccdbca1c8da5e51aacb64da8f00ca3f7446bf857eee0c61a068f9bce55d2d8ea56ba961c56d6ecea19d
7
+ data.tar.gz: f5f54d6eabcfb247a31f3d91bf415b84cc4834dccb6c151e1dd90bbd41846639e1adf4279a9e79fd4176d710f407acf1e2e03ef1bff846253dc1b4892d002986
data/README.md CHANGED
@@ -28,6 +28,7 @@ See pspline.wiki at https://github.com/vsp2old/pspline .
28
28
  5.0.1 Upload for test.
29
29
  5.0.2 Upload for release.
30
30
  5.0.3 Add class PSPLINE::Rfft, class PSPLINE::Cfft.
31
+ 5.0.4 Add method line_integral.
31
32
 
32
33
  ## Development
33
34
 
@@ -0,0 +1,34 @@
1
+ require 'pspline'
2
+ include PSPLINE
3
+ nn = [4, 6]
4
+ jj = [3, 2]
5
+ ss = [3, 2]
6
+ puts "# 2 variable parametric Reisenfeld interpolation"
7
+ S = [0, 1, 2, 3, 4]
8
+ T = [0, 1, 2, 3, 4, 5]
9
+ XYZ = [ [[ 0.0, 5.0, 9.0],[ 0.0, 5.0, 6.0],[ 0.0, 0.5, 6.0],[ 0.0, 0.5, 2.0],[ 0.0, 3.0, 1.0],[ 0.0, 3.0, 0.0]],
10
+ [[ 5.0,-2.5, 6.5],[ 5.0,-2.5, 3.5],[ 0.5,-0.25,5.75],[0.5,-0.25,1.75],[3.0,-1.5,-0.5],[ 3.0,-1.5,-1.5]],
11
+ [[ 0.0,-5.0, 9.0],[ 0.0,-5.0, 6.0],[ 0.0,-0.5, 6.0],[ 0.0,-0.5, 2.0],[ 0.0,-3.0, 1.0],[ 0.0,-3.0, 0.0]],
12
+ [[-5.0, 2.5,11.5],[-5.0, 2.5, 8.5],[-0.5,0.25,6.25],[-0.5,0.25,2.25],[-3.0, 1.5, 2.5],[-3.0, 1.5, 1.5]] ]
13
+ Jbn = ARGV[0].to_i
14
+ Dp = 8
15
+ Rs = Pspline.new(XYZ, [S, T], nn, jj, ss)
16
+ for i in 0..3
17
+ for j in 0..5
18
+ printf("<%d,%d>", S[i], T[j])
19
+ u = XYZ[i][j]
20
+ printf(" % .7f % .7f %10.7f\n", u[0], u[1], u[2])
21
+ end
22
+ end
23
+ printf "# value of interpolation points, Dp = %d", Dp
24
+ if Jbn == 0
25
+ print "\n"
26
+ else
27
+ printf ", Jbn = %d\n", Jbn
28
+ end
29
+ vv = [S, T]
30
+ N = Rs.plot(vv, Dp, [Jbn,0]) do |a, b|
31
+ if (a[1] == 0.0)
32
+ printf("%.3f %.3f % .7f % .7f %10.7f\n", a[0], a[1], b[0], b[1], b[2])
33
+ end
34
+ end
@@ -1,31 +1,31 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- puts "# Parametric period interpolation (Closed curve interpolation)"
6
-
7
- XY = [ [0, 1.0, 0.0],[1, 0.707107, 0.707107],[2, 0.0, 1.0],[3,-0.707107, 0.707107],
8
- [4,-1.0, 0.0],[5,-0.707107,-0.707107],[6, 0.0,-1.0],[7, 0.707107,-0.707107],
9
- [8, 1.0, 0.0] ]
10
-
11
- Jbn = ARGV[0].to_i
12
-
13
- Dp = 8
14
-
15
- Qs = Bspline.new(XY, 8, 5, 1)
16
-
17
- vv = []
18
- XY.each do |p|
19
- printf "% f, % f\n", p[1], p[2]
20
- vv.push p[0]
21
- end
22
- printf "# value of interpolation points, Dp = %d", Dp
23
- if Jbn == 0
24
- print "\n"
25
- else
26
- printf ", Jbn = %d\n", Jbn
27
- end
28
- s = Qs.plot(vv, Dp, Jbn) do |a, b|
29
- printf "% .2f % f % f\n", a, b[0], b[1]
30
- end
31
- #STDERR.puts s
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ puts "# Parametric period interpolation (Closed curve interpolation)"
6
+
7
+ XY = [ [0, 1.0, 0.0],[1, 0.707107, 0.707107],[2, 0.0, 1.0],[3,-0.707107, 0.707107],
8
+ [4,-1.0, 0.0],[5,-0.707107,-0.707107],[6, 0.0,-1.0],[7, 0.707107,-0.707107],
9
+ [8, 1.0, 0.0] ]
10
+
11
+ Jbn = ARGV[0].to_i
12
+
13
+ Dp = 8
14
+
15
+ Qs = Bspline.new(XY, 8, 5, 1)
16
+
17
+ vv = []
18
+ XY.each do |p|
19
+ printf "% f, % f\n", p[1], p[2]
20
+ vv.push p[0]
21
+ end
22
+ printf "# value of interpolation points, Dp = %d", Dp
23
+ if Jbn == 0
24
+ print "\n"
25
+ else
26
+ printf ", Jbn = %d\n", Jbn
27
+ end
28
+ s = Qs.plot(vv, Dp, Jbn) do |a, b|
29
+ printf "% .2f % f % f\n", a, b[0], b[1]
30
+ end
31
+ #STDERR.puts s
@@ -83,8 +83,8 @@ _wrap_init_bspline(int argc, VALUE *argv, VALUE self)
83
83
  int D = argp - argn;
84
84
  if (D < 0)
85
85
  rb_raise(rb_eArgError, "Data points %d < Data size %d", argp, argn);
86
- if (D >= argj)
87
- rb_raise(rb_eArgError, "Additional points %d >= Degree %d", D, argj);
86
+ if (D > argj)
87
+ rb_raise(rb_eArgError, "Additional points %d > Degree %d", D, argj);
88
88
  if (argn <= argj)
89
89
  rb_raise(rb_eArgError, "Data points %d <= Degree %d", argn, argj);
90
90
  if (argc > 3) {
@@ -494,6 +494,52 @@ try {
494
494
  return Wrap_bspline(cBspline, result);
495
495
  }
496
496
 
497
+ static VALUE vfunc;
498
+
499
+ static double ufunc(poly_array<double>& pa)
500
+ {
501
+ int K = pa.unit_size();
502
+ VALUE *vp = ALLOC_N(VALUE, K);
503
+ for (int i = 0; i < K; i++) vp[i] = rb_float_new(pa[i]);
504
+ VALUE vresult = rb_funcall2(vfunc, rb_intern("call"), K, vp);
505
+ free(vp);
506
+ return NUM2DBL(vresult);
507
+ }
508
+
509
+ static VALUE
510
+ _wrap_bspline_lint(int argc, VALUE *argv, VALUE self)
511
+ {
512
+ bspline<double> *arg0; // bspline object
513
+ VALUE vargu, vargx, vargy;
514
+ Get_bspline(self, arg0);
515
+ rb_scan_args(argc, argv, "22", &vfunc, &vargu, &vargx, &vargy);
516
+ int c = arg0->Icox(), j = arg0->Jisu(), n;
517
+ double *q = arg0->Knots(), x = arg0->x_min(), y = arg0->x_max();
518
+ Check_Type(vargu, T_ARRAY);
519
+ int argn = RARRAY_LEN(vargu);
520
+ n = argn > 0 ? argn : c - j + 1;
521
+ double *u = ALLOC_N(double, n);
522
+ for (int i = 0; i < n; i++)
523
+ if (argn > 0) {
524
+ u[i] = NUM2DBL(RARRAY_PTR(vargu)[i]);
525
+ if (u[i] < x || y < u[i] || (i > 0 && u[i] <= u[i-1]))
526
+ rb_raise(rb_eArgError, "Illegal argument");
527
+ } else {
528
+ u[i] = x + i * (y - x) / (n - 1);
529
+ rb_ary_push(vargu, rb_float_new(u[i]));
530
+ }
531
+ x = (argc >= 3) ? NUM2DBL(vargx) : u[0];
532
+ y = (argc == 4) ? NUM2DBL(vargy) : 0 ;
533
+ bspline<double> *result;
534
+ try {
535
+ result = arg0->line_integral(ufunc, n, u, x, y);
536
+ } catch (const char *c) {
537
+ rb_raise(rb_eRuntimeError, "%s", c);
538
+ }
539
+ free(u);
540
+ return Wrap_bspline(cBspline, result);
541
+ }
542
+
497
543
  static void
498
544
  _wrap_Init_bspline(void)
499
545
  {
@@ -505,6 +551,7 @@ _wrap_Init_bspline(void)
505
551
  rb_define_method(cBspline, "value", VALUEFUNC(_wrap_bspline_value), -1);
506
552
  rb_define_method(cBspline, "sekibun", VALUEFUNC(_wrap_bspline_sekibun), 1);
507
553
  rb_define_method(cBspline, "plot", VALUEFUNC(_wrap_bspline_plot), -1);
554
+ rb_define_method(cBspline, "line_integral", VALUEFUNC(_wrap_bspline_lint), -1);
508
555
  rb_define_module_function(mPspline, "fft_complex_transform", VALUEFUNC(_wrap_complex_trans), 2);
509
556
  rb_define_module_function(mPspline, "fft_complex_get", VALUEFUNC(_wrap_complex_get), 2);
510
557
  rb_define_module_function(mPspline, "fft_complex_bspline", VALUEFUNC(_wrap_complex_bspline), 2);
@@ -1,3 +1,3 @@
1
1
  module PSPLINE
2
- VERSION = "5.0.3"
2
+ VERSION = "5.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pspline
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 5.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - vsp2old
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-28 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,7 @@ files:
52
52
  - bin/console
53
53
  - bin/setup
54
54
  - ext/pspline/basis.cpp
55
+ - ext/pspline/example/example.rb
55
56
  - ext/pspline/example/exbspline.ps
56
57
  - ext/pspline/example/exbspline.rb
57
58
  - ext/pspline/example/excspline.ps