I know there is a Timing approach, but I am wondering if there is a Mathematica command that will count the number of flops (floating point operations). For example, if I do:
A = RandomReal[9, {10, 10}]
How can I get a count of the number of flops required to compute:
MatrixForm[A = RandomReal[9, {10, 10}]]
Then, I created a function to compute the cofactor.
Cofactor[m_List?MatrixQ, {i_Integer, j_Integer}] := (-1)^(i + j) Det[
Drop[Transpose[Drop[Transpose[m], {j}]], {i}]]
Now, I can create the cofactor matrix for A and take its transpose which gives me the adjugate matrix.
MatrixForm[
adjA = Transpose[Table[Cofactor[A, {i, j}], {i, 1, 10}, {j, 1, 10}]]]
And I can compute the inverse of matrix A in this manner.
MatrixForm[adjA/Det[A]]
Is there a way to count the number of floating point operations in both methods?
Timing
can be very helpful. $\endgroup$