Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function x = conjgrad(A,b,x0,k)
- x = x0;
- d = b - A*x0;
- lastR = b - A*x0;
- for i=1:k
- if lastR == 0
- return
- end
- alfa=lastR' * lastR / (d' * A * d);
- x = x + alfa * d;
- r = lastR - alfa * A * d;
- beta = r' * r / (lastR' * lastR);
- d = r + beta*d;
- lastR = r;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement