What is the complexity of matrix addition?

后端 未结 4 1472
清酒与你
清酒与你 2021-02-19 21:02

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 calc

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-19 21:07

    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: on some hardware (GPU, vector machines, etc) the addition might run faster than expected (even though complexity is still the same, see discussion below), because the hardware can perform multiple additions in one step. For a bounded problem size (like n < 3) it might even be one step.

提交回复
热议问题