vcopy
Perform copy operations on real-number vectors.
The function interface declaration is as follows:
Copying an integer to a float number:
void (vsip_vcopy_i_f)(const vsip_vview_i *a, const vsip_vview_f *r);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
a |
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 VcopyExample()
{
int32_t src[BUFFER_SIZE_T] = {1, 6, -1, 0, 3, -4, 8, 9, -5, 2};
float dst[BUFFER_SIZE_T];
int64_t stride = 1;
uint64_t offset = 0;
vsip_block_i *block_a = vsip_blockbind_i(src, BUFFER_SIZE_T, VSIP_MEM_NONE);
vsip_block_f *block_r = vsip_blockbind_f(dst, BUFFER_SIZE_T, VSIP_MEM_NONE);
vsip_vview_i *a = vsip_vbind_i(block_a, offset, stride, BUFFER_SIZE_T);
vsip_blockadmit_i(block_a, VSIP_TRUE);
vsip_vview_f *r = vsip_vbind_f(block_r, offset, stride, BUFFER_SIZE_T);
vsip_blockadmit_f(block_r, VSIP_TRUE);
vsip_vcopy_i_f(a, r);
vsip_valldestroy_i(a);
vsip_valldestroy_f(r);
printf("src:\n");
for (int32_t i = 0; i < BUFFER_SIZE_T; ++i) {
printf("%4d ", src[i]);
}
printf("\ndst:\n");
for (int32_t i = 0; i < BUFFER_SIZE_T; ++i) {
printf("%.2f ", dst[i]);
}
printf("\n");
}
int main(void) {
VcopyExample();
return 0;
}
Output:
src: 1 6 -1 0 3 -4 8 9 -5 2 dst: 1.00 6.00 -1.00 0.00 3.00 -4.00 8.00 9.00 -5.00 2.00
Parent topic: Vector Operation Functions