[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Implementing a Jacobi iterative method for Ax=b
From: |
Sergei Steshenko |
Subject: |
Re: Implementing a Jacobi iterative method for Ax=b |
Date: |
Sun, 28 Oct 2012 15:17:28 -0700 (PDT) |
----- Original Message -----
> From: Joza <address@hidden>
> To: address@hidden
> Cc:
> Sent: Sunday, October 28, 2012 11:48 PM
> Subject: Re: Implementing a Jacobi iterative method for Ax=b
>
> Here is my latest code:
>
> function [x, k] = Jacobi2(A, b, tol)
>
> k = 0;
> n = size(A,1);
> x_old = zeros(n,1);
> converged = 0;
>
> for i=1:n
> if A(i,i) == 0.0
> W = A(dmperm(A), :)
> break
> else W = A;
> end
> end
>
> for i=1:n
> D_inv(i,i) = 1/W(i,i)
> end
>
> while ~converged
>
> x_new = x_old + D_inv*(b - W*x_old) % Correction form
> k = k + 1;
>
> if norm(b - W*x_new)/norm(b) < tol
> x = x_new
> converged = 1;
> else
> x_old = x_new;
> end
> end
> ************************************************
> I reorder the matrix using dmperm so that no diagonals are zero.
>
> When i run this get the error:
>
> warning: broken pipe -- some output may be lost
>
> Whats going on!!??
>
"Whats going on!!??" - you forgot to put a semicolon at the end of
W = A(dmperm(A), :)
x = x_new
D_inv(i,i) = 1/W(i,i)
lines.
Regards,
Sergei.
- Implementing a Jacobi iterative method for Ax=b, Joza, 2012/10/28
- Re: Implementing a Jacobi iterative method for Ax=b, Joza, 2012/10/28
- Re: Implementing a Jacobi iterative method for Ax=b, c., 2012/10/28
- Re: Implementing a Jacobi iterative method for Ax=b, Ozzy Lash, 2012/10/28
- Re: Implementing a Jacobi iterative method for Ax=b, Joza, 2012/10/28
- Re: Implementing a Jacobi iterative method for Ax=b, Ozzy Lash, 2012/10/28
- Re: Implementing a Jacobi iterative method for Ax=b, Joza, 2012/10/29
- Re: Implementing a Jacobi iterative method for Ax=b, Joza, 2012/10/29
- Re: Implementing a Jacobi iterative method for Ax=b, Juan Pablo Carbajal, 2012/10/30
- Re: Implementing a Jacobi iterative method for Ax=b, Ozzy Lash, 2012/10/30