vmaxmgval
Calculate the maximum absolute value of real-number vectors.
The function interface declaration is as follows:
Operations on numbers of the float type:
float (vsip_vmaxmgval_f)(const vsip_vview_f *a, uint64_t *j);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
a |
Pointer to the source vector |
The value cannot be NULL. |
Input |
j |
Pointer to the index variable |
The value cannot be NULL. |
Output |
Abnormal Input
When a null pointer is input, the function directly returns a NaN value.
Example
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "kvsip.h"
#include "vsip.h"
#include "vsip_type.h"
#define BUFFER_SIZE_T 10
void VmaxmgvalExample()
{
float src[BUFFER_SIZE_T] = {1.64f, 1.63f, -1.09f, 0.71f, -3.20f, -0.43f, 0.41f, 4.83f, -5.36f, -4.40f};
uint64_t j = 0;
int64_t stride = 1;
uint64_t offset = 0;
vsip_block_f *block_a = vsip_blockbind_f(src, BUFFER_SIZE_T, VSIP_MEM_NONE);
vsip_vview_f *a = vsip_vbind_f(block_a, offset, stride, BUFFER_SIZE_T);
vsip_blockadmit_f(block_a, VSIP_TRUE);
float dst = vsip_vmaxmgval_f(a, &j);
vsip_valldestroy_f(a);
printf("src:\n");
for (int32_t i = 0; i < BUFFER_SIZE_T; ++i) {
printf("%.2f ", src[i]);
}
printf("\nindex: %lu, dst:%.2f\n", j, dst);
}
int main(void) {
VmaxmgvalExample();
return 0;
}
Output:
src: 1.64 1.63 -1.09 0.71 -3.20 -0.43 0.41 4.83 -5.36 -4.40 index: 8, dst:5.36
Parent topic: Vector Operation Functions