Vectors Library
mikroPascal PRO for dsPIC30/33 and PIC24 includes a library for working and using vectors. All routines work with fractional Q15 format.
Library Routines
- Vector_Set
- Vector_Power
- Vector_Subtract
- Vector_Scale
- Vector_Negate
- Vector_Multiply
- Vector_Min
- Vector_Max
- Vector_Dot
- Vector_Correlate
- Vector_Convolve
- Vector_Add
Vector_Set
Prototype |
procedure Vector_Set(var input: array[1024] of word; size, value: word); |
---|---|
Description |
Sets |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec2 : array[3] of word; Vector_Set(vec2, 3, 0x4000); |
Notes |
|
Vector_Power
Prototype |
function Vector_Power(N: word; var Vector: array[1024] of word): word; |
---|---|
Description |
Function returns result of power value (powVal) in radix point 1.15 |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; Vector_Power(3, vec1); |
Notes |
|
Vector_Subtract
Prototype |
procedure Vector_Subtract(var dest, v1, v2: array[1024] of word; numElems: word); |
---|---|
Description |
This function does subtraction of two vectors. dstV[n] = v1[n] - v2[n], n Î [0, numElems-1] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vec2 : array[3] of word; vecDest : array[3] of word; Vector_Subtract(vecDest, vec1, vec2, 3); |
Notes |
|
Vector_Scale
Prototype |
|
---|---|
Description |
This function does vector scaling with scale value. dstV[n] = sclVal * srcV[n], n Î [0, numElems-1] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vecDest : array[3] of word; Vector_Scale(3, 2, vec1, vecDest); |
Notes |
|
Vector_Negate
Prototype |
procedure Vector_Negate(var srcVector, DestVector: array[1024] of word; numElems: word); |
---|---|
Description |
This function does negation of vector. dstV[n] = (-1)*srcV1[n] + 0, n Î [0, numElems) |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vecDest : array[3] of word; Vector_Negate(vec1, vecDest, 3); |
Notes |
|
Vector_Multiply
Prototype |
procedure Vector_Multiply(var v1, v2, dest: array[1024] of word; numElems: word); |
---|---|
Description |
This function does multiplication of two vectors. dstV[n] = srcV1[n] * srcV2[n], n Î [0, numElems-1] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vec2 : array[3] of word; vConDest : array [10] of word; Vector_Multiply(vec1, vConDest, vec2, 3); |
Notes |
|
Vector_Min
Prototype |
function Vector_Min(var Vector: array[1024] of word; numElems: word; var MinIndex: word): word; |
---|---|
Description |
This function finds minimal value in vector. minVal = min (srcV[n]), n Î [0, numElems-1] |
Parameters |
|
Returns |
Minimum value ( |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; index, rslt : word; rslt = Vector_Min(vec1, 3, index); |
Notes | [W0..W5] used, not restored |
Vector_Max
Prototype |
function Vector_Max(var Vector: array[1024] of word; numElems: word; var MaxIndex: word): word; |
---|---|
Description |
This function find maximal value in vector. maxVal = max (srcV[n]), n Î [0, numElems-1] |
Parameters |
|
Returns |
Maximum value ( |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; index, rslt : word; rslt = Vector_Max(vec1, 3, index); |
Notes | [W0..W5] used, not restored |
Vector_Dot
Prototype |
function Vector_Dot(var v1, v2: array[1024] of word; numElems: word): word; |
---|---|
Description |
Function calculates vector dot product. |
Parameters |
|
Returns |
Dot product value :
|
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; rslt = Vector_Dot(vec1,vec1,3); |
Notes |
|
Vector_Correlate
Prototype |
procedure Vector_Correlate(var v1, v2, dest: array[1024] of word; numElemsV1, numElemsV2: word); |
---|---|
Description |
Function calculates Vector correlation (using convolution).
|
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vConDest : array [10] of word; Vector_Correlate(vec1,vec1,vConDest,3,3); |
Notes | [W0..W7] used, not restored |
Vector_Convolve
Prototype |
procedure Vector_Convolve(var v1, v2, dest: array[1024] of word; numElemsV1, numElemsV2: word); |
---|---|
Description |
Function calculates Vector using convolution.
|
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vConDest2 : array[10] of word; Vector_Convolve(vec1,vec1,vConDest2,3,3); |
Notes |
|
Vector_Add
Prototype |
procedure Vector_Add(var dest, v1, v2: array[256] of word; numElems: word); |
---|---|
Description |
Function calculates vector addition. dstV[n] = srcV1[n] + srcV2[n], n Î [0, numElems-1] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
var vec1 : array[3] of word; vec2 : array[3] of word; vecDest : array[3] of word; Vector_Add(vecDest, vec1, vec2, 3); |
Notes |
|
What do you think about this topic ? Send us feedback!