1 Replies - 1739 Views - Last Post: 13 November 2012 - 12:12 PM Rate Topic: -----

#1 MEFerrara  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-November 12

Gaussian seidel iteration technique

Posted 12 November 2012 - 10:09 PM

 Sub pickup()
Dim A(), b(), x()
c1 = ActiveCell.Column
r1 = ActiveCell.Row
nr = Selection.Rows.Count
nc = Selection.Columns.Count
ReDim A(nr, nc), b(nc), x(nr)
e = 0.000001
For i = 1 To nr
 r = r1 + i  1
For j = 1 To nc
        		c = c1 + j - 1
        		A(i, j) = Cells(r, c).Value
    	Next j
    	b(i) = Cells(r, c1 + nc).Value
Next i
Call GS(A, b, x, e, numiter)
For i = 1 To nr
    r = r1 + i + nr + 3
    	For j = 1 To nc
        		c = c1 + j + -1
        		Cells(r, c).Value = A(i, j)
    	Next j
Cells(r, c + 1).Value = b(i)
Cells(r, c + 3).Value = x(i)
Next i
Cells(r + 1, c + 3).Value = numiter
End Sub

Sub GS(A, b, x, e, m)
Dim sp As Double
nr = Selection.Rows.Count
nc = Selection.Columns.Count
For m = 1 To 1000
	 For i = 1 To nc
	sp = 0
  		For j = 1 To nr
		If i <> j Then sp = sp + A(i, j) * x(i)
		Next j
	 xlast = x(i)
  	x(i) = (b(i) - sp) / A(i, i)
	 If Abs(x(i) - xlast) < e Then rc = rc + 1
	 Next i
If rc = nc Then Exit Sub
Next m
End Sub


I am not getting the right answers when i check them with a calculator. This is the method my professor gave us in class so if anyone knows a better route I am more than open to new methods. This is in VBA btw. If anyone can help i would appreciate it.

Is This A Good Question/Topic? 0
  • +

Replies To: Gaussian seidel iteration technique

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Gaussian seidel iteration technique

Posted 13 November 2012 - 12:12 PM

Let's see if we can troubleshoot this first, before deciding your professor doesn't know his stuff and looking for a "better" way to do it. First, please explain in detail the procedure that you used to check your code. "I am not getting the right answers when I check them with a calculator" doesn't give us enough to go on.

This post has been edited by AdamSpeight2008: 13 November 2012 - 07:51 PM
Reason for edit:: Removal of Double Posting

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1