Ignore:
Timestamp:
Mar 13, 2006, 11:57:44 AM (19 years ago)
Author:
ole
Message:

Investigating feasibility of scipy as an alternative to Numeric

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/utilities/numerical_tools.py

    r2526 r2531  
    44"""
    55
    6 import Numeric
    7 
    8 
     6
     7#Establish which Numeric package to use
     8#(this should move to somewhere central)
     9try:
     10    from scipy import ArrayType, array, sum, innerproduct, ravel, sqrt   
     11except:
     12    print 'Could not find scipy - using Numeric'
     13    from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt
     14   
    915
    1016def angle(v):
     
    1420
    1521    from math import acos, pi, sqrt
    16     from Numeric import sum, array
    1722
    1823    l = sqrt( sum (array(v)**2))
     
    7277    """Mean value of a vector
    7378    """
    74     return(float(Numeric.sum(x))/len(x))
     79    return(float(sum(x))/len(x))
    7580
    7681
     
    9095    cy = y - mean(y) 
    9196
    92     p = Numeric.innerproduct(cx,cy)/N
     97    p = innerproduct(cx,cy)/N
    9398    return(p)
    9499
     
    130135    """
    131136 
    132     y = Numeric.ravel(x)
    133     p = Numeric.sqrt(Numeric.innerproduct(y,y))
     137    y = ravel(x)
     138    p = sqrt(innerproduct(y,y))
    134139    return p
    135140   
     
    168173    This function is necessary as array(A) can cause memory overflow.
    169174    """
    170 
    171     from Numeric import ArrayType, array
    172175
    173176    if typecode is None:
Note: See TracChangeset for help on using the changeset viewer.