矩阵加法的复杂度是多少?

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

我发现关于矩阵加法的另一个问题是二次运算,有一些提及一个>.但是我认为它是线性的.

I have found some mentions in another question of matrix addition being a quadratic operation. But I think it is linear.

如果我将矩阵的大小加倍,则需要计算加法的两倍,而不是四倍.

If I double the size of a matrix, I need to calculate double the additions, not quadruple.

主要分歧点似乎是问题的规模.对我来说,这是矩阵中元素的数量.其他人则认为这是列数或行数,因此O(n^2)复杂度.

The main diverging point seems to be what is the size of the problem. To me, it's the number of elements in the matrix. Others think it is the number of columns or lines, hence the O(n^2) complexity.

我将其视为二次运算遇到的另一个问题是,这意味着将3维矩阵加为三次方,而将4维矩阵加为O(n^4)等,即使所有这些问题都可以简化为两个向量相加的问题,它具有明显的线性解.

Another problem I have with seeing it as a quadratic operation is that that means adding 3-dimensional matrices is cubic, and adding 4-dimensional matrices is O(n^4), etc, even though all of these problems can be reduced to the problem of adding two vectors, which has an obviously linear solution.

我是对还是错?如果错了,为什么?

Am I right or wrong? If wrong, why?

推荐答案

这取决于您对问题大小的定义:是元素总数还是矩阵的宽度/高度.哪一个是正确的实际上取决于矩阵加法其中一部分的较大问题.

As you already noted, it depends on your definition of the problem size: is it the total number of elements, or the width/height of the matrix. Which ever is correct actually depends on the larger problem of which the matrix addition is part of.

NB:在某些硬件(GPU,矢量机等)上,添加可能会比预期运行得更快(即使复杂度仍然相同,请参见下面的讨论),因为硬件可以一步执行多次添加.对于有限的问题大小(例如n <3),它甚至可能只是一步.

更多推荐

矩阵加法的复杂度是多少?

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

发布评论

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

>www.elefans.com

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