Rate This Document
Findability
Accuracy
Completeness
Readability

vand

Perform logical AND operations on real-number vectors.

The function interface declaration is as follows:

Operations on numbers of the bool type:

void (vsip_vand_bl)(const vsip_vview_bl *a, const vsip_vview_bl *b, const vsip_vview_bl *r);

Parameters

Parameter

Description

Value Range

Input/Output

a

Pointer to the source vector

The value cannot be NULL.

Input

b

Pointer to the source vector

The value cannot be NULL.

Input

r

Pointer to the destination vector

The value cannot be NULL.

Output

Abnormal Input

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

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 VandExample()
{
    int32_t src1[BUFFER_SIZE_T] = {1, 6, -1, 0, 3, -4, 0, 9, -5, 2};
    int32_t src2[BUFFER_SIZE_T] = {-1, 0, 4, -18, 13, 0, 0, -3, 5, 0};
    int32_t dst[BUFFER_SIZE_T];
    int64_t stride = 1;
    uint64_t offset = 0;

    vsip_block_bl *block_a = vsip_blockbind_bl(src1, BUFFER_SIZE_T, VSIP_MEM_NONE);
    vsip_block_bl *block_b = vsip_blockbind_bl(src2, BUFFER_SIZE_T, VSIP_MEM_NONE);
    vsip_block_bl *block_r = vsip_blockbind_bl(dst, 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);
    vsip_vview_bl *b = vsip_vbind_bl(block_b, offset, stride, BUFFER_SIZE_T);
    vsip_blockadmit_bl(block_b, VSIP_TRUE);
    vsip_vview_bl *r = vsip_vbind_bl(block_r, offset, stride, BUFFER_SIZE_T);
    vsip_blockadmit_bl(block_r, VSIP_TRUE);

    vsip_vand_bl(a, b, r);

    vsip_valldestroy_bl(a);
    vsip_valldestroy_bl(b);
    vsip_valldestroy_bl(r);

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

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

Output:

src1:
1 6 -1 0 3 -4 0 9 -5 2
src2:
-1 0 4 -18 13 0 0 -3 5 0
dst:
1 0 1 0 1 0 0 1 1 0