Ignore:
Timestamp:
Oct 21, 2004, 11:54:49 PM (20 years ago)
Author:
steve
Message:

CG tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/cg_solve.py

    r435 r438  
    11import exceptions
    2 class VectorShapeError(exceptions.Exception):
    3    """
    4    Setup Exception for routine conjugate_gradient
    5    """
    6    def __init__(self,args=None):
    7       self.args = args
    8 
    9 
    10 
     2class VectorShapeError(exceptions.Exception): pass
    113
    124
    135def conjugate_gradient(A,b,x0,imax=2000,tol=1.0e-8,iprint=0):
    14    #
    15    # Try to solve linear equation Ax = b using
    16    # conjugate gradient method
    17    #
    18    # Input
    19    # A: matrix or function which applies a matrix, assumed symmetric
    20    # b: right hand side
    21    # x0: inital guess
    22    # imax: max number of iterations
    23    # tol: tolerance used for residual
    24    #
    25    # Output
    26    # x: approximate solution
    27    # i: number of iterations
    28    #
     6   """
     7   Try to solve linear equation Ax = b using
     8   conjugate gradient method
     9   
     10   Input
     11   A: matrix or function which applies a matrix, assumed symmetric
     12   b: right hand side
     13   x0: inital guess
     14   imax: max number of iterations
     15   tol: tolerance used for residual
     16   
     17   Output
     18   x: approximate solution
     19   """
    2920
    3021   #if nargin<3
     
    3728   b  = asarray(b, typecode=Float)
    3829   x0 = asarray(x0, typecode=Float)
     30   #A = asarray(A, typecode=Float)
    3931
    40    print "A shape",A.shape[0]
    41    print "b shape",len(b.shape)
    42    print "x0 shape",x0.shape[0]
     32   #print "A shape",A.shape
     33   #print "b shape",len(b.shape)
     34   #print "x0 shape",x0.shape[0]
    4335
    4436   if len(b.shape) != 1 :
Note: See TracChangeset for help on using the changeset viewer.