dotp4.c
来自「教程《DSP 原理及其 C 编程开发技术》中的源代码」· C语言 代码 · 共 27 行
C
27 行
//Dotp4.c Multiplies two arrays, each array with 4 numbers
int dotp(short *a, short *b, int ncount); //function prototype
#include <stdio.h> //for printf
#include "dotp4.h" //data file of numbers
#define count 4 //# of data in each array
short x[count] = {x_array}; //declaration of 1st array
short y[count] = {y_array}; //declaration of 2nd array
main()
{
int result = 0; //result sum of products
result = dotp(x,y,count); //call dotp function
printf("result = %d (decimal) \n", result); //print result
}
int dotp(short *a, short *b, int ncount) //dot product function
{
int sum = 0; //init sum
int i;
for (i = 0; i < ncount; i++)
sum += a[i] * b[i]; //sum of products
return(sum); //return sum as result
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?