Vector(API)
From EosPedia
General/Vector is API for expression of vector.
struct
Vector: float, int, double
typedef struct floatVector { unsigned long size; float* data; } floatVector; typedef struct intVector { unsigned long size; int* data; } intVector; typedef struct doubleVector { unsigned long size; double* data; } doubleVector;
size: Size of Vector(Dimension)
data: Real data
API
Initilization
extern floatVector* floatVectorInit(floatVector* v, long size); extern intVector* intVectorInit(intVector* v, long size); extern doubleVector* doubleVectorInit(doubleVector* v, long size);
Free
extern floatVector* floatVectorFree(floatVector* v); extern intVector* intVectorFree(intVector* v); extern doubleVector* doubleVectorFree(doubleVector* v);
Addition
extern floatVector* floatVectorAdd(floatVector* v, floatVector* u, floatVector* w); extern doubleVector* doubleVectorAdd(doubleVector* v, doubleVector* u, doubleVector* w);
Subtraction
extern floatVector* floatVectorMinus(floatVector* v, floatVector* u, floatVector* w); extern doubleVector* doubleVectorMinus(doubleVector* v, doubleVector* u, doubleVector* w);
Inner product
extern double floatVectorScalarProduct(floatVector* x, floatVector* y); extern double doubleVectorScalarProduct(doubleVector* x, doubleVector* y);
Length
extern double lfloatVectorLength(floatVector* x); extern double ldoubleVectorLength(doubleVector* x);
Spline
1D Spline
Create differential value list
extern void lVectorSplineTableMake(floatVector* x, floatVector* y, floatVector* z); extern void ldoubleVectorSplineTableMake(doubleVector* x, doubleVector* y, doubleVector* z);
Input | Description |
---|---|
x[i] | Summation of distance from first through No. i |
y[i] | Data of No. i |
Output | Description |
---|---|
z[i] | Differential value about No. i |
Calculate coordinates of Spline
extern double lVectorSpline(double t, floatVector* x, floatVector* y, floatVector* z); extern double ldoubleVectorSpline(double t, doubleVector* x, doubleVector* y, doubleVector* z);
Input | Description |
---|---|
t | Distance of current position |
p | Distance list |
x | Differential value list |
y | Coordinates list |
Output | Description |
---|---|
z | Coordinates list after correction |
2D Spline
Create differential value list
extern void lVectorSplineTable2DMake(floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b); extern void ldoubleVectorSplineTable2DMake(doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
Input | Description |
---|---|
x | x coordinates list |
y | y coordinates list |
Output | Description |
---|---|
p[i] | Summation of distance from first through No. i |
a[i] | Differential value at No. i of x coordinates |
b[i] | Differential value at No. i of y coordinates |
Calculate coordinates of Spline
extern void lVectorSpline2D(double t, double* px, double* py, floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b); extern void ldoubleVectorSpline2D(double t, double* px, double* py, doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
Input | Description |
---|---|
t | Distance of current position |
p | Distance list |
x | x coordinates list |
y | y coordinates list |
a | Differential value list of x coordinates |
b | Differential value list of y coordinates |
Output | Description |
---|---|
px | x coordinates list after correction |
py | y coordinates list after correction |