The GSL-VECTOR module¶
The <gsl-vector> type¶
- <gsl-vector> Class¶
- Superclasses:
<mutable-sequence>
- Discussion:
A vector of double precision floating point numbers.
- Slots:
- gsl-vector-stride(<gsl-vector>) Method¶
- Signature:
gsl-vector-stride (vector) => (stride)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
stride – An instance of <integer>.
- Discussion:
Return the stride of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let stride = v.gsl-vector-stride;
- gsl-vector-stride-setter(<gsl-vector>) Method¶
- Signature:
gsl-vector-stride-setter (stride vector) => (stride)
- Parameters:
stride – An instance of <integer>.
vector – An instance of <gsl-vector>.
- Values:
stride – An instance of <integer>.
- Discussion:
Set the stride of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); v.gsl-vector-stride := 2;
Allocation functions¶
- make(<gsl-vector>) Method¶
- Signature:
make (<gsl-vector> #key size fill stride) => (vector)
- Parameters:
size (#key) – An instance of <integer>.
fill (#key) – An instance of <double-float>.
stride (#key) – An instance of <integer>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Allocate an array of size elements in a block of memory.
- Examples:
make(<gsl-vector>, size: 10, fill: 1.0d0);
- size(<gsl-vector>) Method¶
- Signature:
size (vector) => (size)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
size – An instance of <integer>.
- Discussion:
Return the size of the vector.
Copying vectors¶
- copy-gsl-vector Function¶
- Signature:
copy-gsl-vector (vector) => (copy)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
copy – An instance of <gsl-vector>.
- Discussion:
Return a copy of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let w = copy-gsl-vector(v);
Accessing elements¶
- element(<gsl-vector>) Method¶
- Signature:
element (vector index) => (element)
- Parameters:
vector – An instance of <gsl-vector>.
index – An instance of <integer>.
- Values:
element – An instance of <double-float>.
- Discussion:
Return the element at the given index.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); element(v, 0);
- element-setter(<gsl-vector>) Method¶
- Signature:
element-setter (value vector index) => (value)
- Parameters:
value – An instance of <double-float>.
vector – An instance of <gsl-vector>.
index – An instance of <integer>.
- Values:
value – An instance of <double-float>.
- Discussion:
Set the element at the given index to the given value.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); element-setter(v, 0, 2.0d0);
Initializing vector elements¶
- set-all! Function¶
- Signature:
set-all! (vector value) => (vector)
- Parameters:
vector – An instance of <gsl-vector>.
value – An instance of <double-float>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Set all elements of the vector to the given value.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); set-all!(v, 2.0d0);
- set-zero! Function¶
- Signature:
set-zero! (vector) => (vector)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Set all elements of the vector to zero.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); set-zero!(v);
- set-basis! Function¶
- Signature:
set-basis! (vector index) => (vector)
- Parameters:
vector – An instance of <gsl-vector>.
index – An instance of <integer>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Set all elements of the vector to zero except for the element at the given index.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); set-basis!(v, 0);
Exchanging elements¶
- swap! Function¶
- Signature:
swap! (vector index) => (vector)
- Parameters:
vector – An instance of <gsl-vector>.
index – An instance of <integer>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Swap the elements at the given index with the element at the given index.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); swap!(v, 0, 1);
- reverse(<gsl-vector>) Method¶
- Signature:
reverse (vector) => (reversed)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
reversed – An instance of <gsl-vector>.
- Discussion:
Return a reversed copy of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let reversed = reverse(v);
- reverse!(<gsl-vector>) Method¶
- Signature:
reverse! (vector) => (vector)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Reverse the vector in place.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); reverse!(v);
Vector operations¶
- sum Function¶
- Signature:
sum (vector) => (sum)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
sum – An instance of <double-float>.
- Discussion:
Return the sum of the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); sum(v);
- +(<gsl-vector>, <gsl-vector>) Method¶
- Signature:
+ (v w) => (sum)
- Parameters:
v – An instance of <gsl-vector>.
w – An instance of <gsl-vector>
- Values:
sum – An instance of <gsl-vector>.
- Discussion:
Return the sum of the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let w = make(<gsl-vector>, size: 10, fill: 2.0d0); let z = v + w;
- -(<gsl-vector>, <gsl-vector>) Method¶
- Signature:
- (v w) => (difference)
- Parameters:
v – An instance of <gsl-vector>.
w – An instance of <gsl-vector>
- Values:
difference – An instance of <gsl-vector>.
- Discussion:
Return the sum of the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let w = make(<gsl-vector>, size: 10, fill: 2.0d0); let z = v - w;
- *(<gsl-vector>, <gsl-vector>) Method¶
- Signature:
* (v w) => (product)
- Parameters:
v – An instance of <gsl-vector>.
w – An instance of <gsl-vector>
- Values:
product – An instance of <gsl-vector>.
- Discussion:
Return the sum of the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let w = make(<gsl-vector>, size: 10, fill: 2.0d0); let z = v * w;
- /(<gsl-vector>, <gsl-vector>) Method¶
- Signature:
/ (v w) => (division)
- Parameters:
v – An instance of <gsl-vector>.
w – An instance of <gsl-vector>.
- Values:
division – An instance of <gsl-vector>.
- Discussion:
Return the division of the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 10.0d0); let w = make(<gsl-vector>, size: 10, fill: 2.0d0); let q = v / w;
- *(<gsl-vector>, <double-float>) Method¶
- Signature:
* (vector value) => (scaled)
- Parameters:
vector – An instance of <gsl-vector>.
value – An instance of <double-float>.
- Values:
scaled – An instance of <gsl-vector>.
- Discussion:
Return the scaled version of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let scaled = v * 2.0d0;
- *(<double-float>, <gsl-vector>) Method¶
- Signature:
* (value vector) => (scaled)
- Parameters:
value – An instance of <double-float>.
vector – An instance of <gsl-vector>.
- Values:
scaled – An instance of <gsl-vector>.
- Discussion:
Return the scaled version of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let scaled = 2.0d0 * v;
- +(<gsl-vector>, <double-float>) Method¶
- Signature:
+ (vector addend) => (sum)
- Parameters:
vector – An instance of <gsl-vector>.
addend – An instance of <double-float>.
- Values:
sum – An instance of <gsl-vector>.
- Discussion:
Adds a constant value to the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let sum = v + 2.0d0;
- sum Function
- Signature:
sum (vector) => (sum)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
sum – An instance of <double-float>.
- Discussion:
Return the sum of the elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); sum(v);
- axpby Function¶
- Signature:
axpby (alpha x beta y) => (v)
- Parameters:
alpha – An instance of <double-float>.
x – An instance of <gsl-vector>.
beta – An instance of <double-float>.
y – An instance of <gsl-vector>.
- Values:
v – An instance of <gsl-vector>.
- Discussion:
Return the result of the operation alpha * x + beta * y.
- Examples:
let alpha = 1.0d0; let beta = 2.0d0; let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let w = make(<gsl-vector>, size: 10, fill: 2.0d0); let v = axpby(alpha, v, beta, w);
- axpby! Function¶
- Signature:
axpby! (alpha x beta y) => (v)
- Parameters:
alpha – An instance of <double-float>.
x – An instance of <gsl-vector>.
beta – An instance of <double-float>.
y – An instance of <gsl-vector>.
- Values:
v – An instance of <gsl-vector>.
- Discussion:
Return the result of the operation alpha * x + beta * y in place.
- Examples:
let alpha = 1.0d0; let beta = 2.0d0; let v = make(<gsl-vector>, size: 10, fill: 1.0d0); let w = make(<gsl-vector>, size: 10, fill: 2.0d0); axpby!(alpha, v, beta, w);
Finding maximum and minimum elements of vectors¶
- gsl-max Function¶
- Signature:
gsl-max (vector) => (max)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
max – An instance of <double-float>.
- Discussion:
Return the maximum element of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); gsl-max(v);
- gsl-min Function¶
- Signature:
gsl-min (vector) => (min)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
min – An instance of <double-float>.
- Discussion:
Return the minimum element of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); gsl-min(v);
- max-index Function¶
- Signature:
max-index (vector) => (max-index)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
max-index – An instance of <integer>.
- Discussion:
Return the index of the maximum element of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); max-index(v);
- min-index Function¶
- Signature:
min-index (vector) => (min-index)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
min-index – An instance of <integer>.
- Discussion:
Return the index of the minimum element of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); min-index(v);
- min-max Function¶
- Signature:
min-max (vector) => (min max)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
min – An instance of <double-float>.
max – An instance of <double-float>.
- Discussion:
Return the minimum and maximum elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); min-max(v);
- min-max-index Function¶
- Signature:
min-max-index (vector) => (min-index max-index)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
min-index – An instance of <integer>.
max-index – An instance of <integer>.
- Discussion:
Return the indices of the minimum and maximum elements of the vector.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); min-max-index(v);
Vector properties¶
- null? Function¶
- Signature:
null? (vector) => (null?)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
null? – An instance of <boolean>.
- Discussion:
Return true if the vector is null.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); null?(v);
- zero?(<gsl-vector>) Method¶
- Signature:
zero? (vector) => (zero?)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
zero? – An instance of <boolean>.
- Discussion:
Return true if the vector is zero.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); v.zero?;
- positive?(<gsl-vector>) Method¶
- Signature:
positive? (vector) => (positive?)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
positive? – An instance of <boolean>.
- Discussion:
Return true if the vector is positive.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); v.positive?;
- negative(<gsl-vector>) Method¶
- Signature:
negative (vector) => (vector)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
vector – An instance of <gsl-vector>.
- Discussion:
Return the negative of the vector.
- Examples:
let v = make(<gsl-vector>, size: 3, fill: 1.0d0); let r = v + (-v); r.zero? // #t
- negative?(<gsl-vector>) Method¶
- Signature:
negative? (vector) => (negative?)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
negative? – An instance of <boolean>.
- Discussion:
Return true if the vector is negative.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: -1.0d0); v.negative?;
- non-negative? Function¶
- Signature:
non-negative? (vector) => (non-negative?)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
non-negative? – An instance of <boolean>.
- Discussion:
Return true if the vector is non-negative.
- Examples:
let v = make(<gsl-vector>, size: 10, fill: 1.0d0); v.non-negative?;
- f=(<gsl-vector>) Method¶
- Signature:
f= (vector vector #key epsilon) => (boolean)
- Parameters:
vector – An instance of <gsl-vector>.
- Values:
boolean – An instance of <boolean>.
- Discussion:
Return true if the vectors are equal.
- Examples:
let a = make(<gsl-vector>, size: 10, fill: 1.0d0); let b = make(<gsl-vector>, size: 10, fill: 1.0d0); f=(a, b, epsilon: 0.00001d0);