1
$\begingroup$

I'm working on a problem about the multiplication of a matrix $A$ of order $m \times n$ by a vector $b$. In particular I'm supposed to determine the number of operations needed.

What is the point of this though? It really gives me more motivation and helps me understand when I understand WHY I am doing something.

Isn't this just showing me how badly my algorithm is messing up calculations? How am I supposed to add these sums for any number of calculations I do?

  • 0
    What are "Flop counts"?2017-02-07
  • 0
    @coffeemath: counting the number of floating point operations. In the ancient days they were far slower than integer operations and could dominate the time needed for a program to run.2017-02-07
  • 0
    @RossMillikan Thanks for the definition. Also this may answer OP's query about the point of counting them.2017-02-07

1 Answers 1

1

The point is to estimate how long an algorithm will take and how it scales with the size of the input. In your example of a matrix multiply you have $mn$ entries in A. Each one has to get multiplied by an entry in b, so there are $mn$ multiplies. Then you have to do $(m-1)n$ additions to get the entries in the result. We can ignore the $-1$ and say the effort expended is $2mn$ floating point operations. If you can do a billion operations in a reasonable amount of time you can afford to have $m$ and $n$ be tens of thousands but not millions.

Some operations have alternate algorithms with different timing. Sorting is a prime example. Some simple minded sorting algorithms scale as the square of the number of items sorted, so again you could afford to sort a few tens of thousands of things but not millions. There are other algorithms that work in $n \log n$ time. Now you can afford to sort tens of millions. That is an enormous increase.

  • 0
    Shouldn't the flop count for this be O(n^2)?2017-02-10
  • 0
    There are $mn$ entries in $A$ and each one gets multiplied by one entry in $b$, so there are $mn$ multiplies. That is $n^2$ if $A$ is square, but you did not specify that.2017-02-10