(no commit message)
[libreriscv.git] / vector_ops.mdwn
1 # Vector Operations Extension to SV
2
3 This extension is usually dependent on SV SUBVL being implemented. When SUBVL is set to define the length of a subvector the operations in this extension interpret the elements as a single vector.
4
5 Normally in SV all operations are scalar and independent, and the operations on them may inherently be independently parallelised, with the result being a vector of length exactly equal to the input vectors.
6
7 In this extension, the subvector itself is typically the unit, although some operations will work on scalars or standard vectors as well, or the result is a scalar that is dependent on all elements within the vector arguments.
8
9 Examples which can require SUBVL include cross product and may in future involve complex numbers.
10
11 ## Vector cross product
12
13 Result is the cross product of x and y, i.e., the resulting components are, in order:
14
15 x[1] * y[2] - y[1] * x[2]
16 x[2] * y[0] - y[2] * x[0]
17 x[0] * y[1] - y[0] * x[1]
18
19 All the operands must be vectors of 3 components of a floating-point type.
20
21 ## Vector dot product
22
23 Computes the dot product of two vectors. Internal accuracy must be greater than the
24 input vectors and the result.
25
26 ## Vector length
27
28 The scalar length of a vector:
29
30 sqrt(x[0]^2 + x[1]^2 + ...).
31
32 ## Vector distance
33
34 The scalar distance between two vectors. Subtracts one vector from the other and returns length
35
36 ## Vector LERP
37
38 Known as **fmix** in GLSL.
39
40 <https://en.m.wikipedia.org/wiki/Linear_interpolation>
41
42 ## Vector SLERP
43
44 <https://en.m.wikipedia.org/wiki/Slerp>