⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dotp4.c

📁 点乘 开发环境:code composer studio3.1 设置说明:project-build options-linker-stack size 5
💻 C
字号:
//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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -