Line | |
---|
1 | function f = flops_chol(n)
|
---|
2 | % FLOPS_CHOL Flops for Cholesky decomposition.
|
---|
3 | % FLOPS_CHOL(n) returns the number of flops for chol(eye(n)).
|
---|
4 |
|
---|
5 | % Formula comes from Numerical Recipes algorithm.
|
---|
6 | % Number of multiplies+adds is:
|
---|
7 | % sum(i=1..n) sum(j=i..n) sum(k=i-1..1) 2 = sum(i=1..n) 2*(n-i+1)*(i-1)
|
---|
8 | % = (n^3-n)/3 = maple('simplify(sum(2*(n-x+1)*(x-1),x=1..n));')
|
---|
9 | % Number of divides is:
|
---|
10 | % sum(i=1..n) (n-i+1) - n = (n^2-n)/2
|
---|
11 |
|
---|
12 | % matlab5 counts n^3/3 only
|
---|
13 | f = (n.^3-n)/3 + (n.^2-n)/2*flops_div + n*flops_sqrt;
|
---|
Note: See
TracBrowser
for help on using the repository browser.