MaxMin2D
AnalysisLibErrType MaxMin2D (void *inputArray, ssize_t numberOfRows, ssize_t numberOfColumns, double *maximumValue, ssize_t *maximumRowIndex, ssize_t *maximumColumnIndex, double *minimumValue, ssize_t *minimumRowIndex, ssize_t *minimumColumnIndex);
Purpose
Finds the maximum and the minimum values in the 2D input array and the their locations in the array. If there are multiple instances of the maximum and/or minimum values, MaxMin2D returns the location of the first occurrence. If all the elements in the 2D input array are NaNs, MaxMin2D returns -1 for the row index and column index of the maximum and minimum values.
MaxMin2D scans the inputArray array by rows.
The following example uses the MaxMin2D function.
double inputData[10][10];
double maxValue, minValue;
int maxRowIndex, maxColumnIndex, minRowIndex, minColumnIndex;
int i, j, numRows, numCols;
AnalysisLibErrType status;
numRows = 10;
numCols = 10;
/* Use a For loop to generate a 2D array of random numbers between 0.0 and 1.0 */
for (j = 0; j < 10; j++)
for (i = 0; i < 10; i++)
inputData[i][j] = Random(0.0, 1.0);
status = MaxMin2D(inputData, numRows, numCols, &maxValue, &maxRowIndex, &maxColumnIndex, &minValue, &minRowIndex, &minColumnIndex);
Parameters
Input | ||
Name | Type | Description |
inputArray | void * | Input array whose maximum and minimum values are determined. This array must be an array of doubles. |
numberOfRows | ssize_t | Number of rows used to determine the maximum and minimum values. |
numberOfColumns | ssize_t | Number of columns used to determine the maximum and minimum values. |
Output | ||
Name | Type | Description |
maximumValue | double | Maximum value found in inputArray. |
maximumRowIndex | ssize_t | Row index of the maximum value found in inputArray. |
maximumColumnIndex | ssize_t | Column index of the maximum value found in inputArray. |
minimumValue | double | Minimum value found in the inputArray. |
minimumRowIndex | ssize_t | Row index of the minimum value found in inputArray. |
minimumColumnIndex | ssize_t | Column index of the minimum value found in 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: Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later