Changeset 7886


Ignore:
Timestamp:
Jul 1, 2010, 5:09:54 PM (14 years ago)
Author:
steve
Message:

Copied sudi's directory

Location:
trunk
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/utilities/sparse.py

    r7276 r7886  
    297297    def __mul__(self, other):
    298298        """Multiply this matrix onto 'other' which can either be
    299         a numeric vector, a numeric matrix or another sparse matrix.
     299        a numeric vector.
    300300        """
    301301
     
    303303            B = num.array(other)
    304304        except:
    305             print 'FIXME: Only numeric types implemented so far'
    306 
    307         return csr_mv(self,B)
     305            raise ValueError, 'FIXME: Only numeric types implemented so far'
     306
     307
     308        # Assume numeric types from now on
     309
     310        if len(B.shape) == 0:
     311            # Scalar - use __rmul__ method
     312            #R = B*self
     313            raise TypeError, 'Sparse matrix X scalar not implemented'
     314
     315        elif len(B.shape) == 1:
     316            # Vector
     317            msg = 'Mismatching dimensions: You cannot multiply (%d x %d) matrix onto %d-vector'\
     318                  %(self.M, self.N, B.shape[0])
     319            assert B.shape[0] == self.N, msg
     320
     321            R = csr_mv(self,B)
     322
     323
     324        elif len(B.shape) == 2:
     325            raise TypeError, 'Sparse matrix X matrix multiplication not implemented'
     326
     327        else:
     328            raise ValueError, 'Dimension too high: d=%d' %len(B.shape)
     329
     330        return R
     331
    308332
    309333
  • trunk/anuga_core/source/anuga/utilities/util_ext.h

    r7276 r7886  
    3131
    3232
     33double sign(double x) {
     34  //Return sign of a double
     35
     36  if (x>0.0) return 1.0;
     37  else if (x<0.0) return -1.0;
     38  else return 0.0;
     39}
     40
    3341int _gradient(double x0, double y0,
    3442              double x1, double y1,
  • trunk/anuga_work/development/sudi/sw_2d/yoon_parabolic_basin_cross_mesh.py

    r7837 r7886  
    1111#---------------
    1212# Module imports
    13 #from anuga.shallow_water_balanced.swb_domain import Domain, Transmissive_boundary, Reflective_boundary,\
     13from anuga import Domain, Transmissive_boundary, Reflective_boundary,\
     14     Dirichlet_boundary, rectangular_cross
     15
     16#from anuga.interface import Domain, Transmissive_boundary, Reflective_boundary,\
    1417#     Dirichlet_boundary
    15 
    16 from anuga.interface import Domain, Transmissive_boundary, Reflective_boundary,\
    17      Dirichlet_boundary
    1818from math import sqrt, cos, sin, pi
    19 from anuga.interface import rectangular_cross
    20 from anuga.utilities.polygon import inside_polygon, is_inside_triangle
     19#from anuga.interface import rectangular_cross
     20#from anuga.utilities.polygon import inside_polygon, is_inside_triangle
    2121from numpy import asarray
    2222
     
    2424#-------------------------------
    2525# Domain
    26 n = 20#200
    27 m = 20#200
     26n = 4#200
     27m = 4#200
    2828lenx = 8000.0
    2929leny = 8000.0
     
    3131
    3232points, elements, boundary = rectangular_cross(m, n, lenx, leny, origin)
     33
     34print points
     35print elements
     36print boundary
     37
    3338domain = Domain(points, elements, boundary)
    3439
Note: See TracChangeset for help on using the changeset viewer.