我要评分
获取效率
正确性
完整性
易理解

vsumval

Calculate the number of true values of a real-number vector.

The function interface declaration is as follows:

Operations on numbers of the float type:

uint64_t (vsip_vsumval_bl)(const vsip_vview_bl *a);

Parameters

Parameter

Description

Value Range

Input/Output

a

Pointer to the source vector

The value cannot be NULL.

Input

Abnormal Input

When a null pointer is input, the function directly returns 0.

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 VsumvalExample()
{
    int32_t src[BUFFER_SIZE_T] = {1, 6, -1, 0, 3, -4, 0, 9, -5, 2};
    int64_t stride = 1;
    uint64_t offset = 0;

    vsip_block_bl *block_a = vsip_blockbind_bl(src, BUFFER_SIZE_T, VSIP_MEM_NONE);

    vsip_vview_bl *a = vsip_vbind_bl(block_a, offset, stride, BUFFER_SIZE_T);
    vsip_blockadmit_bl(block_a, VSIP_TRUE);

    uint64_t dst = vsip_vsumval_bl(a);

    vsip_valldestroy_bl(a);

    printf("src:\n");
    for (int32_t i = 0; i < BUFFER_SIZE_T; ++i) {
        printf("%2d ", src[i]);
    }
    printf("\ndst: %lu\n", dst);
}

int main(void) {
    VsumvalExample();
    return 0;
}

Output:

src:
 1  6 -1  0  3 -4  0  9 -5  2
dst: 8