提交记录 16131


用户 题目 状态 得分 用时 内存 语言 代码长度
lkmcfj mmmd1k. 测测你的双精度矩阵乘法-1k Accepted 100 2.971 s 8200 KB C++ 793 B
提交时间 评测时间
2021-04-04 11:29:01 2021-04-04 11:29:09
#define idx(i, j) ((i) * n + (j))

void matrix_multiply(int n, const double *A, const double *B, double *C) {
	const int BLOCK = 4;
	for (int ii = 0; ii < n; ii += BLOCK)
		for (int jj = 0; jj < n; jj += BLOCK)
			for (int i = ii; i < ii + BLOCK; i ++)
				for (int j = jj; j < jj + BLOCK; j ++)
				{
					double a_ij = A[idx(i, j)];
					register double *c_i = C + i * n;
                                        register const double *b_j = B + j * n;
					const int UNROLL = 4;
					for (int k = 0; k < n; k += UNROLL)
					{
						c_i[0] += a_ij * b_j[0];
						c_i[1] += a_ij * b_j[1];
						c_i[2] += a_ij * b_j[2];
						c_i[3] += a_ij * b_j[3];
                                                c_i += UNROLL;
                                                b_j += UNROLL;
					}
				}
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #12.971 s8 MB + 8 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2021-04-21 22:31:39 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用