matmult.c

来自「nachos系统作业 实现线程系统 实现一个电梯模拟 附实验报告」· C语言 代码 · 共 39 行

C
39
字号
/* matmult.c  *    Test program to do matrix multiplication on large arrays. * *    Intended to stress virtual memory system. * *    Ideally, we could read the matrices off of the file system, *	and store the result back to the file system! */#include "syscall.h"#define Dim 	20	/* sum total of the arrays doesn't fit in 			 * physical memory 			 */int A[Dim][Dim];int B[Dim][Dim];int C[Dim][Dim];intmain(){    int i, j, k;    for (i = 0; i < Dim; i++)		/* first initialize the matrices */	for (j = 0; j < Dim; j++) {	     A[i][j] = i;	     B[i][j] = j;	     C[i][j] = 0;	}    for (i = 0; i < Dim; i++)		/* then multiply them together */	for (j = 0; j < Dim; j++)            for (k = 0; k < Dim; k++)		 C[i][j] += A[i][k] * B[k][j];    Exit(C[Dim-1][Dim-1]);		/* and then we're done */}

⌨️ 快捷键说明

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