Message Boards Message Boards

How to count the number of operations performed during a calculation?

I need to know how can I count the number of operations performed during a calculation of a CompoundExpression.

In some of these expressions there are Dot products between matrices and I want to count how many additions a multiplications are performed in each of these calculations.

In other words, I need a functions that does the same as the function cost of Maple (http://www.maplesoft.com/support/help/Maple/view.aspx?path=codegen/cost)

For instance, I want to know how many additions and multiplications are performed in the execution of the following function:
LinearSolve[Dot[{{1, 2}, {3, 4}}, {{5, 6}, {3, 4}}], {5, 6}]

How can I do it?
POSTED BY: Renato Orsino
Hey Renato, 

I am not particulary sure about this case. In general you can use Trace to get the inforamtion about internal steps. For the Mathematica numeric solvers such as NDSolve and FindMinimum, they have a StepMonitor option, which extracts very detailed internal steps for you. 
POSTED BY: Shenghui Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract