UnitVector
Advanced Analysis Library Only
AnalysisLibErrType UnitVector (double inputArray[], ssize_t numberOfElements, int normType, double userdefinedNorm, double *norm);
Purpose
Finds the norm of the input array and obtains its corresponding unit vector by normalizing the input array with the norm. UnitVector obtains the norm using the following formula:
|
when normtype is 1-norm |
|
when normtype is 2-norm |
|
when normtype is Inf-norm |
|
when normtype is -Inf-norm |
|
when normtype is a user-defined value |
Where x is the inputArray, y is userdefinedNorm, and ||x|| is norm.
This function calculates the unit vector using the following equation:
Example Code
/* The following code calculates the 2-norm of the input array x. */
double x[4] = {-2, 2, -2, 2};
double norm;
UnitVector(x, 4, 2, -1, &norm);
Parameters
Input | ||||||||||||||||||||
Name | Type | Description | ||||||||||||||||||
numberOfElements | ssize_t | Number of elements in inputArray. | ||||||||||||||||||
normType | int | The norm type to compute. normType must be one of the following values.
|
||||||||||||||||||
userdefinedNorm | double | A user-defined norm type. This function uses this value only when normType is NORM_TYPE_USER. userdefinedNorm must be nonzero. | ||||||||||||||||||
Output | ||||||||||||||||||||
Name | Type | Description | ||||||||||||||||||
inputArray | double [] | On input, the input array. On output, this parameter returns the corresponding unit vector obtained by normalizing the input array with norm. | ||||||||||||||||||
norm | double | The norm of inputArray. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 2012 and later