svmul
Multiply a real-number scalar and a real-number vector.
The function interface declaration is as follows:
Operations on numbers of the float type:
void (vsip_svmul_f)(float alpha, const vsip_vview_f *b, const vsip_vview_f *r);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
alpha |
Scalar to be operated |
Unlimited |
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 SvmulExample()
{
float alpha = 1.4f;
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};
float dst[BUFFER_SIZE_T];
int64_t stride = 1;
uint64_t offset = 0;
vsip_block_f *block_b = vsip_blockbind_f(src, BUFFER_SIZE_T, VSIP_MEM_NONE);
vsip_block_f *block_r = vsip_blockbind_f(dst, BUFFER_SIZE_T, VSIP_MEM_NONE);
vsip_vview_f *b = vsip_vbind_f(block_b, offset, stride, BUFFER_SIZE_T);
vsip_blockadmit_f(block_b, VSIP_TRUE);
vsip_vview_f *r = vsip_vbind_f(block_r, offset, stride, BUFFER_SIZE_T);
vsip_blockadmit_f(block_r, VSIP_TRUE);
vsip_svmul_f(alpha, b, r);
vsip_valldestroy_f(b);
vsip_valldestroy_f(r);
printf("alpha: %.4f\nsrc:\n", alpha);
for (int32_t i = 0; i < BUFFER_SIZE_T; ++i) {
printf("%.4f ", src[i]);
}
printf("\ndst:\n");
for (int32_t i = 0; i < BUFFER_SIZE_T; ++i) {
printf("%.4f ", dst[i]);
}
printf("\n");
}
int main(void) {
SvmulExample();
return 0;
}
Output:
alpha: 1.4000 src: 1.6400 1.6300 -1.0900 0.7100 -3.2000 -0.4300 0.4100 -4.8300 5.3600 -4.4000 dst: 2.2960 2.2820 -1.5260 0.9940 -4.4800 -0.6020 0.5740 -6.7620 7.5040 -6.1600
Parent topic: Vector Operation Functions