矩阵乘法算法的时间复杂度

编程入门 行业动态 更新时间:2024-10-23 08:38:46
本文介绍了矩阵乘法算法的时间复杂度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想出了这个算法,矩阵乘法。我曾经读过矩阵乘法为O的时间复杂度(N ^ 2)。 但我认为我的这个算法会给O(N ^ 3)。 我不知道如何计算时间嵌套循环的复杂性。所以,请大家指正。

对于i = 1到n    对于j = 1到n      C [I] [J] = 0      对于k = 1到n          C [I] [J] = C [I] [J] + A [1] [K] * B [k]的[J]。

解决方案

天真的算法,也就是你有什么,一旦你改正它作为评论指出,为O(n ^ 3)。

确实存在的算法,减少这个有点,但你不可能找到一个为O(n ^ 2)执行。我认为,最有效的执行问题仍然是开放的。

查看矩阵乘法这维基百科的文章以了解更多信息。

I came up with this algorithm for matrix multiplication. I read somewhere that matrix multiplication has a time complexity of o(n^2). But I think my this algorithm will give o(n^3). I don't know how to calculate time complexity of nested loops. So please correct me.

for i=1 to n for j=1 to n c[i][j]=0 for k=1 to n c[i][j] = c[i][j]+a[i][k]*b[k][j]

解决方案

The naive algorithm, which is what you've got once you correct it as noted in comments, is O(n^3).

There do exist algorithms that reduce this somewhat, but you're not likely to find an O(n^2) implementation. I believe the question of the most efficient implementation is still open.

See this wikipedia article on Matrix Multiplication for more information.

更多推荐

矩阵乘法算法的时间复杂度

本文发布于:2023-11-28 20:53:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复杂度   乘法   矩阵   算法   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!