![]() ![]() ![]() ![]() On the right side you might want to multiply with the same norm construction applied to x so that the test is for the relative error, taking the scale of the problem into account.īy the instructions in the given code, you are implementing the Jacobi iteration, computing all the updates first and then advancing the iteration vector. What you want to test is some norm of the difference of the vectors as a whole, thus using sum(abs(x-xold))/N or max(abs(x-xold)). By inertia they will accidentally both have the value N, so this criterion makes at least a little sense. Mean? Note that this instruction is outside the loops where i and j are the iteration variables, so potentially, the index values are undefined. Now to some other strangeness in your implementation. So to get correct test examples, you need to actually constructively ensure that condition, for instance via A = rand(N,N)+N*eye(N)Įlse the method will diverge towards infinity in some or all components. The Gauß-Seidel and Jacobi methods only apply to diagonally dominant matrices, not generic random ones. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |