dotprod.c

来自「矩阵点乘」· C语言 代码 · 共 59 行

C
59
字号
/////////////////////////////////////////////////////////////////////////////// 
// 
// 	FILE: dotprod.c 
// 
/////////////////////////////////////////////////////////////////////////////// 
 
const int N = 20; 
 
/////////////////////////////////////////////////////////////////////////////// 
// int a_dot_b( int*, int* ) 
/////////////////////////////////////////////////////////////////////////////// 
 
int a_dot_b( int *a, int *b ) 
{ 
    int i; 
    int output = 0.0; 
 
    for( i=0; i<N; i++ )  
    { 
		output += ( a[i] * b[i] ); 
	} 
 
 
    return( output ); 
} 
 
/////////////////////////////////////////////////////////////////////////////// 
// int a_dot_c( int*, int* ) 
/////////////////////////////////////////////////////////////////////////////// 
 
int a_dot_c( int *a, int *c ) 
{ 
    int i; 
    int output = 0.0; 
 
    for( i=0; i<N; i++ ) 
    { 
		output += ( a[i] * c[i] ); 
	} 
 
    return( output ); 
} 
 
/////////////////////////////////////////////////////////////////////////////// 
// int a_dot_d( int*, int* ) 
/////////////////////////////////////////////////////////////////////////////// 
 
int a_dot_d( int *a, int *d ) 
{ 
    int i; 
    int output = 0.0; 
 
    for (i=0; i<N/2; i++)  
    { 
		output += ( a[2*i] * d[i] ); 
	} 
 
    return( output ); 
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?