0

Suppose that for some needed transformation I have a mxn matrix A that consists of a few 1's and many 0's. If I were to transform a nx1 vector by A, is this considered a vectorized implementation?

While the matrix A mainly consists of 0's, does this still cause the same amount of FLOPs to occur?

Would it be wiser and more optimized to do the transformation needed another way? One that won't cause needless calculations such as 0*c?

SexyToad
  • 113
  • 1
  • 6
  • 1
    Can you show us some code? It sounds like you're looking for a Sparse Matrix. – CookieOfFortune Apr 11 '18 at 16:33
  • Sure, specifically I have a column vector that I want to flip and append to the bottom of the vector. For example, suppose I have the column vector x = [1;2;3], I want to have the vector [1;2;3;2;1]. The matrix A that would do this for me is: A = [1, 0, 0 0, 1, 0 0, 0, 1 0, 1, 0 1, 0, 0] I know that I can use flipud(x) or some other function to achieve roughly what I want, but I meant the question in more in a general sense. There's a few other situations I want to tackle that's more than just flipping a vector. – SexyToad Apr 11 '18 at 16:38
  • How big are your vectors? – CookieOfFortune Apr 11 '18 at 20:43

1 Answers1

0

The matrix is sparse. The number of operations for various things is lower when you store it properly and use the right routines.