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 +4 -4
- data/README.md +1 -0
- data/ext/pspline/example/example.rb +34 -0
- data/ext/pspline/example/exqspline1.rb +31 -31
- data/ext/pspline/pspline.cpp +49 -2
- data/lib/pspline/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd676129ee15c3a24f0aba8101aa3c4e2f0a6ac1
|
|
4
|
+
data.tar.gz: 28632b037254bcef8dee32470ee0ab513864e21f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b029fa56366d6557ae1d97fc2f9f4124b393b9c35afe0ccdbca1c8da5e51aacb64da8f00ca3f7446bf857eee0c61a068f9bce55d2d8ea56ba961c56d6ecea19d
|
|
7
|
+
data.tar.gz: f5f54d6eabcfb247a31f3d91bf415b84cc4834dccb6c151e1dd90bbd41846639e1adf4279a9e79fd4176d710f407acf1e2e03ef1bff846253dc1b4892d002986
|
data/README.md
CHANGED
|
@@ -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
|
data/ext/pspline/pspline.cpp
CHANGED
|
@@ -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
|
|
87
|
-
rb_raise(rb_eArgError, "Additional points %d
|
|
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);
|
data/lib/pspline/version.rb
CHANGED
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.
|
|
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-
|
|
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
|