pspline 5.0.4 → 5.0.5
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/Gemfile +5 -5
- data/README.md +1 -0
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/ext/pspline/example/exbspline.rb +57 -36
- data/ext/pspline/example/excspline.rb +57 -36
- data/ext/pspline/example/exdspline.rb +55 -33
- data/ext/pspline/example/exfspline.rb +44 -44
- data/ext/pspline/example/exfspline1.rb +40 -40
- data/ext/pspline/example/exfspline2.rb +68 -0
- data/ext/pspline/example/exfspline3.rb +64 -0
- data/ext/pspline/example/exmspline.rb +68 -0
- data/ext/pspline/example/expspline.rb +29 -29
- data/ext/pspline/example/expspline1.rb +29 -29
- data/ext/pspline/example/expspline2.rb +47 -47
- data/ext/pspline/example/exqspline.rb +31 -31
- data/ext/pspline/example/exqspline2.rb +50 -50
- data/ext/pspline/example/exqspline3.rb +51 -51
- data/ext/pspline/example/exqspline4.rb +35 -0
- data/ext/pspline/example/exrspline.rb +34 -34
- data/ext/pspline/example/exrspline1.rb +34 -34
- data/ext/pspline/example/exrspline2.rb +44 -44
- data/ext/pspline/example/exsspline.rb +35 -35
- data/ext/pspline/example/exsspline1.rb +35 -35
- data/ext/pspline/example/extspline.rb +54 -32
- data/ext/pspline/include/basis/pspline.h +156 -20
- data/ext/pspline/include/bspline_Config.h +2 -2
- data/ext/pspline/plotsub.cpp +15 -8
- data/ext/pspline/pspline.cpp +160 -66
- data/lib/pspline.rb +71 -63
- data/lib/pspline/version.rb +3 -3
- data/pspline.gemspec +25 -25
- metadata +7 -13
- data/ext/pspline/example/example.rb +0 -34
- data/ext/pspline/example/exbspline.ps +0 -2194
- data/ext/pspline/example/excspline.ps +0 -2985
- data/ext/pspline/example/exdspline.ps +0 -2846
- data/ext/pspline/example/expspline.ps +0 -3299
- data/ext/pspline/example/exqspline.ps +0 -2957
- data/ext/pspline/example/exrspline.ps +0 -2812
- data/ext/pspline/example/exsspline.ps +0 -1965
- data/ext/pspline/example/extspline.ps +0 -2767
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#define bspline_VERSION 5.0
|
|
2
|
-
#define bspline_TYPE 5
|
|
1
|
+
#define bspline_VERSION 5.0
|
|
2
|
+
#define bspline_TYPE 5
|
data/ext/pspline/plotsub.cpp
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include "basis/basis.h"
|
|
12
12
|
#include "basis/pspline.h"
|
|
13
13
|
|
|
14
|
+
// 偏微分プロット
|
|
14
15
|
template <typename T, typename S>
|
|
15
16
|
int plot(const pspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp, const int *b)
|
|
16
17
|
{
|
|
@@ -32,6 +33,9 @@ int plot(const pspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp,
|
|
|
32
33
|
return Npx;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
template int plot(const pspline<double>&, const comb_array<double>&, double**, double**, int, const int*);
|
|
37
|
+
|
|
38
|
+
// 全微分プロット
|
|
35
39
|
template <typename T, typename S>
|
|
36
40
|
int plot(const pspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp, int Jbn, S *jb)
|
|
37
41
|
{
|
|
@@ -53,11 +57,13 @@ int plot(const pspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp,
|
|
|
53
57
|
return Npx;
|
|
54
58
|
}
|
|
55
59
|
|
|
60
|
+
template int plot(const pspline<double>&, const comb_array<double>&, double**, double**, int, int, double*);
|
|
61
|
+
|
|
62
|
+
// 1変数関数積プロット
|
|
56
63
|
template <typename T, typename S>
|
|
57
64
|
int plot(const pspline<T,S>& B, int n, S *x, S **Xp, T **Yp, int Dp, int b)
|
|
58
65
|
{
|
|
59
66
|
int K = B.Unit_size();
|
|
60
|
-
int jb[] = {b};
|
|
61
67
|
|
|
62
68
|
int Npx = (n - 1) * Dp + 1;
|
|
63
69
|
*Xp = T_ALLOC(S, Npx);
|
|
@@ -68,15 +74,17 @@ int plot(const pspline<T,S>& B, int n, S *x, S **Xp, T **Yp, int Dp, int b)
|
|
|
68
74
|
for (int Nd = N0; Nd <= Dp; Nd++) {
|
|
69
75
|
int Np = Nd + (L-1) * Dp;
|
|
70
76
|
S Tp = x[L-1] + Nd * DT;
|
|
71
|
-
poly<S> Sp(1, Tp, (S)0);
|
|
72
77
|
(*Xp)[Np] = Tp;
|
|
73
|
-
poly_array<T> Z = B(
|
|
78
|
+
poly_array<T> Z = B(Tp, b);
|
|
74
79
|
for (int i = 0; i < K; ++i) Yp[i][Np] = Z[i];
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
return Npx;
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
template int plot(const pspline<double>&, int, double *, double **, double **, int, int);
|
|
86
|
+
|
|
87
|
+
// 1変数関数プロット(インデックス)
|
|
80
88
|
template <typename T, typename S>
|
|
81
89
|
int plot(const bspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp, int Jbn)
|
|
82
90
|
{
|
|
@@ -102,6 +110,9 @@ int plot(const bspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp,
|
|
|
102
110
|
return Npx;
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
template int plot(const bspline<double>&, const comb_array<double>&, double **, double **, int, int);
|
|
114
|
+
|
|
115
|
+
// 1変数関数プロット
|
|
105
116
|
template <typename T, typename S>
|
|
106
117
|
int plot(const bspline<T,S>& B, int n, S *x, S **Xp, T **Yp, int Dp, int b)
|
|
107
118
|
{
|
|
@@ -124,9 +135,5 @@ int plot(const bspline<T,S>& B, int n, S *x, S **Xp, T **Yp, int Dp, int b)
|
|
|
124
135
|
return Npx;
|
|
125
136
|
}
|
|
126
137
|
|
|
127
|
-
template int plot(const
|
|
128
|
-
template int plot(const pspline<double,double>&, const comb_array<double>&, double**, double**, int, int, double*);
|
|
129
|
-
template int plot(const pspline<double,double>&, int, double *, double **, double **, int, int);
|
|
130
|
-
template int plot(const bspline<double,double>&, const comb_array<double>&, double **, double **, int, int);
|
|
131
|
-
template int plot(const bspline<double,double>&, int, double *, double **, double **, int, int);
|
|
138
|
+
template int plot(const bspline<double>&, int, double *, double **, double **, int, int);
|
|
132
139
|
|
data/ext/pspline/pspline.cpp
CHANGED
|
@@ -540,6 +540,8 @@ try {
|
|
|
540
540
|
return Wrap_bspline(cBspline, result);
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
+
static VALUE _wrap_bspline_mul(VALUE self, VALUE varg);
|
|
544
|
+
|
|
543
545
|
static void
|
|
544
546
|
_wrap_Init_bspline(void)
|
|
545
547
|
{
|
|
@@ -552,6 +554,7 @@ _wrap_Init_bspline(void)
|
|
|
552
554
|
rb_define_method(cBspline, "sekibun", VALUEFUNC(_wrap_bspline_sekibun), 1);
|
|
553
555
|
rb_define_method(cBspline, "plot", VALUEFUNC(_wrap_bspline_plot), -1);
|
|
554
556
|
rb_define_method(cBspline, "line_integral", VALUEFUNC(_wrap_bspline_lint), -1);
|
|
557
|
+
rb_define_method(cBspline, "*", VALUEFUNC(_wrap_bspline_mul), 1);
|
|
555
558
|
rb_define_module_function(mPspline, "fft_complex_transform", VALUEFUNC(_wrap_complex_trans), 2);
|
|
556
559
|
rb_define_module_function(mPspline, "fft_complex_get", VALUEFUNC(_wrap_complex_get), 2);
|
|
557
560
|
rb_define_module_function(mPspline, "fft_complex_bspline", VALUEFUNC(_wrap_complex_bspline), 2);
|
|
@@ -725,33 +728,41 @@ _wrap_pspline_bracket(int argc, VALUE *argv, VALUE self)
|
|
|
725
728
|
Get_pspline(self, bsp);
|
|
726
729
|
int N = bsp->Grid();
|
|
727
730
|
int K = bsp->Unit_size();
|
|
728
|
-
|
|
729
|
-
vargs = make_list(argc, argv);
|
|
730
|
-
argc = RARRAY_LEN(vargs);
|
|
731
|
-
int M = argc / N;
|
|
731
|
+
mresult = rb_ary_new();
|
|
732
732
|
try {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
733
|
+
for (int m = 0; m < argc; ++m) {
|
|
734
|
+
vargs = argv[m];
|
|
735
|
+
poly_array<double> val;
|
|
736
|
+
if (TYPE(vargs) == T_ARRAY) {
|
|
737
|
+
int L = RARRAY_LEN(vargs);
|
|
738
|
+
if (L != N)
|
|
739
|
+
rb_raise(rb_eArgError, "Array length = %d, it should be %d.", L, N);
|
|
736
740
|
double args[N+1];
|
|
737
741
|
for (int i = 0; i < N; ++i)
|
|
738
|
-
args[i] = NUM2DBL(RARRAY_PTR(vargs)[
|
|
742
|
+
args[i] = NUM2DBL(RARRAY_PTR(vargs)[i]);
|
|
739
743
|
poly<double> arg(args, N);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
744
|
+
val = (*bsp)[arg];
|
|
745
|
+
} else
|
|
746
|
+
val = (*bsp)[NUM2DBL(vargs)];
|
|
747
|
+
if (K == 1)
|
|
748
|
+
vresult = rb_float_new(val[0]);
|
|
749
|
+
else {
|
|
750
|
+
vresult = rb_ary_new();
|
|
751
|
+
for (int j = 0; j < K; ++j)
|
|
752
|
+
rb_ary_push(vresult, rb_float_new(val[j]));
|
|
749
753
|
}
|
|
750
|
-
|
|
754
|
+
rb_ary_push(mresult, vresult);
|
|
755
|
+
}
|
|
751
756
|
} catch (const char *c) {
|
|
752
757
|
rb_raise(rb_eRuntimeError, "%s", c);
|
|
753
758
|
}
|
|
754
|
-
return
|
|
759
|
+
return argc == 1 ? rb_ary_shift(mresult) : mresult;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
void ps_eArgError(VALUE err)
|
|
763
|
+
{
|
|
764
|
+
VALUE str = rb_String(err);
|
|
765
|
+
rb_raise(rb_eArgError, "wrong argument %s", StringValuePtr(str));
|
|
755
766
|
}
|
|
756
767
|
/*******************************************************************************
|
|
757
768
|
関数値
|
|
@@ -766,7 +777,7 @@ _wrap_pspline_value(int argc, VALUE *argv, VALUE self)
|
|
|
766
777
|
VALUE varg1, varg2, varg3;
|
|
767
778
|
pspline<double> *arg0;
|
|
768
779
|
int argn, arg2 = 0, *carg2 = NULL;
|
|
769
|
-
double *carg3 = NULL;
|
|
780
|
+
double arg1, *args, *carg3 = NULL;
|
|
770
781
|
VALUE vargs, vresult = Qnil;
|
|
771
782
|
|
|
772
783
|
rb_scan_args(argc, argv, "12", &varg1, &varg2, &varg3);
|
|
@@ -779,51 +790,67 @@ _wrap_pspline_value(int argc, VALUE *argv, VALUE self)
|
|
|
779
790
|
arg2 = NUM2INT(varg2);
|
|
780
791
|
carg3 = new double[N];
|
|
781
792
|
Check_Type(varg3, T_ARRAY);
|
|
793
|
+
if (RARRAY_LEN(varg3) != N) ps_eArgError(varg3);
|
|
782
794
|
for (int i = 0; i < N; ++i)
|
|
783
795
|
carg3[i] = NUM2DBL(RARRAY_PTR(varg3)[i]);
|
|
784
796
|
}
|
|
785
797
|
// 偏微分
|
|
786
798
|
if (argc == 2) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
799
|
+
if (TYPE(varg2) == T_ARRAY && RARRAY_LEN(varg2) == N) {
|
|
800
|
+
carg2 = new int[N];
|
|
801
|
+
for (int i = 0; i < N; ++i)
|
|
802
|
+
carg2[i] = NUM2INT(RARRAY_PTR(varg2)[i]);
|
|
803
|
+
} else if (TYPE(varg1) != T_ARRAY) {
|
|
804
|
+
arg2 = NUM2INT(varg2);
|
|
805
|
+
argc = 0;
|
|
806
|
+
} else ps_eArgError(varg2);
|
|
791
807
|
}
|
|
792
808
|
// Argument list
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
args
|
|
801
|
-
|
|
809
|
+
poly<double> arg;
|
|
810
|
+
args = NULL;
|
|
811
|
+
if (TYPE(varg1) == T_ARRAY) {
|
|
812
|
+
argn = RARRAY_LEN(varg1);
|
|
813
|
+
vargs = make_list(argn, RARRAY_PTR(varg1));
|
|
814
|
+
argn = RARRAY_LEN(vargs);
|
|
815
|
+
if (argn == N) {
|
|
816
|
+
args = new double[N+1];
|
|
817
|
+
for (int i = 0; i < N; ++i)
|
|
818
|
+
args[i] = NUM2DBL(RARRAY_PTR(vargs)[i]);
|
|
819
|
+
} else ps_eArgError(varg1);
|
|
820
|
+
} else
|
|
821
|
+
if (argc <= 1) arg1 = NUM2DBL(varg1);
|
|
822
|
+
else ps_eArgError(varg1);
|
|
823
|
+
if (argc < 2) argc ^= 1;
|
|
824
|
+
if (args) arg = poly<double>(args, N);
|
|
825
|
+
poly_array<double> val;
|
|
802
826
|
try {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
827
|
+
switch (argc) {
|
|
828
|
+
case 0: // 関数値
|
|
829
|
+
val = args ? (*arg0)(arg) : (*arg0)(arg1);
|
|
830
|
+
delete[] args;
|
|
831
|
+
break;
|
|
832
|
+
case 1: // 関数積の微分
|
|
833
|
+
val = (*arg0)(arg1, arg2);
|
|
834
|
+
delete[] args;
|
|
835
|
+
break;
|
|
836
|
+
case 2: // 偏微分 (partial derivative)
|
|
837
|
+
val = (*arg0)(arg, carg2);
|
|
838
|
+
delete[] carg2;
|
|
839
|
+
break;
|
|
840
|
+
case 3: // 全微分 (total derivative)
|
|
841
|
+
val = (*arg0)(arg, arg2, carg3);
|
|
842
|
+
delete[] carg3;
|
|
843
|
+
}
|
|
816
844
|
} catch (const char *c) {
|
|
817
845
|
rb_raise(rb_eRuntimeError, "%s", c);
|
|
818
846
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
} else rb_raise(rb_eArgError, "wrong argument value");
|
|
847
|
+
if (K == 1)
|
|
848
|
+
vresult = rb_float_new(val[0]);
|
|
849
|
+
else {
|
|
850
|
+
vresult = rb_ary_new();
|
|
851
|
+
for (int j = 0; j < K; ++j)
|
|
852
|
+
rb_ary_push(vresult, rb_float_new(val[j]));
|
|
853
|
+
}
|
|
827
854
|
return vresult;
|
|
828
855
|
}
|
|
829
856
|
|
|
@@ -840,10 +867,13 @@ _wrap_pspline_sekibun(int argc, VALUE *argv, VALUE self)
|
|
|
840
867
|
vargs = make_list(argc, argv);
|
|
841
868
|
argc = RARRAY_LEN(vargs);
|
|
842
869
|
try {
|
|
843
|
-
if (argc == N) {
|
|
870
|
+
if (argc == N || argc == 1) {
|
|
844
871
|
double s[N+1];
|
|
845
872
|
for (int i = 0; i < N; ++i)
|
|
846
|
-
|
|
873
|
+
if (i == 0 || argc == N)
|
|
874
|
+
s[i] = NUM2DBL(RARRAY_PTR(vargs)[i]);
|
|
875
|
+
else
|
|
876
|
+
s[i] = s[i-1];
|
|
847
877
|
poly<double> args(s, N);
|
|
848
878
|
poly_array<double> val = bsp->sekibun(args);
|
|
849
879
|
if (K == 1)
|
|
@@ -875,13 +905,15 @@ _wrap_pspline_plot(int argc, VALUE *argv, VALUE self)
|
|
|
875
905
|
double *arg1[N], *arg2[K];
|
|
876
906
|
arg3 = NUM2INT(vdp);
|
|
877
907
|
if (argc > 2) {
|
|
878
|
-
Check_Type(vjbn, T_ARRAY);
|
|
879
|
-
int n = RARRAY_LEN(vjbn);
|
|
880
|
-
if (n != N)
|
|
881
|
-
rb_raise(rb_eArgError, "Differential orders = %d, it should be %d", n, N);
|
|
882
908
|
arg4 = new int[N];
|
|
883
|
-
|
|
884
|
-
|
|
909
|
+
if (TYPE(vjbn) == T_ARRAY) {
|
|
910
|
+
int n = RARRAY_LEN(vjbn);
|
|
911
|
+
if (n != N)
|
|
912
|
+
rb_raise(rb_eArgError, "Differential orders = %d, it should be %d", n, N);
|
|
913
|
+
for (int i = 0; i < N; ++i)
|
|
914
|
+
arg4[i] = NUM2INT(RARRAY_PTR(vjbn)[i]);
|
|
915
|
+
} else
|
|
916
|
+
arg4[0] = NUM2INT(vjbn);
|
|
885
917
|
}
|
|
886
918
|
Check_Type(varg, T_ARRAY);
|
|
887
919
|
N = RARRAY_LEN(varg);
|
|
@@ -889,10 +921,16 @@ _wrap_pspline_plot(int argc, VALUE *argv, VALUE self)
|
|
|
889
921
|
int result;
|
|
890
922
|
for (int i = 0; i < N; ++i) rb_ary_push(vstu, rb_ary_shift(varg));
|
|
891
923
|
try {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
924
|
+
if (TYPE(RARRAY_PTR(vstu)[0]) == T_ARRAY) {
|
|
925
|
+
comb_array<double> stu = make_var(N, vstu);
|
|
926
|
+
result = plot<double>(*arg0, stu, arg1, arg2, arg3, arg4);
|
|
927
|
+
} else {
|
|
928
|
+
double *x = new double[N];
|
|
929
|
+
for (int i = 0; i < N; i++) x[i] = NUM2DBL(RARRAY_PTR(vstu)[i]);
|
|
930
|
+
result = plot<double>(*arg0, N, x, arg1, arg2, arg3, arg4[0]);
|
|
931
|
+
delete[] x;
|
|
932
|
+
N = 1;
|
|
933
|
+
}
|
|
896
934
|
} catch (const char *c) {
|
|
897
935
|
rb_raise(rb_eRuntimeError, "%s", c);
|
|
898
936
|
}
|
|
@@ -913,6 +951,61 @@ try {
|
|
|
913
951
|
return INT2NUM(result);
|
|
914
952
|
}
|
|
915
953
|
|
|
954
|
+
static VALUE
|
|
955
|
+
_wrap_bspline_mul(VALUE self, VALUE varg)
|
|
956
|
+
{
|
|
957
|
+
bspline<double> *arg0;
|
|
958
|
+
Get_bspline(self, arg0);
|
|
959
|
+
pspline<double> *result;
|
|
960
|
+
if (rb_obj_is_kind_of(varg, cBspline)) {
|
|
961
|
+
bspline<double> *arg1;
|
|
962
|
+
Data_Get_Struct(varg, bspline<double>, arg1);
|
|
963
|
+
if (!arg1) rb_raise(rb_eArgError, "Not Bspline object");
|
|
964
|
+
result = new pspline<double>((*arg0) * (*arg1));
|
|
965
|
+
} else if (rb_obj_is_kind_of(varg, cPspline)) {
|
|
966
|
+
pspline<double> *arg1;
|
|
967
|
+
Data_Get_Struct(varg, pspline<double>, arg1);
|
|
968
|
+
if (!arg1) rb_raise(rb_eArgError, "Not Pspline Object");
|
|
969
|
+
result = new pspline<double>((*arg0) * (*arg1));
|
|
970
|
+
} else {
|
|
971
|
+
double a = NUM2DBL(varg);
|
|
972
|
+
bspline<double> *result = new bspline<double>(*arg0);
|
|
973
|
+
double *p = *result;
|
|
974
|
+
int k = result->Unit_size();
|
|
975
|
+
int c = ((base_spline<double>*)result)->Icox();
|
|
976
|
+
for (int i = 0; i < c * k; i++) p[i] *= a;
|
|
977
|
+
return Wrap_bspline(cBspline, result);
|
|
978
|
+
}
|
|
979
|
+
return Wrap_pspline(cPspline, result);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
static VALUE
|
|
983
|
+
_wrap_pspline_mul(VALUE self, VALUE varg)
|
|
984
|
+
{
|
|
985
|
+
pspline<double> *arg0;
|
|
986
|
+
Get_pspline(self, arg0);
|
|
987
|
+
pspline<double> *result;
|
|
988
|
+
if (rb_obj_is_kind_of(varg, cBspline)) {
|
|
989
|
+
bspline<double> *arg1;
|
|
990
|
+
Data_Get_Struct(varg, bspline<double>, arg1);
|
|
991
|
+
if (!arg1) rb_raise(rb_eArgError, "Not Bspline object");
|
|
992
|
+
result = new pspline<double>((*arg0) * (*arg1));
|
|
993
|
+
}/* else if (rb_obj_is_kind_of(varg, cPspline)) {
|
|
994
|
+
pspline<double> *arg1;
|
|
995
|
+
Data_Get_Struct(varg, pspline<double>, arg1);
|
|
996
|
+
if (!arg1) rb_raise(rb_eArgError, "Not Pspline object");
|
|
997
|
+
result = new pspline<double>((*arg0) * (*arg1));
|
|
998
|
+
}*/ else {
|
|
999
|
+
double a = NUM2DBL(varg);
|
|
1000
|
+
result = new pspline<double>(*arg0);
|
|
1001
|
+
double *p = *result;
|
|
1002
|
+
const Int& c = result->values->icox;
|
|
1003
|
+
int s = c.grid_size();
|
|
1004
|
+
for (int i = 0; i < s; i++) p[i] *= a;
|
|
1005
|
+
}
|
|
1006
|
+
return Wrap_pspline(cPspline, result);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
916
1009
|
static void
|
|
917
1010
|
_wrap_Init_pspline(void)
|
|
918
1011
|
{
|
|
@@ -924,6 +1017,7 @@ _wrap_Init_pspline(void)
|
|
|
924
1017
|
rb_define_method(cPspline, "value", VALUEFUNC(_wrap_pspline_value), -1);
|
|
925
1018
|
rb_define_method(cPspline, "sekibun", VALUEFUNC(_wrap_pspline_sekibun), -1);
|
|
926
1019
|
rb_define_method(cPspline, "plot", VALUEFUNC(_wrap_pspline_plot), -1);
|
|
1020
|
+
rb_define_method(cPspline, "*", VALUEFUNC(_wrap_pspline_mul), 1);
|
|
927
1021
|
}
|
|
928
1022
|
|
|
929
1023
|
#ifdef __cplusplus
|
data/lib/pspline.rb
CHANGED
|
@@ -1,63 +1,71 @@
|
|
|
1
|
-
require "pspline/version"
|
|
2
|
-
require "pspline.so"
|
|
3
|
-
|
|
4
|
-
module PSPLINE
|
|
5
|
-
|
|
6
|
-
class Rfft
|
|
7
|
-
|
|
8
|
-
def initialize(data)
|
|
9
|
-
|
|
10
|
-
end
|
|
11
|
-
def [] (t)
|
|
12
|
-
fft_real_get(
|
|
13
|
-
end
|
|
14
|
-
def spline
|
|
15
|
-
@V = []
|
|
16
|
-
fft_real_bspline(
|
|
17
|
-
end
|
|
18
|
-
def axis
|
|
19
|
-
@V.dup
|
|
20
|
-
end
|
|
21
|
-
def inverse
|
|
22
|
-
fft_real_transform(
|
|
23
|
-
end
|
|
24
|
-
def backword
|
|
25
|
-
fft_real_transform(
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
def
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
def
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
require "pspline/version"
|
|
2
|
+
require "pspline.so"
|
|
3
|
+
|
|
4
|
+
module PSPLINE
|
|
5
|
+
|
|
6
|
+
class Rfft < Array
|
|
7
|
+
|
|
8
|
+
def initialize(data)
|
|
9
|
+
super(fft_real_transform(data, 1))
|
|
10
|
+
end
|
|
11
|
+
def [] (t)
|
|
12
|
+
fft_real_get(self, t)
|
|
13
|
+
end
|
|
14
|
+
def spline order:
|
|
15
|
+
@V = []
|
|
16
|
+
fft_real_bspline(self, order) {|t, z| @V.push t}
|
|
17
|
+
end
|
|
18
|
+
def axis
|
|
19
|
+
@V.dup
|
|
20
|
+
end
|
|
21
|
+
def inverse
|
|
22
|
+
fft_real_transform(self, -1)
|
|
23
|
+
end
|
|
24
|
+
def backword
|
|
25
|
+
fft_real_transform(self, 0)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Cfft < Array
|
|
31
|
+
|
|
32
|
+
def initialize(data)
|
|
33
|
+
super(fft_complex_transform(data, 1))
|
|
34
|
+
end
|
|
35
|
+
def [] (t)
|
|
36
|
+
fft_complex_get(self, t)
|
|
37
|
+
end
|
|
38
|
+
def spline order:
|
|
39
|
+
@V = []
|
|
40
|
+
fft_complex_bspline(self, order) {|t, z| @V.push t}
|
|
41
|
+
end
|
|
42
|
+
def inverse
|
|
43
|
+
fft_complex_transform(self, -1)
|
|
44
|
+
end
|
|
45
|
+
def backword
|
|
46
|
+
fft_real_transform(self, 0)
|
|
47
|
+
end
|
|
48
|
+
def axis
|
|
49
|
+
@V.dup
|
|
50
|
+
end
|
|
51
|
+
def real
|
|
52
|
+
self.first.dup
|
|
53
|
+
end
|
|
54
|
+
def image
|
|
55
|
+
self.last.dup
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class Array
|
|
63
|
+
|
|
64
|
+
def fft_complex_forward
|
|
65
|
+
PSPLINE::Cfft.new(self)
|
|
66
|
+
end
|
|
67
|
+
def fft_real_forward
|
|
68
|
+
PSPLINE::Rfft.new(self)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|