Published using Google Docs
GaussSeidel
Updated automatically every 5 minutes

import numpy

m=int(raw_input('Valor de m:'))

n=int(raw_input('Valor de n:'))

matrix = numpy.zeros((m,n))

vector = numpy.zeros((n))

x=numpy.zeros((m))

print 'Método de Gauss-Seidel'

i=int(raw_input('Número de iteraciones:'))

print 'Introduce la matriz de coeficientes y el vector solución'

for r in range(0,m):

for c in range(0,n):

matrix[(r),(c)]=(raw_input("Elemento a["+str(r+1)+str(c+1)+"] "))

vector[(r)]=(raw_input('b['+str(r+1)+']: '))

print "Método de Gauss-Seidel"

k=0

while k<10:

suma=0

k=k+1

for r in range(0,m):

suma=0

for c in range(0,n):

if (c != r):

suma=suma+matrix[r,c]*x[c]

x[r]=(vector[r]-suma)/matrix[r,r]

print "x["+str(r)+"]: "+str(x[r])