Vectors: High Performance¶
CalcpadCE offers a parallel high-performance vector mode for workloads that outgrow the regular interpreter.
Wrap any vector with hp([...]) (or use the hp creational helpers) and the engine switches to a packed numerical layout with SIMD-friendly element-wise operations, dropping per-element interpretation overhead — the speed-up grows with vector length and is most pronounced on dense reductions and broadcasts.
The four worksheets in this group are direct counterparts of the regular Vectors group, rewritten in HP form: literal and creational construction, indexing and broadcast operators, sorting, ordering and the standard reductions, norms, products and statistical primitives, and resizing, slicing and joining.
The semantics match the plain mode one-to-one, so you can drop hp(...) around an existing pipeline and trade only the storage layout.
Vector Initialization, Indexing and Operators¶
HP foundations: literal vectors wrapped with \(hp(...)\), the corresponding creational helpers, indexing and the broadcast operators on packed storage.
'Direct:
a = hp([cos(0); 2; 3; 2*2; 6 - 1])
'Direct with another vector:
b = hp([0; a; 6; 7; 8])
'From a custom function:
a(x) = hp([1; x; x^2; x^3; x^4])
a(2)
a(3)
'By creational functions:
a = vector_hp(5)'- creates an empty vector with 5 elements
fill(a; 5)'- fills the vector with a value of 5
a = range_hp(0; 10; 2)'- creates a vector from a range of values, starting from 0 to 10 with step 2
"Indexing
'<hr/>
a = hp([2; 4; 6; 8; 10])
a.2'- simple dot operator (constant index)
k = 3', 'a.k'- variable index
a.(2*k - 1)'- expression index
a.5 = 0' - assign a new value to element:'a
a = vector_hp(6)','b = vector_hp(6)
'Initalize values in a block loop
#hide
#for k = 1 : len(a)
a.k = k^2
#loop
#show
a
'Inline loop
$Repeat{b.k = a.(k - 1) @ k = 2 : len(b)}
b
"Vector operators
'<h4>Vector-vector</h4>
a = hp([1; 2; 3; 0])', 'b = hp([0; 4; 5; 6; 7])
'Arithmetic:
a!'- factorial
a^b'- exponentiation
a/b'- floating point division
a\b'- integer division
a÷b'- division bar
a⦼b'- modulo(⦼, remainder)
a*b'- multiplication
a - b'- subtraction
a + b'- addition
'Relational (comparison):
a ≡ b'- equal to
a ≠ b'- unequal to
a < b'- less then
a > b'- greater than
a ≤ b'- less or equal
a ≥ b'- greater or equal
'Logical:
a ∧ b'- logical "and"
a ∨ b'- logical "or"
a ⊕ b'- logical "xor"
'<h4>Vector-scalar</h4>
a = hp([1; 2; 3; 0])', 'b = 2
'Arithmetic:
a^2'- exponentiation
a/2'- floating point division
a\2'- integer division
a÷2'- division bar
a⦼2'- modulo(⦼, remainder)
a*2'- multiplication
a - 2'- subtraction
a + 2'- addition
'Relational (comparison):
a ≡ 2'- equal to
a ≠ 2'- unequal to
a < 2'- less then
a > 2'- greater than
a ≤ 2'- less or equal
a ≥ 2'- greater or equal
'Logical:
a ∧ 2'- logical "and"
a ∨ 2'- logical "or"
a ⊕ 2'- logical "xor"
'<h4>Scalar-vector</h4>
a = 2', 'b = hp([0; 4; 5; 6; 7])
'Arithmetic:
2^b'- exponentiation
2/b'- floating point division
2\b'- integer division
2÷b'- division bar
2⦼b'- modulo(⦼, remainder)
2*b'- multiplication
2 - b'- subtraction
2 + b'- addition
'Relational (comparison):
2 ≡ b'- equal to
2 ≠ b'- unequal to
2 < b'- less then
2 > b'- greater than
2 ≤ b'- less or equal
2 ≥ b'- greater or equal
'Logical:
2 ∧ b'- logical "and"
2 ∨ b'- logical "or
2 ⊕ b'- logical "xor"
Direct:
⃗a = hp ( [cos ( 0 ) ; 2; 3; 2 · 2; 6 − 1] ) = [1 2 3 4 5]
Direct with another vector:
⃗b = hp ( [0; ⃗a; 6; 7; 8] ) = [0 1 2 3 4 5 6 7 8]
From a custom function:
a ( x ) = hp ( [1; x; x2; x3; x4] )
a ( 2 ) = [1 2 4 8 16]
a ( 3 ) = [1 3 9 27 81]
By creational functions:
⃗a = vectorhp ( 5 ) = [0 0 0 0 0] - creates an empty vector with 5 elements
fill ( ⃗a; 5 ) = [5 5 5 5 5] - fills the vector with a value of 5
⃗a = rangehp ( 0; 10; 2 ) = [0 2 4 6 8 10] - creates a vector from a range of values, starting from 0 to 10 with step 2
⃗a = hp ( [2; 4; 6; 8; 10] ) = [2 4 6 8 10]
⃗a2 = 4 - simple dot operator (constant index)
k = 3 , ⃗a3 = 6 - variable index
⃗a5 = 10 - expression index
⃗a5 = 0 - assign a new value to element: ⃗a = [2 4 6 8 0]
⃗a = vectorhp ( 6 ) = [0 0 0 0 0 0] , ⃗b = vectorhp ( 6 ) = [0 0 0 0 0 0]
Initalize values in a block loop
⃗a = [1 4 9 16 25 36]
Inline loop
$Repeat{⃗bk = ⃗ak − 1 for k = 2...len ( ⃗b ) } = 25
⃗b = [0 1 4 9 16 25]
⃗a = hp ( [1; 2; 3; 0] ) = [1 2 3 0] , ⃗b = hp ( [0; 4; 5; 6; 7] ) = [0 4 5 6 7]
Arithmetic:
⃗a! = [1 2 6 1] - factorial
⃗a⊙ ⃗b = [1 16 243 0 0] - exponentiation
⃗a⃗b = [+∞ 0.5 0.6 0 0] - floating point division
⃗a\⃗b = [ Undefined 0 0 0 0] - integer division
⃗a / ⃗b = [+∞ 0.5 0.6 0 0] - division bar
⃗a mod ⃗b = [ Undefined 2 3 0 0] - modulo(⦼, remainder)
⃗a⊙⃗b = [0 8 15 0 0] - multiplication
⃗a − ⃗b = [1 -2 -2 -6 -7] - subtraction
⃗a + ⃗b = [1 6 8 6 7] - addition
Relational (comparison):
⃗a ≡ ⃗b = [0 0 0 0 0] - equal to
⃗a ≠ ⃗b = [1 1 1 1 1] - unequal to
⃗a < ⃗b = [0 1 1 1 1] - less then
⃗a > ⃗b = [1 0 0 0 0] - greater than
⃗a ≤ ⃗b = [0 1 1 1 1] - less or equal
⃗a ≥ ⃗b = [1 0 0 0 0] - greater or equal
Logical:
⃗a and ⃗b = [0 1 1 0 0] - logical "and"
⃗a or ⃗b = [1 1 1 1 1] - logical "or"
⃗a xor ⃗b = [1 0 0 1 1] - logical "xor"
⃗a = hp ( [1; 2; 3; 0] ) = [1 2 3 0] , b = 2
Arithmetic:
⃗a⊙ 2 = [1 4 9 0] - exponentiation
⃗a2 = [0.5 1 1.5 0] - floating point division
⃗a\2 = [0 1 1 0] - integer division
⃗a / 2 = [0.5 1 1.5 0] - division bar
⃗a mod 2 = [1 0 1 0] - modulo(⦼, remainder)
⃗a · 2 = [2 4 6 0] - multiplication
⃗a − 2 = [-1 0 1 -2] - subtraction
⃗a + 2 = [3 4 5 2] - addition
Relational (comparison):
⃗a ≡ 2 = [0 1 0 0] - equal to
⃗a ≠ 2 = [1 0 1 1] - unequal to
⃗a < 2 = [1 0 0 1] - less then
⃗a > 2 = [0 0 1 0] - greater than
⃗a ≤ 2 = [1 1 0 1] - less or equal
⃗a ≥ 2 = [0 1 1 0] - greater or equal
Logical:
⃗a and 2 = [1 1 1 0] - logical "and"
⃗a or 2 = [1 1 1 1] - logical "or"
⃗a xor 2 = [0 0 0 1] - logical "xor"
a = 2 , ⃗b = hp ( [0; 4; 5; 6; 7] ) = [0 4 5 6 7]
Arithmetic:
2⃗b = [1 16 32 64 128] - exponentiation
2⃗b = [+∞ 0.5 0.4 0.333 0.286] - floating point division
2\⃗b = [ Undefined 0 0 0 0] - integer division
2 / ⃗b = [+∞ 0.5 0.4 0.333 0.286] - division bar
2 mod ⃗b = [ Undefined 2 2 2 2] - modulo(⦼, remainder)
2 · ⃗b = [0 8 10 12 14] - multiplication
2 − ⃗b = [2 -2 -3 -4 -5] - subtraction
2 + ⃗b = [2 6 7 8 9] - addition
Relational (comparison):
2 ≡ ⃗b = [0 0 0 0 0] - equal to
2 ≠ ⃗b = [1 1 1 1 1] - unequal to
2 < ⃗b = [0 1 1 1 1] - less then
2 > ⃗b = [1 0 0 0 0] - greater than
2 ≤ ⃗b = [0 1 1 1 1] - less or equal
2 ≥ ⃗b = [1 0 0 0 0] - greater or equal
Logical:
2 and ⃗b = [0 1 1 1 1] - logical "and"
2 or ⃗b = [1 1 1 1 1] - logical "or
2 xor ⃗b = [1 0 0 0 0] - logical "xor"
Vector Data Functions¶
HP variant of the data-oriented toolkit: \(sort\), \(rsort\), \(order\), \(find\), \(count\) and the standard reductions, all running on packed numerical storage.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>Sort</b>(<em>vector</em>) and <b>Rsort</b>(<em>vector</em>)</p><hr/>
a = hp([4; 0; 2; 3; -1; 1])
b = sort(a)'- vector sorted in ascending order
c = rsort(a)'- vector sorted in descending order
a' - remained unchanged
'<p><b>Order</b>(<em>vector</em>) and <b>Revorder</b>(<em>vector</em>)</p><hr/>
x_a = hp([4; 0; 2; 3; -1; 1])'
y_a = hp([1; 2; 3; 4; 5; 6])
i_asc = order(x_a)'- indexes in ascending order of <em>x</em>-values
i_desc = revorder(x_a)'- indexes in descending order of <em>x</em>-values
'Sorts points by ascending order of <em>x</em>-values
x_b = extract(x_a; i_asc)
y_b = extract(y_a; i_asc)
'<p><b>Reverse</b>(<em>vector</em>)</p><hr/>
reverse(hp([1; 2; 3; 4; 5]))'- the elements of the vector in reverse order
'<p><b>Count</b>(<em>vector</em>; <em>value</em>; <em>starting index</em>)</p><hr/>
count(hp([0; 1; 2; 1; 4; 1]); 1; 4)'- the number of elements equal to 1 and index ≥ 4
'<p><b>Search</b>(<em>vector</em>; <em>value</em>; <em>starting index</em>)</p><hr/>
a = hp([0; 1; 2; 1; 4; 1])
search(a; 1; 3)'- the index of the first element in <em>a</em> with value 1 and index ≥ 3
search(a; 1; 7)'- when the index is out of range or nothing is found, returns 0
'<p><b>Find</b>(<em>vector</em>; <em>value</em>; <em>starting index</em>)</p><hr/>
a = hp([0; 1; 2; 1; 4; 1])
find(a; 1; 2)'- the indexes of all elements with value 1, from the 2nd onwards
find(a; 3; 2)'- if the indexes are out of range or nothing is found, returns 0
find_lt(a; 3; 2)'- the indexes of all elements, from the 2nd onwards, that are < 3
find_ge(a; 3; 2)'- the indexes of all elements, from the 2nd onwards, that are ≥ 3
'<p><b>Lookup</b>(<em>vector_a</em>; <em>vector_b</em>; <em>value</em>)</p><hr/>
a = hp([0; 1; 0; 0; 1; 2])
b = hp([1; 2; 3; 4; 5; 6])
lookup(a; b; 0)'- the values from vector <em>b</em> for which the corresponding values in vector <em>a</em> are equal to 0
lookup(a; b; 2)'- the values from vector <em>b</em> for which the corresponding values in vector <em>a</em> are equal to 2
lookup_ge(a; b; 1)'- the values from vector <em>b</em> for which the corresponding values in vector <em>a</em> are ≥ 1
lookup_ne(a; b; 1)'- the values from vector <em>b</em> for which the corresponding values in vector <em>a</em> are ≠ 1
Sort(vector) and Rsort(vector)
⃗a = hp ( [4; 0; 2; 3; -1; 1] ) = [4 0 2 3 -1 1]
⃗b = sort ( ⃗a ) = [-1 0 1 2 3 4] - vector sorted in ascending order
⃗c = rsort ( ⃗a ) = [4 3 2 1 0 -1] - vector sorted in descending order
⃗a = [4 0 2 3 -1 1] - remained unchanged
Order(vector) and Revorder(vector)
⃗xa = hp ( [4; 0; 2; 3; -1; 1] ) = [4 0 2 3 -1 1]
⃗ya = hp ( [1; 2; 3; 4; 5; 6] ) = [1 2 3 4 5 6]
⃗iasc = order ( ⃗xa ) = [5 2 6 3 4 1] - indexes in ascending order of x-values
⃗idesc = revorder ( ⃗xa ) = [1 4 3 6 2 5] - indexes in descending order of x-values
Sorts points by ascending order of x-values
⃗xb = extract ( ⃗xa; ⃗iasc ) = [-1 0 1 2 3 4]
⃗yb = extract ( ⃗ya; ⃗iasc ) = [5 2 6 3 4 1]
Reverse(vector)
reverse ( hp ( [1; 2; 3; 4; 5] ) ) = [5 4 3 2 1] - the elements of the vector in reverse order
Count(vector; value; starting index)
count ( hp ( [0; 1; 2; 1; 4; 1] ) ; 1; 4 ) = 2 - the number of elements equal to 1 and index ≥ 4
Search(vector; value; starting index)
⃗a = hp ( [0; 1; 2; 1; 4; 1] ) = [0 1 2 1 4 1]
search ( ⃗a; 1; 3 ) = 4 - the index of the first element in a with value 1 and index ≥ 3
search ( ⃗a; 1; 7 ) = 0 - when the index is out of range or nothing is found, returns 0
Find(vector; value; starting index)
⃗a = hp ( [0; 1; 2; 1; 4; 1] ) = [0 1 2 1 4 1]
find ( ⃗a; 1; 2 ) = [2 4 6] - the indexes of all elements with value 1, from the 2nd onwards
find ( ⃗a; 3; 2 ) = [] - if the indexes are out of range or nothing is found, returns 0
findlt ( ⃗a; 3; 2 ) = [2 3 4 6] - the indexes of all elements, from the 2nd onwards, that are < 3
findge ( ⃗a; 3; 2 ) = [5] - the indexes of all elements, from the 2nd onwards, that are ≥ 3
Lookup(vector_a; vector_b; value)
⃗a = hp ( [0; 1; 0; 0; 1; 2] ) = [0 1 0 0 1 2]
⃗b = hp ( [1; 2; 3; 4; 5; 6] ) = [1 2 3 4 5 6]
lookup ( ⃗a; ⃗b; 0 ) = [1 3 4] - the values from vector b for which the corresponding values in vector a are equal to 0
lookup ( ⃗a; ⃗b; 2 ) = [6] - the values from vector b for which the corresponding values in vector a are equal to 2
lookupge ( ⃗a; ⃗b; 1 ) = [2 5 6] - the values from vector b for which the corresponding values in vector a are ≥ 1
lookupne ( ⃗a; ⃗b; 1 ) = [1 3 4 6] - the values from vector b for which the corresponding values in vector a are ≠ 1
Vector Math Functions¶
HP variant of the vector math toolkit: \(L_p\) norms, dot and cross products, element-wise transcendentals and statistical primitives, evaluated on packed storage.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>Norm_p</b>(<em>vector</em>)</p><hr/>
norm_p(hp([1; 2; 3]); 3)'- the Lp norm of the vector for 'p = 3
'<p><b>Norm_1</b>(<em>vector</em>)</p><hr/>
norm_1(hp([-1; 2; 3]))'- the L1 (Manhattan or taxicab) norm of the vector
'<p><b>Norm</b>(<em>vector</em>) or <b>Norm_2</b>(<em>vector</em>) or <b>Norm_e</b>(<em>vector</em>)</p></p><hr/>
a = hp([1; 2; 3])
norm(a)
norm_2(a)
norm_e(a)'- the L2 (Euclidian) norm of vector <em>a</em>
'<p><b>Norm_i</b>(<em>vector</em>)</p><hr/>
norm_i(hp([1; 2; 3]))'- the L∞ (infinity) norm of the vector
'<p><b>Unit</b>(<em>vector</em>)</p><hr/>
unit(hp([-1; 2; 3]))'- the normalized (unit) vector
'<p><b>Dot</b>(<em>vector</em>; <em>vector</em>)</p><hr/>
a = hp([1; 2; 4])
b = hp([5; 3; 1])
dot(a; b)'- scalar (dot) product of vectors <em>a</em> and <em>b</em>;
'<p><b>Cross</b>(<em>vector</em>; <em>vector</em>)</p><hr/>
a = hp([1; 2; 4])
b = hp([5; 3; 1])
cross(a; b)'- cross product of vectors <em>a</em> and <em>b</em>;
#rad
'Trigonometric:<hr/>
x = hp([0; 30; 45; 60; 90])*(π/180)
sin(x)'- sine
cos(x)'- cosine
tan(x)'- tangent
csc(x)'- cosecant
sec(x)'- secant
cot(x)'- cotangent
'Hyperbolic:<hr/>
x = hp([0; 0.5; 1])
sinh(x)'- hyperbolic sine
cosh(x)'- hyperbolic cosine
tanh(x)'- hyperbolic tangent
csch(x)'- hyperbolic cosecant
sech(x)'- hyperbolic secant
coth(x)'- hyperbolic cotangent
'Inverse trigonometric:<hr/>
x = hp([0; 0.5; sqrt(2)/2; sqrt(3)/2; 1])
y = reverse(x)
asin(x)'- inverse sine
acos(x)'- inverse cosine
atan(x)'- inverse tangent
atan2(x; y)'- the angle whose tangent is the quotient of y and x
acsc(1/x)'- inverse cosecant
asec(1/x)'- inverse secant
acot(x)'- inverse cotangent
'Inverse hyperbolic:<hr/>
x = hp([1; 2; 4])
asinh(x)'- inverse hyperbolic sine
acosh(x)'- inverse hyperbolic cosine
atanh(x/5)'- inverse hyperbolic tangent
acsch(1/x)'- inverse hyperbolic cosecant
asech(1/x)'- inverse hyperbolic secant
acoth(5/x)'- inverse hyperbolic cotangent
'Logarithmic, exponential and roots:<hr/>
log(x)'- decimal logarithm
ln(x)'- natural logarithm
log_2(x)'- binary logarithm
exp(x)'- natural exponent = eˣ
sqr(x)'- square root
cbrt(x)'- cubic root
root(x; 3)'- n-th root
'Rounding:<hr/>
round(x)'- round to the nearest integer
floor(x)'- round to the smaller integer(towards - ∞)
ceiling(x)'- round to the greater integer(towards + ∞)
trunc(x)'- round to the smaller integer(towards zero)
'Integer:<hr/>
x
y = x + 2
mod(x; y)'- the remainder of an integer division
gcd(y)'- the greatest common divisor of several integers
lcm(y)'- the least common multiple of several integers
'Aggregate and interpolation:<hr />
a = hp([0; 2; 6])
b = hp([5; 3; 1])
min(4; a; 7; b; 10; 11)'- minimum of multiple values
max(4; a; 7; b; 10; 11)'- maximum of multiple values
sum(4; a; 7; b; 10; 11)'- sum of multiple values
sumsq(4; a; 7; b; 10; 11)'- sum of squares
srss(4; a; 7; b; 10; 11)'- square root of sum of squares
average(4; a; 7; b; 10; 11)'- average of multiple values
product(4; a; 7; b; 10; 11)'- product of multiple values
mean(4; a; 7; b; 10; 11)'- geometric mean
take(3; a)'- the 3-rd element from the list
line(1.5; a)'- linear interpolation
spline(1.5; a)'- Hermite spline interpolation
Norm_p(vector)
normp ( hp ( [1; 2; 3] ) ; 3 ) = 3.3 - the Lp norm of the vector for p = 3
Norm_1(vector)
norm1 ( hp ( [-1; 2; 3] ) ) = 6 - the L1 (Manhattan or taxicab) norm of the vector
Norm(vector) or Norm_2(vector) or Norm_e(vector)
⃗a = hp ( [1; 2; 3] ) = [1 2 3]
norm ( ⃗a ) = 3.74
norm2 ( ⃗a ) = 3.74
norme ( ⃗a ) = 3.74 - the L2 (Euclidian) norm of vector a
Norm_i(vector)
normi ( hp ( [1; 2; 3] ) ) = 3 - the L∞ (infinity) norm of the vector
Unit(vector)
unit ( hp ( [-1; 2; 3] ) ) = [-0.267 0.535 0.802] - the normalized (unit) vector
Dot(vector; vector)
⃗a = hp ( [1; 2; 4] ) = [1 2 4]
⃗b = hp ( [5; 3; 1] ) = [5 3 1]
dot ( ⃗a; ⃗b ) = 15 - scalar (dot) product of vectors a and b;
Cross(vector; vector)
⃗a = hp ( [1; 2; 4] ) = [1 2 4]
⃗b = hp ( [5; 3; 1] ) = [5 3 1]
cross ( ⃗a; ⃗b ) = [-10 19 -7] - cross product of vectors a and b;
Trigonometric:
⃗x = hp ( [0; 30; 45; 60; 90] ) · π180 = hp ( [0; 30; 45; 60; 90] ) · 3.14180 = [0 0.524 0.785 1.05 1.57]
sin ( ⃗x ) = [0 0.5 0.707 0.866 1] - sine
cos ( ⃗x ) = [1 0.866 0.707 0.5 0] - cosine
tan ( ⃗x ) = [0 0.577 1 1.73 1.63×1016] - tangent
csc ( ⃗x ) = [+∞ 2 1.41 1.15 1] - cosecant
sec ( ⃗x ) = [1 1.15 1.41 2 1.63×1016] - secant
cot ( ⃗x ) = [+∞ 1.73 1 0.577 0] - cotangent
Hyperbolic:
⃗x = hp ( [0; 0.5; 1] ) = [0 0.5 1]
sinh ( ⃗x ) = [0 0.521 1.18] - hyperbolic sine
cosh ( ⃗x ) = [1 1.13 1.54] - hyperbolic cosine
tanh ( ⃗x ) = [0 0.462 0.762] - hyperbolic tangent
csch ( ⃗x ) = [+∞ 1.92 0.851] - hyperbolic cosecant
sech ( ⃗x ) = [1 0.887 0.648] - hyperbolic secant
coth ( ⃗x ) = [+∞ 2.16 1.31] - hyperbolic cotangent
Inverse trigonometric:
⃗x = hp([0; 0.5;   √ 22;   √ 32; 1]) = [0 0.5 0.707 0.866 1]
⃗y = reverse ( ⃗x ) = [1 0.866 0.707 0.5 0]
asin ( ⃗x ) = [0 0.524 0.785 1.05 1.57] - inverse sine
acos ( ⃗x ) = [1.57 1.05 0.785 0.524 0] - inverse cosine
atan ( ⃗x ) = [0 0.464 0.615 0.714 0.785] - inverse tangent
atan2 ( ⃗x; ⃗y ) = [1.57 1.05 0.785 0.524 0] - the angle whose tangent is the quotient of y and x
acsc(1⃗x) = [0 0.524 0.785 1.05 1.57] - inverse cosecant
asec(1⃗x) = [1.57 1.05 0.785 0.524 0] - inverse secant
acot ( ⃗x ) = [1.57 1.11 0.955 0.857 0.785] - inverse cotangent
Inverse hyperbolic:
⃗x = hp ( [1; 2; 4] ) = [1 2 4]
asinh ( ⃗x ) = [0.881 1.44 2.09] - inverse hyperbolic sine
acosh ( ⃗x ) = [0 1.32 2.06] - inverse hyperbolic cosine
atanh(⃗x5) = [0.203 0.424 1.1] - inverse hyperbolic tangent
acsch(1⃗x) = [0.881 1.44 2.09] - inverse hyperbolic cosecant
asech(1⃗x) = [0 1.32 2.06] - inverse hyperbolic secant
acoth(5⃗x) = [0.203 0.424 1.1] - inverse hyperbolic cotangent
Logarithmic, exponential and roots:
log ( ⃗x ) = [0 0.301 0.602] - decimal logarithm
ln ( ⃗x ) = [0 0.693 1.39] - natural logarithm
log2 ( ⃗x ) = [0 1 2] - binary logarithm
exp ( ⃗x ) = [2.72 7.39 54.6] - natural exponent = eˣ
  √ ⃗x = [1 1.41 2] - square root
 3  √ ⃗x = [1 1.26 1.59] - cubic root
 3  √ ⃗x = [1 1.26 1.59] - n-th root
Rounding:
round ( ⃗x ) = [1 2 4] - round to the nearest integer
floor ( ⃗x ) = [1 2 4] - round to the smaller integer(towards - ∞)
ceiling ( ⃗x ) = [1 2 4] - round to the greater integer(towards + ∞)
trunc ( ⃗x ) = [1 2 4] - round to the smaller integer(towards zero)
Integer:
⃗x = [1 2 4]
⃗y = ⃗x + 2 = [3 4 6]
mod ( ⃗x; ⃗y ) = [1 2 4] - the remainder of an integer division
gcd ( ⃗y ) = 1 - the greatest common divisor of several integers
lcm ( ⃗y ) = 12 - the least common multiple of several integers
Aggregate and interpolation:
⃗a = hp ( [0; 2; 6] ) = [0 2 6]
⃗b = hp ( [5; 3; 1] ) = [5 3 1]
min ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 0 - minimum of multiple values
max ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 11 - maximum of multiple values
sum ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 49 - sum of multiple values
sumsq ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 361 - sum of squares
srss ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 19 - square root of sum of squares
average ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 4.9 - average of multiple values
product ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 0 - product of multiple values
mean ( 4; ⃗a; 7; ⃗b; 10; 11 ) = 0 - geometric mean
take ( 3; ⃗a ) = 6 - the 3-rd element from the list
line ( 1.5; ⃗a ) = 1 - linear interpolation
spline ( 1.5; ⃗a ) = 0.812 - Hermite spline interpolation
Vector Structural Functions¶
HP variant of the structural toolkit: \(len\), \(size\), \(resize\), \(slice\), \(join\) and \(reverse\), operating in-place on packed storage where possible.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>Len</b>(<em>vector</em>) and <b>Size</b>(<em>vector</em>)</p><hr/>
'Explicitly initialized short vectors:
len(hp([1; 2; 3; 0; 0]))'- vector length
size(hp([1; 2; 3; 0; 0]))'- the actual size in memory
'Size is equal to length even if last elements are zero
'Implicitly initialized large vectors:
a = vector_hp(200)
a.35 = 1
len(a)'- the lenght is equal to the count of all elements
size(a)'- the size is equal to the index of the last element intitalized with a non-zero value
'<p><b>Resize</b>(<em>vector</em>; <em>new length</em>)</p><hr/>
a = hp([1; 2; 3; 4; 5])
b = resize(a; 3)' - set a new size and return a reference to <var>a</var>
a'- the original vector was modified
b.1 = 0'- changing a value in the referece...
a'- also changes the original vector.
'<p><b>Join</b>(<em>mixed list of arguments</em>)</p><hr/>
A = hp([1; 2|3; 4])
b = hp([7; 8; 9])
c = hp(join(0; A; 5; 6; b))'- by function...'isHp(c)
c = hp([0; A; 5; 6; b])'- or by square brackets initializer.
isHp(c)
'<p><b>Slice</b>(<em>vector</em>; <em>start index</em>; <em>end index</em>)</p><hr/>
a = hp([1; 2; 3; 4; 5; 6; 7; 8])
slice(a; 3; 7)'- segment between the 3-rd and 7-th elements of vector <em>a</em>, incl.
slice(a; 6; 10)'- if the index is > of the vector length, returns the elements up to the end
'<p><b>First</b>(<em>vector</em>; <em>count</em>)</p><hr/>
a = hp([0; 1; 2; 3; 4; 5; 6])
first(a; 3)'- the first 3 elements of the vector <em>a</em>
first(a; 10)'- if the number of elements is > the vector length, returns all elements
'<p><b>Last</b>(<em>vector</em>; <em>count</em>)</p><hr/>
a = hp([0; 1; 2; 3; 4; 5; 6])
last(a; 3)'- the last 3 elements of the vector <em>a</em>
last(a; 10)'- if the number of elements is > the length of the vector, returns all elements
'<p><b>Extract</b>(<em>vector</em>; <em>indexes</em>)</p><hr/>
a = hp([0; 1; 2; 3; 4; 5; 6])
b = extract(a; [2; 4; 6])'- the elements of <em>a</em>, with indexes 3, 4, and 6
isHp(b)
Len(vector) and Size(vector)
Explicitly initialized short vectors:
len ( hp ( [1; 2; 3; 0; 0] ) ) = 5 - vector length
size ( hp ( [1; 2; 3; 0; 0] ) ) = 5 - the actual size in memory
Size is equal to length even if last elements are zero
Implicitly initialized large vectors:
⃗a = vectorhp ( 200 ) = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0]
⃗a35 = 1
len ( ⃗a ) = 200 - the lenght is equal to the count of all elements
size ( ⃗a ) = 35 - the size is equal to the index of the last element intitalized with a non-zero value
Resize(vector; new length)
⃗a = hp ( [1; 2; 3; 4; 5] ) = [1 2 3 4 5]
⃗b = resize ( ⃗a; 3 ) = [1 2 3] - set a new size and return a reference to a
⃗a = [1 2 3] - the original vector was modified
⃗b1 = 0 - changing a value in the referece...
⃗a = [0 2 3] - also changes the original vector.
Join(mixed list of arguments)
A = hp ( [1; 2 | 3; 4] ) = 12 34
⃗b = hp ( [7; 8; 9] ) = [7 8 9]
⃗c = hp ( join ( 0; A; 5; 6; ⃗b ) ) = [0 1 2 3 4 5 6 7 8 9] - by function... isHp ( ⃗c ) = 1
⃗c = hp ( [0; A; 5; 6; ⃗b] ) = [0 1 2 3 4 5 6 7 8 9] - or by square brackets initializer.
isHp ( ⃗c ) = 1
Slice(vector; start index; end index)
⃗a = hp ( [1; 2; 3; 4; 5; 6; 7; 8] ) = [1 2 3 4 5 6 7 8]
slice ( ⃗a; 3; 7 ) = [3 4 5 6 7] - segment between the 3-rd and 7-th elements of vector a, incl.
slice ( ⃗a; 6; 10 ) = [6 7 8] - if the index is > of the vector length, returns the elements up to the end
First(vector; count)
⃗a = hp ( [0; 1; 2; 3; 4; 5; 6] ) = [0 1 2 3 4 5 6]
first ( ⃗a; 3 ) = [0 1 2] - the first 3 elements of the vector a
first ( ⃗a; 10 ) = [0 1 2 3 4 5 6] - if the number of elements is > the vector length, returns all elements
Last(vector; count)
⃗a = hp ( [0; 1; 2; 3; 4; 5; 6] ) = [0 1 2 3 4 5 6]
last ( ⃗a; 3 ) = [4 5 6] - the last 3 elements of the vector a
last ( ⃗a; 10 ) = [0 1 2 3 4 5 6] - if the number of elements is > the length of the vector, returns all elements
Extract(vector; indexes)
⃗a = hp ( [0; 1; 2; 3; 4; 5; 6] ) = [0 1 2 3 4 5 6]
⃗b = extract ( ⃗a; [2; 4; 6] ) = [1 3 5] - the elements of a, with indexes 3, 4, and 6
isHp ( ⃗b ) = 1
Spotted an error? Edit these examples.