Computational Complexity of Setting Matrix Elements to a Value
이전 댓글 표시
Hello,
I have a problem where I am implementing a projection onto some set (could go into more detail if need be, but for now I'll keep it at that). I know this projection can be implemented really efficiently in MATLAB by simply setting the the entire row of a matrix to 0, while keeping all the other elements the same. Now, I am rather new to the concept of computational complexity, so I was wondering if someone could help me with figuring this out. I believe given a matrix in ℝ
, this complexity should be on
, since we are setting N elements to zero?
, this complexity should be on
, since we are setting N elements to zero?If that is not the correct intuition, could someone please assist me in this topic?
Thanks
댓글 수: 4
Sindar
2020년 10월 13일
That reasoning sounds correct to me (you could think of it as doing N multiplications), but I don't know how useful it is in practice. As you say, this is really efficient, so I'd expect almost any other part of the program to take longer, regardless of scaling. Plus, the actual time will depend a lot on the specifics of memory (is the data stored row-column or column-row? How does the matrix size compare to cache? What tricks does Matlab do when inserting the same value in many locations?)
per isakson
2020년 10월 14일
편집: per isakson
2020년 10월 14일
Sean T
2020년 10월 15일
Sindar
2020년 10월 15일
In this case, I think it's fair to say you've improved it to trivial cost, changing the bottleneck to a different part of the algorithm. This is more informative than a complexity scale, but if they really want it, you could say something like "O(N) with a very small coefficient"
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!