rb-gsl 1.16.0.2 → 1.16.0.3.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README +2 -2
- data/Rakefile +2 -3
- data/lib/gsl/version.rb +1 -1
- data/rdoc/alf.rdoc +5 -5
- data/rdoc/blas.rdoc +8 -8
- data/rdoc/bspline.rdoc +16 -16
- data/rdoc/changes.rdoc +4 -9
- data/rdoc/cheb.rdoc +24 -24
- data/rdoc/cholesky_complex.rdoc +21 -21
- data/rdoc/combi.rdoc +36 -36
- data/rdoc/complex.rdoc +21 -21
- data/rdoc/const.rdoc +46 -46
- data/rdoc/dht.rdoc +48 -48
- data/rdoc/diff.rdoc +41 -41
- data/rdoc/ehandling.rdoc +5 -5
- data/rdoc/eigen.rdoc +152 -152
- data/rdoc/fft.rdoc +145 -145
- data/rdoc/fit.rdoc +108 -108
- data/rdoc/function.rdoc +10 -10
- data/rdoc/graph.rdoc +16 -16
- data/rdoc/hist.rdoc +102 -102
- data/rdoc/hist2d.rdoc +41 -41
- data/rdoc/hist3d.rdoc +8 -8
- data/rdoc/index.rdoc +18 -21
- data/rdoc/integration.rdoc +109 -109
- data/rdoc/interp.rdoc +70 -70
- data/rdoc/intro.rdoc +6 -6
- data/rdoc/linalg.rdoc +187 -187
- data/rdoc/linalg_complex.rdoc +1 -1
- data/rdoc/math.rdoc +57 -57
- data/rdoc/matrix.rdoc +272 -272
- data/rdoc/min.rdoc +56 -56
- data/rdoc/monte.rdoc +21 -21
- data/rdoc/multimin.rdoc +94 -94
- data/rdoc/multiroot.rdoc +79 -79
- data/rdoc/narray.rdoc +31 -31
- data/rdoc/ndlinear.rdoc +53 -53
- data/rdoc/nonlinearfit.rdoc +99 -99
- data/rdoc/ntuple.rdoc +30 -30
- data/rdoc/odeiv.rdoc +87 -87
- data/rdoc/perm.rdoc +89 -89
- data/rdoc/poly.rdoc +65 -65
- data/rdoc/qrng.rdoc +20 -20
- data/rdoc/randist.rdoc +81 -81
- data/rdoc/ref.rdoc +56 -56
- data/rdoc/rng.rdoc +84 -84
- data/rdoc/roots.rdoc +56 -56
- data/rdoc/sf.rdoc +427 -427
- data/rdoc/siman.rdoc +18 -18
- data/rdoc/sort.rdoc +29 -29
- data/rdoc/start.rdoc +8 -8
- data/rdoc/stats.rdoc +51 -51
- data/rdoc/sum.rdoc +11 -11
- data/rdoc/tensor.rdoc +30 -30
- data/rdoc/tut.rdoc +1 -1
- data/rdoc/use.rdoc +37 -37
- data/rdoc/vector.rdoc +187 -187
- data/rdoc/vector_complex.rdoc +23 -23
- data/rdoc/wavelet.rdoc +46 -46
- metadata +17 -20
- data/rdoc/rngextra.rdoc +0 -11
- data/rdoc/screenshot.rdoc +0 -40
data/rdoc/tensor.rdoc
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#
|
2
2
|
# = Tensor manipulations
|
3
|
-
# The tensor library is developed by J. Burguet and distributed
|
4
|
-
# as an add-on package of GSL. See {here}[
|
3
|
+
# The tensor library is developed by J. Burguet and distributed
|
4
|
+
# as an add-on package of GSL. See {here}[https://sourceware.org/ml/gsl-discuss/2004-q4/msg00053.html] and {here}[https://sourceware.org/ml/gsl-discuss/2004-q4/msg00055.html].
|
5
5
|
#
|
6
|
-
# ==
|
6
|
+
# == Class methods
|
7
7
|
# ---
|
8
8
|
# * GSL::Tensor.new(rank, dimention)
|
9
9
|
# * GSL::Tensor.alloc(rank, dimention)
|
@@ -16,7 +16,7 @@
|
|
16
16
|
#
|
17
17
|
# Creates a tensor of rank <tt>rank</tt> and dimension <tt>dimention</tt>,
|
18
18
|
# and initializes all the elements to zero.
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# ---
|
21
21
|
# * GSL::Tensor.copy(tensor)
|
22
22
|
#
|
@@ -33,8 +33,8 @@
|
|
33
33
|
#
|
34
34
|
# Exchanges the elements of the tensor <tt>a</tt> and <tt>b</tt>.
|
35
35
|
#
|
36
|
-
# ==
|
37
|
-
# ===
|
36
|
+
# == Instance methods
|
37
|
+
# === Accessing tensor elements
|
38
38
|
# ---
|
39
39
|
# * GSL::Tensor#set_zero
|
40
40
|
#
|
@@ -45,13 +45,13 @@
|
|
45
45
|
# Sets all the element of the tensor <tt>self</tt> to <tt>x</tt>.
|
46
46
|
# ---
|
47
47
|
# * GSL::Tensor#set(indices, x)
|
48
|
-
# * GSL::Tensor#[indices]=x
|
48
|
+
# * \GSL::Tensor#[indices]=x
|
49
49
|
#
|
50
50
|
# Sets the element of the given indices to <tt>x</tt>.
|
51
51
|
#
|
52
52
|
# ---
|
53
53
|
# * GSL::Tensor#get(indices)
|
54
|
-
# * GSL::Tensor#[indices]
|
54
|
+
# * \GSL::Tensor#[indices]
|
55
55
|
#
|
56
56
|
# Returns the tensor element. If the number of indices given is smaller than the
|
57
57
|
# rank of the tensor, the method GSL::Tensor#subtensor is called.
|
@@ -70,31 +70,31 @@
|
|
70
70
|
#
|
71
71
|
# ---
|
72
72
|
# * GSL::Tensor#subtensor(indices)
|
73
|
-
# * GSL::Tensor#[indices]
|
73
|
+
# * \GSL::Tensor#[indices]
|
74
74
|
#
|
75
75
|
# Return a subtensor.
|
76
|
-
#
|
76
|
+
#
|
77
77
|
# Ex:
|
78
78
|
# >> require("gsl")
|
79
79
|
# => true
|
80
80
|
# >> t = Vector[1..125].to_tensor(3, 5)
|
81
|
-
# => GSL::Tensor:
|
81
|
+
# => GSL::Tensor:
|
82
82
|
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00 6.000e+00 7.000e+00 ... ]
|
83
83
|
# >> t[0]
|
84
|
-
# => GSL::Tensor::View:
|
85
|
-
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00
|
86
|
-
# 6.000e+00 7.000e+00 8.000e+00 9.000e+00 1.000e+01
|
87
|
-
# 1.100e+01 1.200e+01 1.300e+01 1.400e+01 1.500e+01
|
88
|
-
# 1.600e+01 1.700e+01 1.800e+01 1.900e+01 2.000e+01
|
84
|
+
# => GSL::Tensor::View:
|
85
|
+
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00
|
86
|
+
# 6.000e+00 7.000e+00 8.000e+00 9.000e+00 1.000e+01
|
87
|
+
# 1.100e+01 1.200e+01 1.300e+01 1.400e+01 1.500e+01
|
88
|
+
# 1.600e+01 1.700e+01 1.800e+01 1.900e+01 2.000e+01
|
89
89
|
# 2.100e+01 2.200e+01 2.300e+01 2.400e+01 2.500e+01 ]
|
90
90
|
# >> t[0,2]
|
91
|
-
# => GSL::Tensor::View:
|
91
|
+
# => GSL::Tensor::View:
|
92
92
|
# [ 1.100e+01 1.200e+01 1.300e+01 1.400e+01 1.500e+01 ]
|
93
93
|
# >> t[3,1]
|
94
|
-
# => GSL::Tensor::View:
|
94
|
+
# => GSL::Tensor::View:
|
95
95
|
# [ 8.100e+01 8.200e+01 8.300e+01 8.400e+01 8.500e+01 ]
|
96
96
|
# >> t[1][2]
|
97
|
-
# => GSL::Tensor::View:
|
97
|
+
# => GSL::Tensor::View:
|
98
98
|
# [ 3.600e+01 3.700e+01 3.800e+01 3.900e+01 4.000e+01 ]
|
99
99
|
#
|
100
100
|
# ---
|
@@ -115,8 +115,8 @@
|
|
115
115
|
# * GSL::Tensor#to_matrix
|
116
116
|
#
|
117
117
|
# Converts the tensor of rank 2 into a <tt>GSL::Matrix::View</tt> object.
|
118
|
-
#
|
119
|
-
# ===
|
118
|
+
#
|
119
|
+
# === IO
|
120
120
|
# ---
|
121
121
|
# * GSL::Tensor#fwrite(io)
|
122
122
|
# * GSL::Tensor#fwrite(filename)
|
@@ -128,7 +128,7 @@
|
|
128
128
|
# * GSL::Tensor#fscanf(filename)
|
129
129
|
#
|
130
130
|
#
|
131
|
-
# ===
|
131
|
+
# === Max, min
|
132
132
|
# ---
|
133
133
|
# * GSL::Tensor#max
|
134
134
|
# * GSL::Tensor#min
|
@@ -138,7 +138,7 @@
|
|
138
138
|
# * GSL::Tensor#minmax_index
|
139
139
|
#
|
140
140
|
#
|
141
|
-
# ===
|
141
|
+
# === Tensor operations
|
142
142
|
# ---
|
143
143
|
# * GSL::Tensor#add(b)
|
144
144
|
# * GSL::Tensor#+(b)
|
@@ -160,7 +160,7 @@
|
|
160
160
|
# ---
|
161
161
|
# * GSL::Tensor#mul_elements(b)
|
162
162
|
#
|
163
|
-
# This calculate element-by-element multiplication of <tt>self</tt> and <tt>b</tt>,
|
163
|
+
# This calculate element-by-element multiplication of <tt>self</tt> and <tt>b</tt>,
|
164
164
|
# and returns a new tensor.
|
165
165
|
# ---
|
166
166
|
# * GSL::Tensor#mul_elements!(b)
|
@@ -170,7 +170,7 @@
|
|
170
170
|
# * GSL::Tensor#div_elements(b)
|
171
171
|
# * GSL::Tensor#/(b)
|
172
172
|
#
|
173
|
-
# This calculate element-by-element division of <tt>self</tt> and <tt>b</tt>,
|
173
|
+
# This calculate element-by-element division of <tt>self</tt> and <tt>b</tt>,
|
174
174
|
# and returns a new tensor.
|
175
175
|
# Multiplies the elements of tensor <tt>b</tt> to the elements of <tt>self</tt> , <tt>in-place</tt>.
|
176
176
|
# ---
|
@@ -216,10 +216,10 @@
|
|
216
216
|
# * GSL::Tensor#==(b)
|
217
217
|
#
|
218
218
|
# Returns <tt>true</tt> if the tensors have same size and elements
|
219
|
-
# equal to absolute accurary <tt>eps</tt> for all the indices,
|
219
|
+
# equal to absolute accurary <tt>eps</tt> for all the indices,
|
220
220
|
# and <tt>false</tt> otherwise.
|
221
221
|
#
|
222
|
-
# ===
|
222
|
+
# === Tensor properties
|
223
223
|
# ---
|
224
224
|
# * GSL::Tensor#isnull
|
225
225
|
#
|
@@ -242,10 +242,10 @@
|
|
242
242
|
#
|
243
243
|
# Returns the size
|
244
244
|
#
|
245
|
-
# {prev}[link:
|
246
|
-
# {next}[link:
|
245
|
+
# {prev}[link:rng_rdoc.html#label-Random+number+generator+initialization]
|
246
|
+
# {next}[link:narray_rdoc.html]
|
247
247
|
#
|
248
|
-
# {Reference index}[link:
|
248
|
+
# {Reference index}[link:ref_rdoc.html]
|
249
249
|
# {top}[link:index.html]
|
250
250
|
#
|
251
251
|
#
|
data/rdoc/tut.rdoc
CHANGED
data/rdoc/use.rdoc
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
#
|
2
2
|
# = Using Ruby/GSL
|
3
|
-
# ==
|
3
|
+
# == Installation
|
4
4
|
# See {here}[link:index.html].
|
5
5
|
#
|
6
|
-
# ==
|
6
|
+
# == Load the library
|
7
7
|
# Put at the head of your scripts,
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# require 'rubygems' # if installed via RubyGems
|
10
10
|
# require 'gsl'
|
11
11
|
#
|
12
|
-
# ==
|
12
|
+
# == Naming conventions, C Structs and Ruby Classes
|
13
13
|
#
|
14
|
-
# Most of the GSL data types, functions or constants are named as <tt>gsl_xxx</tt> or <tt>GSL_XXX</tt>.
|
15
|
-
# In Ruby/GSL, the prefix <tt>gsl_</tt> is replaced by the module identifier <tt>GSL::</tt>,
|
14
|
+
# Most of the GSL data types, functions or constants are named as <tt>gsl_xxx</tt> or <tt>GSL_XXX</tt>.
|
15
|
+
# In Ruby/GSL, the prefix <tt>gsl_</tt> is replaced by the module identifier <tt>GSL::</tt>,
|
16
16
|
# where <tt>GSL</tt> is the top level module of Ruby/GSL,
|
17
17
|
# and the Ruby classes are defined for each of the GSL C structs under the <tt>GSL</tt> module.
|
18
18
|
# According to the Ruby manner, the name of each class begins with a capital. For example,
|
@@ -32,40 +32,40 @@
|
|
32
32
|
# * Singleton method <tt>GSL::Linalg::LU.decomp</tt>
|
33
33
|
# * Method <tt>GSL::Matrix#LU_decomp</tt>
|
34
34
|
#
|
35
|
-
# ==
|
35
|
+
# == Examples
|
36
36
|
# See the directories "examples/" and "tests/".
|
37
37
|
#
|
38
38
|
# Some of the examples use the <tt>graph</tt> utility to show the results. The <tt>graph</tt>
|
39
|
-
# utility is included in the {GNU plotutils}[
|
40
|
-
# related packages are available from
|
41
|
-
# {here}[http://
|
39
|
+
# utility is included in the {GNU plotutils}[https://gnu.org/software/plotutils/plotutils.html] package. Windows-cygwin binaries of <tt>GNU plotutils</tt> and
|
40
|
+
# related packages are available from
|
41
|
+
# {here}[http://gnuwin32.sourceforge.net/packages/plotutils.htm].
|
42
42
|
#
|
43
|
-
# ==
|
43
|
+
# == Modules and Classes
|
44
44
|
# The following is the list of Ruby/GSL modules and classes, <Name> (<Module or Class>)
|
45
45
|
#
|
46
|
-
# * GSL (Module)
|
47
|
-
# * Complex (Class)
|
48
|
-
# * Poly (Class)
|
46
|
+
# * GSL (Module)
|
47
|
+
# * Complex (Class)
|
48
|
+
# * Poly (Class)
|
49
49
|
# * Workspace (Class)
|
50
50
|
# * DividedDifferenceRepresentation (Class)
|
51
51
|
# * Taylor (Class)
|
52
|
-
# * Sf (Module)
|
52
|
+
# * Sf (Module)
|
53
53
|
# * Result (Class)
|
54
54
|
# * Block (Class)
|
55
55
|
# * Int (Class)
|
56
56
|
# * Byte (Class)
|
57
57
|
# * Index < Permutation
|
58
|
-
# * Vector (Class)
|
58
|
+
# * Vector (Class)
|
59
59
|
# * View < Vector
|
60
60
|
# * Complex (Class)
|
61
61
|
# * View < Vector::Complex
|
62
|
-
# * Matrix (Class)
|
62
|
+
# * Matrix (Class)
|
63
63
|
# * View < Matrix (Class)
|
64
64
|
# * Complex (Class)
|
65
65
|
# * View < Matrix::Complex
|
66
|
-
# * Permutation (Class)
|
67
|
-
# * Combination (Class)
|
68
|
-
# * Linalg (Module)
|
66
|
+
# * Permutation (Class)
|
67
|
+
# * Combination (Class)
|
68
|
+
# * Linalg (Module)
|
69
69
|
# * LU (Module)
|
70
70
|
# * QR (Module)
|
71
71
|
# * QRPT (Module)
|
@@ -90,12 +90,12 @@
|
|
90
90
|
# * Workspace (Class)
|
91
91
|
# * Hermv (Module)
|
92
92
|
# * Workspace (Class)
|
93
|
-
# * FFT (Module)
|
93
|
+
# * FFT (Module)
|
94
94
|
# * ComplexWavetable (Class)
|
95
95
|
# * ComplexWorkspace (Class)
|
96
96
|
# * HalfComplexWavetable (Class)
|
97
97
|
# * RealWavetable (Class)
|
98
|
-
# * RealWorkspace (Class)
|
98
|
+
# * RealWorkspace (Class)
|
99
99
|
# * Wavelet (Class)
|
100
100
|
# * Wavelet2d < Wavelet
|
101
101
|
# * Function (Class)
|
@@ -104,15 +104,15 @@
|
|
104
104
|
# * Workspace
|
105
105
|
# * QAWS_Table
|
106
106
|
# * QAWO_Table
|
107
|
-
# * Rng (Class)
|
107
|
+
# * Rng (Class)
|
108
108
|
# * QRng (Class)
|
109
109
|
# * Ran (Module)
|
110
|
-
# * Stats (Module)
|
111
|
-
# * Histogram (Class)
|
110
|
+
# * Stats (Module)
|
111
|
+
# * Histogram (Class)
|
112
112
|
# * Integral < Histogram
|
113
113
|
# * Pdf (Class)
|
114
114
|
# * Histogram2d (Class)
|
115
|
-
# * N-tuples
|
115
|
+
# * N-tuples
|
116
116
|
# * SelectFn (Class)
|
117
117
|
# * ValueFn (Class)
|
118
118
|
# * Monte (Module)
|
@@ -135,43 +135,43 @@
|
|
135
135
|
# * Interp (Class)
|
136
136
|
# * Accel (Class)
|
137
137
|
# * Spline (Class)
|
138
|
-
# * Diff (Module)
|
138
|
+
# * Diff (Module)
|
139
139
|
# * Deriv (Module)
|
140
|
-
# * Cheb (Class)
|
141
|
-
# * Sum (Module)
|
140
|
+
# * Cheb (Class)
|
141
|
+
# * Sum (Module)
|
142
142
|
# * Levin_u (Class)
|
143
143
|
# * Levin_utrunc (Class)
|
144
|
-
# * Dht (Class)
|
144
|
+
# * Dht (Class)
|
145
145
|
# * Root (Module)
|
146
146
|
# * Solver (Class)
|
147
147
|
# * FdfSolver (Class)
|
148
|
-
# * Min(Module)
|
148
|
+
# * Min(Module)
|
149
149
|
# * FMinimizer (Class)
|
150
150
|
# * MultiRoot (Module)
|
151
151
|
# * Function (Class)
|
152
152
|
# * FSolver (Class)
|
153
153
|
# * Function_fdf (Class)
|
154
154
|
# * FdfSolver (Class)
|
155
|
-
# * MultiMin (Module)
|
155
|
+
# * MultiMin (Module)
|
156
156
|
# * Function (Class)
|
157
157
|
# * FMinimizer (Class)
|
158
158
|
# * Function_fdf (Class)
|
159
159
|
# * FdfMinimizer (Class)
|
160
|
-
# * Fit (Module)
|
160
|
+
# * Fit (Module)
|
161
161
|
# * MultiFit (Module)
|
162
162
|
# * Workspace (Class)
|
163
163
|
# * Solver (Class)
|
164
164
|
# * Function_fdf (Class)
|
165
165
|
# * FdfSolver (Class)
|
166
|
-
# * CONST (Module)
|
166
|
+
# * CONST (Module)
|
167
167
|
# * MKSA (Module)
|
168
168
|
# * CGSM (Module)
|
169
169
|
# * NUM (Module)
|
170
170
|
#
|
171
|
-
# {prev}[link:
|
172
|
-
# {next}[link:
|
171
|
+
# {prev}[link:intro_rdoc.html]
|
172
|
+
# {next}[link:ehandling_rdoc.html]
|
173
173
|
#
|
174
|
-
# {Reference index}[link:
|
174
|
+
# {Reference index}[link:ref_rdoc.html]
|
175
175
|
# {top}[link:index.html]
|
176
176
|
#
|
177
177
|
#
|
data/rdoc/vector.rdoc
CHANGED
@@ -2,37 +2,37 @@
|
|
2
2
|
# = GSL::Vector class
|
3
3
|
#
|
4
4
|
# Contents:
|
5
|
-
# 1. {Class methods}[link:
|
6
|
-
# 1. {Notes}[link:
|
7
|
-
# 1. {Methods}[link:
|
8
|
-
# 1. {Accessing vector elements}[link:
|
9
|
-
# 1. {Initializing vector elements}[link:
|
10
|
-
# 1. {Iterators}[link:
|
11
|
-
# 1. {IO}[link:
|
12
|
-
# 1. {Copying vectors}[link:
|
13
|
-
# 1. {Vector views}[link:
|
14
|
-
# 1. {Vector operations}[link:
|
15
|
-
# 1. {Vector operations with size changes}[link:
|
16
|
-
# 1. {Finding maximum and minimum elements of vectors}[link:
|
17
|
-
# 1. {Vector properties}[link:
|
18
|
-
# 1. {Element-wise vector comparison}[link:
|
19
|
-
# 1. {Histogram}[link:
|
20
|
-
# 1. {Sorting}[link:
|
21
|
-
# 1. {BLAS methods}[link:
|
22
|
-
# 1. {Data type conversions}[link:
|
23
|
-
# 1. {NArray}[link:
|
24
|
-
# 1. {GNU graph interface}[link:
|
25
|
-
#
|
26
|
-
# See also {GSL::Vector::Complex}[link:
|
27
|
-
#
|
28
|
-
# ==
|
29
|
-
#
|
30
|
-
# ---
|
31
|
-
# * GSL::Vector.alloc(ary)
|
32
|
-
# * GSL::Vector.alloc(ary)
|
33
|
-
# * GSL::Vector.alloc(range)
|
34
|
-
# * GSL::Vector.alloc(size)
|
35
|
-
# * GSL::Vector.alloc(elm0, elm1, ....)
|
5
|
+
# 1. {Class methods}[link:vector_rdoc.html#label-Class+methods]
|
6
|
+
# 1. {Notes}[link:vector_rdoc.html#label-NOTE%3A]
|
7
|
+
# 1. {Methods}[link:vector_rdoc.html#label-Methods]
|
8
|
+
# 1. {Accessing vector elements}[link:vector_rdoc.html#label-Accessing+vector+elements]
|
9
|
+
# 1. {Initializing vector elements}[link:vector_rdoc.html#label-Initializing+vector+elements]
|
10
|
+
# 1. {Iterators}[link:vector_rdoc.html#label-Iterators]
|
11
|
+
# 1. {IO}[link:vector_rdoc.html#label-IO]
|
12
|
+
# 1. {Copying vectors}[link:vector_rdoc.html#label-Copying+vectors]
|
13
|
+
# 1. {Vector views}[link:vector_rdoc.html#label-Vector+views]
|
14
|
+
# 1. {Vector operations}[link:vector_rdoc.html#label-Vector+operations]
|
15
|
+
# 1. {Vector operations with size changes}[link:vector_rdoc.html#label-Vector+operations+with+size+changes]
|
16
|
+
# 1. {Finding maximum and minimum elements of vectors}[link:vector_rdoc.html#label-Finding+maximum+and+minimum+elements+of+vectors]
|
17
|
+
# 1. {Vector properties}[link:vector_rdoc.html#label-Vector+Properties]
|
18
|
+
# 1. {Element-wise vector comparison}[link:vector_rdoc.html#label-Element-wise+vector+comparison]
|
19
|
+
# 1. {Histogram}[link:vector_rdoc.html#label-Histogram]
|
20
|
+
# 1. {Sorting}[link:vector_rdoc.html#label-Sorting]
|
21
|
+
# 1. {BLAS methods}[link:vector_rdoc.html#label-BLAS+Methods]
|
22
|
+
# 1. {Data type conversions}[link:vector_rdoc.html#label-Data+type+conversions]
|
23
|
+
# 1. {NArray}[link:vector_rdoc.html#label-NArray+conversions]
|
24
|
+
# 1. {GNU graph interface}[link:vector_rdoc.html#label-Graphics]
|
25
|
+
#
|
26
|
+
# See also {GSL::Vector::Complex}[link:vector_complex_rdoc.html].
|
27
|
+
#
|
28
|
+
# == Class methods
|
29
|
+
#
|
30
|
+
# ---
|
31
|
+
# * GSL::Vector.alloc(ary)
|
32
|
+
# * GSL::Vector.alloc(ary)
|
33
|
+
# * GSL::Vector.alloc(range)
|
34
|
+
# * GSL::Vector.alloc(size)
|
35
|
+
# * GSL::Vector.alloc(elm0, elm1, ....)
|
36
36
|
# * GSL::Vector[elm0, elm1, ....]
|
37
37
|
#
|
38
38
|
# Constructors.
|
@@ -57,12 +57,12 @@
|
|
57
57
|
# ---
|
58
58
|
# * GSL::Vector.linspace(min, max, n = 10)
|
59
59
|
#
|
60
|
-
# Creates an <tt>GSL::Vector</tt> with <tt>n</tt> linearly spaced elements
|
61
|
-
# between <tt>min</tt> and <tt>max</tt>. If <tt>min</tt> is greater than <tt>max</tt>,
|
60
|
+
# Creates an <tt>GSL::Vector</tt> with <tt>n</tt> linearly spaced elements
|
61
|
+
# between <tt>min</tt> and <tt>max</tt>. If <tt>min</tt> is greater than <tt>max</tt>,
|
62
62
|
# the elements are stored in decreasing order. This mimics the <tt>linspace</tt>
|
63
|
-
# function of {GNU Octave}[
|
63
|
+
# function of {GNU Octave}[https://gnu.org/software/octave/].
|
64
64
|
#
|
65
|
-
# Ex:
|
65
|
+
# Ex:
|
66
66
|
# >> x = GSL::Vector.linspace(0, 10, 5)
|
67
67
|
# [ 0.000e+00 2.500e+00 5.000e+00 7.500e+00 1.000e+01 ]
|
68
68
|
# >> y = GSL::Vector.linspace(10, 0, 5)
|
@@ -71,7 +71,7 @@
|
|
71
71
|
# ---
|
72
72
|
# * GSL::Vector.logspace(min, max, n)
|
73
73
|
#
|
74
|
-
# Similar to <tt>GSL::Vector#linspace</tt> except that the values are
|
74
|
+
# Similar to <tt>GSL::Vector#linspace</tt> except that the values are
|
75
75
|
# logarithmically spaced from 10^<tt>min</tt> to 10^<tt>max</tt>.
|
76
76
|
#
|
77
77
|
# Ex:
|
@@ -83,7 +83,7 @@
|
|
83
83
|
# ---
|
84
84
|
# * GSL::Vector.logspace2(min, max, n)
|
85
85
|
#
|
86
|
-
# Similar to <tt>GSL::Vector#linspace</tt> except that the values are
|
86
|
+
# Similar to <tt>GSL::Vector#linspace</tt> except that the values are
|
87
87
|
# logarithmically spaced from <tt>min</tt> to <tt>max</tt>.
|
88
88
|
#
|
89
89
|
# Ex:
|
@@ -97,13 +97,13 @@
|
|
97
97
|
#
|
98
98
|
# This creates a vector of length <tt>n</tt> with elements from <tt>start</tt>
|
99
99
|
# with interval <tt>step</tt> (mimics NArray#indgen).
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# Ex:
|
102
102
|
# >> v = GSL::Vector::Int.indgen(5)
|
103
|
-
# => GSL::Vector::Int:
|
103
|
+
# => GSL::Vector::Int:
|
104
104
|
# [ 0 1 2 3 4 ]
|
105
105
|
# >> v = GSL::Vector::Int.indgen(5, 3)
|
106
|
-
# => GSL::Vector::Int:
|
106
|
+
# => GSL::Vector::Int:
|
107
107
|
# [ 3 4 5 6 7 ]
|
108
108
|
# >> v = GSL::Vector.indgen(4, 1.2, 0.3)
|
109
109
|
# => GSL::Vector
|
@@ -123,39 +123,39 @@
|
|
123
123
|
# c = [6, 6, 7]
|
124
124
|
# d = [5, 7, 9]
|
125
125
|
#
|
126
|
-
# ===
|
126
|
+
# === NArray Extension
|
127
127
|
# If an <tt>NArray</tt> object is given, a newly allocated vector is created.
|
128
128
|
#
|
129
129
|
# Ex:
|
130
130
|
# na = NArray[1.0, 2, 3, 4, 5]
|
131
|
-
# p na <----- NArray.float(5):
|
131
|
+
# p na <----- NArray.float(5):
|
132
132
|
# [ 1.0, 2.0, 3.0, 4.0, 5.0]
|
133
|
-
# v = GSL::Vector.alloc(na)
|
133
|
+
# v = GSL::Vector.alloc(na)
|
134
134
|
# p v <----- [ 1 2 3 4 5 ]
|
135
135
|
#
|
136
136
|
#
|
137
|
-
# See also {here}[link:
|
137
|
+
# See also {here}[link:vector_rdoc.html#label-NArray+conversions].
|
138
138
|
#
|
139
|
-
# ==
|
139
|
+
# == NOTE:
|
140
140
|
# In Ruby/GSL, vector length is limited within the range of Fixnum.
|
141
141
|
# For 32-bit CPU, the maximum of vector length is 2^30 ~ 1e9.
|
142
142
|
#
|
143
|
-
# ==
|
143
|
+
# == Methods
|
144
144
|
#
|
145
|
-
# ===
|
145
|
+
# === Accessing vector elements
|
146
146
|
# ---
|
147
147
|
# * GSL::Vector#get(args)
|
148
|
-
# * GSL::Vector#[args]
|
148
|
+
# * \GSL::Vector#[args]
|
149
149
|
#
|
150
150
|
# Returns elements(s) of the vector <tt>self</tt> if <tt>args</tt> is a single
|
151
151
|
# <tt>Fixnum</tt>, a single <tt>Array</tt> of <tt>Fixnums</tt>, or a single
|
152
152
|
# <tt>GSL::Permutation</tt> (or <tt>GSL::Index</tt>). For all other <tt>args</tt>,
|
153
153
|
# the arguments are treated as with <tt>Vector#subvector</tt> and a
|
154
|
-
# <tt>Vector::View</tt> is returned.
|
154
|
+
# <tt>Vector::View</tt> is returned.
|
155
155
|
#
|
156
156
|
# ---
|
157
157
|
# * GSL::Vector#set(args, val)
|
158
|
-
# * GSL::Vector#[args] = val
|
158
|
+
# * \GSL::Vector#[args] = val
|
159
159
|
#
|
160
160
|
# If <tt>args</tt> is empty, behaves as <tt>#set_all</tt> and <tt>val</tt> must be a
|
161
161
|
# <tt>Numeric</tt>.
|
@@ -211,7 +211,7 @@
|
|
211
211
|
# [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 1.230e+02 ]
|
212
212
|
#
|
213
213
|
#
|
214
|
-
# ===
|
214
|
+
# === Initializing vector elements
|
215
215
|
# ---
|
216
216
|
# * GSL::Vector#set_all(x)
|
217
217
|
#
|
@@ -226,19 +226,19 @@
|
|
226
226
|
# * GSL::Vector#set_basis!(i)
|
227
227
|
#
|
228
228
|
# This method makes a basis vector by setting all the elements of the vector
|
229
|
-
# to zero except for the <tt>i</tt>-th element, which is set to one.
|
229
|
+
# to zero except for the <tt>i</tt>-th element, which is set to one.
|
230
230
|
# For a vector <tt>v</tt> of size 10, the method
|
231
231
|
# v.set_basis!(4)
|
232
|
-
# sets the vector <tt>v</tt> to a basis vector <tt>[0, 0, 0, 0, 1, 0, 0, 0, 0, 0]</tt>.
|
232
|
+
# sets the vector <tt>v</tt> to a basis vector <tt>[0, 0, 0, 0, 1, 0, 0, 0, 0, 0]</tt>.
|
233
233
|
#
|
234
234
|
# ---
|
235
235
|
# * GSL::Vector#set_basis(i)
|
236
236
|
#
|
237
|
-
# This method returns a new basis vector by setting all the elements of the
|
238
|
-
# vector to zero except for the i-th element which is set to one.
|
237
|
+
# This method returns a new basis vector by setting all the elements of the
|
238
|
+
# vector to zero except for the i-th element which is set to one.
|
239
239
|
# For a vector <tt>v</tt> of size 10, the method
|
240
240
|
# vb = v.set_basis(4)
|
241
|
-
# creates a new vector <tt>vb</tt> with elements <tt>[0, 0, 0, 0, 1, 0, 0, 0, 0, 0]</tt>.
|
241
|
+
# creates a new vector <tt>vb</tt> with elements <tt>[0, 0, 0, 0, 1, 0, 0, 0, 0, 0]</tt>.
|
242
242
|
# The vector <tt>v</tt> is not changed.
|
243
243
|
#
|
244
244
|
# ---
|
@@ -247,7 +247,7 @@
|
|
247
247
|
#
|
248
248
|
# Mimics NArray#indgen!.
|
249
249
|
#
|
250
|
-
# ===
|
250
|
+
# === Iterators
|
251
251
|
# ---
|
252
252
|
# * GSL::Vector#each
|
253
253
|
# * GSL::Vector#reverse_each
|
@@ -262,7 +262,7 @@
|
|
262
262
|
# * GSL::Vector#each_index
|
263
263
|
# * GSL::Vector#reverse_each_index
|
264
264
|
#
|
265
|
-
# Iterators
|
265
|
+
# Iterators
|
266
266
|
#
|
267
267
|
# ---
|
268
268
|
# * GSL::Vector#collect { |item| .. }
|
@@ -297,7 +297,7 @@
|
|
297
297
|
# => GSL::Vector::Int
|
298
298
|
# [ 0 1 4 9 16 25 ]
|
299
299
|
#
|
300
|
-
# ===
|
300
|
+
# === IO
|
301
301
|
# ---
|
302
302
|
# * GSL::Vector#print
|
303
303
|
# * GSL::Vector#fprintf(io, format = "%e")
|
@@ -309,20 +309,20 @@
|
|
309
309
|
# * GSL::Vector#fread(io)
|
310
310
|
# * GSL::Vector#fread(filename)
|
311
311
|
#
|
312
|
-
# Methods for writing or reading the vector.
|
312
|
+
# Methods for writing or reading the vector.
|
313
313
|
# The first argument is an <tt>IO</tt> or a <tt>String</tt> object.
|
314
314
|
#
|
315
|
-
# ===
|
315
|
+
# === Copying vectors
|
316
316
|
# ---
|
317
317
|
# * GSL::Vector#clone
|
318
318
|
# * GSL::Vector#duplicate
|
319
319
|
#
|
320
320
|
# Create a new vector of the same elements.
|
321
321
|
#
|
322
|
-
# ===
|
322
|
+
# === Vector views
|
323
323
|
# The <tt>GSL::Vector::View</tt> class is defined to be used as "references" to
|
324
324
|
# vectors. Since the <tt>Vector::View</tt> class is a subclass of <tt>Vector</tt>,
|
325
|
-
# an instance of the <tt>View</tt> class created by slicing a <tt>Vector</tt> object
|
325
|
+
# an instance of the <tt>View</tt> class created by slicing a <tt>Vector</tt> object
|
326
326
|
# can be used same as the original vector. A
|
327
327
|
# <tt>View</tt> object shares the data with the original vector, i.e. any changes
|
328
328
|
# in the elements of the <tt>View</tt> object affect to the original vector.
|
@@ -371,30 +371,30 @@
|
|
371
371
|
# * GSL::Vector#matrix_view(n1, n2)
|
372
372
|
#
|
373
373
|
# This creates a <tt>Matrix::View</tt> object from the vector <tt>self</tt>.
|
374
|
-
# It enables to use the vector as a {Matrix}[link:
|
374
|
+
# It enables to use the vector as a {Matrix}[link:matrix_rdoc.html] object.
|
375
375
|
#
|
376
376
|
# * Ex:
|
377
377
|
#
|
378
378
|
# >> v = GSL::Vector::Int.alloc(1..9)
|
379
|
-
# => GSL::Vector::Int:
|
379
|
+
# => GSL::Vector::Int:
|
380
380
|
# [ 1 2 3 4 5 6 7 8 9 ]
|
381
381
|
# >> m = v.matrix_view(3, 3)
|
382
|
-
# => GSL::Matrix::Int::View:
|
383
|
-
# [ 1 2 3
|
384
|
-
# 4 5 6
|
382
|
+
# => GSL::Matrix::Int::View:
|
383
|
+
# [ 1 2 3
|
384
|
+
# 4 5 6
|
385
385
|
# 7 8 9 ]
|
386
386
|
# >> m[1][2] = 99
|
387
387
|
# => 99
|
388
388
|
# >> v
|
389
|
-
# => GSL::Vector::Int:
|
389
|
+
# => GSL::Vector::Int:
|
390
390
|
# [ 1 2 3 4 5 99 7 8 9 ]
|
391
391
|
#
|
392
|
-
# ===
|
392
|
+
# === Vector operations
|
393
393
|
#
|
394
394
|
# ---
|
395
395
|
# * GSL::Vector#swap_elements(i, j)
|
396
396
|
#
|
397
|
-
# This method exchanges the i-th and j-th elements of the vector <tt>in-place</tt>.
|
397
|
+
# This method exchanges the i-th and j-th elements of the vector <tt>in-place</tt>.
|
398
398
|
#
|
399
399
|
# ---
|
400
400
|
# * GSL::Vector#reverse
|
@@ -402,10 +402,10 @@
|
|
402
402
|
# Reverses the order of the elements of the vector.
|
403
403
|
#
|
404
404
|
# >> v = GSL::Vector::Int[1..5]
|
405
|
-
# => GSL::Vector::Int:
|
405
|
+
# => GSL::Vector::Int:
|
406
406
|
# [ 1 2 3 4 5 ]
|
407
407
|
# >> v.reverse
|
408
|
-
# => GSL::Vector::Int:
|
408
|
+
# => GSL::Vector::Int:
|
409
409
|
# [ 5 4 3 2 1 ]
|
410
410
|
#
|
411
411
|
# ---
|
@@ -417,20 +417,20 @@
|
|
417
417
|
# Transpose the vector from a row vector into a column vector and vice versa.
|
418
418
|
#
|
419
419
|
# >> v = GSL::Vector::Int[1..5]
|
420
|
-
# => GSL::Vector::Int:
|
420
|
+
# => GSL::Vector::Int:
|
421
421
|
# [ 1 2 3 4 5 ]
|
422
422
|
# >> v.col
|
423
|
-
# => GSL::Vector::Int::Col:
|
424
|
-
# [ 1
|
425
|
-
# 2
|
426
|
-
# 3
|
427
|
-
# 4
|
423
|
+
# => GSL::Vector::Int::Col:
|
424
|
+
# [ 1
|
425
|
+
# 2
|
426
|
+
# 3
|
427
|
+
# 4
|
428
428
|
# 5 ]
|
429
429
|
#
|
430
430
|
# ---
|
431
431
|
# * GSL::Vector#add(b)
|
432
432
|
#
|
433
|
-
# Adds the elements of vector <tt>b</tt> to the elements
|
433
|
+
# Adds the elements of vector <tt>b</tt> to the elements
|
434
434
|
# of the vector <tt>self</tt>. A new vector is created, and the vector
|
435
435
|
# <tt>self</tt> is not changed.
|
436
436
|
#
|
@@ -453,7 +453,7 @@
|
|
453
453
|
# * GSL::Vector#scale(x)
|
454
454
|
# * GSL::Vector#scale!(x)
|
455
455
|
#
|
456
|
-
# This method multiplies the elements of vector <tt>self</tt> by
|
456
|
+
# This method multiplies the elements of vector <tt>self</tt> by
|
457
457
|
# the constant factor <tt>x</tt>.
|
458
458
|
#
|
459
459
|
# ---
|
@@ -490,34 +490,34 @@
|
|
490
490
|
# >> v = GSL::Vector[1, 2]
|
491
491
|
# [ 1 2 ]
|
492
492
|
# >> v*2
|
493
|
-
# [ 2 4 ]
|
493
|
+
# [ 2 4 ]
|
494
494
|
# 1. Element-by-element multiplication
|
495
495
|
# >> a = GSL::Vector[1, 2]; b = GSL::Vector[3, 4]
|
496
496
|
# [ 3 4 ]
|
497
497
|
# >> a*b
|
498
|
-
# [ 3 8 ]
|
498
|
+
# [ 3 8 ]
|
499
499
|
# 1. Inner product
|
500
500
|
# >> a = GSL::Vector[1, 2]; b = GSL::Vector[3, 4]
|
501
|
-
# [ 3
|
501
|
+
# [ 3
|
502
502
|
# 4 ]
|
503
503
|
# >> a*b.col
|
504
|
-
# => 11.0
|
504
|
+
# => 11.0
|
505
505
|
# 1. GSL::Vector::Col*Vector -> GSL::Matrix
|
506
506
|
# >> a = GSL::Vector::Col[1, 2]; b = GSL::Vector[3, 4]
|
507
507
|
# [ 3 4 ]
|
508
508
|
# >> a*b
|
509
|
-
# [ 3 4
|
509
|
+
# [ 3 4
|
510
510
|
# 6 8 ]
|
511
511
|
# 1. GSL::Matrix*Vector::Col -> GSL::Vector::Col
|
512
512
|
# >> a = GSL::Vector[1, 2]; m = GSL::Matrix[[2, 3], [4, 5]]
|
513
|
-
# [ 2 3
|
513
|
+
# [ 2 3
|
514
514
|
# 4 5 ]
|
515
515
|
# >> m*a <--- Error
|
516
516
|
# TypeError: Operation with GSL::Vector is not defined (GSL::Vector::Col expected)
|
517
517
|
# from (irb):30:in `*'
|
518
518
|
# from (irb):30
|
519
519
|
# >> m*a.col
|
520
|
-
# [ 8
|
520
|
+
# [ 8
|
521
521
|
# 14 ]
|
522
522
|
#
|
523
523
|
# ---
|
@@ -565,7 +565,7 @@
|
|
565
565
|
# * GSL::Vector#duplicate
|
566
566
|
#
|
567
567
|
# These create a copy of the vector <tt>self</tt>.
|
568
|
-
#
|
568
|
+
#
|
569
569
|
# ---
|
570
570
|
# * GSL::Vector.connect(v1, v2, v3, ...)
|
571
571
|
# * GSL::Vector#connect(v2, v3, ...)
|
@@ -573,13 +573,13 @@
|
|
573
573
|
# Creates a new vector by connecting all the elements of the given vectors.
|
574
574
|
#
|
575
575
|
# >> v1 = GSL::Vector::Int[1, 3]
|
576
|
-
# => GSL::Vector::Int:
|
576
|
+
# => GSL::Vector::Int:
|
577
577
|
# [ 1 3 ]
|
578
578
|
# >> v2 = GSL::Vector::Int[4, 3, 5]
|
579
|
-
# => GSL::Vector::Int:
|
579
|
+
# => GSL::Vector::Int:
|
580
580
|
# [ 4 3 5 ]
|
581
581
|
# >> v1.connect(v2)
|
582
|
-
# => GSL::Vector::Int:
|
582
|
+
# => GSL::Vector::Int:
|
583
583
|
# [ 1 3 4 3 5 ]
|
584
584
|
#
|
585
585
|
# ---
|
@@ -597,10 +597,10 @@
|
|
597
597
|
# Creates a new vector, with elements <tt>fabs(x_i)</tt>.
|
598
598
|
#
|
599
599
|
# >> v = GSL::Vector::Int[-3, 2, -5, 4]
|
600
|
-
# => GSL::Vector::Int:
|
600
|
+
# => GSL::Vector::Int:
|
601
601
|
# [ -3 2 -5 4 ]
|
602
602
|
# >> v.abs
|
603
|
-
# => GSL::Vector::Int:
|
603
|
+
# => GSL::Vector::Int:
|
604
604
|
# [ 3 2 5 4 ]
|
605
605
|
#
|
606
606
|
# ---
|
@@ -610,10 +610,10 @@
|
|
610
610
|
# Create a new vector, with elements <tt>x_i*x_i</tt>.
|
611
611
|
#
|
612
612
|
# >> v = GSL::Vector::Int[1..4]
|
613
|
-
# => GSL::Vector::Int:
|
613
|
+
# => GSL::Vector::Int:
|
614
614
|
# [ 1 2 3 4 ]
|
615
615
|
# >> v.square
|
616
|
-
# => GSL::Vector::Int:
|
616
|
+
# => GSL::Vector::Int:
|
617
617
|
# [ 1 4 9 16 ]
|
618
618
|
#
|
619
619
|
# ---
|
@@ -655,19 +655,19 @@
|
|
655
655
|
# >> require("gsl")
|
656
656
|
# => true
|
657
657
|
# >> a = GSL::Vector[-1, -2, -3, -4]
|
658
|
-
# => GSL::Vector:
|
658
|
+
# => GSL::Vector:
|
659
659
|
# [ -1.000e+00 -2.000e+00 -3.000e+00 -4.000e+00 ]
|
660
660
|
# >> b = a.abs
|
661
|
-
# => GSL::Vector:
|
661
|
+
# => GSL::Vector:
|
662
662
|
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 ]
|
663
663
|
# >> b.sqrt
|
664
|
-
# => GSL::Vector:
|
664
|
+
# => GSL::Vector:
|
665
665
|
# [ 1.000e+00 1.414e+00 1.732e+00 2.000e+00 ]
|
666
666
|
# >> b.square
|
667
|
-
# => GSL::Vector:
|
667
|
+
# => GSL::Vector:
|
668
668
|
# [ 1.000e+00 4.000e+00 9.000e+00 1.600e+01 ]
|
669
669
|
# >> c = b.normalize(2)
|
670
|
-
# => GSL::Vector:
|
670
|
+
# => GSL::Vector:
|
671
671
|
# [ 2.582e-01 5.164e-01 7.746e-01 1.033e+00 ]
|
672
672
|
# >> c.square.sum
|
673
673
|
# => 2.0
|
@@ -675,7 +675,7 @@
|
|
675
675
|
# ---
|
676
676
|
# * GSL::Vector#decimate(n)
|
677
677
|
#
|
678
|
-
# Creates a new vector by averaring every <tt>n</tt>
|
678
|
+
# Creates a new vector by averaring every <tt>n</tt>
|
679
679
|
# points of the vector <tt>self</tt> down to one point.
|
680
680
|
#
|
681
681
|
# ---
|
@@ -702,11 +702,11 @@
|
|
702
702
|
# >> a = GSL::Vector[4, 5, 6]
|
703
703
|
# >> b = GSL::Vector[7, 8, 9]
|
704
704
|
# >> GSL::Vector[1, 2, 3].zip(a, b)
|
705
|
-
# [[ 1.000e+00 4.000e+00 7.000e+00 ],
|
706
|
-
# [ 2.000e+00 5.000e+00 8.000e+00 ],
|
705
|
+
# [[ 1.000e+00 4.000e+00 7.000e+00 ],
|
706
|
+
# [ 2.000e+00 5.000e+00 8.000e+00 ],
|
707
707
|
# [ 3.000e+00 6.000e+00 9.000e+00 ]]
|
708
708
|
# >> GSL::Vector[1, 2].zip(a, b)
|
709
|
-
# [[ 1.000e+00 4.000e+00 7.000e+00 ],
|
709
|
+
# [[ 1.000e+00 4.000e+00 7.000e+00 ],
|
710
710
|
# [ 2.000e+00 5.000e+00 8.000e+00 ]]
|
711
711
|
# >> a.zip(GSL::Vector[1, 2], GSL::Vector[8.0])
|
712
712
|
# [[ 4.000e+00 1.000e+00 8.000e+00 ],
|
@@ -720,7 +720,7 @@
|
|
720
720
|
# <tt>x</tt>, which must be an <tt>Array</tt>, <tt>Fixnum</tt>, <tt>Bignum</tt>,
|
721
721
|
# <tt>Float</tt>, <tt>Range</tt>, or <tt>GSL::Vector</tt>.
|
722
722
|
#
|
723
|
-
# ===
|
723
|
+
# === Vector operations with size changes
|
724
724
|
# The methods below change vector length of <tt>self</tt>. A Vector's length may
|
725
725
|
# not extend past its original allocation. Use of these methods is discouraged.
|
726
726
|
# Existing Views may still refer to elements beyond the end of the shortened
|
@@ -734,7 +734,7 @@
|
|
734
734
|
# ---
|
735
735
|
# * GSL::Vector#delete_at(i)
|
736
736
|
#
|
737
|
-
# Deletes the element at the specified index <tt>i</tt>,
|
737
|
+
# Deletes the element at the specified index <tt>i</tt>,
|
738
738
|
# returning that element, or <tt>nil</tt> if the index is out of range.
|
739
739
|
# ---
|
740
740
|
# * GSL::Vector#delete_if { |x| ... }
|
@@ -742,7 +742,7 @@
|
|
742
742
|
# Deletes every element of <tt>self</tt> for which block evaluates to <tt>true</tt>
|
743
743
|
# and returns <tt>self</tt>.
|
744
744
|
#
|
745
|
-
# ===
|
745
|
+
# === Finding maximum and minimum elements of vectors
|
746
746
|
#
|
747
747
|
# ---
|
748
748
|
# * GSL::Vector#max
|
@@ -763,22 +763,22 @@
|
|
763
763
|
# ---
|
764
764
|
# * GSL::Vector#max_index
|
765
765
|
#
|
766
|
-
# This method returns the index of the maximum value in the vector. When there are
|
767
|
-
# several equal maximum elements then the lowest index is returned.
|
766
|
+
# This method returns the index of the maximum value in the vector. When there are
|
767
|
+
# several equal maximum elements then the lowest index is returned.
|
768
768
|
#
|
769
769
|
# ---
|
770
770
|
# * GSL::Vector#min_index
|
771
771
|
#
|
772
|
-
# This method returns the index of the minimum value in the vector. When there are
|
773
|
-
# several equal minimum elements then the lowest index is returned.
|
772
|
+
# This method returns the index of the minimum value in the vector. When there are
|
773
|
+
# several equal minimum elements then the lowest index is returned.
|
774
774
|
#
|
775
775
|
# ---
|
776
776
|
# * GSL::Vector#minmax_index
|
777
777
|
#
|
778
|
-
# This method returns an array of two elements which has the indices
|
778
|
+
# This method returns an array of two elements which has the indices
|
779
779
|
# of the minimum and the maximum values in the vector <tt>self</tt>.
|
780
780
|
#
|
781
|
-
# ===
|
781
|
+
# === Vector Properties
|
782
782
|
# ---
|
783
783
|
# * GSL::Vector#size
|
784
784
|
# * GSL::Vector#len
|
@@ -814,12 +814,12 @@
|
|
814
814
|
# ---
|
815
815
|
# * GSL::Vector#isnull
|
816
816
|
#
|
817
|
-
# Returns 1 if all the elements of the vector <tt>self</tt>
|
817
|
+
# Returns 1 if all the elements of the vector <tt>self</tt>
|
818
818
|
# are zero, and 0 otherwise.
|
819
819
|
# ---
|
820
820
|
# * GSL::Vector#isnull?
|
821
821
|
#
|
822
|
-
# Return <tt>true</tt> if all the elements of the vector <tt>self</tt>
|
822
|
+
# Return <tt>true</tt> if all the elements of the vector <tt>self</tt>
|
823
823
|
# are zero, and <tt>false</tt> otherwise.
|
824
824
|
# ---
|
825
825
|
# * GSL::Vector#ispos
|
@@ -833,24 +833,24 @@
|
|
833
833
|
# * GSL::Vector#isnonneg
|
834
834
|
# * GSL::Vector#isnonneg?
|
835
835
|
#
|
836
|
-
# (GSL-1.10 or later) Return 1 (true) if all the elements of the vector <tt>self</tt> are non-negative , and 0 (false) otherwise.
|
836
|
+
# (GSL-1.10 or later) Return 1 (true) if all the elements of the vector <tt>self</tt> are non-negative , and 0 (false) otherwise.
|
837
837
|
#
|
838
838
|
# ---
|
839
839
|
# * GSL::Vector#all?
|
840
840
|
#
|
841
|
-
# Returns <tt>true</tt> if all the vector elements are non-zero, and <tt>false</tt>
|
841
|
+
# Returns <tt>true</tt> if all the vector elements are non-zero, and <tt>false</tt>
|
842
842
|
# otherwise. If a block is given, the method returns <tt>true</tt> if the
|
843
843
|
# tests are true for all the elements.
|
844
844
|
# ---
|
845
845
|
# * GSL::Vector#any?
|
846
846
|
#
|
847
|
-
# Returns <tt>true</tt> if any the vector elements are non-zero, and <tt>false</tt>
|
847
|
+
# Returns <tt>true</tt> if any the vector elements are non-zero, and <tt>false</tt>
|
848
848
|
# otherwise. If a block is given, the method returns <tt>true</tt> if the
|
849
849
|
# tests are true for any of the elements.
|
850
850
|
# ---
|
851
851
|
# * GSL::Vector#none?
|
852
852
|
#
|
853
|
-
# Returns <tt>true</tt> if all the elements of the vector <tt>self</tt>
|
853
|
+
# Returns <tt>true</tt> if all the elements of the vector <tt>self</tt>
|
854
854
|
# are zero, and <tt>false</tt> otherwise (just as <tt>GSL::Vector#isnull?</tt>).
|
855
855
|
# If a block is given, the method returns <tt>true</tt> if the
|
856
856
|
# tests are false for all the elements.
|
@@ -884,10 +884,10 @@
|
|
884
884
|
# * GSL::Vector#==(other, eps = 1e-10)
|
885
885
|
#
|
886
886
|
# Returns <tt>true</tt> if the vectors have same size and elements
|
887
|
-
# equal to absolute accurary <tt>eps</tt> for all the indices,
|
887
|
+
# equal to absolute accurary <tt>eps</tt> for all the indices,
|
888
888
|
# and <tt>false</tt> otherwise.
|
889
889
|
#
|
890
|
-
# ===
|
890
|
+
# === Element-wise vector comparison
|
891
891
|
# ---
|
892
892
|
# * GSL::Vector#eq(other)
|
893
893
|
# * GSL::Vector#ne(other)
|
@@ -897,7 +897,7 @@
|
|
897
897
|
# * GSL::Vector#le(other)
|
898
898
|
#
|
899
899
|
# Return a <tt>Block::Byte</tt> object with elements 0/1 by comparing the two vectors
|
900
|
-
# <tt>self</tt> and <tt>other</tt>. Note that the values returned are 0/1,
|
900
|
+
# <tt>self</tt> and <tt>other</tt>. Note that the values returned are 0/1,
|
901
901
|
# not <tt>true/false</tt>, thus all of the elements are "true" in Ruby.
|
902
902
|
#
|
903
903
|
# Ex:
|
@@ -921,7 +921,7 @@
|
|
921
921
|
# ---
|
922
922
|
# * GSL::Vector#and(other)
|
923
923
|
# * GSL::Vector#or(other)
|
924
|
-
# * GSL::Vector#xor(other)
|
924
|
+
# * GSL::Vector#xor(other)
|
925
925
|
# * GSL::Vector#not
|
926
926
|
#
|
927
927
|
#
|
@@ -956,7 +956,7 @@
|
|
956
956
|
# >> a.where
|
957
957
|
# => nil
|
958
958
|
#
|
959
|
-
# ===
|
959
|
+
# === Histogram
|
960
960
|
# ---
|
961
961
|
# * GSL::Vector#histogram(n)
|
962
962
|
# * GSL::Vector#histogram(ranges)
|
@@ -980,7 +980,7 @@
|
|
980
980
|
# h = Histogram.alloc(50, [-4, 4])
|
981
981
|
# h.increment(v)
|
982
982
|
#
|
983
|
-
# ===
|
983
|
+
# === Sorting
|
984
984
|
#
|
985
985
|
# ---
|
986
986
|
# * GSL::Vector#sort
|
@@ -991,12 +991,12 @@
|
|
991
991
|
# ---
|
992
992
|
# * GSL::Vector#sort_index
|
993
993
|
#
|
994
|
-
# This method indirectly sorts the elements of the vector <tt>self</tt> into
|
995
|
-
# ascending order, and returns the resulting permutation.
|
996
|
-
# The elements of permutation give the index of the vector element which
|
997
|
-
# would have been stored in that position if the vector had been sorted in place.
|
994
|
+
# This method indirectly sorts the elements of the vector <tt>self</tt> into
|
995
|
+
# ascending order, and returns the resulting permutation.
|
996
|
+
# The elements of permutation give the index of the vector element which
|
997
|
+
# would have been stored in that position if the vector had been sorted in place.
|
998
998
|
# The first element of permutation gives the index of the least element in the
|
999
|
-
# vector, and the last element of permutation gives the index of the greatest
|
999
|
+
# vector, and the last element of permutation gives the index of the greatest
|
1000
1000
|
# vector element. The vector <tt>self</tt> is not changed.
|
1001
1001
|
#
|
1002
1002
|
# ---
|
@@ -1008,22 +1008,22 @@
|
|
1008
1008
|
#
|
1009
1009
|
# Ex:
|
1010
1010
|
# >> v = GSL::Vector::Int[8, 2, 3, 7, 9, 1, 4]
|
1011
|
-
# => GSL::Vector::Int:
|
1011
|
+
# => GSL::Vector::Int:
|
1012
1012
|
# [ 8 2 3 7 9 1 4 ]
|
1013
1013
|
# >> v.sort
|
1014
|
-
# => GSL::Vector::Int:
|
1014
|
+
# => GSL::Vector::Int:
|
1015
1015
|
# [ 1 2 3 4 7 8 9 ]
|
1016
1016
|
# >> v.sort_index
|
1017
|
-
# => GSL::Permutation:
|
1017
|
+
# => GSL::Permutation:
|
1018
1018
|
# [ 5 1 2 6 3 0 4 ]
|
1019
1019
|
# >> v.sort_largest(3)
|
1020
|
-
# => GSL::Vector::Int:
|
1020
|
+
# => GSL::Vector::Int:
|
1021
1021
|
# [ 9 8 7 ]
|
1022
1022
|
# >> v.sort_smallest(3)
|
1023
|
-
# => GSL::Vector::Int:
|
1023
|
+
# => GSL::Vector::Int:
|
1024
1024
|
# [ 1 2 3 ]
|
1025
1025
|
#
|
1026
|
-
# ===
|
1026
|
+
# === BLAS Methods
|
1027
1027
|
# ---
|
1028
1028
|
# * GSL::Vector#nrm2
|
1029
1029
|
# * GSL::Vector#dnrm2
|
@@ -1036,9 +1036,9 @@
|
|
1036
1036
|
#
|
1037
1037
|
# Compute the absolute sum \sum |x_i| of the elements of the vector.
|
1038
1038
|
#
|
1039
|
-
# ===
|
1039
|
+
# === Data type conversions
|
1040
1040
|
# ---
|
1041
|
-
# * GSL::Vector#to_a
|
1041
|
+
# * GSL::Vector#to_a
|
1042
1042
|
#
|
1043
1043
|
# This method converts the vector into a Ruby array. A Ruby array also can be
|
1044
1044
|
# converted into a GSL::Vector object with the <tt>to_gv</tt> method. For example,
|
@@ -1056,36 +1056,36 @@
|
|
1056
1056
|
# Creates a <tt>GSL::Matrix</tt> object of <tt>nrow</tt> rows and <tt>ncol</tt> columns.
|
1057
1057
|
#
|
1058
1058
|
# >> v = GSL::Vector::Int[1..5]
|
1059
|
-
# => GSL::Vector::Int:
|
1059
|
+
# => GSL::Vector::Int:
|
1060
1060
|
# [ 1 2 3 4 5 ]
|
1061
1061
|
# >> v.to_m(2, 3)
|
1062
|
-
# => GSL::Matrix::Int:
|
1063
|
-
# [ 1 2 3
|
1062
|
+
# => GSL::Matrix::Int:
|
1063
|
+
# [ 1 2 3
|
1064
1064
|
# 4 5 0 ]
|
1065
1065
|
# >> v.to_m(2, 2)
|
1066
|
-
# => GSL::Matrix::Int:
|
1067
|
-
# [ 1 2
|
1066
|
+
# => GSL::Matrix::Int:
|
1067
|
+
# [ 1 2
|
1068
1068
|
# 3 4 ]
|
1069
1069
|
# >> v.to_m(3, 2)
|
1070
|
-
# => GSL::Matrix::Int:
|
1071
|
-
# [ 1 2
|
1072
|
-
# 3 4
|
1070
|
+
# => GSL::Matrix::Int:
|
1071
|
+
# [ 1 2
|
1072
|
+
# 3 4
|
1073
1073
|
# 5 0 ]
|
1074
1074
|
#
|
1075
1075
|
# ---
|
1076
1076
|
# * GSL::Vector#to_m_diagonal
|
1077
1077
|
#
|
1078
|
-
# Converts the vector into a diagonal matrix.
|
1079
|
-
# See also {GSL::Matrix.diagonal(v)}[link:
|
1078
|
+
# Converts the vector into a diagonal matrix.
|
1079
|
+
# See also {GSL::Matrix.diagonal(v)}[link:matrix_rdoc.html].
|
1080
1080
|
#
|
1081
1081
|
# >> v = GSL::Vector[1..4].to_i
|
1082
|
-
# => GSL::Vector::Int:
|
1082
|
+
# => GSL::Vector::Int:
|
1083
1083
|
# [ 1 2 3 4 ]
|
1084
1084
|
# >> v.to_m_diagonal
|
1085
|
-
# => GSL::Matrix::Int:
|
1086
|
-
# [ 1 0 0 0
|
1087
|
-
# 0 2 0 0
|
1088
|
-
# 0 0 3 0
|
1085
|
+
# => GSL::Matrix::Int:
|
1086
|
+
# [ 1 0 0 0
|
1087
|
+
# 0 2 0 0
|
1088
|
+
# 0 0 3 0
|
1089
1089
|
# 0 0 0 4 ]
|
1090
1090
|
#
|
1091
1091
|
# ---
|
@@ -1094,14 +1094,14 @@
|
|
1094
1094
|
# Creates a circulant matrix.
|
1095
1095
|
#
|
1096
1096
|
# >> v = GSL::Vector::Int[1..5]
|
1097
|
-
# => GSL::Vector::Int:
|
1097
|
+
# => GSL::Vector::Int:
|
1098
1098
|
# [ 1 2 3 4 5 ]
|
1099
1099
|
# >> v.to_m_circulant
|
1100
|
-
# => GSL::Matrix::Int:
|
1101
|
-
# [ 5 1 2 3 4
|
1102
|
-
# 4 5 1 2 3
|
1103
|
-
# 3 4 5 1 2
|
1104
|
-
# 2 3 4 5 1
|
1100
|
+
# => GSL::Matrix::Int:
|
1101
|
+
# [ 5 1 2 3 4
|
1102
|
+
# 4 5 1 2 3
|
1103
|
+
# 3 4 5 1 2
|
1104
|
+
# 2 3 4 5 1
|
1105
1105
|
# 1 2 3 4 5 ]
|
1106
1106
|
#
|
1107
1107
|
# ---
|
@@ -1124,12 +1124,12 @@
|
|
1124
1124
|
# * GSL::Vector#to_tensor(rank, dimension)
|
1125
1125
|
#
|
1126
1126
|
#
|
1127
|
-
# ===
|
1127
|
+
# === NArray conversions
|
1128
1128
|
#
|
1129
1129
|
# ---
|
1130
1130
|
# * GSL::Vector#to_na
|
1131
1131
|
#
|
1132
|
-
# Converts a vector <tt>self</tt> into an <tt>NArray</tt> object.
|
1132
|
+
# Converts a vector <tt>self</tt> into an <tt>NArray</tt> object.
|
1133
1133
|
# The data are copied to newly allocated memory.
|
1134
1134
|
#
|
1135
1135
|
# ---
|
@@ -1143,10 +1143,10 @@
|
|
1143
1143
|
# => GSL::Vector::Int
|
1144
1144
|
# [ 1 2 3 4 ]
|
1145
1145
|
# >> na = v.to_na
|
1146
|
-
# => NArray.int(4):
|
1146
|
+
# => NArray.int(4):
|
1147
1147
|
# [ 1, 2, 3, 4 ]
|
1148
1148
|
# >> na2 = v.to_na2
|
1149
|
-
# => NArray(ref).int(4):
|
1149
|
+
# => NArray(ref).int(4):
|
1150
1150
|
# [ 1, 2, 3, 4 ]
|
1151
1151
|
# >> na[1] = 99
|
1152
1152
|
# => 99
|
@@ -1170,53 +1170,53 @@
|
|
1170
1170
|
# * NArray#to_gv2
|
1171
1171
|
# * NArray#to_gslv_view
|
1172
1172
|
#
|
1173
|
-
# A <tt>GSL::Vector::View</tt> object is created from the NArray object <tt>self</tt>.
|
1174
|
-
# This method does not allocate memory for the data: the data of <tt>self</tt>
|
1175
|
-
# are not copied, but shared with the <tt>View</tt> object created, thus
|
1176
|
-
# any modifications to the <tt>View</tt> object affect on the original NArray
|
1177
|
-
# object. In other words, the <tt>View</tt> object can be used as a <tt>reference</tt>
|
1178
|
-
# to the NArray object.
|
1173
|
+
# A <tt>GSL::Vector::View</tt> object is created from the NArray object <tt>self</tt>.
|
1174
|
+
# This method does not allocate memory for the data: the data of <tt>self</tt>
|
1175
|
+
# are not copied, but shared with the <tt>View</tt> object created, thus
|
1176
|
+
# any modifications to the <tt>View</tt> object affect on the original NArray
|
1177
|
+
# object. In other words, the <tt>View</tt> object can be used as a <tt>reference</tt>
|
1178
|
+
# to the NArray object.
|
1179
1179
|
#
|
1180
1180
|
# Ex:
|
1181
1181
|
# tcsh> irb
|
1182
1182
|
# >> require("gsl")
|
1183
1183
|
# => true
|
1184
|
-
# >> na = NArray[1.0, 2, 3, 4, 5]
|
1185
|
-
# => NArray.float(5):
|
1184
|
+
# >> na = NArray[1.0, 2, 3, 4, 5]
|
1185
|
+
# => NArray.float(5):
|
1186
1186
|
# [ 1.0, 2.0, 3.0, 4.0, 5.0 ]
|
1187
1187
|
# >> vv = na.to_gv_view # Create a view sharing the memory
|
1188
|
-
# => GSL::Vector::View
|
1188
|
+
# => GSL::Vector::View
|
1189
1189
|
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00 ]
|
1190
1190
|
# >> vv[3] = 9
|
1191
1191
|
# => 9
|
1192
1192
|
# >> na
|
1193
|
-
# => NArray.float(5):
|
1193
|
+
# => NArray.float(5):
|
1194
1194
|
# [ 1.0, 2.0, 3.0, 9.0, 5.0 ] # The data are changed
|
1195
1195
|
# >> v = na.to_gv # A vector with newly allocated memory
|
1196
|
-
# => GSL::Vector
|
1196
|
+
# => GSL::Vector
|
1197
1197
|
# [ 1.000e+00 2.000e+00 3.000e+00 9.000e+00 5.000e+00 ]
|
1198
1198
|
# >> v[1] = 123
|
1199
1199
|
# => 123
|
1200
1200
|
# >> v
|
1201
|
-
# => GSL::Vector
|
1201
|
+
# => GSL::Vector
|
1202
1202
|
# [ 1.000e+00 1.230e+02 3.000e+00 9.000e+00 5.000e+00 ]
|
1203
|
-
# >> na
|
1204
|
-
# => NArray.float(5):
|
1205
|
-
# [ 1.0, 2.0, 3.0, 9.0, 5.0 ] # v and na are independent
|
1203
|
+
# >> na
|
1204
|
+
# => NArray.float(5):
|
1205
|
+
# [ 1.0, 2.0, 3.0, 9.0, 5.0 ] # v and na are independent
|
1206
1206
|
# >> na = NArray[1.0, 2, 3, 4, 5, 6]
|
1207
|
-
# => NArray.float(6):
|
1207
|
+
# => NArray.float(6):
|
1208
1208
|
# [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
|
1209
1209
|
# >> m = na.to_gv_view.matrix_view(2, 3)
|
1210
1210
|
# => GSL::Matrix::View
|
1211
|
-
# [ 1.000e+00 2.000e+00 3.000e+00
|
1211
|
+
# [ 1.000e+00 2.000e+00 3.000e+00
|
1212
1212
|
# 4.000e+00 5.000e+00 6.000e+00 ]
|
1213
1213
|
# >> m[1][2] = 9
|
1214
1214
|
# => 9
|
1215
1215
|
# >> na
|
1216
|
-
# => NArray.float(6):
|
1216
|
+
# => NArray.float(6):
|
1217
1217
|
# [ 1.0, 2.0, 3.0, 4.0, 5.0, 9.0 ]
|
1218
1218
|
#
|
1219
|
-
# ===
|
1219
|
+
# === Graphics
|
1220
1220
|
# ---
|
1221
1221
|
# * GSL::Vector.graph(y)
|
1222
1222
|
# * GSL::Vector.graph(y, options)
|
@@ -1234,10 +1234,10 @@
|
|
1234
1234
|
# >> s = GSL::Sf::sin(x)
|
1235
1235
|
# >> GSL::Vector.graph(x, c, s, "-T X -C -L 'cos(x), sin(x)'")
|
1236
1236
|
#
|
1237
|
-
# {prev}[link:
|
1238
|
-
# {next}[link:
|
1237
|
+
# {prev}[link:sf_rdoc.html]
|
1238
|
+
# {next}[link:matrix_rdoc.html]
|
1239
1239
|
#
|
1240
|
-
# {Reference index}[link:
|
1240
|
+
# {Reference index}[link:ref_rdoc.html]
|
1241
1241
|
# {top}[link:index.html]
|
1242
|
-
#
|
1242
|
+
#
|
1243
1243
|
#
|