提交记录 16133


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

void matrix_multiply(int n, const double *A, const double *B, double *C) {
	const int BLOCK = 2;
	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.837 s8 MB + 8 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-10-05 12:05:39 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用