From scipy-svn at scipy.org Thu May 1 15:59:24 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 May 2008 14:59:24 -0500 (CDT) Subject: [Scipy-svn] r4201 - in trunk/scipy/interpolate: . tests Message-ID: <20080501195924.44751C7C048@new.scipy.org> Author: peridot Date: 2008-05-01 14:59:21 -0500 (Thu, 01 May 2008) New Revision: 4201 Modified: trunk/scipy/interpolate/polyint.py trunk/scipy/interpolate/tests/test_polyint.py Log: New-style classes and exceptions, and a procedural interface. Modified: trunk/scipy/interpolate/polyint.py =================================================================== --- trunk/scipy/interpolate/polyint.py 2008-04-30 01:41:48 UTC (rev 4200) +++ trunk/scipy/interpolate/polyint.py 2008-05-01 19:59:21 UTC (rev 4201) @@ -2,9 +2,9 @@ from scipy import factorial from numpy import poly1d -__all__ = ["KroghInterpolator", "BarycentricInterpolator", "PiecewisePolynomial"] +__all__ = ["KroghInterpolator", "krogh_interpolate", "BarycentricInterpolator", "barycentric_interpolate", "PiecewisePolynomial", "piecewise_polynomial_interpolate"] -class KroghInterpolator: +class KroghInterpolator(object): """The interpolating polynomial for a set of points Constructs a polynomial that passes through a given set of points, @@ -55,7 +55,7 @@ self.vector_valued = False self.yi = self.yi[:,np.newaxis] elif len(self.yi.shape)>2: - raise ValueError, "y coordinates must be either scalars or vectors" + raise ValueError("y coordinates must be either scalars or vectors") else: self.vector_valued = True @@ -63,7 +63,7 @@ self.n = n nn, r = self.yi.shape if nn!=n: - raise ValueError, "%d x values provided and %d y values; must be equal" % (n, nn) + raise ValueError("%d x values provided and %d y values; must be equal" % (n, nn)) self.r = r c = np.zeros((n+1,r)) @@ -222,12 +222,74 @@ Notes ----- This is computed by evaluating all derivatives up to the desired - one and then discarding the rest. + one (using self.derivatives()) and then discarding the rest. """ return self.derivatives(x,der=der+1)[der] +def krogh_interpolate(xi,yi,x,der=0): + """Convenience function for polynomial interpolation. -class BarycentricInterpolator: + Constructs a polynomial that passes through a given set of points, + optionally with specified derivatives at those points. + Evaluates the polynomial or some of its derivatives. + For reasons of numerical stability, this function does not compute + the coefficients of the polynomial, although they can be obtained + by evaluating all the derivatives. + + Be aware that the algorithms implemented here are not necessarily + the most numerically stable known. Moreover, even in a world of + exact computation, unless the x coordinates are chosen very + carefully - Chebyshev zeros (e.g. cos(i*pi/n)) are a good choice - + polynomial interpolation itself is a very ill-conditioned process + due to the Runge phenomenon. In general, even with well-chosen + x values, degrees higher than about thirty cause problems with + numerical instability in this code. + + Based on Krogh 1970, "Efficient Algorithms for Polynomial Interpolation + and Numerical Differentiation" + + The polynomial passes through all the pairs (xi,yi). One may additionally + specify a number of derivatives at each point xi; this is done by + repeating the value xi and specifying the derivatives as successive + yi values. + + Parameters + ---------- + xi : array-like, length N + known x-coordinates + yi : array-like, N by R + known y-coordinates, interpreted as vectors of length R, + or scalars if R=1 + x : scalar or array-like of length N + Point or points at which to evaluate the derivatives + der : integer or list + How many derivatives to extract; None for all potentially + nonzero derivatives (that is a number equal to the number + of points), or a list of derivatives to extract. This number + includes the function value as 0th derivative. + Returns + ------- + d : array + If the interpolator's values are R-dimensional then the + returned array will be the number of derivatives by N by R. + If x is a scalar, the middle dimension will be dropped; if + the yi are scalars then the last dimension will be dropped. + + Notes + ----- + Construction of the interpolating polynomial is a relatively expensive + process. If you want to evaluate it repeatedly consider using the class + KroghInterpolator (which is what this function uses). + """ + P = KroghInterpolator(xi, yi) + if der==0: + return P(x) + elif np.isscalar(der): + return P.derivative(x,der=der) + else: + return P.derivatives(x,der=np.amax(der)+1)[der] + +class BarycentricInterpolator(object): """The interpolating polynomial for a set of points Constructs a polynomial that passes through a given set of points. @@ -265,7 +327,7 @@ self.n = len(xi) self.xi = np.asarray(xi) if yi is not None and len(yi)!=len(self.xi): - raise ValueError, "yi dimensions do not match xi dimensions" + raise ValueError("yi dimensions do not match xi dimensions") self.set_yi(yi) self.wi = np.zeros(self.n) self.wi[0] = 1 @@ -296,13 +358,13 @@ self.vector_valued = False yi = yi[:,np.newaxis] elif len(yi.shape)>2: - raise ValueError, "y coordinates must be either scalars or vectors" + raise ValueError("y coordinates must be either scalars or vectors") else: self.vector_valued = True n, r = yi.shape if n!=len(self.xi): - raise ValueError, "yi dimensions do not match xi dimensions" + raise ValueError("yi dimensions do not match xi dimensions") self.yi = yi self.r = r @@ -325,23 +387,23 @@ """ if yi is not None: if self.yi is None: - raise ValueError, "No previous yi value to update!" + raise ValueError("No previous yi value to update!") yi = np.asarray(yi) if len(yi.shape)==1: if self.vector_valued: - raise ValueError, "Cannot extend dimension %d y vectors with scalars" % self.r + raise ValueError("Cannot extend dimension %d y vectors with scalars" % self.r) yi = yi[:,np.newaxis] elif len(yi.shape)>2: - raise ValueError, "y coordinates must be either scalars or vectors" + raise ValueError("y coordinates must be either scalars or vectors") else: n, r = yi.shape if r!=self.r: - raise ValueError, "Cannot extend dimension %d y vectors with dimension %d y vectors" % (self.r, r) + raise ValueError("Cannot extend dimension %d y vectors with dimension %d y vectors" % (self.r, r)) self.yi = np.vstack((self.yi,yi)) else: if self.yi is not None: - raise ValueError, "No update to yi provided!" + raise ValueError("No update to yi provided!") old_n = self.n self.xi = np.concatenate((self.xi,xi)) self.n = len(self.xi) @@ -392,9 +454,49 @@ return p[0] else: return p +def barycentric_interpolate(xi, yi, x): + """Convenience function for polynomial interpolation + Constructs a polynomial that passes through a given set of points, + then evaluates the polynomial. For reasons of numerical stability, + this function does not compute the coefficients of the polynomial. -class PiecewisePolynomial: + This function uses a "barycentric interpolation" method that treats + the problem as a special case of rational function interpolation. + This algorithm is quite stable, numerically, but even in a world of + exact computation, unless the x coordinates are chosen very + carefully - Chebyshev zeros (e.g. cos(i*pi/n)) are a good choice - + polynomial interpolation itself is a very ill-conditioned process + due to the Runge phenomenon. + + Based on Berrut and Trefethen 2004, "Barycentric Lagrange Interpolation". + + Parameters + ---------- + xi : array-like of length N + The x coordinates of the points the polynomial should pass through + yi : array-like N by R + The y coordinates of the points the polynomial should pass through; + if R>1 the polynomial is vector-valued. + x : scalar or array-like of length M + + Returns + ------- + y : scalar or array-like of length R or length M or M by R + The shape of y depends on the shape of x and whether the + interpolator is vector-valued or scalar-valued. + + Notes + ----- + + Construction of the interpolation weights is a relatively slow process. + If you want to call this many times with the same xi (but possibly + varying yi or x) you should use the class BarycentricInterpolator. + This is what this function uses internally. + """ + return BarycentricInterpolator(xi, yi)(x) + +class PiecewisePolynomial(object): """Piecewise polynomial curve specified by points and derivatives This class represents a curve that is a piecewise polynomial. It @@ -440,7 +542,7 @@ self.vector_valued = False self.r = 1 else: - raise ValueError, "Each derivative must be a vector, not a higher-rank array" + raise ValueError("Each derivative must be a vector, not a higher-rank array") self.xi = [xi[0]] self.yi = [yi0] @@ -467,7 +569,7 @@ n2 = min(n-n1,len(y2)) n1 = min(n-n2,len(y1)) if n1+n2!=n: - raise ValueError, "Point %g has %d derivatives, point %g has %d derivatives, but order %d requested" % (x1, len(y1), x2, len(y2), order) + raise ValueError("Point %g has %d derivatives, point %g has %d derivatives, but order %d requested" % (x1, len(y1), x2, len(y2), order)) assert n1<=len(y1) assert n2<=len(y2) @@ -500,15 +602,15 @@ yi = np.asarray(yi) if self.vector_valued: if (len(yi.shape)!=2 or yi.shape[1]!=self.r): - raise ValueError, "Each derivative must be a vector of length %d" % self.r + raise ValueError("Each derivative must be a vector of length %d" % self.r) else: if len(yi.shape)!=1: - raise ValueError, "Each derivative must be a scalar" + raise ValueError("Each derivative must be a scalar") if self.direction is None: self.direction = np.sign(xi-self.xi[-1]) elif (xi-self.xi[-1])*self.direction < 0: - raise ValueError, "x coordinates must be in the %d direction: %s" % (self.direction, self.xi) + raise ValueError("x coordinates must be in the %d direction: %s" % (self.direction, self.xi)) self.xi.append(xi) self.yi.append(yi) @@ -594,16 +696,13 @@ Notes ----- - This currently computes all derivatives of the curve segment - containing each x but returns only one. This is because the - number of nonzero derivatives that a segment can have depends - on the degree of the segment, which may vary. + This currently computes (using self.derivatives()) all derivatives + of the curve segment containing each x but returns only one. """ return self.derivatives(x,der=der+1)[der] def derivatives(self, x, der): - """Evaluate a derivative of the piecewise polynomial - + """Evaluate a derivative of the piecewise polynomial Parameters ---------- x : scalar or array-like of length N @@ -631,4 +730,46 @@ c = pos==i y[:,c] = self.polynomials[i].derivatives(x[c],der=der) return y - # FIXME: provide multiderivative finder + + +def piecewise_polynomial_interpolate(xi,yi,x,orders=None,der=0): + """Convenience function for piecewise polynomial interpolation + + Parameters + ---------- + xi : array-like of length N + a sorted list of x-coordinates + yi : list of lists of length N + yi[i] is the list of derivatives known at xi[i] + x : scalar or array-like of length M + orders : list of integers, or integer + a list of polynomial orders, or a single universal order + der : integer + which single derivative to extract + + Returns + ------- + y : scalar or array-like of length R or length M or M by R + + Notes + ----- + If orders is None, or orders[i] is None, then the degree of the + polynomial segment is exactly the degree required to match all i + available derivatives at both endpoints. If orders[i] is not None, + then some derivatives will be ignored. The code will try to use an + equal number of derivatives from each end; if the total number of + derivatives needed is odd, it will prefer the rightmost endpoint. If + not enough derivatives are available, an exception is raised. + + Construction of these piecewise polynomials can be an expensive process; + if you repeatedly evaluate the same polynomial, consider using the class + PiecewisePolynomial (which is what this function does). + """ + + P = PiecewisePolynomial(xi, yi, orders) + if der==0: + return P(x) + elif np.isscalar(der): + return P.derivative(x,der=der) + else: + return P.derivatives(x,der=np.amax(der)+1)[der] Modified: trunk/scipy/interpolate/tests/test_polyint.py =================================================================== --- trunk/scipy/interpolate/tests/test_polyint.py 2008-04-30 01:41:48 UTC (rev 4200) +++ trunk/scipy/interpolate/tests/test_polyint.py 2008-05-01 19:59:21 UTC (rev 4201) @@ -1,7 +1,8 @@ from scipy.testing import * -from scipy.interpolate import KroghInterpolator, \ - BarycentricInterpolator, PiecewisePolynomial +from scipy.interpolate import KroghInterpolator, krogh_interpolate, \ + BarycentricInterpolator, barycentric_interpolate, \ + PiecewisePolynomial, piecewise_polynomial_interpolate import scipy import numpy as np from scipy.interpolate import splrep, splev @@ -102,6 +103,11 @@ assert_array_equal(np.shape(P.derivatives([0])), (n,1,3)) assert_array_equal(np.shape(P.derivatives([0,1])), (n,2,3)) + def test_wrapper(self): + P = KroghInterpolator(self.xs,self.ys) + assert_almost_equal(P(self.test_xs),krogh_interpolate(self.xs,self.ys,self.test_xs)) + assert_almost_equal(P.derivative(self.test_xs,2),krogh_interpolate(self.xs,self.ys,self.test_xs,der=2)) + assert_almost_equal(P.derivatives(self.test_xs,2),krogh_interpolate(self.xs,self.ys,self.test_xs,der=[0,1])) class CheckBarycentric(TestCase): @@ -154,6 +160,9 @@ assert_array_equal(np.shape(P([0])), (1,1)) assert_array_equal(np.shape(P([0,1])), (2,1)) + def test_wrapper(self): + P = BarycentricInterpolator(self.xs,self.ys) + assert_almost_equal(P(self.test_xs),barycentric_interpolate(self.xs,self.ys,self.test_xs)) class CheckPiecewise(TestCase): def setUp(self): @@ -233,6 +242,12 @@ assert_array_equal(np.shape(P.derivative([0],1)), (1,3)) assert_array_equal(np.shape(P.derivative([0,1],1)), (2,3)) + def test_wrapper(self): + P = PiecewisePolynomial(self.xi,self.yi) + assert_almost_equal(P(self.test_xs),piecewise_polynomial_interpolate(self.xi,self.yi,self.test_xs)) + assert_almost_equal(P.derivative(self.test_xs,2),piecewise_polynomial_interpolate(self.xi,self.yi,self.test_xs,der=2)) + assert_almost_equal(P.derivatives(self.test_xs,2),piecewise_polynomial_interpolate(self.xi,self.yi,self.test_xs,der=[0,1])) + if __name__=='__main__': nose.run(argv=['', __file__]) From scipy-svn at scipy.org Thu May 1 16:01:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 May 2008 15:01:20 -0500 (CDT) Subject: [Scipy-svn] r4202 - trunk/scipy/interpolate Message-ID: <20080501200120.D153439C263@new.scipy.org> Author: peridot Date: 2008-05-01 15:01:18 -0500 (Thu, 01 May 2008) New Revision: 4202 Modified: trunk/scipy/interpolate/info.py Log: Module-level documentation for procedural versions Modified: trunk/scipy/interpolate/info.py =================================================================== --- trunk/scipy/interpolate/info.py 2008-05-01 19:59:21 UTC (rev 4201) +++ trunk/scipy/interpolate/info.py 2008-05-01 20:01:18 UTC (rev 4202) @@ -30,11 +30,14 @@ to compute unknown values of a univariate function. BarycentricInterpolator -- Compute with a numerically-stable version of the Lagrange interpolating polynomial. + barycentric_interpolate -- procedural interface to the above KroghInterpolator -- Compute with the Hermite interpolating polynomial (allows the specification of derivatives at some points). + krogh_interpolate -- procedural interface to the above PiecewisePolynomial -- Spline that is specified by giving positions and derivatives at every knot; allows high orders and efficient appending. + piecewise_polynomial_interpolate -- procedural interface to the above Interpolation Classes (multivariate) From scipy-svn at scipy.org Thu May 1 17:02:06 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 May 2008 16:02:06 -0500 (CDT) Subject: [Scipy-svn] r4203 - in trunk/scipy/interpolate: . tests Message-ID: <20080501210206.C8DC539C1FE@new.scipy.org> Author: peridot Date: 2008-05-01 16:02:04 -0500 (Thu, 01 May 2008) New Revision: 4203 Modified: trunk/scipy/interpolate/info.py trunk/scipy/interpolate/polyint.py trunk/scipy/interpolate/tests/test_polyint.py Log: Approximate Taylor polynomials. Modified: trunk/scipy/interpolate/info.py =================================================================== --- trunk/scipy/interpolate/info.py 2008-05-01 20:01:18 UTC (rev 4202) +++ trunk/scipy/interpolate/info.py 2008-05-01 21:02:04 UTC (rev 4203) @@ -48,6 +48,8 @@ Additional tools lagrange -- Compute the Lagrange interpolating polynomial. + approximate_taylor_polynomial -- compute an approximate Taylor polynomial for + a function using polynomial interpolation """ postpone_import = 1 Modified: trunk/scipy/interpolate/polyint.py =================================================================== --- trunk/scipy/interpolate/polyint.py 2008-05-01 20:01:18 UTC (rev 4202) +++ trunk/scipy/interpolate/polyint.py 2008-05-01 21:02:04 UTC (rev 4203) @@ -2,7 +2,7 @@ from scipy import factorial from numpy import poly1d -__all__ = ["KroghInterpolator", "krogh_interpolate", "BarycentricInterpolator", "barycentric_interpolate", "PiecewisePolynomial", "piecewise_polynomial_interpolate"] +__all__ = ["KroghInterpolator", "krogh_interpolate", "BarycentricInterpolator", "barycentric_interpolate", "PiecewisePolynomial", "piecewise_polynomial_interpolate","approximate_taylor_polynomial"] class KroghInterpolator(object): """The interpolating polynomial for a set of points @@ -289,6 +289,64 @@ else: return P.derivatives(x,der=np.amax(der)+1)[der] + + + +def approximate_taylor_polynomial(f,x,degree,scale,order=None): + """Estimate the Taylor polynomial of f at x by polynomial fitting + + A polynomial + Parameters + ---------- + f : callable + The function whose Taylor polynomial is sought. Should accept + a vector of x values. + x : scalar + The point at which the polynomial is to be evaluated. + degree : integer + The degree of the Taylor polynomial + scale : scalar + The width of the interval to use to evaluate the Taylor polynomial. + Function values spread over a range this wide are used to fit the + polynomial. Must be chosen carefully. + order : integer or None + The order of the polynomial to be used in the fitting; f will be + evaluated order+1 times. If None, use degree. + + Returns + ------- + p : poly1d + the Taylor polynomial (translated to the origin, so that + for example p(0)=f(x)). + + Notes + ----- + The appropriate choice of "scale" is a tradeoff - too large and the + function differs from its Taylor polynomial too much to get a good + answer, too small and roundoff errors overwhelm the higher-order terms. + The algorithm used becomes numerically unstable around order 30 even + under ideal circumstances. + + Choosing order somewhat larger than degree may improve the higher-order + terms. + """ + if order is None: + order=degree + + n = order+1 + # Choose n points that cluster near the endpoints of the interval in + # a way that avoids the Runge phenomenon. Ensure, by including the + # endpoint or not as appropriate, that one point always falls at x + # exactly. + xs = scale*np.cos(np.linspace(0,np.pi,n,endpoint=n%1)) + x + + P = KroghInterpolator(xs, f(xs)) + d = P.derivatives(x,der=degree+1) + + return np.poly1d((d/factorial(np.arange(degree+1)))[::-1]) + + + class BarycentricInterpolator(object): """The interpolating polynomial for a set of points @@ -496,6 +554,7 @@ """ return BarycentricInterpolator(xi, yi)(x) + class PiecewisePolynomial(object): """Piecewise polynomial curve specified by points and derivatives Modified: trunk/scipy/interpolate/tests/test_polyint.py =================================================================== --- trunk/scipy/interpolate/tests/test_polyint.py 2008-05-01 20:01:18 UTC (rev 4202) +++ trunk/scipy/interpolate/tests/test_polyint.py 2008-05-01 21:02:04 UTC (rev 4203) @@ -2,7 +2,8 @@ from scipy.testing import * from scipy.interpolate import KroghInterpolator, krogh_interpolate, \ BarycentricInterpolator, barycentric_interpolate, \ - PiecewisePolynomial, piecewise_polynomial_interpolate + PiecewisePolynomial, piecewise_polynomial_interpolate, \ + approximate_taylor_polynomial import scipy import numpy as np from scipy.interpolate import splrep, splev @@ -109,6 +110,14 @@ assert_almost_equal(P.derivative(self.test_xs,2),krogh_interpolate(self.xs,self.ys,self.test_xs,der=2)) assert_almost_equal(P.derivatives(self.test_xs,2),krogh_interpolate(self.xs,self.ys,self.test_xs,der=[0,1])) +class CheckTaylor(TestCase): + def test_exponential(self): + degree = 5 + p = approximate_taylor_polynomial(np.exp, 0, degree, 1, 15) + for i in xrange(degree+1): + assert_almost_equal(p(0),1) + p = p.deriv() + assert_almost_equal(p(0),0) class CheckBarycentric(TestCase): def setUp(self): From scipy-svn at scipy.org Sat May 3 02:22:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 3 May 2008 01:22:46 -0500 (CDT) Subject: [Scipy-svn] r4204 - in trunk/scipy: fftpack integrate interpolate lib/blas lib/lapack linalg optimize sparse/linalg/eigen/arpack sparse/linalg/isolve special stats Message-ID: <20080503062246.8C89B39C0A1@new.scipy.org> Author: cdavid Date: 2008-05-03 01:22:28 -0500 (Sat, 03 May 2008) New Revision: 4204 Modified: trunk/scipy/fftpack/SConstruct trunk/scipy/integrate/SConstruct trunk/scipy/interpolate/SConstruct trunk/scipy/lib/blas/SConstruct trunk/scipy/lib/lapack/SConstruct trunk/scipy/linalg/SConstruct trunk/scipy/optimize/SConstruct trunk/scipy/sparse/linalg/eigen/arpack/SConstruct trunk/scipy/sparse/linalg/isolve/SConstruct trunk/scipy/special/SConstruct trunk/scipy/stats/SConstruct Log: Explicitly initialize numpyf2py tool when needed: numscons does not load it by default. Modified: trunk/scipy/fftpack/SConstruct =================================================================== --- trunk/scipy/fftpack/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/fftpack/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Apr 22 01:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -7,6 +7,7 @@ from numscons import CheckFFT, IsMKL, IsFFTW2, IsFFTW3 env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) Modified: trunk/scipy/integrate/SConstruct =================================================================== --- trunk/scipy/integrate/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/integrate/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Mar 11 04:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin import warnings @@ -7,6 +7,7 @@ from numscons import GetNumpyEnvironment, CheckF77Clib, CheckF77BLAS env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') # Configuration config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib, Modified: trunk/scipy/interpolate/SConstruct =================================================================== --- trunk/scipy/interpolate/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/interpolate/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Apr 22 01:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -6,6 +6,7 @@ from numscons import GetNumpyEnvironment, CheckF77Clib env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib}) if not config.CheckF77Clib(): Modified: trunk/scipy/lib/blas/SConstruct =================================================================== --- trunk/scipy/lib/blas/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/lib/blas/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Wed Mar 05 03:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python import os @@ -15,6 +15,8 @@ from scons_support import do_generate_fake_interface, generate_interface_emitter env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') + env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) #if os.name == 'nt': # # NT needs the pythonlib to run any code importing Python.h, including Modified: trunk/scipy/lib/lapack/SConstruct =================================================================== --- trunk/scipy/lib/lapack/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/lib/lapack/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Apr 22 01:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python import os @@ -17,6 +17,7 @@ generate_interface_emitter env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) #if os.name == 'nt': # # NT needs the pythonlib to run any code importing Python.h, including Modified: trunk/scipy/linalg/SConstruct =================================================================== --- trunk/scipy/linalg/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/linalg/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Apr 22 01:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python import os @@ -19,6 +19,7 @@ # generate_config_header, generate_config_header_emitter env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) # XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) Modified: trunk/scipy/optimize/SConstruct =================================================================== --- trunk/scipy/optimize/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/optimize/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Apr 22 01:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python import os @@ -12,6 +12,7 @@ from numscons import write_info env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') env.Append(CPPPATH = get_numpy_include_dirs()) env.Append(CPPPATH = env['F2PYINCLUDEDIR']) #if os.name == 'nt': Modified: trunk/scipy/sparse/linalg/eigen/arpack/SConstruct =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/sparse/linalg/eigen/arpack/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -14,6 +14,7 @@ config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK, 'CheckF77Clib' : CheckF77Clib}) +env.Tool('numpyf2py') #----------------- # Checking Lapack #----------------- Modified: trunk/scipy/sparse/linalg/isolve/SConstruct =================================================================== --- trunk/scipy/sparse/linalg/isolve/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/sparse/linalg/isolve/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Wed Mar 05 06:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin, splitext @@ -10,6 +10,7 @@ from numscons import write_info env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') env.Append(CPPPATH = [get_numpy_include_dirs(), env['F2PYINCLUDEDIR']]) #if os.name == 'nt': # # NT needs the pythonlib to run any code importing Python.h, including Modified: trunk/scipy/special/SConstruct =================================================================== --- trunk/scipy/special/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/special/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Wed Mar 05 09:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin, basename as pbasename import sys @@ -11,6 +11,8 @@ env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') + env.AppendUnique(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) Modified: trunk/scipy/stats/SConstruct =================================================================== --- trunk/scipy/stats/SConstruct 2008-05-01 21:02:04 UTC (rev 4203) +++ trunk/scipy/stats/SConstruct 2008-05-03 06:22:28 UTC (rev 4204) @@ -1,4 +1,4 @@ -# Last Change: Tue Apr 22 01:00 PM 2008 J +# Last Change: Sat May 03 02:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -7,6 +7,8 @@ env = GetNumpyEnvironment(ARGUMENTS) +t = env.Tool('numpyf2py') + env.AppendUnique(CPPPATH = [get_numpy_include_dirs()]) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) From scipy-svn at scipy.org Sun May 4 09:13:29 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:13:29 -0500 (CDT) Subject: [Scipy-svn] r4205 - branches Message-ID: <20080504131329.74DB339C338@new.scipy.org> Author: cdavid Date: 2008-05-04 08:13:06 -0500 (Sun, 04 May 2008) New Revision: 4205 Removed: branches/scipy.scons/ Log: Remove scipy.scons branch: all changes are now included in svn trunk From scipy-svn at scipy.org Sun May 4 09:14:22 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:14:22 -0500 (CDT) Subject: [Scipy-svn] r4206 - branches Message-ID: <20080504131422.1387739C338@new.scipy.org> Author: cdavid Date: 2008-05-04 08:14:18 -0500 (Sun, 04 May 2008) New Revision: 4206 Removed: branches/build_with_scons/ Log: Remove build_with_scons branch: everything worthwhile is now included in main trunk From scipy-svn at scipy.org Sun May 4 09:14:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:14:56 -0500 (CDT) Subject: [Scipy-svn] r4207 - branches Message-ID: <20080504131456.72F9D39C338@new.scipy.org> Author: cdavid Date: 2008-05-04 08:14:52 -0500 (Sun, 04 May 2008) New Revision: 4207 Removed: branches/cleanconfig_rtm/ Log: From scipy-svn at scipy.org Sun May 4 09:15:27 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:15:27 -0500 (CDT) Subject: [Scipy-svn] r4208 - branches Message-ID: <20080504131527.295F839C428@new.scipy.org> Author: cdavid Date: 2008-05-04 08:15:23 -0500 (Sun, 04 May 2008) New Revision: 4208 Removed: branches/sparse_build_reduce_mem/ Log: From scipy-svn at scipy.org Sun May 4 09:15:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:15:53 -0500 (CDT) Subject: [Scipy-svn] r4209 - branches Message-ID: <20080504131553.82EEA39C428@new.scipy.org> Author: cdavid Date: 2008-05-04 08:15:47 -0500 (Sun, 04 May 2008) New Revision: 4209 Removed: branches/cdavid_pyem_axis_support/ Log: From scipy-svn at scipy.org Sun May 4 09:23:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:23:36 -0500 (CDT) Subject: [Scipy-svn] r4210 - branches Message-ID: <20080504132336.3201C39C428@new.scipy.org> Author: cdavid Date: 2008-05-04 08:23:30 -0500 (Sun, 04 May 2008) New Revision: 4210 Added: branches/refactor_fft/ Log: Start working on branch to refactor fft Copied: branches/refactor_fft (from rev 4209, trunk) From scipy-svn at scipy.org Sun May 4 09:24:47 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:24:47 -0500 (CDT) Subject: [Scipy-svn] r4211 - trunk Message-ID: <20080504132447.22ED139C42A@new.scipy.org> Author: cdavid Date: 2008-05-04 08:24:42 -0500 (Sun, 04 May 2008) New Revision: 4211 Modified: trunk/ Log: Initialized merge tracking via "svnmerge" with revisions "1-4210" from http://svn.scipy.org/svn/scipy/branches/refactor_fft Property changes on: trunk ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 + /branches/build_with_scons:1-3868 /branches/refactor_fft:1-4210 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 From scipy-svn at scipy.org Sun May 4 09:25:48 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 4 May 2008 08:25:48 -0500 (CDT) Subject: [Scipy-svn] r4212 - branches/refactor_fft Message-ID: <20080504132548.9D6A639C42A@new.scipy.org> Author: cdavid Date: 2008-05-04 08:25:43 -0500 (Sun, 04 May 2008) New Revision: 4212 Modified: branches/refactor_fft/ Log: Initialized merge tracking via "svnmerge" with revisions "1-4211" from http://svn.scipy.org/svn/scipy/trunk Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4211 From scipy-svn at scipy.org Mon May 5 02:52:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 01:52:32 -0500 (CDT) Subject: [Scipy-svn] r4213 - branches/refactor_fft/scipy/fftpack Message-ID: <20080505065232.85C3739C240@new.scipy.org> Author: cdavid Date: 2008-05-05 01:52:28 -0500 (Mon, 05 May 2008) New Revision: 4213 Modified: branches/refactor_fft/scipy/fftpack/SConstruct Log: Detect F77 runtime in fftpack scons script, because we will need it when using c++. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-04 13:25:43 UTC (rev 4212) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 06:52:28 UTC (rev 4213) @@ -1,10 +1,11 @@ -# Last Change: Sat May 03 02:00 PM 2008 J +# Last Change: Mon May 05 03:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, write_info from numscons import CheckFFT, IsMKL, IsFFTW2, IsFFTW3 +from numscons import CheckF77Clib env = GetNumpyEnvironment(ARGUMENTS) env.Tool('numpyf2py') @@ -13,8 +14,11 @@ env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) # Check fft implementation -config = env.NumpyConfigure(custom_tests = {'CheckFFT': CheckFFT}) +config = env.NumpyConfigure(custom_tests = {'CheckFFT': CheckFFT, + 'CheckF77Clib' : CheckF77Clib}) has_fft = config.CheckFFT() +if not config.CheckF77Clib(): + raise Exception("Could not get f77/c++ link information") config.Finish() write_info(env) From scipy-svn at scipy.org Mon May 5 03:24:59 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 02:24:59 -0500 (CDT) Subject: [Scipy-svn] r4214 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080505072459.0ADF539C072@new.scipy.org> Author: cdavid Date: 2008-05-05 02:24:48 -0500 (Mon, 05 May 2008) New Revision: 4214 Added: branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx Removed: branches/refactor_fft/scipy/fftpack/src/zfft.c branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.c branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.c Modified: branches/refactor_fft/scipy/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Put zfft API + djbfft/fftw3 implementation into c++. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 06:52:28 UTC (rev 4213) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 07:24:48 UTC (rev 4214) @@ -40,7 +40,7 @@ env.PrependUnique(LIBPATH = env['build_dir']) # Build _fftpack -src = ['src/zfft.c','src/drfft.c','src/zrfft.c', 'src/zfftnd.c', 'fftpack.pyf'] +src = ['src/zfft.cxx','src/drfft.c','src/zrfft.c', 'src/zfftnd.c', 'fftpack.pyf'] env.NumpyPythonExtension('_fftpack', src) # Build convolve Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 06:52:28 UTC (rev 4213) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 07:24:48 UTC (rev 4214) @@ -23,7 +23,7 @@ config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) - sources = ['fftpack.pyf','src/zfft.c','src/drfft.c','src/zrfft.c', + sources = ['fftpack.pyf','src/zfft.cxx','src/drfft.c','src/zrfft.c', 'src/zfftnd.c'] config.add_extension('_fftpack', @@ -31,8 +31,8 @@ libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], depends=['src/zfft_djbfft.c', 'src/zfft_fftpack.c', 'src/zfft_fftw.c', - 'src/zfft_fftw3.c', 'src/zfft_mkl.c', - 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', + 'src/zfft_fftw3.cxx', 'src/zfft_mkl.c', + 'src/drfft_djbfft.cxx', 'src/drfft_fftpack.c', 'src/drfft_fftw3.c', 'src/drfft_fftw.c', 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', 'src/zfftnd_fftw3.c', 'src/zfftnd_mkl.c', Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-05 06:52:28 UTC (rev 4213) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-05 07:24:48 UTC (rev 4214) @@ -31,13 +31,19 @@ #endif #ifdef SCIPY_DJBFFT_H +#ifdef __cplusplus +extern "C" { +#endif #define WITH_DJBFFT #define complex8 complex_double #define COMPLEX8_H #include #include #include +#ifdef __cplusplus +} #endif +#endif #ifdef SCIPY_MKL_H #define WITH_MKL Deleted: branches/refactor_fft/scipy/fftpack/src/zfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.c 2008-05-05 06:52:28 UTC (rev 4213) +++ branches/refactor_fft/scipy/fftpack/src/zfft.c 2008-05-05 07:24:48 UTC (rev 4214) @@ -1,76 +0,0 @@ -/* - Interface to various FFT libraries. - Double complex FFT and IFFT. - Author: Pearu Peterson, August 2002 - */ - -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_PUBLIC_API(name) \ -void destroy_zfft_cache(void)\ -{\ - destroy_z##name##_caches();\ -}\ -\ -void zfft(complex_double *inout, int n, \ - int direction, int howmany, int normalize)\ -{\ - zfft_##name(inout, n, direction, howmany, normalize);\ -} - -/* ************** Definition of backend specific functions ********* */ - -/* - * To add a backend : - * - create a file zfft_name.c, where you define a function zfft_name where - * name is the name of your backend. If you do not use the GEN_CACHE macro, - * you will need to define a function void destroy_zname_caches(void), - * which can do nothing - * - in zfft.c, include the zfft_name.c file, and add the 3 following lines - * just after it: - * #ifndef WITH_DJBFFT - * GEN_PUBLIC_API(name) - * #endif - */ - -#ifdef WITH_FFTW3 - #include "zfft_fftw3.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw3) - #endif -#elif defined WITH_FFTW - #include "zfft_fftw.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw) - #endif -#elif defined WITH_MKL - #include "zfft_mkl.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(mkl) - #endif -#else /* Use fftpack by default */ - #include "zfft_fftpack.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftpack) - #endif -#endif - -/* - * djbfft must be used at the end, because it needs another backend (defined - * above) for non 2^n * size - */ -#ifdef WITH_DJBFFT - #include "zfft_djbfft.c" - void destroy_zfft_cache(void) - { - destroy_zdjbfft_caches(); - zfft_def_destroy_cache(); - } - void zfft(complex_double *inout, int n, - int direction, int howmany, int normalize) - { - zfft_djbfft(inout, n, direction, howmany, normalize); - } -#endif Copied: branches/refactor_fft/scipy/fftpack/src/zfft.cxx (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfft.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.c 2008-05-04 13:25:43 UTC (rev 4212) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 07:24:48 UTC (rev 4214) @@ -0,0 +1,76 @@ +/* + Interface to various FFT libraries. + Double complex FFT and IFFT. + Author: Pearu Peterson, August 2002 + */ + +#include "fftpack.h" + +/* The following macro convert private backend specific function to the public + * functions exported by the module */ +#define GEN_PUBLIC_API(name) \ +extern "C" void destroy_zfft_cache(void)\ +{\ + destroy_z##name##_caches();\ +}\ +\ +extern "C" void zfft(complex_double *inout, int n, \ + int direction, int howmany, int normalize)\ +{\ + zfft_##name(inout, n, direction, howmany, normalize);\ +} + +/* ************** Definition of backend specific functions ********* */ + +/* + * To add a backend : + * - create a file zfft_name.c, where you define a function zfft_name where + * name is the name of your backend. If you do not use the GEN_CACHE macro, + * you will need to define a function void destroy_zname_caches(void), + * which can do nothing + * - in zfft.c, include the zfft_name.c file, and add the 3 following lines + * just after it: + * #ifndef WITH_DJBFFT + * GEN_PUBLIC_API(name) + * #endif + */ + +#ifdef WITH_FFTW3 + #include "zfft_fftw3.cxx" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(fftw3) + #endif +#elif defined WITH_FFTW + #include "zfft_fftw.c" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(fftw) + #endif +#elif defined WITH_MKL + #include "zfft_mkl.c" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(mkl) + #endif +#else /* Use fftpack by default */ + #include "zfft_fftpack.c" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(fftpack) + #endif +#endif + +/* + * djbfft must be used at the end, because it needs another backend (defined + * above) for non 2^n * size + */ +#ifdef WITH_DJBFFT + #include "zfft_djbfft.cxx" + extern "C" void destroy_zfft_cache(void) + { + destroy_zdjbfft_caches(); + zfft_def_destroy_cache(); + } + extern "C" void zfft(complex_double *inout, int n, + int direction, int howmany, int normalize) + { + zfft_djbfft(inout, n, direction, howmany, normalize); + } +#endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.c 2008-05-05 06:52:28 UTC (rev 4213) +++ branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.c 2008-05-05 07:24:48 UTC (rev 4214) @@ -1,151 +0,0 @@ -/* -* DJBFFT only implements size 2^N ! -* -* zfft_def and zfft_def_destroy_cache are the functions -* used for size different than 2^N -*/ -#ifdef WITH_FFTWORK -#define zfft_def zfft_fftwork -#define zfft_def_destroy_cache destroy_zfftwork_cache -#elif defined WITH_FFTW3 -#define zfft_def zfft_fftw3 -#define zfft_def_destroy_cache destroy_zfftw3_caches -#elif defined WITH_FFTW -#define zfft_def zfft_fftw -#define zfft_def_destroy_cache destroy_zfftw_caches -#else -#define zfft_def zfft_fftpack -#define zfft_def_destroy_cache destroy_zfftpack_caches -#endif - -GEN_CACHE(zdjbfft,(int n) - ,unsigned int* f; - double* ptr; - ,caches_zdjbfft[i].n==n - ,caches_zdjbfft[id].f = (unsigned int*)malloc(sizeof(unsigned int)*(n)); - caches_zdjbfft[id].ptr = (double*)malloc(sizeof(double)*(2*n)); - fftfreq_ctable(caches_zdjbfft[id].f,n); - for(i=0;i0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_UNALIGNED); - , - fftw_destroy_plan(caches_zfftw3[id].plan); - fftw_free(caches_zfftw3[id].wrk); - ,10) - -static void zfft_fftw3(complex_double * inout, int n, int dir, int -howmany, int normalize) -{ - fftw_complex *ptr = (fftw_complex*)inout; - fftw_complex *ptrm; - fftw_plan plan = NULL; - double factor = 1./n; - - int i; - - plan = caches_zfftw3[get_cache_id_zfftw3(n, dir)].plan; - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - fftw_execute_dft(plan, ptr, ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - fftw_execute_dft(plan, ptr, ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr =(fftw_complex*)inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) *= factor; - *((double *) (ptr++) + 1) *= factor; - } - } -} -#if 0 -GEN_CACHE(zfftw3,(int n,int d) - ,int direction; - fftw_plan plan; - fftw_complex* ptr; - ,((caches_zfftw3[i].n==n) && - (caches_zfftw3[i].direction==d)) - ,caches_zfftw3[id].direction = d; - caches_zfftw3[id].ptr = fftw_malloc(sizeof(fftw_complex)*(n)); - caches_zfftw3[id].plan = fftw_plan_dft_1d(n, caches_zfftw3[id].ptr, - caches_zfftw3[id].ptr, - (d>0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE); - ,fftw_destroy_plan(caches_zfftw3[id].plan); - fftw_free(caches_zfftw3[id].ptr); - ,10) - -static void zfft_fftw3(complex_double * inout, int n, int dir, int -howmany, int normalize) -{ - complex_double *ptr = inout; - fftw_complex *ptrm = NULL; - fftw_plan plan = NULL; - - int i; - - plan = caches_zfftw3[get_cache_id_zfftw3(n, dir)].plan; - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - ptrm = - caches_zfftw3[get_cache_id_zfftw3(n, dir)].ptr; - memcpy(ptrm, ptr, sizeof(double) * 2 * n); - fftw_execute(plan); - memcpy(ptr, ptrm, sizeof(double) * 2 * n); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - ptrm = - caches_zfftw3[get_cache_id_zfftw3(n, dir)].ptr; - memcpy(ptrm, ptr, sizeof(double) * 2 * n); - fftw_execute(plan); - memcpy(ptr, ptrm, sizeof(double) * 2 * n); - } - break; - - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} -#endif Copied: branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.c 2008-05-04 13:25:43 UTC (rev 4212) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 07:24:48 UTC (rev 4214) @@ -0,0 +1,120 @@ +/* This cache uses FFTW_MEASURE for the plans, and do not copy the data. */ +GEN_CACHE(zfftw3,(int n,int d) + ,int direction; + fftw_plan plan; + fftw_complex *wrk; + ,((caches_zfftw3[i].n==n) && + (caches_zfftw3[i].direction==d)) + ,caches_zfftw3[id].direction = d; + /* This working buffer is only used to compute the plan: we need it + since FFTW_MEASURE destroys its input when computing a plan */ + caches_zfftw3[id].wrk = (fftw_complex*)fftw_malloc(n * sizeof(double) * 2); + caches_zfftw3[id].plan = fftw_plan_dft_1d(n, + caches_zfftw3[id].wrk, + caches_zfftw3[id].wrk, + (d>0?FFTW_FORWARD:FFTW_BACKWARD), + FFTW_ESTIMATE | FFTW_UNALIGNED); + , + fftw_destroy_plan(caches_zfftw3[id].plan); + fftw_free(caches_zfftw3[id].wrk); + ,10) + +static void zfft_fftw3(complex_double * inout, int n, int dir, int +howmany, int normalize) +{ + fftw_complex *ptr = (fftw_complex*)inout; + fftw_complex *ptrm; + fftw_plan plan = NULL; + double factor = 1./n; + + int i; + + plan = caches_zfftw3[get_cache_id_zfftw3(n, dir)].plan; + + switch (dir) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + fftw_execute_dft(plan, ptr, ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + fftw_execute_dft(plan, ptr, ptr); + } + break; + + default: + fprintf(stderr, "zfft: invalid dir=%d\n", dir); + } + + if (normalize) { + ptr =(fftw_complex*)inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) *= factor; + *((double *) (ptr++) + 1) *= factor; + } + } +} +#if 0 +GEN_CACHE(zfftw3,(int n,int d) + ,int direction; + fftw_plan plan; + fftw_complex* ptr; + ,((caches_zfftw3[i].n==n) && + (caches_zfftw3[i].direction==d)) + ,caches_zfftw3[id].direction = d; + caches_zfftw3[id].ptr = fftw_malloc(sizeof(fftw_complex)*(n)); + caches_zfftw3[id].plan = fftw_plan_dft_1d(n, caches_zfftw3[id].ptr, + caches_zfftw3[id].ptr, + (d>0?FFTW_FORWARD:FFTW_BACKWARD), + FFTW_ESTIMATE); + ,fftw_destroy_plan(caches_zfftw3[id].plan); + fftw_free(caches_zfftw3[id].ptr); + ,10) + +static void zfft_fftw3(complex_double * inout, int n, int dir, int +howmany, int normalize) +{ + complex_double *ptr = inout; + fftw_complex *ptrm = NULL; + fftw_plan plan = NULL; + + int i; + + plan = caches_zfftw3[get_cache_id_zfftw3(n, dir)].plan; + + switch (dir) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + ptrm = + caches_zfftw3[get_cache_id_zfftw3(n, dir)].ptr; + memcpy(ptrm, ptr, sizeof(double) * 2 * n); + fftw_execute(plan); + memcpy(ptr, ptrm, sizeof(double) * 2 * n); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + ptrm = + caches_zfftw3[get_cache_id_zfftw3(n, dir)].ptr; + memcpy(ptrm, ptr, sizeof(double) * 2 * n); + fftw_execute(plan); + memcpy(ptr, ptrm, sizeof(double) * 2 * n); + } + break; + + default: + fprintf(stderr, "zfft: invalid dir=%d\n", dir); + } + + if (normalize) { + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= n; + *((double *) (ptr++) + 1) /= n; + } + } +} +#endif From scipy-svn at scipy.org Mon May 5 03:26:54 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 02:26:54 -0500 (CDT) Subject: [Scipy-svn] r4215 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080505072654.9C12B39C072@new.scipy.org> Author: cdavid Date: 2008-05-05 02:26:51 -0500 (Mon, 05 May 2008) New Revision: 4215 Modified: branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx Log: Cosmetic changes to zfft fftw3 implementation. Modified: branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 07:24:48 UTC (rev 4214) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 07:26:51 UTC (rev 4215) @@ -23,9 +23,8 @@ howmany, int normalize) { fftw_complex *ptr = (fftw_complex*)inout; - fftw_complex *ptrm; fftw_plan plan = NULL; - double factor = 1./n; + double factor = 1./n; int i; @@ -56,65 +55,3 @@ } } } -#if 0 -GEN_CACHE(zfftw3,(int n,int d) - ,int direction; - fftw_plan plan; - fftw_complex* ptr; - ,((caches_zfftw3[i].n==n) && - (caches_zfftw3[i].direction==d)) - ,caches_zfftw3[id].direction = d; - caches_zfftw3[id].ptr = fftw_malloc(sizeof(fftw_complex)*(n)); - caches_zfftw3[id].plan = fftw_plan_dft_1d(n, caches_zfftw3[id].ptr, - caches_zfftw3[id].ptr, - (d>0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE); - ,fftw_destroy_plan(caches_zfftw3[id].plan); - fftw_free(caches_zfftw3[id].ptr); - ,10) - -static void zfft_fftw3(complex_double * inout, int n, int dir, int -howmany, int normalize) -{ - complex_double *ptr = inout; - fftw_complex *ptrm = NULL; - fftw_plan plan = NULL; - - int i; - - plan = caches_zfftw3[get_cache_id_zfftw3(n, dir)].plan; - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - ptrm = - caches_zfftw3[get_cache_id_zfftw3(n, dir)].ptr; - memcpy(ptrm, ptr, sizeof(double) * 2 * n); - fftw_execute(plan); - memcpy(ptr, ptrm, sizeof(double) * 2 * n); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - ptrm = - caches_zfftw3[get_cache_id_zfftw3(n, dir)].ptr; - memcpy(ptrm, ptr, sizeof(double) * 2 * n); - fftw_execute(plan); - memcpy(ptr, ptrm, sizeof(double) * 2 * n); - } - break; - - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} -#endif From scipy-svn at scipy.org Mon May 5 04:06:34 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 03:06:34 -0500 (CDT) Subject: [Scipy-svn] r4216 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080505080634.5172A39C11C@new.scipy.org> Author: cdavid Date: 2008-05-05 03:06:28 -0500 (Mon, 05 May 2008) New Revision: 4216 Added: branches/refactor_fft/scipy/fftpack/src/cycliccache.h Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx Log: Use C++ cyclic cache implementation for zfft fftw3. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 07:26:51 UTC (rev 4215) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 08:06:28 UTC (rev 4216) @@ -30,9 +30,9 @@ sources=sources, libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/zfft_djbfft.c', 'src/zfft_fftpack.c', 'src/zfft_fftw.c', + depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.c', 'src/zfft_fftw.c', 'src/zfft_fftw3.cxx', 'src/zfft_mkl.c', - 'src/drfft_djbfft.cxx', 'src/drfft_fftpack.c', + 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', 'src/drfft_fftw3.c', 'src/drfft_fftw.c', 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', 'src/zfftnd_fftw3.c', 'src/zfftnd_mkl.c', Added: branches/refactor_fft/scipy/fftpack/src/cycliccache.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/cycliccache.h 2008-05-05 07:26:51 UTC (rev 4215) +++ branches/refactor_fft/scipy/fftpack/src/cycliccache.h 2008-05-05 08:06:28 UTC (rev 4216) @@ -0,0 +1,100 @@ +#ifndef _CYCLIC_CACHE_H_ +#define _CYCLIC_CACHE_H_ + +namespace fft { + +class CacheId { + public: + CacheId(int n) : m_n(n) {}; + virtual ~CacheId() {}; + + virtual bool operator==(const CacheId& other) const + { + return is_equal(other); + }; + + virtual bool is_equal(const CacheId& other) const + { + return m_n == other.m_n; + }; + + public: + int m_n; + +}; + +template +class Cache { + public: + Cache() {}; + Cache(const T& id) : m_id(id) {}; + virtual ~Cache() {}; + + virtual bool operator==(const Cache& other) const + { + return other.m_id == m_id; + }; + + public: + T m_id; +}; + +template +class CacheManager { + public: + CacheManager(int n) : + m_n(n), + m_curn(0), + m_last(0) + { + m_cache = new U*[n]; + + }; + + virtual ~CacheManager() + { + int i; + + for (i = 0; i < m_curn; ++i) { + delete m_cache[i]; + } + + delete[] m_cache; + } + + virtual U* get_cache(const T& id) + { + int i; + + /* Look in the current cache */ + for (i = 0; i < m_curn; ++i) { + if ( m_cache[i]->m_id == id) { + m_last = i; + return m_cache[i]; + } + } + + /* If still space, create a new cache */ + if (m_curn < m_n) { + i = m_curn; + ++m_curn; + } else { + i = (m_last < m_n - 1) ? m_last + 1 : 0; + delete m_cache[i]; + } + + m_cache[i] = new U(id); + m_last = i; + return m_cache[i]; + }; + + private: + U** m_cache; + int m_n; + int m_curn; + int m_last; +}; + +} + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 07:26:51 UTC (rev 4215) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 08:06:28 UTC (rev 4216) @@ -1,45 +1,104 @@ -/* This cache uses FFTW_MEASURE for the plans, and do not copy the data. */ -GEN_CACHE(zfftw3,(int n,int d) - ,int direction; - fftw_plan plan; - fftw_complex *wrk; - ,((caches_zfftw3[i].n==n) && - (caches_zfftw3[i].direction==d)) - ,caches_zfftw3[id].direction = d; - /* This working buffer is only used to compute the plan: we need it - since FFTW_MEASURE destroys its input when computing a plan */ - caches_zfftw3[id].wrk = (fftw_complex*)fftw_malloc(n * sizeof(double) * 2); - caches_zfftw3[id].plan = fftw_plan_dft_1d(n, - caches_zfftw3[id].wrk, - caches_zfftw3[id].wrk, - (d>0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_UNALIGNED); - , - fftw_destroy_plan(caches_zfftw3[id].plan); - fftw_free(caches_zfftw3[id].wrk); - ,10) +#include -static void zfft_fftw3(complex_double * inout, int n, int dir, int -howmany, int normalize) +#include "cycliccache.h" + +using namespace fft; + +class FFTW3CacheId : public CacheId { + public: + FFTW3CacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; + + virtual bool operator==(const FFTW3CacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const FFTW3CacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_dir == other.m_dir && th->is_equal(*ot); + } + + public: + int m_dir; +}; + +class FFTW3Cache : public Cache { + public: + FFTW3Cache(const FFTW3CacheId& id); + virtual ~FFTW3Cache(); + + int compute(fftw_complex* inout) + { + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; +}; + +FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) +: Cache(id) { + m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk == NULL) { + goto fail_wrk; + } + + m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, + (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), + FFTW_ESTIMATE | FFTW_UNALIGNED); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return ; + +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +FFTW3Cache::~FFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk); +} + +static CacheManager cmgr(10); + +/* stub to make GEN_PUBLIC_API happy */ +static void destroy_zfftw3_caches() +{ +} + +static void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, + int normalize) +{ fftw_complex *ptr = (fftw_complex*)inout; - fftw_plan plan = NULL; double factor = 1./n; + FFTW3Cache *cache; int i; - plan = caches_zfftw3[get_cache_id_zfftw3(n, dir)].plan; + cache = cmgr.get_cache(FFTW3CacheId(n, dir)); switch (dir) { case 1: for (i = 0; i < howmany; ++i, ptr += n) { - fftw_execute_dft(plan, ptr, ptr); + cache->compute(ptr); } break; case -1: for (i = 0; i < howmany; ++i, ptr += n) { - fftw_execute_dft(plan, ptr, ptr); + cache->compute(ptr); } break; @@ -48,7 +107,7 @@ } if (normalize) { - ptr =(fftw_complex*)inout; + ptr =(fftw_complex*)inout; for (i = n * howmany - 1; i >= 0; --i) { *((double *) (ptr)) *= factor; *((double *) (ptr++) + 1) *= factor; From scipy-svn at scipy.org Mon May 5 05:26:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 04:26:46 -0500 (CDT) Subject: [Scipy-svn] r4217 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080505092646.5676939C498@new.scipy.org> Author: cdavid Date: 2008-05-05 04:26:41 -0500 (Mon, 05 May 2008) New Revision: 4217 Modified: branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx Log: Use C++ CacheManager for zfft, djbfft implementation. Modified: branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx 2008-05-05 08:06:28 UTC (rev 4216) +++ branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx 2008-05-05 09:26:41 UTC (rev 4217) @@ -18,28 +18,168 @@ #define zfft_def_destroy_cache destroy_zfftpack_caches #endif -GEN_CACHE(zdjbfft,(int n) - ,unsigned int* f; - double* ptr; - ,caches_zdjbfft[i].n==n - ,caches_zdjbfft[id].f = (unsigned int*)malloc(sizeof(unsigned int)*(n)); - caches_zdjbfft[id].ptr = (double*)malloc(sizeof(double)*(2*n)); - fftfreq_ctable(caches_zdjbfft[id].f,n); - for(i=0;i { + public: + DJBFFTCache(const DJBFFTCacheId& id); + virtual ~DJBFFTCache(); + + int compute_forward(complex_double * inout) const; + int compute_backward(complex_double * inout) const; + int normalize(complex_double * inout) const; + + protected: + unsigned int* m_f; + double* m_ptr; +}; + +DJBFFTCache::DJBFFTCache(const DJBFFTCacheId& id) +: Cache(id) +{ + int i; + int n = id.m_n; + + m_f = (unsigned int*)malloc(sizeof(*m_f) * n); + if (m_f == NULL) { + goto fail_f; + } + + m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); + if (m_ptr == NULL) { + goto clean_f; + } + + fftfreq_ctable(m_f, id.m_n); + for(i = 0; i < n; ++i) { + m_f[i] = (id.m_n - m_f[i]) % id.m_n; + } + return; + +clean_f: + free(m_f); +fail_f: + throw std::bad_alloc(); +} + +DJBFFTCache::~DJBFFTCache() +{ + free(m_ptr); + free(m_f); +} + +int DJBFFTCache::compute_forward(complex_double *inout) const +{ + const int n = m_id.m_n; + int j; + + complex_double *ptrc = NULL; + complex_double *ptr = inout; + + ptrc = (complex_double*)m_ptr; + + memcpy(ptrc, ptr, 2 * n * sizeof(double)); + switch (n) { +#define TMPCASE(N) case N: fftc8_##N(ptrc); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + for (j = 0; j < n; ++j) { + *(ptr + m_f[j]) = *(ptrc + j); + } + + return 0; +} + +int DJBFFTCache::compute_backward(complex_double *inout) const +{ + const int n = m_id.m_n; + int j; + + complex_double *ptrc = NULL; + complex_double *ptr = inout; + + ptrc = (complex_double*)m_ptr; + + for (j = 0; j < n; ++j) { + *(ptrc + j) = *(ptr + m_f[j]); + } + switch (n) { +#define TMPCASE(N) case N: fftc8_un##N(ptrc); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + memcpy(ptr, ptrc, 2 * n * sizeof(double)); + + return 0; +} + +int DJBFFTCache::normalize(complex_double *ptr) const +{ + int n = m_id.m_n; + + switch (n) { +#define TMPCASE(N) case N: fftc8_scale##N(ptr); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + + return 0; +} + +static CacheManager djbfft_cmgr(10); + +/* stub to make GEN_PUBLIC_API happy */ +static void destroy_zdjbfft_caches() +{ +} + /**************** ZFFT function **********************/ static void zfft_djbfft(complex_double * inout, int n, int direction, int howmany, int normalize) { int i; complex_double *ptr = inout; - int j; - complex_double *ptrc = NULL; - unsigned int *f = NULL; + DJBFFTCache *cache; switch (n) { case 2:; @@ -55,69 +195,25 @@ case 2048:; case 4096:; case 8192: - i = get_cache_id_zdjbfft(n); - f = caches_zdjbfft[i].f; - ptrc = (complex_double *) caches_zdjbfft[i].ptr; - } - if (f == 0) { + cache = djbfft_cmgr.get_cache(DJBFFTCacheId(n)); + break; + default: + /* For sizes not handled by djbfft, use default implementation + * and returns */ zfft_def(inout, n, direction, howmany, normalize); + return; } switch (direction) { case 1: for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - memcpy(ptrc, ptr, 2 * n * sizeof(double)); - switch (n) { -#define TMPCASE(N) case N: fftc8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - for (j = 0; j < n; ++j) { - *(ptr + f[j]) = *(ptrc + j); - } - } - + cache->compute_forward(ptr); } break; case -1: for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - for (j = 0; j < n; ++j) { - *(ptrc + j) = *(ptr + f[j]); - } - switch (n) { -#define TMPCASE(N) case N: fftc8_un##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - memcpy(ptr, ptrc, 2 * n * sizeof(double)); - } + cache->compute_backward(ptr); } break; default: @@ -126,26 +222,8 @@ if (normalize) { ptr = inout; - if (f != NULL) { - for (i = 0; i < howmany; ++i, ptr += n) { - switch (n) { -#define TMPCASE(N) case N: fftc8_scale##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - } - } + for (i = 0; i < howmany; ++i, ptr += n) { + cache->normalize(ptr); + } } } Modified: branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 08:06:28 UTC (rev 4216) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 09:26:41 UTC (rev 4217) @@ -71,7 +71,7 @@ fftw_free(m_wrk); } -static CacheManager cmgr(10); +static CacheManager fftw3_cmgr(10); /* stub to make GEN_PUBLIC_API happy */ static void destroy_zfftw3_caches() @@ -87,7 +87,7 @@ int i; - cache = cmgr.get_cache(FFTW3CacheId(n, dir)); + cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, dir)); switch (dir) { case 1: From scipy-svn at scipy.org Mon May 5 05:50:40 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 04:50:40 -0500 (CDT) Subject: [Scipy-svn] r4218 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080505095040.557A539C01A@new.scipy.org> Author: cdavid Date: 2008-05-05 04:50:30 -0500 (Mon, 05 May 2008) New Revision: 4218 Added: branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx Removed: branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfft.cxx Log: Use C++ CacheManager for zfft, fftpack implementation. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 09:26:41 UTC (rev 4217) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 09:50:30 UTC (rev 4218) @@ -30,7 +30,7 @@ sources=sources, libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.c', 'src/zfft_fftw.c', + depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.cxx', 'src/zfft_fftw.c', 'src/zfft_fftw3.cxx', 'src/zfft_mkl.c', 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', 'src/drfft_fftw3.c', 'src/drfft_fftw.c', Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 09:26:41 UTC (rev 4217) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 09:50:30 UTC (rev 4218) @@ -51,7 +51,7 @@ GEN_PUBLIC_API(mkl) #endif #else /* Use fftpack by default */ - #include "zfft_fftpack.c" + #include "zfft_fftpack.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftpack) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.c 2008-05-05 09:26:41 UTC (rev 4217) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.c 2008-05-05 09:50:30 UTC (rev 4218) @@ -1,48 +0,0 @@ -extern void F_FUNC(zfftf,ZFFTF)(int*,double*,double*); -extern void F_FUNC(zfftb,ZFFTB)(int*,double*,double*); -extern void F_FUNC(zffti,ZFFTI)(int*,double*); -GEN_CACHE(zfftpack,(int n) - ,double* wsave; - ,(caches_zfftpack[i].n==n) - ,caches_zfftpack[id].wsave = (double*)malloc(sizeof(double)*(4*n+15)); - F_FUNC(zffti,ZFFTI)(&n,caches_zfftpack[id].wsave); - ,free(caches_zfftpack[id].wsave); - ,10) - -static void zfft_fftpack(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - double *wsave = NULL; - int j; - complex_double *ptrc = NULL; - unsigned int *f = NULL; - - wsave = caches_zfftpack[get_cache_id_zfftpack(n)].wsave; - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - zfftf_(&n, (double *) (ptr), wsave); - - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - zfftb_(&n, (double *) (ptr), wsave); - } - break; - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.c 2008-05-04 13:25:43 UTC (rev 4212) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx 2008-05-05 09:50:30 UTC (rev 4218) @@ -0,0 +1,107 @@ +#include + +#include "cycliccache.h" + +extern "C" { + extern void F_FUNC(zfftf,ZFFTF)(int*,double*,double*); + extern void F_FUNC(zfftb,ZFFTB)(int*,double*,double*); + extern void F_FUNC(zffti,ZFFTI)(int*,double*); +}; + +using namespace fft; + +class FFTPackCacheId : public CacheId { + public: + FFTPackCacheId(int n) : CacheId(n) {}; +}; + +class FFTPackCache: public Cache { + public: + FFTPackCache(const FFTPackCacheId& id); + virtual ~FFTPackCache(); + + int compute_forward(complex_double * inout) const; + int compute_backward(complex_double * inout) const; + + protected: + double* m_wsave; +}; + +FFTPackCache::FFTPackCache(const FFTPackCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + m_wsave = (double *)malloc(sizeof(*m_wsave) * (4 * n + 15)); + if (m_wsave == NULL) { + goto fail; + } + + F_FUNC(zffti,ZFFTI)(&n, m_wsave); + + return; + +fail: + throw std::bad_alloc(); +} + +FFTPackCache::~FFTPackCache() +{ + free(m_wsave); +} + +int FFTPackCache::compute_forward(complex_double *inout) const +{ + int n = m_id.m_n; + + zfftf_(&n, (double *)(inout), m_wsave); + return 0; +} + +int FFTPackCache::compute_backward(complex_double *inout) const +{ + int n = m_id.m_n; + + zfftb_(&n, (double *)(inout), m_wsave); + return 0; +} + +static CacheManager fftpack_cmgr(10); + +void destroy_zfftpack_caches() +{ +} + +static void zfft_fftpack(complex_double * inout, + int n, int direction, int howmany, int normalize) +{ + int i; + complex_double *ptr = inout; + FFTPackCache *cache; + + cache = fftpack_cmgr.get_cache(FFTPackCacheId(n)); + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + default: + fprintf(stderr, "zfft: invalid direction=%d\n", direction); + } + + if (normalize) { + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= n; + *((double *) (ptr++) + 1) /= n; + } + } +} From scipy-svn at scipy.org Mon May 5 06:03:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:03:56 -0500 (CDT) Subject: [Scipy-svn] r4219 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080505100356.E932839C503@new.scipy.org> Author: cdavid Date: 2008-05-05 05:03:48 -0500 (Mon, 05 May 2008) New Revision: 4219 Added: branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx Removed: branches/refactor_fft/scipy/fftpack/src/zfft_fftw.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfft.cxx Log: Use C++ CacheManager for zfft, fftw (2) implementation. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 09:50:30 UTC (rev 4218) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:03:48 UTC (rev 4219) @@ -30,7 +30,7 @@ sources=sources, libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.cxx', 'src/zfft_fftw.c', + depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.cxx', 'src/zfft_fftw.cxx', 'src/zfft_fftw3.cxx', 'src/zfft_mkl.c', 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', 'src/drfft_fftw3.c', 'src/drfft_fftw.c', Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 09:50:30 UTC (rev 4218) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:03:48 UTC (rev 4219) @@ -41,7 +41,7 @@ GEN_PUBLIC_API(fftw3) #endif #elif defined WITH_FFTW - #include "zfft_fftw.c" + #include "zfft_fftw.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftw) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_fftw.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw.c 2008-05-05 09:50:30 UTC (rev 4218) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw.c 2008-05-05 10:03:48 UTC (rev 4219) @@ -1,43 +0,0 @@ -GEN_CACHE(zfftw,(int n,int d) - ,int direction; - fftw_plan plan; - ,((caches_zfftw[i].n==n) && - (caches_zfftw[i].direction==d)) - ,caches_zfftw[id].direction = d; - caches_zfftw[id].plan = fftw_create_plan(n, - (d>0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_IN_PLACE|FFTW_ESTIMATE); - ,fftw_destroy_plan(caches_zfftw[id].plan); - ,10) - -extern void zfft_fftw(complex_double * inout, int n, - int dir, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - fftw_plan plan = NULL; - plan = caches_zfftw[get_cache_id_zfftw(n, dir)].plan; - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - fftw_one(plan, (fftw_complex *) ptr, NULL); - } - break; - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - fftw_one(plan, (fftw_complex *) ptr, NULL); - } - break; - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfft_fftw.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw.c 2008-05-04 13:25:43 UTC (rev 4212) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx 2008-05-05 10:03:48 UTC (rev 4219) @@ -0,0 +1,110 @@ +#if 0 +GEN_CACHE(zfftw,(int n,int d) + ,int direction; + fftw_plan plan; + ,((caches_zfftw[i].n==n) && + (caches_zfftw[i].direction==d)) + ,caches_zfftw[id].direction = d; + caches_zfftw[id].plan = fftw_create_plan(n, + (d>0?FFTW_FORWARD:FFTW_BACKWARD), + FFTW_IN_PLACE|FFTW_ESTIMATE); + ,fftw_destroy_plan(caches_zfftw[id].plan); + ,10) +#endif + +#include + +#include "cycliccache.h" + +using namespace fft; + +class FFTWCacheId : public CacheId { + public: + FFTWCacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; + + virtual bool operator==(const FFTWCacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const FFTWCacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_dir == other.m_dir && th->is_equal(*ot); + } + + public: + int m_dir; +}; + +class FFTWCache : public Cache { + public: + FFTWCache(const FFTWCacheId& id); + virtual ~FFTWCache(); + + int compute(fftw_complex* inout) + { + fftw_one(m_plan, inout, NULL); + return 0; + }; + + protected: + fftw_plan m_plan; +}; + +FFTWCache::FFTWCache(const FFTWCacheId& id) +: Cache(id) +{ + m_plan = fftw_create_plan(id.m_n, + (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), + FFTW_ESTIMATE | FFTW_IN_PLACE); + + if (m_plan == NULL) { + goto fail; + } + + return ; + +fail: + throw std::bad_alloc(); +} + +FFTWCache::~FFTWCache() +{ + fftw_destroy_plan(m_plan); +} + +CacheManager fftw_cmgr(10); + +/* stub to make GEN_PUBLIC_API happy */ +static void destroy_zfftw_caches() +{ +} + +extern void zfft_fftw(complex_double * inout, int n, + int dir, int howmany, int normalize) +{ + int i; + complex_double *ptr = inout; + FFTWCache* cache; + + cache = fftw_cmgr.get_cache(FFTWCacheId(n, dir)); + + if (dir != -1 && dir != 1) { + fprintf(stderr, "zfft: invalid dir=%d\n", dir); + } else { + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute((fftw_complex *) ptr); + } + } + + if (normalize) { + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= n; + *((double *) (ptr++) + 1) /= n; + } + } +} From scipy-svn at scipy.org Mon May 5 06:18:24 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:18:24 -0500 (CDT) Subject: [Scipy-svn] r4220 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080505101824.35EBC39C19D@new.scipy.org> Author: cdavid Date: 2008-05-05 05:18:14 -0500 (Mon, 05 May 2008) New Revision: 4220 Added: branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx Removed: branches/refactor_fft/scipy/fftpack/src/zfft_mkl.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfft.cxx Log: Use C++ CacheManager for zfft, mkl implementation. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:03:48 UTC (rev 4219) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:18:14 UTC (rev 4220) @@ -31,7 +31,7 @@ libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.cxx', 'src/zfft_fftw.cxx', - 'src/zfft_fftw3.cxx', 'src/zfft_mkl.c', + 'src/zfft_fftw3.cxx', 'src/zfft_mkl.cxx', 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', 'src/drfft_fftw3.c', 'src/drfft_fftw.c', 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:03:48 UTC (rev 4219) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:18:14 UTC (rev 4220) @@ -46,7 +46,7 @@ GEN_PUBLIC_API(fftw) #endif #elif defined WITH_MKL - #include "zfft_mkl.c" + #include "zfft_mkl.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(mkl) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_mkl.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_mkl.c 2008-05-05 10:03:48 UTC (rev 4219) +++ branches/refactor_fft/scipy/fftpack/src/zfft_mkl.c 2008-05-05 10:18:14 UTC (rev 4220) @@ -1,42 +0,0 @@ -GEN_CACHE(zmkl,(int n) - ,DFTI_DESCRIPTOR_HANDLE desc_handle; - ,(caches_zmkl[i].n==n) - ,DftiCreateDescriptor(&caches_zmkl[id].desc_handle, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n); - DftiCommitDescriptor(caches_zmkl[id].desc_handle); - ,DftiFreeDescriptor(&caches_zmkl[id].desc_handle); - ,10) - -static void zfft_mkl(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - DFTI_DESCRIPTOR_HANDLE desc_handle; - desc_handle = caches_zmkl[get_cache_id_zmkl(n)].desc_handle; - - switch (direction) { - - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - DftiComputeForward(desc_handle, (double *) ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - DftiComputeBackward(desc_handle, (double *) ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfft_mkl.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_mkl.c 2008-05-04 13:25:43 UTC (rev 4212) +++ branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx 2008-05-05 10:18:14 UTC (rev 4220) @@ -0,0 +1,93 @@ +#include + +#include "cycliccache.h" + +using namespace fft; + +class MKLCacheId : public CacheId { + public: + MKLCacheId(int n) : CacheId(n) {}; +}; + + +class MKLCache: public Cache { + public: + MKLCache(const MKLCacheId& id); + virtual ~MKLCache(); + + int compute_forward(complex_double * inout) const; + int compute_backward(complex_double * inout) const; + + protected: + DFTI_DESCRIPTOR_HANDLE m_hdl; +}; + +MKLCache::MKLCache(const MKLCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n); + DftiCommitDescriptor(m_hdl); + + return; +} + +MKLCache::~MKLCache() +{ + DftiFreeDescriptor(&m_hdl); +} + +int MKLCache::compute_forward(complex_double *inout) const +{ + DftiComputeForward(m_hdl, (double *) inout); + return 0; +} + +int MKLCache::compute_backward(complex_double *inout) const +{ + DftiComputeBackward(m_hdl, (double *) inout); + return 0; +} + +CacheManager mkl_cmgr(10); + +void destroy_zmkl_caches() +{ +} + +static void zfft_mkl(complex_double * inout, + int n, int direction, int howmany, int normalize) +{ + int i; + complex_double *ptr = inout; + MKLCache *cache; + + cache = mkl_cmgr.get_cache(MKLCacheId(n)); + + switch (direction) { + + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + + default: + fprintf(stderr, "zfft: invalid direction=%d\n", direction); + } + + if (normalize) { + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= n; + *((double *) (ptr++) + 1) /= n; + } + } +} From scipy-svn at scipy.org Mon May 5 06:21:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:21:56 -0500 (CDT) Subject: [Scipy-svn] r4221 - in trunk/scipy: fftpack linalg optimize Message-ID: <20080505102156.AA0B839C19D@new.scipy.org> Author: matthew.brett at gmail.com Date: 2008-05-05 05:21:51 -0500 (Mon, 05 May 2008) New Revision: 4221 Modified: trunk/scipy/fftpack/setup.py trunk/scipy/linalg/setup.py trunk/scipy/optimize/setup.py Log: Added benchmark directories to setup.py Modified: trunk/scipy/fftpack/setup.py =================================================================== --- trunk/scipy/fftpack/setup.py 2008-05-05 10:18:14 UTC (rev 4220) +++ trunk/scipy/fftpack/setup.py 2008-05-05 10:21:51 UTC (rev 4221) @@ -19,6 +19,7 @@ djbfft_info = get_info('djbfft') config.add_data_dir('tests') + config.add_data_dir('benchmarks') config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) Modified: trunk/scipy/linalg/setup.py =================================================================== --- trunk/scipy/linalg/setup.py 2008-05-05 10:18:14 UTC (rev 4220) +++ trunk/scipy/linalg/setup.py 2008-05-05 10:21:51 UTC (rev 4221) @@ -184,7 +184,7 @@ ) config.add_data_dir('tests') - + config.add_data_dir('benchmarks') return config if __name__ == '__main__': Modified: trunk/scipy/optimize/setup.py =================================================================== --- trunk/scipy/optimize/setup.py 2008-05-05 10:18:14 UTC (rev 4220) +++ trunk/scipy/optimize/setup.py 2008-05-05 10:21:51 UTC (rev 4221) @@ -42,6 +42,7 @@ config.add_extension('_slsqp', sources=[join('slsqp', x) for x in sources]) config.add_data_dir('tests') + config.add_data_dir('benchmarks') return config if __name__ == '__main__': From scipy-svn at scipy.org Mon May 5 06:32:38 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:32:38 -0500 (CDT) Subject: [Scipy-svn] r4222 - in trunk/scipy/sparse: . benchmarks tests Message-ID: <20080505103238.4DB5F39C19D@new.scipy.org> Author: matthew.brett at gmail.com Date: 2008-05-05 05:32:31 -0500 (Mon, 05 May 2008) New Revision: 4222 Added: trunk/scipy/sparse/benchmarks/ trunk/scipy/sparse/benchmarks/bench_sparse.py Removed: trunk/scipy/sparse/tests/bench_sparse.py Modified: trunk/scipy/sparse/setup.py Log: Moved sparse benchmarks to benchmarks directory Copied: trunk/scipy/sparse/benchmarks/bench_sparse.py (from rev 4219, trunk/scipy/sparse/tests/bench_sparse.py) Modified: trunk/scipy/sparse/setup.py =================================================================== --- trunk/scipy/sparse/setup.py 2008-05-05 10:21:51 UTC (rev 4221) +++ trunk/scipy/sparse/setup.py 2008-05-05 10:32:31 UTC (rev 4222) @@ -7,8 +7,9 @@ config = Configuration('sparse',parent_package,top_path) config.add_data_dir('tests') + config.add_data_dir('benchmarks') + config.add_subpackage('linalg') - config.add_subpackage('sparsetools') return config Deleted: trunk/scipy/sparse/tests/bench_sparse.py =================================================================== --- trunk/scipy/sparse/tests/bench_sparse.py 2008-05-05 10:21:51 UTC (rev 4221) +++ trunk/scipy/sparse/tests/bench_sparse.py 2008-05-05 10:32:31 UTC (rev 4222) @@ -1,280 +0,0 @@ -"""general tests and simple benchmarks for the sparse module""" - -import time - -import numpy -from numpy import ones, array, asarray, empty - -from scipy.testing import * - -from scipy import sparse -from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \ - coo_matrix, lil_matrix, dia_matrix, spdiags - - -def random_sparse(m,n,nnz_per_row): - rows = numpy.arange(m).repeat(nnz_per_row) - cols = numpy.random.random_integers(low=0,high=n-1,size=nnz_per_row*m) - vals = numpy.random.random_sample(m*nnz_per_row) - return coo_matrix((vals,(rows,cols)),(m,n)).tocsr() - - -#TODO move this to a matrix gallery and add unittests -def poisson2d(N,dtype='d',format=None): - """ - Return a sparse matrix for the 2d poisson problem - with standard 5-point finite difference stencil on a - square N-by-N grid. - """ - if N == 1: - diags = asarray( [[4]],dtype=dtype) - return dia_matrix((diags,[0]), shape=(1,1)).asformat(format) - - offsets = array([0,-N,N,-1,1]) - - diags = empty((5,N**2),dtype=dtype) - - diags[0] = 4 #main diagonal - diags[1:] = -1 #all offdiagonals - - diags[3,N-1::N] = 0 #first lower diagonal - diags[4,N::N] = 0 #first upper diagonal - - return dia_matrix((diags,offsets),shape=(N**2,N**2)).asformat(format) - -class BenchmarkSparse(TestCase): - """Simple benchmarks for sparse matrix module""" - - def bench_arithmetic(self): - matrices = [] - #matrices.append( ('A','Identity', sparse.identity(500**2,format='csr')) ) - matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr')) ) - matrices.append( ('B','Poisson5pt^2', poisson2d(500,format='csr')**2) ) - - print - print ' Sparse Matrix Arithmetic' - print '====================================================================' - print ' var | name | shape | dtype | nnz ' - print '--------------------------------------------------------------------' - fmt = ' %1s | %14s | %20s | %9s | %8d ' - - for var,name,mat in matrices: - name = name.center(14) - shape = ("%s" % (mat.shape,)).center(20) - dtype = mat.dtype.name.center(9) - print fmt % (var,name,shape,dtype,mat.nnz) - - space = ' ' * 10 - print - print space+' Timings' - print space+'==========================================' - print space+' format | operation | time (msec) ' - print space+'------------------------------------------' - fmt = space+' %3s | %17s | %7.1f ' - - for format in ['csr']: - vars = dict( [(var,mat.asformat(format)) for (var,name,mat) in matrices ] ) - for X,Y in [ ('A','A'),('A','B'),('B','A'),('B','B') ]: - x,y = vars[X],vars[Y] - for op in ['__add__','__sub__','multiply','__div__','__mul__']: - fn = getattr(x,op) - fn(y) #warmup - - start = time.clock() - iter = 0 - while iter < 5 or time.clock() < start + 1: - fn(y) - iter += 1 - end = time.clock() - - msec_per_it = 1000*(end - start)/float(iter) - operation = (X + '.' + op + '(' + Y + ')').center(17) - print fmt % (format,operation,msec_per_it) - - - def bench_sort(self): - """sort CSR column indices""" - matrices = [] - matrices.append( ('Rand10', 1e4, 10) ) - matrices.append( ('Rand25', 1e4, 25) ) - matrices.append( ('Rand50', 1e4, 50) ) - matrices.append( ('Rand100', 1e4, 100) ) - matrices.append( ('Rand200', 1e4, 200) ) - - print - print ' Sparse Matrix Index Sorting' - print '=====================================================================' - print ' type | name | shape | nnz | time (msec) ' - print '---------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.2f ' - - for name,N,K in matrices: - N = int(N) - A = random_sparse(N,N,K) - - start = time.clock() - iter = 0 - while iter < 5 and time.clock() - start < 1: - A.has_sorted_indices = False - A.sort_indices() - iter += 1 - end = time.clock() - - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - - print fmt % (A.format,name,shape,A.nnz,1e3*(end-start)/float(iter) ) - - def bench_matvec(self): - matrices = [] - matrices.append(('Identity', sparse.identity(10**4,format='dia'))) - matrices.append(('Identity', sparse.identity(10**4,format='csr'))) - matrices.append(('Poisson5pt', poisson2d(300,format='dia'))) - matrices.append(('Poisson5pt', poisson2d(300,format='csr'))) - matrices.append(('Poisson5pt', poisson2d(300,format='bsr'))) - - A = sparse.kron(poisson2d(150),ones((2,2))).tobsr(blocksize=(2,2)) - matrices.append( ('Block2x2', A.tocsr()) ) - matrices.append( ('Block2x2', A) ) - - A = sparse.kron(poisson2d(100),ones((3,3))).tobsr(blocksize=(3,3)) - matrices.append( ('Block3x3', A.tocsr()) ) - matrices.append( ('Block3x3', A) ) - - print - print ' Sparse Matrix Vector Product' - print '==================================================================' - print ' type | name | shape | nnz | MFLOPs ' - print '------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.1f ' - - for name,A in matrices: - x = ones(A.shape[1],dtype=A.dtype) - - y = A*x #warmup - - start = time.clock() - iter = 0 - while iter < 5 or time.clock() < start + 1: - y = A*x - #try: - # #avoid creating y if possible - # A.matvec(x,y) - #except: - # y = A*x - iter += 1 - end = time.clock() - - del y - - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - MFLOPs = (2*A.nnz*iter/(end-start))/float(1e6) - - print fmt % (A.format,name,shape,A.nnz,MFLOPs) - - def bench_construction(self): - """build matrices by inserting single values""" - matrices = [] - matrices.append( ('Empty',csr_matrix((10000,10000))) ) - matrices.append( ('Identity',sparse.identity(10000)) ) - matrices.append( ('Poisson5pt', poisson2d(100)) ) - - print - print ' Sparse Matrix Construction' - print '====================================================================' - print ' type | name | shape | nnz | time (sec) ' - print '--------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.4f ' - - for name,A in matrices: - A = A.tocoo() - - for format in ['lil','dok']: - - start = time.clock() - - iter = 0 - while time.clock() < start + 0.5: - T = eval(format + '_matrix')(A.shape) - for i,j,v in zip(A.row,A.col,A.data): - T[i,j] = v - iter += 1 - end = time.clock() - - del T - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - - print fmt % (format,name,shape,A.nnz,(end-start)/float(iter)) - - def bench_conversion(self): - A = poisson2d(100) - - formats = ['csr','csc','coo','lil','dok'] - - print - print ' Sparse Matrix Conversion' - print '==========================================================' - print ' format | tocsr() | tocsc() | tocoo() | tolil() | todok() ' - print '----------------------------------------------------------' - - for fromfmt in formats: - base = getattr(A,'to' + fromfmt)() - - times = [] - - for tofmt in formats: - try: - fn = getattr(base,'to' + tofmt) - except: - times.append(None) - else: - x = fn() #warmup - start = time.clock() - iter = 0 - while time.clock() < start + 0.2: - x = fn() - iter += 1 - end = time.clock() - del x - times.append( (end - start)/float(iter)) - - output = " %3s " % fromfmt - for t in times: - if t is None: - output += '| n/a ' - else: - output += '| %5.1fms ' % (1000*t) - print output - - -#class TestLarge(TestCase): -# def bench_large(self): -# # Create a 100x100 matrix with 100 non-zero elements -# # and play around with it -# #TODO move this out of Common since it doesn't use spmatrix -# random.seed(0) -# A = dok_matrix((100,100)) -# for k in range(100): -# i = random.randrange(100) -# j = random.randrange(100) -# A[i,j] = 1. -# csr = A.tocsr() -# csc = A.tocsc() -# csc2 = csr.tocsc() -# coo = A.tocoo() -# csr2 = coo.tocsr() -# assert_array_equal(A.transpose().todense(), csr.transpose().todense()) -# assert_array_equal(csc.todense(), csr.todense()) -# assert_array_equal(csr.todense(), csr2.todense()) -# assert_array_equal(csr2.todense().transpose(), coo.transpose().todense()) -# assert_array_equal(csr2.todense(), csc2.todense()) -# csr_plus_csc = csr + csc -# csc_plus_csr = csc + csr -# assert_array_equal(csr_plus_csc.todense(), (2*A).todense()) -# assert_array_equal(csr_plus_csc.todense(), csc_plus_csr.todense()) - - -if __name__ == "__main__": - nose.run(argv=['', __file__]) From scipy-svn at scipy.org Mon May 5 06:36:31 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:36:31 -0500 (CDT) Subject: [Scipy-svn] r4223 - in branches/refactor_fft/scipy/fftpack: . src src/fftw3 Message-ID: <20080505103631.93AC339C45E@new.scipy.org> Author: cdavid Date: 2008-05-05 05:36:19 -0500 (Mon, 05 May 2008) New Revision: 4223 Added: branches/refactor_fft/scipy/fftpack/src/fftw3/ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c Removed: branches/refactor_fft/scipy/fftpack/src/drfft_fftw3.c branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw3.c Modified: branches/refactor_fft/scipy/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.c branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.c Log: Move fftw3 backend source code in subdir. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 10:36:19 UTC (rev 4223) @@ -1,4 +1,4 @@ -# Last Change: Mon May 05 03:00 PM 2008 J +# Last Change: Mon May 05 07:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -12,6 +12,7 @@ env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +env.AppendUnique(CPPPATH = ["src"]) # Check fft implementation config = env.NumpyConfigure(custom_tests = {'CheckFFT': CheckFFT, Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:36:19 UTC (rev 4223) @@ -31,12 +31,13 @@ libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.cxx', 'src/zfft_fftw.cxx', - 'src/zfft_fftw3.cxx', 'src/zfft_mkl.cxx', + 'src/fftw3/zfft.cxx', 'src/zfft_mkl.cxx', 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', - 'src/drfft_fftw3.c', 'src/drfft_fftw.c', + 'src/fftw3/drfft.c', 'src/drfft_fftw.c', 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', - 'src/zfftnd_fftw3.c', 'src/zfftnd_mkl.c', + 'src/fftw3/zfftnd.c', 'src/zfftnd_mkl.c', ], + include_dirs = ['src'], ) config.add_extension('convolve', Modified: branches/refactor_fft/scipy/fftpack/src/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:36:19 UTC (rev 4223) @@ -36,7 +36,7 @@ */ #ifdef WITH_FFTW3 - #include "drfft_fftw3.c" + #include "fftw3/drfft.c" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftw3) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/drfft_fftw3.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft_fftw3.c 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/src/drfft_fftw3.c 2008-05-05 10:36:19 UTC (rev 4223) @@ -1,65 +0,0 @@ -/* - * Last Change: Wed Aug 01 07:00 PM 2007 J - * - * FFTW3 implementation - * - * Original code by Pearu Peterson. - */ - -GEN_CACHE(drfftw3, (int n, int d, int flags) - , int direction; - int flags; - fftw_plan plan; - double *ptr;, ((caches_drfftw3[i].n == n) && - (caches_drfftw3[i].direction == d) && - (caches_drfftw3[i].flags == flags)) - , caches_drfftw3[id].direction = d; - caches_drfftw3[id].flags = flags; - caches_drfftw3[id].ptr = - (double *) fftw_malloc(sizeof(double) * (n)); - caches_drfftw3[id].plan = - fftw_plan_r2r_1d(n, caches_drfftw3[id].ptr, caches_drfftw3[id].ptr, - (d > 0 ? FFTW_R2HC : FFTW_HC2R), flags);, - fftw_destroy_plan(caches_drfftw3[id].plan); - fftw_free(caches_drfftw3[id].ptr);, 10) - -static void drfft_fftw3(double *inout, int n, int direction, int - howmany, int normalize) -{ - int i; - double *ptr = inout; - - double *ptrc = NULL; - fftw_plan plan = NULL; - - i = get_cache_id_drfftw3(n, direction, FFTW_ESTIMATE); - plan = caches_drfftw3[i].plan; - ptrc = caches_drfftw3[i].ptr; - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - memcpy(ptrc, ptr, sizeof(double) * n); - fftw_execute(plan); - COPYRFFTW2STD(ptrc, ptr, n); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - COPYINVRFFTW2STD(ptr, ptrc, n); - fftw_execute(plan); - memcpy(ptr, ptrc, sizeof(double) * n); - } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/drfft_fftw3.c) Copied: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx (from rev 4217, branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx) Copied: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw3.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:36:19 UTC (rev 4223) @@ -36,7 +36,7 @@ */ #ifdef WITH_FFTW3 - #include "zfft_fftw3.cxx" + #include "fftw3/zfft.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftw3) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw3.cxx 2008-05-05 10:36:19 UTC (rev 4223) @@ -1,116 +0,0 @@ -#include - -#include "cycliccache.h" - -using namespace fft; - -class FFTW3CacheId : public CacheId { - public: - FFTW3CacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; - - virtual bool operator==(const FFTW3CacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTW3CacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; -}; - -class FFTW3Cache : public Cache { - public: - FFTW3Cache(const FFTW3CacheId& id); - virtual ~FFTW3Cache(); - - int compute(fftw_complex* inout) - { - fftw_execute_dft(m_plan, inout, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - fftw_complex *m_wrk; -}; - -FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) -: Cache(id) -{ - m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk == NULL) { - goto fail_wrk; - } - - m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, - (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_UNALIGNED); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return ; - -clean_wrk: - fftw_free(m_wrk); -fail_wrk: - throw std::bad_alloc(); -} - -FFTW3Cache::~FFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk); -} - -static CacheManager fftw3_cmgr(10); - -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zfftw3_caches() -{ -} - -static void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, - int normalize) -{ - fftw_complex *ptr = (fftw_complex*)inout; - double factor = 1./n; - FFTW3Cache *cache; - - int i; - - cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, dir)); - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr =(fftw_complex*)inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) *= factor; - *((double *) (ptr++) + 1) *= factor; - } - } -} Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:36:19 UTC (rev 4223) @@ -31,7 +31,7 @@ #endif #ifdef WITH_FFTW3 - #include "zfftnd_fftw3.c" + #include "fftw3/zfftnd.c" GEN_PUBLIC_API(fftw3) #elif defined WITH_FFTW #include "zfftnd_fftw.c" Deleted: branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw3.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw3.c 2008-05-05 10:32:31 UTC (rev 4222) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw3.c 2008-05-05 10:36:19 UTC (rev 4223) @@ -1,40 +0,0 @@ -/* - * fftw3 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Wed Aug 08 02:00 PM 2007 J - */ - -/* stub because fftw3 has no cache mechanism (yet) */ -static void destroy_zfftnd_fftw3_caches(void) {} - -extern void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - - fftw_plan plan = NULL; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - plan = fftw_plan_many_dft(rank, dims, howmany, - (fftw_complex *) ptr, NULL, 1, sz, - (fftw_complex *) ptr, NULL, 1, sz, - (direction > - 0 ? FFTW_FORWARD : FFTW_BACKWARD), - FFTW_ESTIMATE); - fftw_execute(plan); - fftw_destroy_plan(plan); - - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} From scipy-svn at scipy.org Mon May 5 06:42:02 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:42:02 -0500 (CDT) Subject: [Scipy-svn] r4224 - in branches/refactor_fft/scipy/fftpack: . src src/fftw Message-ID: <20080505104202.9607239C45E@new.scipy.org> Author: cdavid Date: 2008-05-05 05:41:50 -0500 (Mon, 05 May 2008) New Revision: 4224 Added: branches/refactor_fft/scipy/fftpack/src/fftw/ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c Removed: branches/refactor_fft/scipy/fftpack/src/drfft_fftw.c branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.c branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.c Log: Move fftw2 backend source code in subdir. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:41:50 UTC (rev 4224) @@ -30,11 +30,11 @@ sources=sources, libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/zfft_djbfft.cxx', 'src/zfft_fftpack.cxx', 'src/zfft_fftw.cxx', + depends=['src/zfft_djbfft.cxx', 'src/fftw/zfft.cxx', 'src/zfft_fftw.cxx', 'src/fftw3/zfft.cxx', 'src/zfft_mkl.cxx', 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', - 'src/fftw3/drfft.c', 'src/drfft_fftw.c', - 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', + 'src/fftw3/drfft.c', 'src/fftw/drfft.c', + 'src/zfftnd_fftpack.c', 'src/fftw/zfftnd.c', 'src/fftw3/zfftnd.c', 'src/zfftnd_mkl.c', ], include_dirs = ['src'], Modified: branches/refactor_fft/scipy/fftpack/src/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:41:50 UTC (rev 4224) @@ -41,7 +41,7 @@ GEN_PUBLIC_API(fftw3) #endif #elif defined WITH_FFTW - #include "drfft_fftw.c" + #include "fftw/drfft.c" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftw) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/drfft_fftw.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft_fftw.c 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/src/drfft_fftw.c 2008-05-05 10:41:50 UTC (rev 4224) @@ -1,70 +0,0 @@ -/* - * Last Change: Wed Aug 01 07:00 PM 2007 J - * - * FFTW2 implementation - * - * Original code by Pearu Peterson. - */ - -GEN_CACHE(drfftw, (int n, int d, int flags) - , int direction; - int flags; - rfftw_plan plan; - double *ptr;, ((caches_drfftw[i].n == n) && - (caches_drfftw[i].direction == d) && - (caches_drfftw[i].flags == flags)) - , caches_drfftw[id].direction = d; - caches_drfftw[id].flags = flags; - caches_drfftw[id].plan = rfftw_create_plan(n, - (d > - 0 ? - FFTW_REAL_TO_COMPLEX - : - FFTW_COMPLEX_TO_REAL), - flags); - caches_drfftw[id].ptr = - (double *) malloc(sizeof(double) * (n));, - rfftw_destroy_plan(caches_drfftw[id].plan); - free(caches_drfftw[id].ptr);, 10) - -static void drfft_fftw(double *inout, int n, int dir, int - howmany, int normalize) -{ - int i; - double *ptr = inout; - double *ptrc = NULL; - rfftw_plan plan = NULL; - - i = get_cache_id_drfftw(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE); - plan = caches_drfftw[i].plan; - ptrc = caches_drfftw[i].ptr; - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - memcpy(ptrc, ptr, sizeof(double) * n); - rfftw(plan, 1, (fftw_real *) ptrc, 1, 1, NULL, 1, 1); - COPYRFFTW2STD(ptrc, ptr, n); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - COPYINVRFFTW2STD(ptr, ptrc, n); - rfftw(plan, 1, (fftw_real *) ptrc, 1, 1, NULL, 1, 1); - memcpy(ptr, ptrc, sizeof(double) * n); - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", dir); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/drfft_fftw.c) Copied: branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx (from rev 4219, branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx) Copied: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:41:50 UTC (rev 4224) @@ -41,7 +41,7 @@ GEN_PUBLIC_API(fftw3) #endif #elif defined WITH_FFTW - #include "zfft_fftw.cxx" + #include "fftw/zfft.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftw) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftw.cxx 2008-05-05 10:41:50 UTC (rev 4224) @@ -1,110 +0,0 @@ -#if 0 -GEN_CACHE(zfftw,(int n,int d) - ,int direction; - fftw_plan plan; - ,((caches_zfftw[i].n==n) && - (caches_zfftw[i].direction==d)) - ,caches_zfftw[id].direction = d; - caches_zfftw[id].plan = fftw_create_plan(n, - (d>0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_IN_PLACE|FFTW_ESTIMATE); - ,fftw_destroy_plan(caches_zfftw[id].plan); - ,10) -#endif - -#include - -#include "cycliccache.h" - -using namespace fft; - -class FFTWCacheId : public CacheId { - public: - FFTWCacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; - - virtual bool operator==(const FFTWCacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTWCacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; -}; - -class FFTWCache : public Cache { - public: - FFTWCache(const FFTWCacheId& id); - virtual ~FFTWCache(); - - int compute(fftw_complex* inout) - { - fftw_one(m_plan, inout, NULL); - return 0; - }; - - protected: - fftw_plan m_plan; -}; - -FFTWCache::FFTWCache(const FFTWCacheId& id) -: Cache(id) -{ - m_plan = fftw_create_plan(id.m_n, - (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_IN_PLACE); - - if (m_plan == NULL) { - goto fail; - } - - return ; - -fail: - throw std::bad_alloc(); -} - -FFTWCache::~FFTWCache() -{ - fftw_destroy_plan(m_plan); -} - -CacheManager fftw_cmgr(10); - -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zfftw_caches() -{ -} - -extern void zfft_fftw(complex_double * inout, int n, - int dir, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - FFTWCache* cache; - - cache = fftw_cmgr.get_cache(FFTWCacheId(n, dir)); - - if (dir != -1 && dir != 1) { - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } else { - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute((fftw_complex *) ptr); - } - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:41:50 UTC (rev 4224) @@ -34,7 +34,7 @@ #include "fftw3/zfftnd.c" GEN_PUBLIC_API(fftw3) #elif defined WITH_FFTW - #include "zfftnd_fftw.c" + #include "fftw/zfftnd.c" GEN_PUBLIC_API(fftw) #elif defined WITH_MKL #include "zfftnd_mkl.c" Deleted: branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw.c 2008-05-05 10:36:19 UTC (rev 4223) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd_fftw.c 2008-05-05 10:41:50 UTC (rev 4224) @@ -1,53 +0,0 @@ -/* - * fftw2 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Thu Sep 06 05:00 PM 2007 J - */ - -GEN_CACHE(zfftnd_fftw, (int n, int *dims, int d, int flags) - , int direction; - int *dims; - fftwnd_plan plan;, ((caches_zfftnd_fftw[i].n == n) && - (caches_zfftnd_fftw[i].direction == d) && - (equal_dims - (n, caches_zfftnd_fftw[i].dims, dims))) - , caches_zfftnd_fftw[id].direction = d; - caches_zfftnd_fftw[id].n = n; - caches_zfftnd_fftw[id].dims = (int *) malloc(sizeof(int) * n); - memcpy(caches_zfftnd_fftw[id].dims, dims, sizeof(int) * n); - caches_zfftnd_fftw[id].plan = - fftwnd_create_plan(n, dims, - (d > 0 ? FFTW_FORWARD : FFTW_BACKWARD), - flags);, - fftwnd_destroy_plan(caches_zfftnd_fftw[id].plan); - free(caches_zfftnd_fftw[id].dims);, 10) - - -extern void zfftnd_fftw(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - fftwnd_plan plan = NULL; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - i = get_cache_id_zfftnd_fftw(rank, dims, direction, - FFTW_IN_PLACE | FFTW_ESTIMATE); - plan = caches_zfftnd_fftw[i].plan; - for (i = 0; i < howmany; ++i, ptr += sz) { - fftwnd_one(plan, (fftw_complex *) ptr, NULL); - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} From scipy-svn at scipy.org Mon May 5 06:46:43 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:46:43 -0500 (CDT) Subject: [Scipy-svn] r4225 - in branches/refactor_fft/scipy/fftpack/src: . mkl Message-ID: <20080505104643.2311639C45E@new.scipy.org> Author: cdavid Date: 2008-05-05 05:46:35 -0500 (Mon, 05 May 2008) New Revision: 4225 Added: branches/refactor_fft/scipy/fftpack/src/mkl/ branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c Removed: branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd_mkl.c Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.c Log: Move mkl backend source code in subdir. Copied: branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx (from rev 4220, branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx) Copied: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfftnd_mkl.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:41:50 UTC (rev 4224) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:46:35 UTC (rev 4225) @@ -46,7 +46,7 @@ GEN_PUBLIC_API(fftw) #endif #elif defined WITH_MKL - #include "zfft_mkl.cxx" + #include "mkl/zfft.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(mkl) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx 2008-05-05 10:41:50 UTC (rev 4224) +++ branches/refactor_fft/scipy/fftpack/src/zfft_mkl.cxx 2008-05-05 10:46:35 UTC (rev 4225) @@ -1,93 +0,0 @@ -#include - -#include "cycliccache.h" - -using namespace fft; - -class MKLCacheId : public CacheId { - public: - MKLCacheId(int n) : CacheId(n) {}; -}; - - -class MKLCache: public Cache { - public: - MKLCache(const MKLCacheId& id); - virtual ~MKLCache(); - - int compute_forward(complex_double * inout) const; - int compute_backward(complex_double * inout) const; - - protected: - DFTI_DESCRIPTOR_HANDLE m_hdl; -}; - -MKLCache::MKLCache(const MKLCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n); - DftiCommitDescriptor(m_hdl); - - return; -} - -MKLCache::~MKLCache() -{ - DftiFreeDescriptor(&m_hdl); -} - -int MKLCache::compute_forward(complex_double *inout) const -{ - DftiComputeForward(m_hdl, (double *) inout); - return 0; -} - -int MKLCache::compute_backward(complex_double *inout) const -{ - DftiComputeBackward(m_hdl, (double *) inout); - return 0; -} - -CacheManager mkl_cmgr(10); - -void destroy_zmkl_caches() -{ -} - -static void zfft_mkl(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - MKLCache *cache; - - cache = mkl_cmgr.get_cache(MKLCacheId(n)); - - switch (direction) { - - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:41:50 UTC (rev 4224) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:46:35 UTC (rev 4225) @@ -37,7 +37,7 @@ #include "fftw/zfftnd.c" GEN_PUBLIC_API(fftw) #elif defined WITH_MKL - #include "zfftnd_mkl.c" + #include "mkl/zfftnd.c" GEN_PUBLIC_API(mkl) #else /* Use fftpack by default */ #include "zfftnd_fftpack.c" Deleted: branches/refactor_fft/scipy/fftpack/src/zfftnd_mkl.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd_mkl.c 2008-05-05 10:41:50 UTC (rev 4224) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd_mkl.c 2008-05-05 10:46:35 UTC (rev 4225) @@ -1,66 +0,0 @@ -/* - * MKL backend for multi dimensional fft - * - * Original code by David M. Cooke - * - * Last Change: Wed Aug 08 03:00 PM 2007 J - */ - -static long *convert_dims(int n, int *dims) -{ - long *ndim; - int i; - ndim = (long *) malloc(sizeof(long) * n); - for (i = 0; i < n; i++) { - ndim[i] = (long) dims[i]; - } - return ndim; -} - -GEN_CACHE(zfftnd_mkl, (int n, int *dims) - , DFTI_DESCRIPTOR_HANDLE desc_handle; - int *dims; - long *ndims;, ((caches_zfftnd_mkl[i].n == n) && - (equal_dims(n, caches_zfftnd_mkl[i].dims, dims))) - , caches_zfftnd_mkl[id].ndims = convert_dims(n, dims); - caches_zfftnd_mkl[id].n = n; - caches_zfftnd_mkl[id].dims = (int *) malloc(sizeof(int) * n); - memcpy(caches_zfftnd_mkl[id].dims, dims, sizeof(int) * n); - DftiCreateDescriptor(&caches_zfftnd_mkl[id].desc_handle, - DFTI_DOUBLE, DFTI_COMPLEX, (long) n, - caches_zfftnd_mkl[id].ndims); - DftiCommitDescriptor(caches_zfftnd_mkl[id].desc_handle);, - DftiFreeDescriptor(&caches_zfftnd_mkl[id].desc_handle); - free(caches_zfftnd_mkl[id].dims); - free(caches_zfftnd_mkl[id].ndims);, 10) - -extern void zfftnd_mkl(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - - DFTI_DESCRIPTOR_HANDLE desc_handle; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - desc_handle = - caches_zfftnd_mkl[get_cache_id_zfftnd_mkl(rank, dims)].desc_handle; - for (i = 0; i < howmany; ++i, ptr += sz) { - if (direction == 1) { - DftiComputeForward(desc_handle, (double *) ptr); - } else if (direction == -1) { - DftiComputeBackward(desc_handle, (double *) ptr); - } - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} From scipy-svn at scipy.org Mon May 5 06:49:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:49:41 -0500 (CDT) Subject: [Scipy-svn] r4226 - in trunk/scipy/sandbox/exmplpackage: . benchmarks tests yyy yyy/tests Message-ID: <20080505104941.BDA5B39C45E@new.scipy.org> Author: matthew.brett at gmail.com Date: 2008-05-05 05:49:32 -0500 (Mon, 05 May 2008) New Revision: 4226 Added: trunk/scipy/sandbox/exmplpackage/benchmarks/ trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py Modified: trunk/scipy/sandbox/exmplpackage/__init__.py trunk/scipy/sandbox/exmplpackage/setup.py trunk/scipy/sandbox/exmplpackage/tests/test_foo.py trunk/scipy/sandbox/exmplpackage/yyy/__init__.py trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py Log: Updated exmplpackage to nose tests framework Modified: trunk/scipy/sandbox/exmplpackage/__init__.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/__init__.py 2008-05-05 10:46:35 UTC (rev 4225) +++ trunk/scipy/sandbox/exmplpackage/__init__.py 2008-05-05 10:49:32 UTC (rev 4226) @@ -5,6 +5,10 @@ # Get documentation string: from info_exmplpackage import __doc__ +# Import testing rig, allowing scipy.examplpackage.test() +from scipy.testing.pkgtester import Tester +test = Tester().test + # Import symbols from sub-module: from foo import * Added: trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py 2008-05-05 10:46:35 UTC (rev 4225) +++ trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py 2008-05-05 10:49:32 UTC (rev 4226) @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# +__usage__ = """ +First ensure that scipy core modules are installed. + +Run benchmarks if scipy is installed: + python -c 'import scipy;scipy.exmplpackage.bench(label=,verbose=)' +""" + +import sys +from scipy.testing import * + +from scipy.sandbox.exmplpackage.foo import * + +class BenchFooBar(TestCase): + + def bench_simple(self): + print 'A long timed benchmark here' + Modified: trunk/scipy/sandbox/exmplpackage/setup.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/setup.py 2008-05-05 10:46:35 UTC (rev 4225) +++ trunk/scipy/sandbox/exmplpackage/setup.py 2008-05-05 10:49:32 UTC (rev 4226) @@ -9,8 +9,9 @@ from numpy.distutils.misc_util import Configuration config = Configuration('exmplpackage',parent_package,top_path) - # include test scripts from tests + # include test scripts from tests, and any benchmarks config.add_data_dir('tests') + config.add_data_dir('benchmarks') # exmplpackage contains Python sub-package yyy config.add_subpackage('yyy') Modified: trunk/scipy/sandbox/exmplpackage/tests/test_foo.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/tests/test_foo.py 2008-05-05 10:46:35 UTC (rev 4225) +++ trunk/scipy/sandbox/exmplpackage/tests/test_foo.py 2008-05-05 10:49:32 UTC (rev 4226) @@ -9,10 +9,10 @@ Build exmplpackage: python setup.py build Run tests locally: - python tests/test_foo.py [-l] [-v] + python tests/test_foo.py Run tests if scipy is installed: - python -c 'import scipy;scipy.exmplpackage.test(level=,verbosity=)' + python -c 'import scipy;scipy.exmplpackage.test(label=,verbose=)' """ import sys @@ -22,12 +22,12 @@ class TestFooBar(TestCase): - def check_simple(self, level=1): + def test_simple(self): assert exmplpackage_foo_bar()=='Hello from exmplpackage_foo_bar' class TestFooGun(TestCase): - def check_simple(self, level=1): + def test_simple(self): assert foo_gun()=='Hello from foo_gun' if __name__ == "__main__": Modified: trunk/scipy/sandbox/exmplpackage/yyy/__init__.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/yyy/__init__.py 2008-05-05 10:46:35 UTC (rev 4225) +++ trunk/scipy/sandbox/exmplpackage/yyy/__init__.py 2008-05-05 10:49:32 UTC (rev 4226) @@ -2,7 +2,11 @@ yyy - Subpackage of Scipy module exmplpackage """ -__all__ = ['fun'] +__all__ = ['fun', 'test'] +# Import testing rig, allowing scipy.examplpackage.yyy.test() +from scipy.testing.pkgtester import Tester +test = Tester().test + def fun(): return 'Hello from yyy.fun' Modified: trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py 2008-05-05 10:46:35 UTC (rev 4225) +++ trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py 2008-05-05 10:49:32 UTC (rev 4226) @@ -1,16 +1,12 @@ -import sys -from numpy.test.testing import * +from scipy.testing import * -set_package_path() -# make sure that all yyy symbols are imported before the del statement: from yyy import fun -del sys.path[0] -class TestFun(NumpyTestCase): - def check_simple(self, level=1): +class TestFun(TestCase): + def test_simple(self): assert fun()=='Hello from yyy.fun' #... if __name__ == "__main__": - NumpyTest().run() + nose.run(argv=['', __file__]) From scipy-svn at scipy.org Mon May 5 06:51:35 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:51:35 -0500 (CDT) Subject: [Scipy-svn] r4227 - in branches/refactor_fft/scipy/fftpack: . src src/fftpack Message-ID: <20080505105135.09DB839C113@new.scipy.org> Author: cdavid Date: 2008-05-05 05:51:23 -0500 (Mon, 05 May 2008) New Revision: 4227 Added: branches/refactor_fft/scipy/fftpack/src/fftpack/ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c Removed: branches/refactor_fft/scipy/fftpack/src/drfft_fftpack.c branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd_fftpack.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.c branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.c Log: Move fftpack backend source code in subdir. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:51:23 UTC (rev 4227) @@ -30,12 +30,12 @@ sources=sources, libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/zfft_djbfft.cxx', 'src/fftw/zfft.cxx', 'src/zfft_fftw.cxx', - 'src/fftw3/zfft.cxx', 'src/zfft_mkl.cxx', - 'src/drfft_djbfft.c', 'src/drfft_fftpack.c', + depends=['src/zfft_djbfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', + 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', + 'src/drfft_djbfft.c', 'src/fftpack/drfft.c', 'src/fftw3/drfft.c', 'src/fftw/drfft.c', - 'src/zfftnd_fftpack.c', 'src/fftw/zfftnd.c', - 'src/fftw3/zfftnd.c', 'src/zfftnd_mkl.c', + 'src/fftpack/zfftnd.c', 'src/fftw/zfftnd.c', + 'src/fftw3/zfftnd.c', 'src/mkl/zfftnd.c', ], include_dirs = ['src'], ) Modified: branches/refactor_fft/scipy/fftpack/src/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:51:23 UTC (rev 4227) @@ -46,7 +46,7 @@ GEN_PUBLIC_API(fftw) #endif #else /* Use fftpack by default */ - #include "drfft_fftpack.c" + #include "fftpack/drfft.c" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftpack) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/drfft_fftpack.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft_fftpack.c 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/src/drfft_fftpack.c 2008-05-05 10:51:23 UTC (rev 4227) @@ -1,54 +0,0 @@ -/* - * Last Change: Wed Aug 01 07:00 PM 2007 J - * - * FFTPACK implementation - * - * Original code by Pearu Peterson. - */ - -extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); -extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); -extern void F_FUNC(dffti, DFFTI) (int *, double *); -GEN_CACHE(drfftpack, (int n) - , double *wsave; - , (caches_drfftpack[i].n == n) - , caches_drfftpack[id].wsave = - (double *) malloc(sizeof(double) * (2 * n + 15)); - F_FUNC(dffti, DFFTI) (&n, caches_drfftpack[id].wsave); - , free(caches_drfftpack[id].wsave); - , 10) - -static void drfft_fftpack(double *inout, int n, int direction, int howmany, - int normalize) -{ - int i; - double *ptr = inout; - double *wsave = NULL; - wsave = caches_drfftpack[get_cache_id_drfftpack(n)].wsave; - - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - dfftf_(&n, ptr, wsave); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - dfftb_(&n, ptr, wsave); - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/drfft_fftpack.c) Copied: branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx (from rev 4218, branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx) Copied: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/zfftnd_fftpack.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:51:23 UTC (rev 4227) @@ -51,7 +51,7 @@ GEN_PUBLIC_API(mkl) #endif #else /* Use fftpack by default */ - #include "zfft_fftpack.cxx" + #include "fftpack/zfft.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftpack) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/src/zfft_fftpack.cxx 2008-05-05 10:51:23 UTC (rev 4227) @@ -1,107 +0,0 @@ -#include - -#include "cycliccache.h" - -extern "C" { - extern void F_FUNC(zfftf,ZFFTF)(int*,double*,double*); - extern void F_FUNC(zfftb,ZFFTB)(int*,double*,double*); - extern void F_FUNC(zffti,ZFFTI)(int*,double*); -}; - -using namespace fft; - -class FFTPackCacheId : public CacheId { - public: - FFTPackCacheId(int n) : CacheId(n) {}; -}; - -class FFTPackCache: public Cache { - public: - FFTPackCache(const FFTPackCacheId& id); - virtual ~FFTPackCache(); - - int compute_forward(complex_double * inout) const; - int compute_backward(complex_double * inout) const; - - protected: - double* m_wsave; -}; - -FFTPackCache::FFTPackCache(const FFTPackCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - m_wsave = (double *)malloc(sizeof(*m_wsave) * (4 * n + 15)); - if (m_wsave == NULL) { - goto fail; - } - - F_FUNC(zffti,ZFFTI)(&n, m_wsave); - - return; - -fail: - throw std::bad_alloc(); -} - -FFTPackCache::~FFTPackCache() -{ - free(m_wsave); -} - -int FFTPackCache::compute_forward(complex_double *inout) const -{ - int n = m_id.m_n; - - zfftf_(&n, (double *)(inout), m_wsave); - return 0; -} - -int FFTPackCache::compute_backward(complex_double *inout) const -{ - int n = m_id.m_n; - - zfftb_(&n, (double *)(inout), m_wsave); - return 0; -} - -static CacheManager fftpack_cmgr(10); - -void destroy_zfftpack_caches() -{ -} - -static void zfft_fftpack(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - FFTPackCache *cache; - - cache = fftpack_cmgr.get_cache(FFTPackCacheId(n)); - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-05 10:51:23 UTC (rev 4227) @@ -40,6 +40,6 @@ #include "mkl/zfftnd.c" GEN_PUBLIC_API(mkl) #else /* Use fftpack by default */ - #include "zfftnd_fftpack.c" + #include "fftpack/zfftnd.c" GEN_PUBLIC_API(fftpack) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfftnd_fftpack.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd_fftpack.c 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd_fftpack.c 2008-05-05 10:51:23 UTC (rev 4227) @@ -1,118 +0,0 @@ -/* - * fftpack backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Wed Aug 08 02:00 PM 2007 J - */ - -GEN_CACHE(zfftnd_fftpack, (int n, int rank) - , complex_double * ptr; int *iptr; int rank; - , ((caches_zfftnd_fftpack[i].n == n) - && (caches_zfftnd_fftpack[i].rank == rank)) - , caches_zfftnd_fftpack[id].n = n; - caches_zfftnd_fftpack[id].ptr = - (complex_double *) malloc(2 * sizeof(double) * n); - caches_zfftnd_fftpack[id].iptr = - (int *) malloc(4 * rank * sizeof(int)); - , - free(caches_zfftnd_fftpack[id].ptr); - free(caches_zfftnd_fftpack[id].iptr); - , 10) - -static -/*inline : disabled because MSVC6.0 fails to compile it. */ -int next_comb(int *ia, int *da, int m) -{ - while (m >= 0 && ia[m] == da[m]) { - ia[m--] = 0; - } - if (m < 0) { - return 0; - } - ia[m]++; - return 1; -} - -static -void flatten(complex_double * dest, complex_double * src, - int rank, int strides_axis, int dims_axis, int unflat, - int *tmp) -{ - int *new_strides = tmp + rank; - int *new_dims = tmp + 2 * rank; - int *ia = tmp + 3 * rank; - int rm1 = rank - 1, rm2 = rank - 2; - int i, j, k; - for (i = 0; i < rm2; ++i) - ia[i] = 0; - ia[rm2] = -1; - j = 0; - if (unflat) { - while (next_comb(ia, new_dims, rm2)) { - k = 0; - for (i = 0; i < rm1; ++i) { - k += ia[i] * new_strides[i]; - } - for (i = 0; i < dims_axis; ++i) { - *(dest + k + i * strides_axis) = *(src + j++); - } - } - } else { - while (next_comb(ia, new_dims, rm2)) { - k = 0; - for (i = 0; i < rm1; ++i) { - k += ia[i] * new_strides[i]; - } - for (i = 0; i < dims_axis; ++i) { - *(dest + j++) = *(src + k + i * strides_axis); - } - } - } -} - -extern void zfft(complex_double * inout, - int n, int direction, int howmany, int normalize); - -extern void zfftnd_fftpack(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - int axis; - complex_double *tmp; - int *itmp; - int k, j; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - zfft(ptr, dims[rank - 1], direction, howmany * sz / dims[rank - 1], - normalize); - - i = get_cache_id_zfftnd_fftpack(sz, rank); - tmp = caches_zfftnd_fftpack[i].ptr; - itmp = caches_zfftnd_fftpack[i].iptr; - - itmp[rank - 1] = 1; - for (i = 2; i <= rank; ++i) { - itmp[rank - i] = itmp[rank - i + 1] * dims[rank - i + 1]; - } - - for (i = 0; i < howmany; ++i, ptr += sz) { - for (axis = 0; axis < rank - 1; ++axis) { - for (k = j = 0; k < rank; ++k) { - if (k != axis) { - *(itmp + rank + j) = itmp[k]; - *(itmp + 2 * rank + j++) = dims[k] - 1; - } - } - flatten(tmp, ptr, rank, itmp[axis], dims[axis], 0, itmp); - zfft(tmp, dims[axis], direction, sz / dims[axis], normalize); - flatten(ptr, tmp, rank, itmp[axis], dims[axis], 1, itmp); - } - } - -} From scipy-svn at scipy.org Mon May 5 06:54:42 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 05:54:42 -0500 (CDT) Subject: [Scipy-svn] r4228 - in branches/refactor_fft/scipy/fftpack: . src src/djbfft Message-ID: <20080505105442.1691E39C45E@new.scipy.org> Author: cdavid Date: 2008-05-05 05:54:32 -0500 (Mon, 05 May 2008) New Revision: 4228 Added: branches/refactor_fft/scipy/fftpack/src/djbfft/ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx Removed: branches/refactor_fft/scipy/fftpack/src/drfft_djbfft.c branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.c branches/refactor_fft/scipy/fftpack/src/zfft.cxx Log: Move djbfft backend source code in subdir. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:51:23 UTC (rev 4227) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:54:32 UTC (rev 4228) @@ -30,9 +30,9 @@ sources=sources, libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/zfft_djbfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', + depends=['src/djbfft/zfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', - 'src/drfft_djbfft.c', 'src/fftpack/drfft.c', + 'src/djbfft/drfft.c', 'src/fftpack/drfft.c', 'src/fftw3/drfft.c', 'src/fftw/drfft.c', 'src/fftpack/zfftnd.c', 'src/fftw/zfftnd.c', 'src/fftw3/zfftnd.c', 'src/mkl/zfftnd.c', Copied: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c (from rev 4212, branches/refactor_fft/scipy/fftpack/src/drfft_djbfft.c) Copied: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx (from rev 4217, branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx) Modified: branches/refactor_fft/scipy/fftpack/src/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:51:23 UTC (rev 4227) +++ branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 10:54:32 UTC (rev 4228) @@ -57,7 +57,7 @@ * above) for non 2^n * size */ #ifdef WITH_DJBFFT - #include "drfft_djbfft.c" + #include "djbfft/drfft.c" void destroy_drfft_cache(void) { destroy_drdjbfft_caches(); Deleted: branches/refactor_fft/scipy/fftpack/src/drfft_djbfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft_djbfft.c 2008-05-05 10:51:23 UTC (rev 4227) +++ branches/refactor_fft/scipy/fftpack/src/drfft_djbfft.c 2008-05-05 10:54:32 UTC (rev 4228) @@ -1,131 +0,0 @@ -/* - * Last Change: Wed Aug 01 08:00 PM 2007 J - * - * Original code by Pearu Peterson. - */ - -/* - * DJBFFT only implements size 2^N ! - * - * drfft_def and drfft_def_destroy_cache are the functions used for size different - * than 2^N - */ -#ifdef WITH_FFTW3 -#define drfft_def drfft_fftw3 -#define drfft_def_destroy_cache destroy_drfftw3_caches -#elif defined WITH_FFTW -#define drfft_def drfft_fftw -#define drfft_def_destroy_cache destroy_drfftw_caches -#else -#define drfft_def drfft_fftpack -#define drfft_def_destroy_cache destroy_drfftpack_caches -#endif - -GEN_CACHE(drdjbfft, (int n) - , unsigned int *f; - double *ptr;, - caches_drdjbfft[i].n == n, - caches_drdjbfft[id].f = (unsigned int *) malloc(sizeof(unsigned int) * (n)); - caches_drdjbfft[id].ptr = (double *) malloc(sizeof(double) * n); - fftfreq_rtable(caches_drdjbfft[id].f, n);, - free(caches_drdjbfft[id].f); - free(caches_drdjbfft[id].ptr);, - 10) - -/**************** ZFFT function **********************/ -static void drfft_djbfft(double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - double *ptr = inout; - double *ptrc = NULL; - unsigned int *f = NULL; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - i = get_cache_id_drdjbfft(n); - f = caches_drdjbfft[i].f; - ptrc = caches_drdjbfft[i].ptr; - } - if (f == NULL) { - drfft_def(inout, n, direction, howmany, normalize); - } - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - COPYSTD2DJB(ptr, ptrc, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYDJB2STD(ptrc, ptr, f, n); - } - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - COPYINVSTD2DJB(ptr, ptrc, normalize, f, n); - switch (n) { - -#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(ptrc);fftr8_un##N(ptrc);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYINVDJB2STD(ptrc, ptr, n); - } - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize && f != NULL && direction == 1) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:51:23 UTC (rev 4227) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-05 10:54:32 UTC (rev 4228) @@ -62,7 +62,7 @@ * above) for non 2^n * size */ #ifdef WITH_DJBFFT - #include "zfft_djbfft.cxx" + #include "djbfft/zfft.cxx" extern "C" void destroy_zfft_cache(void) { destroy_zdjbfft_caches(); Deleted: branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx 2008-05-05 10:51:23 UTC (rev 4227) +++ branches/refactor_fft/scipy/fftpack/src/zfft_djbfft.cxx 2008-05-05 10:54:32 UTC (rev 4228) @@ -1,229 +0,0 @@ -/* -* DJBFFT only implements size 2^N ! -* -* zfft_def and zfft_def_destroy_cache are the functions -* used for size different than 2^N -*/ -#ifdef WITH_FFTWORK -#define zfft_def zfft_fftwork -#define zfft_def_destroy_cache destroy_zfftwork_cache -#elif defined WITH_FFTW3 -#define zfft_def zfft_fftw3 -#define zfft_def_destroy_cache destroy_zfftw3_caches -#elif defined WITH_FFTW -#define zfft_def zfft_fftw -#define zfft_def_destroy_cache destroy_zfftw_caches -#else -#define zfft_def zfft_fftpack -#define zfft_def_destroy_cache destroy_zfftpack_caches -#endif - -class DJBFFTCacheId : public CacheId { - public: - DJBFFTCacheId(int n) : CacheId(n) {}; -}; - -class DJBFFTCache: public Cache { - public: - DJBFFTCache(const DJBFFTCacheId& id); - virtual ~DJBFFTCache(); - - int compute_forward(complex_double * inout) const; - int compute_backward(complex_double * inout) const; - int normalize(complex_double * inout) const; - - protected: - unsigned int* m_f; - double* m_ptr; -}; - -DJBFFTCache::DJBFFTCache(const DJBFFTCacheId& id) -: Cache(id) -{ - int i; - int n = id.m_n; - - m_f = (unsigned int*)malloc(sizeof(*m_f) * n); - if (m_f == NULL) { - goto fail_f; - } - - m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); - if (m_ptr == NULL) { - goto clean_f; - } - - fftfreq_ctable(m_f, id.m_n); - for(i = 0; i < n; ++i) { - m_f[i] = (id.m_n - m_f[i]) % id.m_n; - } - return; - -clean_f: - free(m_f); -fail_f: - throw std::bad_alloc(); -} - -DJBFFTCache::~DJBFFTCache() -{ - free(m_ptr); - free(m_f); -} - -int DJBFFTCache::compute_forward(complex_double *inout) const -{ - const int n = m_id.m_n; - int j; - - complex_double *ptrc = NULL; - complex_double *ptr = inout; - - ptrc = (complex_double*)m_ptr; - - memcpy(ptrc, ptr, 2 * n * sizeof(double)); - switch (n) { -#define TMPCASE(N) case N: fftc8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - for (j = 0; j < n; ++j) { - *(ptr + m_f[j]) = *(ptrc + j); - } - - return 0; -} - -int DJBFFTCache::compute_backward(complex_double *inout) const -{ - const int n = m_id.m_n; - int j; - - complex_double *ptrc = NULL; - complex_double *ptr = inout; - - ptrc = (complex_double*)m_ptr; - - for (j = 0; j < n; ++j) { - *(ptrc + j) = *(ptr + m_f[j]); - } - switch (n) { -#define TMPCASE(N) case N: fftc8_un##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - memcpy(ptr, ptrc, 2 * n * sizeof(double)); - - return 0; -} - -int DJBFFTCache::normalize(complex_double *ptr) const -{ - int n = m_id.m_n; - - switch (n) { -#define TMPCASE(N) case N: fftc8_scale##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - - return 0; -} - -static CacheManager djbfft_cmgr(10); - -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zdjbfft_caches() -{ -} - -/**************** ZFFT function **********************/ -static void zfft_djbfft(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - DJBFFTCache *cache; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - cache = djbfft_cmgr.get_cache(DJBFFTCacheId(n)); - break; - default: - /* For sizes not handled by djbfft, use default implementation - * and returns */ - zfft_def(inout, n, direction, howmany, normalize); - return; - } - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = 0; i < howmany; ++i, ptr += n) { - cache->normalize(ptr); - } - } -} From scipy-svn at scipy.org Mon May 5 07:03:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 06:03:36 -0500 (CDT) Subject: [Scipy-svn] r4229 - in branches/refactor_fft: . scipy/fftpack scipy/linalg scipy/optimize scipy/sandbox/exmplpackage scipy/sandbox/exmplpackage/benchmarks scipy/sandbox/exmplpackage/tests scipy/sandbox/exmplpackage/yyy scipy/sandbox/exmplpackage/yyy/tests scipy/sparse scipy/sparse/benchmarks scipy/sparse/tests Message-ID: <20080505110336.D739339C45E@new.scipy.org> Author: cdavid Date: 2008-05-05 06:03:00 -0500 (Mon, 05 May 2008) New Revision: 4229 Added: branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks/ branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py branches/refactor_fft/scipy/sparse/benchmarks/ branches/refactor_fft/scipy/sparse/benchmarks/bench_sparse.py Removed: branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py branches/refactor_fft/scipy/sparse/benchmarks/bench_sparse.py branches/refactor_fft/scipy/sparse/tests/bench_sparse.py Modified: branches/refactor_fft/ branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/linalg/setup.py branches/refactor_fft/scipy/optimize/setup.py branches/refactor_fft/scipy/sandbox/exmplpackage/__init__.py branches/refactor_fft/scipy/sandbox/exmplpackage/setup.py branches/refactor_fft/scipy/sandbox/exmplpackage/tests/test_foo.py branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/__init__.py branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py branches/refactor_fft/scipy/sparse/setup.py Log: Merged revisions 4212-4228 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r4221 | matthew.brett at gmail.com | 2008-05-05 19:21:51 +0900 (Mon, 05 May 2008) | 1 line Added benchmark directories to setup.py ........ r4222 | matthew.brett at gmail.com | 2008-05-05 19:32:31 +0900 (Mon, 05 May 2008) | 1 line Moved sparse benchmarks to benchmarks directory ........ r4226 | matthew.brett at gmail.com | 2008-05-05 19:49:32 +0900 (Mon, 05 May 2008) | 1 line Updated exmplpackage to nose tests framework ........ Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4211 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4228 Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -19,6 +19,7 @@ djbfft_info = get_info('djbfft') config.add_data_dir('tests') + config.add_data_dir('benchmarks') config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) Modified: branches/refactor_fft/scipy/linalg/setup.py =================================================================== --- branches/refactor_fft/scipy/linalg/setup.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/linalg/setup.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -184,7 +184,7 @@ ) config.add_data_dir('tests') - + config.add_data_dir('benchmarks') return config if __name__ == '__main__': Modified: branches/refactor_fft/scipy/optimize/setup.py =================================================================== --- branches/refactor_fft/scipy/optimize/setup.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/optimize/setup.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -42,6 +42,7 @@ config.add_extension('_slsqp', sources=[join('slsqp', x) for x in sources]) config.add_data_dir('tests') + config.add_data_dir('benchmarks') return config if __name__ == '__main__': Modified: branches/refactor_fft/scipy/sandbox/exmplpackage/__init__.py =================================================================== --- branches/refactor_fft/scipy/sandbox/exmplpackage/__init__.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sandbox/exmplpackage/__init__.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -5,6 +5,10 @@ # Get documentation string: from info_exmplpackage import __doc__ +# Import testing rig, allowing scipy.examplpackage.test() +from scipy.testing.pkgtester import Tester +test = Tester().test + # Import symbols from sub-module: from foo import * Copied: branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks (from rev 4226, trunk/scipy/sandbox/exmplpackage/benchmarks) Deleted: branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -1,19 +0,0 @@ -#!/usr/bin/env python -# -__usage__ = """ -First ensure that scipy core modules are installed. - -Run benchmarks if scipy is installed: - python -c 'import scipy;scipy.exmplpackage.bench(label=,verbose=)' -""" - -import sys -from scipy.testing import * - -from scipy.sandbox.exmplpackage.foo import * - -class BenchFooBar(TestCase): - - def bench_simple(self): - print 'A long timed benchmark here' - Copied: branches/refactor_fft/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py (from rev 4226, trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py) Modified: branches/refactor_fft/scipy/sandbox/exmplpackage/setup.py =================================================================== --- branches/refactor_fft/scipy/sandbox/exmplpackage/setup.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sandbox/exmplpackage/setup.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -9,8 +9,9 @@ from numpy.distutils.misc_util import Configuration config = Configuration('exmplpackage',parent_package,top_path) - # include test scripts from tests + # include test scripts from tests, and any benchmarks config.add_data_dir('tests') + config.add_data_dir('benchmarks') # exmplpackage contains Python sub-package yyy config.add_subpackage('yyy') Modified: branches/refactor_fft/scipy/sandbox/exmplpackage/tests/test_foo.py =================================================================== --- branches/refactor_fft/scipy/sandbox/exmplpackage/tests/test_foo.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sandbox/exmplpackage/tests/test_foo.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -9,10 +9,10 @@ Build exmplpackage: python setup.py build Run tests locally: - python tests/test_foo.py [-l] [-v] + python tests/test_foo.py Run tests if scipy is installed: - python -c 'import scipy;scipy.exmplpackage.test(level=,verbosity=)' + python -c 'import scipy;scipy.exmplpackage.test(label=,verbose=)' """ import sys @@ -22,12 +22,12 @@ class TestFooBar(TestCase): - def check_simple(self, level=1): + def test_simple(self): assert exmplpackage_foo_bar()=='Hello from exmplpackage_foo_bar' class TestFooGun(TestCase): - def check_simple(self, level=1): + def test_simple(self): assert foo_gun()=='Hello from foo_gun' if __name__ == "__main__": Modified: branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/__init__.py =================================================================== --- branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/__init__.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/__init__.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -2,7 +2,11 @@ yyy - Subpackage of Scipy module exmplpackage """ -__all__ = ['fun'] +__all__ = ['fun', 'test'] +# Import testing rig, allowing scipy.examplpackage.yyy.test() +from scipy.testing.pkgtester import Tester +test = Tester().test + def fun(): return 'Hello from yyy.fun' Modified: branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py =================================================================== --- branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -1,16 +1,12 @@ -import sys -from numpy.test.testing import * +from scipy.testing import * -set_package_path() -# make sure that all yyy symbols are imported before the del statement: from yyy import fun -del sys.path[0] -class TestFun(NumpyTestCase): - def check_simple(self, level=1): +class TestFun(TestCase): + def test_simple(self): assert fun()=='Hello from yyy.fun' #... if __name__ == "__main__": - NumpyTest().run() + nose.run(argv=['', __file__]) Copied: branches/refactor_fft/scipy/sparse/benchmarks (from rev 4226, trunk/scipy/sparse/benchmarks) Deleted: branches/refactor_fft/scipy/sparse/benchmarks/bench_sparse.py =================================================================== --- trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-05-05 10:49:32 UTC (rev 4226) +++ branches/refactor_fft/scipy/sparse/benchmarks/bench_sparse.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -1,280 +0,0 @@ -"""general tests and simple benchmarks for the sparse module""" - -import time - -import numpy -from numpy import ones, array, asarray, empty - -from scipy.testing import * - -from scipy import sparse -from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \ - coo_matrix, lil_matrix, dia_matrix, spdiags - - -def random_sparse(m,n,nnz_per_row): - rows = numpy.arange(m).repeat(nnz_per_row) - cols = numpy.random.random_integers(low=0,high=n-1,size=nnz_per_row*m) - vals = numpy.random.random_sample(m*nnz_per_row) - return coo_matrix((vals,(rows,cols)),(m,n)).tocsr() - - -#TODO move this to a matrix gallery and add unittests -def poisson2d(N,dtype='d',format=None): - """ - Return a sparse matrix for the 2d poisson problem - with standard 5-point finite difference stencil on a - square N-by-N grid. - """ - if N == 1: - diags = asarray( [[4]],dtype=dtype) - return dia_matrix((diags,[0]), shape=(1,1)).asformat(format) - - offsets = array([0,-N,N,-1,1]) - - diags = empty((5,N**2),dtype=dtype) - - diags[0] = 4 #main diagonal - diags[1:] = -1 #all offdiagonals - - diags[3,N-1::N] = 0 #first lower diagonal - diags[4,N::N] = 0 #first upper diagonal - - return dia_matrix((diags,offsets),shape=(N**2,N**2)).asformat(format) - -class BenchmarkSparse(TestCase): - """Simple benchmarks for sparse matrix module""" - - def bench_arithmetic(self): - matrices = [] - #matrices.append( ('A','Identity', sparse.identity(500**2,format='csr')) ) - matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr')) ) - matrices.append( ('B','Poisson5pt^2', poisson2d(500,format='csr')**2) ) - - print - print ' Sparse Matrix Arithmetic' - print '====================================================================' - print ' var | name | shape | dtype | nnz ' - print '--------------------------------------------------------------------' - fmt = ' %1s | %14s | %20s | %9s | %8d ' - - for var,name,mat in matrices: - name = name.center(14) - shape = ("%s" % (mat.shape,)).center(20) - dtype = mat.dtype.name.center(9) - print fmt % (var,name,shape,dtype,mat.nnz) - - space = ' ' * 10 - print - print space+' Timings' - print space+'==========================================' - print space+' format | operation | time (msec) ' - print space+'------------------------------------------' - fmt = space+' %3s | %17s | %7.1f ' - - for format in ['csr']: - vars = dict( [(var,mat.asformat(format)) for (var,name,mat) in matrices ] ) - for X,Y in [ ('A','A'),('A','B'),('B','A'),('B','B') ]: - x,y = vars[X],vars[Y] - for op in ['__add__','__sub__','multiply','__div__','__mul__']: - fn = getattr(x,op) - fn(y) #warmup - - start = time.clock() - iter = 0 - while iter < 5 or time.clock() < start + 1: - fn(y) - iter += 1 - end = time.clock() - - msec_per_it = 1000*(end - start)/float(iter) - operation = (X + '.' + op + '(' + Y + ')').center(17) - print fmt % (format,operation,msec_per_it) - - - def bench_sort(self): - """sort CSR column indices""" - matrices = [] - matrices.append( ('Rand10', 1e4, 10) ) - matrices.append( ('Rand25', 1e4, 25) ) - matrices.append( ('Rand50', 1e4, 50) ) - matrices.append( ('Rand100', 1e4, 100) ) - matrices.append( ('Rand200', 1e4, 200) ) - - print - print ' Sparse Matrix Index Sorting' - print '=====================================================================' - print ' type | name | shape | nnz | time (msec) ' - print '---------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.2f ' - - for name,N,K in matrices: - N = int(N) - A = random_sparse(N,N,K) - - start = time.clock() - iter = 0 - while iter < 5 and time.clock() - start < 1: - A.has_sorted_indices = False - A.sort_indices() - iter += 1 - end = time.clock() - - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - - print fmt % (A.format,name,shape,A.nnz,1e3*(end-start)/float(iter) ) - - def bench_matvec(self): - matrices = [] - matrices.append(('Identity', sparse.identity(10**4,format='dia'))) - matrices.append(('Identity', sparse.identity(10**4,format='csr'))) - matrices.append(('Poisson5pt', poisson2d(300,format='dia'))) - matrices.append(('Poisson5pt', poisson2d(300,format='csr'))) - matrices.append(('Poisson5pt', poisson2d(300,format='bsr'))) - - A = sparse.kron(poisson2d(150),ones((2,2))).tobsr(blocksize=(2,2)) - matrices.append( ('Block2x2', A.tocsr()) ) - matrices.append( ('Block2x2', A) ) - - A = sparse.kron(poisson2d(100),ones((3,3))).tobsr(blocksize=(3,3)) - matrices.append( ('Block3x3', A.tocsr()) ) - matrices.append( ('Block3x3', A) ) - - print - print ' Sparse Matrix Vector Product' - print '==================================================================' - print ' type | name | shape | nnz | MFLOPs ' - print '------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.1f ' - - for name,A in matrices: - x = ones(A.shape[1],dtype=A.dtype) - - y = A*x #warmup - - start = time.clock() - iter = 0 - while iter < 5 or time.clock() < start + 1: - y = A*x - #try: - # #avoid creating y if possible - # A.matvec(x,y) - #except: - # y = A*x - iter += 1 - end = time.clock() - - del y - - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - MFLOPs = (2*A.nnz*iter/(end-start))/float(1e6) - - print fmt % (A.format,name,shape,A.nnz,MFLOPs) - - def bench_construction(self): - """build matrices by inserting single values""" - matrices = [] - matrices.append( ('Empty',csr_matrix((10000,10000))) ) - matrices.append( ('Identity',sparse.identity(10000)) ) - matrices.append( ('Poisson5pt', poisson2d(100)) ) - - print - print ' Sparse Matrix Construction' - print '====================================================================' - print ' type | name | shape | nnz | time (sec) ' - print '--------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.4f ' - - for name,A in matrices: - A = A.tocoo() - - for format in ['lil','dok']: - - start = time.clock() - - iter = 0 - while time.clock() < start + 0.5: - T = eval(format + '_matrix')(A.shape) - for i,j,v in zip(A.row,A.col,A.data): - T[i,j] = v - iter += 1 - end = time.clock() - - del T - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - - print fmt % (format,name,shape,A.nnz,(end-start)/float(iter)) - - def bench_conversion(self): - A = poisson2d(100) - - formats = ['csr','csc','coo','lil','dok'] - - print - print ' Sparse Matrix Conversion' - print '==========================================================' - print ' format | tocsr() | tocsc() | tocoo() | tolil() | todok() ' - print '----------------------------------------------------------' - - for fromfmt in formats: - base = getattr(A,'to' + fromfmt)() - - times = [] - - for tofmt in formats: - try: - fn = getattr(base,'to' + tofmt) - except: - times.append(None) - else: - x = fn() #warmup - start = time.clock() - iter = 0 - while time.clock() < start + 0.2: - x = fn() - iter += 1 - end = time.clock() - del x - times.append( (end - start)/float(iter)) - - output = " %3s " % fromfmt - for t in times: - if t is None: - output += '| n/a ' - else: - output += '| %5.1fms ' % (1000*t) - print output - - -#class TestLarge(TestCase): -# def bench_large(self): -# # Create a 100x100 matrix with 100 non-zero elements -# # and play around with it -# #TODO move this out of Common since it doesn't use spmatrix -# random.seed(0) -# A = dok_matrix((100,100)) -# for k in range(100): -# i = random.randrange(100) -# j = random.randrange(100) -# A[i,j] = 1. -# csr = A.tocsr() -# csc = A.tocsc() -# csc2 = csr.tocsc() -# coo = A.tocoo() -# csr2 = coo.tocsr() -# assert_array_equal(A.transpose().todense(), csr.transpose().todense()) -# assert_array_equal(csc.todense(), csr.todense()) -# assert_array_equal(csr.todense(), csr2.todense()) -# assert_array_equal(csr2.todense().transpose(), coo.transpose().todense()) -# assert_array_equal(csr2.todense(), csc2.todense()) -# csr_plus_csc = csr + csc -# csc_plus_csr = csc + csr -# assert_array_equal(csr_plus_csc.todense(), (2*A).todense()) -# assert_array_equal(csr_plus_csc.todense(), csc_plus_csr.todense()) - - -if __name__ == "__main__": - nose.run(argv=['', __file__]) Copied: branches/refactor_fft/scipy/sparse/benchmarks/bench_sparse.py (from rev 4226, trunk/scipy/sparse/benchmarks/bench_sparse.py) Modified: branches/refactor_fft/scipy/sparse/setup.py =================================================================== --- branches/refactor_fft/scipy/sparse/setup.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sparse/setup.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -7,8 +7,9 @@ config = Configuration('sparse',parent_package,top_path) config.add_data_dir('tests') + config.add_data_dir('benchmarks') + config.add_subpackage('linalg') - config.add_subpackage('sparsetools') return config Deleted: branches/refactor_fft/scipy/sparse/tests/bench_sparse.py =================================================================== --- branches/refactor_fft/scipy/sparse/tests/bench_sparse.py 2008-05-05 10:54:32 UTC (rev 4228) +++ branches/refactor_fft/scipy/sparse/tests/bench_sparse.py 2008-05-05 11:03:00 UTC (rev 4229) @@ -1,280 +0,0 @@ -"""general tests and simple benchmarks for the sparse module""" - -import time - -import numpy -from numpy import ones, array, asarray, empty - -from scipy.testing import * - -from scipy import sparse -from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \ - coo_matrix, lil_matrix, dia_matrix, spdiags - - -def random_sparse(m,n,nnz_per_row): - rows = numpy.arange(m).repeat(nnz_per_row) - cols = numpy.random.random_integers(low=0,high=n-1,size=nnz_per_row*m) - vals = numpy.random.random_sample(m*nnz_per_row) - return coo_matrix((vals,(rows,cols)),(m,n)).tocsr() - - -#TODO move this to a matrix gallery and add unittests -def poisson2d(N,dtype='d',format=None): - """ - Return a sparse matrix for the 2d poisson problem - with standard 5-point finite difference stencil on a - square N-by-N grid. - """ - if N == 1: - diags = asarray( [[4]],dtype=dtype) - return dia_matrix((diags,[0]), shape=(1,1)).asformat(format) - - offsets = array([0,-N,N,-1,1]) - - diags = empty((5,N**2),dtype=dtype) - - diags[0] = 4 #main diagonal - diags[1:] = -1 #all offdiagonals - - diags[3,N-1::N] = 0 #first lower diagonal - diags[4,N::N] = 0 #first upper diagonal - - return dia_matrix((diags,offsets),shape=(N**2,N**2)).asformat(format) - -class BenchmarkSparse(TestCase): - """Simple benchmarks for sparse matrix module""" - - def bench_arithmetic(self): - matrices = [] - #matrices.append( ('A','Identity', sparse.identity(500**2,format='csr')) ) - matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr')) ) - matrices.append( ('B','Poisson5pt^2', poisson2d(500,format='csr')**2) ) - - print - print ' Sparse Matrix Arithmetic' - print '====================================================================' - print ' var | name | shape | dtype | nnz ' - print '--------------------------------------------------------------------' - fmt = ' %1s | %14s | %20s | %9s | %8d ' - - for var,name,mat in matrices: - name = name.center(14) - shape = ("%s" % (mat.shape,)).center(20) - dtype = mat.dtype.name.center(9) - print fmt % (var,name,shape,dtype,mat.nnz) - - space = ' ' * 10 - print - print space+' Timings' - print space+'==========================================' - print space+' format | operation | time (msec) ' - print space+'------------------------------------------' - fmt = space+' %3s | %17s | %7.1f ' - - for format in ['csr']: - vars = dict( [(var,mat.asformat(format)) for (var,name,mat) in matrices ] ) - for X,Y in [ ('A','A'),('A','B'),('B','A'),('B','B') ]: - x,y = vars[X],vars[Y] - for op in ['__add__','__sub__','multiply','__div__','__mul__']: - fn = getattr(x,op) - fn(y) #warmup - - start = time.clock() - iter = 0 - while iter < 5 or time.clock() < start + 1: - fn(y) - iter += 1 - end = time.clock() - - msec_per_it = 1000*(end - start)/float(iter) - operation = (X + '.' + op + '(' + Y + ')').center(17) - print fmt % (format,operation,msec_per_it) - - - def bench_sort(self): - """sort CSR column indices""" - matrices = [] - matrices.append( ('Rand10', 1e4, 10) ) - matrices.append( ('Rand25', 1e4, 25) ) - matrices.append( ('Rand50', 1e4, 50) ) - matrices.append( ('Rand100', 1e4, 100) ) - matrices.append( ('Rand200', 1e4, 200) ) - - print - print ' Sparse Matrix Index Sorting' - print '=====================================================================' - print ' type | name | shape | nnz | time (msec) ' - print '---------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.2f ' - - for name,N,K in matrices: - N = int(N) - A = random_sparse(N,N,K) - - start = time.clock() - iter = 0 - while iter < 5 and time.clock() - start < 1: - A.has_sorted_indices = False - A.sort_indices() - iter += 1 - end = time.clock() - - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - - print fmt % (A.format,name,shape,A.nnz,1e3*(end-start)/float(iter) ) - - def bench_matvec(self): - matrices = [] - matrices.append(('Identity', sparse.identity(10**4,format='dia'))) - matrices.append(('Identity', sparse.identity(10**4,format='csr'))) - matrices.append(('Poisson5pt', poisson2d(300,format='dia'))) - matrices.append(('Poisson5pt', poisson2d(300,format='csr'))) - matrices.append(('Poisson5pt', poisson2d(300,format='bsr'))) - - A = sparse.kron(poisson2d(150),ones((2,2))).tobsr(blocksize=(2,2)) - matrices.append( ('Block2x2', A.tocsr()) ) - matrices.append( ('Block2x2', A) ) - - A = sparse.kron(poisson2d(100),ones((3,3))).tobsr(blocksize=(3,3)) - matrices.append( ('Block3x3', A.tocsr()) ) - matrices.append( ('Block3x3', A) ) - - print - print ' Sparse Matrix Vector Product' - print '==================================================================' - print ' type | name | shape | nnz | MFLOPs ' - print '------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.1f ' - - for name,A in matrices: - x = ones(A.shape[1],dtype=A.dtype) - - y = A*x #warmup - - start = time.clock() - iter = 0 - while iter < 5 or time.clock() < start + 1: - y = A*x - #try: - # #avoid creating y if possible - # A.matvec(x,y) - #except: - # y = A*x - iter += 1 - end = time.clock() - - del y - - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - MFLOPs = (2*A.nnz*iter/(end-start))/float(1e6) - - print fmt % (A.format,name,shape,A.nnz,MFLOPs) - - def bench_construction(self): - """build matrices by inserting single values""" - matrices = [] - matrices.append( ('Empty',csr_matrix((10000,10000))) ) - matrices.append( ('Identity',sparse.identity(10000)) ) - matrices.append( ('Poisson5pt', poisson2d(100)) ) - - print - print ' Sparse Matrix Construction' - print '====================================================================' - print ' type | name | shape | nnz | time (sec) ' - print '--------------------------------------------------------------------' - fmt = ' %3s | %12s | %20s | %8d | %6.4f ' - - for name,A in matrices: - A = A.tocoo() - - for format in ['lil','dok']: - - start = time.clock() - - iter = 0 - while time.clock() < start + 0.5: - T = eval(format + '_matrix')(A.shape) - for i,j,v in zip(A.row,A.col,A.data): - T[i,j] = v - iter += 1 - end = time.clock() - - del T - name = name.center(12) - shape = ("%s" % (A.shape,)).center(20) - - print fmt % (format,name,shape,A.nnz,(end-start)/float(iter)) - - def bench_conversion(self): - A = poisson2d(100) - - formats = ['csr','csc','coo','lil','dok'] - - print - print ' Sparse Matrix Conversion' - print '==========================================================' - print ' format | tocsr() | tocsc() | tocoo() | tolil() | todok() ' - print '----------------------------------------------------------' - - for fromfmt in formats: - base = getattr(A,'to' + fromfmt)() - - times = [] - - for tofmt in formats: - try: - fn = getattr(base,'to' + tofmt) - except: - times.append(None) - else: - x = fn() #warmup - start = time.clock() - iter = 0 - while time.clock() < start + 0.2: - x = fn() - iter += 1 - end = time.clock() - del x - times.append( (end - start)/float(iter)) - - output = " %3s " % fromfmt - for t in times: - if t is None: - output += '| n/a ' - else: - output += '| %5.1fms ' % (1000*t) - print output - - -#class TestLarge(TestCase): -# def bench_large(self): -# # Create a 100x100 matrix with 100 non-zero elements -# # and play around with it -# #TODO move this out of Common since it doesn't use spmatrix -# random.seed(0) -# A = dok_matrix((100,100)) -# for k in range(100): -# i = random.randrange(100) -# j = random.randrange(100) -# A[i,j] = 1. -# csr = A.tocsr() -# csc = A.tocsc() -# csc2 = csr.tocsc() -# coo = A.tocoo() -# csr2 = coo.tocsr() -# assert_array_equal(A.transpose().todense(), csr.transpose().todense()) -# assert_array_equal(csc.todense(), csr.todense()) -# assert_array_equal(csr.todense(), csr2.todense()) -# assert_array_equal(csr2.todense().transpose(), coo.transpose().todense()) -# assert_array_equal(csr2.todense(), csc2.todense()) -# csr_plus_csc = csr + csc -# csc_plus_csr = csc + csr -# assert_array_equal(csr_plus_csc.todense(), (2*A).todense()) -# assert_array_equal(csr_plus_csc.todense(), csc_plus_csr.todense()) - - -if __name__ == "__main__": - nose.run(argv=['', __file__]) From scipy-svn at scipy.org Mon May 5 07:08:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 06:08:18 -0500 (CDT) Subject: [Scipy-svn] r4230 - branches/refactor_fft/scipy/fftpack Message-ID: <20080505110818.44E8B39C1E0@new.scipy.org> Author: cdavid Date: 2008-05-05 06:08:12 -0500 (Mon, 05 May 2008) New Revision: 4230 Modified: branches/refactor_fft/scipy/fftpack/SConstruct Log: scons build: Handle include path for backends. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 11:03:00 UTC (rev 4229) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 11:08:12 UTC (rev 4230) @@ -12,7 +12,10 @@ env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -env.AppendUnique(CPPPATH = ["src"]) +backends_paths = [pjoin(env['build_dir'], 'src', b) + for b in ["mkl", "fftw", "djbfft", "fftpack"]] +env.AppendUnique(CPPPATH = backends_paths) +env.AppendUnique(CPPPATH = [pjoin(env['build_dir'], "src")]) # Check fft implementation config = env.NumpyConfigure(custom_tests = {'CheckFFT': CheckFFT, From scipy-svn at scipy.org Mon May 5 09:02:50 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 08:02:50 -0500 (CDT) Subject: [Scipy-svn] r4231 - branches/refactor_fft/scipy/fftpack Message-ID: <20080505130250.17BCE39C2A6@new.scipy.org> Author: cdavid Date: 2008-05-05 08:02:41 -0500 (Mon, 05 May 2008) New Revision: 4231 Modified: branches/refactor_fft/scipy/fftpack/SConstruct Log: Forgot to add fftw3 specific source dir in scons script. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 11:08:12 UTC (rev 4230) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-05 13:02:41 UTC (rev 4231) @@ -1,4 +1,4 @@ -# Last Change: Mon May 05 07:00 PM 2008 J +# Last Change: Mon May 05 08:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -13,7 +13,7 @@ env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) backends_paths = [pjoin(env['build_dir'], 'src', b) - for b in ["mkl", "fftw", "djbfft", "fftpack"]] + for b in ["mkl", "fftw", "djbfft", "fftpack", "fftw3"]] env.AppendUnique(CPPPATH = backends_paths) env.AppendUnique(CPPPATH = [pjoin(env['build_dir'], "src")]) From scipy-svn at scipy.org Mon May 5 09:07:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 08:07:07 -0500 (CDT) Subject: [Scipy-svn] r4232 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080505130707.48846C7C050@new.scipy.org> Author: cdavid Date: 2008-05-05 08:07:01 -0500 (Mon, 05 May 2008) New Revision: 4232 Added: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx Log: Put CacheId code in separate file for sharing (fftw3 backend only). Added: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-05 13:02:41 UTC (rev 4231) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-05 13:07:01 UTC (rev 4232) @@ -0,0 +1,35 @@ +#ifndef _SCIPYFFT_FFTW_COMMON_H_ +#define _SCIPYFFT_FFTW_COMMON_H_ + +#include "cycliccache.h" + +namespace fft { + +class FFTW3CacheId : public CacheId { + public: + FFTW3CacheId(int n, int dir) : + CacheId(n), + m_dir(dir) + { + }; + + virtual bool operator==(const FFTW3CacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const FFTW3CacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_dir == other.m_dir && th->is_equal(*ot); + } + + public: + int m_dir; +}; + +}; // namespace fft + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-05 13:02:41 UTC (rev 4231) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-05 13:07:01 UTC (rev 4232) @@ -1,30 +1,9 @@ #include -#include "cycliccache.h" +#include "common.h" using namespace fft; -class FFTW3CacheId : public CacheId { - public: - FFTW3CacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; - - virtual bool operator==(const FFTW3CacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTW3CacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; -}; - class FFTW3Cache : public Cache { public: FFTW3Cache(const FFTW3CacheId& id); From scipy-svn at scipy.org Mon May 5 09:08:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 08:08:20 -0500 (CDT) Subject: [Scipy-svn] r4233 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080505130820.84D1739C0DB@new.scipy.org> Author: cdavid Date: 2008-05-05 08:08:12 -0500 (Mon, 05 May 2008) New Revision: 4233 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx Log: Add simd alignement for cache id in fftw3 backend. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-05 13:07:01 UTC (rev 4232) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-05 13:08:12 UTC (rev 4233) @@ -3,13 +3,21 @@ #include "cycliccache.h" +#include + namespace fft { +inline bool is_simd_aligned(const void * p) +{ + return ((reinterpret_cast (p)) & 0xF == 0); +} + class FFTW3CacheId : public CacheId { public: - FFTW3CacheId(int n, int dir) : + FFTW3CacheId(int n, int dir, bool isalign) : CacheId(n), - m_dir(dir) + m_dir(dir), + m_isalign(isalign) { }; @@ -23,11 +31,13 @@ const CacheId *ot = &other; const CacheId *th = this; - return m_dir == other.m_dir && th->is_equal(*ot); + return m_isalign == other.m_isalign && + m_dir == other.m_dir && th->is_equal(*ot); } public: int m_dir; + bool m_isalign; }; }; // namespace fft Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-05 13:07:01 UTC (rev 4232) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-05 13:08:12 UTC (rev 4233) @@ -1,4 +1,5 @@ #include +#include #include "common.h" @@ -9,8 +10,9 @@ FFTW3Cache(const FFTW3CacheId& id); virtual ~FFTW3Cache(); - int compute(fftw_complex* inout) + int compute(fftw_complex* inout) const { + assert (m_id.m_isalign ? is_simd_aligned(inout) : true); fftw_execute_dft(m_plan, inout, inout); return 0; }; @@ -23,14 +25,20 @@ FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) : Cache(id) { + int flags = FFTW_ESTIMATE; + m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); if (m_wrk == NULL) { goto fail_wrk; } + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_UNALIGNED); + flags); if (m_plan == NULL) { goto clean_wrk; @@ -63,11 +71,22 @@ fftw_complex *ptr = (fftw_complex*)inout; double factor = 1./n; FFTW3Cache *cache; + bool isaligned; int i; - cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, dir)); + isaligned = is_simd_aligned(ptr); + if (howmany > 1) { + /* + * If executing for several consecutive buffers, we have to + * check that the shifting one buffer does not make it + * unaligned + */ + isaligned = isaligned && is_simd_aligned(ptr + n); + } + cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); + switch (dir) { case 1: for (i = 0; i < howmany; ++i, ptr += n) { From scipy-svn at scipy.org Mon May 5 12:39:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 May 2008 11:39:28 -0500 (CDT) Subject: [Scipy-svn] r4234 - in branches/refactor_fft/scipy/fftpack: . src src/fftw3 Message-ID: <20080505163928.61A1F39C0DF@new.scipy.org> Author: cdavid Date: 2008-05-05 11:39:18 -0500 (Mon, 05 May 2008) New Revision: 4234 Added: branches/refactor_fft/scipy/fftpack/src/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx Removed: branches/refactor_fft/scipy/fftpack/src/drfft.c branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Moving fftw3 implementation of drfft in c++ code. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 13:08:12 UTC (rev 4233) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-05 16:39:18 UTC (rev 4234) @@ -24,7 +24,7 @@ config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) - sources = ['fftpack.pyf','src/zfft.cxx','src/drfft.c','src/zrfft.c', + sources = ['fftpack.pyf','src/zfft.cxx','src/drfft.cxx','src/zrfft.c', 'src/zfftnd.c'] config.add_extension('_fftpack', @@ -34,7 +34,7 @@ depends=['src/djbfft/zfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', 'src/djbfft/drfft.c', 'src/fftpack/drfft.c', - 'src/fftw3/drfft.c', 'src/fftw/drfft.c', + 'src/fftw3/drfft.cxx', 'src/fftw/drfft.c', 'src/fftpack/zfftnd.c', 'src/fftw/zfftnd.c', 'src/fftw3/zfftnd.c', 'src/mkl/zfftnd.c', ], Deleted: branches/refactor_fft/scipy/fftpack/src/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 13:08:12 UTC (rev 4233) +++ branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 16:39:18 UTC (rev 4234) @@ -1,71 +0,0 @@ -/* - Interface to various FFT libraries. - Double real FFT and IFFT. - Author: Pearu Peterson, August 2002 - */ - -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_PUBLIC_API(name) \ -void destroy_drfft_cache(void)\ -{\ - destroy_dr##name##_caches();\ -}\ -\ -void drfft(double *inout, int n, \ - int direction, int howmany, int normalize)\ -{\ - drfft_##name(inout, n, direction, howmany, normalize);\ -} - -/* ************** Definition of backend specific functions ********* */ - -/* - * To add a backend : - * - create a file drfft_name.c, where you define a function drfft_name where - * name is the name of your backend. If you do not use the GEN_CACHE macro, - * you will need to define a function void destroy_drname_caches(void), - * which can do nothing - * - in drfft.c, include the drfft_name.c file, and add the 3 following lines - * just after it: - * #ifndef WITH_DJBFFT - * GEN_PUBLIC_API(name) - * #endif - */ - -#ifdef WITH_FFTW3 - #include "fftw3/drfft.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw3) - #endif -#elif defined WITH_FFTW - #include "fftw/drfft.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw) - #endif -#else /* Use fftpack by default */ - #include "fftpack/drfft.c" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftpack) - #endif -#endif - -/* - * djbfft must be used at the end, because it needs another backend (defined - * above) for non 2^n * size - */ -#ifdef WITH_DJBFFT - #include "djbfft/drfft.c" - void destroy_drfft_cache(void) - { - destroy_drdjbfft_caches(); - drfft_def_destroy_cache(); - } - void drfft(double *inout, int n, - int direction, int howmany, int normalize) - { - drfft_djbfft(inout, n, direction, howmany, normalize); - } -#endif Copied: branches/refactor_fft/scipy/fftpack/src/drfft.cxx (from rev 4233, branches/refactor_fft/scipy/fftpack/src/drfft.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.c 2008-05-05 13:08:12 UTC (rev 4233) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-05 16:39:18 UTC (rev 4234) @@ -0,0 +1,71 @@ +/* + Interface to various FFT libraries. + Double real FFT and IFFT. + Author: Pearu Peterson, August 2002 + */ + +#include "fftpack.h" + +/* The following macro convert private backend specific function to the public + * functions exported by the module */ +#define GEN_PUBLIC_API(name) \ +void destroy_drfft_cache(void)\ +{\ + destroy_dr##name##_caches();\ +}\ +\ +void drfft(double *inout, int n, \ + int direction, int howmany, int normalize)\ +{\ + drfft_##name(inout, n, direction, howmany, normalize);\ +} + +/* ************** Definition of backend specific functions ********* */ + +/* + * To add a backend : + * - create a file drfft_name.c, where you define a function drfft_name where + * name is the name of your backend. If you do not use the GEN_CACHE macro, + * you will need to define a function void destroy_drname_caches(void), + * which can do nothing + * - in drfft.c, include the drfft_name.c file, and add the 3 following lines + * just after it: + * #ifndef WITH_DJBFFT + * GEN_PUBLIC_API(name) + * #endif + */ + +#ifdef WITH_FFTW3 + #include "fftw3/drfft.cxx" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(fftw3) + #endif +#elif defined WITH_FFTW + #include "fftw/drfft.c" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(fftw) + #endif +#else /* Use fftpack by default */ + #include "fftpack/drfft.c" + #ifndef WITH_DJBFFT + GEN_PUBLIC_API(fftpack) + #endif +#endif + +/* + * djbfft must be used at the end, because it needs another backend (defined + * above) for non 2^n * size + */ +#ifdef WITH_DJBFFT + #include "djbfft/drfft.c" + void destroy_drfft_cache(void) + { + destroy_drdjbfft_caches(); + drfft_def_destroy_cache(); + } + void drfft(double *inout, int n, + int direction, int howmany, int normalize) + { + drfft_djbfft(inout, n, direction, howmany, normalize); + } +#endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c 2008-05-05 13:08:12 UTC (rev 4233) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c 2008-05-05 16:39:18 UTC (rev 4234) @@ -1,65 +0,0 @@ -/* - * Last Change: Wed Aug 01 07:00 PM 2007 J - * - * FFTW3 implementation - * - * Original code by Pearu Peterson. - */ - -GEN_CACHE(drfftw3, (int n, int d, int flags) - , int direction; - int flags; - fftw_plan plan; - double *ptr;, ((caches_drfftw3[i].n == n) && - (caches_drfftw3[i].direction == d) && - (caches_drfftw3[i].flags == flags)) - , caches_drfftw3[id].direction = d; - caches_drfftw3[id].flags = flags; - caches_drfftw3[id].ptr = - (double *) fftw_malloc(sizeof(double) * (n)); - caches_drfftw3[id].plan = - fftw_plan_r2r_1d(n, caches_drfftw3[id].ptr, caches_drfftw3[id].ptr, - (d > 0 ? FFTW_R2HC : FFTW_HC2R), flags);, - fftw_destroy_plan(caches_drfftw3[id].plan); - fftw_free(caches_drfftw3[id].ptr);, 10) - -static void drfft_fftw3(double *inout, int n, int direction, int - howmany, int normalize) -{ - int i; - double *ptr = inout; - - double *ptrc = NULL; - fftw_plan plan = NULL; - - i = get_cache_id_drfftw3(n, direction, FFTW_ESTIMATE); - plan = caches_drfftw3[i].plan; - ptrc = caches_drfftw3[i].ptr; - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - memcpy(ptrc, ptr, sizeof(double) * n); - fftw_execute(plan); - COPYRFFTW2STD(ptrc, ptr, n); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - COPYINVRFFTW2STD(ptr, ptrc, n); - fftw_execute(plan); - memcpy(ptr, ptrc, sizeof(double) * n); - } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx (from rev 4233, branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.c) From scipy-svn at scipy.org Tue May 6 07:59:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 06:59:46 -0500 (CDT) Subject: [Scipy-svn] r4235 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080506115946.5F4FC39C0C3@new.scipy.org> Author: cdavid Date: 2008-05-06 06:59:41 -0500 (Tue, 06 May 2008) New Revision: 4235 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h Log: Fix is_simd_aligned. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-05 16:39:18 UTC (rev 4234) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-06 11:59:41 UTC (rev 4235) @@ -7,9 +7,9 @@ namespace fft { -inline bool is_simd_aligned(const void * p) +inline int is_simd_aligned(const void * p) { - return ((reinterpret_cast (p)) & 0xF == 0); + return (((reinterpret_cast (p)) & 0xF) == 0); } class FFTW3CacheId : public CacheId { From scipy-svn at scipy.org Tue May 6 13:14:48 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 12:14:48 -0500 (CDT) Subject: [Scipy-svn] r4236 - trunk/scipy/stats Message-ID: <20080506171448.C1DFC39C1A6@new.scipy.org> Author: pierregm Date: 2008-05-06 12:14:47 -0500 (Tue, 06 May 2008) New Revision: 4236 Modified: trunk/scipy/stats/mmorestats.py Log: mmorestats : fixed a bug w/ hdquantiles Modified: trunk/scipy/stats/mmorestats.py =================================================================== --- trunk/scipy/stats/mmorestats.py 2008-05-06 11:59:41 UTC (rev 4235) +++ trunk/scipy/stats/mmorestats.py 2008-05-06 17:14:47 UTC (rev 4236) @@ -164,7 +164,7 @@ p = np.array(prob, copy=False, ndmin=1) # Computes quantiles along axis (or globally) if (axis is None): - result = _hdsd_1D(data.compressed(), p) + result = _hdsd_1D(data, p) else: assert data.ndim <= 2, "Array should be 2D at most !" result = ma.apply_along_axis(_hdsd_1D, axis, data, p) From scipy-svn at scipy.org Tue May 6 13:16:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 12:16:53 -0500 (CDT) Subject: [Scipy-svn] r4237 - trunk/scipy/stats Message-ID: <20080506171653.2C29339C3F7@new.scipy.org> Author: pierregm Date: 2008-05-06 12:16:51 -0500 (Tue, 06 May 2008) New Revision: 4237 Modified: trunk/scipy/stats/mstats.py Log: mstats : kendall_tau : fixed a pb when n=2 theil_slopes: return a (4,) tuple instead of a (3,(),) tuple Modified: trunk/scipy/stats/mstats.py =================================================================== --- trunk/scipy/stats/mstats.py 2008-05-06 17:14:47 UTC (rev 4236) +++ trunk/scipy/stats/mstats.py 2008-05-06 17:16:51 UTC (rev 4237) @@ -538,6 +538,9 @@ y = ma.array(y, mask=m, copy=True) n -= m.sum() # + if n < 2: + return (np.nan, np.nan) + # rx = ma.masked_equal(rankdata(x, use_missing=use_missing),0) ry = ma.masked_equal(rankdata(y, use_missing=use_missing),0) idx = rx.argsort() @@ -563,9 +566,12 @@ v1 = np.sum(v*k*(k-1) for (k,v) in xties.iteritems()) * \ np.sum(v*k*(k-1) for (k,v) in yties.iteritems()) v1 /= 2.*n*(n-1) - v2 = np.sum(v*k*(k-1)*(k-2) for (k,v) in xties.iteritems()) * \ - np.sum(v*k*(k-1)*(k-2) for (k,v) in yties.iteritems()) - v2 /= 9.*n*(n-1)*(n-2) + if n > 2: + v2 = np.sum(v*k*(k-1)*(k-2) for (k,v) in xties.iteritems()) * \ + np.sum(v*k*(k-1)*(k-2) for (k,v) in yties.iteritems()) + v2 /= 9.*n*(n-1)*(n-2) + else: + v2 = 0 else: v1 = v2 = 0 var_s /= 18. @@ -752,7 +758,7 @@ Ru = np.round((nt - z*sigma)/2. + 1) Rl = np.round((nt + z*sigma)/2.) delta = slopes[[Rl,Ru]] - return medslope, medinter, delta + return medslope, medinter, delta[0], delta[1] def sen_seasonal_slopes(x): From scipy-svn at scipy.org Tue May 6 21:16:00 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 20:16:00 -0500 (CDT) Subject: [Scipy-svn] r4238 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080507011600.5EE2D39C0F1@new.scipy.org> Author: cdavid Date: 2008-05-06 20:15:55 -0500 (Tue, 06 May 2008) New Revision: 4238 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h Log: Return bool and not int in is_simd_aligned. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-06 17:16:51 UTC (rev 4237) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-07 01:15:55 UTC (rev 4238) @@ -7,7 +7,7 @@ namespace fft { -inline int is_simd_aligned(const void * p) +inline bool is_simd_aligned(const void * p) { return (((reinterpret_cast (p)) & 0xF) == 0); } From scipy-svn at scipy.org Tue May 6 21:16:55 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 20:16:55 -0500 (CDT) Subject: [Scipy-svn] r4239 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080507011655.4A2CE39C034@new.scipy.org> Author: cdavid Date: 2008-05-06 20:16:50 -0500 (Tue, 06 May 2008) New Revision: 4239 Modified: branches/refactor_fft/scipy/fftpack/src/drfft.cxx Log: Set C linkage for drfft api. Modified: branches/refactor_fft/scipy/fftpack/src/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-07 01:15:55 UTC (rev 4238) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-07 01:16:50 UTC (rev 4239) @@ -9,12 +9,12 @@ /* The following macro convert private backend specific function to the public * functions exported by the module */ #define GEN_PUBLIC_API(name) \ -void destroy_drfft_cache(void)\ +extern "C" void destroy_drfft_cache(void)\ {\ destroy_dr##name##_caches();\ }\ \ -void drfft(double *inout, int n, \ +extern "C" void drfft(double *inout, int n, \ int direction, int howmany, int normalize)\ {\ drfft_##name(inout, n, direction, howmany, normalize);\ @@ -58,12 +58,12 @@ */ #ifdef WITH_DJBFFT #include "djbfft/drfft.c" - void destroy_drfft_cache(void) + extern "C" void destroy_drfft_cache(void) { destroy_drdjbfft_caches(); drfft_def_destroy_cache(); } - void drfft(double *inout, int n, + extern "C" void drfft(double *inout, int n, int direction, int howmany, int normalize) { drfft_djbfft(inout, n, direction, howmany, normalize); From scipy-svn at scipy.org Tue May 6 21:20:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 20:20:28 -0500 (CDT) Subject: [Scipy-svn] r4240 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080507012028.BA09139C1BF@new.scipy.org> Author: cdavid Date: 2008-05-06 20:20:23 -0500 (Tue, 06 May 2008) New Revision: 4240 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx Log: FFTW3 implementation for drfft know uses C++ cache mgr. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-07 01:16:50 UTC (rev 4239) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-07 01:20:23 UTC (rev 4240) @@ -1,11 +1,12 @@ /* * Last Change: Wed Aug 01 07:00 PM 2007 J * - * FFTW3 implementation + * RFFTW3 implementation * * Original code by Pearu Peterson. */ +#if 0 GEN_CACHE(drfftw3, (int n, int d, int flags) , int direction; int flags; @@ -22,44 +23,136 @@ (d > 0 ? FFTW_R2HC : FFTW_HC2R), flags);, fftw_destroy_plan(caches_drfftw3[id].plan); fftw_free(caches_drfftw3[id].ptr);, 10) +#endif +#include +#include + +#include "common.h" + +using namespace fft; + +class RFFTW3Cache : public Cache { + public: + RFFTW3Cache(const FFTW3CacheId& id); + virtual ~RFFTW3Cache(); + + int compute_forward(double* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : true); + fftw_execute_r2r(m_plan, inout, m_wrk); + COPYRFFTW2STD(m_wrk, inout, m_id.m_n); + return 0; + }; + + int compute_backward(double* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : true); + COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); + fftw_execute_r2r(m_plan, m_wrk, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + double *m_wrk; + double *m_wrk2; +}; + +RFFTW3Cache::RFFTW3Cache(const FFTW3CacheId& id) +: Cache(id) +{ + int flags = FFTW_MEASURE; + + m_wrk = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk == NULL) { + goto fail_wrk; + } + + m_wrk2 = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk2 == NULL) { + goto clean_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_r2r_1d(id.m_n, m_wrk, m_wrk2, + (id.m_dir > 0 ? FFTW_R2HC:FFTW_HC2R), + flags); + + if (m_plan == NULL) { + goto clean_wrk2; + } + + return ; + +clean_wrk2: + fftw_free(m_wrk2); +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +RFFTW3Cache::~RFFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk2); + fftw_free(m_wrk); +} + +static CacheManager fftw3_cmgr(10); + +/* stub to make GEN_PUBLIC_API happy */ +static void destroy_drfftw3_caches() +{ +} + static void drfft_fftw3(double *inout, int n, int direction, int howmany, int normalize) { - int i; - double *ptr = inout; + int i; + double *ptr = inout; - double *ptrc = NULL; - fftw_plan plan = NULL; + RFFTW3Cache *cache; + bool isaligned; - i = get_cache_id_drfftw3(n, direction, FFTW_ESTIMATE); - plan = caches_drfftw3[i].plan; - ptrc = caches_drfftw3[i].ptr; - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - memcpy(ptrc, ptr, sizeof(double) * n); - fftw_execute(plan); - COPYRFFTW2STD(ptrc, ptr, n); - } - break; + isaligned = is_simd_aligned(ptr); - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - COPYINVRFFTW2STD(ptr, ptrc, n); - fftw_execute(plan); - memcpy(ptr, ptrc, sizeof(double) * n); + if (howmany > 1) { + /* + * If executing for several consecutive buffers, we have to + * check that the shifting one buffer does not make it + * unaligned + */ + isaligned = isaligned && is_simd_aligned(ptr + n); } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } + cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + } + + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } } From scipy-svn at scipy.org Tue May 6 23:12:49 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 May 2008 22:12:49 -0500 (CDT) Subject: [Scipy-svn] r4241 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080507031249.52FC639C071@new.scipy.org> Author: cdavid Date: 2008-05-06 22:12:40 -0500 (Tue, 06 May 2008) New Revision: 4241 Added: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/src/zfftnd.c Modified: branches/refactor_fft/scipy/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/setup.py Log: Use C++ for zffnd API. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-07 01:20:23 UTC (rev 4240) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-07 03:12:40 UTC (rev 4241) @@ -1,4 +1,4 @@ -# Last Change: Mon May 05 08:00 PM 2008 J +# Last Change: Wed May 07 11:00 AM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -44,7 +44,7 @@ env.PrependUnique(LIBPATH = env['build_dir']) # Build _fftpack -src = ['src/zfft.cxx','src/drfft.c','src/zrfft.c', 'src/zfftnd.c', 'fftpack.pyf'] +src = ['src/zfft.cxx','src/drfft.cxx','src/zrfft.c', 'src/zfftnd.cxx', 'fftpack.pyf'] env.NumpyPythonExtension('_fftpack', src) # Build convolve Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-07 01:20:23 UTC (rev 4240) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-07 03:12:40 UTC (rev 4241) @@ -25,7 +25,7 @@ sources=[join('dfftpack','*.f')]) sources = ['fftpack.pyf','src/zfft.cxx','src/drfft.cxx','src/zrfft.c', - 'src/zfftnd.c'] + 'src/zfftnd.cxx'] config.add_extension('_fftpack', sources=sources, Deleted: branches/refactor_fft/scipy/fftpack/src/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-07 01:20:23 UTC (rev 4240) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.c 2008-05-07 03:12:40 UTC (rev 4241) @@ -1,45 +0,0 @@ -/* - Interface to various FFT libraries. - Double complex FFT and IFFT, arbitrary dimensions. - Author: Pearu Peterson, August 2002 - */ -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_PUBLIC_API(name) \ -void destroy_zfftnd_cache(void)\ -{\ - destroy_zfftnd_##name##_caches();\ -}\ -\ -void zfftnd(complex_double * inout, int rank,\ - int *dims, int direction, int howmany, int normalize)\ -{\ - zfftnd_##name(inout, rank, dims, direction, howmany, normalize);\ -} - -#if defined(WITH_FFTW) || defined(WITH_MKL) -static -int equal_dims(int rank,int *dims1,int *dims2) { - int i; - for (i=0;i Author: peridot Date: 2008-05-06 23:18:20 -0500 (Tue, 06 May 2008) New Revision: 4242 Modified: trunk/scipy/interpolate/fitpack.py Log: Provided references extracted from FITPACK routines so users can find the journal articles describing how these routines work without looking in the FORTRAN source code. Modified: trunk/scipy/interpolate/fitpack.py =================================================================== --- trunk/scipy/interpolate/fitpack.py 2008-05-07 03:12:40 UTC (rev 4241) +++ trunk/scipy/interpolate/fitpack.py 2008-05-07 04:18:20 UTC (rev 4242) @@ -172,6 +172,16 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Dierckx P. : Algorithms for smoothing data with periodic and + parametric splines, Computer Graphics and Image + Processing 20 (1982) 171-184. + Dierckx P. : Algorithms for smoothing data with periodic and param- + etric splines, report tw55, Dept. Computer Science, + K.U.Leuven, 1981. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ if task<=0: _parcur_cache = {'t': array([],float), 'wrk': array([],float), @@ -331,6 +341,21 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + + Based on algorithms described in: + Dierckx P. : An algorithm for smoothing, differentiation and integ- + ration of experimental data using spline functions, + J.Comp.Appl.Maths 1 (1975) 165-184. + Dierckx P. : A fast algorithm for smoothing data on a rectangular + grid while using spline functions, SIAM J.Numer.Anal. + 19 (1982) 1286-1304. + Dierckx P. : An improved algorithm for curve fitting with spline + functions, report tw54, Dept. Computer Science,K.U. + Leuven, 1981. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ if task<=0: _curfit_cache = {} @@ -436,6 +461,14 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + de Boor C : On calculating with b-splines, J. Approximation Theory + 6 (1972) 50-62. + Cox M.G. : The numerical evaluation of b-splines, J. Inst. Maths + Applics 10 (1972) 134-149. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck try: @@ -481,6 +514,12 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Gaffney P.W. : The calculation of indefinite integrals of b-splines + J. Inst. Maths Applics 17 (1976) 37-41. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck try: @@ -519,6 +558,7 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + """ t,c,k=tck if k==4: t=t[1:-1] @@ -566,6 +606,14 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + Notes: + Based on algorithms from: + de Boor C : On calculating with b-splines, J. Approximation Theory + 6 (1972) 50-62. + Cox M.G. : The numerical evaluation of b-splines, J. Inst. Maths + applics 10 (1972) 134-149. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck try: @@ -601,7 +649,8 @@ Description: Given a set of data points (x[i], y[i], z[i]) representing a surface - z=f(x,y), compute a B-spline representation of the surface. + z=f(x,y), compute a B-spline representation of the surface. Based on + the routine SURFIT from FITPACK. Inputs: @@ -653,6 +702,15 @@ splprep, splrep, splint, sproot, splev - evaluation, roots, integral UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Based on algorithms from: + Dierckx P. : An algorithm for surface fitting with spline functions + Ima J. Numer. Anal. 1 (1981) 267-283. + Dierckx P. : An algorithm for surface fitting with spline functions + report tw50, Dept. Computer Science,K.U.Leuven, 1980. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ x,y,z=map(myasarray,[x,y,z]) x,y,z=map(ravel,[x,y,z]) # ensure 1-d arrays. @@ -736,7 +794,7 @@ Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or - both are floats. + both are floats. Based on BISPEV from FITPACK. Inputs: @@ -760,6 +818,15 @@ splprep, splrep, splint, sproot, splev - evaluation, roots, integral UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Based on algorithms from: + Dierckx P. : An algorithm for surface fitting with spline functions + Ima J. Numer. Anal. 1 (1981) 267-283. + Dierckx P. : An algorithm for surface fitting with spline functions + report tw50, Dept. Computer Science,K.U.Leuven, 1980. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ tx,ty,c,kx,ky=tck if not (0<=dx Author: cdavid Date: 2008-05-07 03:43:56 -0500 (Wed, 07 May 2008) New Revision: 4243 Added: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Log: Use C++ cache manager for fftw3 implementation of zfftnd (does not work). Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-07 04:18:20 UTC (rev 4242) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-07 08:43:56 UTC (rev 4243) @@ -36,7 +36,7 @@ 'src/djbfft/drfft.c', 'src/fftpack/drfft.c', 'src/fftw3/drfft.cxx', 'src/fftw/drfft.c', 'src/fftpack/zfftnd.c', 'src/fftw/zfftnd.c', - 'src/fftw3/zfftnd.c', 'src/mkl/zfftnd.c', + 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.c', ], include_dirs = ['src'], ) Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c 2008-05-07 04:18:20 UTC (rev 4242) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c 2008-05-07 08:43:56 UTC (rev 4243) @@ -1,40 +0,0 @@ -/* - * fftw3 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Wed Aug 08 02:00 PM 2007 J - */ - -/* stub because fftw3 has no cache mechanism (yet) */ -static void destroy_zfftnd_fftw3_caches(void) {} - -extern void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - - fftw_plan plan = NULL; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - plan = fftw_plan_many_dft(rank, dims, howmany, - (fftw_complex *) ptr, NULL, 1, sz, - (fftw_complex *) ptr, NULL, 1, sz, - (direction > - 0 ? FFTW_FORWARD : FFTW_BACKWARD), - FFTW_ESTIMATE); - fftw_execute(plan); - fftw_destroy_plan(plan); - - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx (from rev 4242, branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.c 2008-05-07 04:18:20 UTC (rev 4242) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-07 08:43:56 UTC (rev 4243) @@ -0,0 +1,173 @@ +/* + * fftw3 backend for multi dimensional fft + * + * Original code by Pearu Peaterson + * + * Last Change: Wed Aug 08 02:00 PM 2007 J + */ +#include +#include + +#include "common.h" + +using namespace fft; + +class NDFFTW3CacheId { + public: + NDFFTW3CacheId(int rank, int* dims, int howmany, int dir, bool isalign); + virtual ~NDFFTW3CacheId(); + + virtual bool operator==(const NDFFTW3CacheId& other) const + { + return is_equal(other); + }; + + virtual bool is_equal(const NDFFTW3CacheId& other) const; + + public: + int m_rank; + int *m_dims; + int m_howmany; + int m_dir; + bool m_isalign; + +}; + +NDFFTW3CacheId::NDFFTW3CacheId(int rank, int* dims, int howmany, int dir, bool isalign) : + m_rank(rank), + m_howmany(howmany), + m_dir(dir), + m_isalign(isalign) +{ + m_dims = (int*)fftw_malloc(m_rank * sizeof(*m_dims)); + if (m_dims == NULL) { + goto fail; + } + memcpy(m_dims, dims, m_rank * sizeof(*m_dims)); + + return; + +fail: + std::bad_alloc(); +} + +NDFFTW3CacheId::~NDFFTW3CacheId() +{ + fftw_free(m_dims); +} + +bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId& other) const +{ + bool res; + int i; + + res = (other.m_dir == m_dir); + res = res && (other.m_isalign == m_isalign); + res = res && (m_howmany == other.m_howmany); + + if (m_rank == other.m_rank) { + fprintf(stderr, "rank is %d, %d\n", m_rank, other.m_rank); + for (i = 0; i < m_rank; ++i) { + res = res && (m_dims[i] == other.m_dims[i]); + } + } else { + return false; + } + + return res; +} + +/* stub because fftw3 has no cache mechanism (yet) */ +static void destroy_zfftnd_fftw3_caches(void) {} + +class NDFFTW3Cache : public Cache { + public: + NDFFTW3Cache(const NDFFTW3CacheId& id); + virtual ~NDFFTW3Cache(); + + int compute(fftw_complex* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : true); + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; +}; + +NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId& id) +: Cache(id) +{ + int flags = FFTW_ESTIMATE; + int sz; + int i; + + sz = 1; + for (i = 0; i < m_id.m_rank; ++i) { + sz *= m_id.m_dims[i]; + } + + m_wrk = (fftw_complex*)fftw_malloc(sz * sizeof(fftw_complex) ); + if (m_wrk == NULL) { + goto fail_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_many_dft(m_id.m_rank, + m_id.m_dims, m_id.m_howmany, + m_wrk, NULL, 1, sz, + m_wrk, NULL, 1, sz, + (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return ; + +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +NDFFTW3Cache::~NDFFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk); +} + +static CacheManager fftw3_cmgr(10); + +extern void zfftnd_fftw3(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize) +{ + int i, sz; + fftw_complex *ptr = (fftw_complex*)inout; + NDFFTW3Cache *cache; + + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } + + + cache = fftw3_cmgr.get_cache(NDFFTW3CacheId(rank, dims, howmany, direction, is_simd_aligned(inout))); + + cache->compute(ptr); + + if (normalize) { + ptr = (fftw_complex*)inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } +} Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-07 04:18:20 UTC (rev 4242) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-07 08:43:56 UTC (rev 4243) @@ -31,7 +31,7 @@ #endif #ifdef WITH_FFTW3 - #include "fftw3/zfftnd.c" + #include "fftw3/zfftnd.cxx" GEN_PUBLIC_API(fftw3) #elif defined WITH_FFTW #include "fftw/zfftnd.c" From scipy-svn at scipy.org Wed May 7 06:08:19 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 May 2008 05:08:19 -0500 (CDT) Subject: [Scipy-svn] r4244 - in branches/refactor_fft/scipy/fftpack: . src/fftw3 Message-ID: <20080507100819.7FA25C7C02A@new.scipy.org> Author: cdavid Date: 2008-05-07 05:08:14 -0500 (Wed, 07 May 2008) New Revision: 4244 Modified: branches/refactor_fft/scipy/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx Log: Add a copy ctor for NDFFTW3CacheId, because has an array member (dims). Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-07 08:43:56 UTC (rev 4243) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-07 10:08:14 UTC (rev 4244) @@ -1,4 +1,4 @@ -# Last Change: Wed May 07 11:00 AM 2008 J +# Last Change: Wed May 07 06:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-07 08:43:56 UTC (rev 4243) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-07 10:08:14 UTC (rev 4244) @@ -3,7 +3,7 @@ * * Original code by Pearu Peaterson * - * Last Change: Wed Aug 08 02:00 PM 2007 J + * Last Change: Wed May 07 06:00 PM 2008 J */ #include #include @@ -17,6 +17,8 @@ NDFFTW3CacheId(int rank, int* dims, int howmany, int dir, bool isalign); virtual ~NDFFTW3CacheId(); + NDFFTW3CacheId(const NDFFTW3CacheId&); + virtual bool operator==(const NDFFTW3CacheId& other) const { return is_equal(other); @@ -30,30 +32,54 @@ int m_howmany; int m_dir; bool m_isalign; - + + private: + int init(int rank, int* dims); }; +int NDFFTW3CacheId::init(int rank, int* dims) +{ + m_dims = (int*)malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + NDFFTW3CacheId::NDFFTW3CacheId(int rank, int* dims, int howmany, int dir, bool isalign) : m_rank(rank), m_howmany(howmany), m_dir(dir), m_isalign(isalign) { - m_dims = (int*)fftw_malloc(m_rank * sizeof(*m_dims)); - if (m_dims == NULL) { + if (init(rank, dims)) { goto fail; } - memcpy(m_dims, dims, m_rank * sizeof(*m_dims)); - return; +fail: + std::bad_alloc(); +} +NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId& copy) : + m_rank(copy.m_rank), + m_howmany(copy.m_howmany), + m_dir(copy.m_dir), + m_isalign(copy.m_isalign) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + fail: std::bad_alloc(); } NDFFTW3CacheId::~NDFFTW3CacheId() { - fftw_free(m_dims); + free(m_dims); } bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId& other) const @@ -66,7 +92,6 @@ res = res && (m_howmany == other.m_howmany); if (m_rank == other.m_rank) { - fprintf(stderr, "rank is %d, %d\n", m_rank, other.m_rank); for (i = 0; i < m_rank; ++i) { res = res && (m_dims[i] == other.m_dims[i]); } @@ -158,7 +183,6 @@ sz *= dims[i]; } - cache = fftw3_cmgr.get_cache(NDFFTW3CacheId(rank, dims, howmany, direction, is_simd_aligned(inout))); cache->compute(ptr); From scipy-svn at scipy.org Thu May 8 08:09:12 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 07:09:12 -0500 (CDT) Subject: [Scipy-svn] r4245 - branches/refactor_fft/scipy/fftpack/src/fftpack Message-ID: <20080508120912.EC1A939C259@scipy.org> Author: cdavid Date: 2008-05-08 07:09:08 -0500 (Thu, 08 May 2008) New Revision: 4245 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c Log: Use C linkage for fortran func declaration. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c 2008-05-07 10:08:14 UTC (rev 4244) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c 2008-05-08 12:09:08 UTC (rev 4245) @@ -71,8 +71,10 @@ } } +extern "C" { extern void zfft(complex_double * inout, int n, int direction, int howmany, int normalize); +}; extern void zfftnd_fftpack(complex_double * inout, int rank, int *dims, int direction, int howmany, From scipy-svn at scipy.org Thu May 8 08:14:43 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 07:14:43 -0500 (CDT) Subject: [Scipy-svn] r4246 - in branches/refactor_fft/scipy/fftpack: . src src/fftpack Message-ID: <20080508121443.BE11939C259@scipy.org> Author: cdavid Date: 2008-05-08 07:14:28 -0500 (Thu, 08 May 2008) New Revision: 4246 Added: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx Removed: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.cxx Log: Translate zfftnd , fftpack backend, in c++. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:09:08 UTC (rev 4245) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:14:28 UTC (rev 4246) @@ -33,7 +33,7 @@ extra_info=[fft_opt_info, djbfft_info], depends=['src/djbfft/zfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', - 'src/djbfft/drfft.c', 'src/fftpack/drfft.c', + 'src/djbfft/drfft.c', 'src/fftpack/drfft.cxx', 'src/fftw3/drfft.cxx', 'src/fftw/drfft.c', 'src/fftpack/zfftnd.c', 'src/fftw/zfftnd.c', 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.c', Modified: branches/refactor_fft/scipy/fftpack/src/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-08 12:09:08 UTC (rev 4245) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-08 12:14:28 UTC (rev 4246) @@ -46,7 +46,7 @@ GEN_PUBLIC_API(fftw) #endif #else /* Use fftpack by default */ - #include "fftpack/drfft.c" + #include "fftpack/drfft.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftpack) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c 2008-05-08 12:09:08 UTC (rev 4245) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c 2008-05-08 12:14:28 UTC (rev 4246) @@ -1,54 +0,0 @@ -/* - * Last Change: Wed Aug 01 07:00 PM 2007 J - * - * FFTPACK implementation - * - * Original code by Pearu Peterson. - */ - -extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); -extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); -extern void F_FUNC(dffti, DFFTI) (int *, double *); -GEN_CACHE(drfftpack, (int n) - , double *wsave; - , (caches_drfftpack[i].n == n) - , caches_drfftpack[id].wsave = - (double *) malloc(sizeof(double) * (2 * n + 15)); - F_FUNC(dffti, DFFTI) (&n, caches_drfftpack[id].wsave); - , free(caches_drfftpack[id].wsave); - , 10) - -static void drfft_fftpack(double *inout, int n, int direction, int howmany, - int normalize) -{ - int i; - double *ptr = inout; - double *wsave = NULL; - wsave = caches_drfftpack[get_cache_id_drfftpack(n)].wsave; - - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - dfftf_(&n, ptr, wsave); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - dfftb_(&n, ptr, wsave); - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx (from rev 4244, branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.c 2008-05-07 10:08:14 UTC (rev 4244) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-08 12:14:28 UTC (rev 4246) @@ -0,0 +1,57 @@ +/* + * Last Change: Wed Aug 01 07:00 PM 2007 J + * + * FFTPACK implementation + * + * Original code by Pearu Peterson. + */ + +extern "C" { +extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); +extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); +extern void F_FUNC(dffti, DFFTI) (int *, double *); +}; + +GEN_CACHE(drfftpack, (int n) + , double *wsave; + , (caches_drfftpack[i].n == n) + , caches_drfftpack[id].wsave = + (double *) malloc(sizeof(double) * (2 * n + 15)); + F_FUNC(dffti, DFFTI) (&n, caches_drfftpack[id].wsave); + , free(caches_drfftpack[id].wsave); + , 10) + +static void drfft_fftpack(double *inout, int n, int direction, int howmany, + int normalize) +{ + int i; + double *ptr = inout; + double *wsave = NULL; + wsave = caches_drfftpack[get_cache_id_drfftpack(n)].wsave; + + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + dfftf_(&n, ptr, wsave); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + dfftb_(&n, ptr, wsave); + } + break; + + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + } + + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } +} From scipy-svn at scipy.org Thu May 8 08:26:35 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 07:26:35 -0500 (CDT) Subject: [Scipy-svn] r4247 - in branches/refactor_fft/scipy/fftpack: . src src/fftpack Message-ID: <20080508122635.50C1E39C069@scipy.org> Author: cdavid Date: 2008-05-08 07:26:26 -0500 (Thu, 08 May 2008) New Revision: 4247 Added: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Log: Change C->C++ extension for fftpack implementation of zfftnd. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:14:28 UTC (rev 4246) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:26:26 UTC (rev 4247) @@ -35,7 +35,7 @@ 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', 'src/djbfft/drfft.c', 'src/fftpack/drfft.cxx', 'src/fftw3/drfft.cxx', 'src/fftw/drfft.c', - 'src/fftpack/zfftnd.c', 'src/fftw/zfftnd.c', + 'src/fftpack/zfftnd.cxx', 'src/fftw/zfftnd.c', 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.c', ], include_dirs = ['src'], Deleted: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c 2008-05-08 12:14:28 UTC (rev 4246) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c 2008-05-08 12:26:26 UTC (rev 4247) @@ -1,120 +0,0 @@ -/* - * fftpack backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Wed Aug 08 02:00 PM 2007 J - */ - -GEN_CACHE(zfftnd_fftpack, (int n, int rank) - , complex_double * ptr; int *iptr; int rank; - , ((caches_zfftnd_fftpack[i].n == n) - && (caches_zfftnd_fftpack[i].rank == rank)) - , caches_zfftnd_fftpack[id].n = n; - caches_zfftnd_fftpack[id].ptr = - (complex_double *) malloc(2 * sizeof(double) * n); - caches_zfftnd_fftpack[id].iptr = - (int *) malloc(4 * rank * sizeof(int)); - , - free(caches_zfftnd_fftpack[id].ptr); - free(caches_zfftnd_fftpack[id].iptr); - , 10) - -static -/*inline : disabled because MSVC6.0 fails to compile it. */ -int next_comb(int *ia, int *da, int m) -{ - while (m >= 0 && ia[m] == da[m]) { - ia[m--] = 0; - } - if (m < 0) { - return 0; - } - ia[m]++; - return 1; -} - -static -void flatten(complex_double * dest, complex_double * src, - int rank, int strides_axis, int dims_axis, int unflat, - int *tmp) -{ - int *new_strides = tmp + rank; - int *new_dims = tmp + 2 * rank; - int *ia = tmp + 3 * rank; - int rm1 = rank - 1, rm2 = rank - 2; - int i, j, k; - for (i = 0; i < rm2; ++i) - ia[i] = 0; - ia[rm2] = -1; - j = 0; - if (unflat) { - while (next_comb(ia, new_dims, rm2)) { - k = 0; - for (i = 0; i < rm1; ++i) { - k += ia[i] * new_strides[i]; - } - for (i = 0; i < dims_axis; ++i) { - *(dest + k + i * strides_axis) = *(src + j++); - } - } - } else { - while (next_comb(ia, new_dims, rm2)) { - k = 0; - for (i = 0; i < rm1; ++i) { - k += ia[i] * new_strides[i]; - } - for (i = 0; i < dims_axis; ++i) { - *(dest + j++) = *(src + k + i * strides_axis); - } - } - } -} - -extern "C" { -extern void zfft(complex_double * inout, - int n, int direction, int howmany, int normalize); -}; - -extern void zfftnd_fftpack(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - int axis; - complex_double *tmp; - int *itmp; - int k, j; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - zfft(ptr, dims[rank - 1], direction, howmany * sz / dims[rank - 1], - normalize); - - i = get_cache_id_zfftnd_fftpack(sz, rank); - tmp = caches_zfftnd_fftpack[i].ptr; - itmp = caches_zfftnd_fftpack[i].iptr; - - itmp[rank - 1] = 1; - for (i = 2; i <= rank; ++i) { - itmp[rank - i] = itmp[rank - i + 1] * dims[rank - i + 1]; - } - - for (i = 0; i < howmany; ++i, ptr += sz) { - for (axis = 0; axis < rank - 1; ++axis) { - for (k = j = 0; k < rank; ++k) { - if (k != axis) { - *(itmp + rank + j) = itmp[k]; - *(itmp + 2 * rank + j++) = dims[k] - 1; - } - } - flatten(tmp, ptr, rank, itmp[axis], dims[axis], 0, itmp); - zfft(tmp, dims[axis], direction, sz / dims[axis], normalize); - flatten(ptr, tmp, rank, itmp[axis], dims[axis], 1, itmp); - } - } - -} Copied: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx (from rev 4245, branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-08 12:14:28 UTC (rev 4246) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-08 12:26:26 UTC (rev 4247) @@ -40,6 +40,6 @@ #include "mkl/zfftnd.c" GEN_PUBLIC_API(mkl) #else /* Use fftpack by default */ - #include "fftpack/zfftnd.c" + #include "fftpack/zfftnd.cxx" GEN_PUBLIC_API(fftpack) #endif From scipy-svn at scipy.org Thu May 8 08:36:35 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 07:36:35 -0500 (CDT) Subject: [Scipy-svn] r4248 - in branches/refactor_fft/scipy/fftpack: . src src/fftw Message-ID: <20080508123635.ABECC39C2EB@scipy.org> Author: cdavid Date: 2008-05-08 07:36:20 -0500 (Thu, 08 May 2008) New Revision: 4248 Added: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Log: Change C->C++ extension for fftw2 implementation of zfftnd/drfft. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:26:26 UTC (rev 4247) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:36:20 UTC (rev 4248) @@ -34,8 +34,8 @@ depends=['src/djbfft/zfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', 'src/djbfft/drfft.c', 'src/fftpack/drfft.cxx', - 'src/fftw3/drfft.cxx', 'src/fftw/drfft.c', - 'src/fftpack/zfftnd.cxx', 'src/fftw/zfftnd.c', + 'src/fftw3/drfft.cxx', 'src/fftw/drfft.cxx', + 'src/fftpack/zfftnd.cxx', 'src/fftw/zfftnd.cxx', 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.c', ], include_dirs = ['src'], Modified: branches/refactor_fft/scipy/fftpack/src/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-08 12:26:26 UTC (rev 4247) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-08 12:36:20 UTC (rev 4248) @@ -41,7 +41,7 @@ GEN_PUBLIC_API(fftw3) #endif #elif defined WITH_FFTW - #include "fftw/drfft.c" + #include "fftw/drfft.cxx" #ifndef WITH_DJBFFT GEN_PUBLIC_API(fftw) #endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c 2008-05-08 12:26:26 UTC (rev 4247) +++ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c 2008-05-08 12:36:20 UTC (rev 4248) @@ -1,70 +0,0 @@ -/* - * Last Change: Wed Aug 01 07:00 PM 2007 J - * - * FFTW2 implementation - * - * Original code by Pearu Peterson. - */ - -GEN_CACHE(drfftw, (int n, int d, int flags) - , int direction; - int flags; - rfftw_plan plan; - double *ptr;, ((caches_drfftw[i].n == n) && - (caches_drfftw[i].direction == d) && - (caches_drfftw[i].flags == flags)) - , caches_drfftw[id].direction = d; - caches_drfftw[id].flags = flags; - caches_drfftw[id].plan = rfftw_create_plan(n, - (d > - 0 ? - FFTW_REAL_TO_COMPLEX - : - FFTW_COMPLEX_TO_REAL), - flags); - caches_drfftw[id].ptr = - (double *) malloc(sizeof(double) * (n));, - rfftw_destroy_plan(caches_drfftw[id].plan); - free(caches_drfftw[id].ptr);, 10) - -static void drfft_fftw(double *inout, int n, int dir, int - howmany, int normalize) -{ - int i; - double *ptr = inout; - double *ptrc = NULL; - rfftw_plan plan = NULL; - - i = get_cache_id_drfftw(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE); - plan = caches_drfftw[i].plan; - ptrc = caches_drfftw[i].ptr; - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - memcpy(ptrc, ptr, sizeof(double) * n); - rfftw(plan, 1, (fftw_real *) ptrc, 1, 1, NULL, 1, 1); - COPYRFFTW2STD(ptrc, ptr, n); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - COPYINVRFFTW2STD(ptr, ptrc, n); - rfftw(plan, 1, (fftw_real *) ptrc, 1, 1, NULL, 1, 1); - memcpy(ptr, ptrc, sizeof(double) * n); - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", dir); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx (from rev 4244, branches/refactor_fft/scipy/fftpack/src/fftw/drfft.c) Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c 2008-05-08 12:26:26 UTC (rev 4247) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c 2008-05-08 12:36:20 UTC (rev 4248) @@ -1,53 +0,0 @@ -/* - * fftw2 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Thu Sep 06 05:00 PM 2007 J - */ - -GEN_CACHE(zfftnd_fftw, (int n, int *dims, int d, int flags) - , int direction; - int *dims; - fftwnd_plan plan;, ((caches_zfftnd_fftw[i].n == n) && - (caches_zfftnd_fftw[i].direction == d) && - (equal_dims - (n, caches_zfftnd_fftw[i].dims, dims))) - , caches_zfftnd_fftw[id].direction = d; - caches_zfftnd_fftw[id].n = n; - caches_zfftnd_fftw[id].dims = (int *) malloc(sizeof(int) * n); - memcpy(caches_zfftnd_fftw[id].dims, dims, sizeof(int) * n); - caches_zfftnd_fftw[id].plan = - fftwnd_create_plan(n, dims, - (d > 0 ? FFTW_FORWARD : FFTW_BACKWARD), - flags);, - fftwnd_destroy_plan(caches_zfftnd_fftw[id].plan); - free(caches_zfftnd_fftw[id].dims);, 10) - - -extern void zfftnd_fftw(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - fftwnd_plan plan = NULL; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - i = get_cache_id_zfftnd_fftw(rank, dims, direction, - FFTW_IN_PLACE | FFTW_ESTIMATE); - plan = caches_zfftnd_fftw[i].plan; - for (i = 0; i < howmany; ++i, ptr += sz) { - fftwnd_one(plan, (fftw_complex *) ptr, NULL); - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx (from rev 4244, branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-08 12:26:26 UTC (rev 4247) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-08 12:36:20 UTC (rev 4248) @@ -34,7 +34,7 @@ #include "fftw3/zfftnd.cxx" GEN_PUBLIC_API(fftw3) #elif defined WITH_FFTW - #include "fftw/zfftnd.c" + #include "fftw/zfftnd.cxx" GEN_PUBLIC_API(fftw) #elif defined WITH_MKL #include "mkl/zfftnd.c" From scipy-svn at scipy.org Thu May 8 09:58:03 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 08:58:03 -0500 (CDT) Subject: [Scipy-svn] r4249 - in branches/refactor_fft/scipy/fftpack: . src src/mkl Message-ID: <20080508135803.2F04F39C069@scipy.org> Author: cdavid Date: 2008-05-08 08:57:46 -0500 (Thu, 08 May 2008) New Revision: 4249 Added: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Log: Change c->c++ extension for mkl. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 12:36:20 UTC (rev 4248) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-08 13:57:46 UTC (rev 4249) @@ -36,7 +36,7 @@ 'src/djbfft/drfft.c', 'src/fftpack/drfft.cxx', 'src/fftw3/drfft.cxx', 'src/fftw/drfft.cxx', 'src/fftpack/zfftnd.cxx', 'src/fftw/zfftnd.cxx', - 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.c', + 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.cxx', ], include_dirs = ['src'], ) Deleted: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c 2008-05-08 12:36:20 UTC (rev 4248) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c 2008-05-08 13:57:46 UTC (rev 4249) @@ -1,66 +0,0 @@ -/* - * MKL backend for multi dimensional fft - * - * Original code by David M. Cooke - * - * Last Change: Wed Aug 08 03:00 PM 2007 J - */ - -static long *convert_dims(int n, int *dims) -{ - long *ndim; - int i; - ndim = (long *) malloc(sizeof(long) * n); - for (i = 0; i < n; i++) { - ndim[i] = (long) dims[i]; - } - return ndim; -} - -GEN_CACHE(zfftnd_mkl, (int n, int *dims) - , DFTI_DESCRIPTOR_HANDLE desc_handle; - int *dims; - long *ndims;, ((caches_zfftnd_mkl[i].n == n) && - (equal_dims(n, caches_zfftnd_mkl[i].dims, dims))) - , caches_zfftnd_mkl[id].ndims = convert_dims(n, dims); - caches_zfftnd_mkl[id].n = n; - caches_zfftnd_mkl[id].dims = (int *) malloc(sizeof(int) * n); - memcpy(caches_zfftnd_mkl[id].dims, dims, sizeof(int) * n); - DftiCreateDescriptor(&caches_zfftnd_mkl[id].desc_handle, - DFTI_DOUBLE, DFTI_COMPLEX, (long) n, - caches_zfftnd_mkl[id].ndims); - DftiCommitDescriptor(caches_zfftnd_mkl[id].desc_handle);, - DftiFreeDescriptor(&caches_zfftnd_mkl[id].desc_handle); - free(caches_zfftnd_mkl[id].dims); - free(caches_zfftnd_mkl[id].ndims);, 10) - -extern void zfftnd_mkl(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - - DFTI_DESCRIPTOR_HANDLE desc_handle; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - desc_handle = - caches_zfftnd_mkl[get_cache_id_zfftnd_mkl(rank, dims)].desc_handle; - for (i = 0; i < howmany; ++i, ptr += sz) { - if (direction == 1) { - DftiComputeForward(desc_handle, (double *) ptr); - } else if (direction == -1) { - DftiComputeBackward(desc_handle, (double *) ptr); - } - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx (from rev 4244, branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.c) Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-08 12:36:20 UTC (rev 4248) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-08 13:57:46 UTC (rev 4249) @@ -37,7 +37,7 @@ #include "fftw/zfftnd.cxx" GEN_PUBLIC_API(fftw) #elif defined WITH_MKL - #include "mkl/zfftnd.c" + #include "mkl/zfftnd.cxx" GEN_PUBLIC_API(mkl) #else /* Use fftpack by default */ #include "fftpack/zfftnd.cxx" From scipy-svn at scipy.org Thu May 8 14:14:27 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 13:14:27 -0500 (CDT) Subject: [Scipy-svn] r4250 - in trunk/scipy/sparse: . tests Message-ID: <20080508181427.C7BBB39C14D@scipy.org> Author: wnbell Date: 2008-05-08 13:13:41 -0500 (Thu, 08 May 2008) New Revision: 4250 Modified: trunk/scipy/sparse/bsr.py trunk/scipy/sparse/compressed.py trunk/scipy/sparse/dok.py trunk/scipy/sparse/tests/test_base.py Log: make sparse work with new numpy matrix indexing behavior Modified: trunk/scipy/sparse/bsr.py =================================================================== --- trunk/scipy/sparse/bsr.py 2008-05-08 13:57:46 UTC (rev 4249) +++ trunk/scipy/sparse/bsr.py 2008-05-08 18:13:41 UTC (rev 4250) @@ -380,9 +380,13 @@ return bsr_matrix((data,indices,indptr),shape=(M,N),blocksize=(R,C)) elif isdense(other): # TODO make sparse * dense matrix multiplication more efficient + + # matvec each column of other + result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) + if isinstance(other, matrix): + result = asmatrix(result) + return result - # matvec each column of other - return hstack( [ self * col.reshape(-1,1) for col in other.T ] ) else: raise TypeError, "need a dense or sparse matrix" Modified: trunk/scipy/sparse/compressed.py =================================================================== --- trunk/scipy/sparse/compressed.py 2008-05-08 13:57:46 UTC (rev 4249) +++ trunk/scipy/sparse/compressed.py 2008-05-08 18:13:41 UTC (rev 4250) @@ -304,9 +304,13 @@ elif isdense(other): # TODO make sparse * dense matrix multiplication more efficient + + # matvec each column of other + result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) + if isinstance(other, matrix): + result = asmatrix(result) + return result - # matvec each column of other - return hstack( [ self * col.reshape(-1,1) for col in other.T ] ) else: raise TypeError, "need a dense or sparse matrix" Modified: trunk/scipy/sparse/dok.py =================================================================== --- trunk/scipy/sparse/dok.py 2008-05-08 13:57:46 UTC (rev 4249) +++ trunk/scipy/sparse/dok.py 2008-05-08 18:13:41 UTC (rev 4250) @@ -482,40 +482,40 @@ return base, ext - def matvec(self, other): - if isdense(other): - if other.shape[0] != self.shape[1]: - raise ValueError, "dimensions do not match" - new = [0] * self.shape[0] - for key in self.keys(): - new[int(key[0])] += self[key] * other[int(key[1])] - new = array(new) - if isinstance(other, matrix): - new = asmatrix(new) - # Do we need to return the transpose? - if other.shape[1] == 1: - new = new.T - return new - else: - raise TypeError, "need a dense vector" +# def matvec(self, other): +# if isdense(other): +# if other.shape[0] != self.shape[1]: +# raise ValueError, "dimensions do not match" +# new = [0] * self.shape[0] +# for key in self.keys(): +# new[int(key[0])] += self[key] * other[int(key[1])] +# new = array(new) +# if isinstance(other, matrix): +# new = asmatrix(new) +# # Do we need to return the transpose? +# if other.shape[1] == 1: +# new = new.T +# return new +# else: +# raise TypeError, "need a dense vector" +# +# def rmatvec(self, other, conjugate=True): +# if isdense(other): +# if other.shape[-1] != self.shape[0]: +# raise ValueError, "dimensions do not match" +# new = [0] * self.shape[1] +# for key in self.keys(): +# new[int(key[1])] += other[int(key[0])] * conj(self[key]) +# new = array(new) +# if isinstance(other, matrix): +# new = asmatrix(new) +# # Do we need to return the transpose? +# if other.shape[1] == 1: +# new = new.T +# return new +# else: +# raise TypeError, "need a dense vector" - def rmatvec(self, other, conjugate=True): - if isdense(other): - if other.shape[-1] != self.shape[0]: - raise ValueError, "dimensions do not match" - new = [0] * self.shape[1] - for key in self.keys(): - new[int(key[1])] += other[int(key[0])] * conj(self[key]) - new = array(new) - if isinstance(other, matrix): - new = asmatrix(new) - # Do we need to return the transpose? - if other.shape[1] == 1: - new = new.T - return new - else: - raise TypeError, "need a dense vector" - def tocoo(self): """ Return a copy of this matrix in COOrdinate format""" from coo import coo_matrix Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-05-08 13:57:46 UTC (rev 4249) +++ trunk/scipy/sparse/tests/test_base.py 2008-05-08 18:13:41 UTC (rev 4250) @@ -702,8 +702,8 @@ assert_equal(A[[[-1],[-3],[-2]],[2,-4]].todense(),B[[[-1],[-3],[-2]],[2,-4]]) # [i] - assert_equal(A[1].todense(),B[1]) - assert_equal(A[-2].todense(),B[-2]) + assert_equal(A[1,:].todense(),B[1,:]) + assert_equal(A[-2,:].todense(),B[-2,:]) # [1:2] assert_equal(A[1:4].todense(),B[1:4]) From scipy-svn at scipy.org Thu May 8 18:21:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 17:21:56 -0500 (CDT) Subject: [Scipy-svn] r4251 - trunk/scipy/special Message-ID: <20080508222156.994D039C04A@scipy.org> Author: peridot Date: 2008-05-08 17:21:48 -0500 (Thu, 08 May 2008) New Revision: 4251 Modified: trunk/scipy/special/basic.py Log: Correct Bessel function zeros docstring to match code Modified: trunk/scipy/special/basic.py =================================================================== --- trunk/scipy/special/basic.py 2008-05-08 18:13:41 UTC (rev 4250) +++ trunk/scipy/special/basic.py 2008-05-08 22:21:48 UTC (rev 4251) @@ -49,7 +49,7 @@ def jnjnp_zeros(nt): - """Compute nt (<=1400) zeros of the bessel functions Jn and Jn' + """Compute nt (<=1200) zeros of the bessel functions Jn and Jn' and arange them in order of their magnitudes. Outputs (all are arrays of length nt): From scipy-svn at scipy.org Thu May 8 18:47:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 May 2008 17:47:53 -0500 (CDT) Subject: [Scipy-svn] r4252 - trunk/scipy/weave Message-ID: <20080508224753.9D44739C093@scipy.org> Author: rkern Date: 2008-05-08 17:47:52 -0500 (Thu, 08 May 2008) New Revision: 4252 Modified: trunk/scipy/weave/common_info.py Log: const-correctness patch by Norbet Namec. Modified: trunk/scipy/weave/common_info.py =================================================================== --- trunk/scipy/weave/common_info.py 2008-05-08 22:21:48 UTC (rev 4251) +++ trunk/scipy/weave/common_info.py 2008-05-08 22:47:52 UTC (rev 4252) @@ -15,7 +15,7 @@ object None = object(Py_None); } -char* find_type(PyObject* py_obj) +const char* find_type(PyObject* py_obj) { if(py_obj == NULL) return "C NULL value"; if(PyCallable_Check(py_obj)) return "callable"; @@ -76,13 +76,13 @@ get_variable_support_code = \ """ -void handle_variable_not_found(char* var_name) +void handle_variable_not_found(const char* var_name) { char msg[500]; sprintf(msg,"Conversion Error: variable '%s' not found in local or global scope.",var_name); throw_error(PyExc_NameError,msg); } -PyObject* get_variable(char* name,PyObject* locals, PyObject* globals) +PyObject* get_variable(const char* name,PyObject* locals, PyObject* globals) { // no checking done for error -- locals and globals should // already be validated as dictionaries. If var is NULL, the @@ -101,7 +101,7 @@ py_to_raw_dict_support_code = \ """ -PyObject* py_to_raw_dict(PyObject* py_obj, char* name) +PyObject* py_to_raw_dict(PyObject* py_obj, const char* name) { // simply check that the value is a valid dictionary pointer. if(!py_obj || !PyDict_Check(py_obj)) From scipy-svn at scipy.org Sun May 11 04:56:05 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 03:56:05 -0500 (CDT) Subject: [Scipy-svn] r4253 - in branches/refactor_fft: . scipy/interpolate scipy/sparse scipy/sparse/tests scipy/special scipy/stats scipy/weave Message-ID: <20080511085605.75604C7C00E@scipy.org> Author: cdavid Date: 2008-05-11 03:55:52 -0500 (Sun, 11 May 2008) New Revision: 4253 Modified: branches/refactor_fft/ branches/refactor_fft/scipy/interpolate/fitpack.py branches/refactor_fft/scipy/sparse/bsr.py branches/refactor_fft/scipy/sparse/compressed.py branches/refactor_fft/scipy/sparse/dok.py branches/refactor_fft/scipy/sparse/tests/test_base.py branches/refactor_fft/scipy/special/basic.py branches/refactor_fft/scipy/stats/mmorestats.py branches/refactor_fft/scipy/stats/mstats.py branches/refactor_fft/scipy/weave/common_info.py Log: Merged revisions 4229-4252 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r4236 | pierregm | 2008-05-07 02:14:47 +0900 (Wed, 07 May 2008) | 1 line mmorestats : fixed a bug w/ hdquantiles ........ r4237 | pierregm | 2008-05-07 02:16:51 +0900 (Wed, 07 May 2008) | 2 lines mstats : kendall_tau : fixed a pb when n=2 theil_slopes: return a (4,) tuple instead of a (3,(),) tuple ........ r4242 | peridot | 2008-05-07 13:18:20 +0900 (Wed, 07 May 2008) | 2 lines Provided references extracted from FITPACK routines so users can find the journal articles describing how these routines work without looking in the FORTRAN source code. ........ r4250 | wnbell | 2008-05-09 03:13:41 +0900 (Fri, 09 May 2008) | 2 lines make sparse work with new numpy matrix indexing behavior ........ r4251 | peridot | 2008-05-09 07:21:48 +0900 (Fri, 09 May 2008) | 2 lines Correct Bessel function zeros docstring to match code ........ r4252 | rkern | 2008-05-09 07:47:52 +0900 (Fri, 09 May 2008) | 1 line const-correctness patch by Norbet Namec. ........ Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4228 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4252 Modified: branches/refactor_fft/scipy/interpolate/fitpack.py =================================================================== --- branches/refactor_fft/scipy/interpolate/fitpack.py 2008-05-08 22:47:52 UTC (rev 4252) +++ branches/refactor_fft/scipy/interpolate/fitpack.py 2008-05-11 08:55:52 UTC (rev 4253) @@ -172,6 +172,16 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Dierckx P. : Algorithms for smoothing data with periodic and + parametric splines, Computer Graphics and Image + Processing 20 (1982) 171-184. + Dierckx P. : Algorithms for smoothing data with periodic and param- + etric splines, report tw55, Dept. Computer Science, + K.U.Leuven, 1981. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ if task<=0: _parcur_cache = {'t': array([],float), 'wrk': array([],float), @@ -331,6 +341,21 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + + Based on algorithms described in: + Dierckx P. : An algorithm for smoothing, differentiation and integ- + ration of experimental data using spline functions, + J.Comp.Appl.Maths 1 (1975) 165-184. + Dierckx P. : A fast algorithm for smoothing data on a rectangular + grid while using spline functions, SIAM J.Numer.Anal. + 19 (1982) 1286-1304. + Dierckx P. : An improved algorithm for curve fitting with spline + functions, report tw54, Dept. Computer Science,K.U. + Leuven, 1981. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ if task<=0: _curfit_cache = {} @@ -436,6 +461,14 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + de Boor C : On calculating with b-splines, J. Approximation Theory + 6 (1972) 50-62. + Cox M.G. : The numerical evaluation of b-splines, J. Inst. Maths + Applics 10 (1972) 134-149. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck try: @@ -481,6 +514,12 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Gaffney P.W. : The calculation of indefinite integrals of b-splines + J. Inst. Maths Applics 17 (1976) 37-41. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck try: @@ -519,6 +558,7 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + """ t,c,k=tck if k==4: t=t[1:-1] @@ -566,6 +606,14 @@ bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + Notes: + Based on algorithms from: + de Boor C : On calculating with b-splines, J. Approximation Theory + 6 (1972) 50-62. + Cox M.G. : The numerical evaluation of b-splines, J. Inst. Maths + applics 10 (1972) 134-149. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck try: @@ -601,7 +649,8 @@ Description: Given a set of data points (x[i], y[i], z[i]) representing a surface - z=f(x,y), compute a B-spline representation of the surface. + z=f(x,y), compute a B-spline representation of the surface. Based on + the routine SURFIT from FITPACK. Inputs: @@ -653,6 +702,15 @@ splprep, splrep, splint, sproot, splev - evaluation, roots, integral UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Based on algorithms from: + Dierckx P. : An algorithm for surface fitting with spline functions + Ima J. Numer. Anal. 1 (1981) 267-283. + Dierckx P. : An algorithm for surface fitting with spline functions + report tw50, Dept. Computer Science,K.U.Leuven, 1980. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ x,y,z=map(myasarray,[x,y,z]) x,y,z=map(ravel,[x,y,z]) # ensure 1-d arrays. @@ -736,7 +794,7 @@ Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or - both are floats. + both are floats. Based on BISPEV from FITPACK. Inputs: @@ -760,6 +818,15 @@ splprep, splrep, splint, sproot, splev - evaluation, roots, integral UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions + + Notes: + Based on algorithms from: + Dierckx P. : An algorithm for surface fitting with spline functions + Ima J. Numer. Anal. 1 (1981) 267-283. + Dierckx P. : An algorithm for surface fitting with spline functions + report tw50, Dept. Computer Science,K.U.Leuven, 1980. + Dierckx P. : Curve and surface fitting with splines, Monographs on + Numerical Analysis, Oxford University Press, 1993. """ tx,ty,c,kx,ky=tck if not (0<=dx 2: + v2 = np.sum(v*k*(k-1)*(k-2) for (k,v) in xties.iteritems()) * \ + np.sum(v*k*(k-1)*(k-2) for (k,v) in yties.iteritems()) + v2 /= 9.*n*(n-1)*(n-2) + else: + v2 = 0 else: v1 = v2 = 0 var_s /= 18. @@ -752,7 +758,7 @@ Ru = np.round((nt - z*sigma)/2. + 1) Rl = np.round((nt + z*sigma)/2.) delta = slopes[[Rl,Ru]] - return medslope, medinter, delta + return medslope, medinter, delta[0], delta[1] def sen_seasonal_slopes(x): Modified: branches/refactor_fft/scipy/weave/common_info.py =================================================================== --- branches/refactor_fft/scipy/weave/common_info.py 2008-05-08 22:47:52 UTC (rev 4252) +++ branches/refactor_fft/scipy/weave/common_info.py 2008-05-11 08:55:52 UTC (rev 4253) @@ -15,7 +15,7 @@ object None = object(Py_None); } -char* find_type(PyObject* py_obj) +const char* find_type(PyObject* py_obj) { if(py_obj == NULL) return "C NULL value"; if(PyCallable_Check(py_obj)) return "callable"; @@ -76,13 +76,13 @@ get_variable_support_code = \ """ -void handle_variable_not_found(char* var_name) +void handle_variable_not_found(const char* var_name) { char msg[500]; sprintf(msg,"Conversion Error: variable '%s' not found in local or global scope.",var_name); throw_error(PyExc_NameError,msg); } -PyObject* get_variable(char* name,PyObject* locals, PyObject* globals) +PyObject* get_variable(const char* name,PyObject* locals, PyObject* globals) { // no checking done for error -- locals and globals should // already be validated as dictionaries. If var is NULL, the @@ -101,7 +101,7 @@ py_to_raw_dict_support_code = \ """ -PyObject* py_to_raw_dict(PyObject* py_obj, char* name) +PyObject* py_to_raw_dict(PyObject* py_obj, const char* name) { // simply check that the value is a valid dictionary pointer. if(!py_obj || !PyDict_Check(py_obj)) From scipy-svn at scipy.org Sun May 11 05:13:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 04:13:41 -0500 (CDT) Subject: [Scipy-svn] r4254 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080511091341.F086339C153@scipy.org> Author: cdavid Date: 2008-05-11 04:13:36 -0500 (Sun, 11 May 2008) New Revision: 4254 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx Log: Reindent code correctly for fftw3 backend. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-11 08:55:52 UTC (rev 4253) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-11 09:13:36 UTC (rev 4254) @@ -1,30 +1,11 @@ /* - * Last Change: Wed Aug 01 07:00 PM 2007 J + * Last Change: Sun May 11 05:00 PM 2008 J * * RFFTW3 implementation * * Original code by Pearu Peterson. */ -#if 0 -GEN_CACHE(drfftw3, (int n, int d, int flags) - , int direction; - int flags; - fftw_plan plan; - double *ptr;, ((caches_drfftw3[i].n == n) && - (caches_drfftw3[i].direction == d) && - (caches_drfftw3[i].flags == flags)) - , caches_drfftw3[id].direction = d; - caches_drfftw3[id].flags = flags; - caches_drfftw3[id].ptr = - (double *) fftw_malloc(sizeof(double) * (n)); - caches_drfftw3[id].plan = - fftw_plan_r2r_1d(n, caches_drfftw3[id].ptr, caches_drfftw3[id].ptr, - (d > 0 ? FFTW_R2HC : FFTW_HC2R), flags);, - fftw_destroy_plan(caches_drfftw3[id].plan); - fftw_free(caches_drfftw3[id].ptr);, 10) -#endif - #include #include @@ -39,7 +20,8 @@ int compute_forward(double* inout) const { - assert (m_id.m_isalign ? is_simd_aligned(inout) : true); + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); fftw_execute_r2r(m_plan, inout, m_wrk); COPYRFFTW2STD(m_wrk, inout, m_id.m_n); return 0; @@ -47,7 +29,8 @@ int compute_backward(double* inout) const { - assert (m_id.m_isalign ? is_simd_aligned(inout) : true); + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); fftw_execute_r2r(m_plan, m_wrk, inout); return 0; @@ -116,8 +99,8 @@ int i; double *ptr = inout; - RFFTW3Cache *cache; - bool isaligned; + RFFTW3Cache *cache; + bool isaligned; isaligned = is_simd_aligned(ptr); Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-11 08:55:52 UTC (rev 4253) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-11 09:13:36 UTC (rev 4254) @@ -12,7 +12,8 @@ int compute(fftw_complex* inout) const { - assert (m_id.m_isalign ? is_simd_aligned(inout) : true); + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); fftw_execute_dft(m_plan, inout, inout); return 0; }; @@ -37,7 +38,8 @@ } m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, - (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), + (id.m_dir > 0 ? FFTW_FORWARD : + FFTW_BACKWARD), flags); if (m_plan == NULL) { @@ -68,10 +70,10 @@ static void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, int normalize) { - fftw_complex *ptr = (fftw_complex*)inout; - double factor = 1./n; - FFTW3Cache *cache; - bool isaligned; + fftw_complex *ptr = (fftw_complex*)inout; + double factor = 1./n; + FFTW3Cache *cache; + bool isaligned; int i; Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-11 08:55:52 UTC (rev 4253) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-11 09:13:36 UTC (rev 4254) @@ -3,7 +3,7 @@ * * Original code by Pearu Peaterson * - * Last Change: Wed May 07 06:00 PM 2008 J + * Last Change: Sun May 11 06:00 PM 2008 J */ #include #include @@ -13,46 +13,47 @@ using namespace fft; class NDFFTW3CacheId { - public: - NDFFTW3CacheId(int rank, int* dims, int howmany, int dir, bool isalign); + public: + NDFFTW3CacheId(int rank, int *dims, int howmany, int dir, + bool isalign); virtual ~NDFFTW3CacheId(); - NDFFTW3CacheId(const NDFFTW3CacheId&); + NDFFTW3CacheId(const NDFFTW3CacheId &); - virtual bool operator==(const NDFFTW3CacheId& other) const - { - return is_equal(other); - }; + virtual bool operator==(const NDFFTW3CacheId & other) const { + return is_equal(other); + }; - virtual bool is_equal(const NDFFTW3CacheId& other) const; + virtual bool is_equal(const NDFFTW3CacheId & other) const; - public: - int m_rank; - int *m_dims; + public: + int m_rank; + int *m_dims; int m_howmany; int m_dir; bool m_isalign; private: - int init(int rank, int* dims); + int init(int rank, int *dims); }; -int NDFFTW3CacheId::init(int rank, int* dims) +int NDFFTW3CacheId::init(int rank, int *dims) { - m_dims = (int*)malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); - return 0; + return 0; } -NDFFTW3CacheId::NDFFTW3CacheId(int rank, int* dims, int howmany, int dir, bool isalign) : - m_rank(rank), - m_howmany(howmany), - m_dir(dir), +NDFFTW3CacheId::NDFFTW3CacheId(int rank, int *dims, int howmany, + int dir, bool isalign) : + m_rank(rank), + m_howmany(howmany), + m_dir(dir), m_isalign(isalign) { if (init(rank, dims)) { @@ -63,102 +64,104 @@ std::bad_alloc(); } -NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId& copy) : +NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId & copy) : m_rank(copy.m_rank), - m_howmany(copy.m_howmany), - m_dir(copy.m_dir), + m_howmany(copy.m_howmany), + m_dir(copy.m_dir), m_isalign(copy.m_isalign) { - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } fail: - std::bad_alloc(); + std::bad_alloc(); } NDFFTW3CacheId::~NDFFTW3CacheId() { - free(m_dims); + free(m_dims); } -bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId& other) const +bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId & other) const { - bool res; - int i; + bool res; + int i; - res = (other.m_dir == m_dir); - res = res && (other.m_isalign == m_isalign); - res = res && (m_howmany == other.m_howmany); - - if (m_rank == other.m_rank) { - for (i = 0; i < m_rank; ++i) { - res = res && (m_dims[i] == other.m_dims[i]); - } - } else { - return false; - } + res = (other.m_dir == m_dir); + res = res && (other.m_isalign == m_isalign); + res = res && (m_howmany == other.m_howmany); - return res; + if (m_rank == other.m_rank) { + for (i = 0; i < m_rank; ++i) { + res = res && (m_dims[i] == other.m_dims[i]); + } + } else { + return false; + } + + return res; } /* stub because fftw3 has no cache mechanism (yet) */ -static void destroy_zfftnd_fftw3_caches(void) {} +static void destroy_zfftnd_fftw3_caches(void) +{ +} -class NDFFTW3Cache : public Cache { - public: - NDFFTW3Cache(const NDFFTW3CacheId& id); - virtual ~NDFFTW3Cache(); +class NDFFTW3Cache:public Cache < NDFFTW3CacheId > { + public: + NDFFTW3Cache(const NDFFTW3CacheId & id); + virtual ~ NDFFTW3Cache(); - int compute(fftw_complex* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : true); - fftw_execute_dft(m_plan, inout, inout); - return 0; - }; + int compute(fftw_complex * inout) const { + assert(m_id.m_isalign ? is_simd_aligned(inout) : true); + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; - protected: - fftw_plan m_plan; - fftw_complex *m_wrk; + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; }; -NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId& id) -: Cache(id) +NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId & id) +: Cache < NDFFTW3CacheId > (id) { - int flags = FFTW_ESTIMATE; - int sz; - int i; + int flags = FFTW_ESTIMATE; + int sz; + int i; - sz = 1; - for (i = 0; i < m_id.m_rank; ++i) { - sz *= m_id.m_dims[i]; - } + sz = 1; + for (i = 0; i < m_id.m_rank; ++i) { + sz *= m_id.m_dims[i]; + } - m_wrk = (fftw_complex*)fftw_malloc(sz * sizeof(fftw_complex) ); + m_wrk = (fftw_complex *) fftw_malloc(sz * sizeof(fftw_complex)); if (m_wrk == NULL) { goto fail_wrk; } - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } - m_plan = fftw_plan_many_dft(m_id.m_rank, - m_id.m_dims, m_id.m_howmany, - m_wrk, NULL, 1, sz, - m_wrk, NULL, 1, sz, - (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), - flags); + m_plan = fftw_plan_many_dft(m_id.m_rank, + m_id.m_dims, m_id.m_howmany, + m_wrk, NULL, 1, sz, + m_wrk, NULL, 1, sz, + (id.m_dir > + 0 ? FFTW_FORWARD : FFTW_BACKWARD), + flags); if (m_plan == NULL) { goto clean_wrk; } - return ; + return; -clean_wrk: + clean_wrk: fftw_free(m_wrk); -fail_wrk: + fail_wrk: throw std::bad_alloc(); } @@ -168,30 +171,34 @@ fftw_free(m_wrk); } -static CacheManager fftw3_cmgr(10); +static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > fftw3_cmgr(10); extern void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) + int *dims, int direction, int howmany, + int normalize) { - int i, sz; - fftw_complex *ptr = (fftw_complex*)inout; - NDFFTW3Cache *cache; + int i, sz; + fftw_complex *ptr = (fftw_complex *) inout; + NDFFTW3Cache *cache; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } - cache = fftw3_cmgr.get_cache(NDFFTW3CacheId(rank, dims, howmany, direction, is_simd_aligned(inout))); + cache = + fftw3_cmgr. + get_cache(NDFFTW3CacheId + (rank, dims, howmany, direction, + is_simd_aligned(inout))); - cache->compute(ptr); + cache->compute(ptr); - if (normalize) { - ptr = (fftw_complex*)inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } + if (normalize) { + ptr = (fftw_complex *) inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } } From scipy-svn at scipy.org Sun May 11 05:20:52 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 04:20:52 -0500 (CDT) Subject: [Scipy-svn] r4255 - branches/refactor_fft/scipy/fftpack/src/mkl Message-ID: <20080511092052.A219339C153@scipy.org> Author: cdavid Date: 2008-05-11 04:20:47 -0500 (Sun, 11 May 2008) New Revision: 4255 Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Log: Reindent zfftnd mkl implementation, to match PEP 7. Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 09:13:36 UTC (rev 4254) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 09:20:47 UTC (rev 4255) @@ -3,18 +3,19 @@ * * Original code by David M. Cooke * - * Last Change: Wed Aug 08 03:00 PM 2007 J + * Last Change: Sun May 11 06:00 PM 2008 J */ static long *convert_dims(int n, int *dims) { - long *ndim; - int i; - ndim = (long *) malloc(sizeof(long) * n); - for (i = 0; i < n; i++) { - ndim[i] = (long) dims[i]; - } - return ndim; + long *ndim; + int i; + + ndim = (long *) malloc(sizeof(*ndim) * n); + for (i = 0; i < n; i++) { + ndim[i] = (long) dims[i]; + } + return ndim; } GEN_CACHE(zfftnd_mkl, (int n, int *dims) @@ -38,29 +39,29 @@ int *dims, int direction, int howmany, int normalize) { - int i, sz; - complex_double *ptr = inout; + int i, sz, id; + complex_double *ptr = inout; - DFTI_DESCRIPTOR_HANDLE desc_handle; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } + DFTI_DESCRIPTOR_HANDLE desc_handle; + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } - desc_handle = - caches_zfftnd_mkl[get_cache_id_zfftnd_mkl(rank, dims)].desc_handle; - for (i = 0; i < howmany; ++i, ptr += sz) { - if (direction == 1) { - DftiComputeForward(desc_handle, (double *) ptr); - } else if (direction == -1) { - DftiComputeBackward(desc_handle, (double *) ptr); + id = get_cache_id_zfftnd_mkl(rank, dims); + desc_handle = caches_zfftnd_mkl[id].desc_handle; + for (i = 0; i < howmany; ++i, ptr += sz) { + if (direction == 1) { + DftiComputeForward(desc_handle, (double *) ptr); + } else if (direction == -1) { + DftiComputeBackward(desc_handle, (double *) ptr); + } } - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; + if (normalize) { + ptr = inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } } - } } From scipy-svn at scipy.org Sun May 11 05:59:40 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 04:59:40 -0500 (CDT) Subject: [Scipy-svn] r4256 - branches/refactor_fft/scipy/fftpack/src/mkl Message-ID: <20080511095940.81BF739C153@scipy.org> Author: cdavid Date: 2008-05-11 04:59:35 -0500 (Sun, 11 May 2008) New Revision: 4256 Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Log: mkl backend for zfftnd now uses c++ cycle cache. Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 09:20:47 UTC (rev 4255) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 09:59:35 UTC (rev 4256) @@ -5,9 +5,146 @@ * * Last Change: Sun May 11 06:00 PM 2008 J */ +#include -static long *convert_dims(int n, int *dims) +#include "cycliccache.h" + +using namespace fft; + +class NDMKLCacheId { + public: + NDMKLCacheId(int rank, int *dim); + virtual ~NDMKLCacheId(); + + NDMKLCacheId(const NDMKLCacheId &); + + virtual bool operator==(const NDMKLCacheId & other) const { + return is_equal(other); + }; + + virtual bool is_equal(const NDMKLCacheId & other) const; + + public: + int m_rank; + int *m_dims; + + private: + int init(int rank, int *dims); +}; + +int NDMKLCacheId::init(int rank, int *dims) { + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + +NDMKLCacheId::NDMKLCacheId(int rank, int *dims) : + m_rank(rank) +{ + if (init(rank, dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDMKLCacheId::NDMKLCacheId(const NDMKLCacheId & copy) : + m_rank(copy.m_rank) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDMKLCacheId::~NDMKLCacheId() +{ + free(m_dims); +} + +bool NDMKLCacheId::is_equal(const NDMKLCacheId & other) const +{ + bool res; + + if (m_rank == other.m_rank) { + res = equal_dims(m_rank, m_dims, other.m_dims); + } else { + return false; + } + + return res; +} + +/* + * Cache class for nd-MKL + */ +class NDMKLCache:public Cache < NDMKLCacheId > { + public: + NDMKLCache(const NDMKLCacheId & id); + virtual ~ NDMKLCache(); + + int compute_forward(double * inout) const + { + DftiComputeForward(m_hdl, inout); + return 0; + }; + + int compute_backward(double * inout) const + { + DftiComputeBackward(m_hdl, inout); + return 0; + }; + + protected: + int m_rank; + int *m_dims; + long *m_ndims; + DFTI_DESCRIPTOR_HANDLE m_hdl; + + private: + long *convert_dims(int n, int *dims) const; + +}; + +NDMKLCache::NDMKLCache(const NDMKLCacheId & id) +: Cache < NDMKLCacheId > (id) +{ + m_rank = id.m_rank; + m_ndims = convert_dims(id.m_rank, id.m_dims); + m_dims = (int *) malloc(sizeof(int) * m_rank); + if (m_dims == NULL) { + goto fail; + } + + memcpy(m_dims, id.m_dims, sizeof(int) * m_rank); + DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, (long) m_rank, + m_ndims); + DftiCommitDescriptor(m_hdl); + + return; + +fail: + throw std::bad_alloc(); +} + +NDMKLCache::~NDMKLCache() +{ + DftiFreeDescriptor(&m_hdl); + free(m_dims); + free(m_ndims); +} + +long* NDMKLCache::convert_dims(int n, int *dims) const +{ long *ndim; int i; @@ -18,44 +155,42 @@ return ndim; } -GEN_CACHE(zfftnd_mkl, (int n, int *dims) - , DFTI_DESCRIPTOR_HANDLE desc_handle; - int *dims; - long *ndims;, ((caches_zfftnd_mkl[i].n == n) && - (equal_dims(n, caches_zfftnd_mkl[i].dims, dims))) - , caches_zfftnd_mkl[id].ndims = convert_dims(n, dims); - caches_zfftnd_mkl[id].n = n; - caches_zfftnd_mkl[id].dims = (int *) malloc(sizeof(int) * n); - memcpy(caches_zfftnd_mkl[id].dims, dims, sizeof(int) * n); - DftiCreateDescriptor(&caches_zfftnd_mkl[id].desc_handle, - DFTI_DOUBLE, DFTI_COMPLEX, (long) n, - caches_zfftnd_mkl[id].ndims); - DftiCommitDescriptor(caches_zfftnd_mkl[id].desc_handle);, - DftiFreeDescriptor(&caches_zfftnd_mkl[id].desc_handle); - free(caches_zfftnd_mkl[id].dims); - free(caches_zfftnd_mkl[id].ndims);, 10) +static CacheManager < NDMKLCacheId, NDMKLCache > mkl_cmgr(10); +/* stub to make GEN_CACHE happy */ +static void destroy_zfftnd_mkl_caches() +{ +} + extern void zfftnd_mkl(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) { - int i, sz, id; + int i, sz; complex_double *ptr = inout; + NDMKLCache *cache; - DFTI_DESCRIPTOR_HANDLE desc_handle; sz = 1; for (i = 0; i < rank; ++i) { sz *= dims[i]; } - id = get_cache_id_zfftnd_mkl(rank, dims); - desc_handle = caches_zfftnd_mkl[id].desc_handle; - for (i = 0; i < howmany; ++i, ptr += sz) { - if (direction == 1) { - DftiComputeForward(desc_handle, (double *) ptr); - } else if (direction == -1) { - DftiComputeBackward(desc_handle, (double *) ptr); - } + cache = mkl_cmgr.get_cache(NDMKLCacheId(rank, dims)); + switch(direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += sz) { + cache->compute_forward((double*)ptr); + } + break; + case -1: + for (i = 0; i < howmany; ++i, ptr += sz) { + cache->compute_backward((double*)ptr); + } + break; + default: + fprintf(stderr, + "nd mkl:Wrong direction (this is a bug)\n"); + return; } if (normalize) { ptr = inout; From scipy-svn at scipy.org Sun May 11 06:01:03 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:01:03 -0500 (CDT) Subject: [Scipy-svn] r4257 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080511100103.6622E39C153@scipy.org> Author: cdavid Date: 2008-05-11 05:00:59 -0500 (Sun, 11 May 2008) New Revision: 4257 Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx Log: Remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-11 09:59:35 UTC (rev 4256) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-11 10:00:59 UTC (rev 4257) @@ -1,17 +1,3 @@ -#if 0 -GEN_CACHE(zfftw,(int n,int d) - ,int direction; - fftw_plan plan; - ,((caches_zfftw[i].n==n) && - (caches_zfftw[i].direction==d)) - ,caches_zfftw[id].direction = d; - caches_zfftw[id].plan = fftw_create_plan(n, - (d>0?FFTW_FORWARD:FFTW_BACKWARD), - FFTW_IN_PLACE|FFTW_ESTIMATE); - ,fftw_destroy_plan(caches_zfftw[id].plan); - ,10) -#endif - #include #include "cycliccache.h" From scipy-svn at scipy.org Sun May 11 06:30:48 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:30:48 -0500 (CDT) Subject: [Scipy-svn] r4258 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080511103048.06A7C39C452@scipy.org> Author: cdavid Date: 2008-05-11 05:30:45 -0500 (Sun, 11 May 2008) New Revision: 4258 Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx Log: fftw (2) backend for drfft now uses c++ cycle cache. Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-11 10:00:59 UTC (rev 4257) +++ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-11 10:30:45 UTC (rev 4258) @@ -1,11 +1,107 @@ /* - * Last Change: Wed Aug 01 07:00 PM 2007 J + * Last Change: Sun May 11 07:00 PM 2008 J * * FFTW2 implementation * * Original code by Pearu Peterson. */ +#include +#include "cycliccache.h" + +using namespace fft; + +class RFFTWCacheId : public CacheId { + public: + RFFTWCacheId(int n, int dir, int flags); + + virtual bool operator==(const RFFTWCacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const RFFTWCacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_dir == other.m_dir && + m_flags == other.m_flags && + th->is_equal(*ot); + } + + public: + int m_dir; + int m_flags; +}; + +RFFTWCacheId::RFFTWCacheId(int n, int dir, int flags): + CacheId(n), + m_dir(dir), + m_flags(flags) +{ +} + +class RFFTWCache : public Cache { + public: + RFFTWCache(const RFFTWCacheId& id); + virtual ~RFFTWCache(); + + int compute(double* inout) const; + + protected: + rfftw_plan m_plan; + double *m_wrk; +}; + +RFFTWCache::RFFTWCache(const RFFTWCacheId& id) +: Cache(id) +{ + m_wrk = (double *) malloc(sizeof(double) * id.m_n); + if(m_wrk == NULL) { + goto fail; + } + + m_plan = rfftw_create_plan(id.m_n, + (id.m_dir > 0 ? FFTW_REAL_TO_COMPLEX : + FFTW_COMPLEX_TO_REAL), + id.m_flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return; + +clean_wrk: + free(m_wrk); +fail: + throw std::bad_alloc(); +} + +RFFTWCache::~RFFTWCache() +{ + free(m_wrk); + rfftw_destroy_plan(m_plan); +} + +int RFFTWCache::compute(double* inout) const +{ + if(m_id.m_dir == 1) { + memcpy(m_wrk, inout, sizeof(double) * m_id.m_n); + rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); + COPYRFFTW2STD(m_wrk, inout, m_id.m_n); + } else { + COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); + rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); + memcpy(inout, m_wrk, sizeof(double) * m_id.m_n); + } + return 0; +}; + +CacheManager rfftw_cmgr(10); + +#if 0 GEN_CACHE(drfftw, (int n, int d, int flags) , int direction; int flags; @@ -26,45 +122,37 @@ (double *) malloc(sizeof(double) * (n));, rfftw_destroy_plan(caches_drfftw[id].plan); free(caches_drfftw[id].ptr);, 10) +#endif -static void drfft_fftw(double *inout, int n, int dir, int - howmany, int normalize) +/* stub to make GEN_PUBLIC_API happy */ +static void destroy_drfftw_caches() { - int i; - double *ptr = inout; - double *ptrc = NULL; - rfftw_plan plan = NULL; +} - i = get_cache_id_drfftw(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE); - plan = caches_drfftw[i].plan; - ptrc = caches_drfftw[i].ptr; +static void drfft_fftw(double *inout, int n, int dir, + int howmany, int normalize) +{ + int i; + double *ptr = inout; + RFFTWCache *cache; - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - memcpy(ptrc, ptr, sizeof(double) * n); - rfftw(plan, 1, (fftw_real *) ptrc, 1, 1, NULL, 1, 1); - COPYRFFTW2STD(ptrc, ptr, n); - } - break; + cache = rfftw_cmgr.get_cache( + RFFTWCacheId(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE)); - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - COPYINVRFFTW2STD(ptr, ptrc, n); - rfftw(plan, 1, (fftw_real *) ptrc, 1, 1, NULL, 1, 1); - memcpy(ptr, ptrc, sizeof(double) * n); + if (dir != -1 && dir != 1) { + fprintf(stderr, "drfft: invalid dir=%d\n", dir); + return; + } else { + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute(ptr); + } } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", dir); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } } - } } From scipy-svn at scipy.org Sun May 11 06:31:25 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:31:25 -0500 (CDT) Subject: [Scipy-svn] r4259 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080511103125.EA57539C452@scipy.org> Author: cdavid Date: 2008-05-11 05:31:22 -0500 (Sun, 11 May 2008) New Revision: 4259 Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx Log: Remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-11 10:30:45 UTC (rev 4258) +++ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-11 10:31:22 UTC (rev 4259) @@ -101,29 +101,6 @@ CacheManager rfftw_cmgr(10); -#if 0 -GEN_CACHE(drfftw, (int n, int d, int flags) - , int direction; - int flags; - rfftw_plan plan; - double *ptr;, ((caches_drfftw[i].n == n) && - (caches_drfftw[i].direction == d) && - (caches_drfftw[i].flags == flags)) - , caches_drfftw[id].direction = d; - caches_drfftw[id].flags = flags; - caches_drfftw[id].plan = rfftw_create_plan(n, - (d > - 0 ? - FFTW_REAL_TO_COMPLEX - : - FFTW_COMPLEX_TO_REAL), - flags); - caches_drfftw[id].ptr = - (double *) malloc(sizeof(double) * (n));, - rfftw_destroy_plan(caches_drfftw[id].plan); - free(caches_drfftw[id].ptr);, 10) -#endif - /* stub to make GEN_PUBLIC_API happy */ static void destroy_drfftw_caches() { From scipy-svn at scipy.org Sun May 11 06:57:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:57:18 -0500 (CDT) Subject: [Scipy-svn] r4260 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080511105718.500C139C401@scipy.org> Author: cdavid Date: 2008-05-11 05:57:14 -0500 (Sun, 11 May 2008) New Revision: 4260 Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx Log: fftw (2) backend for zfftnd now uses c++ cycle cache. Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 10:31:22 UTC (rev 4259) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 10:57:14 UTC (rev 4260) @@ -3,9 +3,150 @@ * * Original code by Pearu Peaterson * - * Last Change: Thu Sep 06 05:00 PM 2007 J + * Last Change: Sun May 11 07:00 PM 2008 J */ +#include +#include +#include + +using namespace fft; + +class NDFFTWCacheId { + public: + NDFFTWCacheId(int rank, int *dims, int dir, int flags); + virtual ~NDFFTWCacheId(); + + NDFFTWCacheId(const NDFFTWCacheId &); + + virtual bool operator==(const NDFFTWCacheId & other) const { + return is_equal(other); + }; + + virtual bool is_equal(const NDFFTWCacheId & other) const; + + public: + int m_dir; + int m_rank; + int *m_dims; + int m_flags; + + private: + int init(int rank, int *dims); +}; + +int NDFFTWCacheId::init(int rank, int *dims) +{ + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + +NDFFTWCacheId::NDFFTWCacheId(int rank, int *dims, int dir, int flags) : + m_dir(dir), + m_rank(rank), + m_flags(flags) +{ + if (init(rank, dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTWCacheId::NDFFTWCacheId(const NDFFTWCacheId & copy) : + m_dir(copy.m_dir), + m_rank(copy.m_rank), + m_flags(copy.m_flags) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTWCacheId::~NDFFTWCacheId() +{ + free(m_dims); +} + +bool NDFFTWCacheId::is_equal(const NDFFTWCacheId & other) const +{ + bool res; + + res = (other.m_dir == m_dir); + res = res && (other.m_flags == m_flags); + + if (m_rank == other.m_rank) { + res = res && equal_dims(m_rank, m_dims, other.m_dims); + } else { + return false; + } + + return res; +} + +class NDFFTWCache : public Cache < NDFFTWCacheId > { + public: + NDFFTWCache(const NDFFTWCacheId & id); + virtual ~ NDFFTWCache(); + + int compute(fftw_complex * inout) const + { + fftwnd_one(m_plan, inout, NULL); + return 0; + }; + + protected: + fftwnd_plan m_plan; +}; + +NDFFTWCache::NDFFTWCache(const NDFFTWCacheId & id) +: Cache < NDFFTWCacheId > (id) +{ + int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; +#if 0 + int sz; + int i; + + sz = 1; + for (i = 0; i < m_id.m_rank; ++i) { + sz *= m_id.m_dims[i]; + } +#endif + + m_plan = fftwnd_create_plan(m_id.m_rank, + m_id.m_dims, + (id.m_dir > 0 ? + FFTW_FORWARD : FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto fail; + } + + return; + +fail: + throw std::bad_alloc(); +} + +NDFFTWCache::~NDFFTWCache() +{ + fftwnd_destroy_plan(m_plan); +} + +static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); + +#if 0 GEN_CACHE(zfftnd_fftw, (int n, int *dims, int d, int flags) , int direction; int *dims; @@ -23,31 +164,39 @@ flags);, fftwnd_destroy_plan(caches_zfftnd_fftw[id].plan); free(caches_zfftnd_fftw[id].dims);, 10) +#endif +/* stub to make GEN_PUBLIC_API happy */ +static void destroy_zfftnd_fftw_caches() +{ +} extern void zfftnd_fftw(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) { - int i, sz; - complex_double *ptr = inout; - fftwnd_plan plan = NULL; + int i, sz; + complex_double *ptr = inout; + NDFFTWCache *cache; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - i = get_cache_id_zfftnd_fftw(rank, dims, direction, - FFTW_IN_PLACE | FFTW_ESTIMATE); - plan = caches_zfftnd_fftw[i].plan; - for (i = 0; i < howmany; ++i, ptr += sz) { - fftwnd_one(plan, (fftw_complex *) ptr, NULL); - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } + + cache = fftwnd_cmgr.get_cache( + NDFFTWCacheId(rank, dims, direction, + FFTW_IN_PLACE | FFTW_ESTIMATE)); + + for (i = 0; i < howmany; ++i, ptr += sz) { + cache->compute((fftw_complex*)ptr); + } + + if (normalize) { + ptr = inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } } From scipy-svn at scipy.org Sun May 11 06:57:45 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:57:45 -0500 (CDT) Subject: [Scipy-svn] r4261 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080511105745.5DB6D39C457@scipy.org> Author: cdavid Date: 2008-05-11 05:57:42 -0500 (Sun, 11 May 2008) New Revision: 4261 Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx Log: remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 10:57:14 UTC (rev 4260) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 10:57:42 UTC (rev 4261) @@ -146,26 +146,6 @@ static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); -#if 0 -GEN_CACHE(zfftnd_fftw, (int n, int *dims, int d, int flags) - , int direction; - int *dims; - fftwnd_plan plan;, ((caches_zfftnd_fftw[i].n == n) && - (caches_zfftnd_fftw[i].direction == d) && - (equal_dims - (n, caches_zfftnd_fftw[i].dims, dims))) - , caches_zfftnd_fftw[id].direction = d; - caches_zfftnd_fftw[id].n = n; - caches_zfftnd_fftw[id].dims = (int *) malloc(sizeof(int) * n); - memcpy(caches_zfftnd_fftw[id].dims, dims, sizeof(int) * n); - caches_zfftnd_fftw[id].plan = - fftwnd_create_plan(n, dims, - (d > 0 ? FFTW_FORWARD : FFTW_BACKWARD), - flags);, - fftwnd_destroy_plan(caches_zfftnd_fftw[id].plan); - free(caches_zfftnd_fftw[id].dims);, 10) -#endif - /* stub to make GEN_PUBLIC_API happy */ static void destroy_zfftnd_fftw_caches() { From scipy-svn at scipy.org Sun May 11 06:58:09 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:58:09 -0500 (CDT) Subject: [Scipy-svn] r4262 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080511105809.C968939C401@scipy.org> Author: cdavid Date: 2008-05-11 05:58:04 -0500 (Sun, 11 May 2008) New Revision: 4262 Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx Log: remove trailing spaces. Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 10:57:42 UTC (rev 4261) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 10:58:04 UTC (rev 4262) @@ -49,7 +49,7 @@ NDFFTWCacheId::NDFFTWCacheId(int rank, int *dims, int dir, int flags) : m_dir(dir), - m_rank(rank), + m_rank(rank), m_flags(flags) { if (init(rank, dims)) { @@ -60,7 +60,7 @@ std::bad_alloc(); } -NDFFTWCacheId::NDFFTWCacheId(const NDFFTWCacheId & copy) : +NDFFTWCacheId::NDFFTWCacheId(const NDFFTWCacheId & copy) : m_dir(copy.m_dir), m_rank(copy.m_rank), m_flags(copy.m_flags) @@ -99,7 +99,7 @@ NDFFTWCache(const NDFFTWCacheId & id); virtual ~ NDFFTWCache(); - int compute(fftw_complex * inout) const + int compute(fftw_complex * inout) const { fftwnd_one(m_plan, inout, NULL); return 0; @@ -125,7 +125,7 @@ m_plan = fftwnd_create_plan(m_id.m_rank, m_id.m_dims, - (id.m_dir > 0 ? + (id.m_dir > 0 ? FFTW_FORWARD : FFTW_BACKWARD), flags); @@ -165,7 +165,7 @@ } cache = fftwnd_cmgr.get_cache( - NDFFTWCacheId(rank, dims, direction, + NDFFTWCacheId(rank, dims, direction, FFTW_IN_PLACE | FFTW_ESTIMATE)); for (i = 0; i < howmany; ++i, ptr += sz) { From scipy-svn at scipy.org Sun May 11 06:59:50 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 05:59:50 -0500 (CDT) Subject: [Scipy-svn] r4263 - branches/refactor_fft/scipy/fftpack/src/mkl Message-ID: <20080511105950.B5FE439C401@scipy.org> Author: cdavid Date: 2008-05-11 05:59:46 -0500 (Sun, 11 May 2008) New Revision: 4263 Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Log: Fix comment. Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 10:58:04 UTC (rev 4262) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 10:59:46 UTC (rev 4263) @@ -3,7 +3,7 @@ * * Original code by David M. Cooke * - * Last Change: Sun May 11 06:00 PM 2008 J + * Last Change: Sun May 11 07:00 PM 2008 J */ #include @@ -157,7 +157,7 @@ static CacheManager < NDMKLCacheId, NDMKLCache > mkl_cmgr(10); -/* stub to make GEN_CACHE happy */ +/* stub to make GEN_PUBLIC_API happy */ static void destroy_zfftnd_mkl_caches() { } From scipy-svn at scipy.org Sun May 11 07:01:35 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 06:01:35 -0500 (CDT) Subject: [Scipy-svn] r4264 - in branches/refactor_fft/scipy/fftpack: . src src/djbfft Message-ID: <20080511110135.71BED39C401@scipy.org> Author: cdavid Date: 2008-05-11 06:01:25 -0500 (Sun, 11 May 2008) New Revision: 4264 Added: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx Removed: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/drfft.cxx Log: djbfft implementation of rfft api is now a C++ source file. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-11 10:59:46 UTC (rev 4263) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-11 11:01:25 UTC (rev 4264) @@ -33,7 +33,7 @@ extra_info=[fft_opt_info, djbfft_info], depends=['src/djbfft/zfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', - 'src/djbfft/drfft.c', 'src/fftpack/drfft.cxx', + 'src/djbfft/drfft.cxx', 'src/fftpack/drfft.cxx', 'src/fftw3/drfft.cxx', 'src/fftw/drfft.cxx', 'src/fftpack/zfftnd.cxx', 'src/fftw/zfftnd.cxx', 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.cxx', Deleted: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c 2008-05-11 10:59:46 UTC (rev 4263) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c 2008-05-11 11:01:25 UTC (rev 4264) @@ -1,131 +0,0 @@ -/* - * Last Change: Wed Aug 01 08:00 PM 2007 J - * - * Original code by Pearu Peterson. - */ - -/* - * DJBFFT only implements size 2^N ! - * - * drfft_def and drfft_def_destroy_cache are the functions used for size different - * than 2^N - */ -#ifdef WITH_FFTW3 -#define drfft_def drfft_fftw3 -#define drfft_def_destroy_cache destroy_drfftw3_caches -#elif defined WITH_FFTW -#define drfft_def drfft_fftw -#define drfft_def_destroy_cache destroy_drfftw_caches -#else -#define drfft_def drfft_fftpack -#define drfft_def_destroy_cache destroy_drfftpack_caches -#endif - -GEN_CACHE(drdjbfft, (int n) - , unsigned int *f; - double *ptr;, - caches_drdjbfft[i].n == n, - caches_drdjbfft[id].f = (unsigned int *) malloc(sizeof(unsigned int) * (n)); - caches_drdjbfft[id].ptr = (double *) malloc(sizeof(double) * n); - fftfreq_rtable(caches_drdjbfft[id].f, n);, - free(caches_drdjbfft[id].f); - free(caches_drdjbfft[id].ptr);, - 10) - -/**************** ZFFT function **********************/ -static void drfft_djbfft(double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - double *ptr = inout; - double *ptrc = NULL; - unsigned int *f = NULL; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - i = get_cache_id_drdjbfft(n); - f = caches_drdjbfft[i].f; - ptrc = caches_drdjbfft[i].ptr; - } - if (f == NULL) { - drfft_def(inout, n, direction, howmany, normalize); - } - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - COPYSTD2DJB(ptr, ptrc, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYDJB2STD(ptrc, ptr, f, n); - } - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - COPYINVSTD2DJB(ptr, ptrc, normalize, f, n); - switch (n) { - -#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(ptrc);fftr8_un##N(ptrc);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYINVDJB2STD(ptrc, ptr, n); - } - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize && f != NULL && direction == 1) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx (from rev 4252, branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.c) Modified: branches/refactor_fft/scipy/fftpack/src/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-11 10:59:46 UTC (rev 4263) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-11 11:01:25 UTC (rev 4264) @@ -57,7 +57,7 @@ * above) for non 2^n * size */ #ifdef WITH_DJBFFT - #include "djbfft/drfft.c" + #include "djbfft/drfft.cxx" extern "C" void destroy_drfft_cache(void) { destroy_drdjbfft_caches(); From scipy-svn at scipy.org Sun May 11 07:04:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 06:04:41 -0500 (CDT) Subject: [Scipy-svn] r4265 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080511110441.07E6539C401@scipy.org> Author: cdavid Date: 2008-05-11 06:04:37 -0500 (Sun, 11 May 2008) New Revision: 4265 Added: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx Log: Put DJBFFT key id in common header. Added: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-11 11:01:25 UTC (rev 4264) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-11 11:04:37 UTC (rev 4265) @@ -0,0 +1,9 @@ +#ifndef _SCIPY_DJBFFT_COMMON_H +#define _SCIPY_DJBFFT_COMMON_H + +class DJBFFTCacheId : public CacheId { + public: + DJBFFTCacheId(int n) : CacheId(n) {}; +}; + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-11 11:01:25 UTC (rev 4264) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-11 11:04:37 UTC (rev 4265) @@ -4,6 +4,9 @@ * zfft_def and zfft_def_destroy_cache are the functions * used for size different than 2^N */ + +#include "common.h" + #ifdef WITH_FFTWORK #define zfft_def zfft_fftwork #define zfft_def_destroy_cache destroy_zfftwork_cache @@ -18,11 +21,6 @@ #define zfft_def_destroy_cache destroy_zfftpack_caches #endif -class DJBFFTCacheId : public CacheId { - public: - DJBFFTCacheId(int n) : CacheId(n) {}; -}; - class DJBFFTCache: public Cache { public: DJBFFTCache(const DJBFFTCacheId& id); From scipy-svn at scipy.org Sun May 11 07:35:17 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 06:35:17 -0500 (CDT) Subject: [Scipy-svn] r4266 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080511113517.26CCD39C330@scipy.org> Author: cdavid Date: 2008-05-11 06:35:13 -0500 (Sun, 11 May 2008) New Revision: 4266 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx Log: djbfft backend for drfft now uses c++ cycliccache. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-11 11:04:37 UTC (rev 4265) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-11 11:35:13 UTC (rev 4266) @@ -1,9 +1,15 @@ #ifndef _SCIPY_DJBFFT_COMMON_H #define _SCIPY_DJBFFT_COMMON_H +#include + +namespace fft { + class DJBFFTCacheId : public CacheId { public: DJBFFTCacheId(int n) : CacheId(n) {}; }; +}; + #endif Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-11 11:04:37 UTC (rev 4265) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-11 11:35:13 UTC (rev 4266) @@ -1,15 +1,19 @@ /* - * Last Change: Wed Aug 01 08:00 PM 2007 J + * Last Change: Sun May 11 08:00 PM 2008 J * * Original code by Pearu Peterson. */ - /* - * DJBFFT only implements size 2^N ! + * RDJBFFT only implements size 2^N ! * * drfft_def and drfft_def_destroy_cache are the functions used for size different * than 2^N */ +#include +#include + +#include "common.h" + #ifdef WITH_FFTW3 #define drfft_def drfft_fftw3 #define drfft_def_destroy_cache destroy_drfftw3_caches @@ -21,6 +25,7 @@ #define drfft_def_destroy_cache destroy_drfftpack_caches #endif +#if 0 GEN_CACHE(drdjbfft, (int n) , unsigned int *f; double *ptr;, @@ -31,101 +36,169 @@ free(caches_drdjbfft[id].f); free(caches_drdjbfft[id].ptr);, 10) +#endif -/**************** ZFFT function **********************/ -static void drfft_djbfft(double * inout, - int n, int direction, int howmany, int normalize) +using namespace fft; + +class RDJBFFTCache: public Cache { + public: + RDJBFFTCache(const DJBFFTCacheId& id); + virtual ~RDJBFFTCache(); + + int compute_forward(double * inout) const; + int compute_backward(double * inout, int normalize) const; + + protected: + unsigned int* m_f; + double* m_ptr; +}; + +RDJBFFTCache::RDJBFFTCache(const DJBFFTCacheId& id) +: Cache(id) { - int i; - double *ptr = inout; - double *ptrc = NULL; - unsigned int *f = NULL; + int n = id.m_n; - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - i = get_cache_id_drdjbfft(n); - f = caches_drdjbfft[i].f; - ptrc = caches_drdjbfft[i].ptr; - } - if (f == NULL) { - drfft_def(inout, n, direction, howmany, normalize); - } + m_f = (unsigned int*)malloc(sizeof(*m_f) * n); + if (m_f == NULL) { + goto fail_f; + } - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - COPYSTD2DJB(ptr, ptrc, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); + m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); + if (m_ptr == NULL) { + goto clean_f; + } + + fftfreq_rtable(m_f, id.m_n); + return; + +clean_f: + free(m_f); +fail_f: + throw std::bad_alloc(); +} + +RDJBFFTCache::~RDJBFFTCache() +{ + free(m_ptr); + free(m_f); +} + +int RDJBFFTCache::compute_forward(double *inout) const +{ + const int n = m_id.m_n; + + COPYSTD2DJB(inout, m_ptr, n); + switch (n) { +#define TMPCASE(N) case N: fftr8_##N(m_ptr); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE - } - COPYDJB2STD(ptrc, ptr, f, n); - } } - break; + COPYDJB2STD(m_ptr, inout, m_f, n); - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - if (f != NULL) { - COPYINVSTD2DJB(ptr, ptrc, normalize, f, n); - switch (n) { + return 0; +} -#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(ptrc);fftr8_un##N(ptrc);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); +int RDJBFFTCache::compute_backward(double *inout, int normalize) const +{ + const int n = m_id.m_n; + + COPYINVSTD2DJB(inout, m_ptr, normalize, m_f, n); + switch (n) { +#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(m_ptr);fftr8_un##N(m_ptr);break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE - } - COPYINVDJB2STD(ptrc, ptr, n); - } } - break; + COPYINVDJB2STD(m_ptr, inout, n); - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } + return 0; +} - if (normalize && f != NULL && direction == 1) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; +static CacheManager rdjbfft_cmgr(10); + +/* Stub to make GEN_PUBLIC_API happy */ +static void destroy_drdjbfft_caches() +{ +} + +/**************** ZFFT function **********************/ +static void drfft_djbfft(double * inout, + int n, int direction, int howmany, int normalize) +{ + int i; + double *ptr = inout; + RDJBFFTCache *cache; + unsigned int *f = NULL; + + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + cache = rdjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + break; + default: + /* For sizes not handled by djbfft, use default + * implementation and returns */ + drfft_def(inout, n, direction, howmany, normalize); + return; } - } + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr, normalize); + } + break; + + default: + fprintf(stderr, "drfft: invalid direction=%d\n", + direction); + } + + if (normalize && f != NULL && direction == 1) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } } From scipy-svn at scipy.org Sun May 11 07:58:42 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 06:58:42 -0500 (CDT) Subject: [Scipy-svn] r4267 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080511115842.2B1B839C08D@scipy.org> Author: cdavid Date: 2008-05-11 06:58:38 -0500 (Sun, 11 May 2008) New Revision: 4267 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx Log: remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-11 11:35:13 UTC (rev 4266) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-11 11:58:38 UTC (rev 4267) @@ -25,19 +25,6 @@ #define drfft_def_destroy_cache destroy_drfftpack_caches #endif -#if 0 -GEN_CACHE(drdjbfft, (int n) - , unsigned int *f; - double *ptr;, - caches_drdjbfft[i].n == n, - caches_drdjbfft[id].f = (unsigned int *) malloc(sizeof(unsigned int) * (n)); - caches_drdjbfft[id].ptr = (double *) malloc(sizeof(double) * n); - fftfreq_rtable(caches_drdjbfft[id].f, n);, - free(caches_drdjbfft[id].f); - free(caches_drdjbfft[id].ptr);, - 10) -#endif - using namespace fft; class RDJBFFTCache: public Cache { From scipy-svn at scipy.org Sun May 11 08:07:13 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 07:07:13 -0500 (CDT) Subject: [Scipy-svn] r4268 - branches/refactor_fft/scipy/fftpack/src/fftpack Message-ID: <20080511120713.6900839C096@scipy.org> Author: cdavid Date: 2008-05-11 07:07:10 -0500 (Sun, 11 May 2008) New Revision: 4268 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx Log: fftpack backend for drfft now uses c++ cyclic cache. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-11 11:58:38 UTC (rev 4267) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-11 12:07:10 UTC (rev 4268) @@ -1,17 +1,81 @@ /* - * Last Change: Wed Aug 01 07:00 PM 2007 J + * Last Change: Sun May 11 08:00 PM 2008 J * * FFTPACK implementation * * Original code by Pearu Peterson. */ +#include +#include "cycliccache.h" + extern "C" { extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); extern void F_FUNC(dffti, DFFTI) (int *, double *); }; +using namespace fft; + +class RFFTPackCacheId : public CacheId { + public: + RFFTPackCacheId(int n) : CacheId(n) {}; +}; + +class RFFTPackCache: public Cache { + public: + RFFTPackCache(const RFFTPackCacheId& id); + virtual ~RFFTPackCache(); + + int compute_forward(double * inout) const; + int compute_backward(double * inout) const; + + protected: + double* m_wsave; +}; + +RFFTPackCache::RFFTPackCache(const RFFTPackCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + m_wsave = (double *)malloc(sizeof(*m_wsave) * (2 * n + 15)); + if (m_wsave == NULL) { + goto fail; + } + + F_FUNC(dffti, DFFTI)(&n, m_wsave); + + return; + +fail: + throw std::bad_alloc(); +} + +RFFTPackCache::~RFFTPackCache() +{ + free(m_wsave); +} + +int RFFTPackCache::compute_forward(double *inout) const +{ + int n = m_id.m_n; + + F_FUNC(dfftf, DFFTF)(&n, inout, m_wsave); + return 0; +} + +int RFFTPackCache::compute_backward(double *inout) const +{ + int n = m_id.m_n; + + F_FUNC(dfftb, DFFTB)(&n, inout, m_wsave); + return 0; +} + +static CacheManager rfftpack_cmgr(10); + +#if 0 GEN_CACHE(drfftpack, (int n) , double *wsave; , (caches_drfftpack[i].n == n) @@ -20,38 +84,47 @@ F_FUNC(dffti, DFFTI) (&n, caches_drfftpack[id].wsave); , free(caches_drfftpack[id].wsave); , 10) +#endif +/* + * Stub to make GEN_PUBLIC_API api + */ +static void destroy_drfftpack_caches() +{ +} + static void drfft_fftpack(double *inout, int n, int direction, int howmany, int normalize) { - int i; - double *ptr = inout; - double *wsave = NULL; - wsave = caches_drfftpack[get_cache_id_drfftpack(n)].wsave; + int i; + double *ptr = inout; + RFFTPackCache* cache; + cache = rfftpack_cmgr.get_cache(RFFTPackCacheId(n)); - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - dfftf_(&n, ptr, wsave); - } - break; + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - dfftb_(&n, ptr, wsave); + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + return; } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } } - } } From scipy-svn at scipy.org Sun May 11 08:49:13 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 07:49:13 -0500 (CDT) Subject: [Scipy-svn] r4269 - branches/refactor_fft/scipy/fftpack/src/fftpack Message-ID: <20080511124913.DB06639C064@scipy.org> Author: cdavid Date: 2008-05-11 07:49:09 -0500 (Sun, 11 May 2008) New Revision: 4269 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx Log: fftpack backend for zfftnd now uses c++ cyclic cache. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-11 12:07:10 UTC (rev 4268) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-11 12:49:09 UTC (rev 4269) @@ -3,9 +3,146 @@ * * Original code by Pearu Peaterson * - * Last Change: Wed Aug 08 02:00 PM 2007 J + * Last Change: Sun May 11 09:00 PM 2008 J */ +#include +#include "cycliccache.h" + +extern "C" { +extern void zfft(complex_double * inout, + int n, int direction, int howmany, int normalize); +}; + +static int next_comb(int *ia, int *da, int m); +static void flatten(complex_double * dest, complex_double * src, + int rank, int strides_axis, int dims_axis, int unflat, + int *tmp); + + +using namespace fft; + +class NDFFTPackCacheId : public CacheId { + public: + NDFFTPackCacheId(int n, int rank) : + CacheId(n), + m_rank(rank) + { + }; + + virtual bool operator==(const NDFFTPackCacheId &other) const + { + return is_equal(other); + }; + + virtual bool is_equal(const NDFFTPackCacheId &other) const; + + public: + int m_rank; +}; + +bool NDFFTPackCacheId::is_equal(const NDFFTPackCacheId & other) const +{ + return m_n == other.m_n && m_rank == other.m_rank; +} + +class NDFFTPackCache: public Cache { + public: + NDFFTPackCache(const NDFFTPackCacheId& id); + virtual ~NDFFTPackCache(); + + int compute(complex_double * inout, int sz, int* dims, + int direction, int normalize, int howmany) const; + + protected: + complex_double* m_wsave; + int* m_iptr; + + private: + int prepare(int *dims) const; +}; + +NDFFTPackCache::NDFFTPackCache(const NDFFTPackCacheId& id) +: Cache(id) +{ + int n = id.m_n; + int rank = id.m_rank; + + m_wsave = (complex_double *)malloc(sizeof(*m_wsave) * (2 * n)); + if (m_wsave == NULL) { + goto fail; + } + + m_iptr = (int*)malloc(4 * rank * sizeof(*m_iptr)); + if (m_iptr == NULL) { + goto clean_wsave; + } + + return; + +clean_wsave: + free(m_wsave); +fail: + throw std::bad_alloc(); +} + +NDFFTPackCache::~NDFFTPackCache() +{ + free(m_iptr); + free(m_wsave); +} + +int NDFFTPackCache::compute(complex_double *inout, int sz, int *dims, + int direction, int normalize, + int howmany) const +{ + int rank = m_id.m_rank; + int i, axis, k, j; + complex_double *tmp = m_wsave; + complex_double *ptr = inout; + + zfft(inout, dims[rank - 1], direction, howmany * sz / dims[rank - 1], + normalize); + prepare(dims); + + for (i = 0; i < howmany; ++i, ptr += sz) { + for (axis = 0; axis < rank - 1; ++axis) { + for (k = j = 0; k < rank; ++k) { + if (k != axis) { + *(m_iptr + rank + j) = m_iptr[k]; + *(m_iptr + 2 * rank + j++) = dims[k] - 1; + } + } + flatten(tmp, ptr, rank, m_iptr[axis], dims[axis], 0, m_iptr); + zfft(tmp, dims[axis], direction, sz / dims[axis], normalize); + flatten(ptr, tmp, rank, m_iptr[axis], dims[axis], 1, m_iptr); + } + } + return 0; +} + +int NDFFTPackCache::prepare(int *dims) const +{ + int rank = m_id.m_rank; + int i; + + m_iptr[rank - 1] = 1; + for (i = 2; i <= rank; ++i) { + m_iptr[rank - i] = m_iptr[rank - i + 1] * dims[rank - i + 1]; + } + + return 0; +} + +static CacheManager ndfftpack_cmgr(10); + +#if 0 +/* stub to make PUBLIC_GEN_API happy */ +static void destroy_zfftnd_fftpack_caches() +{ +} +#endif + GEN_CACHE(zfftnd_fftpack, (int n, int rank) , complex_double * ptr; int *iptr; int rank; , ((caches_zfftnd_fftpack[i].n == n) @@ -24,14 +161,14 @@ /*inline : disabled because MSVC6.0 fails to compile it. */ int next_comb(int *ia, int *da, int m) { - while (m >= 0 && ia[m] == da[m]) { - ia[m--] = 0; - } - if (m < 0) { - return 0; - } - ia[m]++; - return 1; + while (m >= 0 && ia[m] == da[m]) { + ia[m--] = 0; + } + if (m < 0) { + return 0; + } + ia[m]++; + return 1; } static @@ -39,82 +176,55 @@ int rank, int strides_axis, int dims_axis, int unflat, int *tmp) { - int *new_strides = tmp + rank; - int *new_dims = tmp + 2 * rank; - int *ia = tmp + 3 * rank; - int rm1 = rank - 1, rm2 = rank - 2; - int i, j, k; - for (i = 0; i < rm2; ++i) - ia[i] = 0; - ia[rm2] = -1; - j = 0; - if (unflat) { - while (next_comb(ia, new_dims, rm2)) { - k = 0; - for (i = 0; i < rm1; ++i) { - k += ia[i] * new_strides[i]; - } - for (i = 0; i < dims_axis; ++i) { - *(dest + k + i * strides_axis) = *(src + j++); - } + int *new_strides = tmp + rank; + int *new_dims = tmp + 2 * rank; + int *ia = tmp + 3 * rank; + int rm1 = rank - 1, rm2 = rank - 2; + int i, j, k; + + for (i = 0; i < rm2; ++i) { + ia[i] = 0; } - } else { - while (next_comb(ia, new_dims, rm2)) { - k = 0; - for (i = 0; i < rm1; ++i) { - k += ia[i] * new_strides[i]; - } - for (i = 0; i < dims_axis; ++i) { - *(dest + j++) = *(src + k + i * strides_axis); - } + + ia[rm2] = -1; + j = 0; + if (unflat) { + while (next_comb(ia, new_dims, rm2)) { + k = 0; + for (i = 0; i < rm1; ++i) { + k += ia[i] * new_strides[i]; + } + for (i = 0; i < dims_axis; ++i) { + *(dest + k + i * strides_axis) = *(src + j++); + } + } + } else { + while (next_comb(ia, new_dims, rm2)) { + k = 0; + for (i = 0; i < rm1; ++i) { + k += ia[i] * new_strides[i]; + } + for (i = 0; i < dims_axis; ++i) { + *(dest + j++) = *(src + k + i * strides_axis); + } + } } - } } -extern "C" { -extern void zfft(complex_double * inout, - int n, int direction, int howmany, int normalize); -}; - extern void zfftnd_fftpack(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) { - int i, sz; - complex_double *ptr = inout; - int axis; - complex_double *tmp; - int *itmp; - int k, j; + int i, sz; + complex_double *ptr = inout; + NDFFTPackCache* cache; - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - zfft(ptr, dims[rank - 1], direction, howmany * sz / dims[rank - 1], - normalize); + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } - i = get_cache_id_zfftnd_fftpack(sz, rank); - tmp = caches_zfftnd_fftpack[i].ptr; - itmp = caches_zfftnd_fftpack[i].iptr; + cache = ndfftpack_cmgr.get_cache(NDFFTPackCacheId(sz, rank)); + cache->compute(ptr, sz, dims, direction, normalize, howmany); - itmp[rank - 1] = 1; - for (i = 2; i <= rank; ++i) { - itmp[rank - i] = itmp[rank - i + 1] * dims[rank - i + 1]; - } - - for (i = 0; i < howmany; ++i, ptr += sz) { - for (axis = 0; axis < rank - 1; ++axis) { - for (k = j = 0; k < rank; ++k) { - if (k != axis) { - *(itmp + rank + j) = itmp[k]; - *(itmp + 2 * rank + j++) = dims[k] - 1; - } - } - flatten(tmp, ptr, rank, itmp[axis], dims[axis], 0, itmp); - zfft(tmp, dims[axis], direction, sz / dims[axis], normalize); - flatten(ptr, tmp, rank, itmp[axis], dims[axis], 1, itmp); - } - } - } From scipy-svn at scipy.org Sun May 11 08:50:05 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 07:50:05 -0500 (CDT) Subject: [Scipy-svn] r4270 - branches/refactor_fft/scipy/fftpack/src/fftpack Message-ID: <20080511125005.5EE1F39C064@scipy.org> Author: cdavid Date: 2008-05-11 07:50:00 -0500 (Sun, 11 May 2008) New Revision: 4270 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx Log: Remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-11 12:49:09 UTC (rev 4269) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) @@ -1,5 +1,5 @@ /* - * Last Change: Sun May 11 08:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J * * FFTPACK implementation * @@ -75,17 +75,6 @@ static CacheManager rfftpack_cmgr(10); -#if 0 -GEN_CACHE(drfftpack, (int n) - , double *wsave; - , (caches_drfftpack[i].n == n) - , caches_drfftpack[id].wsave = - (double *) malloc(sizeof(double) * (2 * n + 15)); - F_FUNC(dffti, DFFTI) (&n, caches_drfftpack[id].wsave); - , free(caches_drfftpack[id].wsave); - , 10) -#endif - /* * Stub to make GEN_PUBLIC_API api */ Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-11 12:49:09 UTC (rev 4269) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-11 12:50:00 UTC (rev 4270) @@ -136,27 +136,11 @@ static CacheManager ndfftpack_cmgr(10); -#if 0 /* stub to make PUBLIC_GEN_API happy */ static void destroy_zfftnd_fftpack_caches() { } -#endif -GEN_CACHE(zfftnd_fftpack, (int n, int rank) - , complex_double * ptr; int *iptr; int rank; - , ((caches_zfftnd_fftpack[i].n == n) - && (caches_zfftnd_fftpack[i].rank == rank)) - , caches_zfftnd_fftpack[id].n = n; - caches_zfftnd_fftpack[id].ptr = - (complex_double *) malloc(2 * sizeof(double) * n); - caches_zfftnd_fftpack[id].iptr = - (int *) malloc(4 * rank * sizeof(int)); - , - free(caches_zfftnd_fftpack[id].ptr); - free(caches_zfftnd_fftpack[id].iptr); - , 10) - static /*inline : disabled because MSVC6.0 fails to compile it. */ int next_comb(int *ia, int *da, int m) From scipy-svn at scipy.org Sun May 11 09:06:00 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 08:06:00 -0500 (CDT) Subject: [Scipy-svn] r4271 - in branches/refactor_fft/scipy/fftpack: . src src/djbfft src/fftpack src/fftw src/fftw3 src/mkl Message-ID: <20080511130600.9227839C12A@scipy.org> Author: cdavid Date: 2008-05-11 08:05:41 -0500 (Sun, 11 May 2008) New Revision: 4271 Modified: branches/refactor_fft/scipy/fftpack/basic.py branches/refactor_fft/scipy/fftpack/fftpack.pyf branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx branches/refactor_fft/scipy/fftpack/src/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Log: remove destroy cache stub for fftpack (all backends). Modified: branches/refactor_fft/scipy/fftpack/basic.py =================================================================== --- branches/refactor_fft/scipy/fftpack/basic.py 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/basic.py 2008-05-11 13:05:41 UTC (rev 4271) @@ -12,12 +12,6 @@ import numpy import _fftpack as fftpack -import atexit -atexit.register(fftpack.destroy_zfft_cache) -atexit.register(fftpack.destroy_zfftnd_cache) -atexit.register(fftpack.destroy_drfft_cache) -del atexit - def istype(arr, typeclass): return issubclass(arr.dtype.type, typeclass) Modified: branches/refactor_fft/scipy/fftpack/fftpack.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-11 13:05:41 UTC (rev 4271) @@ -71,18 +71,6 @@ } end subroutine zfftnd - subroutine destroy_zfft_cache() - intent(c) destroy_zfft_cache - end subroutine destroy_zfft_cache - - subroutine destroy_zfftnd_cache() - intent(c) destroy_zfftnd_cache - end subroutine destroy_zfftnd_cache - - subroutine destroy_drfft_cache() - intent(c) destroy_drfft_cache - end subroutine destroy_drfft_cache - end interface end python module _fftpack Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -1,13 +1,13 @@ /* - * Last Change: Sun May 11 08:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J * * Original code by Pearu Peterson. */ + /* * RDJBFFT only implements size 2^N ! * - * drfft_def and drfft_def_destroy_cache are the functions used for size different - * than 2^N + * drfft_def is the functions used for size different * than 2^N */ #include #include @@ -16,13 +16,10 @@ #ifdef WITH_FFTW3 #define drfft_def drfft_fftw3 -#define drfft_def_destroy_cache destroy_drfftw3_caches #elif defined WITH_FFTW #define drfft_def drfft_fftw -#define drfft_def_destroy_cache destroy_drfftw_caches #else #define drfft_def drfft_fftpack -#define drfft_def_destroy_cache destroy_drfftpack_caches #endif using namespace fft; @@ -126,11 +123,6 @@ static CacheManager rdjbfft_cmgr(10); -/* Stub to make GEN_PUBLIC_API happy */ -static void destroy_drdjbfft_caches() -{ -} - /**************** ZFFT function **********************/ static void drfft_djbfft(double * inout, int n, int direction, int howmany, int normalize) Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -1,24 +1,19 @@ /* * DJBFFT only implements size 2^N ! * -* zfft_def and zfft_def_destroy_cache are the functions -* used for size different than 2^N +* zfft_def is the function * used for size different than 2^N */ #include "common.h" #ifdef WITH_FFTWORK #define zfft_def zfft_fftwork -#define zfft_def_destroy_cache destroy_zfftwork_cache #elif defined WITH_FFTW3 #define zfft_def zfft_fftw3 -#define zfft_def_destroy_cache destroy_zfftw3_caches #elif defined WITH_FFTW #define zfft_def zfft_fftw -#define zfft_def_destroy_cache destroy_zfftw_caches #else #define zfft_def zfft_fftpack -#define zfft_def_destroy_cache destroy_zfftpack_caches #endif class DJBFFTCache: public Cache { @@ -166,11 +161,6 @@ static CacheManager djbfft_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zdjbfft_caches() -{ -} - /**************** ZFFT function **********************/ static void zfft_djbfft(complex_double * inout, int n, int direction, int howmany, int normalize) Modified: branches/refactor_fft/scipy/fftpack/src/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -9,11 +9,6 @@ /* The following macro convert private backend specific function to the public * functions exported by the module */ #define GEN_PUBLIC_API(name) \ -extern "C" void destroy_drfft_cache(void)\ -{\ - destroy_dr##name##_caches();\ -}\ -\ extern "C" void drfft(double *inout, int n, \ int direction, int howmany, int normalize)\ {\ @@ -58,11 +53,6 @@ */ #ifdef WITH_DJBFFT #include "djbfft/drfft.cxx" - extern "C" void destroy_drfft_cache(void) - { - destroy_drdjbfft_caches(); - drfft_def_destroy_cache(); - } extern "C" void drfft(double *inout, int n, int direction, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -75,13 +75,6 @@ static CacheManager rfftpack_cmgr(10); -/* - * Stub to make GEN_PUBLIC_API api - */ -static void destroy_drfftpack_caches() -{ -} - static void drfft_fftpack(double *inout, int n, int direction, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -68,10 +68,6 @@ static CacheManager fftpack_cmgr(10); -void destroy_zfftpack_caches() -{ -} - static void zfft_fftpack(complex_double * inout, int n, int direction, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -136,11 +136,6 @@ static CacheManager ndfftpack_cmgr(10); -/* stub to make PUBLIC_GEN_API happy */ -static void destroy_zfftnd_fftpack_caches() -{ -} - static /*inline : disabled because MSVC6.0 fails to compile it. */ int next_comb(int *ia, int *da, int m) Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -1,5 +1,5 @@ /* - * Last Change: Sun May 11 07:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J * * FFTW2 implementation * @@ -101,11 +101,6 @@ CacheManager rfftw_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_drfftw_caches() -{ -} - static void drfft_fftw(double *inout, int n, int dir, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -64,11 +64,6 @@ CacheManager fftw_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zfftw_caches() -{ -} - extern void zfft_fftw(complex_double * inout, int n, int dir, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -3,7 +3,7 @@ * * Original code by Pearu Peaterson * - * Last Change: Sun May 11 07:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J */ #include #include @@ -146,11 +146,6 @@ static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zfftnd_fftw_caches() -{ -} - extern void zfftnd_fftw(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -1,5 +1,5 @@ /* - * Last Change: Sun May 11 05:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J * * RFFTW3 implementation * @@ -88,11 +88,6 @@ static CacheManager fftw3_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_drfftw3_caches() -{ -} - static void drfft_fftw3(double *inout, int n, int direction, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -62,11 +62,6 @@ static CacheManager fftw3_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zfftw3_caches() -{ -} - static void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -3,7 +3,7 @@ * * Original code by Pearu Peaterson * - * Last Change: Sun May 11 06:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J */ #include #include @@ -103,11 +103,6 @@ return res; } -/* stub because fftw3 has no cache mechanism (yet) */ -static void destroy_zfftnd_fftw3_caches(void) -{ -} - class NDFFTW3Cache:public Cache < NDFFTW3CacheId > { public: NDFFTW3Cache(const NDFFTW3CacheId & id); Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -52,10 +52,6 @@ CacheManager mkl_cmgr(10); -void destroy_zmkl_caches() -{ -} - static void zfft_mkl(complex_double * inout, int n, int direction, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -3,7 +3,7 @@ * * Original code by David M. Cooke * - * Last Change: Sun May 11 07:00 PM 2008 J + * Last Change: Sun May 11 09:00 PM 2008 J */ #include @@ -157,11 +157,6 @@ static CacheManager < NDMKLCacheId, NDMKLCache > mkl_cmgr(10); -/* stub to make GEN_PUBLIC_API happy */ -static void destroy_zfftnd_mkl_caches() -{ -} - extern void zfftnd_mkl(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) Modified: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -9,11 +9,6 @@ /* The following macro convert private backend specific function to the public * functions exported by the module */ #define GEN_PUBLIC_API(name) \ -extern "C" void destroy_zfft_cache(void)\ -{\ - destroy_z##name##_caches();\ -}\ -\ extern "C" void zfft(complex_double *inout, int n, \ int direction, int howmany, int normalize)\ {\ @@ -22,19 +17,6 @@ /* ************** Definition of backend specific functions ********* */ -/* - * To add a backend : - * - create a file zfft_name.c, where you define a function zfft_name where - * name is the name of your backend. If you do not use the GEN_CACHE macro, - * you will need to define a function void destroy_zname_caches(void), - * which can do nothing - * - in zfft.c, include the zfft_name.c file, and add the 3 following lines - * just after it: - * #ifndef WITH_DJBFFT - * GEN_PUBLIC_API(name) - * #endif - */ - #ifdef WITH_FFTW3 #include "fftw3/zfft.cxx" #ifndef WITH_DJBFFT @@ -63,11 +45,6 @@ */ #ifdef WITH_DJBFFT #include "djbfft/zfft.cxx" - extern "C" void destroy_zfft_cache(void) - { - destroy_zdjbfft_caches(); - zfft_def_destroy_cache(); - } extern "C" void zfft(complex_double *inout, int n, int direction, int howmany, int normalize) { Modified: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-11 12:50:00 UTC (rev 4270) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-11 13:05:41 UTC (rev 4271) @@ -8,11 +8,6 @@ /* The following macro convert private backend specific function to the public * functions exported by the module */ #define GEN_PUBLIC_API(name) \ -extern "C" void destroy_zfftnd_cache(void)\ -{\ - destroy_zfftnd_##name##_caches();\ -}\ -\ extern "C" void zfftnd(complex_double * inout, int rank,\ int *dims, int direction, int howmany, int normalize)\ {\ @@ -20,26 +15,28 @@ } #if defined(WITH_FFTW) || defined(WITH_MKL) -static -int equal_dims(int rank,int *dims1,int *dims2) { - int i; - for (i=0;i Author: cdavid Date: 2008-05-11 08:32:48 -0500 (Sun, 11 May 2008) New Revision: 4272 Added: branches/refactor_fft/scipy/fftpack/src/convolve.cxx Removed: branches/refactor_fft/scipy/fftpack/src/convolve.c Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Make convolve implementation a C++ source file. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-11 13:05:41 UTC (rev 4271) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-11 13:32:48 UTC (rev 4272) @@ -42,7 +42,7 @@ ) config.add_extension('convolve', - sources=['convolve.pyf','src/convolve.c'], + sources=['convolve.pyf','src/convolve.cxx'], libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], ) Deleted: branches/refactor_fft/scipy/fftpack/src/convolve.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.c 2008-05-11 13:05:41 UTC (rev 4271) +++ branches/refactor_fft/scipy/fftpack/src/convolve.c 2008-05-11 13:32:48 UTC (rev 4272) @@ -1,377 +0,0 @@ -/* - Generic functions for computing 1D convolutions of periodic sequences. - - Supported FFT libraries: - DJBFFT - optional, used for power-of-two length arrays - FFTW - optional - FFTPACK - used if any of the above libraries is not available - - Author: Pearu Peterson, September 2002 - */ - -#include "fftpack.h" - -/**************** DJBFFT *****************************/ -#ifdef WITH_DJBFFT -GEN_CACHE(ddjbfft,(int n) - ,double* ptr; - ,(caches_ddjbfft[i].n==n) - ,caches_ddjbfft[id].ptr = (double*)malloc(sizeof(double)*n); - ,free(caches_ddjbfft[id].ptr); - ,20) -#endif - -/**************** FFTW *****************************/ -#ifdef WITH_FFTW -GEN_CACHE(drfftw,(int n) - ,rfftw_plan plan1; - rfftw_plan plan2; - ,(caches_drfftw[i].n==n) - ,caches_drfftw[id].plan1 = rfftw_create_plan(n, - FFTW_REAL_TO_COMPLEX, - FFTW_IN_PLACE|FFTW_ESTIMATE); - caches_drfftw[id].plan2 = rfftw_create_plan(n, - FFTW_COMPLEX_TO_REAL, - FFTW_IN_PLACE|FFTW_ESTIMATE); - ,rfftw_destroy_plan(caches_drfftw[id].plan1); - rfftw_destroy_plan(caches_drfftw[id].plan2); - ,20) -#else -/**************** FFTPACK ZFFT **********************/ -extern void F_FUNC(dfftf,DFFTF)(int*,double*,double*); -extern void F_FUNC(dfftb,DFFTB)(int*,double*,double*); -extern void F_FUNC(dffti,DFFTI)(int*,double*); -GEN_CACHE(dfftpack,(int n) - ,double* wsave; - ,(caches_dfftpack[i].n==n) - ,caches_dfftpack[id].wsave = (double*)malloc(sizeof(double)*(2*n+15)); - F_FUNC(dffti,DFFTI)(&n,caches_dfftpack[id].wsave); - ,free(caches_dfftpack[id].wsave); - ,20) -#endif -extern void destroy_convolve_cache(void) { -#ifdef WITH_DJBFFT - destroy_ddjbfft_caches(); -#endif -#ifdef WITH_FFTW - destroy_drfftw_caches(); -#else - destroy_dfftpack_caches(); -#endif -} - -/**************** convolve **********************/ -extern -void convolve(int n,double* inout,double* omega,int swap_real_imag) { - int i; -#ifdef WITH_DJBFFT - double* ptr = NULL; -#endif -#ifdef WITH_FFTW - rfftw_plan plan1 = NULL; - rfftw_plan plan2 = NULL; -#else - double* wsave = NULL; -#endif -#ifdef WITH_DJBFFT - switch (n) { - case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; - case 512:;case 1024:;case 2048:;case 4096:;case 8192: - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; - COPYSTD2DJB(inout,ptr,n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2);TMPCASE(4);TMPCASE(8);TMPCASE(16);TMPCASE(32); - TMPCASE(64);TMPCASE(128);TMPCASE(256);TMPCASE(512); - TMPCASE(1024);TMPCASE(2048);TMPCASE(4096);TMPCASE(8192); -#undef TMPCASE - } - if (swap_real_imag) { - int n1 = n-1; - double c; - ptr[0] *= omega[0]; - ptr[1] *= omega[1]; - for(i=2;in2) f[k] -= n; - omega[0] = (*kernel_func)(0)/n; - switch (d%4) { - case 0: - for (k=2;kn2) f[k] -= n; + omega[0] = (*kernel_func)(0)/n; + switch (d%4) { + case 0: + for (k=2;k Author: cdavid Date: 2008-05-11 10:09:15 -0500 (Sun, 11 May 2008) New Revision: 4273 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Use C linkage if cpluscplus. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-11 13:32:48 UTC (rev 4272) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-11 15:09:15 UTC (rev 4273) @@ -13,13 +13,17 @@ typedef struct {double r,i;} complex_double; typedef struct {float r,i;} complex_float; +#ifdef __cplusplus extern "C" { +#endif void init_convolution_kernel(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist); void convolve(int n,double* inout,double* omega,int swap_real_imag); void convolve_z(int n,double* inout,double* omega_real,double* omega_imag); +#ifdef __cplusplus }; +#endif extern int ispow2le2e30(int n); extern int ispow2le2e13(int n); From scipy-svn at scipy.org Sun May 11 11:38:10 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 May 2008 10:38:10 -0500 (CDT) Subject: [Scipy-svn] r4274 - in branches/refactor_fft/scipy/fftpack/src: . fftpack Message-ID: <20080511153810.B615A39C194@scipy.org> Author: cdavid Date: 2008-05-11 10:38:04 -0500 (Sun, 11 May 2008) New Revision: 4274 Added: branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx Log: Put fftpack backend for convolve in separate file. Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-11 15:09:15 UTC (rev 4273) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-11 15:38:04 UTC (rev 4274) @@ -52,14 +52,31 @@ }; #endif +#ifdef WITH_FFTPACK +void destroy_convolve_cache(void) +{ + destroy_dfftpack_cache_fftpack(); +} + +void convolve(int n,double* inout,double* omega,int swap_real_imag) +{ + convolve(n, inout, omega, swap_real_imag); +} + +void convolve_z(int n,double* inout,double* omega,int swap_real_imag) +{ + convolve_z_fftpack(n, inout, omage_real, omega_imag); +} + +#include "src/convolve.cxx" +#endif + extern "C" void destroy_convolve_cache(void) { #ifdef WITH_DJBFFT destroy_ddjbfft_caches(); #endif #ifdef WITH_FFTW destroy_drfftw_caches(); -#else - destroy_dfftpack_caches(); #endif } @@ -137,28 +154,8 @@ for(i=0;i Author: cdavid Date: 2008-05-11 11:50:05 -0500 (Sun, 11 May 2008) New Revision: 4275 Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx Log: Fix fftpack backend for convolve. Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-11 15:38:04 UTC (rev 4274) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-11 16:50:05 UTC (rev 4275) @@ -38,39 +38,34 @@ ,20) #else /**************** FFTPACK ZFFT **********************/ -extern "C" { -extern void F_FUNC(dfftf,DFFTF)(int*,double*,double*); -extern void F_FUNC(dfftb,DFFTB)(int*,double*,double*); -extern void F_FUNC(dffti,DFFTI)(int*,double*); -GEN_CACHE(dfftpack,(int n) - ,double* wsave; - ,(caches_dfftpack[i].n==n) - ,caches_dfftpack[id].wsave = (double*)malloc(sizeof(double)*(2*n+15)); - F_FUNC(dffti,DFFTI)(&n,caches_dfftpack[id].wsave); - ,free(caches_dfftpack[id].wsave); - ,20) -}; -#endif +#include "fftpack/convolve.cxx" -#ifdef WITH_FFTPACK -void destroy_convolve_cache(void) +extern "C" void destroy_convolve_cache(void) { - destroy_dfftpack_cache_fftpack(); + destroy_convolve_cache_fftpack(); } -void convolve(int n,double* inout,double* omega,int swap_real_imag) +extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) { - convolve(n, inout, omega, swap_real_imag); + convolve_fftpack(n, inout, omega, swap_real_imag); } -void convolve_z(int n,double* inout,double* omega,int swap_real_imag) +extern "C" void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) { - convolve_z_fftpack(n, inout, omage_real, omega_imag); + convolve_z_fftpack(n, inout, omega_real, omega_imag); } -#include "src/convolve.cxx" +extern "C" void init_convolution_kernel(int n,double* omega, int d, + double (*kernel_func)(int), + int zero_nyquist) +{ + init_convolution_kernel_fftpack(n, omega, d, kernel_func, zero_nyquist); +} + #endif +#if (defined WITH_DJBFFT) | (defined WITH_FFTW) + extern "C" void destroy_convolve_cache(void) { #ifdef WITH_DJBFFT destroy_ddjbfft_caches(); @@ -83,15 +78,12 @@ /**************** convolve **********************/ extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) { - int i; #ifdef WITH_DJBFFT double* ptr = NULL; #endif #ifdef WITH_FFTW rfftw_plan plan1 = NULL; rfftw_plan plan2 = NULL; -#else - double* wsave = NULL; #endif #ifdef WITH_DJBFFT switch (n) { @@ -154,22 +146,19 @@ for(i=0;i Author: cdavid Date: 2008-05-12 07:59:22 -0500 (Mon, 12 May 2008) New Revision: 4276 Added: branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/convolve.cxx Log: fftw backend for convolve now in separate file. From scipy-svn at scipy.org Mon May 12 09:02:43 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:02:43 -0500 (CDT) Subject: [Scipy-svn] r4277 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080512130243.2FDA739C198@scipy.org> Author: cdavid Date: 2008-05-12 08:02:36 -0500 (Mon, 12 May 2008) New Revision: 4277 Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/convolve.cxx Log: djbfft + fftw backend for convolve works again. From scipy-svn at scipy.org Mon May 12 09:03:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:03:36 -0500 (CDT) Subject: [Scipy-svn] r4278 - in branches/refactor_fft/scipy/fftpack/src: . djbfft Message-ID: <20080512130336.E5DB039C198@scipy.org> Author: cdavid Date: 2008-05-12 08:03:31 -0500 (Mon, 12 May 2008) New Revision: 4278 Added: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx Log: Put djbfft implementation of convolve in separate file. Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-12 13:02:36 UTC (rev 4277) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-12 13:03:31 UTC (rev 4278) @@ -11,16 +11,6 @@ #include "fftpack.h" -/**************** DJBFFT *****************************/ -#ifdef WITH_DJBFFT -GEN_CACHE(ddjbfft,(int n) - ,double* ptr; - ,(caches_ddjbfft[i].n==n) - ,caches_ddjbfft[id].ptr = (double*)malloc(sizeof(double)*n); - ,free(caches_ddjbfft[id].ptr); - ,20) -#endif - /**************** FFTW *****************************/ #ifdef WITH_FFTW #include "fftw/convolve.cxx" @@ -80,333 +70,5 @@ #endif #ifdef WITH_DJBFFT - -extern "C" void destroy_convolve_cache(void) { -#ifdef WITH_DJBFFT - destroy_ddjbfft_caches(); + #include "djbfft/convolve.cxx" #endif -#ifdef WITH_FFTW - destroy_drfftw_caches(); -#else - destroy_dfftpack_caches(); -#endif -} - -/**************** convolve **********************/ -extern "C" -void convolve(int n,double* inout,double* omega,int swap_real_imag) { - int i; -#ifdef WITH_DJBFFT - double* ptr = NULL; -#endif -#ifdef WITH_FFTW - rfftw_plan plan1 = NULL; - rfftw_plan plan2 = NULL; -#else - double* wsave = NULL; -#endif -#ifdef WITH_DJBFFT - switch (n) { - case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; - case 512:;case 1024:;case 2048:;case 4096:;case 8192: - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; - COPYSTD2DJB(inout,ptr,n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2);TMPCASE(4);TMPCASE(8);TMPCASE(16);TMPCASE(32); - TMPCASE(64);TMPCASE(128);TMPCASE(256);TMPCASE(512); - TMPCASE(1024);TMPCASE(2048);TMPCASE(4096);TMPCASE(8192); -#undef TMPCASE - } - if (swap_real_imag) { - int n1 = n-1; - double c; - ptr[0] *= omega[0]; - ptr[1] *= omega[1]; - for(i=2;in2) f[k] -= n; - omega[0] = (*kernel_func)(0)/n; - switch (d%4) { - case 0: - for (k=2;kn2) f[k] -= n; + omega[0] = (*kernel_func)(0)/n; + switch (d%4) { + case 0: + for (k=2;k Author: cdavid Date: 2008-05-12 08:04:21 -0500 (Mon, 12 May 2008) New Revision: 4279 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: Put djbfft implementation of convolve in separate file. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:03:31 UTC (rev 4278) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:04:21 UTC (rev 4279) @@ -1,3 +1,15 @@ +#ifdef WITH_FFTW +#define destroy_convolve_cache_def destroy_convolve_cache_fftw +#define convolve_def convolve_fftw +#define convolve_z_def convolve_z_fftw +#define init_convolution_kernel_def init_convolution_kernel_fftw +#else +#define destroy_convolve_cache_def destroy_convolve_cache_fftpack +#define convolve_def convolve_fftpack +#define convolve_z_def convolve_z_fftpack +#define init_convolution_kernel_def init_convolution_kernel_fftpack +#endif + GEN_CACHE(ddjbfft,(int n) ,double* ptr; ,(caches_ddjbfft[i].n==n) @@ -5,15 +17,10 @@ ,free(caches_ddjbfft[id].ptr); ,20) -extern "C" void destroy_convolve_cache(void) { -#ifdef WITH_DJBFFT - destroy_ddjbfft_caches(); -#endif -#ifdef WITH_FFTW - destroy_drfftw_caches(); -#else - destroy_dfftpack_caches(); -#endif +extern "C" void destroy_convolve_cache(void) +{ + destroy_ddjbfft_caches(); + destroy_convolve_cache_def(); } /**************** convolve **********************/ @@ -23,12 +30,6 @@ #ifdef WITH_DJBFFT double* ptr = NULL; #endif -#ifdef WITH_FFTW - rfftw_plan plan1 = NULL; - rfftw_plan plan2 = NULL; -#else - double* wsave = NULL; -#endif #ifdef WITH_DJBFFT switch (n) { case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; @@ -70,27 +71,12 @@ #endif { #ifdef WITH_FFTW - int l = (n-1)/2+1; - i = get_cache_id_drfftw(n); - plan1 = caches_drfftw[i].plan1; - plan2 = caches_drfftw[i].plan2; - rfftw_one(plan1, (fftw_real *)inout, NULL); - if (swap_real_imag) { - double c; - inout[0] *= omega[0]; - if (!(n%2)) - inout[n/2] *= omega[n/2]; - for(i=1;i Author: cdavid Date: 2008-05-12 08:06:30 -0500 (Mon, 12 May 2008) New Revision: 4280 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: Avoid duplicate code for convolve when djbftt + fftpack backends are used. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:04:21 UTC (rev 4279) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:06:30 UTC (rev 4280) @@ -70,33 +70,7 @@ } #endif { -#ifdef WITH_FFTW -#else - double* wsave = NULL; -#endif -#ifdef WITH_FFTW convolve_def(n,inout,omega,swap_real_imag); -#else - i = get_cache_id_dfftpack(n); - wsave = caches_dfftpack[i].wsave; - F_FUNC(dfftf,DFFTF)(&n,inout,wsave); - if (swap_real_imag) { - double c; - int n1 = n-1; - inout[0] *= omega[0]; - if (!(n%2)) - inout[n-1] *= omega[n-1]; - for(i=1;i Author: cdavid Date: 2008-05-12 08:06:56 -0500 (Mon, 12 May 2008) New Revision: 4281 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: Remove WITH_DJBFFT in djbfft backend. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:06:30 UTC (rev 4280) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:06:56 UTC (rev 4281) @@ -25,12 +25,10 @@ /**************** convolve **********************/ extern "C" -void convolve(int n,double* inout,double* omega,int swap_real_imag) { +void convolve(int n,double* inout,double* omega,int swap_real_imag) +{ int i; -#ifdef WITH_DJBFFT double* ptr = NULL; -#endif -#ifdef WITH_DJBFFT switch (n) { case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; case 512:;case 1024:;case 2048:;case 4096:;case 8192: @@ -68,7 +66,6 @@ COPYINVDJB2STD2(ptr,inout,n); return; } -#endif { convolve_def(n,inout,omega,swap_real_imag); } @@ -78,10 +75,7 @@ extern "C" void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) { int i; -#ifdef WITH_DJBFFT double* ptr = NULL; -#endif -#ifdef WITH_DJBFFT switch (n) { case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; case 512:;case 1024:;case 2048:;case 4096:;case 8192: @@ -118,7 +112,6 @@ COPYINVDJB2STD2(ptr,inout,n); return; } -#endif { convolve_z_def(n,inout,omega_real,omega_imag); } @@ -133,7 +126,6 @@ omega[0] = kernel_func(0) conjugate(omega[-k]) == omega[k] */ -#ifdef WITH_DJBFFT switch (n) { case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; case 512:;case 1024:;case 2048:;case 4096:;case 8192: @@ -174,6 +166,5 @@ } return; } -#endif init_convolution_kernel_def(n,omega, d, kernel_func, zero_nyquist); } From scipy-svn at scipy.org Mon May 12 09:07:31 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:07:31 -0500 (CDT) Subject: [Scipy-svn] r4282 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512130731.DDE6739C198@scipy.org> Author: cdavid Date: 2008-05-12 08:07:26 -0500 (Mon, 12 May 2008) New Revision: 4282 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: Fix indentation for djbfft backend for convolve. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:06:56 UTC (rev 4281) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:07:26 UTC (rev 4282) @@ -10,14 +10,13 @@ #define init_convolution_kernel_def init_convolution_kernel_fftpack #endif -GEN_CACHE(ddjbfft,(int n) - ,double* ptr; - ,(caches_ddjbfft[i].n==n) - ,caches_ddjbfft[id].ptr = (double*)malloc(sizeof(double)*n); - ,free(caches_ddjbfft[id].ptr); - ,20) +GEN_CACHE(ddjbfft, (int n) + , double *ptr;, (caches_ddjbfft[i].n == n) + , caches_ddjbfft[id].ptr = + (double *) malloc(sizeof(double) * n);, + free(caches_ddjbfft[id].ptr);, 20) -extern "C" void destroy_convolve_cache(void) +extern "C" void destroy_convolve_cache(void) { destroy_ddjbfft_caches(); destroy_convolve_cache_def(); @@ -25,146 +24,239 @@ /**************** convolve **********************/ extern "C" -void convolve(int n,double* inout,double* omega,int swap_real_imag) + void convolve(int n, double *inout, double *omega, int swap_real_imag) { - int i; - double* ptr = NULL; - switch (n) { - case 2:;case 4:;case 8:;case 16:;case 32:;case 64:;case 128:;case 256:; - case 512:;case 1024:;case 2048:;case 4096:;case 8192: - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; - COPYSTD2DJB(inout,ptr,n); - switch (n) { + int i; + double *ptr = NULL; + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + i = get_cache_id_ddjbfft(n); + ptr = caches_ddjbfft[i].ptr; + COPYSTD2DJB(inout, ptr, n); + switch (n) { #define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2);TMPCASE(4);TMPCASE(8);TMPCASE(16);TMPCASE(32); - TMPCASE(64);TMPCASE(128);TMPCASE(256);TMPCASE(512); - TMPCASE(1024);TMPCASE(2048);TMPCASE(4096);TMPCASE(8192); + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE - } - if (swap_real_imag) { - int n1 = n-1; - double c; - ptr[0] *= omega[0]; - ptr[1] *= omega[1]; - for(i=2;in2) f[k] -= n; - omega[0] = (*kernel_func)(0)/n; - switch (d%4) { - case 0: - for (k=2;k n2) + f[k] -= n; + omega[0] = (*kernel_func) (0) / n; + switch (d % 4) { + case 0: + for (k = 2; k < n - 1; k += 2) { + omega[k] = + (*kernel_func) (f[k]) / n2; + omega[k + 1] = -omega[k]; + } + omega[1] = + (zero_nyquist ? 0.0 + : (*kernel_func) (n2) / n); + break; + case 1:; + case -3: + for (k = 2; k < n - 1; k += 2) + omega[k] = omega[k + 1] = + -(*kernel_func) (f[k]) / n2; + omega[1] = + (zero_nyquist ? 0.0 + : (*kernel_func) (n2) / n); + break; + case 2:; + case -2: + for (k = 2; k < n - 1; k += 2) { + omega[k] = + -(*kernel_func) (f[k]) / n2; + omega[k + 1] = -omega[k]; + } + omega[1] = + (zero_nyquist ? 0.0 : + -(*kernel_func) (n2) / n); + break; + case 3:; + case -1: + for (k = 2; k < n - 1; k += 2) + omega[k] = omega[k + 1] = + (*kernel_func) (f[k]) / n2; + omega[1] = + (zero_nyquist ? 0.0 : + -(*kernel_func) (n2) / n); + break; + } + free(f); + } + return; } - omega[1] = (zero_nyquist?0.0:(*kernel_func)(n2)/n); - break; - case 1:;case -3: - for (k=2;k Author: cdavid Date: 2008-05-12 08:08:07 -0500 (Mon, 12 May 2008) New Revision: 4283 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: More cleanup for djbfft backend for convolve. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:07:26 UTC (rev 4282) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:08:07 UTC (rev 4283) @@ -23,12 +23,72 @@ } /**************** convolve **********************/ -extern "C" - void convolve(int n, double *inout, double *omega, int swap_real_imag) +static void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) { int i; double *ptr = NULL; + + i = get_cache_id_ddjbfft(n); + ptr = caches_ddjbfft[i].ptr; + COPYSTD2DJB(inout, ptr, n); switch (n) { +#define TMPCASE(N) case N: fftr8_##N(ptr); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + if (swap_real_imag) { + int n1 = n - 1; + double c; + ptr[0] *= omega[0]; + ptr[1] *= omega[1]; + for (i = 2; i < n1; i += 2) { + c = ptr[i] * omega[i]; + ptr[i] = ptr[i + 1] * omega[i + 1]; + ptr[i + 1] = c; + } + } else { + for (i = 0; i < n; ++i) { + ptr[i] *= omega[i]; + } + } + switch (n) { +#define TMPCASE(N)case N:fftr8_un##N(ptr);break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + COPYINVDJB2STD2(ptr, inout, n); +} + +extern "C" +void convolve(int n, double *inout, double *omega, int swap_real_imag) +{ + bool use_def = true; + + switch (n) { case 2:; case 4:; case 8:; @@ -42,71 +102,83 @@ case 2048:; case 4096:; case 8192: - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; - COPYSTD2DJB(inout, ptr, n); - switch (n) { + use_def = false; + } + + if (!use_def) { + convolve_djbfft(n, inout, omega, swap_real_imag); + } else { + convolve_def(n, inout, omega, swap_real_imag); + } +} + +/**************** convolve **********************/ +static void convolve_z_djbfft(int n, double *inout, double *omega_real, + double *omega_imag) +{ + int i; + double *ptr = NULL; + + i = get_cache_id_ddjbfft(n); + ptr = caches_ddjbfft[i].ptr; + COPYSTD2DJB(inout, ptr, n); + switch (n) { #define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE + } + { + int n1 = n - 1; + double c; + ptr[0] *= (omega_real[0] + omega_imag[0]); + ptr[1] *= (omega_real[1] + omega_imag[1]); + for (i = 2; i < n1; i += 2) { + c = ptr[i] * omega_imag[i]; + ptr[i] *= omega_real[i]; + ptr[i] += ptr[i + 1] * omega_imag[i + 1]; + ptr[i + 1] *= omega_real[i + 1]; + ptr[i + 1] += c; } - if (swap_real_imag) { - int n1 = n - 1; - double c; - ptr[0] *= omega[0]; - ptr[1] *= omega[1]; - for (i = 2; i < n1; i += 2) { - c = ptr[i] * omega[i]; - ptr[i] = ptr[i + 1] * omega[i + 1]; - ptr[i + 1] = c; - } - } else - for (i = 0; i < n; ++i) - ptr[i] *= omega[i]; - switch (n) { + } + switch (n) { #define TMPCASE(N)case N:fftr8_un##N(ptr);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE - } - COPYINVDJB2STD2(ptr, inout, n); - return; } - { - convolve_def(n, inout, omega, swap_real_imag); - } + COPYINVDJB2STD2(ptr, inout, n); + return; } -/**************** convolve **********************/ extern "C" void convolve_z(int n, double *inout, double *omega_real, double *omega_imag) { - int i; - double *ptr = NULL; + bool use_def = true; + switch (n) { case 2:; case 4:; @@ -121,69 +193,79 @@ case 2048:; case 4096:; case 8192: - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; - COPYSTD2DJB(inout, ptr, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - { - int n1 = n - 1; - double c; - ptr[0] *= (omega_real[0] + omega_imag[0]); - ptr[1] *= (omega_real[1] + omega_imag[1]); - for (i = 2; i < n1; i += 2) { - c = ptr[i] * omega_imag[i]; - ptr[i] *= omega_real[i]; - ptr[i] += ptr[i + 1] * omega_imag[i + 1]; - ptr[i + 1] *= omega_real[i + 1]; - ptr[i + 1] += c; - } - } - switch (n) { -#define TMPCASE(N)case N:fftr8_un##N(ptr);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYINVDJB2STD2(ptr, inout, n); - return; + use_def = false; } - { + + if (use_def) { convolve_z_def(n, inout, omega_real, omega_imag); + } else { + convolve_z_djbfft(n, inout, omega_real, omega_imag); } } +static void init_convolution_kernel_djbfft(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist) +{ + int k, n2 = n / 2; + unsigned int *f = + (unsigned int *) malloc(sizeof(int) * (n)); + fftfreq_rtable(f, n); + for (k = 1; k < n; ++k) + if (f[k] > n2) + f[k] -= n; + omega[0] = (*kernel_func) (0) / n; + switch (d % 4) { + case 0: + for (k = 2; k < n - 1; k += 2) { + omega[k] = + (*kernel_func) (f[k]) / n2; + omega[k + 1] = -omega[k]; + } + omega[1] = + (zero_nyquist ? 0.0 + : (*kernel_func) (n2) / n); + break; + case 1:; + case -3: + for (k = 2; k < n - 1; k += 2) + omega[k] = omega[k + 1] = + -(*kernel_func) (f[k]) / n2; + omega[1] = + (zero_nyquist ? 0.0 + : (*kernel_func) (n2) / n); + break; + case 2:; + case -2: + for (k = 2; k < n - 1; k += 2) { + omega[k] = + -(*kernel_func) (f[k]) / n2; + omega[k + 1] = -omega[k]; + } + omega[1] = + (zero_nyquist ? 0.0 : + -(*kernel_func) (n2) / n); + break; + case 3:; + case -1: + for (k = 2; k < n - 1; k += 2) + omega[k] = omega[k + 1] = + (*kernel_func) (f[k]) / n2; + omega[1] = + (zero_nyquist ? 0.0 : + -(*kernel_func) (n2) / n); + break; + } + free(f); +} + extern "C" void init_convolution_kernel(int n, double *omega, int d, double (*kernel_func) (int), int zero_nyquist) { + bool use_def = true; + /* omega[k] = pow(sqrt(-1),d) * kernel_func(k) omega[0] = kernel_func(0) @@ -203,60 +285,14 @@ case 2048:; case 4096:; case 8192: - { - int k, n2 = n / 2; - unsigned int *f = - (unsigned int *) malloc(sizeof(int) * (n)); - fftfreq_rtable(f, n); - for (k = 1; k < n; ++k) - if (f[k] > n2) - f[k] -= n; - omega[0] = (*kernel_func) (0) / n; - switch (d % 4) { - case 0: - for (k = 2; k < n - 1; k += 2) { - omega[k] = - (*kernel_func) (f[k]) / n2; - omega[k + 1] = -omega[k]; - } - omega[1] = - (zero_nyquist ? 0.0 - : (*kernel_func) (n2) / n); - break; - case 1:; - case -3: - for (k = 2; k < n - 1; k += 2) - omega[k] = omega[k + 1] = - -(*kernel_func) (f[k]) / n2; - omega[1] = - (zero_nyquist ? 0.0 - : (*kernel_func) (n2) / n); - break; - case 2:; - case -2: - for (k = 2; k < n - 1; k += 2) { - omega[k] = - -(*kernel_func) (f[k]) / n2; - omega[k + 1] = -omega[k]; - } - omega[1] = - (zero_nyquist ? 0.0 : - -(*kernel_func) (n2) / n); - break; - case 3:; - case -1: - for (k = 2; k < n - 1; k += 2) - omega[k] = omega[k + 1] = - (*kernel_func) (f[k]) / n2; - omega[1] = - (zero_nyquist ? 0.0 : - -(*kernel_func) (n2) / n); - break; - } - free(f); - } - return; + use_def = false; } - init_convolution_kernel_def(n, omega, d, kernel_func, - zero_nyquist); + + if (use_def) { + init_convolution_kernel_def(n, omega, d, kernel_func, + zero_nyquist); + } else { + init_convolution_kernel_djbfft(n, omega, d, kernel_func, + zero_nyquist); + } } From scipy-svn at scipy.org Mon May 12 09:08:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:08:32 -0500 (CDT) Subject: [Scipy-svn] r4284 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512130832.3BCBE39C50D@scipy.org> Author: cdavid Date: 2008-05-12 08:08:27 -0500 (Mon, 12 May 2008) New Revision: 4284 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: And more... Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:08:07 UTC (rev 4283) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:08:27 UTC (rev 4284) @@ -118,6 +118,8 @@ { int i; double *ptr = NULL; + int n1 = n - 1; + double c; i = get_cache_id_ddjbfft(n); ptr = caches_ddjbfft[i].ptr; @@ -139,19 +141,17 @@ TMPCASE(8192); #undef TMPCASE } - { - int n1 = n - 1; - double c; - ptr[0] *= (omega_real[0] + omega_imag[0]); - ptr[1] *= (omega_real[1] + omega_imag[1]); - for (i = 2; i < n1; i += 2) { - c = ptr[i] * omega_imag[i]; - ptr[i] *= omega_real[i]; - ptr[i] += ptr[i + 1] * omega_imag[i + 1]; - ptr[i + 1] *= omega_real[i + 1]; - ptr[i + 1] += c; - } + + ptr[0] *= (omega_real[0] + omega_imag[0]); + ptr[1] *= (omega_real[1] + omega_imag[1]); + for (i = 2; i < n1; i += 2) { + c = ptr[i] * omega_imag[i]; + ptr[i] *= omega_real[i]; + ptr[i] += ptr[i + 1] * omega_imag[i + 1]; + ptr[i + 1] *= omega_real[i + 1]; + ptr[i + 1] += c; } + switch (n) { #define TMPCASE(N)case N:fftr8_un##N(ptr);break TMPCASE(2); From scipy-svn at scipy.org Mon May 12 09:08:54 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:08:54 -0500 (CDT) Subject: [Scipy-svn] r4285 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512130854.0F82C39C50D@scipy.org> Author: cdavid Date: 2008-05-12 08:08:51 -0500 (Mon, 12 May 2008) New Revision: 4285 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: Fix unsigned/signed comparison warning. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:08:27 UTC (rev 4284) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 13:08:51 UTC (rev 4285) @@ -207,7 +207,8 @@ double (*kernel_func) (int), int zero_nyquist) { - int k, n2 = n / 2; + int k; + unsigned int n2 = n / 2; unsigned int *f = (unsigned int *) malloc(sizeof(int) * (n)); fftfreq_rtable(f, n); From scipy-svn at scipy.org Mon May 12 09:09:23 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:09:23 -0500 (CDT) Subject: [Scipy-svn] r4286 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512130923.E66D639C50D@scipy.org> Author: cdavid Date: 2008-05-12 08:09:20 -0500 (Mon, 12 May 2008) New Revision: 4286 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx Log: Fix drfft implementation by djbfft backend. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-12 13:08:51 UTC (rev 4285) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-12 13:09:20 UTC (rev 4286) @@ -1,13 +1,14 @@ /* - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Wed Aug 01 08:00 PM 2007 J * * Original code by Pearu Peterson. */ /* - * RDJBFFT only implements size 2^N ! + * DJBFFT only implements size 2^N ! * - * drfft_def is the functions used for size different * than 2^N + * drfft_def and drfft_def_destroy_cache are the functions used for size different + * than 2^N */ #include #include @@ -67,117 +68,130 @@ free(m_f); } -int RDJBFFTCache::compute_forward(double *inout) const +int RDJBFFTCache::compute_forward(double *inout) const { - const int n = m_id.m_n; + double *ptr = inout; + double *ptrc = m_ptr; - COPYSTD2DJB(inout, m_ptr, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(m_ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); + int n = m_id.m_n; + COPYSTD2DJB(ptr, ptrc, n); + switch (n) { +#define TMPCASE(N) case N: fftr8_##N(ptrc); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE - } - COPYDJB2STD(m_ptr, inout, m_f, n); - - return 0; + } + COPYDJB2STD(ptrc, ptr, m_f, n); + return 0; } -int RDJBFFTCache::compute_backward(double *inout, int normalize) const +int RDJBFFTCache::compute_backward(double *inout, int normalize) const { - const int n = m_id.m_n; + double *ptr = inout; + double *ptrc = m_ptr; - COPYINVSTD2DJB(inout, m_ptr, normalize, m_f, n); - switch (n) { -#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(m_ptr);fftr8_un##N(m_ptr);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); + int n = m_id.m_n; + + COPYINVSTD2DJB(ptr, ptrc, normalize, m_f, n); + switch (n) { + +#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(ptrc);fftr8_un##N(ptrc);break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); #undef TMPCASE - } - COPYINVDJB2STD(m_ptr, inout, n); - - return 0; + } + COPYINVDJB2STD(ptrc, ptr, n); + return 0; } static CacheManager rdjbfft_cmgr(10); +#if 0 +GEN_CACHE(drdjbfft, (int n) + , unsigned int *f; + double *ptr;, + caches_drdjbfft[i].n == n, + caches_drdjbfft[id].f = (unsigned int *) malloc(sizeof(unsigned int) * (n)); + caches_drdjbfft[id].ptr = (double *) malloc(sizeof(double) * n); + fftfreq_rtable(caches_drdjbfft[id].f, n);, + free(caches_drdjbfft[id].f); + free(caches_drdjbfft[id].ptr);, + 10) +#endif + /**************** ZFFT function **********************/ static void drfft_djbfft(double * inout, int n, int direction, int howmany, int normalize) { - int i; - double *ptr = inout; - RDJBFFTCache *cache; - unsigned int *f = NULL; + int i; + double *ptr = inout; + RDJBFFTCache *cache; - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - cache = rdjbfft_cmgr.get_cache(DJBFFTCacheId(n)); - break; - default: - /* For sizes not handled by djbfft, use default - * implementation and returns */ - drfft_def(inout, n, direction, howmany, normalize); - return; - } + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + cache = rdjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + break; + default: + drfft_def(inout, n, direction, howmany, normalize); + return; + } - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr, normalize); - } - break; + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr, normalize); + } + break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", - direction); - } + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + } - if (normalize && f != NULL && direction == 1) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } + if (normalize && direction == 1) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } } From scipy-svn at scipy.org Mon May 12 09:09:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:09:46 -0500 (CDT) Subject: [Scipy-svn] r4287 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512130946.216BF39C50D@scipy.org> Author: cdavid Date: 2008-05-12 08:09:42 -0500 (Mon, 12 May 2008) New Revision: 4287 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx Log: Remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-12 13:09:20 UTC (rev 4286) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-12 13:09:42 UTC (rev 4287) @@ -128,19 +128,6 @@ static CacheManager rdjbfft_cmgr(10); -#if 0 -GEN_CACHE(drdjbfft, (int n) - , unsigned int *f; - double *ptr;, - caches_drdjbfft[i].n == n, - caches_drdjbfft[id].f = (unsigned int *) malloc(sizeof(unsigned int) * (n)); - caches_drdjbfft[id].ptr = (double *) malloc(sizeof(double) * n); - fftfreq_rtable(caches_drdjbfft[id].f, n);, - free(caches_drdjbfft[id].f); - free(caches_drdjbfft[id].ptr);, - 10) -#endif - /**************** ZFFT function **********************/ static void drfft_djbfft(double * inout, int n, int direction, int howmany, int normalize) From scipy-svn at scipy.org Mon May 12 09:46:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:46:20 -0500 (CDT) Subject: [Scipy-svn] r4288 - in branches/refactor_fft/scipy/fftpack: . src src/fftw Message-ID: <20080512134620.783A239C50E@scipy.org> Author: cdavid Date: 2008-05-12 08:46:14 -0500 (Mon, 12 May 2008) New Revision: 4288 Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx Log: fftw backend for convolve now uses c++ cyclic cache. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-12 13:09:42 UTC (rev 4287) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-12 13:46:14 UTC (rev 4288) @@ -45,7 +45,8 @@ sources=['convolve.pyf','src/convolve.cxx'], libraries=['dfftpack'], extra_info=[fft_opt_info, djbfft_info], - depends=['src/fftpack/convolve.cxx', 'src/fftw/convolve.cxx', "src/djbfft/convolve.cxx"] + depends=['src/fftpack/convolve.cxx', 'src/fftw/convolve.cxx', "src/djbfft/convolve.cxx"], + include_dirs = ['src'], ) return config Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-12 13:09:42 UTC (rev 4287) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-12 13:46:14 UTC (rev 4288) @@ -18,7 +18,6 @@ #ifndef WITH_DJBFFT extern "C" void destroy_convolve_cache(void) { - destroy_convolve_cache_fftw(); } extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) Modified: branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-12 13:09:42 UTC (rev 4287) +++ branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-12 13:46:14 UTC (rev 4288) @@ -1,37 +1,74 @@ -GEN_CACHE(drfftw,(int n) - ,rfftw_plan plan1; - rfftw_plan plan2; - ,(caches_drfftw[i].n==n) - ,caches_drfftw[id].plan1 = rfftw_create_plan(n, - FFTW_REAL_TO_COMPLEX, - FFTW_IN_PLACE|FFTW_ESTIMATE); - caches_drfftw[id].plan2 = rfftw_create_plan(n, - FFTW_COMPLEX_TO_REAL, - FFTW_IN_PLACE|FFTW_ESTIMATE); - ,rfftw_destroy_plan(caches_drfftw[id].plan1); - rfftw_destroy_plan(caches_drfftw[id].plan2); - ,20) +#include -static void destroy_convolve_cache_fftw(void) +#include "cycliccache.h" + +using namespace fft; + +class DRFFTWCacheId : public CacheId { + public: + DRFFTWCacheId(int n); + +}; + +DRFFTWCacheId::DRFFTWCacheId(int n): + CacheId(n) { - destroy_drfftw_caches(); } -/**************** convolve **********************/ -static -void convolve_fftw(int n,double* inout,double* omega,int swap_real_imag) +class DRFFTWCache : public Cache { + public: + DRFFTWCache(const DRFFTWCacheId& id); + virtual ~DRFFTWCache(); + + int convolve(double* inout, double* omega, + int swap_real_imag) const; + int convolve_z(double* inout, double* omega_real, + double* omega_imag) const; + + protected: + rfftw_plan m_plan1; + rfftw_plan m_plan2; +}; + +DRFFTWCache::DRFFTWCache(const DRFFTWCacheId& id) +: Cache(id) { - int i; - rfftw_plan plan1 = NULL; - rfftw_plan plan2 = NULL; + int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; + + m_plan1 = rfftw_create_plan(id.m_n, FFTW_REAL_TO_COMPLEX, flags); + if (m_plan1 == NULL) { + goto fail; + } + + m_plan2 = rfftw_create_plan(id.m_n, FFTW_COMPLEX_TO_REAL, flags); + if (m_plan2 == NULL) { + goto clean_plan1; + } + + return; + +clean_plan1: + rfftw_destroy_plan(m_plan1); +fail: + throw std::bad_alloc(); +} + +DRFFTWCache::~DRFFTWCache() +{ + rfftw_destroy_plan(m_plan2); + rfftw_destroy_plan(m_plan1); +} + +int DRFFTWCache::convolve(double* inout, double* omega, int swap_real_imag) + const +{ + int n = m_id.m_n; int l = (n-1)/2+1; + int i; + double c; - i = get_cache_id_drfftw(n); - plan1 = caches_drfftw[i].plan1; - plan2 = caches_drfftw[i].plan2; - rfftw_one(plan1, (fftw_real *)inout, NULL); + rfftw_one(m_plan1, (fftw_real *)inout, NULL); if (swap_real_imag) { - double c; inout[0] *= omega[0]; if (!(n%2)) { inout[n/2] *= omega[n/2]; @@ -46,22 +83,20 @@ inout[i] *= omega[i]; } } - rfftw_one(plan2, (fftw_real *)inout, NULL); + rfftw_one(m_plan2, (fftw_real *)inout, NULL); + + return 0; } -/**************** convolve **********************/ -static -void convolve_z_fftw(int n,double* inout,double* omega_real,double* omega_imag) { +int DRFFTWCache::convolve_z(double* inout, double* omega_real, + double* omega_imag) const +{ + int n = m_id.m_n; int i; - rfftw_plan plan1 = NULL; - rfftw_plan plan2 = NULL; int l = (n-1)/2+1; double c; - i = get_cache_id_drfftw(n); - plan1 = caches_drfftw[i].plan1; - plan2 = caches_drfftw[i].plan2; - rfftw_one(plan1, (fftw_real *)inout, NULL); + rfftw_one(m_plan1, (fftw_real *)inout, NULL); inout[0] *= (omega_real[0]+omega_imag[0]); if (!(n%2)) { @@ -74,10 +109,34 @@ inout[n-i] *= omega_real[n-i]; inout[n-i] += c; } - rfftw_one(plan2, (fftw_real *)inout, NULL); + rfftw_one(m_plan2, (fftw_real *)inout, NULL); + + return 0; } +CacheManager drfftw_cmgr(20); + +/**************** convolve **********************/ static +void convolve_fftw(int n,double* inout,double* omega,int swap_real_imag) +{ + DRFFTWCache *cache; + + cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); + cache->convolve(inout, omega, swap_real_imag); +} + +/**************** convolve **********************/ +static +void convolve_z_fftw(int n,double* inout,double* omega_real,double* omega_imag) +{ + DRFFTWCache *cache; + + cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); + cache->convolve_z(inout, omega_real, omega_imag); +} + +static void init_convolution_kernel_fftw(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist) From scipy-svn at scipy.org Mon May 12 09:49:43 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 08:49:43 -0500 (CDT) Subject: [Scipy-svn] r4289 - branches/refactor_fft/scipy/fftpack/src/fftpack Message-ID: <20080512134943.956E839C50E@scipy.org> Author: cdavid Date: 2008-05-12 08:49:37 -0500 (Mon, 12 May 2008) New Revision: 4289 Added: branches/refactor_fft/scipy/fftpack/src/fftpack/common.h Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx Log: Put drfft cache code in separate file for fftpack backend, for future sharing with convolve. Added: branches/refactor_fft/scipy/fftpack/src/fftpack/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/common.h 2008-05-12 13:46:14 UTC (rev 4288) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/common.h 2008-05-12 13:49:37 UTC (rev 4289) @@ -0,0 +1,74 @@ +#ifndef _SCIPY_FFTPACK_FFTPACK_COMMON_H +#define _SCIPY_FFTPACK_FFTPACK_COMMON_H + +#include + +#include "cycliccache.h" + +namespace fft { + +extern "C" { +extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); +extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); +extern void F_FUNC(dffti, DFFTI) (int *, double *); +}; + +class RFFTPackCacheId : public CacheId { + public: + RFFTPackCacheId(int n) : CacheId(n) {}; +}; + +class RFFTPackCache: public Cache { + public: + RFFTPackCache(const RFFTPackCacheId& id); + virtual ~RFFTPackCache(); + + int compute_forward(double * inout) const; + int compute_backward(double * inout) const; + + protected: + double* m_wsave; +}; + +RFFTPackCache::RFFTPackCache(const RFFTPackCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + m_wsave = (double *)malloc(sizeof(*m_wsave) * (2 * n + 15)); + if (m_wsave == NULL) { + goto fail; + } + + F_FUNC(dffti, DFFTI)(&n, m_wsave); + + return; + +fail: + throw std::bad_alloc(); +} + +RFFTPackCache::~RFFTPackCache() +{ + free(m_wsave); +} + +int RFFTPackCache::compute_forward(double *inout) const +{ + int n = m_id.m_n; + + F_FUNC(dfftf, DFFTF)(&n, inout, m_wsave); + return 0; +} + +int RFFTPackCache::compute_backward(double *inout) const +{ + int n = m_id.m_n; + + F_FUNC(dfftb, DFFTB)(&n, inout, m_wsave); + return 0; +} + +}; + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-12 13:46:14 UTC (rev 4288) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-12 13:49:37 UTC (rev 4289) @@ -1,78 +1,14 @@ /* - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Mon May 12 10:00 PM 2008 J * * FFTPACK implementation * * Original code by Pearu Peterson. */ -#include +#include "common.h" -#include "cycliccache.h" - -extern "C" { -extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); -extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); -extern void F_FUNC(dffti, DFFTI) (int *, double *); -}; - using namespace fft; -class RFFTPackCacheId : public CacheId { - public: - RFFTPackCacheId(int n) : CacheId(n) {}; -}; - -class RFFTPackCache: public Cache { - public: - RFFTPackCache(const RFFTPackCacheId& id); - virtual ~RFFTPackCache(); - - int compute_forward(double * inout) const; - int compute_backward(double * inout) const; - - protected: - double* m_wsave; -}; - -RFFTPackCache::RFFTPackCache(const RFFTPackCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - m_wsave = (double *)malloc(sizeof(*m_wsave) * (2 * n + 15)); - if (m_wsave == NULL) { - goto fail; - } - - F_FUNC(dffti, DFFTI)(&n, m_wsave); - - return; - -fail: - throw std::bad_alloc(); -} - -RFFTPackCache::~RFFTPackCache() -{ - free(m_wsave); -} - -int RFFTPackCache::compute_forward(double *inout) const -{ - int n = m_id.m_n; - - F_FUNC(dfftf, DFFTF)(&n, inout, m_wsave); - return 0; -} - -int RFFTPackCache::compute_backward(double *inout) const -{ - int n = m_id.m_n; - - F_FUNC(dfftb, DFFTB)(&n, inout, m_wsave); - return 0; -} - static CacheManager rfftpack_cmgr(10); static void drfft_fftpack(double *inout, int n, int direction, int howmany, From scipy-svn at scipy.org Mon May 12 10:16:09 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 09:16:09 -0500 (CDT) Subject: [Scipy-svn] r4290 - in branches/refactor_fft/scipy/fftpack/src: . fftpack Message-ID: <20080512141609.6367F39C343@scipy.org> Author: cdavid Date: 2008-05-12 09:16:04 -0500 (Mon, 12 May 2008) New Revision: 4290 Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx Log: fftpack backend for convolve now uses c++ cyclic cache. Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-12 13:49:37 UTC (rev 4289) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-12 14:16:04 UTC (rev 4290) @@ -45,7 +45,6 @@ #ifndef WITH_DJBFFT extern "C" void destroy_convolve_cache(void) { - destroy_convolve_cache_fftpack(); } extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx 2008-05-12 13:49:37 UTC (rev 4289) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx 2008-05-12 14:16:04 UTC (rev 4290) @@ -1,27 +1,24 @@ -extern "C" { -extern void F_FUNC(dfftf,DFFTF)(int*,double*,double*); -extern void F_FUNC(dfftb,DFFTB)(int*,double*,double*); -extern void F_FUNC(dffti,DFFTI)(int*,double*); -GEN_CACHE(dfftpack,(int n) - ,double* wsave; - ,(caches_dfftpack[i].n==n) - ,caches_dfftpack[id].wsave = (double*)malloc(sizeof(double)*(2*n+15)); - F_FUNC(dffti,DFFTI)(&n,caches_dfftpack[id].wsave); - ,free(caches_dfftpack[id].wsave); - ,20) +#include "common.h" + +using namespace fft; + +class DFFTPackCache : public RFFTPackCache { + public: + DFFTPackCache(const RFFTPackCacheId& id) : RFFTPackCache(id) {}; + virtual ~DFFTPackCache() {}; + + public: + int convolve(double* inout, double* omega, int swap_real_imag) const; + int convolve_z(double* inout, double* omega_real, double* omega_imag) const; }; -static void destroy_convolve_cache_fftpack(void) +int DFFTPackCache::convolve(double* inout, double* omega, int swap_real_imag) + const { - destroy_dfftpack_caches(); -} + int i; + int n = m_id.m_n; + double* wsave = m_wsave; -static void convolve_fftpack(int n,double* inout,double* omega,int swap_real_imag) -{ - int i; - double* wsave = NULL; - i = get_cache_id_dfftpack(n); - wsave = caches_dfftpack[i].wsave; F_FUNC(dfftf,DFFTF)(&n,inout,wsave); if (swap_real_imag) { double c; @@ -39,18 +36,19 @@ for(i=0;i dfftpack_cmgr(20); + +static void convolve_fftpack(int n,double* inout,double* omega,int swap_real_imag) +{ + DFFTPackCache* cache; + + cache = dfftpack_cmgr.get_cache(RFFTPackCacheId(n)); + cache->convolve(inout, omega, swap_real_imag); +} + +static void convolve_z_fftpack(int n,double* inout,double* omega_real,double* omega_imag) +{ + DFFTPackCache* cache; + + cache = dfftpack_cmgr.get_cache(RFFTPackCacheId(n)); + cache->convolve_z(inout, omega_real, omega_imag); +} + void init_convolution_kernel_fftpack(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist) From scipy-svn at scipy.org Mon May 12 10:53:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 09:53:41 -0500 (CDT) Subject: [Scipy-svn] r4291 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512145341.2723539C33F@scipy.org> Author: cdavid Date: 2008-05-12 09:53:35 -0500 (Mon, 12 May 2008) New Revision: 4291 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: djbfft backend for convolve now uses c++ cyclic cache. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 14:16:04 UTC (rev 4290) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 14:53:35 UTC (rev 4291) @@ -1,3 +1,8 @@ +#include +#include + +#include "common.h" + #ifdef WITH_FFTW #define destroy_convolve_cache_def destroy_convolve_cache_fftw #define convolve_def convolve_fftw @@ -10,26 +15,57 @@ #define init_convolution_kernel_def init_convolution_kernel_fftpack #endif +#if 0 GEN_CACHE(ddjbfft, (int n) , double *ptr;, (caches_ddjbfft[i].n == n) , caches_ddjbfft[id].ptr = (double *) malloc(sizeof(double) * n);, free(caches_ddjbfft[id].ptr);, 20) +#endif -extern "C" void destroy_convolve_cache(void) +using namespace fft; + +class DDJBFFTCache: public Cache { + public: + DDJBFFTCache(const DJBFFTCacheId& id); + virtual ~DDJBFFTCache(); + + int convolve(double *inout, double *omega, + int swap_real_imag) const; + int convolve_z(double *inout, double *omega_real, + double* omega_imag) const; + protected: + double* m_ptr; +}; + +DDJBFFTCache::DDJBFFTCache(const DJBFFTCacheId& id) +: Cache(id) { - destroy_ddjbfft_caches(); - destroy_convolve_cache_def(); + int n = id.m_n; + + m_ptr = (double *)malloc(sizeof(*m_ptr) * n); + if (m_ptr == NULL) { + goto fail; + } + + return; + +fail: + throw std::bad_alloc(); } -/**************** convolve **********************/ -static void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) +DDJBFFTCache::~DDJBFFTCache() { + free(m_ptr); +} + +int DDJBFFTCache::convolve(double *inout, double *omega, int swap_real_imag) + const +{ int i; - double *ptr = NULL; + double *ptr = m_ptr; + int n = m_id.m_n; - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; COPYSTD2DJB(inout, ptr, n); switch (n) { #define TMPCASE(N) case N: fftr8_##N(ptr); break @@ -81,48 +117,19 @@ #undef TMPCASE } COPYINVDJB2STD2(ptr, inout, n); -} -extern "C" -void convolve(int n, double *inout, double *omega, int swap_real_imag) -{ - bool use_def = true; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - use_def = false; - } - - if (!use_def) { - convolve_djbfft(n, inout, omega, swap_real_imag); - } else { - convolve_def(n, inout, omega, swap_real_imag); - } + return 0; } -/**************** convolve **********************/ -static void convolve_z_djbfft(int n, double *inout, double *omega_real, - double *omega_imag) +int DDJBFFTCache::convolve_z(double *inout, double *omega_real, double *omega_imag) + const { int i; - double *ptr = NULL; + int n = m_id.m_n; + double *ptr = m_ptr; int n1 = n - 1; double c; - i = get_cache_id_ddjbfft(n); - ptr = caches_ddjbfft[i].ptr; COPYSTD2DJB(inout, ptr, n); switch (n) { #define TMPCASE(N) case N: fftr8_##N(ptr); break @@ -170,10 +177,65 @@ #undef TMPCASE } COPYINVDJB2STD2(ptr, inout, n); - return; + return 0; } +static CacheManager ddjbfft_cmgr(20); + +/* stub */ +extern "C" void destroy_convolve_cache() +{ +} + +/**************** convolve **********************/ +static void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) +{ + DDJBFFTCache *cache; + + cache = ddjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + cache->convolve(inout, omega, swap_real_imag); +} + extern "C" +void convolve(int n, double *inout, double *omega, int swap_real_imag) +{ + bool use_def = true; + + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + use_def = false; + } + + if (!use_def) { + convolve_djbfft(n, inout, omega, swap_real_imag); + } else { + convolve_def(n, inout, omega, swap_real_imag); + } +} + +/**************** convolve **********************/ +static void convolve_z_djbfft(int n, double *inout, double *omega_real, + double *omega_imag) +{ + DDJBFFTCache *cache; + + cache = ddjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + cache->convolve_z(inout, omega_real, omega_imag); +} + +extern "C" void convolve_z(int n, double *inout, double *omega_real, double *omega_imag) { From scipy-svn at scipy.org Mon May 12 10:54:27 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 09:54:27 -0500 (CDT) Subject: [Scipy-svn] r4292 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080512145427.9803539C343@scipy.org> Author: cdavid Date: 2008-05-12 09:54:22 -0500 (Mon, 12 May 2008) New Revision: 4292 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx Log: Remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 14:53:35 UTC (rev 4291) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-12 14:54:22 UTC (rev 4292) @@ -4,25 +4,15 @@ #include "common.h" #ifdef WITH_FFTW -#define destroy_convolve_cache_def destroy_convolve_cache_fftw #define convolve_def convolve_fftw #define convolve_z_def convolve_z_fftw #define init_convolution_kernel_def init_convolution_kernel_fftw #else -#define destroy_convolve_cache_def destroy_convolve_cache_fftpack #define convolve_def convolve_fftpack #define convolve_z_def convolve_z_fftpack #define init_convolution_kernel_def init_convolution_kernel_fftpack #endif -#if 0 -GEN_CACHE(ddjbfft, (int n) - , double *ptr;, (caches_ddjbfft[i].n == n) - , caches_ddjbfft[id].ptr = - (double *) malloc(sizeof(double) * n);, - free(caches_ddjbfft[id].ptr);, 20) -#endif - using namespace fft; class DDJBFFTCache: public Cache { From scipy-svn at scipy.org Mon May 12 12:01:37 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 11:01:37 -0500 (CDT) Subject: [Scipy-svn] r4293 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080512160137.1527439C717@scipy.org> Author: cdavid Date: 2008-05-12 11:01:32 -0500 (Mon, 12 May 2008) New Revision: 4293 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Finally: remove unused GEN_CACHE macro. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-12 14:54:22 UTC (rev 4292) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-12 16:01:32 UTC (rev 4293) @@ -84,49 +84,6 @@ #endif #endif -/* - Simple cyclic cache. - */ -#define GEN_CACHE(name,CACHEARG,CACHETYPE,CHECK,MALLOC,FREE,CACHESIZE) \ -typedef struct {\ - int n;\ - CACHETYPE \ -} cache_type_##name;\ -static cache_type_##name caches_##name[CACHESIZE];\ -static int nof_in_cache_##name = 0;\ -static int last_cache_id_##name = 0;\ -static int get_cache_id_##name CACHEARG { \ - int i,id = -1; \ - for (i=0;i=0) goto exit;\ - if (nof_in_cache_##name Author: wnbell Date: 2008-05-12 15:15:50 -0500 (Mon, 12 May 2008) New Revision: 4294 Modified: trunk/scipy/sparse/csr.py trunk/scipy/sparse/tests/test_base.py Log: fixed indexing bug reported by Robert Cimrman http://thread.gmane.org/gmane.comp.python.scientific.devel/7986 Modified: trunk/scipy/sparse/csr.py =================================================================== --- trunk/scipy/sparse/csr.py 2008-05-12 16:01:32 UTC (rev 4293) +++ trunk/scipy/sparse/csr.py 2008-05-12 20:15:50 UTC (rev 4294) @@ -363,7 +363,8 @@ check_bounds( j0, j1, N ) indptr, indices, data = get_csr_submatrix( M, N, \ - self.indptr, self.indices, self.data, i0, i1, j0, j1 ) + self.indptr, self.indices, self.data, \ + int(i0), int(i1), int(j0), int(j1) ) shape = (i1 - i0, j1 - j0) Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-05-12 16:01:32 UTC (rev 4293) +++ trunk/scipy/sparse/tests/test_base.py 2008-05-12 20:15:50 UTC (rev 4294) @@ -679,6 +679,13 @@ assert_equal(A[:,2].todense(),B[:,2]) assert_equal(A[3:4,9].todense(),B[3:4,9]) assert_equal(A[1:4,-5].todense(),B[1:4,-5]) + assert_equal(A[2:-1,3].todense(),B[2:-1,3]) + + # [1:2,1:2] + assert_equal(A[1:2,1:2].todense(),B[1:2,1:2]) + assert_equal(A[4:,3:].todense(),B[4:,3:]) + assert_equal(A[:4,:5].todense(),B[:4,:5]) + assert_equal(A[2:-1,:5].todense(),B[2:-1,:5]) # [1:2,[1,2]] assert_equal(A[:,[2,8,3,-1]].todense(),B[:,[2,8,3,-1]]) @@ -721,6 +728,13 @@ assert_equal(A[:,[1,3]][[2,4],:].todense(), B[:,[1,3]][[2,4],:] ) assert_equal(A[:,[-1,-3]][[2,-4],:].todense(), B[:,[-1,-3]][[2,-4],:] ) + + # Check bug reported by Robert Cimrman: + # http://thread.gmane.org/gmane.comp.python.scientific.devel/7986 + s = slice(numpy.int8(2),numpy.int8(4),None) + assert_equal(A[s,:].todense(), B[2:4,:]) + assert_equal(A[:,s].todense(), B[:,2:4]) + class _TestArithmetic: """ Test real/complex arithmetic From scipy-svn at scipy.org Mon May 12 21:57:24 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 20:57:24 -0500 (CDT) Subject: [Scipy-svn] r4295 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513015724.403FA39C120@scipy.org> Author: cdavid Date: 2008-05-12 20:57:19 -0500 (Mon, 12 May 2008) New Revision: 4295 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Remove unused fftwork backend code. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-12 20:15:50 UTC (rev 4294) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 01:57:19 UTC (rev 4295) @@ -28,11 +28,6 @@ extern int ispow2le2e30(int n); extern int ispow2le2e13(int n); -#ifdef SCIPY_FFTWORK_H -#define WITH_FFTWORK -#include "fftwork/fast_header.h" -#endif - #ifdef SCIPY_DJBFFT_H #ifdef __cplusplus extern "C" { From scipy-svn at scipy.org Mon May 12 23:27:50 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 22:27:50 -0500 (CDT) Subject: [Scipy-svn] r4296 - in branches/refactor_fft/scipy/fftpack: . src Message-ID: <20080513032750.9079139C192@scipy.org> Author: cdavid Date: 2008-05-12 22:27:43 -0500 (Mon, 12 May 2008) New Revision: 4296 Added: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx Removed: branches/refactor_fft/scipy/fftpack/src/drfft.cxx branches/refactor_fft/scipy/fftpack/src/zfft.cxx branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx Modified: branches/refactor_fft/scipy/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/setup.py Log: Start working on getting all types of fft defined at one location. Modified: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-13 01:57:19 UTC (rev 4295) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-13 03:27:43 UTC (rev 4296) @@ -1,4 +1,4 @@ -# Last Change: Wed May 07 06:00 PM 2008 J +# Last Change: Tue May 13 10:00 AM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -48,5 +48,5 @@ env.NumpyPythonExtension('_fftpack', src) # Build convolve -src = ['src/convolve.c', 'convolve.pyf'] +src = ['src/convolve.cxx', 'convolve.pyf'] env.NumpyPythonExtension('convolve', src) Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 01:57:19 UTC (rev 4295) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 03:27:43 UTC (rev 4296) @@ -24,8 +24,7 @@ config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) - sources = ['fftpack.pyf','src/zfft.cxx','src/drfft.cxx','src/zrfft.c', - 'src/zfftnd.cxx'] + sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] config.add_extension('_fftpack', sources=sources, Deleted: branches/refactor_fft/scipy/fftpack/src/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-13 01:57:19 UTC (rev 4295) +++ branches/refactor_fft/scipy/fftpack/src/drfft.cxx 2008-05-13 03:27:43 UTC (rev 4296) @@ -1,61 +0,0 @@ -/* - Interface to various FFT libraries. - Double real FFT and IFFT. - Author: Pearu Peterson, August 2002 - */ - -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_PUBLIC_API(name) \ -extern "C" void drfft(double *inout, int n, \ - int direction, int howmany, int normalize)\ -{\ - drfft_##name(inout, n, direction, howmany, normalize);\ -} - -/* ************** Definition of backend specific functions ********* */ - -/* - * To add a backend : - * - create a file drfft_name.c, where you define a function drfft_name where - * name is the name of your backend. If you do not use the GEN_CACHE macro, - * you will need to define a function void destroy_drname_caches(void), - * which can do nothing - * - in drfft.c, include the drfft_name.c file, and add the 3 following lines - * just after it: - * #ifndef WITH_DJBFFT - * GEN_PUBLIC_API(name) - * #endif - */ - -#ifdef WITH_FFTW3 - #include "fftw3/drfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw3) - #endif -#elif defined WITH_FFTW - #include "fftw/drfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw) - #endif -#else /* Use fftpack by default */ - #include "fftpack/drfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftpack) - #endif -#endif - -/* - * djbfft must be used at the end, because it needs another backend (defined - * above) for non 2^n * size - */ -#ifdef WITH_DJBFFT - #include "djbfft/drfft.cxx" - extern "C" void drfft(double *inout, int n, - int direction, int howmany, int normalize) - { - drfft_djbfft(inout, n, direction, howmany, normalize); - } -#endif Added: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 01:57:19 UTC (rev 4295) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 03:27:43 UTC (rev 4296) @@ -0,0 +1,90 @@ +#include "fftpack.h" + +/* The following macro convert private backend specific function to the public + * functions exported by the module */ +#define GEN_ZFFT_API(name) \ +extern "C" void zfft(complex_double *inout, int n, \ + int direction, int howmany, int normalize)\ +{\ + zfft_##name(inout, n, direction, howmany, normalize);\ +} + +#define GEN_DRFFT_API(name) \ +extern "C" void drfft(double *inout, int n, \ + int direction, int howmany, int normalize)\ +{\ + drfft_##name(inout, n, direction, howmany, normalize);\ +} + +#define GEN_ZFFTND_API(name) \ +extern "C" void zfftnd(complex_double * inout, int rank,\ + int *dims, int direction, int howmany, int normalize)\ +{\ + zfftnd_##name(inout, rank, dims, direction, howmany, normalize);\ +} + + +/* ************** Definition of backend specific functions ********* */ + +/* + * To add a backend : + * - create a file drfft_name.c, where you define a function drfft_name where + * name is the name of your backend. If you do not use the GEN_CACHE macro, + * you will need to define a function void destroy_drname_caches(void), + * which can do nothing + * - in drfft.c, include the drfft_name.c file, and add the 3 following lines + * just after it: + * #ifndef WITH_DJBFFT + * GEN_PUBLIC_API(name) + * #endif + */ + +#include "fftpack/drfft.cxx" +#include "fftpack/zfftnd.cxx" +#include "fftpack/zfft.cxx" + +#ifdef WITH_FFTW3 + #include "fftw3/drfft.cxx" + #include "fftw3/zfft.cxx" + #include "fftw3/zfftnd.cxx" + #ifndef WITH_DJBFFT + GEN_ZFFT_API(fftw3) + GEN_DRFFT_API(fftw3) + GEN_ZFFTND_API(fftw3) + #endif +#elif defined WITH_FFTW + #include "fftw/drfft.cxx" + #include "fftw/zfft.cxx" + #include "fftw/zfftnd.cxx" + #ifndef WITH_DJBFFT + GEN_ZFFT_API(fftw) + GEN_DRFFT_API(fftw) + GEN_ZFFTND_API(fftw) + #endif +#elif defined WITH_MKL + #include "mkl/zfft.cxx" + #include "mkl/zfftnd.cxx" + #ifndef WITH_DJBFFT + GEN_ZFFT_API(mkl) + GEN_ZFFTND_API(mkl) + #endif + GEN_DRFFT_API(fftpack) +#endif + +#if (!defined WITH_DJBFFT) && (!defined WITH_MKL) \ + && (!defined WITH_FFTW) && (!defined WITH_FFTW3) +GEN_ZFFT_API(fftpack) +GEN_DRFFT_API(fftpack) +GEN_ZFFTND_API(fftpack) +#endif + +/* + * djbfft must be used at the end, because it needs another backend (defined + * above) for non 2^n * size + */ +#ifdef WITH_DJBFFT + #include "djbfft/drfft.cxx" + #include "djbfft/zfft.cxx" + GEN_DRFFT_API(djbfft) + GEN_ZFFT_API(djbfft) +#endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-13 01:57:19 UTC (rev 4295) +++ branches/refactor_fft/scipy/fftpack/src/zfft.cxx 2008-05-13 03:27:43 UTC (rev 4296) @@ -1,53 +0,0 @@ -/* - Interface to various FFT libraries. - Double complex FFT and IFFT. - Author: Pearu Peterson, August 2002 - */ - -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_PUBLIC_API(name) \ -extern "C" void zfft(complex_double *inout, int n, \ - int direction, int howmany, int normalize)\ -{\ - zfft_##name(inout, n, direction, howmany, normalize);\ -} - -/* ************** Definition of backend specific functions ********* */ - -#ifdef WITH_FFTW3 - #include "fftw3/zfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw3) - #endif -#elif defined WITH_FFTW - #include "fftw/zfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftw) - #endif -#elif defined WITH_MKL - #include "mkl/zfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(mkl) - #endif -#else /* Use fftpack by default */ - #include "fftpack/zfft.cxx" - #ifndef WITH_DJBFFT - GEN_PUBLIC_API(fftpack) - #endif -#endif - -/* - * djbfft must be used at the end, because it needs another backend (defined - * above) for non 2^n * size - */ -#ifdef WITH_DJBFFT - #include "djbfft/zfft.cxx" - extern "C" void zfft(complex_double *inout, int n, - int direction, int howmany, int normalize) - { - zfft_djbfft(inout, n, direction, howmany, normalize); - } -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-13 01:57:19 UTC (rev 4295) +++ branches/refactor_fft/scipy/fftpack/src/zfftnd.cxx 2008-05-13 03:27:43 UTC (rev 4296) @@ -1,42 +0,0 @@ -/* - Interface to various FFT libraries. - Double complex FFT and IFFT, arbitrary dimensions. - Author: Pearu Peterson, August 2002 - */ -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_PUBLIC_API(name) \ -extern "C" void zfftnd(complex_double * inout, int rank,\ - int *dims, int direction, int howmany, int normalize)\ -{\ - zfftnd_##name(inout, rank, dims, direction, howmany, normalize);\ -} - -#if defined(WITH_FFTW) || defined(WITH_MKL) -static int equal_dims(int rank,int *dims1,int *dims2) -{ - int i; - for (i = 0; i < rank; ++i) { - if (dims1[i] != dims2[i]) { - return 0; - } - } - return 1; -} -#endif - -#ifdef WITH_FFTW3 - #include "fftw3/zfftnd.cxx" - GEN_PUBLIC_API(fftw3) -#elif defined WITH_FFTW - #include "fftw/zfftnd.cxx" - GEN_PUBLIC_API(fftw) -#elif defined WITH_MKL - #include "mkl/zfftnd.cxx" - GEN_PUBLIC_API(mkl) -#else /* Use fftpack by default */ - #include "fftpack/zfftnd.cxx" - GEN_PUBLIC_API(fftpack) -#endif From scipy-svn at scipy.org Mon May 12 23:36:23 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 22:36:23 -0500 (CDT) Subject: [Scipy-svn] r4297 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513033623.C2CEE39C192@scipy.org> Author: cdavid Date: 2008-05-12 22:36:20 -0500 (Mon, 12 May 2008) New Revision: 4297 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx Log: Restore wrongly deleted equal_dims. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 03:27:43 UTC (rev 4296) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 03:36:20 UTC (rev 4297) @@ -43,6 +43,19 @@ #include "fftpack/zfftnd.cxx" #include "fftpack/zfft.cxx" +#if defined(WITH_FFTW) || defined(WITH_MKL) +static int equal_dims(int rank,int *dims1,int *dims2) +{ + int i; + for (i = 0; i < rank; ++i) { + if (dims1[i] != dims2[i]) { + return 0; + } + } + return 1; +} +#endif + #ifdef WITH_FFTW3 #include "fftw3/drfft.cxx" #include "fftw3/zfft.cxx" From scipy-svn at scipy.org Mon May 12 23:36:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 22:36:46 -0500 (CDT) Subject: [Scipy-svn] r4298 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080513033646.12F5139C192@scipy.org> Author: cdavid Date: 2008-05-12 22:36:41 -0500 (Mon, 12 May 2008) New Revision: 4298 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx Log: fftw3 backend builds again. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-13 03:36:20 UTC (rev 4297) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-13 03:36:41 UTC (rev 4298) @@ -1,5 +1,5 @@ /* - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Tue May 13 12:00 PM 2008 J * * RFFTW3 implementation * @@ -86,7 +86,7 @@ fftw_free(m_wrk); } -static CacheManager fftw3_cmgr(10); +static CacheManager drfftw3_cmgr(10); static void drfft_fftw3(double *inout, int n, int direction, int howmany, int normalize) @@ -108,7 +108,7 @@ isaligned = isaligned && is_simd_aligned(ptr + n); } - cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); + cache = drfftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); switch (direction) { case 1: Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-13 03:36:20 UTC (rev 4297) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-13 03:36:41 UTC (rev 4298) @@ -60,7 +60,7 @@ fftw_free(m_wrk); } -static CacheManager fftw3_cmgr(10); +static CacheManager zfftw3_cmgr(10); static void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, int normalize) @@ -82,7 +82,7 @@ */ isaligned = isaligned && is_simd_aligned(ptr + n); } - cache = fftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); + cache = zfftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); switch (dir) { case 1: Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-13 03:36:20 UTC (rev 4297) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-13 03:36:41 UTC (rev 4298) @@ -3,7 +3,7 @@ * * Original code by Pearu Peaterson * - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Tue May 13 12:00 PM 2008 J */ #include #include @@ -166,7 +166,7 @@ fftw_free(m_wrk); } -static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > fftw3_cmgr(10); +static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > ndfftw3_cmgr(10); extern void zfftnd_fftw3(complex_double * inout, int rank, int *dims, int direction, int howmany, @@ -182,7 +182,7 @@ } cache = - fftw3_cmgr. + ndfftw3_cmgr. get_cache(NDFFTW3CacheId (rank, dims, howmany, direction, is_simd_aligned(inout))); From scipy-svn at scipy.org Mon May 12 23:41:09 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 22:41:09 -0500 (CDT) Subject: [Scipy-svn] r4299 - branches/refactor_fft/scipy/fftpack/src/mkl Message-ID: <20080513034109.40D4539C236@scipy.org> Author: cdavid Date: 2008-05-12 22:41:02 -0500 (Mon, 12 May 2008) New Revision: 4299 Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Log: Fix mkl backend. Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-13 03:36:41 UTC (rev 4298) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-13 03:41:02 UTC (rev 4299) @@ -50,7 +50,7 @@ return 0; } -CacheManager mkl_cmgr(10); +CacheManager zmkl_cmgr(10); static void zfft_mkl(complex_double * inout, int n, int direction, int howmany, int normalize) @@ -59,7 +59,7 @@ complex_double *ptr = inout; MKLCache *cache; - cache = mkl_cmgr.get_cache(MKLCacheId(n)); + cache = zmkl_cmgr.get_cache(MKLCacheId(n)); switch (direction) { Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-13 03:36:41 UTC (rev 4298) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-13 03:41:02 UTC (rev 4299) @@ -3,7 +3,7 @@ * * Original code by David M. Cooke * - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Tue May 13 12:00 PM 2008 J */ #include @@ -155,7 +155,7 @@ return ndim; } -static CacheManager < NDMKLCacheId, NDMKLCache > mkl_cmgr(10); +static CacheManager < NDMKLCacheId, NDMKLCache > ndmkl_cmgr(10); extern void zfftnd_mkl(complex_double * inout, int rank, int *dims, int direction, int howmany, @@ -170,7 +170,7 @@ sz *= dims[i]; } - cache = mkl_cmgr.get_cache(NDMKLCacheId(rank, dims)); + cache = ndmkl_cmgr.get_cache(NDMKLCacheId(rank, dims)); switch(direction) { case 1: for (i = 0; i < howmany; ++i, ptr += sz) { From scipy-svn at scipy.org Mon May 12 23:50:17 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 May 2008 22:50:17 -0500 (CDT) Subject: [Scipy-svn] r4300 - branches/refactor_fft/scipy/fftpack/src/djbfft Message-ID: <20080513035017.ECAD539C064@scipy.org> Author: cdavid Date: 2008-05-12 22:50:11 -0500 (Mon, 12 May 2008) New Revision: 4300 Added: branches/refactor_fft/scipy/fftpack/src/djbfft/api.h Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx Log: Export fft functions as C api for djbfft. Added: branches/refactor_fft/scipy/fftpack/src/djbfft/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-13 03:41:02 UTC (rev 4299) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-13 03:50:11 UTC (rev 4300) @@ -0,0 +1,10 @@ +#ifndef _SCIPY_FFTPACK_DJBFFT_API_H_ +#define _SCIPY_FFTPACK_DJBFFT_API_H_ + +void drfft_djbfft(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_djbfft(complex_double * inout, + int n, int direction, int howmany, int normalize); + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-13 03:41:02 UTC (rev 4299) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-13 03:50:11 UTC (rev 4300) @@ -3,6 +3,8 @@ #include +#include "api.h" + namespace fft { class DJBFFTCacheId : public CacheId { Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-13 03:41:02 UTC (rev 4299) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-13 03:50:11 UTC (rev 4300) @@ -1,5 +1,5 @@ /* - * Last Change: Wed Aug 01 08:00 PM 2007 J + * Last Change: Tue May 13 12:00 PM 2008 J * * Original code by Pearu Peterson. */ @@ -129,7 +129,7 @@ static CacheManager rdjbfft_cmgr(10); /**************** ZFFT function **********************/ -static void drfft_djbfft(double * inout, +void drfft_djbfft(double * inout, int n, int direction, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-13 03:41:02 UTC (rev 4299) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-13 03:50:11 UTC (rev 4300) @@ -162,7 +162,7 @@ static CacheManager djbfft_cmgr(10); /**************** ZFFT function **********************/ -static void zfft_djbfft(complex_double * inout, +void zfft_djbfft(complex_double * inout, int n, int direction, int howmany, int normalize) { int i; From scipy-svn at scipy.org Tue May 13 01:42:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 00:42:18 -0500 (CDT) Subject: [Scipy-svn] r4301 - in branches/refactor_fft/scipy/fftpack: . src src/djbfft Message-ID: <20080513054218.7AB6039C0CA@scipy.org> Author: cdavid Date: 2008-05-13 00:42:10 -0500 (Tue, 13 May 2008) New Revision: 4301 Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/djbfft/api.h branches/refactor_fft/scipy/fftpack/src/djbfft/common.h branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: djbfft backend is now a separate lib. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 03:50:11 UTC (rev 4300) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 05:42:10 UTC (rev 4301) @@ -8,15 +8,25 @@ from numpy.distutils.system_info import get_info config = Configuration('fftpack',parent_package, top_path) + backends = ['mkl', 'djbfft', 'fftw3', 'fftw2'] + info = dict([(k, False) for k in backends]) + djbfft_info = {} mkl_info = get_info('mkl') if mkl_info: mkl_info.setdefault('define_macros', []).append(('SCIPY_MKL_H', None)) fft_opt_info = mkl_info + info['mkl'] = True else: - fft_opt_info = get_info('fftw3') or get_info('fftw2') \ - or get_info('dfftw') + # Take the first in the list + for b in ['fftw3', 'fftw2']: + tmp = get_info(b) + if tmp: + fft_opt_info = tmp + info[b] = True + break djbfft_info = get_info('djbfft') + info['djbfft'] = True config.add_data_dir('tests') config.add_data_dir('benchmarks') @@ -24,6 +34,20 @@ config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) + backends_src = {} + backends_src['djbfft'] = [join('src/djbfft/', i) for i in + ['zfft.cxx', 'drfft.cxx']] + backends_src['fftw3'] = [join('src/fftw3/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + + for b in ['djbfft']: + if info[b]: + config.add_library('%s_backend' % b, + sources = backends_src[b], + include_dirs = ['src', djbfft_info['include_dirs'], + fft_opt_info['include_dirs']]) + + sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] config.add_extension('_fftpack', Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-13 03:50:11 UTC (rev 4300) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-13 05:42:10 UTC (rev 4301) @@ -1,10 +1,21 @@ #ifndef _SCIPY_FFTPACK_DJBFFT_API_H_ #define _SCIPY_FFTPACK_DJBFFT_API_H_ +#include "fftpack.h" + void drfft_djbfft(double * inout, int n, int direction, int howmany, int normalize); void zfft_djbfft(complex_double * inout, int n, int direction, int howmany, int normalize); +#define complex8 complex_double +#define COMPLEX8_H + +extern "C" { +#include +#include +#include +}; + #endif Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-13 03:50:11 UTC (rev 4300) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-13 05:42:10 UTC (rev 4301) @@ -3,8 +3,6 @@ #include -#include "api.h" - namespace fft { class DJBFFTCacheId : public CacheId { Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-13 03:50:11 UTC (rev 4300) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-13 05:42:10 UTC (rev 4301) @@ -1,5 +1,5 @@ /* - * Last Change: Tue May 13 12:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J * * Original code by Pearu Peterson. */ @@ -14,6 +14,7 @@ #include #include "common.h" +#include "api.h" #ifdef WITH_FFTW3 #define drfft_def drfft_fftw3 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-13 03:50:11 UTC (rev 4300) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-13 05:42:10 UTC (rev 4301) @@ -3,8 +3,10 @@ * * zfft_def is the function * used for size different than 2^N */ +#include #include "common.h" +#include "api.h" #ifdef WITH_FFTWORK #define zfft_def zfft_fftwork @@ -16,6 +18,8 @@ #define zfft_def zfft_fftpack #endif +using namespace fft; + class DJBFFTCache: public Cache { public: DJBFFTCache(const DJBFFTCacheId& id); Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 03:50:11 UTC (rev 4300) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 05:42:10 UTC (rev 4301) @@ -13,35 +13,28 @@ typedef struct {double r,i;} complex_double; typedef struct {float r,i;} complex_float; -#ifdef __cplusplus extern "C" { -#endif void init_convolution_kernel(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist); void convolve(int n,double* inout,double* omega,int swap_real_imag); void convolve_z(int n,double* inout,double* omega_real,double* omega_imag); -#ifdef __cplusplus + +void drfft_fftpack(double *inout, int n, int direction, int howmany, + int normalize); +void zfft_fftpack(complex_double * inout, + int n, int direction, int howmany, int normalize); +void zfftnd_fftpack(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); }; -#endif extern int ispow2le2e30(int n); extern int ispow2le2e13(int n); #ifdef SCIPY_DJBFFT_H -#ifdef __cplusplus -extern "C" { -#endif #define WITH_DJBFFT -#define complex8 complex_double -#define COMPLEX8_H -#include -#include -#include -#ifdef __cplusplus -} #endif -#endif #ifdef SCIPY_MKL_H #define WITH_MKL From scipy-svn at scipy.org Tue May 13 01:48:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 00:48:32 -0500 (CDT) Subject: [Scipy-svn] r4302 - in branches/refactor_fft/scipy/fftpack: . src src/fftw3 Message-ID: <20080513054832.98FA039C0CA@scipy.org> Author: cdavid Date: 2008-05-13 00:48:23 -0500 (Tue, 13 May 2008) New Revision: 4302 Added: branches/refactor_fft/scipy/fftpack/src/fftw3/api.h Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack.h branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx Log: fftw3 backend is now a separate lib. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 05:42:10 UTC (rev 4301) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 05:48:23 UTC (rev 4302) @@ -40,14 +40,13 @@ backends_src['fftw3'] = [join('src/fftw3/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - for b in ['djbfft']: + for b in ['djbfft', 'fftw3']: if info[b]: config.add_library('%s_backend' % b, sources = backends_src[b], include_dirs = ['src', djbfft_info['include_dirs'], fft_opt_info['include_dirs']]) - sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] config.add_extension('_fftpack', Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 05:42:10 UTC (rev 4301) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 05:48:23 UTC (rev 4302) @@ -13,7 +13,9 @@ typedef struct {double r,i;} complex_double; typedef struct {float r,i;} complex_float; +#ifdef __cplusplus extern "C" { +#endif void init_convolution_kernel(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist); @@ -27,7 +29,9 @@ void zfftnd_fftpack(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize); +#ifdef __cplusplus }; +#endif extern int ispow2le2e30(int n); extern int ispow2le2e13(int n); @@ -43,7 +47,6 @@ #ifdef SCIPY_FFTW3_H #define WITH_FFTW3 -#include #endif #ifdef SCIPY_DFFTW_H Added: branches/refactor_fft/scipy/fftpack/src/fftw3/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-13 05:42:10 UTC (rev 4301) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-13 05:48:23 UTC (rev 4302) @@ -0,0 +1,16 @@ +#ifndef _SCIPY_FFTPACK_FFTW3_API_H_ +#define _SCIPY_FFTPACK_FFTW3_API_H_ + +#include "fftpack.h" + +void drfft_fftw3(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_fftw3(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_fftw3(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-13 05:42:10 UTC (rev 4301) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-13 05:48:23 UTC (rev 4302) @@ -1,5 +1,5 @@ /* - * Last Change: Tue May 13 12:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J * * RFFTW3 implementation * @@ -9,7 +9,10 @@ #include #include +#include + #include "common.h" +#include "api.h" using namespace fft; @@ -88,7 +91,7 @@ static CacheManager drfftw3_cmgr(10); -static void drfft_fftw3(double *inout, int n, int direction, int +void drfft_fftw3(double *inout, int n, int direction, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-13 05:42:10 UTC (rev 4301) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-13 05:48:23 UTC (rev 4302) @@ -1,7 +1,10 @@ #include #include +#include + #include "common.h" +#include "api.h" using namespace fft; @@ -62,7 +65,7 @@ static CacheManager zfftw3_cmgr(10); -static void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, +void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, int normalize) { fftw_complex *ptr = (fftw_complex*)inout; Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-13 05:42:10 UTC (rev 4301) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-13 05:48:23 UTC (rev 4302) @@ -3,12 +3,15 @@ * * Original code by Pearu Peaterson * - * Last Change: Tue May 13 12:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J */ #include #include +#include + #include "common.h" +#include "api.h" using namespace fft; From scipy-svn at scipy.org Tue May 13 01:55:21 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 00:55:21 -0500 (CDT) Subject: [Scipy-svn] r4303 - in branches/refactor_fft/scipy/fftpack: . src src/fftw Message-ID: <20080513055521.2A8D839C0CA@scipy.org> Author: cdavid Date: 2008-05-13 00:55:12 -0500 (Tue, 13 May 2008) New Revision: 4303 Added: branches/refactor_fft/scipy/fftpack/src/fftw/api.h Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack.cxx branches/refactor_fft/scipy/fftpack/src/fftpack.h branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx Log: fftw is now a separate lib. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 05:55:12 UTC (rev 4303) @@ -8,7 +8,7 @@ from numpy.distutils.system_info import get_info config = Configuration('fftpack',parent_package, top_path) - backends = ['mkl', 'djbfft', 'fftw3', 'fftw2'] + backends = ['mkl', 'djbfft', 'fftw3', 'fftw'] info = dict([(k, False) for k in backends]) djbfft_info = {} @@ -19,7 +19,7 @@ info['mkl'] = True else: # Take the first in the list - for b in ['fftw3', 'fftw2']: + for b in ['fftw3', 'fftw']: tmp = get_info(b) if tmp: fft_opt_info = tmp @@ -39,8 +39,10 @@ ['zfft.cxx', 'drfft.cxx']] backends_src['fftw3'] = [join('src/fftw3/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + backends_src['fftw'] = [join('src/fftw/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - for b in ['djbfft', 'fftw3']: + for b in ['djbfft', 'fftw3', 'fftw']: if info[b]: config.add_library('%s_backend' % b, sources = backends_src[b], Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 05:55:12 UTC (rev 4303) @@ -43,19 +43,6 @@ #include "fftpack/zfftnd.cxx" #include "fftpack/zfft.cxx" -#if defined(WITH_FFTW) || defined(WITH_MKL) -static int equal_dims(int rank,int *dims1,int *dims2) -{ - int i; - for (i = 0; i < rank; ++i) { - if (dims1[i] != dims2[i]) { - return 0; - } - } - return 1; -} -#endif - #ifdef WITH_FFTW3 #include "fftw3/drfft.cxx" #include "fftw3/zfft.cxx" Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 05:55:12 UTC (rev 4303) @@ -57,8 +57,6 @@ #ifdef SCIPY_FFTW_H #define WITH_FFTW -#include -#include #endif #if defined(NO_APPEND_FORTRAN) Added: branches/refactor_fft/scipy/fftpack/src/fftw/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-13 05:55:12 UTC (rev 4303) @@ -0,0 +1,16 @@ +#ifndef _SCIPY_FFTPACK_FFTW_API_H_ +#define _SCIPY_FFTPACK_FFTW_API_H_ + +#include "fftpack.h" + +void drfft_fftw(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_fftw(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_fftw(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-13 05:55:12 UTC (rev 4303) @@ -1,5 +1,5 @@ /* - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J * * FFTW2 implementation * @@ -7,7 +7,11 @@ */ #include +#include +#include + #include "cycliccache.h" +#include "api.h" using namespace fft; @@ -101,7 +105,7 @@ CacheManager rfftw_cmgr(10); -static void drfft_fftw(double *inout, int n, int dir, +void drfft_fftw(double *inout, int n, int dir, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-13 05:55:12 UTC (rev 4303) @@ -1,6 +1,10 @@ #include +#include +#include + #include "cycliccache.h" +#include "api.h" using namespace fft; @@ -64,7 +68,7 @@ CacheManager fftw_cmgr(10); -extern void zfft_fftw(complex_double * inout, int n, +void zfft_fftw(complex_double * inout, int n, int dir, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-13 05:48:23 UTC (rev 4302) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-13 05:55:12 UTC (rev 4303) @@ -3,15 +3,30 @@ * * Original code by Pearu Peaterson * - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J */ #include #include +#include +#include + #include +#include "api.h" using namespace fft; +static int equal_dims(int rank,int *dims1,int *dims2) +{ + int i; + for (i = 0; i < rank; ++i) { + if (dims1[i] != dims2[i]) { + return 0; + } + } + return 1; +} + class NDFFTWCacheId { public: NDFFTWCacheId(int rank, int *dims, int dir, int flags); @@ -146,7 +161,7 @@ static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); -extern void zfftnd_fftw(complex_double * inout, int rank, +void zfftnd_fftw(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) { From scipy-svn at scipy.org Tue May 13 02:14:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 01:14:07 -0500 (CDT) Subject: [Scipy-svn] r4304 - in branches/refactor_fft/scipy/fftpack: . src/fftpack Message-ID: <20080513061407.092A039C14B@scipy.org> Author: cdavid Date: 2008-05-13 01:14:01 -0500 (Tue, 13 May 2008) New Revision: 4304 Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx Log: fftpack is now a separate lib. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 05:55:12 UTC (rev 4303) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 06:14:01 UTC (rev 4304) @@ -8,8 +8,9 @@ from numpy.distutils.system_info import get_info config = Configuration('fftpack',parent_package, top_path) - backends = ['mkl', 'djbfft', 'fftw3', 'fftw'] + backends = ['mkl', 'djbfft', 'fftw3', 'fftw', 'fftpack'] info = dict([(k, False) for k in backends]) + info['fftpack'] = True djbfft_info = {} mkl_info = get_info('mkl') @@ -41,35 +42,31 @@ ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] backends_src['fftw'] = [join('src/fftw/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + backends_src['fftpack'] = [join('src/fftpack/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - for b in ['djbfft', 'fftw3', 'fftw']: + libs = ['dfftpack'] + for b in ['djbfft', 'fftw3', 'fftw', 'fftpack']: if info[b]: config.add_library('%s_backend' % b, sources = backends_src[b], include_dirs = ['src', djbfft_info['include_dirs'], fft_opt_info['include_dirs']]) + libs.append(b) sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] config.add_extension('_fftpack', sources=sources, - libraries=['dfftpack'], + libraries = libs, extra_info=[fft_opt_info, djbfft_info], - depends=['src/djbfft/zfft.cxx', 'src/fftw/zfft.cxx', 'src/fftpack/zfft.cxx', - 'src/fftw3/zfft.cxx', 'src/mkl/zfft.cxx', - 'src/djbfft/drfft.cxx', 'src/fftpack/drfft.cxx', - 'src/fftw3/drfft.cxx', 'src/fftw/drfft.cxx', - 'src/fftpack/zfftnd.cxx', 'src/fftw/zfftnd.cxx', - 'src/fftw3/zfftnd.cxx', 'src/mkl/zfftnd.cxx', - ], include_dirs = ['src'], ) config.add_extension('convolve', - sources=['convolve.pyf','src/convolve.cxx'], - libraries=['dfftpack'], - extra_info=[fft_opt_info, djbfft_info], - depends=['src/fftpack/convolve.cxx', 'src/fftw/convolve.cxx', "src/djbfft/convolve.cxx"], + sources = ['convolve.pyf','src/convolve.cxx'], + libraries = libs, + extra_info = [fft_opt_info, djbfft_info], include_dirs = ['src'], ) return config Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-13 05:55:12 UTC (rev 4303) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx 2008-05-13 06:14:01 UTC (rev 4304) @@ -1,17 +1,19 @@ /* - * Last Change: Mon May 12 10:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J * * FFTPACK implementation * * Original code by Pearu Peterson. */ +#include "api.h" + #include "common.h" using namespace fft; static CacheManager rfftpack_cmgr(10); -static void drfft_fftpack(double *inout, int n, int direction, int howmany, +void drfft_fftpack(double *inout, int n, int direction, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx 2008-05-13 05:55:12 UTC (rev 4303) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx 2008-05-13 06:14:01 UTC (rev 4304) @@ -1,5 +1,7 @@ #include +#include "api.h" + #include "cycliccache.h" extern "C" { @@ -68,7 +70,7 @@ static CacheManager fftpack_cmgr(10); -static void zfft_fftpack(complex_double * inout, +void zfft_fftpack(complex_double * inout, int n, int direction, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-13 05:55:12 UTC (rev 4303) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-13 06:14:01 UTC (rev 4304) @@ -3,10 +3,12 @@ * * Original code by Pearu Peaterson * - * Last Change: Sun May 11 09:00 PM 2008 J + * Last Change: Tue May 13 02:00 PM 2008 J */ #include +#include "api.h" + #include "cycliccache.h" extern "C" { From scipy-svn at scipy.org Tue May 13 03:32:50 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 02:32:50 -0500 (CDT) Subject: [Scipy-svn] r4305 - branches/refactor_fft/scipy/fftpack Message-ID: <20080513073250.A187639C2A0@scipy.org> Author: cdavid Date: 2008-05-13 02:32:46 -0500 (Tue, 13 May 2008) New Revision: 4305 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: More fixes for setup.py. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 06:14:01 UTC (rev 4304) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 07:32:46 UTC (rev 4305) @@ -10,7 +10,6 @@ backends = ['mkl', 'djbfft', 'fftw3', 'fftw', 'fftpack'] info = dict([(k, False) for k in backends]) - info['fftpack'] = True djbfft_info = {} mkl_info = get_info('mkl') @@ -19,15 +18,23 @@ fft_opt_info = mkl_info info['mkl'] = True else: - # Take the first in the list - for b in ['fftw3', 'fftw']: - tmp = get_info(b) - if tmp: - fft_opt_info = tmp - info[b] = True - break + def has_optimized_backend(): + # Take the first in the list + for b in ['fftw3', 'fftw']: + tmp = get_info(b) + if tmp: + fft_opt_info = tmp + info[b] = True + return True + return False + + if not has_optimized_backend(): + info['fftpack'] = True + fft_opt_info = {} + djbfft_info = get_info('djbfft') - info['djbfft'] = True + if djbfft_info: + info['djbfft'] = True config.add_data_dir('tests') config.add_data_dir('benchmarks') @@ -35,6 +42,7 @@ config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) + # Build backends for fftpack and convolve backends_src = {} backends_src['djbfft'] = [join('src/djbfft/', i) for i in ['zfft.cxx', 'drfft.cxx']] @@ -45,17 +53,28 @@ backends_src['fftpack'] = [join('src/fftpack/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - libs = ['dfftpack'] - for b in ['djbfft', 'fftw3', 'fftw', 'fftpack']: + libs = [] + + def build_backend(backend, opts): + libname = '%s_backend' % backend + config.add_library(libname, + sources = backends_src[backend], + include_dirs = ['src'] + [i['include_dirs'] for i in opts]) + libs.append(libname) + + for b in ['fftw3', 'fftw']: if info[b]: - config.add_library('%s_backend' % b, - sources = backends_src[b], - include_dirs = ['src', djbfft_info['include_dirs'], - fft_opt_info['include_dirs']]) - libs.append(b) + build_backend(b, [djbfft_info, fft_opt_info]) + if info['fftpack']: + build_backend('fftpack', []) + + if info['djbfft']: + build_backend('djbfft', [djbfft_info]) + sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] + libs.append('dfftpack') config.add_extension('_fftpack', sources=sources, libraries = libs, From scipy-svn at scipy.org Tue May 13 03:33:31 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 02:33:31 -0500 (CDT) Subject: [Scipy-svn] r4306 - in branches/refactor_fft/scipy/fftpack/src: . fftpack Message-ID: <20080513073331.14C2639C29C@scipy.org> Author: cdavid Date: 2008-05-13 02:33:26 -0500 (Tue, 13 May 2008) New Revision: 4306 Added: branches/refactor_fft/scipy/fftpack/src/fftpack/api.h Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/common.h Log: fftpack backend now works when split. Added: branches/refactor_fft/scipy/fftpack/src/fftpack/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/api.h 2008-05-13 07:32:46 UTC (rev 4305) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/api.h 2008-05-13 07:33:26 UTC (rev 4306) @@ -0,0 +1,16 @@ +#ifndef _SCIPY_FFTPACK_FFTPACK_API_H_ +#define _SCIPY_FFTPACK_FFTPACK_API_H_ + +#include "fftpack.h" + +void drfft_fftpack(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_fftpack(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_fftpack(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/common.h 2008-05-13 07:32:46 UTC (rev 4305) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/common.h 2008-05-13 07:33:26 UTC (rev 4306) @@ -4,15 +4,16 @@ #include #include "cycliccache.h" +#include "api.h" -namespace fft { - extern "C" { extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *); extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *); extern void F_FUNC(dffti, DFFTI) (int *, double *); }; +namespace fft { + class RFFTPackCacheId : public CacheId { public: RFFTPackCacheId(int n) : CacheId(n) {}; Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 07:32:46 UTC (rev 4305) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 07:33:26 UTC (rev 4306) @@ -39,10 +39,6 @@ * #endif */ -#include "fftpack/drfft.cxx" -#include "fftpack/zfftnd.cxx" -#include "fftpack/zfft.cxx" - #ifdef WITH_FFTW3 #include "fftw3/drfft.cxx" #include "fftw3/zfft.cxx" From scipy-svn at scipy.org Tue May 13 03:35:09 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 02:35:09 -0500 (CDT) Subject: [Scipy-svn] r4307 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513073509.5EAC539C288@scipy.org> Author: cdavid Date: 2008-05-13 02:35:05 -0500 (Tue, 13 May 2008) New Revision: 4307 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx Log: Do not include code, only header for djbfft imp of fftpack. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 07:33:26 UTC (rev 4306) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 07:35:05 UTC (rev 4307) @@ -79,8 +79,7 @@ * above) for non 2^n * size */ #ifdef WITH_DJBFFT - #include "djbfft/drfft.cxx" - #include "djbfft/zfft.cxx" + #include "djbfft/api.h" GEN_DRFFT_API(djbfft) GEN_ZFFT_API(djbfft) #endif From scipy-svn at scipy.org Tue May 13 04:09:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:09:36 -0500 (CDT) Subject: [Scipy-svn] r4308 - branches/refactor_fft/scipy/fftpack Message-ID: <20080513080936.3DA7239C13A@scipy.org> Author: cdavid Date: 2008-05-13 03:09:26 -0500 (Tue, 13 May 2008) New Revision: 4308 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Fix linking order issues. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 07:35:05 UTC (rev 4307) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:09:26 UTC (rev 4308) @@ -45,7 +45,7 @@ # Build backends for fftpack and convolve backends_src = {} backends_src['djbfft'] = [join('src/djbfft/', i) for i in - ['zfft.cxx', 'drfft.cxx']] + ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']] backends_src['fftw3'] = [join('src/fftw3/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] backends_src['fftw'] = [join('src/fftw/', i) for i in @@ -62,6 +62,14 @@ include_dirs = ['src'] + [i['include_dirs'] for i in opts]) libs.append(libname) + # NOTE: ORDER MATTERS !!!!!! The order in the libs list matters: don't + # change anything here if you don't know what you are doing, better ask the + # scipy-dev ML. If libfoo1 depends on libfoo2, -lfoo1 -lfoo2 works, but + # -lfoo2 -lfoo1 won't (and you don't know it at runtime, only at load + # time). + if info['djbfft']: + build_backend('djbfft', [djbfft_info]) + for b in ['fftw3', 'fftw']: if info[b]: build_backend(b, [djbfft_info, fft_opt_info]) @@ -69,12 +77,10 @@ if info['fftpack']: build_backend('fftpack', []) - if info['djbfft']: - build_backend('djbfft', [djbfft_info]) + libs.append('dfftpack') sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] - libs.append('dfftpack') config.add_extension('_fftpack', sources=sources, libraries = libs, @@ -83,7 +89,7 @@ ) config.add_extension('convolve', - sources = ['convolve.pyf','src/convolve.cxx'], + sources = ['convolve.pyf', 'src/convolve.cxx'], libraries = libs, extra_info = [fft_opt_info, djbfft_info], include_dirs = ['src'], From scipy-svn at scipy.org Tue May 13 04:12:34 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:12:34 -0500 (CDT) Subject: [Scipy-svn] r4309 - in branches/refactor_fft/scipy/fftpack/src: . djbfft fftpack Message-ID: <20080513081234.26CD039C140@scipy.org> Author: cdavid Date: 2008-05-13 03:12:24 -0500 (Tue, 13 May 2008) New Revision: 4309 Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/src/djbfft/api.h branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftpack.cxx branches/refactor_fft/scipy/fftpack/src/fftpack.h branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx Log: convolve now works with djbfft independant backend. Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-13 08:09:26 UTC (rev 4308) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-13 08:12:24 UTC (rev 4309) @@ -11,6 +11,25 @@ #include "fftpack.h" +#define GEN_CONVOLVE_API(name) \ +extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) \ +{\ + convolve_##name(n, inout, omega, swap_real_imag);\ +}\ +extern "C" void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) \ +{\ + convolve_z_##name(n, inout, omega_real, omega_imag);\ +}\ +extern "C" void init_convolution_kernel(int n,double* omega, int d, \ + double (*kernel_func)(int), \ + int zero_nyquist) \ +{\ + init_convolution_kernel_##name(n,omega, d, kernel_func, zero_nyquist);\ +} \ +extern "C" void destroy_convolve_cache(void) \ +{\ +} + /**************** FFTW *****************************/ #ifdef WITH_FFTW #include "fftw/convolve.cxx" @@ -68,5 +87,6 @@ #endif #ifdef WITH_DJBFFT - #include "djbfft/convolve.cxx" + #include "djbfft/api.h" + GEN_CONVOLVE_API(djbfft) #endif Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-13 08:09:26 UTC (rev 4308) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-13 08:12:24 UTC (rev 4309) @@ -3,12 +3,29 @@ #include "fftpack.h" +/* + * straight FFT api + */ void drfft_djbfft(double * inout, int n, int direction, int howmany, int normalize); void zfft_djbfft(complex_double * inout, int n, int direction, int howmany, int normalize); +/* + * Convolution api + */ +void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag); +void convolve_z_djbfft(int n, double *inout, double *omega_real, + double* omega_imag); + +void init_convolution_kernel_djbfft(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist); + +/* + * Common headers and def + */ #define complex8 complex_double #define COMPLEX8_H Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-13 08:09:26 UTC (rev 4308) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-13 08:12:24 UTC (rev 4309) @@ -2,6 +2,7 @@ #include #include "common.h" +#include "api.h" #ifdef WITH_FFTW #define convolve_def convolve_fftw @@ -172,13 +173,8 @@ static CacheManager ddjbfft_cmgr(20); -/* stub */ -extern "C" void destroy_convolve_cache() -{ -} - /**************** convolve **********************/ -static void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) +static void do_convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) { DDJBFFTCache *cache; @@ -186,8 +182,7 @@ cache->convolve(inout, omega, swap_real_imag); } -extern "C" -void convolve(int n, double *inout, double *omega, int swap_real_imag) +void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) { bool use_def = true; @@ -209,14 +204,14 @@ } if (!use_def) { - convolve_djbfft(n, inout, omega, swap_real_imag); + do_convolve_djbfft(n, inout, omega, swap_real_imag); } else { convolve_def(n, inout, omega, swap_real_imag); } } /**************** convolve **********************/ -static void convolve_z_djbfft(int n, double *inout, double *omega_real, +static void do_convolve_z_djbfft(int n, double *inout, double *omega_real, double *omega_imag) { DDJBFFTCache *cache; @@ -225,8 +220,7 @@ cache->convolve_z(inout, omega_real, omega_imag); } -extern "C" - void convolve_z(int n, double *inout, double *omega_real, +void convolve_z_djbfft(int n, double *inout, double *omega_real, double *omega_imag) { bool use_def = true; @@ -251,11 +245,11 @@ if (use_def) { convolve_z_def(n, inout, omega_real, omega_imag); } else { - convolve_z_djbfft(n, inout, omega_real, omega_imag); + do_convolve_z_djbfft(n, inout, omega_real, omega_imag); } } -static void init_convolution_kernel_djbfft(int n, double *omega, int d, +void do_init_convolution_kernel_djbfft(int n, double *omega, int d, double (*kernel_func) (int), int zero_nyquist) { @@ -312,8 +306,7 @@ free(f); } -extern "C" - void init_convolution_kernel(int n, double *omega, int d, +void init_convolution_kernel_djbfft(int n, double *omega, int d, double (*kernel_func) (int), int zero_nyquist) { @@ -345,7 +338,7 @@ init_convolution_kernel_def(n, omega, d, kernel_func, zero_nyquist); } else { - init_convolution_kernel_djbfft(n, omega, d, kernel_func, + do_init_convolution_kernel_djbfft(n, omega, d, kernel_func, zero_nyquist); } } Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx 2008-05-13 08:09:26 UTC (rev 4308) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx 2008-05-13 08:12:24 UTC (rev 4309) @@ -67,7 +67,7 @@ static CacheManager dfftpack_cmgr(20); -static void convolve_fftpack(int n,double* inout,double* omega,int swap_real_imag) +void convolve_fftpack(int n,double* inout,double* omega,int swap_real_imag) { DFFTPackCache* cache; @@ -75,7 +75,7 @@ cache->convolve(inout, omega, swap_real_imag); } -static void convolve_z_fftpack(int n,double* inout,double* omega_real,double* omega_imag) +void convolve_z_fftpack(int n,double* inout,double* omega_real,double* omega_imag) { DFFTPackCache* cache; Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 08:09:26 UTC (rev 4308) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 08:12:24 UTC (rev 4309) @@ -82,4 +82,5 @@ #include "djbfft/api.h" GEN_DRFFT_API(djbfft) GEN_ZFFT_API(djbfft) + GEN_ZFFTND_API(fftpack) #endif Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 08:09:26 UTC (rev 4308) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 08:12:24 UTC (rev 4309) @@ -16,11 +16,11 @@ #ifdef __cplusplus extern "C" { #endif -void init_convolution_kernel(int n,double* omega, int d, +void init_convolution_kernel_fftpack(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist); -void convolve(int n,double* inout,double* omega,int swap_real_imag); -void convolve_z(int n,double* inout,double* omega_real,double* omega_imag); +void convolve_fftpack(int n,double* inout,double* omega,int swap_real_imag); +void convolve_z_fftpack(int n,double* inout,double* omega_real,double* omega_imag); void drfft_fftpack(double *inout, int n, int direction, int howmany, int normalize); From scipy-svn at scipy.org Tue May 13 04:26:15 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:26:15 -0500 (CDT) Subject: [Scipy-svn] r4310 - in branches/refactor_fft/scipy/fftpack: . src/fftw Message-ID: <20080513082615.738D739C26E@scipy.org> Author: cdavid Date: 2008-05-13 03:26:09 -0500 (Tue, 13 May 2008) New Revision: 4310 Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftw/api.h branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx Log: fftw backend as a lib now works for convolve too. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:12:24 UTC (rev 4309) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:26:09 UTC (rev 4310) @@ -8,7 +8,7 @@ from numpy.distutils.system_info import get_info config = Configuration('fftpack',parent_package, top_path) - backends = ['mkl', 'djbfft', 'fftw3', 'fftw', 'fftpack'] + backends = ['mkl', 'djbfft', 'fftw3', 'fftw2', 'fftpack'] info = dict([(k, False) for k in backends]) djbfft_info = {} @@ -20,17 +20,17 @@ else: def has_optimized_backend(): # Take the first in the list - for b in ['fftw3', 'fftw']: + for b in ['fftw3', 'fftw2']: tmp = get_info(b) if tmp: - fft_opt_info = tmp + opt = tmp info[b] = True - return True + return opt return False - if not has_optimized_backend(): + fft_opt_info = has_optimized_backend() + if not fft_opt_info: info['fftpack'] = True - fft_opt_info = {} djbfft_info = get_info('djbfft') if djbfft_info: @@ -48,7 +48,7 @@ ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']] backends_src['fftw3'] = [join('src/fftw3/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - backends_src['fftw'] = [join('src/fftw/', i) for i in + backends_src['fftw2'] = [join('src/fftw/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] backends_src['fftpack'] = [join('src/fftpack/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] @@ -70,9 +70,9 @@ if info['djbfft']: build_backend('djbfft', [djbfft_info]) - for b in ['fftw3', 'fftw']: + for b in ['fftw3', 'fftw2']: if info[b]: - build_backend(b, [djbfft_info, fft_opt_info]) + build_backend(b, [fft_opt_info]) if info['fftpack']: build_backend('fftpack', []) Modified: branches/refactor_fft/scipy/fftpack/src/fftw/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-13 08:12:24 UTC (rev 4309) +++ branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-13 08:26:09 UTC (rev 4310) @@ -3,6 +3,9 @@ #include "fftpack.h" +/* + * straight FFT api + */ void drfft_fftw(double * inout, int n, int direction, int howmany, int normalize); @@ -13,4 +16,15 @@ int *dims, int direction, int howmany, int normalize); +/* + * Convolution api + */ +void convolve_fftw(int n, double *inout, double *omega, int swap_real_imag); +void convolve_z_fftw(int n, double *inout, double *omega_real, + double* omega_imag); + +void init_convolution_kernel_fftw(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist); + #endif Modified: branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-13 08:12:24 UTC (rev 4309) +++ branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-13 08:26:09 UTC (rev 4310) @@ -1,5 +1,10 @@ #include +#include +#include + +#include "api.h" + #include "cycliccache.h" using namespace fft; @@ -117,7 +122,6 @@ CacheManager drfftw_cmgr(20); /**************** convolve **********************/ -static void convolve_fftw(int n,double* inout,double* omega,int swap_real_imag) { DRFFTWCache *cache; @@ -127,7 +131,6 @@ } /**************** convolve **********************/ -static void convolve_z_fftw(int n,double* inout,double* omega_real,double* omega_imag) { DRFFTWCache *cache; @@ -136,7 +139,6 @@ cache->convolve_z(inout, omega_real, omega_imag); } -static void init_convolution_kernel_fftw(int n,double* omega, int d, double (*kernel_func)(int), int zero_nyquist) From scipy-svn at scipy.org Tue May 13 04:41:16 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:41:16 -0500 (CDT) Subject: [Scipy-svn] r4311 - branches/refactor_fft/scipy/fftpack Message-ID: <20080513084116.0C9BC39C04C@scipy.org> Author: cdavid Date: 2008-05-13 03:41:13 -0500 (Tue, 13 May 2008) New Revision: 4311 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Refactor a bit setup.py (still ugly, though). Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:26:09 UTC (rev 4310) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:41:13 UTC (rev 4311) @@ -3,45 +3,7 @@ from os.path import join -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - from numpy.distutils.system_info import get_info - config = Configuration('fftpack',parent_package, top_path) - - backends = ['mkl', 'djbfft', 'fftw3', 'fftw2', 'fftpack'] - info = dict([(k, False) for k in backends]) - - djbfft_info = {} - mkl_info = get_info('mkl') - if mkl_info: - mkl_info.setdefault('define_macros', []).append(('SCIPY_MKL_H', None)) - fft_opt_info = mkl_info - info['mkl'] = True - else: - def has_optimized_backend(): - # Take the first in the list - for b in ['fftw3', 'fftw2']: - tmp = get_info(b) - if tmp: - opt = tmp - info[b] = True - return opt - return False - - fft_opt_info = has_optimized_backend() - if not fft_opt_info: - info['fftpack'] = True - - djbfft_info = get_info('djbfft') - if djbfft_info: - info['djbfft'] = True - - config.add_data_dir('tests') - config.add_data_dir('benchmarks') - - config.add_library('dfftpack', - sources=[join('dfftpack','*.f')]) - +def build_backends(config, opts, info, djbfft_info, fft_opt_info): # Build backends for fftpack and convolve backends_src = {} backends_src['djbfft'] = [join('src/djbfft/', i) for i in @@ -49,9 +11,9 @@ backends_src['fftw3'] = [join('src/fftw3/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] backends_src['fftw2'] = [join('src/fftw/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] backends_src['fftpack'] = [join('src/fftpack/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] libs = [] @@ -78,20 +40,71 @@ build_backend('fftpack', []) libs.append('dfftpack') + return libs +def get_available_backends(): + from numpy.distutils.system_info import get_info + backends = ['mkl', 'djbfft', 'fftw3', 'fftw2', 'fftpack'] + info = dict([(k, False) for k in backends]) + + djbfft_info = {} + mkl_info = get_info('mkl') + if mkl_info: + mkl_info.setdefault('define_macros', []).append(('SCIPY_MKL_H', None)) + fft_opt_info = mkl_info + info['mkl'] = True + else: + def has_optimized_backend(): + # Take the first in the list + for b in ['fftw3', 'fftw2']: + tmp = get_info(b) + if tmp: + opt = tmp + info[b] = True + return opt + return {} + + fft_opt_info = has_optimized_backend() + if not fft_opt_info: + info['fftpack'] = True + + djbfft_info = get_info('djbfft') + if djbfft_info: + info['djbfft'] = True + + return info, djbfft_info, fft_opt_info + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('fftpack',parent_package, top_path) + + info, djbfft_info, fft_opt_info = get_available_backends() + opts = [fft_opt_info] + if djbfft_info: + opts.append(djbfft_info) + + libs = build_backends(config, opts, info, djbfft_info, fft_opt_info) + + config.add_data_dir('tests') + config.add_data_dir('benchmarks') + + config.add_library('dfftpack', + sources=[join('dfftpack','*.f')]) + sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] + # Build the python extensions config.add_extension('_fftpack', sources=sources, libraries = libs, - extra_info=[fft_opt_info, djbfft_info], + extra_info = opts, include_dirs = ['src'], ) config.add_extension('convolve', sources = ['convolve.pyf', 'src/convolve.cxx'], libraries = libs, - extra_info = [fft_opt_info, djbfft_info], + extra_info = opts, include_dirs = ['src'], ) return config From scipy-svn at scipy.org Tue May 13 04:42:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:42:07 -0500 (CDT) Subject: [Scipy-svn] r4312 - in branches/refactor_fft/scipy/fftpack/src: . fftw3 Message-ID: <20080513084207.B6DAF39C04C@scipy.org> Author: cdavid Date: 2008-05-13 03:42:02 -0500 (Tue, 13 May 2008) New Revision: 4312 Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/api.h Log: Do not include cxx files anymore in convolve module source. Modified: branches/refactor_fft/scipy/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-13 08:41:13 UTC (rev 4311) +++ branches/refactor_fft/scipy/fftpack/src/convolve.cxx 2008-05-13 08:42:02 UTC (rev 4312) @@ -32,56 +32,18 @@ /**************** FFTW *****************************/ #ifdef WITH_FFTW -#include "fftw/convolve.cxx" +#include "fftw/api.h" #ifndef WITH_DJBFFT -extern "C" void destroy_convolve_cache(void) -{ -} - -extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) -{ - convolve_fftw(n, inout, omega, swap_real_imag); -} - -extern "C" void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) -{ - convolve_z_fftw(n, inout, omega_real, omega_imag); -} - -extern "C" void init_convolution_kernel(int n,double* omega, int d, - double (*kernel_func)(int), - int zero_nyquist) -{ - init_convolution_kernel_fftw(n, omega, d, kernel_func, zero_nyquist); -} + GEN_CONVOLVE_API(fftw) #endif #else /**************** FFTPACK ZFFT **********************/ -#include "fftpack/convolve.cxx" +#include "fftpack/api.h" #ifndef WITH_DJBFFT -extern "C" void destroy_convolve_cache(void) -{ -} - -extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) -{ - convolve_fftpack(n, inout, omega, swap_real_imag); -} - -extern "C" void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) -{ - convolve_z_fftpack(n, inout, omega_real, omega_imag); -} - -extern "C" void init_convolution_kernel(int n,double* omega, int d, - double (*kernel_func)(int), - int zero_nyquist) -{ - init_convolution_kernel_fftpack(n, omega, d, kernel_func, zero_nyquist); -} + GEN_CONVOLVE_API(fftpack) #endif #endif Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-13 08:41:13 UTC (rev 4311) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-13 08:42:02 UTC (rev 4312) @@ -3,6 +3,9 @@ #include "fftpack.h" +/* + * straight FFT api + */ void drfft_fftw3(double * inout, int n, int direction, int howmany, int normalize); From scipy-svn at scipy.org Tue May 13 04:53:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:53:07 -0500 (CDT) Subject: [Scipy-svn] r4313 - branches/refactor_fft/scipy/fftpack Message-ID: <20080513085307.89D1A39C140@scipy.org> Author: cdavid Date: 2008-05-13 03:52:59 -0500 (Tue, 13 May 2008) New Revision: 4313 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: More quirks in setup.py Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:42:02 UTC (rev 4312) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:52:59 UTC (rev 4313) @@ -43,6 +43,7 @@ return libs def get_available_backends(): + # XXX: This whole thing is just a big mess... from numpy.distutils.system_info import get_info backends = ['mkl', 'djbfft', 'fftw3', 'fftw2', 'fftpack'] info = dict([(k, False) for k in backends]) @@ -54,19 +55,17 @@ fft_opt_info = mkl_info info['mkl'] = True else: - def has_optimized_backend(): - # Take the first in the list - for b in ['fftw3', 'fftw2']: - tmp = get_info(b) - if tmp: - opt = tmp - info[b] = True - return opt - return {} - - fft_opt_info = has_optimized_backend() - if not fft_opt_info: + fft_opt_info = get_info('fftw3') + if fft_opt_info: + info['fftw3'] = True + # We need fftpack for convolve (no fftw3 backend) info['fftpack'] = True + else: + fft_opt_info = get_info('fftw2') + if not fft_opt_info: + info['fftpack'] = True + else: + info['fftw2'] = True djbfft_info = get_info('djbfft') if djbfft_info: From scipy-svn at scipy.org Tue May 13 04:53:31 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 03:53:31 -0500 (CDT) Subject: [Scipy-svn] r4314 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513085331.EB21539C140@scipy.org> Author: cdavid Date: 2008-05-13 03:53:28 -0500 (Tue, 13 May 2008) New Revision: 4314 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx Log: Do not include cxx files anymore in fftpack, only use headers. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 08:52:59 UTC (rev 4313) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 08:53:28 UTC (rev 4314) @@ -40,24 +40,21 @@ */ #ifdef WITH_FFTW3 - #include "fftw3/drfft.cxx" - #include "fftw3/zfft.cxx" - #include "fftw3/zfftnd.cxx" + #include "fftw3/api.h" #ifndef WITH_DJBFFT GEN_ZFFT_API(fftw3) GEN_DRFFT_API(fftw3) GEN_ZFFTND_API(fftw3) #endif #elif defined WITH_FFTW - #include "fftw/drfft.cxx" - #include "fftw/zfft.cxx" - #include "fftw/zfftnd.cxx" + #include "fftw/api.h" #ifndef WITH_DJBFFT GEN_ZFFT_API(fftw) GEN_DRFFT_API(fftw) GEN_ZFFTND_API(fftw) #endif #elif defined WITH_MKL +#error MKL backend not supported ! #include "mkl/zfft.cxx" #include "mkl/zfftnd.cxx" #ifndef WITH_DJBFFT From scipy-svn at scipy.org Tue May 13 05:06:09 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:06:09 -0500 (CDT) Subject: [Scipy-svn] r4315 - in branches/refactor_fft/scipy/fftpack: . src src/mkl Message-ID: <20080513090609.6716BC7C011@scipy.org> Author: cdavid Date: 2008-05-13 04:06:02 -0500 (Tue, 13 May 2008) New Revision: 4315 Modified: branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack.cxx branches/refactor_fft/scipy/fftpack/src/fftpack.h branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Log: Fixing mkl backend. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 08:53:28 UTC (rev 4314) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-13 09:06:02 UTC (rev 4315) @@ -14,6 +14,8 @@ ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] backends_src['fftpack'] = [join('src/fftpack/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] + backends_src['mkl'] = [join('src/mkl/', i) for i in + ['zfft.cxx', 'zfftnd.cxx']] libs = [] @@ -29,6 +31,9 @@ # scipy-dev ML. If libfoo1 depends on libfoo2, -lfoo1 -lfoo2 works, but # -lfoo2 -lfoo1 won't (and you don't know it at runtime, only at load # time). + if info['mkl']: + build_backend('mkl', [fft_opt_info]) + if info['djbfft']: build_backend('djbfft', [djbfft_info]) @@ -54,6 +59,8 @@ mkl_info.setdefault('define_macros', []).append(('SCIPY_MKL_H', None)) fft_opt_info = mkl_info info['mkl'] = True + # We need fftpack for convolve and real transforms + info['fftpack'] = True else: fft_opt_info = get_info('fftw3') if fft_opt_info: Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 08:53:28 UTC (rev 4314) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 09:06:02 UTC (rev 4315) @@ -54,9 +54,7 @@ GEN_ZFFTND_API(fftw) #endif #elif defined WITH_MKL -#error MKL backend not supported ! - #include "mkl/zfft.cxx" - #include "mkl/zfftnd.cxx" + #include "mkl/api.h" #ifndef WITH_DJBFFT GEN_ZFFT_API(mkl) GEN_ZFFTND_API(mkl) Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 08:53:28 UTC (rev 4314) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:06:02 UTC (rev 4315) @@ -42,7 +42,6 @@ #ifdef SCIPY_MKL_H #define WITH_MKL -#include #endif #ifdef SCIPY_FFTW3_H Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-13 08:53:28 UTC (rev 4314) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-13 09:06:02 UTC (rev 4315) @@ -1,5 +1,8 @@ #include +#include + +#include "api.h" #include "cycliccache.h" using namespace fft; @@ -52,7 +55,7 @@ CacheManager zmkl_cmgr(10); -static void zfft_mkl(complex_double * inout, +void zfft_mkl(complex_double * inout, int n, int direction, int howmany, int normalize) { int i; Modified: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-13 08:53:28 UTC (rev 4314) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-13 09:06:02 UTC (rev 4315) @@ -3,14 +3,28 @@ * * Original code by David M. Cooke * - * Last Change: Tue May 13 12:00 PM 2008 J + * Last Change: Tue May 13 05:00 PM 2008 J */ #include +#include + +#include "api.h" #include "cycliccache.h" using namespace fft; +static int equal_dims(int rank,int *dims1,int *dims2) +{ + int i; + for (i = 0; i < rank; ++i) { + if (dims1[i] != dims2[i]) { + return 0; + } + } + return 1; +} + class NDMKLCacheId { public: NDMKLCacheId(int rank, int *dim); @@ -157,7 +171,7 @@ static CacheManager < NDMKLCacheId, NDMKLCache > ndmkl_cmgr(10); -extern void zfftnd_mkl(complex_double * inout, int rank, +void zfftnd_mkl(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize) { From scipy-svn at scipy.org Tue May 13 05:07:37 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:07:37 -0500 (CDT) Subject: [Scipy-svn] r4316 - branches/refactor_fft/scipy/fftpack/src/mkl Message-ID: <20080513090737.2506939C2EC@scipy.org> Author: cdavid Date: 2008-05-13 04:07:33 -0500 (Tue, 13 May 2008) New Revision: 4316 Added: branches/refactor_fft/scipy/fftpack/src/mkl/api.h Log: Forgot to add one file for mkl backend. Added: branches/refactor_fft/scipy/fftpack/src/mkl/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/api.h 2008-05-13 09:06:02 UTC (rev 4315) +++ branches/refactor_fft/scipy/fftpack/src/mkl/api.h 2008-05-13 09:07:33 UTC (rev 4316) @@ -0,0 +1,16 @@ +#ifndef _SCIPY_FFTPACK_MKL_API_H_ +#define _SCIPY_FFTPACK_MKL_API_H_ + +#include "fftpack.h" + +/* + * straight FFT api + */ +void zfft_mkl(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_mkl(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif From scipy-svn at scipy.org Tue May 13 05:12:00 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:12:00 -0500 (CDT) Subject: [Scipy-svn] r4317 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513091200.3DF3439C13A@scipy.org> Author: cdavid Date: 2008-05-13 04:11:56 -0500 (Tue, 13 May 2008) New Revision: 4317 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx Log: Update comments for fftpack source file. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 09:07:33 UTC (rev 4316) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.cxx 2008-05-13 09:11:56 UTC (rev 4317) @@ -24,19 +24,10 @@ } -/* ************** Definition of backend specific functions ********* */ - /* - * To add a backend : - * - create a file drfft_name.c, where you define a function drfft_name where - * name is the name of your backend. If you do not use the GEN_CACHE macro, - * you will need to define a function void destroy_drname_caches(void), - * which can do nothing - * - in drfft.c, include the drfft_name.c file, and add the 3 following lines - * just after it: - * #ifndef WITH_DJBFFT - * GEN_PUBLIC_API(name) - * #endif + * Each backend define public functions in the backend specific api.h file, and + * depending on the options, we set the function called by the python extension + * to a backend specific one. */ #ifdef WITH_FFTW3 From scipy-svn at scipy.org Tue May 13 05:13:10 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:13:10 -0500 (CDT) Subject: [Scipy-svn] r4318 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513091310.603BA39C13A@scipy.org> Author: cdavid Date: 2008-05-13 04:13:06 -0500 (Tue, 13 May 2008) New Revision: 4318 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: remove dead code. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:11:56 UTC (rev 4317) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:13:06 UTC (rev 4318) @@ -33,9 +33,6 @@ }; #endif -extern int ispow2le2e30(int n); -extern int ispow2le2e13(int n); - #ifdef SCIPY_DJBFFT_H #define WITH_DJBFFT #endif @@ -48,12 +45,6 @@ #define WITH_FFTW3 #endif -#ifdef SCIPY_DFFTW_H -#define WITH_FFTW -#include -#include -#endif - #ifdef SCIPY_FFTW_H #define WITH_FFTW #endif From scipy-svn at scipy.org Tue May 13 05:15:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:15:07 -0500 (CDT) Subject: [Scipy-svn] r4319 - in branches/refactor_fft/scipy/fftpack/src: . djbfft Message-ID: <20080513091507.6BF7539C2EB@scipy.org> Author: cdavid Date: 2008-05-13 04:15:02 -0500 (Tue, 13 May 2008) New Revision: 4319 Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Putting djbfft specific macro in djbfft backend. Modified: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-13 09:13:06 UTC (rev 4318) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-13 09:15:02 UTC (rev 4319) @@ -3,6 +3,75 @@ #include +#define COPYSTD2DJB(SRC,DEST,N) { \ + int n2 = (N)/2,k,j; \ + *(DEST) = *(SRC); \ + *(DEST+1) = *(SRC+n2); \ + for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ + *(DEST+k) = *(SRC+n2+j); \ + *(DEST+k+1) = *(SRC+j); \ + } \ +} + +#define COPYINVDJB2STD(SRC,DEST,N) { \ + int n2 = (N)/2,k,j; \ + *(DEST) = *(SRC); \ + *(DEST+n2) = *(SRC+1); \ + for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ + *(DEST+n2+j) = *(SRC+k); \ + *(DEST+j) = *(SRC+k+1); \ + } \ +} + +#define COPYINVDJB2STD2(SRC,DEST,N) { \ + int n2 = (N)/2,k,j; \ + *(DEST) = *(SRC); \ + *(DEST+(N)-1) = *(SRC+(N)-1); \ + for (j=1,k=1;jn2) { \ + j = 2*(N-j); \ + *(DEST+j-1) = *(SRC+k); \ + *(DEST+j) = -*(SRC+k+1); \ + } else { \ + j *= 2; \ + *(DEST+j-1) = *(SRC+k); \ + *(DEST+j) = *(SRC+k+1); \ + } \ + } \ +} +#define COPYINVSTD2DJB(SRC,DEST,NORMALIZE,FRQ,N) { \ + int n2 = (N)/2,k,j; \ + if (NORMALIZE) { \ + *(DEST) = *(SRC); \ + *(DEST+1) = *(SRC+N-1); \ + } else { \ + *(DEST) = (*(SRC))*0.5; \ + *(DEST+1) = (*(SRC+N-1))*0.5; \ + } \ + for (k=2;kn2) { \ + j = 2*(N-j); \ + *(DEST+k) = *(SRC+j-1); \ + *(DEST+k+1) = -*(SRC+j); \ + } else { \ + j *= 2; \ + *(DEST+k) = *(SRC+j-1); \ + *(DEST+k+1) = *(SRC+j); \ + } \ + } \ +} namespace fft { class DJBFFTCacheId : public CacheId { Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:13:06 UTC (rev 4318) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:15:02 UTC (rev 4319) @@ -63,75 +63,6 @@ #endif #endif -#define COPYSTD2DJB(SRC,DEST,N) { \ - int n2 = (N)/2,k,j; \ - *(DEST) = *(SRC); \ - *(DEST+1) = *(SRC+n2); \ - for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ - *(DEST+k) = *(SRC+n2+j); \ - *(DEST+k+1) = *(SRC+j); \ - } \ -} - -#define COPYINVDJB2STD(SRC,DEST,N) { \ - int n2 = (N)/2,k,j; \ - *(DEST) = *(SRC); \ - *(DEST+n2) = *(SRC+1); \ - for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ - *(DEST+n2+j) = *(SRC+k); \ - *(DEST+j) = *(SRC+k+1); \ - } \ -} - -#define COPYINVDJB2STD2(SRC,DEST,N) { \ - int n2 = (N)/2,k,j; \ - *(DEST) = *(SRC); \ - *(DEST+(N)-1) = *(SRC+(N)-1); \ - for (j=1,k=1;jn2) { \ - j = 2*(N-j); \ - *(DEST+j-1) = *(SRC+k); \ - *(DEST+j) = -*(SRC+k+1); \ - } else { \ - j *= 2; \ - *(DEST+j-1) = *(SRC+k); \ - *(DEST+j) = *(SRC+k+1); \ - } \ - } \ -} -#define COPYINVSTD2DJB(SRC,DEST,NORMALIZE,FRQ,N) { \ - int n2 = (N)/2,k,j; \ - if (NORMALIZE) { \ - *(DEST) = *(SRC); \ - *(DEST+1) = *(SRC+N-1); \ - } else { \ - *(DEST) = (*(SRC))*0.5; \ - *(DEST+1) = (*(SRC+N-1))*0.5; \ - } \ - for (k=2;kn2) { \ - j = 2*(N-j); \ - *(DEST+k) = *(SRC+j-1); \ - *(DEST+k+1) = -*(SRC+j); \ - } else { \ - j *= 2; \ - *(DEST+k) = *(SRC+j-1); \ - *(DEST+k+1) = *(SRC+j); \ - } \ - } \ -} #define COPYRFFTW2STD(SRC,DEST,N) { \ int j,n2=(N)/2; \ *(DEST) = *(SRC); \ From scipy-svn at scipy.org Tue May 13 05:18:47 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:18:47 -0500 (CDT) Subject: [Scipy-svn] r4320 - in branches/refactor_fft/scipy/fftpack/src: . fftw fftw3 Message-ID: <20080513091847.0BEE939C034@scipy.org> Author: cdavid Date: 2008-05-13 04:18:42 -0500 (Tue, 13 May 2008) New Revision: 4320 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/common.h Log: Putting fftw specific macro in fftw backends. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:15:02 UTC (rev 4319) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-13 09:18:42 UTC (rev 4320) @@ -63,31 +63,4 @@ #endif #endif -#define COPYRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) { \ - *(DEST+2*n2-1) = *(SRC+n2); \ - if ((N)%2) \ - *(DEST+2*n2) = *(SRC+(N)-n2); \ - } \ -} -#define COPYINVRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) {\ - *(DEST+n2) = *(SRC+2*n2-1); \ - if ((N)%2) \ - *(DEST+(N)-n2) = *(SRC+2*n2); \ - } \ -} - #endif Modified: branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-13 09:15:02 UTC (rev 4319) +++ branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx 2008-05-13 09:18:42 UTC (rev 4320) @@ -1,5 +1,5 @@ /* - * Last Change: Tue May 13 02:00 PM 2008 J + * Last Change: Tue May 13 06:00 PM 2008 J * * FFTW2 implementation * @@ -12,6 +12,7 @@ #include "cycliccache.h" #include "api.h" +#include "common.h" using namespace fft; Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-13 09:15:02 UTC (rev 4319) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-13 09:18:42 UTC (rev 4320) @@ -5,6 +5,33 @@ #include +#define COPYRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) { \ + *(DEST+2*n2-1) = *(SRC+n2); \ + if ((N)%2) \ + *(DEST+2*n2) = *(SRC+(N)-n2); \ + } \ +} +#define COPYINVRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) {\ + *(DEST+n2) = *(SRC+2*n2-1); \ + if ((N)%2) \ + *(DEST+(N)-n2) = *(SRC+2*n2); \ + } \ +} + namespace fft { inline bool is_simd_aligned(const void * p) From scipy-svn at scipy.org Tue May 13 05:19:14 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:19:14 -0500 (CDT) Subject: [Scipy-svn] r4321 - branches/refactor_fft/scipy/fftpack/src/fftw Message-ID: <20080513091914.42DF439C034@scipy.org> Author: cdavid Date: 2008-05-13 04:19:07 -0500 (Tue, 13 May 2008) New Revision: 4321 Added: branches/refactor_fft/scipy/fftpack/src/fftw/common.h Log: Forgot to add a file for fftw backend. Added: branches/refactor_fft/scipy/fftpack/src/fftw/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/common.h 2008-05-13 09:18:42 UTC (rev 4320) +++ branches/refactor_fft/scipy/fftpack/src/fftw/common.h 2008-05-13 09:19:07 UTC (rev 4321) @@ -0,0 +1,31 @@ +#ifndef _SCIPY_FFTW_COMMON_H +#define _SCIPY_FFTW_COMMON_H + +#define COPYRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) { \ + *(DEST+2*n2-1) = *(SRC+n2); \ + if ((N)%2) \ + *(DEST+2*n2) = *(SRC+(N)-n2); \ + } \ +} +#define COPYINVRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) {\ + *(DEST+n2) = *(SRC+2*n2-1); \ + if ((N)%2) \ + *(DEST+(N)-n2) = *(SRC+2*n2); \ + } \ +} + +#endif From scipy-svn at scipy.org Tue May 13 05:19:40 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:19:40 -0500 (CDT) Subject: [Scipy-svn] r4322 - branches/refactor_fft/scipy/fftpack/src/fftw3 Message-ID: <20080513091940.3B2EB39C034@scipy.org> Author: cdavid Date: 2008-05-13 04:19:36 -0500 (Tue, 13 May 2008) New Revision: 4322 Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h Log: Fix a typo in guard against recursive include. Modified: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-13 09:19:07 UTC (rev 4321) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-13 09:19:36 UTC (rev 4322) @@ -1,5 +1,5 @@ -#ifndef _SCIPYFFT_FFTW_COMMON_H_ -#define _SCIPYFFT_FFTW_COMMON_H_ +#ifndef _SCIPYFFT_FFTW3_COMMON_H_ +#define _SCIPYFFT_FFTW3_COMMON_H_ #include "cycliccache.h" From scipy-svn at scipy.org Tue May 13 05:51:02 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 04:51:02 -0500 (CDT) Subject: [Scipy-svn] r4323 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080513095102.B68D239C3BC@scipy.org> Author: cdavid Date: 2008-05-13 04:50:58 -0500 (Tue, 13 May 2008) New Revision: 4323 Modified: branches/refactor_fft/scipy/fftpack/src/zrfft.c Log: zrfft.c is now pep7 compatible. Modified: branches/refactor_fft/scipy/fftpack/src/zrfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zrfft.c 2008-05-13 09:19:36 UTC (rev 4322) +++ branches/refactor_fft/scipy/fftpack/src/zrfft.c 2008-05-13 09:50:58 UTC (rev 4323) @@ -1,54 +1,56 @@ /* - Interface to various FFT libraries. - Double complex FFT and IFFT with zero imaginary input. - Author: Pearu Peterson, August 2002 - */ + Interface to various FFT libraries. + Double complex FFT and IFFT with zero imaginary input. +Author: Pearu Peterson, August 2002 +*/ #include "fftpack.h" -extern void drfft(double *inout,int n,int direction,int howmany,int normalize); +extern void drfft(double *inout, int n, int direction, int howmany, + int normalize); -extern void zrfft(complex_double *inout, - int n,int direction,int howmany,int normalize) { - int i,j,k; - double* ptr = (double *)inout; - switch (direction) { +extern void zrfft(complex_double * inout, int n, int direction, + int howmany, int normalize) +{ + int i, j, k; + double *ptr = (double *) inout; + switch (direction) { case 1: - for (i=0;i Author: cdavid Date: 2008-05-13 04:54:17 -0500 (Tue, 13 May 2008) New Revision: 4324 Modified: branches/refactor_fft/scipy/fftpack/src/zrfft.c Log: Forgot to remove tab. Modified: branches/refactor_fft/scipy/fftpack/src/zrfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zrfft.c 2008-05-13 09:50:58 UTC (rev 4323) +++ branches/refactor_fft/scipy/fftpack/src/zrfft.c 2008-05-13 09:54:17 UTC (rev 4324) @@ -7,50 +7,50 @@ #include "fftpack.h" extern void drfft(double *inout, int n, int direction, int howmany, - int normalize); + int normalize); extern void zrfft(complex_double * inout, int n, int direction, - int howmany, int normalize) + int howmany, int normalize) { int i, j, k; double *ptr = (double *) inout; switch (direction) { case 1: - for (i = 0; i < howmany; ++i, ptr += 2 * n) { - *(ptr + 1) = *ptr; - for (j = 2, k = 3; j < n; ++j, ++k) - *(ptr + k) = *(ptr + 2 * j); - drfft(ptr + 1, n, 1, 1, normalize); - *ptr = *(ptr + 1); - *(ptr + 1) = 0.0; - if (!(n % 2)) - *(ptr + n + 1) = 0.0; - for (j = 2, k = 2 * n - 2; j < n; j += 2, k -= 2) { - *(ptr + k) = *(ptr + j); - *(ptr + k + 1) = -(*(ptr + j + 1)); - } - } - break; + for (i = 0; i < howmany; ++i, ptr += 2 * n) { + *(ptr + 1) = *ptr; + for (j = 2, k = 3; j < n; ++j, ++k) + *(ptr + k) = *(ptr + 2 * j); + drfft(ptr + 1, n, 1, 1, normalize); + *ptr = *(ptr + 1); + *(ptr + 1) = 0.0; + if (!(n % 2)) + *(ptr + n + 1) = 0.0; + for (j = 2, k = 2 * n - 2; j < n; j += 2, k -= 2) { + *(ptr + k) = *(ptr + j); + *(ptr + k + 1) = -(*(ptr + j + 1)); + } + } + break; case -1: - for (i = 0; i < howmany; ++i, ptr += 2 * n) { - *(ptr + 1) = (*ptr); - for (j = 1, k = 2; j < n; ++j, ++k) - *(ptr + k) = (*(ptr + 2 * j)); - drfft(ptr + 1, n, 1, 1, normalize); - *ptr = *(ptr + 1); - *(ptr + 1) = 0.0; - if (!(n % 2)) - *(ptr + n + 1) = 0.0; - for (j = 2, k = 2 * n - 2; j < n; j += 2, k -= 2) { - double d; - *(ptr + k) = *(ptr + j); - d = *(ptr + j + 1); - *(ptr + k + 1) = d; - *(ptr + j + 1) = -d; - } - } - break; + for (i = 0; i < howmany; ++i, ptr += 2 * n) { + *(ptr + 1) = (*ptr); + for (j = 1, k = 2; j < n; ++j, ++k) + *(ptr + k) = (*(ptr + 2 * j)); + drfft(ptr + 1, n, 1, 1, normalize); + *ptr = *(ptr + 1); + *(ptr + 1) = 0.0; + if (!(n % 2)) + *(ptr + n + 1) = 0.0; + for (j = 2, k = 2 * n - 2; j < n; j += 2, k -= 2) { + double d; + *(ptr + k) = *(ptr + j); + d = *(ptr + j + 1); + *(ptr + k + 1) = d; + *(ptr + j + 1) = -d; + } + } + break; default: - fprintf(stderr, "zrfft: invalid direction=%d\n", direction); + fprintf(stderr, "zrfft: invalid direction=%d\n", direction); } } From scipy-svn at scipy.org Tue May 13 14:08:14 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 13:08:14 -0500 (CDT) Subject: [Scipy-svn] r4325 - trunk/scipy/weave Message-ID: <20080513180814.11AAC39C293@scipy.org> Author: rkern Date: 2008-05-13 13:08:11 -0500 (Tue, 13 May 2008) New Revision: 4325 Modified: trunk/scipy/weave/standard_array_spec.py Log: More const-correctness fixes from Norbert Nemec. Modified: trunk/scipy/weave/standard_array_spec.py =================================================================== --- trunk/scipy/weave/standard_array_spec.py 2008-05-13 09:54:17 UTC (rev 4324) +++ trunk/scipy/weave/standard_array_spec.py 2008-05-13 18:08:11 UTC (rev 4325) @@ -41,7 +41,7 @@ if (!PyArray_EquivTypenums(arr_type, numeric_type)) { - char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", + const char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", "int", "uint", "long", "ulong", "longlong", "ulonglong", "float", "double", "longdouble", "cfloat", "cdouble", "clongdouble", "object", "string", "unicode", "void", "ntype", @@ -66,7 +66,7 @@ } if (!PyArray_EquivTypenums(arr_type, numeric_type)) { - char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", + const char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", "int", "uint", "long", "ulong", "longlong", "ulonglong", "float", "double", "longdouble", "cfloat", "cdouble", "clongdouble", "object", "string", "unicode", "void", "ntype", From scipy-svn at scipy.org Tue May 13 18:42:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 May 2008 17:42:36 -0500 (CDT) Subject: [Scipy-svn] r4326 - trunk/scipy/stats Message-ID: <20080513224236.186DF39C05D@scipy.org> Author: oliphant Date: 2008-05-13 17:42:35 -0500 (Tue, 13 May 2008) New Revision: 4326 Modified: trunk/scipy/stats/stats.py Log: Fixed formula for standard error according to Greene -- Econometrics pg. 160. Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2008-05-13 18:08:11 UTC (rev 4325) +++ trunk/scipy/stats/stats.py 2008-05-13 22:42:35 UTC (rev 4326) @@ -1661,7 +1661,7 @@ prob = betai(0.5*df,0.5,df/(df+t*t)) slope = r_num / ss(xm) intercept = ymean - slope*xmean - sterrest = np.sqrt(1-r*r)*samplestd(y) + sterrest = np.sqrt((1-r*r)*ss(y) / ss(x) / df) return slope, intercept, r, prob, sterrest From scipy-svn at scipy.org Wed May 14 02:46:26 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 14 May 2008 01:46:26 -0500 (CDT) Subject: [Scipy-svn] r4327 - in branches/refactor_fft: . scipy/sparse scipy/sparse/tests scipy/stats scipy/weave Message-ID: <20080514064626.D56D539C316@scipy.org> Author: cdavid Date: 2008-05-14 01:46:10 -0500 (Wed, 14 May 2008) New Revision: 4327 Modified: branches/refactor_fft/ branches/refactor_fft/scipy/sparse/csr.py branches/refactor_fft/scipy/sparse/tests/test_base.py branches/refactor_fft/scipy/stats/stats.py branches/refactor_fft/scipy/weave/standard_array_spec.py Log: Merged revisions 4253-4326 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r4294 | wnbell | 2008-05-13 05:15:50 +0900 (Tue, 13 May 2008) | 4 lines fixed indexing bug reported by Robert Cimrman http://thread.gmane.org/gmane.comp.python.scientific.devel/7986 ........ r4325 | rkern | 2008-05-14 03:08:11 +0900 (Wed, 14 May 2008) | 1 line More const-correctness fixes from Norbert Nemec. ........ r4326 | oliphant | 2008-05-14 07:42:35 +0900 (Wed, 14 May 2008) | 1 line Fixed formula for standard error according to Greene -- Econometrics pg. 160. ........ Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4252 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4326 Modified: branches/refactor_fft/scipy/sparse/csr.py =================================================================== --- branches/refactor_fft/scipy/sparse/csr.py 2008-05-13 22:42:35 UTC (rev 4326) +++ branches/refactor_fft/scipy/sparse/csr.py 2008-05-14 06:46:10 UTC (rev 4327) @@ -363,7 +363,8 @@ check_bounds( j0, j1, N ) indptr, indices, data = get_csr_submatrix( M, N, \ - self.indptr, self.indices, self.data, i0, i1, j0, j1 ) + self.indptr, self.indices, self.data, \ + int(i0), int(i1), int(j0), int(j1) ) shape = (i1 - i0, j1 - j0) Modified: branches/refactor_fft/scipy/sparse/tests/test_base.py =================================================================== --- branches/refactor_fft/scipy/sparse/tests/test_base.py 2008-05-13 22:42:35 UTC (rev 4326) +++ branches/refactor_fft/scipy/sparse/tests/test_base.py 2008-05-14 06:46:10 UTC (rev 4327) @@ -679,6 +679,13 @@ assert_equal(A[:,2].todense(),B[:,2]) assert_equal(A[3:4,9].todense(),B[3:4,9]) assert_equal(A[1:4,-5].todense(),B[1:4,-5]) + assert_equal(A[2:-1,3].todense(),B[2:-1,3]) + + # [1:2,1:2] + assert_equal(A[1:2,1:2].todense(),B[1:2,1:2]) + assert_equal(A[4:,3:].todense(),B[4:,3:]) + assert_equal(A[:4,:5].todense(),B[:4,:5]) + assert_equal(A[2:-1,:5].todense(),B[2:-1,:5]) # [1:2,[1,2]] assert_equal(A[:,[2,8,3,-1]].todense(),B[:,[2,8,3,-1]]) @@ -721,6 +728,13 @@ assert_equal(A[:,[1,3]][[2,4],:].todense(), B[:,[1,3]][[2,4],:] ) assert_equal(A[:,[-1,-3]][[2,-4],:].todense(), B[:,[-1,-3]][[2,-4],:] ) + + # Check bug reported by Robert Cimrman: + # http://thread.gmane.org/gmane.comp.python.scientific.devel/7986 + s = slice(numpy.int8(2),numpy.int8(4),None) + assert_equal(A[s,:].todense(), B[2:4,:]) + assert_equal(A[:,s].todense(), B[:,2:4]) + class _TestArithmetic: """ Test real/complex arithmetic Modified: branches/refactor_fft/scipy/stats/stats.py =================================================================== --- branches/refactor_fft/scipy/stats/stats.py 2008-05-13 22:42:35 UTC (rev 4326) +++ branches/refactor_fft/scipy/stats/stats.py 2008-05-14 06:46:10 UTC (rev 4327) @@ -1661,7 +1661,7 @@ prob = betai(0.5*df,0.5,df/(df+t*t)) slope = r_num / ss(xm) intercept = ymean - slope*xmean - sterrest = np.sqrt(1-r*r)*samplestd(y) + sterrest = np.sqrt((1-r*r)*ss(y) / ss(x) / df) return slope, intercept, r, prob, sterrest Modified: branches/refactor_fft/scipy/weave/standard_array_spec.py =================================================================== --- branches/refactor_fft/scipy/weave/standard_array_spec.py 2008-05-13 22:42:35 UTC (rev 4326) +++ branches/refactor_fft/scipy/weave/standard_array_spec.py 2008-05-14 06:46:10 UTC (rev 4327) @@ -41,7 +41,7 @@ if (!PyArray_EquivTypenums(arr_type, numeric_type)) { - char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", + const char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", "int", "uint", "long", "ulong", "longlong", "ulonglong", "float", "double", "longdouble", "cfloat", "cdouble", "clongdouble", "object", "string", "unicode", "void", "ntype", @@ -66,7 +66,7 @@ } if (!PyArray_EquivTypenums(arr_type, numeric_type)) { - char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", + const char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort", "int", "uint", "long", "ulong", "longlong", "ulonglong", "float", "double", "longdouble", "cfloat", "cdouble", "clongdouble", "object", "string", "unicode", "void", "ntype", From scipy-svn at scipy.org Thu May 15 08:26:39 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:26:39 -0500 (CDT) Subject: [Scipy-svn] r4328 - branches/refactor_fft/scipy/fftpack Message-ID: <20080515122639.B511F39C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:26:31 -0500 (Thu, 15 May 2008) New Revision: 4328 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Do not build any optimized backend anymore. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-14 06:46:10 UTC (rev 4327) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:26:31 UTC (rev 4328) @@ -84,33 +84,26 @@ from numpy.distutils.misc_util import Configuration config = Configuration('fftpack',parent_package, top_path) - info, djbfft_info, fft_opt_info = get_available_backends() - opts = [fft_opt_info] - if djbfft_info: - opts.append(djbfft_info) - - libs = build_backends(config, opts, info, djbfft_info, fft_opt_info) - config.add_data_dir('tests') config.add_data_dir('benchmarks') config.add_library('dfftpack', sources=[join('dfftpack','*.f')]) - sources = ['fftpack.pyf', 'src/fftpack.cxx', 'src/zrfft.c'] + sources = ['fftpack.pyf', 'src/zrfft.c'] + for s in ["zfft.cxx", "zfftnd.cxx", "drfft.cxx"]: + sources.append(join('src/fftpack', s)) # Build the python extensions config.add_extension('_fftpack', sources=sources, - libraries = libs, - extra_info = opts, + libraries = ["dfftpack"], include_dirs = ['src'], ) config.add_extension('convolve', sources = ['convolve.pyf', 'src/convolve.cxx'], - libraries = libs, - extra_info = opts, + libraries = ["dfftpack"], include_dirs = ['src'], ) return config From scipy-svn at scipy.org Thu May 15 08:26:59 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:26:59 -0500 (CDT) Subject: [Scipy-svn] r4329 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080515122659.DEB1C39C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:26:51 -0500 (Thu, 15 May 2008) New Revision: 4329 Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h Log: Do not define backend specific symbols. Modified: branches/refactor_fft/scipy/fftpack/src/fftpack.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-15 12:26:31 UTC (rev 4328) +++ branches/refactor_fft/scipy/fftpack/src/fftpack.h 2008-05-15 12:26:51 UTC (rev 4329) @@ -6,9 +6,8 @@ #ifndef FFTPACK_H #define FFTPACK_H -#include #include -#include +#include typedef struct {double r,i;} complex_double; typedef struct {float r,i;} complex_float; @@ -33,22 +32,6 @@ }; #endif -#ifdef SCIPY_DJBFFT_H -#define WITH_DJBFFT -#endif - -#ifdef SCIPY_MKL_H -#define WITH_MKL -#endif - -#ifdef SCIPY_FFTW3_H -#define WITH_FFTW3 -#endif - -#ifdef SCIPY_FFTW_H -#define WITH_FFTW -#endif - #if defined(NO_APPEND_FORTRAN) #if defined(UPPERCASE_FORTRAN) #define F_FUNC(f,F) F From scipy-svn at scipy.org Thu May 15 08:27:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:27:32 -0500 (CDT) Subject: [Scipy-svn] r4330 - in branches/refactor_fft/scipy/fftpack: . src src/fftpack Message-ID: <20080515122732.CEE2839C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:27:12 -0500 (Thu, 15 May 2008) New Revision: 4330 Modified: branches/refactor_fft/scipy/fftpack/convolve.pyf branches/refactor_fft/scipy/fftpack/fftpack.pyf branches/refactor_fft/scipy/fftpack/setup.py branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/zrfft.c Log: Rename all public functions as *_fftpack, since we only use fftpack now. Modified: branches/refactor_fft/scipy/fftpack/convolve.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/convolve.pyf 2008-05-15 12:26:51 UTC (rev 4329) +++ branches/refactor_fft/scipy/fftpack/convolve.pyf 2008-05-15 12:27:12 UTC (rev 4330) @@ -13,35 +13,35 @@ python module convolve interface - subroutine init_convolution_kernel (n,omega,d,kernel_func,zero_nyquist) - intent(c) init_convolution_kernel + subroutine init_convolution_kernel_fftpack (n,omega,d,kernel_func,zero_nyquist) + intent(c) init_convolution_kernel_fftpack use convolve__user__routines external kernel_func integer intent(in,c),check(n>0) :: n integer intent(in,c),optional :: d = 0 real*8 intent(out,c),dimension(n),depend(n) :: omega integer intent(in,c),optional,depend(d) :: zero_nyquist = d%2 - end subroutine init_convolution_kernel + end subroutine init_convolution_kernel_fftpack - subroutine destroy_convolve_cache() - intent(c) destroy_convolve_cache - end subroutine destroy_convolve_cache + subroutine destroy_convolve_cache_fftpack() + intent(c) destroy_convolve_cache_fftpack + end subroutine destroy_convolve_cache_fftpack - subroutine convolve(n,x,omega,swap_real_imag) - intent(c) convolve + subroutine convolve_fftpack(n,x,omega,swap_real_imag) + intent(c) convolve_fftpack integer intent(c,hide),depend (x) :: n = len(x) real*8 intent(c,in,out,copy,out=y),dimension(n):: x real*8 intent(c,in,cache),dimension(n),depend(n) :: omega integer intent(c,in),optional :: swap_real_imag = 0 - end subroutine convolve + end subroutine convolve_fftpack - subroutine convolve_z(n,x,omega_real,omega_imag) - intent(c) convolve_z + subroutine convolve_z_fftpack(n,x,omega_real,omega_imag) + intent(c) convolve_z_fftpack integer intent(c,hide),depend (x) :: n = len(x) real*8 intent(c,in,out,copy,out=y),dimension(n):: x real*8 intent(c,in,cache),dimension(n),depend(n) :: omega_real real*8 intent(c,in,cache),dimension(n),depend(n) :: omega_imag - end subroutine convolve_z + end subroutine convolve_z_fftpack end interface end python module convolve Modified: branches/refactor_fft/scipy/fftpack/fftpack.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-15 12:26:51 UTC (rev 4329) +++ branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-15 12:27:12 UTC (rev 4330) @@ -4,9 +4,9 @@ python module _fftpack interface - subroutine zfft(x,n,direction,howmany,normalize) + subroutine zfft_fftpack(x,n,direction,howmany,normalize) ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft + intent(c) zfft_fftpack complex*16 intent(c,in,out,copy,out=y) :: x(*) integer optional,depend(x),intent(c,in) :: n=size(x) check(n>0) n @@ -15,11 +15,11 @@ integer optional,intent(c,in) :: direction = 1 integer optional,intent(c,in),depend(direction) & :: normalize = (direction<0) - end subroutine zfft + end subroutine zfft_fftpack - subroutine drfft(x,n,direction,howmany,normalize) + subroutine drfft_fftpack(x,n,direction,howmany,normalize) ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft + intent(c) drfft_fftpack real*8 intent(c,in,out,copy,out=y) :: x(*) integer optional,depend(x),intent(c,in) :: n=size(x) check(n>0&&n<=size(x)) n @@ -28,11 +28,11 @@ integer optional,intent(c,in) :: direction = 1 integer optional,intent(c,in),depend(direction) & :: normalize = (direction<0) - end subroutine drfft + end subroutine drfft_fftpack - subroutine zrfft(x,n,direction,howmany,normalize) + subroutine zrfft_fftpack(x,n,direction,howmany,normalize) ! y = zrfft(x[,n,direction,normalize,overwrite_x]) - intent(c) zrfft + intent(c) zrfft_fftpack complex*16 intent(c,in,out,overwrite,out=y) :: x(*) integer optional,depend(x),intent(c,in) :: n=size(x) check(n>0&&n<=size(x)) n @@ -41,11 +41,11 @@ integer optional,intent(c,in) :: direction = 1 integer optional,intent(c,in),depend(direction) & :: normalize = (direction<0) - end subroutine zrfft + end subroutine zrfft_fftpack - subroutine zfftnd(x,r,s,direction,howmany,normalize,j) + subroutine zfftnd_fftpack(x,r,s,direction,howmany,normalize,j) ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd + intent(c) zfftnd_fftpack complex*16 intent(c,in,out,copy,out=y) :: x(*) integer intent(c,hide),depend(x) :: r=old_rank(x) integer intent(c,hide) :: j=0 @@ -69,7 +69,7 @@ "inconsistency in x.shape and s argument"); & } & } - end subroutine zfftnd + end subroutine zfftnd_fftpack end interface end python module _fftpack Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:26:51 UTC (rev 4329) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:27:12 UTC (rev 4330) @@ -102,7 +102,7 @@ ) config.add_extension('convolve', - sources = ['convolve.pyf', 'src/convolve.cxx'], + sources = ['convolve.pyf', 'src/fftpack/convolve.cxx'], libraries = ["dfftpack"], include_dirs = ['src'], ) Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx 2008-05-15 12:26:51 UTC (rev 4329) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx 2008-05-15 12:27:12 UTC (rev 4330) @@ -1,5 +1,9 @@ #include "common.h" +extern "C" void destroy_convolve_cache_fftpack(void) +{ +} + using namespace fft; class DFFTPackCache : public RFFTPackCache { Modified: branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-15 12:26:51 UTC (rev 4329) +++ branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx 2008-05-15 12:27:12 UTC (rev 4330) @@ -12,7 +12,7 @@ #include "cycliccache.h" extern "C" { -extern void zfft(complex_double * inout, +extern void zfft_fftpack(complex_double * inout, int n, int direction, int howmany, int normalize); }; @@ -103,7 +103,7 @@ complex_double *tmp = m_wsave; complex_double *ptr = inout; - zfft(inout, dims[rank - 1], direction, howmany * sz / dims[rank - 1], + zfft_fftpack(inout, dims[rank - 1], direction, howmany * sz / dims[rank - 1], normalize); prepare(dims); @@ -116,7 +116,7 @@ } } flatten(tmp, ptr, rank, m_iptr[axis], dims[axis], 0, m_iptr); - zfft(tmp, dims[axis], direction, sz / dims[axis], normalize); + zfft_fftpack(tmp, dims[axis], direction, sz / dims[axis], normalize); flatten(ptr, tmp, rank, m_iptr[axis], dims[axis], 1, m_iptr); } } Modified: branches/refactor_fft/scipy/fftpack/src/zrfft.c =================================================================== --- branches/refactor_fft/scipy/fftpack/src/zrfft.c 2008-05-15 12:26:51 UTC (rev 4329) +++ branches/refactor_fft/scipy/fftpack/src/zrfft.c 2008-05-15 12:27:12 UTC (rev 4330) @@ -6,10 +6,7 @@ #include "fftpack.h" -extern void drfft(double *inout, int n, int direction, int howmany, - int normalize); - -extern void zrfft(complex_double * inout, int n, int direction, +extern void zrfft_fftpack(complex_double * inout, int n, int direction, int howmany, int normalize) { int i, j, k; @@ -20,7 +17,7 @@ *(ptr + 1) = *ptr; for (j = 2, k = 3; j < n; ++j, ++k) *(ptr + k) = *(ptr + 2 * j); - drfft(ptr + 1, n, 1, 1, normalize); + drfft_fftpack(ptr + 1, n, 1, 1, normalize); *ptr = *(ptr + 1); *(ptr + 1) = 0.0; if (!(n % 2)) @@ -36,7 +33,7 @@ *(ptr + 1) = (*ptr); for (j = 1, k = 2; j < n; ++j, ++k) *(ptr + k) = (*(ptr + 2 * j)); - drfft(ptr + 1, n, 1, 1, normalize); + drfft_fftpack(ptr + 1, n, 1, 1, normalize); *ptr = *(ptr + 1); *(ptr + 1) = 0.0; if (!(n % 2)) From scipy-svn at scipy.org Thu May 15 08:27:59 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:27:59 -0500 (CDT) Subject: [Scipy-svn] r4331 - in branches/refactor_fft/scipy/fftpack: . tests Message-ID: <20080515122759.43BD339C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:27:46 -0500 (Thu, 15 May 2008) New Revision: 4331 Modified: branches/refactor_fft/scipy/fftpack/basic.py branches/refactor_fft/scipy/fftpack/pseudo_diffs.py branches/refactor_fft/scipy/fftpack/tests/test_basic.py Log: reflect C api name changes in python modules. Modified: branches/refactor_fft/scipy/fftpack/basic.py =================================================================== --- branches/refactor_fft/scipy/fftpack/basic.py 2008-05-15 12:27:12 UTC (rev 4330) +++ branches/refactor_fft/scipy/fftpack/basic.py 2008-05-15 12:27:46 UTC (rev 4331) @@ -79,12 +79,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfft + work_function = fftpack.zfft_fftpack elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zrfft + work_function = fftpack.zrfft_fftpack #return _raw_fft(tmp,n,axis,1,overwrite_x,work_function) if n is None: @@ -117,12 +117,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfft + work_function = fftpack.zfft_fftpack elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zrfft + work_function = fftpack.zrfft_fftpack #return _raw_fft(tmp,n,axis,-1,overwrite_x,work_function) if n is None: @@ -169,7 +169,7 @@ tmp = asarray(x) if not numpy.isrealobj(tmp): raise TypeError,"1st argument must be real sequence" - work_function = fftpack.drfft + work_function = fftpack.drfft_fftpack return _raw_fft(tmp,n,axis,1,overwrite_x,work_function) @@ -213,7 +213,7 @@ tmp = asarray(x) if not numpy.isrealobj(tmp): raise TypeError,"1st argument must be real sequence" - work_function = fftpack.drfft + work_function = fftpack.drfft_fftpack return _raw_fft(tmp,n,axis,-1,overwrite_x,work_function) @@ -285,12 +285,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfftnd + work_function = fftpack.zfftnd_fftpack elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zfftnd + work_function = fftpack.zfftnd_fftpack return _raw_fftnd(tmp,shape,axes,1,overwrite_x,work_function) @@ -313,12 +313,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfftnd + work_function = fftpack.zfftnd_fftpack elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zfftnd + work_function = fftpack.zfftnd_fftpack return _raw_fftnd(tmp,shape,axes,-1,overwrite_x,work_function) Modified: branches/refactor_fft/scipy/fftpack/pseudo_diffs.py =================================================================== --- branches/refactor_fft/scipy/fftpack/pseudo_diffs.py 2008-05-15 12:27:12 UTC (rev 4330) +++ branches/refactor_fft/scipy/fftpack/pseudo_diffs.py 2008-05-15 12:27:46 UTC (rev 4331) @@ -12,7 +12,7 @@ import convolve import atexit -atexit.register(convolve.destroy_convolve_cache) +atexit.register(convolve.destroy_convolve_cache_fftpack) del atexit @@ -60,11 +60,11 @@ if k: return pow(c*k,order) return 0 - omega = convolve.init_convolution_kernel(n,kernel,d=order, + omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=order, zero_nyquist=1) _cache[(n,order,c)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,swap_real_imag=order%2, + return convolve.convolve_fftpack(tmp,omega,swap_real_imag=order%2, overwrite_x=overwrite_x) del _cache @@ -110,10 +110,10 @@ def kernel(k,h=h): if k: return 1.0/tanh(h*k) return 0 - omega = convolve.init_convolution_kernel(n,kernel,d=1) + omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) _cache[(n,h)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -146,10 +146,10 @@ def kernel(k,h=h): if k: return -tanh(h*k) return 0 - omega = convolve.init_convolution_kernel(n,kernel,d=1) + omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) _cache[(n,h)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -183,10 +183,10 @@ if k>0: return 1.0 elif k<0: return -1.0 return 0.0 - omega = convolve.init_convolution_kernel(n,kernel,d=1) + omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) _cache[n] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -242,10 +242,10 @@ def kernel(k,a=a,b=b): if k: return -cosh(a*k)/sinh(b*k) return 0 - omega = convolve.init_convolution_kernel(n,kernel,d=1) + omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -288,10 +288,10 @@ def kernel(k,a=a,b=b): if k: return sinh(a*k)/cosh(b*k) return 0 - omega = convolve.init_convolution_kernel(n,kernel,d=1) + omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -333,10 +333,10 @@ def kernel(k,a=a,b=b): if k: return sinh(a*k)/sinh(b*k) return float(a)/b - omega = convolve.init_convolution_kernel(n,kernel) + omega = convolve.init_convolution_kernel_fftpack(n,kernel) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,overwrite_x=overwrite_x) del _cache @@ -378,10 +378,10 @@ while _cache: _cache.popitem() def kernel(k,a=a,b=b): return cosh(a*k)/cosh(b*k) - omega = convolve.init_convolution_kernel(n,kernel) + omega = convolve.init_convolution_kernel_fftpack(n,kernel) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve(tmp,omega,overwrite_x=overwrite_x) + return convolve.convolve_fftpack(tmp,omega,overwrite_x=overwrite_x) del _cache _cache = {} @@ -412,15 +412,15 @@ while _cache: _cache.popitem() def kernel_real(k,a=a): return cos(a*k) def kernel_imag(k,a=a): return sin(a*k) - omega_real = convolve.init_convolution_kernel(n,kernel_real,d=0, + omega_real = convolve.init_convolution_kernel_fftpack(n,kernel_real,d=0, zero_nyquist=0) - omega_imag = convolve.init_convolution_kernel(n,kernel_imag,d=1, + omega_imag = convolve.init_convolution_kernel_fftpack(n,kernel_imag,d=1, zero_nyquist=0) _cache[(n,a)] = omega_real,omega_imag else: omega_real,omega_imag = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_z(tmp,omega_real,omega_imag, + return convolve.convolve_z_fftpack(tmp,omega_real,omega_imag, overwrite_x=overwrite_x) del _cache Modified: branches/refactor_fft/scipy/fftpack/tests/test_basic.py =================================================================== --- branches/refactor_fft/scipy/fftpack/tests/test_basic.py 2008-05-15 12:27:12 UTC (rev 4330) +++ branches/refactor_fft/scipy/fftpack/tests/test_basic.py 2008-05-15 12:27:46 UTC (rev 4331) @@ -13,7 +13,6 @@ import sys from scipy.testing import * from scipy.fftpack import ifft,fft,fftn,ifftn,rfft,irfft -from scipy.fftpack import _fftpack as fftpack from numpy import arange, add, array, asarray, zeros, dot, exp, pi,\ swapaxes, double, cdouble @@ -118,10 +117,10 @@ for i in range(2,14): n = 2**i x = range(n) - y = fftpack.zfft(x) + y = fft(x) y2 = numpy.fft.fft(x) assert_array_almost_equal(y,y2) - y = fftpack.zrfft(x) + y = fft(x) assert_array_almost_equal(y,y2) @@ -145,10 +144,10 @@ for i in range(2,14): n = 2**i x = range(n) - y = fftpack.zfft(x,direction=-1) + y = ifft(x) y2 = numpy.fft.ifft(x) assert_array_almost_equal(y,y2) - y = fftpack.zrfft(x,direction=-1) + y = ifft(x) assert_array_almost_equal(y,y2) def test_random_complex(self): @@ -189,7 +188,7 @@ for k in range(1,n/2): y1[2*k-1] = y2[k].real y1[2*k] = y2[k].imag - y = fftpack.drfft(x) + y = rfft(x) assert_array_almost_equal(y,y1) @@ -221,7 +220,7 @@ x1[n-k] = x[2*k-1]-1j*x[2*k] x1[n/2] = x[-1] y1 = numpy_ifft(x1) - y = fftpack.drfft(x,direction=-1) + y = irfft(x) assert_array_almost_equal(y,y1) def test_random_real(self): From scipy-svn at scipy.org Thu May 15 08:29:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:29:32 -0500 (CDT) Subject: [Scipy-svn] r4332 - in branches/refactor_fft/scipy/fftpack: . backends backends/djbfft backends/fftw backends/fftw3 backends/mkl src/djbfft src/fftw src/fftw3 src/mkl Message-ID: <20080515122932.8CC7A39C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:28:27 -0500 (Thu, 15 May 2008) New Revision: 4332 Added: branches/refactor_fft/scipy/fftpack/backends/ branches/refactor_fft/scipy/fftpack/backends/djbfft/ branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h branches/refactor_fft/scipy/fftpack/backends/djbfft/common.h branches/refactor_fft/scipy/fftpack/backends/djbfft/convolve.cxx branches/refactor_fft/scipy/fftpack/backends/djbfft/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/djbfft/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/ branches/refactor_fft/scipy/fftpack/backends/fftw/api.h branches/refactor_fft/scipy/fftpack/backends/fftw/common.h branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/ branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx branches/refactor_fft/scipy/fftpack/backends/mkl/ branches/refactor_fft/scipy/fftpack/backends/mkl/api.h branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/src/djbfft/api.h branches/refactor_fft/scipy/fftpack/src/djbfft/common.h branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/api.h branches/refactor_fft/scipy/fftpack/src/fftw/common.h branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx branches/refactor_fft/scipy/fftpack/src/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/api.h branches/refactor_fft/scipy/fftpack/src/fftw3/common.h branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx branches/refactor_fft/scipy/fftpack/src/mkl/api.h branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx Log: Move optimized backends in specific directory. Copied: branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/djbfft/api.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,38 @@ +#ifndef _SCIPY_FFTPACK_DJBFFT_API_H_ +#define _SCIPY_FFTPACK_DJBFFT_API_H_ + +#include "fftpack.h" + +/* + * straight FFT api + */ +void drfft_djbfft(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_djbfft(complex_double * inout, + int n, int direction, int howmany, int normalize); + +/* + * Convolution api + */ +void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag); +void convolve_z_djbfft(int n, double *inout, double *omega_real, + double* omega_imag); + +void init_convolution_kernel_djbfft(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist); + +/* + * Common headers and def + */ +#define complex8 complex_double +#define COMPLEX8_H + +extern "C" { +#include +#include +#include +}; + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/djbfft/common.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/djbfft/common.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/djbfft/common.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,84 @@ +#ifndef _SCIPY_DJBFFT_COMMON_H +#define _SCIPY_DJBFFT_COMMON_H + +#include + +#define COPYSTD2DJB(SRC,DEST,N) { \ + int n2 = (N)/2,k,j; \ + *(DEST) = *(SRC); \ + *(DEST+1) = *(SRC+n2); \ + for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ + *(DEST+k) = *(SRC+n2+j); \ + *(DEST+k+1) = *(SRC+j); \ + } \ +} + +#define COPYINVDJB2STD(SRC,DEST,N) { \ + int n2 = (N)/2,k,j; \ + *(DEST) = *(SRC); \ + *(DEST+n2) = *(SRC+1); \ + for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ + *(DEST+n2+j) = *(SRC+k); \ + *(DEST+j) = *(SRC+k+1); \ + } \ +} + +#define COPYINVDJB2STD2(SRC,DEST,N) { \ + int n2 = (N)/2,k,j; \ + *(DEST) = *(SRC); \ + *(DEST+(N)-1) = *(SRC+(N)-1); \ + for (j=1,k=1;jn2) { \ + j = 2*(N-j); \ + *(DEST+j-1) = *(SRC+k); \ + *(DEST+j) = -*(SRC+k+1); \ + } else { \ + j *= 2; \ + *(DEST+j-1) = *(SRC+k); \ + *(DEST+j) = *(SRC+k+1); \ + } \ + } \ +} +#define COPYINVSTD2DJB(SRC,DEST,NORMALIZE,FRQ,N) { \ + int n2 = (N)/2,k,j; \ + if (NORMALIZE) { \ + *(DEST) = *(SRC); \ + *(DEST+1) = *(SRC+N-1); \ + } else { \ + *(DEST) = (*(SRC))*0.5; \ + *(DEST+1) = (*(SRC+N-1))*0.5; \ + } \ + for (k=2;kn2) { \ + j = 2*(N-j); \ + *(DEST+k) = *(SRC+j-1); \ + *(DEST+k+1) = -*(SRC+j); \ + } else { \ + j *= 2; \ + *(DEST+k) = *(SRC+j-1); \ + *(DEST+k+1) = *(SRC+j); \ + } \ + } \ +} +namespace fft { + +class DJBFFTCacheId : public CacheId { + public: + DJBFFTCacheId(int n) : CacheId(n) {}; +}; + +}; + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/djbfft/convolve.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/djbfft/convolve.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,344 @@ +#include +#include + +#include "common.h" +#include "api.h" + +#ifdef WITH_FFTW +#define convolve_def convolve_fftw +#define convolve_z_def convolve_z_fftw +#define init_convolution_kernel_def init_convolution_kernel_fftw +#else +#define convolve_def convolve_fftpack +#define convolve_z_def convolve_z_fftpack +#define init_convolution_kernel_def init_convolution_kernel_fftpack +#endif + +using namespace fft; + +class DDJBFFTCache: public Cache { + public: + DDJBFFTCache(const DJBFFTCacheId& id); + virtual ~DDJBFFTCache(); + + int convolve(double *inout, double *omega, + int swap_real_imag) const; + int convolve_z(double *inout, double *omega_real, + double* omega_imag) const; + protected: + double* m_ptr; +}; + +DDJBFFTCache::DDJBFFTCache(const DJBFFTCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + m_ptr = (double *)malloc(sizeof(*m_ptr) * n); + if (m_ptr == NULL) { + goto fail; + } + + return; + +fail: + throw std::bad_alloc(); +} + +DDJBFFTCache::~DDJBFFTCache() +{ + free(m_ptr); +} + +int DDJBFFTCache::convolve(double *inout, double *omega, int swap_real_imag) + const +{ + int i; + double *ptr = m_ptr; + int n = m_id.m_n; + + COPYSTD2DJB(inout, ptr, n); + switch (n) { +#define TMPCASE(N) case N: fftr8_##N(ptr); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + if (swap_real_imag) { + int n1 = n - 1; + double c; + ptr[0] *= omega[0]; + ptr[1] *= omega[1]; + for (i = 2; i < n1; i += 2) { + c = ptr[i] * omega[i]; + ptr[i] = ptr[i + 1] * omega[i + 1]; + ptr[i + 1] = c; + } + } else { + for (i = 0; i < n; ++i) { + ptr[i] *= omega[i]; + } + } + switch (n) { +#define TMPCASE(N)case N:fftr8_un##N(ptr);break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + COPYINVDJB2STD2(ptr, inout, n); + + return 0; +} + +int DDJBFFTCache::convolve_z(double *inout, double *omega_real, double *omega_imag) + const +{ + int i; + int n = m_id.m_n; + double *ptr = m_ptr; + int n1 = n - 1; + double c; + + COPYSTD2DJB(inout, ptr, n); + switch (n) { +#define TMPCASE(N) case N: fftr8_##N(ptr); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + + ptr[0] *= (omega_real[0] + omega_imag[0]); + ptr[1] *= (omega_real[1] + omega_imag[1]); + for (i = 2; i < n1; i += 2) { + c = ptr[i] * omega_imag[i]; + ptr[i] *= omega_real[i]; + ptr[i] += ptr[i + 1] * omega_imag[i + 1]; + ptr[i + 1] *= omega_real[i + 1]; + ptr[i + 1] += c; + } + + switch (n) { +#define TMPCASE(N)case N:fftr8_un##N(ptr);break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + COPYINVDJB2STD2(ptr, inout, n); + return 0; +} + +static CacheManager ddjbfft_cmgr(20); + +/**************** convolve **********************/ +static void do_convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) +{ + DDJBFFTCache *cache; + + cache = ddjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + cache->convolve(inout, omega, swap_real_imag); +} + +void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) +{ + bool use_def = true; + + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + use_def = false; + } + + if (!use_def) { + do_convolve_djbfft(n, inout, omega, swap_real_imag); + } else { + convolve_def(n, inout, omega, swap_real_imag); + } +} + +/**************** convolve **********************/ +static void do_convolve_z_djbfft(int n, double *inout, double *omega_real, + double *omega_imag) +{ + DDJBFFTCache *cache; + + cache = ddjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + cache->convolve_z(inout, omega_real, omega_imag); +} + +void convolve_z_djbfft(int n, double *inout, double *omega_real, + double *omega_imag) +{ + bool use_def = true; + + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + use_def = false; + } + + if (use_def) { + convolve_z_def(n, inout, omega_real, omega_imag); + } else { + do_convolve_z_djbfft(n, inout, omega_real, omega_imag); + } +} + +void do_init_convolution_kernel_djbfft(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist) +{ + int k; + unsigned int n2 = n / 2; + unsigned int *f = + (unsigned int *) malloc(sizeof(int) * (n)); + fftfreq_rtable(f, n); + for (k = 1; k < n; ++k) + if (f[k] > n2) + f[k] -= n; + omega[0] = (*kernel_func) (0) / n; + switch (d % 4) { + case 0: + for (k = 2; k < n - 1; k += 2) { + omega[k] = + (*kernel_func) (f[k]) / n2; + omega[k + 1] = -omega[k]; + } + omega[1] = + (zero_nyquist ? 0.0 + : (*kernel_func) (n2) / n); + break; + case 1:; + case -3: + for (k = 2; k < n - 1; k += 2) + omega[k] = omega[k + 1] = + -(*kernel_func) (f[k]) / n2; + omega[1] = + (zero_nyquist ? 0.0 + : (*kernel_func) (n2) / n); + break; + case 2:; + case -2: + for (k = 2; k < n - 1; k += 2) { + omega[k] = + -(*kernel_func) (f[k]) / n2; + omega[k + 1] = -omega[k]; + } + omega[1] = + (zero_nyquist ? 0.0 : + -(*kernel_func) (n2) / n); + break; + case 3:; + case -1: + for (k = 2; k < n - 1; k += 2) + omega[k] = omega[k + 1] = + (*kernel_func) (f[k]) / n2; + omega[1] = + (zero_nyquist ? 0.0 : + -(*kernel_func) (n2) / n); + break; + } + free(f); +} + +void init_convolution_kernel_djbfft(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist) +{ + bool use_def = true; + + /* + omega[k] = pow(sqrt(-1),d) * kernel_func(k) + omega[0] = kernel_func(0) + conjugate(omega[-k]) == omega[k] + */ + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + use_def = false; + } + + if (use_def) { + init_convolution_kernel_def(n, omega, d, kernel_func, + zero_nyquist); + } else { + do_init_convolution_kernel_djbfft(n, omega, d, kernel_func, + zero_nyquist); + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/djbfft/drfft.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/djbfft/drfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,185 @@ +/* + * Last Change: Tue May 13 02:00 PM 2008 J + * + * Original code by Pearu Peterson. + */ + +/* + * DJBFFT only implements size 2^N ! + * + * drfft_def and drfft_def_destroy_cache are the functions used for size different + * than 2^N + */ +#include +#include + +#include "common.h" +#include "api.h" + +#ifdef WITH_FFTW3 +#define drfft_def drfft_fftw3 +#elif defined WITH_FFTW +#define drfft_def drfft_fftw +#else +#define drfft_def drfft_fftpack +#endif + +using namespace fft; + +class RDJBFFTCache: public Cache { + public: + RDJBFFTCache(const DJBFFTCacheId& id); + virtual ~RDJBFFTCache(); + + int compute_forward(double * inout) const; + int compute_backward(double * inout, int normalize) const; + + protected: + unsigned int* m_f; + double* m_ptr; +}; + +RDJBFFTCache::RDJBFFTCache(const DJBFFTCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + m_f = (unsigned int*)malloc(sizeof(*m_f) * n); + if (m_f == NULL) { + goto fail_f; + } + + m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); + if (m_ptr == NULL) { + goto clean_f; + } + + fftfreq_rtable(m_f, id.m_n); + return; + +clean_f: + free(m_f); +fail_f: + throw std::bad_alloc(); +} + +RDJBFFTCache::~RDJBFFTCache() +{ + free(m_ptr); + free(m_f); +} + +int RDJBFFTCache::compute_forward(double *inout) const +{ + double *ptr = inout; + double *ptrc = m_ptr; + + int n = m_id.m_n; + COPYSTD2DJB(ptr, ptrc, n); + switch (n) { +#define TMPCASE(N) case N: fftr8_##N(ptrc); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + COPYDJB2STD(ptrc, ptr, m_f, n); + return 0; +} + +int RDJBFFTCache::compute_backward(double *inout, int normalize) const +{ + double *ptr = inout; + double *ptrc = m_ptr; + + int n = m_id.m_n; + + COPYINVSTD2DJB(ptr, ptrc, normalize, m_f, n); + switch (n) { + +#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(ptrc);fftr8_un##N(ptrc);break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + COPYINVDJB2STD(ptrc, ptr, n); + return 0; +} + +static CacheManager rdjbfft_cmgr(10); + +/**************** ZFFT function **********************/ +void drfft_djbfft(double * inout, + int n, int direction, int howmany, int normalize) +{ + int i; + double *ptr = inout; + RDJBFFTCache *cache; + + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + cache = rdjbfft_cmgr.get_cache(DJBFFTCacheId(n)); + break; + default: + drfft_def(inout, n, direction, howmany, normalize); + return; + } + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr, normalize); + } + break; + + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + } + + if (normalize && direction == 1) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/djbfft/zfft.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/djbfft/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,221 @@ +/* +* DJBFFT only implements size 2^N ! +* +* zfft_def is the function * used for size different than 2^N +*/ +#include + +#include "common.h" +#include "api.h" + +#ifdef WITH_FFTWORK +#define zfft_def zfft_fftwork +#elif defined WITH_FFTW3 +#define zfft_def zfft_fftw3 +#elif defined WITH_FFTW +#define zfft_def zfft_fftw +#else +#define zfft_def zfft_fftpack +#endif + +using namespace fft; + +class DJBFFTCache: public Cache { + public: + DJBFFTCache(const DJBFFTCacheId& id); + virtual ~DJBFFTCache(); + + int compute_forward(complex_double * inout) const; + int compute_backward(complex_double * inout) const; + int normalize(complex_double * inout) const; + + protected: + unsigned int* m_f; + double* m_ptr; +}; + +DJBFFTCache::DJBFFTCache(const DJBFFTCacheId& id) +: Cache(id) +{ + int i; + int n = id.m_n; + + m_f = (unsigned int*)malloc(sizeof(*m_f) * n); + if (m_f == NULL) { + goto fail_f; + } + + m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); + if (m_ptr == NULL) { + goto clean_f; + } + + fftfreq_ctable(m_f, id.m_n); + for(i = 0; i < n; ++i) { + m_f[i] = (id.m_n - m_f[i]) % id.m_n; + } + return; + +clean_f: + free(m_f); +fail_f: + throw std::bad_alloc(); +} + +DJBFFTCache::~DJBFFTCache() +{ + free(m_ptr); + free(m_f); +} + +int DJBFFTCache::compute_forward(complex_double *inout) const +{ + const int n = m_id.m_n; + int j; + + complex_double *ptrc = NULL; + complex_double *ptr = inout; + + ptrc = (complex_double*)m_ptr; + + memcpy(ptrc, ptr, 2 * n * sizeof(double)); + switch (n) { +#define TMPCASE(N) case N: fftc8_##N(ptrc); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + for (j = 0; j < n; ++j) { + *(ptr + m_f[j]) = *(ptrc + j); + } + + return 0; +} + +int DJBFFTCache::compute_backward(complex_double *inout) const +{ + const int n = m_id.m_n; + int j; + + complex_double *ptrc = NULL; + complex_double *ptr = inout; + + ptrc = (complex_double*)m_ptr; + + for (j = 0; j < n; ++j) { + *(ptrc + j) = *(ptr + m_f[j]); + } + switch (n) { +#define TMPCASE(N) case N: fftc8_un##N(ptrc); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + memcpy(ptr, ptrc, 2 * n * sizeof(double)); + + return 0; +} + +int DJBFFTCache::normalize(complex_double *ptr) const +{ + int n = m_id.m_n; + + switch (n) { +#define TMPCASE(N) case N: fftc8_scale##N(ptr); break + TMPCASE(2); + TMPCASE(4); + TMPCASE(8); + TMPCASE(16); + TMPCASE(32); + TMPCASE(64); + TMPCASE(128); + TMPCASE(256); + TMPCASE(512); + TMPCASE(1024); + TMPCASE(2048); + TMPCASE(4096); + TMPCASE(8192); +#undef TMPCASE + } + + return 0; +} + +static CacheManager djbfft_cmgr(10); + +/**************** ZFFT function **********************/ +void zfft_djbfft(complex_double * inout, + int n, int direction, int howmany, int normalize) +{ + int i; + complex_double *ptr = inout; + DJBFFTCache *cache; + + switch (n) { + case 2:; + case 4:; + case 8:; + case 16:; + case 32:; + case 64:; + case 128:; + case 256:; + case 512:; + case 1024:; + case 2048:; + case 4096:; + case 8192: + cache = djbfft_cmgr.get_cache(DJBFFTCacheId(n)); + break; + default: + /* For sizes not handled by djbfft, use default implementation + * and returns */ + zfft_def(inout, n, direction, howmany, normalize); + return; + } + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + default: + fprintf(stderr, "zfft: invalid direction=%d\n", direction); + } + + if (normalize) { + ptr = inout; + for (i = 0; i < howmany; ++i, ptr += n) { + cache->normalize(ptr); + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/api.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw/api.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,30 @@ +#ifndef _SCIPY_FFTPACK_FFTW_API_H_ +#define _SCIPY_FFTPACK_FFTW_API_H_ + +#include "fftpack.h" + +/* + * straight FFT api + */ +void drfft_fftw(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_fftw(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_fftw(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +/* + * Convolution api + */ +void convolve_fftw(int n, double *inout, double *omega, int swap_real_imag); +void convolve_z_fftw(int n, double *inout, double *omega_real, + double* omega_imag); + +void init_convolution_kernel_fftw(int n, double *omega, int d, + double (*kernel_func) (int), + int zero_nyquist); + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/common.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw/common.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/common.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/common.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,31 @@ +#ifndef _SCIPY_FFTW_COMMON_H +#define _SCIPY_FFTW_COMMON_H + +#define COPYRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) { \ + *(DEST+2*n2-1) = *(SRC+n2); \ + if ((N)%2) \ + *(DEST+2*n2) = *(SRC+(N)-n2); \ + } \ +} +#define COPYINVRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) {\ + *(DEST+n2) = *(SRC+2*n2-1); \ + if ((N)%2) \ + *(DEST+(N)-n2) = *(SRC+2*n2); \ + } \ +} + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,183 @@ +#include + +#include +#include + +#include "api.h" + +#include "cycliccache.h" + +using namespace fft; + +class DRFFTWCacheId : public CacheId { + public: + DRFFTWCacheId(int n); + +}; + +DRFFTWCacheId::DRFFTWCacheId(int n): + CacheId(n) +{ +} + +class DRFFTWCache : public Cache { + public: + DRFFTWCache(const DRFFTWCacheId& id); + virtual ~DRFFTWCache(); + + int convolve(double* inout, double* omega, + int swap_real_imag) const; + int convolve_z(double* inout, double* omega_real, + double* omega_imag) const; + + protected: + rfftw_plan m_plan1; + rfftw_plan m_plan2; +}; + +DRFFTWCache::DRFFTWCache(const DRFFTWCacheId& id) +: Cache(id) +{ + int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; + + m_plan1 = rfftw_create_plan(id.m_n, FFTW_REAL_TO_COMPLEX, flags); + if (m_plan1 == NULL) { + goto fail; + } + + m_plan2 = rfftw_create_plan(id.m_n, FFTW_COMPLEX_TO_REAL, flags); + if (m_plan2 == NULL) { + goto clean_plan1; + } + + return; + +clean_plan1: + rfftw_destroy_plan(m_plan1); +fail: + throw std::bad_alloc(); +} + +DRFFTWCache::~DRFFTWCache() +{ + rfftw_destroy_plan(m_plan2); + rfftw_destroy_plan(m_plan1); +} + +int DRFFTWCache::convolve(double* inout, double* omega, int swap_real_imag) + const +{ + int n = m_id.m_n; + int l = (n-1)/2+1; + int i; + double c; + + rfftw_one(m_plan1, (fftw_real *)inout, NULL); + if (swap_real_imag) { + inout[0] *= omega[0]; + if (!(n%2)) { + inout[n/2] *= omega[n/2]; + } + for(i=1;i drfftw_cmgr(20); + +/**************** convolve **********************/ +void convolve_fftw(int n,double* inout,double* omega,int swap_real_imag) +{ + DRFFTWCache *cache; + + cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); + cache->convolve(inout, omega, swap_real_imag); +} + +/**************** convolve **********************/ +void convolve_z_fftw(int n,double* inout,double* omega_real,double* omega_imag) +{ + DRFFTWCache *cache; + + cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); + cache->convolve_z(inout, omega_real, omega_imag); +} + +void init_convolution_kernel_fftw(int n,double* omega, int d, + double (*kernel_func)(int), + int zero_nyquist) +{ + /* + * omega[k] = pow(sqrt(-1),d) * kernel_func(k) + * omega[0] = kernel_func(0) + * conjugate(omega[-k]) == omega[k] + */ + int k,l=(n-1)/2+1; + omega[0] = (*kernel_func)(0)/n;; + switch (d%4) { + case 0: + for (k=1;k + +#include +#include + +#include "cycliccache.h" +#include "api.h" +#include "common.h" + +using namespace fft; + +class RFFTWCacheId : public CacheId { + public: + RFFTWCacheId(int n, int dir, int flags); + + virtual bool operator==(const RFFTWCacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const RFFTWCacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_dir == other.m_dir && + m_flags == other.m_flags && + th->is_equal(*ot); + } + + public: + int m_dir; + int m_flags; +}; + +RFFTWCacheId::RFFTWCacheId(int n, int dir, int flags): + CacheId(n), + m_dir(dir), + m_flags(flags) +{ +} + +class RFFTWCache : public Cache { + public: + RFFTWCache(const RFFTWCacheId& id); + virtual ~RFFTWCache(); + + int compute(double* inout) const; + + protected: + rfftw_plan m_plan; + double *m_wrk; +}; + +RFFTWCache::RFFTWCache(const RFFTWCacheId& id) +: Cache(id) +{ + m_wrk = (double *) malloc(sizeof(double) * id.m_n); + if(m_wrk == NULL) { + goto fail; + } + + m_plan = rfftw_create_plan(id.m_n, + (id.m_dir > 0 ? FFTW_REAL_TO_COMPLEX : + FFTW_COMPLEX_TO_REAL), + id.m_flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return; + +clean_wrk: + free(m_wrk); +fail: + throw std::bad_alloc(); +} + +RFFTWCache::~RFFTWCache() +{ + free(m_wrk); + rfftw_destroy_plan(m_plan); +} + +int RFFTWCache::compute(double* inout) const +{ + if(m_id.m_dir == 1) { + memcpy(m_wrk, inout, sizeof(double) * m_id.m_n); + rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); + COPYRFFTW2STD(m_wrk, inout, m_id.m_n); + } else { + COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); + rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); + memcpy(inout, m_wrk, sizeof(double) * m_id.m_n); + } + return 0; +}; + +CacheManager rfftw_cmgr(10); + +void drfft_fftw(double *inout, int n, int dir, + int howmany, int normalize) +{ + int i; + double *ptr = inout; + RFFTWCache *cache; + + cache = rfftw_cmgr.get_cache( + RFFTWCacheId(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE)); + + if (dir != -1 && dir != 1) { + fprintf(stderr, "drfft: invalid dir=%d\n", dir); + return; + } else { + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute(ptr); + } + } + + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/zfft.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,95 @@ +#include + +#include +#include + +#include "cycliccache.h" +#include "api.h" + +using namespace fft; + +class FFTWCacheId : public CacheId { + public: + FFTWCacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; + + virtual bool operator==(const FFTWCacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const FFTWCacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_dir == other.m_dir && th->is_equal(*ot); + } + + public: + int m_dir; +}; + +class FFTWCache : public Cache { + public: + FFTWCache(const FFTWCacheId& id); + virtual ~FFTWCache(); + + int compute(fftw_complex* inout) + { + fftw_one(m_plan, inout, NULL); + return 0; + }; + + protected: + fftw_plan m_plan; +}; + +FFTWCache::FFTWCache(const FFTWCacheId& id) +: Cache(id) +{ + m_plan = fftw_create_plan(id.m_n, + (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), + FFTW_ESTIMATE | FFTW_IN_PLACE); + + if (m_plan == NULL) { + goto fail; + } + + return ; + +fail: + throw std::bad_alloc(); +} + +FFTWCache::~FFTWCache() +{ + fftw_destroy_plan(m_plan); +} + +CacheManager fftw_cmgr(10); + +void zfft_fftw(complex_double * inout, int n, + int dir, int howmany, int normalize) +{ + int i; + complex_double *ptr = inout; + FFTWCache* cache; + + cache = fftw_cmgr.get_cache(FFTWCacheId(n, dir)); + + if (dir != -1 && dir != 1) { + fprintf(stderr, "zfft: invalid dir=%d\n", dir); + } else { + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute((fftw_complex *) ptr); + } + } + + if (normalize) { + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= n; + *((double *) (ptr++) + 1) /= n; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,192 @@ +/* + * fftw2 backend for multi dimensional fft + * + * Original code by Pearu Peaterson + * + * Last Change: Tue May 13 02:00 PM 2008 J + */ +#include +#include + +#include +#include + +#include +#include "api.h" + +using namespace fft; + +static int equal_dims(int rank,int *dims1,int *dims2) +{ + int i; + for (i = 0; i < rank; ++i) { + if (dims1[i] != dims2[i]) { + return 0; + } + } + return 1; +} + +class NDFFTWCacheId { + public: + NDFFTWCacheId(int rank, int *dims, int dir, int flags); + virtual ~NDFFTWCacheId(); + + NDFFTWCacheId(const NDFFTWCacheId &); + + virtual bool operator==(const NDFFTWCacheId & other) const { + return is_equal(other); + }; + + virtual bool is_equal(const NDFFTWCacheId & other) const; + + public: + int m_dir; + int m_rank; + int *m_dims; + int m_flags; + + private: + int init(int rank, int *dims); +}; + +int NDFFTWCacheId::init(int rank, int *dims) +{ + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + +NDFFTWCacheId::NDFFTWCacheId(int rank, int *dims, int dir, int flags) : + m_dir(dir), + m_rank(rank), + m_flags(flags) +{ + if (init(rank, dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTWCacheId::NDFFTWCacheId(const NDFFTWCacheId & copy) : + m_dir(copy.m_dir), + m_rank(copy.m_rank), + m_flags(copy.m_flags) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTWCacheId::~NDFFTWCacheId() +{ + free(m_dims); +} + +bool NDFFTWCacheId::is_equal(const NDFFTWCacheId & other) const +{ + bool res; + + res = (other.m_dir == m_dir); + res = res && (other.m_flags == m_flags); + + if (m_rank == other.m_rank) { + res = res && equal_dims(m_rank, m_dims, other.m_dims); + } else { + return false; + } + + return res; +} + +class NDFFTWCache : public Cache < NDFFTWCacheId > { + public: + NDFFTWCache(const NDFFTWCacheId & id); + virtual ~ NDFFTWCache(); + + int compute(fftw_complex * inout) const + { + fftwnd_one(m_plan, inout, NULL); + return 0; + }; + + protected: + fftwnd_plan m_plan; +}; + +NDFFTWCache::NDFFTWCache(const NDFFTWCacheId & id) +: Cache < NDFFTWCacheId > (id) +{ + int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; +#if 0 + int sz; + int i; + + sz = 1; + for (i = 0; i < m_id.m_rank; ++i) { + sz *= m_id.m_dims[i]; + } +#endif + + m_plan = fftwnd_create_plan(m_id.m_rank, + m_id.m_dims, + (id.m_dir > 0 ? + FFTW_FORWARD : FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto fail; + } + + return; + +fail: + throw std::bad_alloc(); +} + +NDFFTWCache::~NDFFTWCache() +{ + fftwnd_destroy_plan(m_plan); +} + +static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); + +void zfftnd_fftw(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize) +{ + int i, sz; + complex_double *ptr = inout; + NDFFTWCache *cache; + + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } + + cache = fftwnd_cmgr.get_cache( + NDFFTWCacheId(rank, dims, direction, + FFTW_IN_PLACE | FFTW_ESTIMATE)); + + for (i = 0; i < howmany; ++i, ptr += sz) { + cache->compute((fftw_complex*)ptr); + } + + if (normalize) { + ptr = inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw3/api.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,19 @@ +#ifndef _SCIPY_FFTPACK_FFTW3_API_H_ +#define _SCIPY_FFTPACK_FFTW3_API_H_ + +#include "fftpack.h" + +/* + * straight FFT api + */ +void drfft_fftw3(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_fftw3(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_fftw3(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw3/common.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,72 @@ +#ifndef _SCIPYFFT_FFTW3_COMMON_H_ +#define _SCIPYFFT_FFTW3_COMMON_H_ + +#include "cycliccache.h" + +#include + +#define COPYRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) { \ + *(DEST+2*n2-1) = *(SRC+n2); \ + if ((N)%2) \ + *(DEST+2*n2) = *(SRC+(N)-n2); \ + } \ +} +#define COPYINVRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) {\ + *(DEST+n2) = *(SRC+2*n2-1); \ + if ((N)%2) \ + *(DEST+(N)-n2) = *(SRC+2*n2); \ + } \ +} + +namespace fft { + +inline bool is_simd_aligned(const void * p) +{ + return (((reinterpret_cast (p)) & 0xF) == 0); +} + +class FFTW3CacheId : public CacheId { + public: + FFTW3CacheId(int n, int dir, bool isalign) : + CacheId(n), + m_dir(dir), + m_isalign(isalign) + { + }; + + virtual bool operator==(const FFTW3CacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const FFTW3CacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_isalign == other.m_isalign && + m_dir == other.m_dir && th->is_equal(*ot); + } + + public: + int m_dir; + bool m_isalign; +}; + +}; // namespace fft + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,139 @@ +/* + * Last Change: Tue May 13 02:00 PM 2008 J + * + * RFFTW3 implementation + * + * Original code by Pearu Peterson. + */ + +#include +#include + +#include + +#include "common.h" +#include "api.h" + +using namespace fft; + +class RFFTW3Cache : public Cache { + public: + RFFTW3Cache(const FFTW3CacheId& id); + virtual ~RFFTW3Cache(); + + int compute_forward(double* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); + fftw_execute_r2r(m_plan, inout, m_wrk); + COPYRFFTW2STD(m_wrk, inout, m_id.m_n); + return 0; + }; + + int compute_backward(double* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); + COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); + fftw_execute_r2r(m_plan, m_wrk, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + double *m_wrk; + double *m_wrk2; +}; + +RFFTW3Cache::RFFTW3Cache(const FFTW3CacheId& id) +: Cache(id) +{ + int flags = FFTW_MEASURE; + + m_wrk = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk == NULL) { + goto fail_wrk; + } + + m_wrk2 = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk2 == NULL) { + goto clean_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_r2r_1d(id.m_n, m_wrk, m_wrk2, + (id.m_dir > 0 ? FFTW_R2HC:FFTW_HC2R), + flags); + + if (m_plan == NULL) { + goto clean_wrk2; + } + + return ; + +clean_wrk2: + fftw_free(m_wrk2); +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +RFFTW3Cache::~RFFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk2); + fftw_free(m_wrk); +} + +static CacheManager drfftw3_cmgr(10); + +void drfft_fftw3(double *inout, int n, int direction, int + howmany, int normalize) +{ + int i; + double *ptr = inout; + + RFFTW3Cache *cache; + bool isaligned; + + isaligned = is_simd_aligned(ptr); + + if (howmany > 1) { + /* + * If executing for several consecutive buffers, we have to + * check that the shifting one buffer does not make it + * unaligned + */ + isaligned = isaligned && is_simd_aligned(ptr + n); + } + + cache = drfftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + } + + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,114 @@ +#include +#include + +#include + +#include "common.h" +#include "api.h" + +using namespace fft; + +class FFTW3Cache : public Cache { + public: + FFTW3Cache(const FFTW3CacheId& id); + virtual ~FFTW3Cache(); + + int compute(fftw_complex* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; +}; + +FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) +: Cache(id) +{ + int flags = FFTW_ESTIMATE; + + m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk == NULL) { + goto fail_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, + (id.m_dir > 0 ? FFTW_FORWARD : + FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return ; + +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +FFTW3Cache::~FFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk); +} + +static CacheManager zfftw3_cmgr(10); + +void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, + int normalize) +{ + fftw_complex *ptr = (fftw_complex*)inout; + double factor = 1./n; + FFTW3Cache *cache; + bool isaligned; + + int i; + + isaligned = is_simd_aligned(ptr); + + if (howmany > 1) { + /* + * If executing for several consecutive buffers, we have to + * check that the shifting one buffer does not make it + * unaligned + */ + isaligned = isaligned && is_simd_aligned(ptr + n); + } + cache = zfftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); + + switch (dir) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute(ptr); + } + break; + + default: + fprintf(stderr, "zfft: invalid dir=%d\n", dir); + } + + if (normalize) { + ptr =(fftw_complex*)inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) *= factor; + *((double *) (ptr++) + 1) *= factor; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,202 @@ +/* + * fftw3 backend for multi dimensional fft + * + * Original code by Pearu Peaterson + * + * Last Change: Tue May 13 02:00 PM 2008 J + */ +#include +#include + +#include + +#include "common.h" +#include "api.h" + +using namespace fft; + +class NDFFTW3CacheId { + public: + NDFFTW3CacheId(int rank, int *dims, int howmany, int dir, + bool isalign); + virtual ~NDFFTW3CacheId(); + + NDFFTW3CacheId(const NDFFTW3CacheId &); + + virtual bool operator==(const NDFFTW3CacheId & other) const { + return is_equal(other); + }; + + virtual bool is_equal(const NDFFTW3CacheId & other) const; + + public: + int m_rank; + int *m_dims; + int m_howmany; + int m_dir; + bool m_isalign; + + private: + int init(int rank, int *dims); +}; + +int NDFFTW3CacheId::init(int rank, int *dims) +{ + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + +NDFFTW3CacheId::NDFFTW3CacheId(int rank, int *dims, int howmany, + int dir, bool isalign) : + m_rank(rank), + m_howmany(howmany), + m_dir(dir), + m_isalign(isalign) +{ + if (init(rank, dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId & copy) : + m_rank(copy.m_rank), + m_howmany(copy.m_howmany), + m_dir(copy.m_dir), + m_isalign(copy.m_isalign) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTW3CacheId::~NDFFTW3CacheId() +{ + free(m_dims); +} + +bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId & other) const +{ + bool res; + int i; + + res = (other.m_dir == m_dir); + res = res && (other.m_isalign == m_isalign); + res = res && (m_howmany == other.m_howmany); + + if (m_rank == other.m_rank) { + for (i = 0; i < m_rank; ++i) { + res = res && (m_dims[i] == other.m_dims[i]); + } + } else { + return false; + } + + return res; +} + +class NDFFTW3Cache:public Cache < NDFFTW3CacheId > { + public: + NDFFTW3Cache(const NDFFTW3CacheId & id); + virtual ~ NDFFTW3Cache(); + + int compute(fftw_complex * inout) const { + assert(m_id.m_isalign ? is_simd_aligned(inout) : true); + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; +}; + +NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId & id) +: Cache < NDFFTW3CacheId > (id) +{ + int flags = FFTW_ESTIMATE; + int sz; + int i; + + sz = 1; + for (i = 0; i < m_id.m_rank; ++i) { + sz *= m_id.m_dims[i]; + } + + m_wrk = (fftw_complex *) fftw_malloc(sz * sizeof(fftw_complex)); + if (m_wrk == NULL) { + goto fail_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_many_dft(m_id.m_rank, + m_id.m_dims, m_id.m_howmany, + m_wrk, NULL, 1, sz, + m_wrk, NULL, 1, sz, + (id.m_dir > + 0 ? FFTW_FORWARD : FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return; + + clean_wrk: + fftw_free(m_wrk); + fail_wrk: + throw std::bad_alloc(); +} + +NDFFTW3Cache::~NDFFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk); +} + +static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > ndfftw3_cmgr(10); + +extern void zfftnd_fftw3(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize) +{ + int i, sz; + fftw_complex *ptr = (fftw_complex *) inout; + NDFFTW3Cache *cache; + + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } + + cache = + ndfftw3_cmgr. + get_cache(NDFFTW3CacheId + (rank, dims, howmany, direction, + is_simd_aligned(inout))); + + cache->compute(ptr); + + if (normalize) { + ptr = (fftw_complex *) inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/api.h (from rev 4331, branches/refactor_fft/scipy/fftpack/src/mkl/api.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,16 @@ +#ifndef _SCIPY_FFTPACK_MKL_API_H_ +#define _SCIPY_FFTPACK_MKL_API_H_ + +#include "fftpack.h" + +/* + * straight FFT api + */ +void zfft_mkl(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_mkl(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,92 @@ +#include + +#include + +#include "api.h" +#include "cycliccache.h" + +using namespace fft; + +class MKLCacheId : public CacheId { + public: + MKLCacheId(int n) : CacheId(n) {}; +}; + + +class MKLCache: public Cache { + public: + MKLCache(const MKLCacheId& id); + virtual ~MKLCache(); + + int compute_forward(complex_double * inout) const; + int compute_backward(complex_double * inout) const; + + protected: + DFTI_DESCRIPTOR_HANDLE m_hdl; +}; + +MKLCache::MKLCache(const MKLCacheId& id) +: Cache(id) +{ + int n = id.m_n; + + DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n); + DftiCommitDescriptor(m_hdl); + + return; +} + +MKLCache::~MKLCache() +{ + DftiFreeDescriptor(&m_hdl); +} + +int MKLCache::compute_forward(complex_double *inout) const +{ + DftiComputeForward(m_hdl, (double *) inout); + return 0; +} + +int MKLCache::compute_backward(complex_double *inout) const +{ + DftiComputeBackward(m_hdl, (double *) inout); + return 0; +} + +CacheManager zmkl_cmgr(10); + +void zfft_mkl(complex_double * inout, + int n, int direction, int howmany, int normalize) +{ + int i; + complex_double *ptr = inout; + MKLCache *cache; + + cache = zmkl_cmgr.get_cache(MKLCacheId(n)); + + switch (direction) { + + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + + default: + fprintf(stderr, "zfft: invalid direction=%d\n", direction); + } + + if (normalize) { + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= n; + *((double *) (ptr++) + 1) /= n; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx (from rev 4331, branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -0,0 +1,211 @@ +/* + * MKL backend for multi dimensional fft + * + * Original code by David M. Cooke + * + * Last Change: Tue May 13 05:00 PM 2008 J + */ +#include + +#include + +#include "api.h" +#include "cycliccache.h" + +using namespace fft; + +static int equal_dims(int rank,int *dims1,int *dims2) +{ + int i; + for (i = 0; i < rank; ++i) { + if (dims1[i] != dims2[i]) { + return 0; + } + } + return 1; +} + +class NDMKLCacheId { + public: + NDMKLCacheId(int rank, int *dim); + virtual ~NDMKLCacheId(); + + NDMKLCacheId(const NDMKLCacheId &); + + virtual bool operator==(const NDMKLCacheId & other) const { + return is_equal(other); + }; + + virtual bool is_equal(const NDMKLCacheId & other) const; + + public: + int m_rank; + int *m_dims; + + private: + int init(int rank, int *dims); +}; + +int NDMKLCacheId::init(int rank, int *dims) +{ + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + +NDMKLCacheId::NDMKLCacheId(int rank, int *dims) : + m_rank(rank) +{ + if (init(rank, dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDMKLCacheId::NDMKLCacheId(const NDMKLCacheId & copy) : + m_rank(copy.m_rank) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDMKLCacheId::~NDMKLCacheId() +{ + free(m_dims); +} + +bool NDMKLCacheId::is_equal(const NDMKLCacheId & other) const +{ + bool res; + + if (m_rank == other.m_rank) { + res = equal_dims(m_rank, m_dims, other.m_dims); + } else { + return false; + } + + return res; +} + +/* + * Cache class for nd-MKL + */ +class NDMKLCache:public Cache < NDMKLCacheId > { + public: + NDMKLCache(const NDMKLCacheId & id); + virtual ~ NDMKLCache(); + + int compute_forward(double * inout) const + { + DftiComputeForward(m_hdl, inout); + return 0; + }; + + int compute_backward(double * inout) const + { + DftiComputeBackward(m_hdl, inout); + return 0; + }; + + protected: + int m_rank; + int *m_dims; + long *m_ndims; + DFTI_DESCRIPTOR_HANDLE m_hdl; + + private: + long *convert_dims(int n, int *dims) const; + +}; + +NDMKLCache::NDMKLCache(const NDMKLCacheId & id) +: Cache < NDMKLCacheId > (id) +{ + m_rank = id.m_rank; + m_ndims = convert_dims(id.m_rank, id.m_dims); + m_dims = (int *) malloc(sizeof(int) * m_rank); + if (m_dims == NULL) { + goto fail; + } + + memcpy(m_dims, id.m_dims, sizeof(int) * m_rank); + DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, (long) m_rank, + m_ndims); + DftiCommitDescriptor(m_hdl); + + return; + +fail: + throw std::bad_alloc(); +} + +NDMKLCache::~NDMKLCache() +{ + DftiFreeDescriptor(&m_hdl); + free(m_dims); + free(m_ndims); +} + +long* NDMKLCache::convert_dims(int n, int *dims) const +{ + long *ndim; + int i; + + ndim = (long *) malloc(sizeof(*ndim) * n); + for (i = 0; i < n; i++) { + ndim[i] = (long) dims[i]; + } + return ndim; +} + +static CacheManager < NDMKLCacheId, NDMKLCache > ndmkl_cmgr(10); + +void zfftnd_mkl(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize) +{ + int i, sz; + complex_double *ptr = inout; + NDMKLCache *cache; + + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } + + cache = ndmkl_cmgr.get_cache(NDMKLCacheId(rank, dims)); + switch(direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += sz) { + cache->compute_forward((double*)ptr); + } + break; + case -1: + for (i = 0; i < howmany; ++i, ptr += sz) { + cache->compute_backward((double*)ptr); + } + break; + default: + fprintf(stderr, + "nd mkl:Wrong direction (this is a bug)\n"); + return; + } + if (normalize) { + ptr = inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } +} Deleted: branches/refactor_fft/scipy/fftpack/src/djbfft/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,38 +0,0 @@ -#ifndef _SCIPY_FFTPACK_DJBFFT_API_H_ -#define _SCIPY_FFTPACK_DJBFFT_API_H_ - -#include "fftpack.h" - -/* - * straight FFT api - */ -void drfft_djbfft(double * inout, int n, int direction, int howmany, - int normalize); - -void zfft_djbfft(complex_double * inout, - int n, int direction, int howmany, int normalize); - -/* - * Convolution api - */ -void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag); -void convolve_z_djbfft(int n, double *inout, double *omega_real, - double* omega_imag); - -void init_convolution_kernel_djbfft(int n, double *omega, int d, - double (*kernel_func) (int), - int zero_nyquist); - -/* - * Common headers and def - */ -#define complex8 complex_double -#define COMPLEX8_H - -extern "C" { -#include -#include -#include -}; - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/djbfft/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/common.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,84 +0,0 @@ -#ifndef _SCIPY_DJBFFT_COMMON_H -#define _SCIPY_DJBFFT_COMMON_H - -#include - -#define COPYSTD2DJB(SRC,DEST,N) { \ - int n2 = (N)/2,k,j; \ - *(DEST) = *(SRC); \ - *(DEST+1) = *(SRC+n2); \ - for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ - *(DEST+k) = *(SRC+n2+j); \ - *(DEST+k+1) = *(SRC+j); \ - } \ -} - -#define COPYINVDJB2STD(SRC,DEST,N) { \ - int n2 = (N)/2,k,j; \ - *(DEST) = *(SRC); \ - *(DEST+n2) = *(SRC+1); \ - for (j=(N)/2-1,k=2;j>0;--j,k+=2) { \ - *(DEST+n2+j) = *(SRC+k); \ - *(DEST+j) = *(SRC+k+1); \ - } \ -} - -#define COPYINVDJB2STD2(SRC,DEST,N) { \ - int n2 = (N)/2,k,j; \ - *(DEST) = *(SRC); \ - *(DEST+(N)-1) = *(SRC+(N)-1); \ - for (j=1,k=1;jn2) { \ - j = 2*(N-j); \ - *(DEST+j-1) = *(SRC+k); \ - *(DEST+j) = -*(SRC+k+1); \ - } else { \ - j *= 2; \ - *(DEST+j-1) = *(SRC+k); \ - *(DEST+j) = *(SRC+k+1); \ - } \ - } \ -} -#define COPYINVSTD2DJB(SRC,DEST,NORMALIZE,FRQ,N) { \ - int n2 = (N)/2,k,j; \ - if (NORMALIZE) { \ - *(DEST) = *(SRC); \ - *(DEST+1) = *(SRC+N-1); \ - } else { \ - *(DEST) = (*(SRC))*0.5; \ - *(DEST+1) = (*(SRC+N-1))*0.5; \ - } \ - for (k=2;kn2) { \ - j = 2*(N-j); \ - *(DEST+k) = *(SRC+j-1); \ - *(DEST+k+1) = -*(SRC+j); \ - } else { \ - j *= 2; \ - *(DEST+k) = *(SRC+j-1); \ - *(DEST+k+1) = *(SRC+j); \ - } \ - } \ -} -namespace fft { - -class DJBFFTCacheId : public CacheId { - public: - DJBFFTCacheId(int n) : CacheId(n) {}; -}; - -}; - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/convolve.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,344 +0,0 @@ -#include -#include - -#include "common.h" -#include "api.h" - -#ifdef WITH_FFTW -#define convolve_def convolve_fftw -#define convolve_z_def convolve_z_fftw -#define init_convolution_kernel_def init_convolution_kernel_fftw -#else -#define convolve_def convolve_fftpack -#define convolve_z_def convolve_z_fftpack -#define init_convolution_kernel_def init_convolution_kernel_fftpack -#endif - -using namespace fft; - -class DDJBFFTCache: public Cache { - public: - DDJBFFTCache(const DJBFFTCacheId& id); - virtual ~DDJBFFTCache(); - - int convolve(double *inout, double *omega, - int swap_real_imag) const; - int convolve_z(double *inout, double *omega_real, - double* omega_imag) const; - protected: - double* m_ptr; -}; - -DDJBFFTCache::DDJBFFTCache(const DJBFFTCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - m_ptr = (double *)malloc(sizeof(*m_ptr) * n); - if (m_ptr == NULL) { - goto fail; - } - - return; - -fail: - throw std::bad_alloc(); -} - -DDJBFFTCache::~DDJBFFTCache() -{ - free(m_ptr); -} - -int DDJBFFTCache::convolve(double *inout, double *omega, int swap_real_imag) - const -{ - int i; - double *ptr = m_ptr; - int n = m_id.m_n; - - COPYSTD2DJB(inout, ptr, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - if (swap_real_imag) { - int n1 = n - 1; - double c; - ptr[0] *= omega[0]; - ptr[1] *= omega[1]; - for (i = 2; i < n1; i += 2) { - c = ptr[i] * omega[i]; - ptr[i] = ptr[i + 1] * omega[i + 1]; - ptr[i + 1] = c; - } - } else { - for (i = 0; i < n; ++i) { - ptr[i] *= omega[i]; - } - } - switch (n) { -#define TMPCASE(N)case N:fftr8_un##N(ptr);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYINVDJB2STD2(ptr, inout, n); - - return 0; -} - -int DDJBFFTCache::convolve_z(double *inout, double *omega_real, double *omega_imag) - const -{ - int i; - int n = m_id.m_n; - double *ptr = m_ptr; - int n1 = n - 1; - double c; - - COPYSTD2DJB(inout, ptr, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - - ptr[0] *= (omega_real[0] + omega_imag[0]); - ptr[1] *= (omega_real[1] + omega_imag[1]); - for (i = 2; i < n1; i += 2) { - c = ptr[i] * omega_imag[i]; - ptr[i] *= omega_real[i]; - ptr[i] += ptr[i + 1] * omega_imag[i + 1]; - ptr[i + 1] *= omega_real[i + 1]; - ptr[i + 1] += c; - } - - switch (n) { -#define TMPCASE(N)case N:fftr8_un##N(ptr);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYINVDJB2STD2(ptr, inout, n); - return 0; -} - -static CacheManager ddjbfft_cmgr(20); - -/**************** convolve **********************/ -static void do_convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) -{ - DDJBFFTCache *cache; - - cache = ddjbfft_cmgr.get_cache(DJBFFTCacheId(n)); - cache->convolve(inout, omega, swap_real_imag); -} - -void convolve_djbfft(int n, double *inout, double *omega, int swap_real_imag) -{ - bool use_def = true; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - use_def = false; - } - - if (!use_def) { - do_convolve_djbfft(n, inout, omega, swap_real_imag); - } else { - convolve_def(n, inout, omega, swap_real_imag); - } -} - -/**************** convolve **********************/ -static void do_convolve_z_djbfft(int n, double *inout, double *omega_real, - double *omega_imag) -{ - DDJBFFTCache *cache; - - cache = ddjbfft_cmgr.get_cache(DJBFFTCacheId(n)); - cache->convolve_z(inout, omega_real, omega_imag); -} - -void convolve_z_djbfft(int n, double *inout, double *omega_real, - double *omega_imag) -{ - bool use_def = true; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - use_def = false; - } - - if (use_def) { - convolve_z_def(n, inout, omega_real, omega_imag); - } else { - do_convolve_z_djbfft(n, inout, omega_real, omega_imag); - } -} - -void do_init_convolution_kernel_djbfft(int n, double *omega, int d, - double (*kernel_func) (int), - int zero_nyquist) -{ - int k; - unsigned int n2 = n / 2; - unsigned int *f = - (unsigned int *) malloc(sizeof(int) * (n)); - fftfreq_rtable(f, n); - for (k = 1; k < n; ++k) - if (f[k] > n2) - f[k] -= n; - omega[0] = (*kernel_func) (0) / n; - switch (d % 4) { - case 0: - for (k = 2; k < n - 1; k += 2) { - omega[k] = - (*kernel_func) (f[k]) / n2; - omega[k + 1] = -omega[k]; - } - omega[1] = - (zero_nyquist ? 0.0 - : (*kernel_func) (n2) / n); - break; - case 1:; - case -3: - for (k = 2; k < n - 1; k += 2) - omega[k] = omega[k + 1] = - -(*kernel_func) (f[k]) / n2; - omega[1] = - (zero_nyquist ? 0.0 - : (*kernel_func) (n2) / n); - break; - case 2:; - case -2: - for (k = 2; k < n - 1; k += 2) { - omega[k] = - -(*kernel_func) (f[k]) / n2; - omega[k + 1] = -omega[k]; - } - omega[1] = - (zero_nyquist ? 0.0 : - -(*kernel_func) (n2) / n); - break; - case 3:; - case -1: - for (k = 2; k < n - 1; k += 2) - omega[k] = omega[k + 1] = - (*kernel_func) (f[k]) / n2; - omega[1] = - (zero_nyquist ? 0.0 : - -(*kernel_func) (n2) / n); - break; - } - free(f); -} - -void init_convolution_kernel_djbfft(int n, double *omega, int d, - double (*kernel_func) (int), - int zero_nyquist) -{ - bool use_def = true; - - /* - omega[k] = pow(sqrt(-1),d) * kernel_func(k) - omega[0] = kernel_func(0) - conjugate(omega[-k]) == omega[k] - */ - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - use_def = false; - } - - if (use_def) { - init_convolution_kernel_def(n, omega, d, kernel_func, - zero_nyquist); - } else { - do_init_convolution_kernel_djbfft(n, omega, d, kernel_func, - zero_nyquist); - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/drfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,185 +0,0 @@ -/* - * Last Change: Tue May 13 02:00 PM 2008 J - * - * Original code by Pearu Peterson. - */ - -/* - * DJBFFT only implements size 2^N ! - * - * drfft_def and drfft_def_destroy_cache are the functions used for size different - * than 2^N - */ -#include -#include - -#include "common.h" -#include "api.h" - -#ifdef WITH_FFTW3 -#define drfft_def drfft_fftw3 -#elif defined WITH_FFTW -#define drfft_def drfft_fftw -#else -#define drfft_def drfft_fftpack -#endif - -using namespace fft; - -class RDJBFFTCache: public Cache { - public: - RDJBFFTCache(const DJBFFTCacheId& id); - virtual ~RDJBFFTCache(); - - int compute_forward(double * inout) const; - int compute_backward(double * inout, int normalize) const; - - protected: - unsigned int* m_f; - double* m_ptr; -}; - -RDJBFFTCache::RDJBFFTCache(const DJBFFTCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - m_f = (unsigned int*)malloc(sizeof(*m_f) * n); - if (m_f == NULL) { - goto fail_f; - } - - m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); - if (m_ptr == NULL) { - goto clean_f; - } - - fftfreq_rtable(m_f, id.m_n); - return; - -clean_f: - free(m_f); -fail_f: - throw std::bad_alloc(); -} - -RDJBFFTCache::~RDJBFFTCache() -{ - free(m_ptr); - free(m_f); -} - -int RDJBFFTCache::compute_forward(double *inout) const -{ - double *ptr = inout; - double *ptrc = m_ptr; - - int n = m_id.m_n; - COPYSTD2DJB(ptr, ptrc, n); - switch (n) { -#define TMPCASE(N) case N: fftr8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYDJB2STD(ptrc, ptr, m_f, n); - return 0; -} - -int RDJBFFTCache::compute_backward(double *inout, int normalize) const -{ - double *ptr = inout; - double *ptrc = m_ptr; - - int n = m_id.m_n; - - COPYINVSTD2DJB(ptr, ptrc, normalize, m_f, n); - switch (n) { - -#define TMPCASE(N)case N:if(normalize)fftr8_scale##N(ptrc);fftr8_un##N(ptrc);break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - COPYINVDJB2STD(ptrc, ptr, n); - return 0; -} - -static CacheManager rdjbfft_cmgr(10); - -/**************** ZFFT function **********************/ -void drfft_djbfft(double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - double *ptr = inout; - RDJBFFTCache *cache; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - cache = rdjbfft_cmgr.get_cache(DJBFFTCacheId(n)); - break; - default: - drfft_def(inout, n, direction, howmany, normalize); - return; - } - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr, normalize); - } - break; - - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize && direction == 1) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/djbfft/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,221 +0,0 @@ -/* -* DJBFFT only implements size 2^N ! -* -* zfft_def is the function * used for size different than 2^N -*/ -#include - -#include "common.h" -#include "api.h" - -#ifdef WITH_FFTWORK -#define zfft_def zfft_fftwork -#elif defined WITH_FFTW3 -#define zfft_def zfft_fftw3 -#elif defined WITH_FFTW -#define zfft_def zfft_fftw -#else -#define zfft_def zfft_fftpack -#endif - -using namespace fft; - -class DJBFFTCache: public Cache { - public: - DJBFFTCache(const DJBFFTCacheId& id); - virtual ~DJBFFTCache(); - - int compute_forward(complex_double * inout) const; - int compute_backward(complex_double * inout) const; - int normalize(complex_double * inout) const; - - protected: - unsigned int* m_f; - double* m_ptr; -}; - -DJBFFTCache::DJBFFTCache(const DJBFFTCacheId& id) -: Cache(id) -{ - int i; - int n = id.m_n; - - m_f = (unsigned int*)malloc(sizeof(*m_f) * n); - if (m_f == NULL) { - goto fail_f; - } - - m_ptr = (double *)malloc(sizeof(*m_ptr) * 2 * n); - if (m_ptr == NULL) { - goto clean_f; - } - - fftfreq_ctable(m_f, id.m_n); - for(i = 0; i < n; ++i) { - m_f[i] = (id.m_n - m_f[i]) % id.m_n; - } - return; - -clean_f: - free(m_f); -fail_f: - throw std::bad_alloc(); -} - -DJBFFTCache::~DJBFFTCache() -{ - free(m_ptr); - free(m_f); -} - -int DJBFFTCache::compute_forward(complex_double *inout) const -{ - const int n = m_id.m_n; - int j; - - complex_double *ptrc = NULL; - complex_double *ptr = inout; - - ptrc = (complex_double*)m_ptr; - - memcpy(ptrc, ptr, 2 * n * sizeof(double)); - switch (n) { -#define TMPCASE(N) case N: fftc8_##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - for (j = 0; j < n; ++j) { - *(ptr + m_f[j]) = *(ptrc + j); - } - - return 0; -} - -int DJBFFTCache::compute_backward(complex_double *inout) const -{ - const int n = m_id.m_n; - int j; - - complex_double *ptrc = NULL; - complex_double *ptr = inout; - - ptrc = (complex_double*)m_ptr; - - for (j = 0; j < n; ++j) { - *(ptrc + j) = *(ptr + m_f[j]); - } - switch (n) { -#define TMPCASE(N) case N: fftc8_un##N(ptrc); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - memcpy(ptr, ptrc, 2 * n * sizeof(double)); - - return 0; -} - -int DJBFFTCache::normalize(complex_double *ptr) const -{ - int n = m_id.m_n; - - switch (n) { -#define TMPCASE(N) case N: fftc8_scale##N(ptr); break - TMPCASE(2); - TMPCASE(4); - TMPCASE(8); - TMPCASE(16); - TMPCASE(32); - TMPCASE(64); - TMPCASE(128); - TMPCASE(256); - TMPCASE(512); - TMPCASE(1024); - TMPCASE(2048); - TMPCASE(4096); - TMPCASE(8192); -#undef TMPCASE - } - - return 0; -} - -static CacheManager djbfft_cmgr(10); - -/**************** ZFFT function **********************/ -void zfft_djbfft(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - DJBFFTCache *cache; - - switch (n) { - case 2:; - case 4:; - case 8:; - case 16:; - case 32:; - case 64:; - case 128:; - case 256:; - case 512:; - case 1024:; - case 2048:; - case 4096:; - case 8192: - cache = djbfft_cmgr.get_cache(DJBFFTCacheId(n)); - break; - default: - /* For sizes not handled by djbfft, use default implementation - * and returns */ - zfft_def(inout, n, direction, howmany, normalize); - return; - } - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = 0; i < howmany; ++i, ptr += n) { - cache->normalize(ptr); - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,30 +0,0 @@ -#ifndef _SCIPY_FFTPACK_FFTW_API_H_ -#define _SCIPY_FFTPACK_FFTW_API_H_ - -#include "fftpack.h" - -/* - * straight FFT api - */ -void drfft_fftw(double * inout, int n, int direction, int howmany, - int normalize); - -void zfft_fftw(complex_double * inout, - int n, int direction, int howmany, int normalize); - -void zfftnd_fftw(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize); - -/* - * Convolution api - */ -void convolve_fftw(int n, double *inout, double *omega, int swap_real_imag); -void convolve_z_fftw(int n, double *inout, double *omega_real, - double* omega_imag); - -void init_convolution_kernel_fftw(int n, double *omega, int d, - double (*kernel_func) (int), - int zero_nyquist); - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/common.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw/common.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,31 +0,0 @@ -#ifndef _SCIPY_FFTW_COMMON_H -#define _SCIPY_FFTW_COMMON_H - -#define COPYRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) { \ - *(DEST+2*n2-1) = *(SRC+n2); \ - if ((N)%2) \ - *(DEST+2*n2) = *(SRC+(N)-n2); \ - } \ -} -#define COPYINVRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) {\ - *(DEST+n2) = *(SRC+2*n2-1); \ - if ((N)%2) \ - *(DEST+(N)-n2) = *(SRC+2*n2); \ - } \ -} - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw/convolve.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,183 +0,0 @@ -#include - -#include -#include - -#include "api.h" - -#include "cycliccache.h" - -using namespace fft; - -class DRFFTWCacheId : public CacheId { - public: - DRFFTWCacheId(int n); - -}; - -DRFFTWCacheId::DRFFTWCacheId(int n): - CacheId(n) -{ -} - -class DRFFTWCache : public Cache { - public: - DRFFTWCache(const DRFFTWCacheId& id); - virtual ~DRFFTWCache(); - - int convolve(double* inout, double* omega, - int swap_real_imag) const; - int convolve_z(double* inout, double* omega_real, - double* omega_imag) const; - - protected: - rfftw_plan m_plan1; - rfftw_plan m_plan2; -}; - -DRFFTWCache::DRFFTWCache(const DRFFTWCacheId& id) -: Cache(id) -{ - int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; - - m_plan1 = rfftw_create_plan(id.m_n, FFTW_REAL_TO_COMPLEX, flags); - if (m_plan1 == NULL) { - goto fail; - } - - m_plan2 = rfftw_create_plan(id.m_n, FFTW_COMPLEX_TO_REAL, flags); - if (m_plan2 == NULL) { - goto clean_plan1; - } - - return; - -clean_plan1: - rfftw_destroy_plan(m_plan1); -fail: - throw std::bad_alloc(); -} - -DRFFTWCache::~DRFFTWCache() -{ - rfftw_destroy_plan(m_plan2); - rfftw_destroy_plan(m_plan1); -} - -int DRFFTWCache::convolve(double* inout, double* omega, int swap_real_imag) - const -{ - int n = m_id.m_n; - int l = (n-1)/2+1; - int i; - double c; - - rfftw_one(m_plan1, (fftw_real *)inout, NULL); - if (swap_real_imag) { - inout[0] *= omega[0]; - if (!(n%2)) { - inout[n/2] *= omega[n/2]; - } - for(i=1;i drfftw_cmgr(20); - -/**************** convolve **********************/ -void convolve_fftw(int n,double* inout,double* omega,int swap_real_imag) -{ - DRFFTWCache *cache; - - cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); - cache->convolve(inout, omega, swap_real_imag); -} - -/**************** convolve **********************/ -void convolve_z_fftw(int n,double* inout,double* omega_real,double* omega_imag) -{ - DRFFTWCache *cache; - - cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); - cache->convolve_z(inout, omega_real, omega_imag); -} - -void init_convolution_kernel_fftw(int n,double* omega, int d, - double (*kernel_func)(int), - int zero_nyquist) -{ - /* - * omega[k] = pow(sqrt(-1),d) * kernel_func(k) - * omega[0] = kernel_func(0) - * conjugate(omega[-k]) == omega[k] - */ - int k,l=(n-1)/2+1; - omega[0] = (*kernel_func)(0)/n;; - switch (d%4) { - case 0: - for (k=1;k - -#include -#include - -#include "cycliccache.h" -#include "api.h" -#include "common.h" - -using namespace fft; - -class RFFTWCacheId : public CacheId { - public: - RFFTWCacheId(int n, int dir, int flags); - - virtual bool operator==(const RFFTWCacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const RFFTWCacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && - m_flags == other.m_flags && - th->is_equal(*ot); - } - - public: - int m_dir; - int m_flags; -}; - -RFFTWCacheId::RFFTWCacheId(int n, int dir, int flags): - CacheId(n), - m_dir(dir), - m_flags(flags) -{ -} - -class RFFTWCache : public Cache { - public: - RFFTWCache(const RFFTWCacheId& id); - virtual ~RFFTWCache(); - - int compute(double* inout) const; - - protected: - rfftw_plan m_plan; - double *m_wrk; -}; - -RFFTWCache::RFFTWCache(const RFFTWCacheId& id) -: Cache(id) -{ - m_wrk = (double *) malloc(sizeof(double) * id.m_n); - if(m_wrk == NULL) { - goto fail; - } - - m_plan = rfftw_create_plan(id.m_n, - (id.m_dir > 0 ? FFTW_REAL_TO_COMPLEX : - FFTW_COMPLEX_TO_REAL), - id.m_flags); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return; - -clean_wrk: - free(m_wrk); -fail: - throw std::bad_alloc(); -} - -RFFTWCache::~RFFTWCache() -{ - free(m_wrk); - rfftw_destroy_plan(m_plan); -} - -int RFFTWCache::compute(double* inout) const -{ - if(m_id.m_dir == 1) { - memcpy(m_wrk, inout, sizeof(double) * m_id.m_n); - rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); - COPYRFFTW2STD(m_wrk, inout, m_id.m_n); - } else { - COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); - rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); - memcpy(inout, m_wrk, sizeof(double) * m_id.m_n); - } - return 0; -}; - -CacheManager rfftw_cmgr(10); - -void drfft_fftw(double *inout, int n, int dir, - int howmany, int normalize) -{ - int i; - double *ptr = inout; - RFFTWCache *cache; - - cache = rfftw_cmgr.get_cache( - RFFTWCacheId(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE)); - - if (dir != -1 && dir != 1) { - fprintf(stderr, "drfft: invalid dir=%d\n", dir); - return; - } else { - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,95 +0,0 @@ -#include - -#include -#include - -#include "cycliccache.h" -#include "api.h" - -using namespace fft; - -class FFTWCacheId : public CacheId { - public: - FFTWCacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; - - virtual bool operator==(const FFTWCacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTWCacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; -}; - -class FFTWCache : public Cache { - public: - FFTWCache(const FFTWCacheId& id); - virtual ~FFTWCache(); - - int compute(fftw_complex* inout) - { - fftw_one(m_plan, inout, NULL); - return 0; - }; - - protected: - fftw_plan m_plan; -}; - -FFTWCache::FFTWCache(const FFTWCacheId& id) -: Cache(id) -{ - m_plan = fftw_create_plan(id.m_n, - (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_IN_PLACE); - - if (m_plan == NULL) { - goto fail; - } - - return ; - -fail: - throw std::bad_alloc(); -} - -FFTWCache::~FFTWCache() -{ - fftw_destroy_plan(m_plan); -} - -CacheManager fftw_cmgr(10); - -void zfft_fftw(complex_double * inout, int n, - int dir, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - FFTWCache* cache; - - cache = fftw_cmgr.get_cache(FFTWCacheId(n, dir)); - - if (dir != -1 && dir != 1) { - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } else { - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute((fftw_complex *) ptr); - } - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw/zfftnd.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,192 +0,0 @@ -/* - * fftw2 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Tue May 13 02:00 PM 2008 J - */ -#include -#include - -#include -#include - -#include -#include "api.h" - -using namespace fft; - -static int equal_dims(int rank,int *dims1,int *dims2) -{ - int i; - for (i = 0; i < rank; ++i) { - if (dims1[i] != dims2[i]) { - return 0; - } - } - return 1; -} - -class NDFFTWCacheId { - public: - NDFFTWCacheId(int rank, int *dims, int dir, int flags); - virtual ~NDFFTWCacheId(); - - NDFFTWCacheId(const NDFFTWCacheId &); - - virtual bool operator==(const NDFFTWCacheId & other) const { - return is_equal(other); - }; - - virtual bool is_equal(const NDFFTWCacheId & other) const; - - public: - int m_dir; - int m_rank; - int *m_dims; - int m_flags; - - private: - int init(int rank, int *dims); -}; - -int NDFFTWCacheId::init(int rank, int *dims) -{ - m_dims = (int *) malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); - - return 0; - -} - -NDFFTWCacheId::NDFFTWCacheId(int rank, int *dims, int dir, int flags) : - m_dir(dir), - m_rank(rank), - m_flags(flags) -{ - if (init(rank, dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTWCacheId::NDFFTWCacheId(const NDFFTWCacheId & copy) : - m_dir(copy.m_dir), - m_rank(copy.m_rank), - m_flags(copy.m_flags) -{ - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTWCacheId::~NDFFTWCacheId() -{ - free(m_dims); -} - -bool NDFFTWCacheId::is_equal(const NDFFTWCacheId & other) const -{ - bool res; - - res = (other.m_dir == m_dir); - res = res && (other.m_flags == m_flags); - - if (m_rank == other.m_rank) { - res = res && equal_dims(m_rank, m_dims, other.m_dims); - } else { - return false; - } - - return res; -} - -class NDFFTWCache : public Cache < NDFFTWCacheId > { - public: - NDFFTWCache(const NDFFTWCacheId & id); - virtual ~ NDFFTWCache(); - - int compute(fftw_complex * inout) const - { - fftwnd_one(m_plan, inout, NULL); - return 0; - }; - - protected: - fftwnd_plan m_plan; -}; - -NDFFTWCache::NDFFTWCache(const NDFFTWCacheId & id) -: Cache < NDFFTWCacheId > (id) -{ - int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; -#if 0 - int sz; - int i; - - sz = 1; - for (i = 0; i < m_id.m_rank; ++i) { - sz *= m_id.m_dims[i]; - } -#endif - - m_plan = fftwnd_create_plan(m_id.m_rank, - m_id.m_dims, - (id.m_dir > 0 ? - FFTW_FORWARD : FFTW_BACKWARD), - flags); - - if (m_plan == NULL) { - goto fail; - } - - return; - -fail: - throw std::bad_alloc(); -} - -NDFFTWCache::~NDFFTWCache() -{ - fftwnd_destroy_plan(m_plan); -} - -static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); - -void zfftnd_fftw(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - NDFFTWCache *cache; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - cache = fftwnd_cmgr.get_cache( - NDFFTWCacheId(rank, dims, direction, - FFTW_IN_PLACE | FFTW_ESTIMATE)); - - for (i = 0; i < howmany; ++i, ptr += sz) { - cache->compute((fftw_complex*)ptr); - } - - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,19 +0,0 @@ -#ifndef _SCIPY_FFTPACK_FFTW3_API_H_ -#define _SCIPY_FFTPACK_FFTW3_API_H_ - -#include "fftpack.h" - -/* - * straight FFT api - */ -void drfft_fftw3(double * inout, int n, int direction, int howmany, - int normalize); - -void zfft_fftw3(complex_double * inout, - int n, int direction, int howmany, int normalize); - -void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize); - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/common.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,72 +0,0 @@ -#ifndef _SCIPYFFT_FFTW3_COMMON_H_ -#define _SCIPYFFT_FFTW3_COMMON_H_ - -#include "cycliccache.h" - -#include - -#define COPYRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) { \ - *(DEST+2*n2-1) = *(SRC+n2); \ - if ((N)%2) \ - *(DEST+2*n2) = *(SRC+(N)-n2); \ - } \ -} -#define COPYINVRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) {\ - *(DEST+n2) = *(SRC+2*n2-1); \ - if ((N)%2) \ - *(DEST+(N)-n2) = *(SRC+2*n2); \ - } \ -} - -namespace fft { - -inline bool is_simd_aligned(const void * p) -{ - return (((reinterpret_cast (p)) & 0xF) == 0); -} - -class FFTW3CacheId : public CacheId { - public: - FFTW3CacheId(int n, int dir, bool isalign) : - CacheId(n), - m_dir(dir), - m_isalign(isalign) - { - }; - - virtual bool operator==(const FFTW3CacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTW3CacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_isalign == other.m_isalign && - m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; - bool m_isalign; -}; - -}; // namespace fft - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/drfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,139 +0,0 @@ -/* - * Last Change: Tue May 13 02:00 PM 2008 J - * - * RFFTW3 implementation - * - * Original code by Pearu Peterson. - */ - -#include -#include - -#include - -#include "common.h" -#include "api.h" - -using namespace fft; - -class RFFTW3Cache : public Cache { - public: - RFFTW3Cache(const FFTW3CacheId& id); - virtual ~RFFTW3Cache(); - - int compute_forward(double* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : - true); - fftw_execute_r2r(m_plan, inout, m_wrk); - COPYRFFTW2STD(m_wrk, inout, m_id.m_n); - return 0; - }; - - int compute_backward(double* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : - true); - COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); - fftw_execute_r2r(m_plan, m_wrk, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - double *m_wrk; - double *m_wrk2; -}; - -RFFTW3Cache::RFFTW3Cache(const FFTW3CacheId& id) -: Cache(id) -{ - int flags = FFTW_MEASURE; - - m_wrk = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk == NULL) { - goto fail_wrk; - } - - m_wrk2 = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk2 == NULL) { - goto clean_wrk; - } - - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } - - m_plan = fftw_plan_r2r_1d(id.m_n, m_wrk, m_wrk2, - (id.m_dir > 0 ? FFTW_R2HC:FFTW_HC2R), - flags); - - if (m_plan == NULL) { - goto clean_wrk2; - } - - return ; - -clean_wrk2: - fftw_free(m_wrk2); -clean_wrk: - fftw_free(m_wrk); -fail_wrk: - throw std::bad_alloc(); -} - -RFFTW3Cache::~RFFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk2); - fftw_free(m_wrk); -} - -static CacheManager drfftw3_cmgr(10); - -void drfft_fftw3(double *inout, int n, int direction, int - howmany, int normalize) -{ - int i; - double *ptr = inout; - - RFFTW3Cache *cache; - bool isaligned; - - isaligned = is_simd_aligned(ptr); - - if (howmany > 1) { - /* - * If executing for several consecutive buffers, we have to - * check that the shifting one buffer does not make it - * unaligned - */ - isaligned = isaligned && is_simd_aligned(ptr + n); - } - - cache = drfftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,114 +0,0 @@ -#include -#include - -#include - -#include "common.h" -#include "api.h" - -using namespace fft; - -class FFTW3Cache : public Cache { - public: - FFTW3Cache(const FFTW3CacheId& id); - virtual ~FFTW3Cache(); - - int compute(fftw_complex* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : - true); - fftw_execute_dft(m_plan, inout, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - fftw_complex *m_wrk; -}; - -FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) -: Cache(id) -{ - int flags = FFTW_ESTIMATE; - - m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk == NULL) { - goto fail_wrk; - } - - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } - - m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, - (id.m_dir > 0 ? FFTW_FORWARD : - FFTW_BACKWARD), - flags); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return ; - -clean_wrk: - fftw_free(m_wrk); -fail_wrk: - throw std::bad_alloc(); -} - -FFTW3Cache::~FFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk); -} - -static CacheManager zfftw3_cmgr(10); - -void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, - int normalize) -{ - fftw_complex *ptr = (fftw_complex*)inout; - double factor = 1./n; - FFTW3Cache *cache; - bool isaligned; - - int i; - - isaligned = is_simd_aligned(ptr); - - if (howmany > 1) { - /* - * If executing for several consecutive buffers, we have to - * check that the shifting one buffer does not make it - * unaligned - */ - isaligned = isaligned && is_simd_aligned(ptr + n); - } - cache = zfftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr =(fftw_complex*)inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) *= factor; - *((double *) (ptr++) + 1) *= factor; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/fftw3/zfftnd.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,202 +0,0 @@ -/* - * fftw3 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Tue May 13 02:00 PM 2008 J - */ -#include -#include - -#include - -#include "common.h" -#include "api.h" - -using namespace fft; - -class NDFFTW3CacheId { - public: - NDFFTW3CacheId(int rank, int *dims, int howmany, int dir, - bool isalign); - virtual ~NDFFTW3CacheId(); - - NDFFTW3CacheId(const NDFFTW3CacheId &); - - virtual bool operator==(const NDFFTW3CacheId & other) const { - return is_equal(other); - }; - - virtual bool is_equal(const NDFFTW3CacheId & other) const; - - public: - int m_rank; - int *m_dims; - int m_howmany; - int m_dir; - bool m_isalign; - - private: - int init(int rank, int *dims); -}; - -int NDFFTW3CacheId::init(int rank, int *dims) -{ - m_dims = (int *) malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); - - return 0; - -} - -NDFFTW3CacheId::NDFFTW3CacheId(int rank, int *dims, int howmany, - int dir, bool isalign) : - m_rank(rank), - m_howmany(howmany), - m_dir(dir), - m_isalign(isalign) -{ - if (init(rank, dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId & copy) : - m_rank(copy.m_rank), - m_howmany(copy.m_howmany), - m_dir(copy.m_dir), - m_isalign(copy.m_isalign) -{ - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTW3CacheId::~NDFFTW3CacheId() -{ - free(m_dims); -} - -bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId & other) const -{ - bool res; - int i; - - res = (other.m_dir == m_dir); - res = res && (other.m_isalign == m_isalign); - res = res && (m_howmany == other.m_howmany); - - if (m_rank == other.m_rank) { - for (i = 0; i < m_rank; ++i) { - res = res && (m_dims[i] == other.m_dims[i]); - } - } else { - return false; - } - - return res; -} - -class NDFFTW3Cache:public Cache < NDFFTW3CacheId > { - public: - NDFFTW3Cache(const NDFFTW3CacheId & id); - virtual ~ NDFFTW3Cache(); - - int compute(fftw_complex * inout) const { - assert(m_id.m_isalign ? is_simd_aligned(inout) : true); - fftw_execute_dft(m_plan, inout, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - fftw_complex *m_wrk; -}; - -NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId & id) -: Cache < NDFFTW3CacheId > (id) -{ - int flags = FFTW_ESTIMATE; - int sz; - int i; - - sz = 1; - for (i = 0; i < m_id.m_rank; ++i) { - sz *= m_id.m_dims[i]; - } - - m_wrk = (fftw_complex *) fftw_malloc(sz * sizeof(fftw_complex)); - if (m_wrk == NULL) { - goto fail_wrk; - } - - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } - - m_plan = fftw_plan_many_dft(m_id.m_rank, - m_id.m_dims, m_id.m_howmany, - m_wrk, NULL, 1, sz, - m_wrk, NULL, 1, sz, - (id.m_dir > - 0 ? FFTW_FORWARD : FFTW_BACKWARD), - flags); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return; - - clean_wrk: - fftw_free(m_wrk); - fail_wrk: - throw std::bad_alloc(); -} - -NDFFTW3Cache::~NDFFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk); -} - -static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > ndfftw3_cmgr(10); - -extern void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - fftw_complex *ptr = (fftw_complex *) inout; - NDFFTW3Cache *cache; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - cache = - ndfftw3_cmgr. - get_cache(NDFFTW3CacheId - (rank, dims, howmany, direction, - is_simd_aligned(inout))); - - cache->compute(ptr); - - if (normalize) { - ptr = (fftw_complex *) inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/mkl/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/api.h 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/mkl/api.h 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,16 +0,0 @@ -#ifndef _SCIPY_FFTPACK_MKL_API_H_ -#define _SCIPY_FFTPACK_MKL_API_H_ - -#include "fftpack.h" - -/* - * straight FFT api - */ -void zfft_mkl(complex_double * inout, - int n, int direction, int howmany, int normalize); - -void zfftnd_mkl(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize); - -#endif Deleted: branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfft.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,92 +0,0 @@ -#include - -#include - -#include "api.h" -#include "cycliccache.h" - -using namespace fft; - -class MKLCacheId : public CacheId { - public: - MKLCacheId(int n) : CacheId(n) {}; -}; - - -class MKLCache: public Cache { - public: - MKLCache(const MKLCacheId& id); - virtual ~MKLCache(); - - int compute_forward(complex_double * inout) const; - int compute_backward(complex_double * inout) const; - - protected: - DFTI_DESCRIPTOR_HANDLE m_hdl; -}; - -MKLCache::MKLCache(const MKLCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n); - DftiCommitDescriptor(m_hdl); - - return; -} - -MKLCache::~MKLCache() -{ - DftiFreeDescriptor(&m_hdl); -} - -int MKLCache::compute_forward(complex_double *inout) const -{ - DftiComputeForward(m_hdl, (double *) inout); - return 0; -} - -int MKLCache::compute_backward(complex_double *inout) const -{ - DftiComputeBackward(m_hdl, (double *) inout); - return 0; -} - -CacheManager zmkl_cmgr(10); - -void zfft_mkl(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - MKLCache *cache; - - cache = zmkl_cmgr.get_cache(MKLCacheId(n)); - - switch (direction) { - - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-15 12:27:46 UTC (rev 4331) +++ branches/refactor_fft/scipy/fftpack/src/mkl/zfftnd.cxx 2008-05-15 12:28:27 UTC (rev 4332) @@ -1,211 +0,0 @@ -/* - * MKL backend for multi dimensional fft - * - * Original code by David M. Cooke - * - * Last Change: Tue May 13 05:00 PM 2008 J - */ -#include - -#include - -#include "api.h" -#include "cycliccache.h" - -using namespace fft; - -static int equal_dims(int rank,int *dims1,int *dims2) -{ - int i; - for (i = 0; i < rank; ++i) { - if (dims1[i] != dims2[i]) { - return 0; - } - } - return 1; -} - -class NDMKLCacheId { - public: - NDMKLCacheId(int rank, int *dim); - virtual ~NDMKLCacheId(); - - NDMKLCacheId(const NDMKLCacheId &); - - virtual bool operator==(const NDMKLCacheId & other) const { - return is_equal(other); - }; - - virtual bool is_equal(const NDMKLCacheId & other) const; - - public: - int m_rank; - int *m_dims; - - private: - int init(int rank, int *dims); -}; - -int NDMKLCacheId::init(int rank, int *dims) -{ - m_dims = (int *) malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); - - return 0; - -} - -NDMKLCacheId::NDMKLCacheId(int rank, int *dims) : - m_rank(rank) -{ - if (init(rank, dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDMKLCacheId::NDMKLCacheId(const NDMKLCacheId & copy) : - m_rank(copy.m_rank) -{ - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDMKLCacheId::~NDMKLCacheId() -{ - free(m_dims); -} - -bool NDMKLCacheId::is_equal(const NDMKLCacheId & other) const -{ - bool res; - - if (m_rank == other.m_rank) { - res = equal_dims(m_rank, m_dims, other.m_dims); - } else { - return false; - } - - return res; -} - -/* - * Cache class for nd-MKL - */ -class NDMKLCache:public Cache < NDMKLCacheId > { - public: - NDMKLCache(const NDMKLCacheId & id); - virtual ~ NDMKLCache(); - - int compute_forward(double * inout) const - { - DftiComputeForward(m_hdl, inout); - return 0; - }; - - int compute_backward(double * inout) const - { - DftiComputeBackward(m_hdl, inout); - return 0; - }; - - protected: - int m_rank; - int *m_dims; - long *m_ndims; - DFTI_DESCRIPTOR_HANDLE m_hdl; - - private: - long *convert_dims(int n, int *dims) const; - -}; - -NDMKLCache::NDMKLCache(const NDMKLCacheId & id) -: Cache < NDMKLCacheId > (id) -{ - m_rank = id.m_rank; - m_ndims = convert_dims(id.m_rank, id.m_dims); - m_dims = (int *) malloc(sizeof(int) * m_rank); - if (m_dims == NULL) { - goto fail; - } - - memcpy(m_dims, id.m_dims, sizeof(int) * m_rank); - DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, (long) m_rank, - m_ndims); - DftiCommitDescriptor(m_hdl); - - return; - -fail: - throw std::bad_alloc(); -} - -NDMKLCache::~NDMKLCache() -{ - DftiFreeDescriptor(&m_hdl); - free(m_dims); - free(m_ndims); -} - -long* NDMKLCache::convert_dims(int n, int *dims) const -{ - long *ndim; - int i; - - ndim = (long *) malloc(sizeof(*ndim) * n); - for (i = 0; i < n; i++) { - ndim[i] = (long) dims[i]; - } - return ndim; -} - -static CacheManager < NDMKLCacheId, NDMKLCache > ndmkl_cmgr(10); - -void zfftnd_mkl(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - NDMKLCache *cache; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - cache = ndmkl_cmgr.get_cache(NDMKLCacheId(rank, dims)); - switch(direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += sz) { - cache->compute_forward((double*)ptr); - } - break; - case -1: - for (i = 0; i < howmany; ++i, ptr += sz) { - cache->compute_backward((double*)ptr); - } - break; - default: - fprintf(stderr, - "nd mkl:Wrong direction (this is a bug)\n"); - return; - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} From scipy-svn at scipy.org Thu May 15 08:29:57 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:29:57 -0500 (CDT) Subject: [Scipy-svn] r4333 - in branches/refactor_fft/scipy/fftpack: . backends backends/include Message-ID: <20080515122957.EEC0039C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:29:46 -0500 (Thu, 15 May 2008) New Revision: 4333 Added: branches/refactor_fft/scipy/fftpack/backends/include/ branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h branches/refactor_fft/scipy/fftpack/backends/setup.py Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Modify setup to build optional backends if available. Added: branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:28:27 UTC (rev 4332) +++ branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:29:46 UTC (rev 4333) @@ -0,0 +1,100 @@ +#ifndef _CYCLIC_CACHE_H_ +#define _CYCLIC_CACHE_H_ + +namespace fft { + +class CacheId { + public: + CacheId(int n) : m_n(n) {}; + virtual ~CacheId() {}; + + virtual bool operator==(const CacheId& other) const + { + return is_equal(other); + }; + + virtual bool is_equal(const CacheId& other) const + { + return m_n == other.m_n; + }; + + public: + int m_n; + +}; + +template +class Cache { + public: + Cache() {}; + Cache(const T& id) : m_id(id) {}; + virtual ~Cache() {}; + + virtual bool operator==(const Cache& other) const + { + return other.m_id == m_id; + }; + + public: + T m_id; +}; + +template +class CacheManager { + public: + CacheManager(int n) : + m_n(n), + m_curn(0), + m_last(0) + { + m_cache = new U*[n]; + + }; + + virtual ~CacheManager() + { + int i; + + for (i = 0; i < m_curn; ++i) { + delete m_cache[i]; + } + + delete[] m_cache; + } + + virtual U* get_cache(const T& id) + { + int i; + + /* Look in the current cache */ + for (i = 0; i < m_curn; ++i) { + if ( m_cache[i]->m_id == id) { + m_last = i; + return m_cache[i]; + } + } + + /* If still space, create a new cache */ + if (m_curn < m_n) { + i = m_curn; + ++m_curn; + } else { + i = (m_last < m_n - 1) ? m_last + 1 : 0; + delete m_cache[i]; + } + + m_cache[i] = new U(id); + m_last = i; + return m_cache[i]; + }; + + private: + U** m_cache; + int m_n; + int m_curn; + int m_last; +}; + +} + +#endif Added: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:28:27 UTC (rev 4332) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:29:46 UTC (rev 4333) @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# Created by Pearu Peterson, August 2002 + +from os.path import join + +def build_backends(config): + from numpy.distutils.system_info import get_info + # Build backends for fftpack and convolve + backends_src = {} + backends_src['djbfft'] = [join('djbfft/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']] + backends_src['fftw3'] = [join('fftw3/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + backends_src['fftw2'] = [join('fftw/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] + backends_src['fftpack'] = [join('fftpack/', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] + backends_src['mkl'] = [join('mkl/', i) for i in + ['zfft.cxx', 'zfftnd.cxx']] + + backends = ['mkl', 'djbfft', 'fftw3', 'fftw2'] + for backend in backends: + info = get_info(backend) + if info: + config.add_library("%s_backend" % backend, + sources = backends_src[backend], + include_dirs = ["include", + info['include_dirs']]) + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('backends', parent_package, top_path) + build_backends(config) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) Property changes on: branches/refactor_fft/scipy/fftpack/backends/setup.py ___________________________________________________________________ Name: svn:executable + * Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:28:27 UTC (rev 4332) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:29:46 UTC (rev 4333) @@ -106,6 +106,10 @@ libraries = ["dfftpack"], include_dirs = ['src'], ) + + # Build optional backends + config.add_subpackage('backends') + return config if __name__ == '__main__': From scipy-svn at scipy.org Thu May 15 08:30:16 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:30:16 -0500 (CDT) Subject: [Scipy-svn] r4334 - branches/refactor_fft/scipy/fftpack Message-ID: <20080515123016.CE68339C31E@scipy.org> Author: cdavid Date: 2008-05-15 07:30:09 -0500 (Thu, 15 May 2008) New Revision: 4334 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Fix indentation. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:29:46 UTC (rev 4333) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:30:09 UTC (rev 4334) @@ -92,7 +92,7 @@ sources = ['fftpack.pyf', 'src/zrfft.c'] for s in ["zfft.cxx", "zfftnd.cxx", "drfft.cxx"]: - sources.append(join('src/fftpack', s)) + sources.append(join('src/fftpack', s)) # Build the python extensions config.add_extension('_fftpack', From scipy-svn at scipy.org Thu May 15 08:30:35 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:30:35 -0500 (CDT) Subject: [Scipy-svn] r4335 - branches/refactor_fft/scipy/fftpack Message-ID: <20080515123035.0D72339C2AA@scipy.org> Author: cdavid Date: 2008-05-15 07:30:26 -0500 (Thu, 15 May 2008) New Revision: 4335 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Remove dead code. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:30:09 UTC (rev 4334) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:30:26 UTC (rev 4335) @@ -3,83 +3,6 @@ from os.path import join -def build_backends(config, opts, info, djbfft_info, fft_opt_info): - # Build backends for fftpack and convolve - backends_src = {} - backends_src['djbfft'] = [join('src/djbfft/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']] - backends_src['fftw3'] = [join('src/fftw3/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - backends_src['fftw2'] = [join('src/fftw/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] - backends_src['fftpack'] = [join('src/fftpack/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] - backends_src['mkl'] = [join('src/mkl/', i) for i in - ['zfft.cxx', 'zfftnd.cxx']] - - libs = [] - - def build_backend(backend, opts): - libname = '%s_backend' % backend - config.add_library(libname, - sources = backends_src[backend], - include_dirs = ['src'] + [i['include_dirs'] for i in opts]) - libs.append(libname) - - # NOTE: ORDER MATTERS !!!!!! The order in the libs list matters: don't - # change anything here if you don't know what you are doing, better ask the - # scipy-dev ML. If libfoo1 depends on libfoo2, -lfoo1 -lfoo2 works, but - # -lfoo2 -lfoo1 won't (and you don't know it at runtime, only at load - # time). - if info['mkl']: - build_backend('mkl', [fft_opt_info]) - - if info['djbfft']: - build_backend('djbfft', [djbfft_info]) - - for b in ['fftw3', 'fftw2']: - if info[b]: - build_backend(b, [fft_opt_info]) - - if info['fftpack']: - build_backend('fftpack', []) - - libs.append('dfftpack') - return libs - -def get_available_backends(): - # XXX: This whole thing is just a big mess... - from numpy.distutils.system_info import get_info - backends = ['mkl', 'djbfft', 'fftw3', 'fftw2', 'fftpack'] - info = dict([(k, False) for k in backends]) - - djbfft_info = {} - mkl_info = get_info('mkl') - if mkl_info: - mkl_info.setdefault('define_macros', []).append(('SCIPY_MKL_H', None)) - fft_opt_info = mkl_info - info['mkl'] = True - # We need fftpack for convolve and real transforms - info['fftpack'] = True - else: - fft_opt_info = get_info('fftw3') - if fft_opt_info: - info['fftw3'] = True - # We need fftpack for convolve (no fftw3 backend) - info['fftpack'] = True - else: - fft_opt_info = get_info('fftw2') - if not fft_opt_info: - info['fftpack'] = True - else: - info['fftw2'] = True - - djbfft_info = get_info('djbfft') - if djbfft_info: - info['djbfft'] = True - - return info, djbfft_info, fft_opt_info - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('fftpack',parent_package, top_path) From scipy-svn at scipy.org Thu May 15 08:31:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:31:07 -0500 (CDT) Subject: [Scipy-svn] r4336 - in branches/refactor_fft/scipy/fftpack/backends: fftw3 include Message-ID: <20080515123107.F0DA339C2AA@scipy.org> Author: cdavid Date: 2008-05-15 07:30:52 -0500 (Thu, 15 May 2008) New Revision: 4336 Added: branches/refactor_fft/scipy/fftpack/backends/include/misc.h Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h Log: fftw3 now builds. Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h 2008-05-15 12:30:26 UTC (rev 4335) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h 2008-05-15 12:30:52 UTC (rev 4336) @@ -1,8 +1,6 @@ #ifndef _SCIPY_FFTPACK_FFTW3_API_H_ #define _SCIPY_FFTPACK_FFTW3_API_H_ -#include "fftpack.h" - /* * straight FFT api */ Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h 2008-05-15 12:30:26 UTC (rev 4335) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h 2008-05-15 12:30:52 UTC (rev 4336) @@ -2,6 +2,7 @@ #define _SCIPYFFT_FFTW3_COMMON_H_ #include "cycliccache.h" +#include "misc.h" #include Added: branches/refactor_fft/scipy/fftpack/backends/include/misc.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/include/misc.h 2008-05-15 12:30:26 UTC (rev 4335) +++ branches/refactor_fft/scipy/fftpack/backends/include/misc.h 2008-05-15 12:30:52 UTC (rev 4336) @@ -0,0 +1,8 @@ +#ifndef _SCIPY_FFTPACK_BACKENDS_ +#define _SCIPY_FFTPACK_BACKENDS_ + +#include + +typedef std::complex complex_double; + +#endif From scipy-svn at scipy.org Thu May 15 08:31:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:31:41 -0500 (CDT) Subject: [Scipy-svn] r4337 - in branches/refactor_fft/scipy/fftpack/backends: djbfft fftw mkl Message-ID: <20080515123141.1CB5939C2AA@scipy.org> Author: cdavid Date: 2008-05-15 07:31:24 -0500 (Thu, 15 May 2008) New Revision: 4337 Modified: branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h branches/refactor_fft/scipy/fftpack/backends/fftw/api.h branches/refactor_fft/scipy/fftpack/backends/mkl/api.h Log: mkl, djbfft and fftw backends now build. Modified: branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h 2008-05-15 12:30:52 UTC (rev 4336) +++ branches/refactor_fft/scipy/fftpack/backends/djbfft/api.h 2008-05-15 12:31:24 UTC (rev 4337) @@ -1,7 +1,7 @@ #ifndef _SCIPY_FFTPACK_DJBFFT_API_H_ #define _SCIPY_FFTPACK_DJBFFT_API_H_ -#include "fftpack.h" +#include "misc.h" /* * straight FFT api Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/api.h 2008-05-15 12:30:52 UTC (rev 4336) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/api.h 2008-05-15 12:31:24 UTC (rev 4337) @@ -1,7 +1,7 @@ #ifndef _SCIPY_FFTPACK_FFTW_API_H_ #define _SCIPY_FFTPACK_FFTW_API_H_ -#include "fftpack.h" +#include "misc.h" /* * straight FFT api Modified: branches/refactor_fft/scipy/fftpack/backends/mkl/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-15 12:30:52 UTC (rev 4336) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-15 12:31:24 UTC (rev 4337) @@ -1,7 +1,7 @@ #ifndef _SCIPY_FFTPACK_MKL_API_H_ #define _SCIPY_FFTPACK_MKL_API_H_ -#include "fftpack.h" +#include "misc.h" /* * straight FFT api From scipy-svn at scipy.org Thu May 15 08:32:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:32:28 -0500 (CDT) Subject: [Scipy-svn] r4338 - in branches/refactor_fft/scipy/fftpack/backends: . common fftw3 fftw3/src include Message-ID: <20080515123228.09FD539C2AA@scipy.org> Author: cdavid Date: 2008-05-15 07:31:58 -0500 (Thu, 15 May 2008) New Revision: 4338 Added: branches/refactor_fft/scipy/fftpack/backends/common/ branches/refactor_fft/scipy/fftpack/backends/common/cycliccache.h branches/refactor_fft/scipy/fftpack/backends/common/misc.h branches/refactor_fft/scipy/fftpack/backends/fftw3/src/ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h branches/refactor_fft/scipy/fftpack/backends/fftw3/src/common.h branches/refactor_fft/scipy/fftpack/backends/fftw3/src/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/src/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/src/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h branches/refactor_fft/scipy/fftpack/backends/include/misc.h Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py Log: Put sources of fftw3 backend one dir deeper. Copied: branches/refactor_fft/scipy/fftpack/backends/common/cycliccache.h (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/common/cycliccache.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,100 @@ +#ifndef _CYCLIC_CACHE_H_ +#define _CYCLIC_CACHE_H_ + +namespace fft { + +class CacheId { + public: + CacheId(int n) : m_n(n) {}; + virtual ~CacheId() {}; + + virtual bool operator==(const CacheId& other) const + { + return is_equal(other); + }; + + virtual bool is_equal(const CacheId& other) const + { + return m_n == other.m_n; + }; + + public: + int m_n; + +}; + +template +class Cache { + public: + Cache() {}; + Cache(const T& id) : m_id(id) {}; + virtual ~Cache() {}; + + virtual bool operator==(const Cache& other) const + { + return other.m_id == m_id; + }; + + public: + T m_id; +}; + +template +class CacheManager { + public: + CacheManager(int n) : + m_n(n), + m_curn(0), + m_last(0) + { + m_cache = new U*[n]; + + }; + + virtual ~CacheManager() + { + int i; + + for (i = 0; i < m_curn; ++i) { + delete m_cache[i]; + } + + delete[] m_cache; + } + + virtual U* get_cache(const T& id) + { + int i; + + /* Look in the current cache */ + for (i = 0; i < m_curn; ++i) { + if ( m_cache[i]->m_id == id) { + m_last = i; + return m_cache[i]; + } + } + + /* If still space, create a new cache */ + if (m_curn < m_n) { + i = m_curn; + ++m_curn; + } else { + i = (m_last < m_n - 1) ? m_last + 1 : 0; + delete m_cache[i]; + } + + m_cache[i] = new U(id); + m_last = i; + return m_cache[i]; + }; + + private: + U** m_cache; + int m_n; + int m_curn; + int m_last; +}; + +} + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/common/misc.h (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/include/misc.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/include/misc.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/common/misc.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,8 @@ +#ifndef _SCIPY_FFTPACK_BACKENDS_ +#define _SCIPY_FFTPACK_BACKENDS_ + +#include + +typedef std::complex complex_double; + +#endif Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,17 +0,0 @@ -#ifndef _SCIPY_FFTPACK_FFTW3_API_H_ -#define _SCIPY_FFTPACK_FFTW3_API_H_ - -/* - * straight FFT api - */ -void drfft_fftw3(double * inout, int n, int direction, int howmany, - int normalize); - -void zfft_fftw3(complex_double * inout, - int n, int direction, int howmany, int normalize); - -void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize); - -#endif Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,73 +0,0 @@ -#ifndef _SCIPYFFT_FFTW3_COMMON_H_ -#define _SCIPYFFT_FFTW3_COMMON_H_ - -#include "cycliccache.h" -#include "misc.h" - -#include - -#define COPYRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) { \ - *(DEST+2*n2-1) = *(SRC+n2); \ - if ((N)%2) \ - *(DEST+2*n2) = *(SRC+(N)-n2); \ - } \ -} -#define COPYINVRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) {\ - *(DEST+n2) = *(SRC+2*n2-1); \ - if ((N)%2) \ - *(DEST+(N)-n2) = *(SRC+2*n2); \ - } \ -} - -namespace fft { - -inline bool is_simd_aligned(const void * p) -{ - return (((reinterpret_cast (p)) & 0xF) == 0); -} - -class FFTW3CacheId : public CacheId { - public: - FFTW3CacheId(int n, int dir, bool isalign) : - CacheId(n), - m_dir(dir), - m_isalign(isalign) - { - }; - - virtual bool operator==(const FFTW3CacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTW3CacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_isalign == other.m_isalign && - m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; - bool m_isalign; -}; - -}; // namespace fft - -#endif Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,139 +0,0 @@ -/* - * Last Change: Tue May 13 02:00 PM 2008 J - * - * RFFTW3 implementation - * - * Original code by Pearu Peterson. - */ - -#include -#include - -#include - -#include "common.h" -#include "api.h" - -using namespace fft; - -class RFFTW3Cache : public Cache { - public: - RFFTW3Cache(const FFTW3CacheId& id); - virtual ~RFFTW3Cache(); - - int compute_forward(double* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : - true); - fftw_execute_r2r(m_plan, inout, m_wrk); - COPYRFFTW2STD(m_wrk, inout, m_id.m_n); - return 0; - }; - - int compute_backward(double* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : - true); - COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); - fftw_execute_r2r(m_plan, m_wrk, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - double *m_wrk; - double *m_wrk2; -}; - -RFFTW3Cache::RFFTW3Cache(const FFTW3CacheId& id) -: Cache(id) -{ - int flags = FFTW_MEASURE; - - m_wrk = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk == NULL) { - goto fail_wrk; - } - - m_wrk2 = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk2 == NULL) { - goto clean_wrk; - } - - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } - - m_plan = fftw_plan_r2r_1d(id.m_n, m_wrk, m_wrk2, - (id.m_dir > 0 ? FFTW_R2HC:FFTW_HC2R), - flags); - - if (m_plan == NULL) { - goto clean_wrk2; - } - - return ; - -clean_wrk2: - fftw_free(m_wrk2); -clean_wrk: - fftw_free(m_wrk); -fail_wrk: - throw std::bad_alloc(); -} - -RFFTW3Cache::~RFFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk2); - fftw_free(m_wrk); -} - -static CacheManager drfftw3_cmgr(10); - -void drfft_fftw3(double *inout, int n, int direction, int - howmany, int normalize) -{ - int i; - double *ptr = inout; - - RFFTW3Cache *cache; - bool isaligned; - - isaligned = is_simd_aligned(ptr); - - if (howmany > 1) { - /* - * If executing for several consecutive buffers, we have to - * check that the shifting one buffer does not make it - * unaligned - */ - isaligned = isaligned && is_simd_aligned(ptr + n); - } - - cache = drfftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); - - switch (direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - default: - fprintf(stderr, "drfft: invalid direction=%d\n", direction); - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/api.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,17 @@ +#ifndef _SCIPY_FFTPACK_FFTW3_API_H_ +#define _SCIPY_FFTPACK_FFTW3_API_H_ + +/* + * straight FFT api + */ +void drfft_fftw3(double * inout, int n, int direction, int howmany, + int normalize); + +void zfft_fftw3(complex_double * inout, + int n, int direction, int howmany, int normalize); + +void zfftnd_fftw3(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize); + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/common.h (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/common.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/common.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,73 @@ +#ifndef _SCIPYFFT_FFTW3_COMMON_H_ +#define _SCIPYFFT_FFTW3_COMMON_H_ + +#include "cycliccache.h" +#include "misc.h" + +#include + +#define COPYRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) { \ + *(DEST+2*n2-1) = *(SRC+n2); \ + if ((N)%2) \ + *(DEST+2*n2) = *(SRC+(N)-n2); \ + } \ +} +#define COPYINVRFFTW2STD(SRC,DEST,N) { \ + int j,n2=(N)/2; \ + *(DEST) = *(SRC); \ + for (j=1;j1) {\ + *(DEST+n2) = *(SRC+2*n2-1); \ + if ((N)%2) \ + *(DEST+(N)-n2) = *(SRC+2*n2); \ + } \ +} + +namespace fft { + +inline bool is_simd_aligned(const void * p) +{ + return (((reinterpret_cast (p)) & 0xF) == 0); +} + +class FFTW3CacheId : public CacheId { + public: + FFTW3CacheId(int n, int dir, bool isalign) : + CacheId(n), + m_dir(dir), + m_isalign(isalign) + { + }; + + virtual bool operator==(const FFTW3CacheId& other) const + { + return is_equal(other); + } + + virtual bool is_equal(const FFTW3CacheId& other) const + { + const CacheId *ot = &other; + const CacheId *th = this; + + return m_isalign == other.m_isalign && + m_dir == other.m_dir && th->is_equal(*ot); + } + + public: + int m_dir; + bool m_isalign; +}; + +}; // namespace fft + +#endif Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/drfft.cxx (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/drfft.cxx 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/drfft.cxx 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,139 @@ +/* + * Last Change: Tue May 13 02:00 PM 2008 J + * + * RFFTW3 implementation + * + * Original code by Pearu Peterson. + */ + +#include +#include + +#include + +#include "common.h" +#include "api.h" + +using namespace fft; + +class RFFTW3Cache : public Cache { + public: + RFFTW3Cache(const FFTW3CacheId& id); + virtual ~RFFTW3Cache(); + + int compute_forward(double* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); + fftw_execute_r2r(m_plan, inout, m_wrk); + COPYRFFTW2STD(m_wrk, inout, m_id.m_n); + return 0; + }; + + int compute_backward(double* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); + COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); + fftw_execute_r2r(m_plan, m_wrk, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + double *m_wrk; + double *m_wrk2; +}; + +RFFTW3Cache::RFFTW3Cache(const FFTW3CacheId& id) +: Cache(id) +{ + int flags = FFTW_MEASURE; + + m_wrk = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk == NULL) { + goto fail_wrk; + } + + m_wrk2 = (double*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk2 == NULL) { + goto clean_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_r2r_1d(id.m_n, m_wrk, m_wrk2, + (id.m_dir > 0 ? FFTW_R2HC:FFTW_HC2R), + flags); + + if (m_plan == NULL) { + goto clean_wrk2; + } + + return ; + +clean_wrk2: + fftw_free(m_wrk2); +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +RFFTW3Cache::~RFFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk2); + fftw_free(m_wrk); +} + +static CacheManager drfftw3_cmgr(10); + +void drfft_fftw3(double *inout, int n, int direction, int + howmany, int normalize) +{ + int i; + double *ptr = inout; + + RFFTW3Cache *cache; + bool isaligned; + + isaligned = is_simd_aligned(ptr); + + if (howmany > 1) { + /* + * If executing for several consecutive buffers, we have to + * check that the shifting one buffer does not make it + * unaligned + */ + isaligned = isaligned && is_simd_aligned(ptr + n); + } + + cache = drfftw3_cmgr.get_cache(FFTW3CacheId(n, direction, isaligned)); + + switch (direction) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_forward(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute_backward(ptr); + } + break; + default: + fprintf(stderr, "drfft: invalid direction=%d\n", direction); + } + + if (normalize) { + double d = 1.0 / n; + ptr = inout; + for (i = n * howmany - 1; i >= 0; --i) { + (*(ptr++)) *= d; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/zfft.cxx (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/zfft.cxx 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,114 @@ +#include +#include + +#include + +#include "common.h" +#include "api.h" + +using namespace fft; + +class FFTW3Cache : public Cache { + public: + FFTW3Cache(const FFTW3CacheId& id); + virtual ~FFTW3Cache(); + + int compute(fftw_complex* inout) const + { + assert (m_id.m_isalign ? is_simd_aligned(inout) : + true); + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; +}; + +FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) +: Cache(id) +{ + int flags = FFTW_ESTIMATE; + + m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); + if (m_wrk == NULL) { + goto fail_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, + (id.m_dir > 0 ? FFTW_FORWARD : + FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return ; + +clean_wrk: + fftw_free(m_wrk); +fail_wrk: + throw std::bad_alloc(); +} + +FFTW3Cache::~FFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk); +} + +static CacheManager zfftw3_cmgr(10); + +void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, + int normalize) +{ + fftw_complex *ptr = (fftw_complex*)inout; + double factor = 1./n; + FFTW3Cache *cache; + bool isaligned; + + int i; + + isaligned = is_simd_aligned(ptr); + + if (howmany > 1) { + /* + * If executing for several consecutive buffers, we have to + * check that the shifting one buffer does not make it + * unaligned + */ + isaligned = isaligned && is_simd_aligned(ptr + n); + } + cache = zfftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); + + switch (dir) { + case 1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute(ptr); + } + break; + + case -1: + for (i = 0; i < howmany; ++i, ptr += n) { + cache->compute(ptr); + } + break; + + default: + fprintf(stderr, "zfft: invalid dir=%d\n", dir); + } + + if (normalize) { + ptr =(fftw_complex*)inout; + for (i = n * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) *= factor; + *((double *) (ptr++) + 1) *= factor; + } + } +} Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/zfftnd.cxx (from rev 4337, branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/zfftnd.cxx 2008-05-15 12:31:58 UTC (rev 4338) @@ -0,0 +1,202 @@ +/* + * fftw3 backend for multi dimensional fft + * + * Original code by Pearu Peaterson + * + * Last Change: Tue May 13 02:00 PM 2008 J + */ +#include +#include + +#include + +#include "common.h" +#include "api.h" + +using namespace fft; + +class NDFFTW3CacheId { + public: + NDFFTW3CacheId(int rank, int *dims, int howmany, int dir, + bool isalign); + virtual ~NDFFTW3CacheId(); + + NDFFTW3CacheId(const NDFFTW3CacheId &); + + virtual bool operator==(const NDFFTW3CacheId & other) const { + return is_equal(other); + }; + + virtual bool is_equal(const NDFFTW3CacheId & other) const; + + public: + int m_rank; + int *m_dims; + int m_howmany; + int m_dir; + bool m_isalign; + + private: + int init(int rank, int *dims); +}; + +int NDFFTW3CacheId::init(int rank, int *dims) +{ + m_dims = (int *) malloc(sizeof(int) * rank); + if (m_dims == NULL) { + return -1; + } + memcpy(m_dims, dims, rank * sizeof(*m_dims)); + + return 0; + +} + +NDFFTW3CacheId::NDFFTW3CacheId(int rank, int *dims, int howmany, + int dir, bool isalign) : + m_rank(rank), + m_howmany(howmany), + m_dir(dir), + m_isalign(isalign) +{ + if (init(rank, dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId & copy) : + m_rank(copy.m_rank), + m_howmany(copy.m_howmany), + m_dir(copy.m_dir), + m_isalign(copy.m_isalign) +{ + if (init(copy.m_rank, copy.m_dims)) { + goto fail; + } + +fail: + std::bad_alloc(); +} + +NDFFTW3CacheId::~NDFFTW3CacheId() +{ + free(m_dims); +} + +bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId & other) const +{ + bool res; + int i; + + res = (other.m_dir == m_dir); + res = res && (other.m_isalign == m_isalign); + res = res && (m_howmany == other.m_howmany); + + if (m_rank == other.m_rank) { + for (i = 0; i < m_rank; ++i) { + res = res && (m_dims[i] == other.m_dims[i]); + } + } else { + return false; + } + + return res; +} + +class NDFFTW3Cache:public Cache < NDFFTW3CacheId > { + public: + NDFFTW3Cache(const NDFFTW3CacheId & id); + virtual ~ NDFFTW3Cache(); + + int compute(fftw_complex * inout) const { + assert(m_id.m_isalign ? is_simd_aligned(inout) : true); + fftw_execute_dft(m_plan, inout, inout); + return 0; + }; + + protected: + fftw_plan m_plan; + fftw_complex *m_wrk; +}; + +NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId & id) +: Cache < NDFFTW3CacheId > (id) +{ + int flags = FFTW_ESTIMATE; + int sz; + int i; + + sz = 1; + for (i = 0; i < m_id.m_rank; ++i) { + sz *= m_id.m_dims[i]; + } + + m_wrk = (fftw_complex *) fftw_malloc(sz * sizeof(fftw_complex)); + if (m_wrk == NULL) { + goto fail_wrk; + } + + if (!m_id.m_isalign) { + flags |= FFTW_UNALIGNED; + } + + m_plan = fftw_plan_many_dft(m_id.m_rank, + m_id.m_dims, m_id.m_howmany, + m_wrk, NULL, 1, sz, + m_wrk, NULL, 1, sz, + (id.m_dir > + 0 ? FFTW_FORWARD : FFTW_BACKWARD), + flags); + + if (m_plan == NULL) { + goto clean_wrk; + } + + return; + + clean_wrk: + fftw_free(m_wrk); + fail_wrk: + throw std::bad_alloc(); +} + +NDFFTW3Cache::~NDFFTW3Cache() +{ + fftw_destroy_plan(m_plan); + fftw_free(m_wrk); +} + +static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > ndfftw3_cmgr(10); + +extern void zfftnd_fftw3(complex_double * inout, int rank, + int *dims, int direction, int howmany, + int normalize) +{ + int i, sz; + fftw_complex *ptr = (fftw_complex *) inout; + NDFFTW3Cache *cache; + + sz = 1; + for (i = 0; i < rank; ++i) { + sz *= dims[i]; + } + + cache = + ndfftw3_cmgr. + get_cache(NDFFTW3CacheId + (rank, dims, howmany, direction, + is_simd_aligned(inout))); + + cache->compute(ptr); + + if (normalize) { + ptr = (fftw_complex *) inout; + for (i = sz * howmany - 1; i >= 0; --i) { + *((double *) (ptr)) /= sz; + *((double *) (ptr++) + 1) /= sz; + } + } +} Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/zfft.cxx 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,114 +0,0 @@ -#include -#include - -#include - -#include "common.h" -#include "api.h" - -using namespace fft; - -class FFTW3Cache : public Cache { - public: - FFTW3Cache(const FFTW3CacheId& id); - virtual ~FFTW3Cache(); - - int compute(fftw_complex* inout) const - { - assert (m_id.m_isalign ? is_simd_aligned(inout) : - true); - fftw_execute_dft(m_plan, inout, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - fftw_complex *m_wrk; -}; - -FFTW3Cache::FFTW3Cache(const FFTW3CacheId& id) -: Cache(id) -{ - int flags = FFTW_ESTIMATE; - - m_wrk = (fftw_complex*)fftw_malloc(id.m_n * sizeof(double) * 2); - if (m_wrk == NULL) { - goto fail_wrk; - } - - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } - - m_plan = fftw_plan_dft_1d(id.m_n, m_wrk, m_wrk, - (id.m_dir > 0 ? FFTW_FORWARD : - FFTW_BACKWARD), - flags); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return ; - -clean_wrk: - fftw_free(m_wrk); -fail_wrk: - throw std::bad_alloc(); -} - -FFTW3Cache::~FFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk); -} - -static CacheManager zfftw3_cmgr(10); - -void zfft_fftw3(complex_double * inout, int n, int dir, int howmany, - int normalize) -{ - fftw_complex *ptr = (fftw_complex*)inout; - double factor = 1./n; - FFTW3Cache *cache; - bool isaligned; - - int i; - - isaligned = is_simd_aligned(ptr); - - if (howmany > 1) { - /* - * If executing for several consecutive buffers, we have to - * check that the shifting one buffer does not make it - * unaligned - */ - isaligned = isaligned && is_simd_aligned(ptr + n); - } - cache = zfftw3_cmgr.get_cache(FFTW3CacheId(n, dir, isaligned)); - - switch (dir) { - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } - - if (normalize) { - ptr =(fftw_complex*)inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) *= factor; - *((double *) (ptr++) + 1) *= factor; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/zfftnd.cxx 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,202 +0,0 @@ -/* - * fftw3 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Tue May 13 02:00 PM 2008 J - */ -#include -#include - -#include - -#include "common.h" -#include "api.h" - -using namespace fft; - -class NDFFTW3CacheId { - public: - NDFFTW3CacheId(int rank, int *dims, int howmany, int dir, - bool isalign); - virtual ~NDFFTW3CacheId(); - - NDFFTW3CacheId(const NDFFTW3CacheId &); - - virtual bool operator==(const NDFFTW3CacheId & other) const { - return is_equal(other); - }; - - virtual bool is_equal(const NDFFTW3CacheId & other) const; - - public: - int m_rank; - int *m_dims; - int m_howmany; - int m_dir; - bool m_isalign; - - private: - int init(int rank, int *dims); -}; - -int NDFFTW3CacheId::init(int rank, int *dims) -{ - m_dims = (int *) malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); - - return 0; - -} - -NDFFTW3CacheId::NDFFTW3CacheId(int rank, int *dims, int howmany, - int dir, bool isalign) : - m_rank(rank), - m_howmany(howmany), - m_dir(dir), - m_isalign(isalign) -{ - if (init(rank, dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTW3CacheId::NDFFTW3CacheId(const NDFFTW3CacheId & copy) : - m_rank(copy.m_rank), - m_howmany(copy.m_howmany), - m_dir(copy.m_dir), - m_isalign(copy.m_isalign) -{ - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTW3CacheId::~NDFFTW3CacheId() -{ - free(m_dims); -} - -bool NDFFTW3CacheId::is_equal(const NDFFTW3CacheId & other) const -{ - bool res; - int i; - - res = (other.m_dir == m_dir); - res = res && (other.m_isalign == m_isalign); - res = res && (m_howmany == other.m_howmany); - - if (m_rank == other.m_rank) { - for (i = 0; i < m_rank; ++i) { - res = res && (m_dims[i] == other.m_dims[i]); - } - } else { - return false; - } - - return res; -} - -class NDFFTW3Cache:public Cache < NDFFTW3CacheId > { - public: - NDFFTW3Cache(const NDFFTW3CacheId & id); - virtual ~ NDFFTW3Cache(); - - int compute(fftw_complex * inout) const { - assert(m_id.m_isalign ? is_simd_aligned(inout) : true); - fftw_execute_dft(m_plan, inout, inout); - return 0; - }; - - protected: - fftw_plan m_plan; - fftw_complex *m_wrk; -}; - -NDFFTW3Cache::NDFFTW3Cache(const NDFFTW3CacheId & id) -: Cache < NDFFTW3CacheId > (id) -{ - int flags = FFTW_ESTIMATE; - int sz; - int i; - - sz = 1; - for (i = 0; i < m_id.m_rank; ++i) { - sz *= m_id.m_dims[i]; - } - - m_wrk = (fftw_complex *) fftw_malloc(sz * sizeof(fftw_complex)); - if (m_wrk == NULL) { - goto fail_wrk; - } - - if (!m_id.m_isalign) { - flags |= FFTW_UNALIGNED; - } - - m_plan = fftw_plan_many_dft(m_id.m_rank, - m_id.m_dims, m_id.m_howmany, - m_wrk, NULL, 1, sz, - m_wrk, NULL, 1, sz, - (id.m_dir > - 0 ? FFTW_FORWARD : FFTW_BACKWARD), - flags); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return; - - clean_wrk: - fftw_free(m_wrk); - fail_wrk: - throw std::bad_alloc(); -} - -NDFFTW3Cache::~NDFFTW3Cache() -{ - fftw_destroy_plan(m_plan); - fftw_free(m_wrk); -} - -static CacheManager < NDFFTW3CacheId, NDFFTW3Cache > ndfftw3_cmgr(10); - -extern void zfftnd_fftw3(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - fftw_complex *ptr = (fftw_complex *) inout; - NDFFTW3Cache *cache; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - cache = - ndfftw3_cmgr. - get_cache(NDFFTW3CacheId - (rank, dims, howmany, direction, - is_simd_aligned(inout))); - - cache->compute(ptr); - - if (normalize) { - ptr = (fftw_complex *) inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,100 +0,0 @@ -#ifndef _CYCLIC_CACHE_H_ -#define _CYCLIC_CACHE_H_ - -namespace fft { - -class CacheId { - public: - CacheId(int n) : m_n(n) {}; - virtual ~CacheId() {}; - - virtual bool operator==(const CacheId& other) const - { - return is_equal(other); - }; - - virtual bool is_equal(const CacheId& other) const - { - return m_n == other.m_n; - }; - - public: - int m_n; - -}; - -template -class Cache { - public: - Cache() {}; - Cache(const T& id) : m_id(id) {}; - virtual ~Cache() {}; - - virtual bool operator==(const Cache& other) const - { - return other.m_id == m_id; - }; - - public: - T m_id; -}; - -template -class CacheManager { - public: - CacheManager(int n) : - m_n(n), - m_curn(0), - m_last(0) - { - m_cache = new U*[n]; - - }; - - virtual ~CacheManager() - { - int i; - - for (i = 0; i < m_curn; ++i) { - delete m_cache[i]; - } - - delete[] m_cache; - } - - virtual U* get_cache(const T& id) - { - int i; - - /* Look in the current cache */ - for (i = 0; i < m_curn; ++i) { - if ( m_cache[i]->m_id == id) { - m_last = i; - return m_cache[i]; - } - } - - /* If still space, create a new cache */ - if (m_curn < m_n) { - i = m_curn; - ++m_curn; - } else { - i = (m_last < m_n - 1) ? m_last + 1 : 0; - delete m_cache[i]; - } - - m_cache[i] = new U(id); - m_last = i; - return m_cache[i]; - }; - - private: - U** m_cache; - int m_n; - int m_curn; - int m_last; -}; - -} - -#endif Deleted: branches/refactor_fft/scipy/fftpack/backends/include/misc.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/include/misc.h 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/include/misc.h 2008-05-15 12:31:58 UTC (rev 4338) @@ -1,8 +0,0 @@ -#ifndef _SCIPY_FFTPACK_BACKENDS_ -#define _SCIPY_FFTPACK_BACKENDS_ - -#include - -typedef std::complex complex_double; - -#endif Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:31:24 UTC (rev 4337) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:31:58 UTC (rev 4338) @@ -9,7 +9,7 @@ backends_src = {} backends_src['djbfft'] = [join('djbfft/', i) for i in ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']] - backends_src['fftw3'] = [join('fftw3/', i) for i in + backends_src['fftw3'] = [join('fftw3/src', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] backends_src['fftw2'] = [join('fftw/', i) for i in ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] @@ -24,8 +24,9 @@ if info: config.add_library("%s_backend" % backend, sources = backends_src[backend], - include_dirs = ["include", + include_dirs = ["common", info['include_dirs']]) + config.add_extension("_%s" % backend, sources = [join(backend, "%s.pyf" % backend)], extra_info = info, libraries = ["%s_backend" % backend]) def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration From scipy-svn at scipy.org Thu May 15 08:34:21 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:34:21 -0500 (CDT) Subject: [Scipy-svn] r4339 - branches/refactor_fft/scipy/fftpack/src Message-ID: <20080515123421.1875F39C2AA@scipy.org> Author: cdavid Date: 2008-05-15 07:34:14 -0500 (Thu, 15 May 2008) New Revision: 4339 Removed: branches/refactor_fft/scipy/fftpack/src/djbfft/ branches/refactor_fft/scipy/fftpack/src/fftw/ branches/refactor_fft/scipy/fftpack/src/fftw3/ branches/refactor_fft/scipy/fftpack/src/mkl/ Log: Remove empty directories which were not removed by git-svn. From scipy-svn at scipy.org Thu May 15 08:36:58 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:36:58 -0500 (CDT) Subject: [Scipy-svn] r4340 - branches/refactor_fft/scipy/fftpack/backends/fftw3 Message-ID: <20080515123658.17C4939C06D@scipy.org> Author: cdavid Date: 2008-05-15 07:36:52 -0500 (Thu, 15 May 2008) New Revision: 4340 Added: branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf Log: Add f2py interface for fftw3 backend. Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack.pyf) =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-15 12:31:58 UTC (rev 4338) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf 2008-05-15 12:36:52 UTC (rev 4340) @@ -0,0 +1,77 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _fftw3 + interface + + subroutine zfft_fftw3(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_fftw3 + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_fftw3 + + subroutine drfft_fftw3(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft_fftw3 + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft_fftw3 + + subroutine zrfft_fftw3(x,n,direction,howmany,normalize) + ! y = zrfft(x[,n,direction,normalize,overwrite_x]) + intent(c) zrfft_fftw3 + complex*16 intent(c,in,out,overwrite,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zrfft_fftw3 + + subroutine zfftnd_fftw3(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_fftw3 + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i Author: cdavid Date: 2008-05-15 07:44:54 -0500 (Thu, 15 May 2008) New Revision: 4341 Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h Log: Set C linkage for f2py Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h 2008-05-15 12:36:52 UTC (rev 4340) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/api.h 2008-05-15 12:44:54 UTC (rev 4341) @@ -4,6 +4,7 @@ /* * straight FFT api */ +extern "C" { void drfft_fftw3(double * inout, int n, int direction, int howmany, int normalize); @@ -13,5 +14,6 @@ void zfftnd_fftw3(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize); +}; #endif From scipy-svn at scipy.org Thu May 15 08:45:57 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 07:45:57 -0500 (CDT) Subject: [Scipy-svn] r4342 - in branches/refactor_fft/scipy/fftpack/backends: . fftw3 Message-ID: <20080515124557.1403539C01A@scipy.org> Author: cdavid Date: 2008-05-15 07:45:52 -0500 (Thu, 15 May 2008) New Revision: 4342 Removed: branches/refactor_fft/scipy/fftpack/backends/include/ Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf Log: Remove empty dir left by git. Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf 2008-05-15 12:44:54 UTC (rev 4341) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf 2008-05-15 12:45:52 UTC (rev 4342) @@ -30,18 +30,18 @@ :: normalize = (direction<0) end subroutine drfft_fftw3 - subroutine zrfft_fftw3(x,n,direction,howmany,normalize) - ! y = zrfft(x[,n,direction,normalize,overwrite_x]) - intent(c) zrfft_fftw3 - complex*16 intent(c,in,out,overwrite,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zrfft_fftw3 +! subroutine zrfft_fftw3(x,n,direction,howmany,normalize) +! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) zrfft_fftw3 +! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine zrfft_fftw3 subroutine zfftnd_fftw3(x,r,s,direction,howmany,normalize,j) ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) From scipy-svn at scipy.org Thu May 15 10:04:31 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 09:04:31 -0500 (CDT) Subject: [Scipy-svn] r4344 - in branches/refactor_fft/scipy/fftpack/fftpack: . FFTPACK Message-ID: <20080515140431.5F0CC39C458@scipy.org> Author: cdavid Date: 2008-05-15 09:03:42 -0500 (Thu, 15 May 2008) New Revision: 4344 Added: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/ branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftb.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftb1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftf.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftf1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cffti.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cffti1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cosqb.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cosqf.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cosqi.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cost.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/costi.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/doc branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftb.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftb1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftf.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftf1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rffti.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rffti1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinqb.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinqf.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinqi.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sint.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sint1.f branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinti.f Removed: branches/refactor_fft/scipy/fftpack/fftpack/cfftb.f branches/refactor_fft/scipy/fftpack/fftpack/cfftb1.f branches/refactor_fft/scipy/fftpack/fftpack/cfftf.f branches/refactor_fft/scipy/fftpack/fftpack/cfftf1.f branches/refactor_fft/scipy/fftpack/fftpack/cffti.f branches/refactor_fft/scipy/fftpack/fftpack/cffti1.f branches/refactor_fft/scipy/fftpack/fftpack/cosqb.f branches/refactor_fft/scipy/fftpack/fftpack/cosqf.f branches/refactor_fft/scipy/fftpack/fftpack/cosqi.f branches/refactor_fft/scipy/fftpack/fftpack/cost.f branches/refactor_fft/scipy/fftpack/fftpack/costi.f branches/refactor_fft/scipy/fftpack/fftpack/doc branches/refactor_fft/scipy/fftpack/fftpack/rfftb.f branches/refactor_fft/scipy/fftpack/fftpack/rfftb1.f branches/refactor_fft/scipy/fftpack/fftpack/rfftf.f branches/refactor_fft/scipy/fftpack/fftpack/rfftf1.f branches/refactor_fft/scipy/fftpack/fftpack/rffti.f branches/refactor_fft/scipy/fftpack/fftpack/rffti1.f branches/refactor_fft/scipy/fftpack/fftpack/sinqb.f branches/refactor_fft/scipy/fftpack/fftpack/sinqf.f branches/refactor_fft/scipy/fftpack/fftpack/sinqi.f branches/refactor_fft/scipy/fftpack/fftpack/sint.f branches/refactor_fft/scipy/fftpack/fftpack/sint1.f branches/refactor_fft/scipy/fftpack/fftpack/sinti.f Log: Move sources of fftpack in subdir Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cfftb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftb1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cfftb1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cfftf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cfftf1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cfftf1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cffti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cffti.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cffti1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cffti1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cosqb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cosqb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cosqf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cosqf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cosqi.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cosqi.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/cost.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/cost.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/costi.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/costi.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/doc (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/doc) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/rfftb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftb1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/rfftb1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/rfftf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rfftf1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/rfftf1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rffti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/rffti.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/rffti1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/rffti1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinqb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/sinqb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinqf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/sinqf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinqi.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/sinqi.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sint.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/sint.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sint1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/sint1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/FFTPACK/sinti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack/sinti.f) Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cfftb.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cfftb.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cfftb.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,8 +0,0 @@ - SUBROUTINE CFFTB (N,C,WSAVE) - DIMENSION C(*) ,WSAVE(*) - IF (N .EQ. 1) RETURN - IW1 = N+N+1 - IW2 = IW1+N+N - CALL CFFTB1 (N,C,WSAVE,WSAVE(IW1),WSAVE(IW2)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cfftb1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cfftb1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cfftb1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,368 +0,0 @@ - SUBROUTINE CFFTB1 (N,C,CH,WA,IFAC) - DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*) - NF = IFAC(2) - NA = 0 - L1 = 1 - IW = 1 - DO 116 K1=1,NF - IP = IFAC(K1+2) - L2 = IP*L1 - IDO = N/L2 - IDOT = IDO+IDO - IDL1 = IDOT*L1 - IF (IP .NE. 4) GO TO 103 - IX2 = IW+IDOT - IX3 = IX2+IDOT - IF (NA .NE. 0) GO TO 101 - CALL PASSB4 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3)) - GO TO 102 - 101 CALL PASSB4 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3)) - 102 NA = 1-NA - GO TO 115 - 103 IF (IP .NE. 2) GO TO 106 - IF (NA .NE. 0) GO TO 104 - CALL PASSB2 (IDOT,L1,C,CH,WA(IW)) - GO TO 105 - 104 CALL PASSB2 (IDOT,L1,CH,C,WA(IW)) - 105 NA = 1-NA - GO TO 115 - 106 IF (IP .NE. 3) GO TO 109 - IX2 = IW+IDOT - IF (NA .NE. 0) GO TO 107 - CALL PASSB3 (IDOT,L1,C,CH,WA(IW),WA(IX2)) - GO TO 108 - 107 CALL PASSB3 (IDOT,L1,CH,C,WA(IW),WA(IX2)) - 108 NA = 1-NA - GO TO 115 - 109 IF (IP .NE. 5) GO TO 112 - IX2 = IW+IDOT - IX3 = IX2+IDOT - IX4 = IX3+IDOT - IF (NA .NE. 0) GO TO 110 - CALL PASSB5 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - GO TO 111 - 110 CALL PASSB5 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - 111 NA = 1-NA - GO TO 115 - 112 IF (NA .NE. 0) GO TO 113 - CALL PASSB (NAC,IDOT,IP,L1,IDL1,C,C,C,CH,CH,WA(IW)) - GO TO 114 - 113 CALL PASSB (NAC,IDOT,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW)) - 114 IF (NAC .NE. 0) NA = 1-NA - 115 L1 = L2 - IW = IW+(IP-1)*IDOT - 116 CONTINUE - IF (NA .EQ. 0) RETURN - N2 = N+N - DO 117 I=1,N2 - C(I) = CH(I) - 117 CONTINUE - RETURN - END - SUBROUTINE PASSB2 (IDO,L1,CC,CH,WA1) - DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) , - 1 WA1(*) - IF (IDO .GT. 2) GO TO 102 - DO 101 K=1,L1 - CH(1,K,1) = CC(1,1,K)+CC(1,2,K) - CH(1,K,2) = CC(1,1,K)-CC(1,2,K) - CH(2,K,1) = CC(2,1,K)+CC(2,2,K) - CH(2,K,2) = CC(2,1,K)-CC(2,2,K) - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - CH(I-1,K,1) = CC(I-1,1,K)+CC(I-1,2,K) - TR2 = CC(I-1,1,K)-CC(I-1,2,K) - CH(I,K,1) = CC(I,1,K)+CC(I,2,K) - TI2 = CC(I,1,K)-CC(I,2,K) - CH(I,K,2) = WA1(I-1)*TI2+WA1(I)*TR2 - CH(I-1,K,2) = WA1(I-1)*TR2-WA1(I)*TI2 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSB3 (IDO,L1,CC,CH,WA1,WA2) - DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) , - 1 WA1(*) ,WA2(*) - DATA TAUR,TAUI /-.5,.866025403784439/ - IF (IDO .NE. 2) GO TO 102 - DO 101 K=1,L1 - TR2 = CC(1,2,K)+CC(1,3,K) - CR2 = CC(1,1,K)+TAUR*TR2 - CH(1,K,1) = CC(1,1,K)+TR2 - TI2 = CC(2,2,K)+CC(2,3,K) - CI2 = CC(2,1,K)+TAUR*TI2 - CH(2,K,1) = CC(2,1,K)+TI2 - CR3 = TAUI*(CC(1,2,K)-CC(1,3,K)) - CI3 = TAUI*(CC(2,2,K)-CC(2,3,K)) - CH(1,K,2) = CR2-CI3 - CH(1,K,3) = CR2+CI3 - CH(2,K,2) = CI2+CR3 - CH(2,K,3) = CI2-CR3 - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - TR2 = CC(I-1,2,K)+CC(I-1,3,K) - CR2 = CC(I-1,1,K)+TAUR*TR2 - CH(I-1,K,1) = CC(I-1,1,K)+TR2 - TI2 = CC(I,2,K)+CC(I,3,K) - CI2 = CC(I,1,K)+TAUR*TI2 - CH(I,K,1) = CC(I,1,K)+TI2 - CR3 = TAUI*(CC(I-1,2,K)-CC(I-1,3,K)) - CI3 = TAUI*(CC(I,2,K)-CC(I,3,K)) - DR2 = CR2-CI3 - DR3 = CR2+CI3 - DI2 = CI2+CR3 - DI3 = CI2-CR3 - CH(I,K,2) = WA1(I-1)*DI2+WA1(I)*DR2 - CH(I-1,K,2) = WA1(I-1)*DR2-WA1(I)*DI2 - CH(I,K,3) = WA2(I-1)*DI3+WA2(I)*DR3 - CH(I-1,K,3) = WA2(I-1)*DR3-WA2(I)*DI3 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSB4 (IDO,L1,CC,CH,WA1,WA2,WA3) - DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) , - 1 WA1(*) ,WA2(*) ,WA3(*) - IF (IDO .NE. 2) GO TO 102 - DO 101 K=1,L1 - TI1 = CC(2,1,K)-CC(2,3,K) - TI2 = CC(2,1,K)+CC(2,3,K) - TR4 = CC(2,4,K)-CC(2,2,K) - TI3 = CC(2,2,K)+CC(2,4,K) - TR1 = CC(1,1,K)-CC(1,3,K) - TR2 = CC(1,1,K)+CC(1,3,K) - TI4 = CC(1,2,K)-CC(1,4,K) - TR3 = CC(1,2,K)+CC(1,4,K) - CH(1,K,1) = TR2+TR3 - CH(1,K,3) = TR2-TR3 - CH(2,K,1) = TI2+TI3 - CH(2,K,3) = TI2-TI3 - CH(1,K,2) = TR1+TR4 - CH(1,K,4) = TR1-TR4 - CH(2,K,2) = TI1+TI4 - CH(2,K,4) = TI1-TI4 - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - TI1 = CC(I,1,K)-CC(I,3,K) - TI2 = CC(I,1,K)+CC(I,3,K) - TI3 = CC(I,2,K)+CC(I,4,K) - TR4 = CC(I,4,K)-CC(I,2,K) - TR1 = CC(I-1,1,K)-CC(I-1,3,K) - TR2 = CC(I-1,1,K)+CC(I-1,3,K) - TI4 = CC(I-1,2,K)-CC(I-1,4,K) - TR3 = CC(I-1,2,K)+CC(I-1,4,K) - CH(I-1,K,1) = TR2+TR3 - CR3 = TR2-TR3 - CH(I,K,1) = TI2+TI3 - CI3 = TI2-TI3 - CR2 = TR1+TR4 - CR4 = TR1-TR4 - CI2 = TI1+TI4 - CI4 = TI1-TI4 - CH(I-1,K,2) = WA1(I-1)*CR2-WA1(I)*CI2 - CH(I,K,2) = WA1(I-1)*CI2+WA1(I)*CR2 - CH(I-1,K,3) = WA2(I-1)*CR3-WA2(I)*CI3 - CH(I,K,3) = WA2(I-1)*CI3+WA2(I)*CR3 - CH(I-1,K,4) = WA3(I-1)*CR4-WA3(I)*CI4 - CH(I,K,4) = WA3(I-1)*CI4+WA3(I)*CR4 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSB5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4) - DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) , - 1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*) - DATA TR11,TI11,TR12,TI12 /.309016994374947,.951056516295154, - 1-.809016994374947,.587785252292473/ - IF (IDO .NE. 2) GO TO 102 - DO 101 K=1,L1 - TI5 = CC(2,2,K)-CC(2,5,K) - TI2 = CC(2,2,K)+CC(2,5,K) - TI4 = CC(2,3,K)-CC(2,4,K) - TI3 = CC(2,3,K)+CC(2,4,K) - TR5 = CC(1,2,K)-CC(1,5,K) - TR2 = CC(1,2,K)+CC(1,5,K) - TR4 = CC(1,3,K)-CC(1,4,K) - TR3 = CC(1,3,K)+CC(1,4,K) - CH(1,K,1) = CC(1,1,K)+TR2+TR3 - CH(2,K,1) = CC(2,1,K)+TI2+TI3 - CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3 - CI2 = CC(2,1,K)+TR11*TI2+TR12*TI3 - CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3 - CI3 = CC(2,1,K)+TR12*TI2+TR11*TI3 - CR5 = TI11*TR5+TI12*TR4 - CI5 = TI11*TI5+TI12*TI4 - CR4 = TI12*TR5-TI11*TR4 - CI4 = TI12*TI5-TI11*TI4 - CH(1,K,2) = CR2-CI5 - CH(1,K,5) = CR2+CI5 - CH(2,K,2) = CI2+CR5 - CH(2,K,3) = CI3+CR4 - CH(1,K,3) = CR3-CI4 - CH(1,K,4) = CR3+CI4 - CH(2,K,4) = CI3-CR4 - CH(2,K,5) = CI2-CR5 - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - TI5 = CC(I,2,K)-CC(I,5,K) - TI2 = CC(I,2,K)+CC(I,5,K) - TI4 = CC(I,3,K)-CC(I,4,K) - TI3 = CC(I,3,K)+CC(I,4,K) - TR5 = CC(I-1,2,K)-CC(I-1,5,K) - TR2 = CC(I-1,2,K)+CC(I-1,5,K) - TR4 = CC(I-1,3,K)-CC(I-1,4,K) - TR3 = CC(I-1,3,K)+CC(I-1,4,K) - CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3 - CH(I,K,1) = CC(I,1,K)+TI2+TI3 - CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3 - CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3 - CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3 - CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3 - CR5 = TI11*TR5+TI12*TR4 - CI5 = TI11*TI5+TI12*TI4 - CR4 = TI12*TR5-TI11*TR4 - CI4 = TI12*TI5-TI11*TI4 - DR3 = CR3-CI4 - DR4 = CR3+CI4 - DI3 = CI3+CR4 - DI4 = CI3-CR4 - DR5 = CR2+CI5 - DR2 = CR2-CI5 - DI5 = CI2-CR5 - DI2 = CI2+CR5 - CH(I-1,K,2) = WA1(I-1)*DR2-WA1(I)*DI2 - CH(I,K,2) = WA1(I-1)*DI2+WA1(I)*DR2 - CH(I-1,K,3) = WA2(I-1)*DR3-WA2(I)*DI3 - CH(I,K,3) = WA2(I-1)*DI3+WA2(I)*DR3 - CH(I-1,K,4) = WA3(I-1)*DR4-WA3(I)*DI4 - CH(I,K,4) = WA3(I-1)*DI4+WA3(I)*DR4 - CH(I-1,K,5) = WA4(I-1)*DR5-WA4(I)*DI5 - CH(I,K,5) = WA4(I-1)*DI5+WA4(I)*DR5 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSB (NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA) - DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) , - 1 C1(IDO,L1,IP) ,WA(*) ,C2(IDL1,IP), - 2 CH2(IDL1,IP) - IDOT = IDO/2 - NT = IP*IDL1 - IPP2 = IP+2 - IPPH = (IP+1)/2 - IDP = IP*IDO -C - IF (IDO .LT. L1) GO TO 106 - DO 103 J=2,IPPH - JC = IPP2-J - DO 102 K=1,L1 - DO 101 I=1,IDO - CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) - CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) - 101 CONTINUE - 102 CONTINUE - 103 CONTINUE - DO 105 K=1,L1 - DO 104 I=1,IDO - CH(I,K,1) = CC(I,1,K) - 104 CONTINUE - 105 CONTINUE - GO TO 112 - 106 DO 109 J=2,IPPH - JC = IPP2-J - DO 108 I=1,IDO - DO 107 K=1,L1 - CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) - CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) - 107 CONTINUE - 108 CONTINUE - 109 CONTINUE - DO 111 I=1,IDO - DO 110 K=1,L1 - CH(I,K,1) = CC(I,1,K) - 110 CONTINUE - 111 CONTINUE - 112 IDL = 2-IDO - INC = 0 - DO 116 L=2,IPPH - LC = IPP2-L - IDL = IDL+IDO - DO 113 IK=1,IDL1 - C2(IK,L) = CH2(IK,1)+WA(IDL-1)*CH2(IK,2) - C2(IK,LC) = WA(IDL)*CH2(IK,IP) - 113 CONTINUE - IDLJ = IDL - INC = INC+IDO - DO 115 J=3,IPPH - JC = IPP2-J - IDLJ = IDLJ+INC - IF (IDLJ .GT. IDP) IDLJ = IDLJ-IDP - WAR = WA(IDLJ-1) - WAI = WA(IDLJ) - DO 114 IK=1,IDL1 - C2(IK,L) = C2(IK,L)+WAR*CH2(IK,J) - C2(IK,LC) = C2(IK,LC)+WAI*CH2(IK,JC) - 114 CONTINUE - 115 CONTINUE - 116 CONTINUE - DO 118 J=2,IPPH - DO 117 IK=1,IDL1 - CH2(IK,1) = CH2(IK,1)+CH2(IK,J) - 117 CONTINUE - 118 CONTINUE - DO 120 J=2,IPPH - JC = IPP2-J - DO 119 IK=2,IDL1,2 - CH2(IK-1,J) = C2(IK-1,J)-C2(IK,JC) - CH2(IK-1,JC) = C2(IK-1,J)+C2(IK,JC) - CH2(IK,J) = C2(IK,J)+C2(IK-1,JC) - CH2(IK,JC) = C2(IK,J)-C2(IK-1,JC) - 119 CONTINUE - 120 CONTINUE - NAC = 1 - IF (IDO .EQ. 2) RETURN - NAC = 0 - DO 121 IK=1,IDL1 - C2(IK,1) = CH2(IK,1) - 121 CONTINUE - DO 123 J=2,IP - DO 122 K=1,L1 - C1(1,K,J) = CH(1,K,J) - C1(2,K,J) = CH(2,K,J) - 122 CONTINUE - 123 CONTINUE - IF (IDOT .GT. L1) GO TO 127 - IDIJ = 0 - DO 126 J=2,IP - IDIJ = IDIJ+2 - DO 125 I=4,IDO,2 - IDIJ = IDIJ+2 - DO 124 K=1,L1 - C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J) - C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J) - 124 CONTINUE - 125 CONTINUE - 126 CONTINUE - RETURN - 127 IDJ = 2-IDO - DO 130 J=2,IP - IDJ = IDJ+IDO - DO 129 K=1,L1 - IDIJ = IDJ - DO 128 I=4,IDO,2 - IDIJ = IDIJ+2 - C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J) - C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J) - 128 CONTINUE - 129 CONTINUE - 130 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cfftf.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cfftf.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cfftf.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,8 +0,0 @@ - SUBROUTINE CFFTF (N,C,WSAVE) - DIMENSION C(*) ,WSAVE(*) - IF (N .EQ. 1) RETURN - IW1 = N+N+1 - IW2 = IW1+N+N - CALL CFFTF1 (N,C,WSAVE,WSAVE(IW1),WSAVE(IW2)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cfftf1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cfftf1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cfftf1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,368 +0,0 @@ - SUBROUTINE CFFTF1 (N,C,CH,WA,IFAC) - DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*) - NF = IFAC(2) - NA = 0 - L1 = 1 - IW = 1 - DO 116 K1=1,NF - IP = IFAC(K1+2) - L2 = IP*L1 - IDO = N/L2 - IDOT = IDO+IDO - IDL1 = IDOT*L1 - IF (IP .NE. 4) GO TO 103 - IX2 = IW+IDOT - IX3 = IX2+IDOT - IF (NA .NE. 0) GO TO 101 - CALL PASSF4 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3)) - GO TO 102 - 101 CALL PASSF4 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3)) - 102 NA = 1-NA - GO TO 115 - 103 IF (IP .NE. 2) GO TO 106 - IF (NA .NE. 0) GO TO 104 - CALL PASSF2 (IDOT,L1,C,CH,WA(IW)) - GO TO 105 - 104 CALL PASSF2 (IDOT,L1,CH,C,WA(IW)) - 105 NA = 1-NA - GO TO 115 - 106 IF (IP .NE. 3) GO TO 109 - IX2 = IW+IDOT - IF (NA .NE. 0) GO TO 107 - CALL PASSF3 (IDOT,L1,C,CH,WA(IW),WA(IX2)) - GO TO 108 - 107 CALL PASSF3 (IDOT,L1,CH,C,WA(IW),WA(IX2)) - 108 NA = 1-NA - GO TO 115 - 109 IF (IP .NE. 5) GO TO 112 - IX2 = IW+IDOT - IX3 = IX2+IDOT - IX4 = IX3+IDOT - IF (NA .NE. 0) GO TO 110 - CALL PASSF5 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - GO TO 111 - 110 CALL PASSF5 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - 111 NA = 1-NA - GO TO 115 - 112 IF (NA .NE. 0) GO TO 113 - CALL PASSF (NAC,IDOT,IP,L1,IDL1,C,C,C,CH,CH,WA(IW)) - GO TO 114 - 113 CALL PASSF (NAC,IDOT,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW)) - 114 IF (NAC .NE. 0) NA = 1-NA - 115 L1 = L2 - IW = IW+(IP-1)*IDOT - 116 CONTINUE - IF (NA .EQ. 0) RETURN - N2 = N+N - DO 117 I=1,N2 - C(I) = CH(I) - 117 CONTINUE - RETURN - END - SUBROUTINE PASSF2 (IDO,L1,CC,CH,WA1) - DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) , - 1 WA1(*) - IF (IDO .GT. 2) GO TO 102 - DO 101 K=1,L1 - CH(1,K,1) = CC(1,1,K)+CC(1,2,K) - CH(1,K,2) = CC(1,1,K)-CC(1,2,K) - CH(2,K,1) = CC(2,1,K)+CC(2,2,K) - CH(2,K,2) = CC(2,1,K)-CC(2,2,K) - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - CH(I-1,K,1) = CC(I-1,1,K)+CC(I-1,2,K) - TR2 = CC(I-1,1,K)-CC(I-1,2,K) - CH(I,K,1) = CC(I,1,K)+CC(I,2,K) - TI2 = CC(I,1,K)-CC(I,2,K) - CH(I,K,2) = WA1(I-1)*TI2-WA1(I)*TR2 - CH(I-1,K,2) = WA1(I-1)*TR2+WA1(I)*TI2 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSF3 (IDO,L1,CC,CH,WA1,WA2) - DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) , - 1 WA1(*) ,WA2(*) - DATA TAUR,TAUI /-.5,-.866025403784439/ - IF (IDO .NE. 2) GO TO 102 - DO 101 K=1,L1 - TR2 = CC(1,2,K)+CC(1,3,K) - CR2 = CC(1,1,K)+TAUR*TR2 - CH(1,K,1) = CC(1,1,K)+TR2 - TI2 = CC(2,2,K)+CC(2,3,K) - CI2 = CC(2,1,K)+TAUR*TI2 - CH(2,K,1) = CC(2,1,K)+TI2 - CR3 = TAUI*(CC(1,2,K)-CC(1,3,K)) - CI3 = TAUI*(CC(2,2,K)-CC(2,3,K)) - CH(1,K,2) = CR2-CI3 - CH(1,K,3) = CR2+CI3 - CH(2,K,2) = CI2+CR3 - CH(2,K,3) = CI2-CR3 - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - TR2 = CC(I-1,2,K)+CC(I-1,3,K) - CR2 = CC(I-1,1,K)+TAUR*TR2 - CH(I-1,K,1) = CC(I-1,1,K)+TR2 - TI2 = CC(I,2,K)+CC(I,3,K) - CI2 = CC(I,1,K)+TAUR*TI2 - CH(I,K,1) = CC(I,1,K)+TI2 - CR3 = TAUI*(CC(I-1,2,K)-CC(I-1,3,K)) - CI3 = TAUI*(CC(I,2,K)-CC(I,3,K)) - DR2 = CR2-CI3 - DR3 = CR2+CI3 - DI2 = CI2+CR3 - DI3 = CI2-CR3 - CH(I,K,2) = WA1(I-1)*DI2-WA1(I)*DR2 - CH(I-1,K,2) = WA1(I-1)*DR2+WA1(I)*DI2 - CH(I,K,3) = WA2(I-1)*DI3-WA2(I)*DR3 - CH(I-1,K,3) = WA2(I-1)*DR3+WA2(I)*DI3 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSF4 (IDO,L1,CC,CH,WA1,WA2,WA3) - DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) , - 1 WA1(*) ,WA2(*) ,WA3(*) - IF (IDO .NE. 2) GO TO 102 - DO 101 K=1,L1 - TI1 = CC(2,1,K)-CC(2,3,K) - TI2 = CC(2,1,K)+CC(2,3,K) - TR4 = CC(2,2,K)-CC(2,4,K) - TI3 = CC(2,2,K)+CC(2,4,K) - TR1 = CC(1,1,K)-CC(1,3,K) - TR2 = CC(1,1,K)+CC(1,3,K) - TI4 = CC(1,4,K)-CC(1,2,K) - TR3 = CC(1,2,K)+CC(1,4,K) - CH(1,K,1) = TR2+TR3 - CH(1,K,3) = TR2-TR3 - CH(2,K,1) = TI2+TI3 - CH(2,K,3) = TI2-TI3 - CH(1,K,2) = TR1+TR4 - CH(1,K,4) = TR1-TR4 - CH(2,K,2) = TI1+TI4 - CH(2,K,4) = TI1-TI4 - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - TI1 = CC(I,1,K)-CC(I,3,K) - TI2 = CC(I,1,K)+CC(I,3,K) - TI3 = CC(I,2,K)+CC(I,4,K) - TR4 = CC(I,2,K)-CC(I,4,K) - TR1 = CC(I-1,1,K)-CC(I-1,3,K) - TR2 = CC(I-1,1,K)+CC(I-1,3,K) - TI4 = CC(I-1,4,K)-CC(I-1,2,K) - TR3 = CC(I-1,2,K)+CC(I-1,4,K) - CH(I-1,K,1) = TR2+TR3 - CR3 = TR2-TR3 - CH(I,K,1) = TI2+TI3 - CI3 = TI2-TI3 - CR2 = TR1+TR4 - CR4 = TR1-TR4 - CI2 = TI1+TI4 - CI4 = TI1-TI4 - CH(I-1,K,2) = WA1(I-1)*CR2+WA1(I)*CI2 - CH(I,K,2) = WA1(I-1)*CI2-WA1(I)*CR2 - CH(I-1,K,3) = WA2(I-1)*CR3+WA2(I)*CI3 - CH(I,K,3) = WA2(I-1)*CI3-WA2(I)*CR3 - CH(I-1,K,4) = WA3(I-1)*CR4+WA3(I)*CI4 - CH(I,K,4) = WA3(I-1)*CI4-WA3(I)*CR4 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSF5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4) - DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) , - 1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*) - DATA TR11,TI11,TR12,TI12 /.309016994374947,-.951056516295154, - 1-.809016994374947,-.587785252292473/ - IF (IDO .NE. 2) GO TO 102 - DO 101 K=1,L1 - TI5 = CC(2,2,K)-CC(2,5,K) - TI2 = CC(2,2,K)+CC(2,5,K) - TI4 = CC(2,3,K)-CC(2,4,K) - TI3 = CC(2,3,K)+CC(2,4,K) - TR5 = CC(1,2,K)-CC(1,5,K) - TR2 = CC(1,2,K)+CC(1,5,K) - TR4 = CC(1,3,K)-CC(1,4,K) - TR3 = CC(1,3,K)+CC(1,4,K) - CH(1,K,1) = CC(1,1,K)+TR2+TR3 - CH(2,K,1) = CC(2,1,K)+TI2+TI3 - CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3 - CI2 = CC(2,1,K)+TR11*TI2+TR12*TI3 - CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3 - CI3 = CC(2,1,K)+TR12*TI2+TR11*TI3 - CR5 = TI11*TR5+TI12*TR4 - CI5 = TI11*TI5+TI12*TI4 - CR4 = TI12*TR5-TI11*TR4 - CI4 = TI12*TI5-TI11*TI4 - CH(1,K,2) = CR2-CI5 - CH(1,K,5) = CR2+CI5 - CH(2,K,2) = CI2+CR5 - CH(2,K,3) = CI3+CR4 - CH(1,K,3) = CR3-CI4 - CH(1,K,4) = CR3+CI4 - CH(2,K,4) = CI3-CR4 - CH(2,K,5) = CI2-CR5 - 101 CONTINUE - RETURN - 102 DO 104 K=1,L1 - DO 103 I=2,IDO,2 - TI5 = CC(I,2,K)-CC(I,5,K) - TI2 = CC(I,2,K)+CC(I,5,K) - TI4 = CC(I,3,K)-CC(I,4,K) - TI3 = CC(I,3,K)+CC(I,4,K) - TR5 = CC(I-1,2,K)-CC(I-1,5,K) - TR2 = CC(I-1,2,K)+CC(I-1,5,K) - TR4 = CC(I-1,3,K)-CC(I-1,4,K) - TR3 = CC(I-1,3,K)+CC(I-1,4,K) - CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3 - CH(I,K,1) = CC(I,1,K)+TI2+TI3 - CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3 - CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3 - CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3 - CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3 - CR5 = TI11*TR5+TI12*TR4 - CI5 = TI11*TI5+TI12*TI4 - CR4 = TI12*TR5-TI11*TR4 - CI4 = TI12*TI5-TI11*TI4 - DR3 = CR3-CI4 - DR4 = CR3+CI4 - DI3 = CI3+CR4 - DI4 = CI3-CR4 - DR5 = CR2+CI5 - DR2 = CR2-CI5 - DI5 = CI2-CR5 - DI2 = CI2+CR5 - CH(I-1,K,2) = WA1(I-1)*DR2+WA1(I)*DI2 - CH(I,K,2) = WA1(I-1)*DI2-WA1(I)*DR2 - CH(I-1,K,3) = WA2(I-1)*DR3+WA2(I)*DI3 - CH(I,K,3) = WA2(I-1)*DI3-WA2(I)*DR3 - CH(I-1,K,4) = WA3(I-1)*DR4+WA3(I)*DI4 - CH(I,K,4) = WA3(I-1)*DI4-WA3(I)*DR4 - CH(I-1,K,5) = WA4(I-1)*DR5+WA4(I)*DI5 - CH(I,K,5) = WA4(I-1)*DI5-WA4(I)*DR5 - 103 CONTINUE - 104 CONTINUE - RETURN - END - SUBROUTINE PASSF (NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA) - DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) , - 1 C1(IDO,L1,IP) ,WA(*) ,C2(IDL1,IP), - 2 CH2(IDL1,IP) - IDOT = IDO/2 - NT = IP*IDL1 - IPP2 = IP+2 - IPPH = (IP+1)/2 - IDP = IP*IDO -C - IF (IDO .LT. L1) GO TO 106 - DO 103 J=2,IPPH - JC = IPP2-J - DO 102 K=1,L1 - DO 101 I=1,IDO - CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) - CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) - 101 CONTINUE - 102 CONTINUE - 103 CONTINUE - DO 105 K=1,L1 - DO 104 I=1,IDO - CH(I,K,1) = CC(I,1,K) - 104 CONTINUE - 105 CONTINUE - GO TO 112 - 106 DO 109 J=2,IPPH - JC = IPP2-J - DO 108 I=1,IDO - DO 107 K=1,L1 - CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) - CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) - 107 CONTINUE - 108 CONTINUE - 109 CONTINUE - DO 111 I=1,IDO - DO 110 K=1,L1 - CH(I,K,1) = CC(I,1,K) - 110 CONTINUE - 111 CONTINUE - 112 IDL = 2-IDO - INC = 0 - DO 116 L=2,IPPH - LC = IPP2-L - IDL = IDL+IDO - DO 113 IK=1,IDL1 - C2(IK,L) = CH2(IK,1)+WA(IDL-1)*CH2(IK,2) - C2(IK,LC) = -WA(IDL)*CH2(IK,IP) - 113 CONTINUE - IDLJ = IDL - INC = INC+IDO - DO 115 J=3,IPPH - JC = IPP2-J - IDLJ = IDLJ+INC - IF (IDLJ .GT. IDP) IDLJ = IDLJ-IDP - WAR = WA(IDLJ-1) - WAI = WA(IDLJ) - DO 114 IK=1,IDL1 - C2(IK,L) = C2(IK,L)+WAR*CH2(IK,J) - C2(IK,LC) = C2(IK,LC)-WAI*CH2(IK,JC) - 114 CONTINUE - 115 CONTINUE - 116 CONTINUE - DO 118 J=2,IPPH - DO 117 IK=1,IDL1 - CH2(IK,1) = CH2(IK,1)+CH2(IK,J) - 117 CONTINUE - 118 CONTINUE - DO 120 J=2,IPPH - JC = IPP2-J - DO 119 IK=2,IDL1,2 - CH2(IK-1,J) = C2(IK-1,J)-C2(IK,JC) - CH2(IK-1,JC) = C2(IK-1,J)+C2(IK,JC) - CH2(IK,J) = C2(IK,J)+C2(IK-1,JC) - CH2(IK,JC) = C2(IK,J)-C2(IK-1,JC) - 119 CONTINUE - 120 CONTINUE - NAC = 1 - IF (IDO .EQ. 2) RETURN - NAC = 0 - DO 121 IK=1,IDL1 - C2(IK,1) = CH2(IK,1) - 121 CONTINUE - DO 123 J=2,IP - DO 122 K=1,L1 - C1(1,K,J) = CH(1,K,J) - C1(2,K,J) = CH(2,K,J) - 122 CONTINUE - 123 CONTINUE - IF (IDOT .GT. L1) GO TO 127 - IDIJ = 0 - DO 126 J=2,IP - IDIJ = IDIJ+2 - DO 125 I=4,IDO,2 - IDIJ = IDIJ+2 - DO 124 K=1,L1 - C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)+WA(IDIJ)*CH(I,K,J) - C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)-WA(IDIJ)*CH(I-1,K,J) - 124 CONTINUE - 125 CONTINUE - 126 CONTINUE - RETURN - 127 IDJ = 2-IDO - DO 130 J=2,IP - IDJ = IDJ+IDO - DO 129 K=1,L1 - IDIJ = IDJ - DO 128 I=4,IDO,2 - IDIJ = IDIJ+2 - C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)+WA(IDIJ)*CH(I,K,J) - C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)-WA(IDIJ)*CH(I-1,K,J) - 128 CONTINUE - 129 CONTINUE - 130 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cffti.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cffti.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cffti.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,8 +0,0 @@ - SUBROUTINE CFFTI (N,WSAVE) - DIMENSION WSAVE(*) - IF (N .EQ. 1) RETURN - IW1 = N+N+1 - IW2 = IW1+N+N - CALL CFFTI1 (N,WSAVE(IW1),WSAVE(IW2)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cffti1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cffti1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cffti1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,62 +0,0 @@ - SUBROUTINE CFFTI1 (N,WA,IFAC) - DIMENSION WA(*) ,IFAC(*) ,NTRYH(4) - DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/3,4,2,5/ - NL = N - NF = 0 - J = 0 - 101 J = J+1 - IF (J.le.4) GO TO 102 - GO TO 103 - 102 NTRY = NTRYH(J) - GO TO 104 - 103 NTRY = NTRY+2 - 104 NQ = NL/NTRY - NR = NL-NTRY*NQ - IF (NR.eq.0) GO TO 105 - GO TO 101 - 105 NF = NF+1 - IFAC(NF+2) = NTRY - NL = NQ - IF (NTRY .NE. 2) GO TO 107 - IF (NF .EQ. 1) GO TO 107 - DO 106 I=2,NF - IB = NF-I+2 - IFAC(IB+2) = IFAC(IB+1) - 106 CONTINUE - IFAC(3) = 2 - 107 IF (NL .NE. 1) GO TO 104 - IFAC(1) = N - IFAC(2) = NF - TPI = 6.28318530717959 - ARGH = TPI/FLOAT(N) - I = 2 - L1 = 1 - DO 110 K1=1,NF - IP = IFAC(K1+2) - LD = 0 - L2 = L1*IP - IDO = N/L2 - IDOT = IDO+IDO+2 - IPM = IP-1 - DO 109 J=1,IPM - I1 = I - WA(I-1) = 1. - WA(I) = 0. - LD = LD+L1 - FI = 0. - ARGLD = FLOAT(LD)*ARGH - DO 108 II=4,IDOT,2 - I = I+2 - FI = FI+1. - ARG = FI*ARGLD - WA(I-1) = COS(ARG) - WA(I) = SIN(ARG) - 108 CONTINUE - IF (IP .LE. 5) GO TO 109 - WA(I1-1) = WA(I-1) - WA(I1) = WA(I) - 109 CONTINUE - L1 = L2 - 110 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cosqb.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cosqb.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cosqb.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,42 +0,0 @@ - SUBROUTINE COSQB (N,X,WSAVE) - DIMENSION X(*) ,WSAVE(*) - DATA TSQRT2 /2.82842712474619/ - IF (N.lt.2) GO TO 101 - IF (N.eq.2) GO TO 102 - GO TO 103 - 101 X(1) = 4.*X(1) - RETURN - 102 X1 = 4.*(X(1)+X(2)) - X(2) = TSQRT2*(X(1)-X(2)) - X(1) = X1 - RETURN - 103 CALL COSQB1 (N,X,WSAVE,WSAVE(N+1)) - RETURN - END - SUBROUTINE COSQB1 (N,X,W,XH) - DIMENSION X(1) ,W(1) ,XH(1) - NS2 = (N+1)/2 - NP2 = N+2 - DO 101 I=3,N,2 - XIM1 = X(I-1)+X(I) - X(I) = X(I)-X(I-1) - X(I-1) = XIM1 - 101 CONTINUE - X(1) = X(1)+X(1) - MODN = MOD(N,2) - IF (MODN .EQ. 0) X(N) = X(N)+X(N) - CALL RFFTB (N,X,XH) - DO 102 K=2,NS2 - KC = NP2-K - XH(K) = W(K-1)*X(KC)+W(KC-1)*X(K) - XH(KC) = W(K-1)*X(K)-W(KC-1)*X(KC) - 102 CONTINUE - IF (MODN .EQ. 0) X(NS2+1) = W(NS2)*(X(NS2+1)+X(NS2+1)) - DO 103 K=2,NS2 - KC = NP2-K - X(K) = XH(K)+XH(KC) - X(KC) = XH(K)-XH(KC) - 103 CONTINUE - X(1) = X(1)+X(1) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cosqf.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cosqf.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cosqf.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,38 +0,0 @@ - SUBROUTINE COSQF (N,X,WSAVE) - DIMENSION X(*) ,WSAVE(*) - DATA SQRT2 /1.4142135623731/ - IF (N.lt.2) GO TO 102 - IF (N.eq.2) GO TO 101 - GO TO 103 - 101 TSQX = SQRT2*X(2) - X(2) = X(1)-TSQX - X(1) = X(1)+TSQX - 102 RETURN - 103 CALL COSQF1 (N,X,WSAVE,WSAVE(N+1)) - RETURN - END - SUBROUTINE COSQF1 (N,X,W,XH) - DIMENSION X(1) ,W(1) ,XH(1) - NS2 = (N+1)/2 - NP2 = N+2 - DO 101 K=2,NS2 - KC = NP2-K - XH(K) = X(K)+X(KC) - XH(KC) = X(K)-X(KC) - 101 CONTINUE - MODN = MOD(N,2) - IF (MODN .EQ. 0) XH(NS2+1) = X(NS2+1)+X(NS2+1) - DO 102 K=2,NS2 - KC = NP2-K - X(K) = W(K-1)*XH(KC)+W(KC-1)*XH(K) - X(KC) = W(K-1)*XH(K)-W(KC-1)*XH(KC) - 102 CONTINUE - IF (MODN .EQ. 0) X(NS2+1) = W(NS2)*XH(NS2+1) - CALL RFFTF (N,X,XH) - DO 103 I=3,N,2 - XIM1 = X(I-1)-X(I) - X(I) = X(I-1)+X(I) - X(I-1) = XIM1 - 103 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cosqi.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cosqi.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cosqi.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,12 +0,0 @@ - SUBROUTINE COSQI (N,WSAVE) - DIMENSION WSAVE(*) - DATA PIH /1.57079632679491/ - DT = PIH/FLOAT(N) - FK = 0. - DO 101 K=1,N - FK = FK+1. - WSAVE(K) = COS(FK*DT) - 101 CONTINUE - CALL RFFTI (N,WSAVE(N+1)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/cost.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/cost.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/cost.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,44 +0,0 @@ - SUBROUTINE COST (N,X,WSAVE) - DIMENSION X(*) ,WSAVE(*) - NM1 = N-1 - NP1 = N+1 - NS2 = N/2 - IF (N.lt.2) GO TO 106 - IF (N.eq.2) GO TO 101 - GO TO 102 - 101 X1H = X(1)+X(2) - X(2) = X(1)-X(2) - X(1) = X1H - RETURN - 102 IF (N .GT. 3) GO TO 103 - X1P3 = X(1)+X(3) - TX2 = X(2)+X(2) - X(2) = X(1)-X(3) - X(1) = X1P3+TX2 - X(3) = X1P3-TX2 - RETURN - 103 C1 = X(1)-X(N) - X(1) = X(1)+X(N) - DO 104 K=2,NS2 - KC = NP1-K - T1 = X(K)+X(KC) - T2 = X(K)-X(KC) - C1 = C1+WSAVE(KC)*T2 - T2 = WSAVE(K)*T2 - X(K) = T1-T2 - X(KC) = T1+T2 - 104 CONTINUE - MODN = MOD(N,2) - IF (MODN .NE. 0) X(NS2+1) = X(NS2+1)+X(NS2+1) - CALL RFFTF (NM1,X,WSAVE(N+1)) - XIM2 = X(2) - X(2) = C1 - DO 105 I=4,N,2 - XI = X(I) - X(I) = X(I-2)-X(I-1) - X(I-1) = XIM2 - XIM2 = XI - 105 CONTINUE - IF (MODN .NE. 0) X(N) = XIM2 - 106 RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/costi.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/costi.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/costi.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,18 +0,0 @@ - SUBROUTINE COSTI (N,WSAVE) - DIMENSION WSAVE(*) - DATA PI /3.14159265358979/ - IF (N .LE. 3) RETURN - NM1 = N-1 - NP1 = N+1 - NS2 = N/2 - DT = PI/FLOAT(NM1) - FK = 0. - DO 101 K=2,NS2 - KC = NP1-K - FK = FK+1. - WSAVE(K) = 2.*SIN(FK*DT) - WSAVE(KC) = 2.*COS(FK*DT) - 101 CONTINUE - CALL RFFTI (NM1,WSAVE(N+1)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/doc =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/doc 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/doc 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,866 +0,0 @@ - - FFTPACK - -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - version 4 april 1985 - - a package of fortran subprograms for the fast fourier - transform of periodic and other symmetric sequences - - by - - paul n swarztrauber - - national center for atmospheric research boulder,colorado 80307 - - which is sponsored by the national science foundation - -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - - -this package consists of programs which perform fast fourier -transforms for both complex and real periodic sequences and -certain other symmetric sequences that are listed below. - -1. rffti initialize rfftf and rfftb -2. rfftf forward transform of a real periodic sequence -3. rfftb backward transform of a real coefficient array - -4. ezffti initialize ezfftf and ezfftb -5. ezfftf a simplified real periodic forward transform -6. ezfftb a simplified real periodic backward transform - -7. sinti initialize sint -8. sint sine transform of a real odd sequence - -9. costi initialize cost -10. cost cosine transform of a real even sequence - -11. sinqi initialize sinqf and sinqb -12. sinqf forward sine transform with odd wave numbers -13. sinqb unnormalized inverse of sinqf - -14. cosqi initialize cosqf and cosqb -15. cosqf forward cosine transform with odd wave numbers -16. cosqb unnormalized inverse of cosqf - -17. cffti initialize cfftf and cfftb -18. cfftf forward transform of a complex periodic sequence -19. cfftb unnormalized inverse of cfftf - - -****************************************************************** - -subroutine rffti(n,wsave) - - **************************************************************** - -subroutine rffti initializes the array wsave which is used in -both rfftf and rfftb. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the sequence to be transformed. - -output parameter - -wsave a work array which must be dimensioned at least 2*n+15. - the same work array can be used for both rfftf and rfftb - as long as n remains unchanged. different wsave arrays - are required for different values of n. the contents of - wsave must not be changed between calls of rfftf or rfftb. - -****************************************************************** - -subroutine rfftf(n,r,wsave) - -****************************************************************** - -subroutine rfftf computes the fourier coefficients of a real -perodic sequence (fourier analysis). the transform is defined -below at output parameter r. - -input parameters - -n the length of the array r to be transformed. the method - is most efficient when n is a product of small primes. - n may change so long as different work arrays are provided - -r a real array of length n which contains the sequence - to be transformed - -wsave a work array which must be dimensioned at least 2*n+15. - in the program that calls rfftf. the wsave array must be - initialized by calling subroutine rffti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - the same wsave array can be used by rfftf and rfftb. - - -output parameters - -r r(1) = the sum from i=1 to i=n of r(i) - - if n is even set l =n/2 , if n is odd set l = (n+1)/2 - - then for k = 2,...,l - - r(2*k-2) = the sum from i = 1 to i = n of - - r(i)*cos((k-1)*(i-1)*2*pi/n) - - r(2*k-1) = the sum from i = 1 to i = n of - - -r(i)*sin((k-1)*(i-1)*2*pi/n) - - if n is even - - r(n) = the sum from i = 1 to i = n of - - (-1)**(i-1)*r(i) - - ***** note - this transform is unnormalized since a call of rfftf - followed by a call of rfftb will multiply the input - sequence by n. - -wsave contains results which must not be destroyed between - calls of rfftf or rfftb. - - -****************************************************************** - -subroutine rfftb(n,r,wsave) - -****************************************************************** - -subroutine rfftb computes the real perodic sequence from its -fourier coefficients (fourier synthesis). the transform is defined -below at output parameter r. - -input parameters - -n the length of the array r to be transformed. the method - is most efficient when n is a product of small primes. - n may change so long as different work arrays are provided - -r a real array of length n which contains the sequence - to be transformed - -wsave a work array which must be dimensioned at least 2*n+15. - in the program that calls rfftb. the wsave array must be - initialized by calling subroutine rffti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - the same wsave array can be used by rfftf and rfftb. - - -output parameters - -r for n even and for i = 1,...,n - - r(i) = r(1)+(-1)**(i-1)*r(n) - - plus the sum from k=2 to k=n/2 of - - 2.*r(2*k-2)*cos((k-1)*(i-1)*2*pi/n) - - -2.*r(2*k-1)*sin((k-1)*(i-1)*2*pi/n) - - for n odd and for i = 1,...,n - - r(i) = r(1) plus the sum from k=2 to k=(n+1)/2 of - - 2.*r(2*k-2)*cos((k-1)*(i-1)*2*pi/n) - - -2.*r(2*k-1)*sin((k-1)*(i-1)*2*pi/n) - - ***** note - this transform is unnormalized since a call of rfftf - followed by a call of rfftb will multiply the input - sequence by n. - -wsave contains results which must not be destroyed between - calls of rfftb or rfftf. - - -****************************************************************** - -subroutine ezffti(n,wsave) - -****************************************************************** - -subroutine ezffti initializes the array wsave which is used in -both ezfftf and ezfftb. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the sequence to be transformed. - -output parameter - -wsave a work array which must be dimensioned at least 3*n+15. - the same work array can be used for both ezfftf and ezfftb - as long as n remains unchanged. different wsave arrays - are required for different values of n. - - -****************************************************************** - -subroutine ezfftf(n,r,azero,a,b,wsave) - -****************************************************************** - -subroutine ezfftf computes the fourier coefficients of a real -perodic sequence (fourier analysis). the transform is defined -below at output parameters azero,a and b. ezfftf is a simplified -but slower version of rfftf. - -input parameters - -n the length of the array r to be transformed. the method - is must efficient when n is the product of small primes. - -r a real array of length n which contains the sequence - to be transformed. r is not destroyed. - - -wsave a work array which must be dimensioned at least 3*n+15. - in the program that calls ezfftf. the wsave array must be - initialized by calling subroutine ezffti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - the same wsave array can be used by ezfftf and ezfftb. - -output parameters - -azero the sum from i=1 to i=n of r(i)/n - -a,b for n even b(n/2)=0. and a(n/2) is the sum from i=1 to - i=n of (-1)**(i-1)*r(i)/n - - for n even define kmax=n/2-1 - for n odd define kmax=(n-1)/2 - - then for k=1,...,kmax - - a(k) equals the sum from i=1 to i=n of - - 2./n*r(i)*cos(k*(i-1)*2*pi/n) - - b(k) equals the sum from i=1 to i=n of - - 2./n*r(i)*sin(k*(i-1)*2*pi/n) - - -****************************************************************** - -subroutine ezfftb(n,r,azero,a,b,wsave) - -****************************************************************** - -subroutine ezfftb computes a real perodic sequence from its -fourier coefficients (fourier synthesis). the transform is -defined below at output parameter r. ezfftb is a simplified -but slower version of rfftb. - -input parameters - -n the length of the output array r. the method is most - efficient when n is the product of small primes. - -azero the constant fourier coefficient - -a,b arrays which contain the remaining fourier coefficients - these arrays are not destroyed. - - the length of these arrays depends on whether n is even or - odd. - - if n is even n/2 locations are required - if n is odd (n-1)/2 locations are required - -wsave a work array which must be dimensioned at least 3*n+15. - in the program that calls ezfftb. the wsave array must be - initialized by calling subroutine ezffti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - the same wsave array can be used by ezfftf and ezfftb. - - -output parameters - -r if n is even define kmax=n/2 - if n is odd define kmax=(n-1)/2 - - then for i=1,...,n - - r(i)=azero plus the sum from k=1 to k=kmax of - - a(k)*cos(k*(i-1)*2*pi/n)+b(k)*sin(k*(i-1)*2*pi/n) - -********************* complex notation ************************** - - for j=1,...,n - - r(j) equals the sum from k=-kmax to k=kmax of - - c(k)*exp(i*k*(j-1)*2*pi/n) - - where - - c(k) = .5*cmplx(a(k),-b(k)) for k=1,...,kmax - - c(-k) = conjg(c(k)) - - c(0) = azero - - and i=sqrt(-1) - -*************** amplitude - phase notation *********************** - - for i=1,...,n - - r(i) equals azero plus the sum from k=1 to k=kmax of - - alpha(k)*cos(k*(i-1)*2*pi/n+beta(k)) - - where - - alpha(k) = sqrt(a(k)*a(k)+b(k)*b(k)) - - cos(beta(k))=a(k)/alpha(k) - - sin(beta(k))=-b(k)/alpha(k) - -****************************************************************** - -subroutine sinti(n,wsave) - -****************************************************************** - -subroutine sinti initializes the array wsave which is used in -subroutine sint. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the sequence to be transformed. the method - is most efficient when n+1 is a product of small primes. - -output parameter - -wsave a work array with at least int(2.5*n+15) locations. - different wsave arrays are required for different values - of n. the contents of wsave must not be changed between - calls of sint. - -****************************************************************** - -subroutine sint(n,x,wsave) - -****************************************************************** - -subroutine sint computes the discrete fourier sine transform -of an odd sequence x(i). the transform is defined below at -output parameter x. - -sint is the unnormalized inverse of itself since a call of sint -followed by another call of sint will multiply the input sequence -x by 2*(n+1). - -the array wsave which is used by subroutine sint must be -initialized by calling subroutine sinti(n,wsave). - -input parameters - -n the length of the sequence to be transformed. the method - is most efficient when n+1 is the product of small primes. - -x an array which contains the sequence to be transformed - - -wsave a work array with dimension at least int(2.5*n+15) - in the program that calls sint. the wsave array must be - initialized by calling subroutine sinti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - -output parameters - -x for i=1,...,n - - x(i)= the sum from k=1 to k=n - - 2*x(k)*sin(k*i*pi/(n+1)) - - a call of sint followed by another call of - sint will multiply the sequence x by 2*(n+1). - hence sint is the unnormalized inverse - of itself. - -wsave contains initialization calculations which must not be - destroyed between calls of sint. - -****************************************************************** - -subroutine costi(n,wsave) - -****************************************************************** - -subroutine costi initializes the array wsave which is used in -subroutine cost. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the sequence to be transformed. the method - is most efficient when n-1 is a product of small primes. - -output parameter - -wsave a work array which must be dimensioned at least 3*n+15. - different wsave arrays are required for different values - of n. the contents of wsave must not be changed between - calls of cost. - -****************************************************************** - -subroutine cost(n,x,wsave) - -****************************************************************** - -subroutine cost computes the discrete fourier cosine transform -of an even sequence x(i). the transform is defined below at output -parameter x. - -cost is the unnormalized inverse of itself since a call of cost -followed by another call of cost will multiply the input sequence -x by 2*(n-1). the transform is defined below at output parameter x - -the array wsave which is used by subroutine cost must be -initialized by calling subroutine costi(n,wsave). - -input parameters - -n the length of the sequence x. n must be greater than 1. - the method is most efficient when n-1 is a product of - small primes. - -x an array which contains the sequence to be transformed - -wsave a work array which must be dimensioned at least 3*n+15 - in the program that calls cost. the wsave array must be - initialized by calling subroutine costi(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - -output parameters - -x for i=1,...,n - - x(i) = x(1)+(-1)**(i-1)*x(n) - - + the sum from k=2 to k=n-1 - - 2*x(k)*cos((k-1)*(i-1)*pi/(n-1)) - - a call of cost followed by another call of - cost will multiply the sequence x by 2*(n-1) - hence cost is the unnormalized inverse - of itself. - -wsave contains initialization calculations which must not be - destroyed between calls of cost. - -****************************************************************** - -subroutine sinqi(n,wsave) - -****************************************************************** - -subroutine sinqi initializes the array wsave which is used in -both sinqf and sinqb. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the sequence to be transformed. the method - is most efficient when n is a product of small primes. - -output parameter - -wsave a work array which must be dimensioned at least 3*n+15. - the same work array can be used for both sinqf and sinqb - as long as n remains unchanged. different wsave arrays - are required for different values of n. the contents of - wsave must not be changed between calls of sinqf or sinqb. - -****************************************************************** - -subroutine sinqf(n,x,wsave) - -****************************************************************** - -subroutine sinqf computes the fast fourier transform of quarter -wave data. that is , sinqf computes the coefficients in a sine -series representation with only odd wave numbers. the transform -is defined below at output parameter x. - -sinqb is the unnormalized inverse of sinqf since a call of sinqf -followed by a call of sinqb will multiply the input sequence x -by 4*n. - -the array wsave which is used by subroutine sinqf must be -initialized by calling subroutine sinqi(n,wsave). - - -input parameters - -n the length of the array x to be transformed. the method - is most efficient when n is a product of small primes. - -x an array which contains the sequence to be transformed - -wsave a work array which must be dimensioned at least 3*n+15. - in the program that calls sinqf. the wsave array must be - initialized by calling subroutine sinqi(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - -output parameters - -x for i=1,...,n - - x(i) = (-1)**(i-1)*x(n) - - + the sum from k=1 to k=n-1 of - - 2*x(k)*sin((2*i-1)*k*pi/(2*n)) - - a call of sinqf followed by a call of - sinqb will multiply the sequence x by 4*n. - therefore sinqb is the unnormalized inverse - of sinqf. - -wsave contains initialization calculations which must not - be destroyed between calls of sinqf or sinqb. - -****************************************************************** - -subroutine sinqb(n,x,wsave) - -****************************************************************** - -subroutine sinqb computes the fast fourier transform of quarter -wave data. that is , sinqb computes a sequence from its -representation in terms of a sine series with odd wave numbers. -the transform is defined below at output parameter x. - -sinqf is the unnormalized inverse of sinqb since a call of sinqb -followed by a call of sinqf will multiply the input sequence x -by 4*n. - -the array wsave which is used by subroutine sinqb must be -initialized by calling subroutine sinqi(n,wsave). - - -input parameters - -n the length of the array x to be transformed. the method - is most efficient when n is a product of small primes. - -x an array which contains the sequence to be transformed - -wsave a work array which must be dimensioned at least 3*n+15. - in the program that calls sinqb. the wsave array must be - initialized by calling subroutine sinqi(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - -output parameters - -x for i=1,...,n - - x(i)= the sum from k=1 to k=n of - - 4*x(k)*sin((2k-1)*i*pi/(2*n)) - - a call of sinqb followed by a call of - sinqf will multiply the sequence x by 4*n. - therefore sinqf is the unnormalized inverse - of sinqb. - -wsave contains initialization calculations which must not - be destroyed between calls of sinqb or sinqf. - -****************************************************************** - -subroutine cosqi(n,wsave) - -****************************************************************** - -subroutine cosqi initializes the array wsave which is used in -both cosqf and cosqb. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the array to be transformed. the method - is most efficient when n is a product of small primes. - -output parameter - -wsave a work array which must be dimensioned at least 3*n+15. - the same work array can be used for both cosqf and cosqb - as long as n remains unchanged. different wsave arrays - are required for different values of n. the contents of - wsave must not be changed between calls of cosqf or cosqb. - -****************************************************************** - -subroutine cosqf(n,x,wsave) - -****************************************************************** - -subroutine cosqf computes the fast fourier transform of quarter -wave data. that is , cosqf computes the coefficients in a cosine -series representation with only odd wave numbers. the transform -is defined below at output parameter x - -cosqf is the unnormalized inverse of cosqb since a call of cosqf -followed by a call of cosqb will multiply the input sequence x -by 4*n. - -the array wsave which is used by subroutine cosqf must be -initialized by calling subroutine cosqi(n,wsave). - - -input parameters - -n the length of the array x to be transformed. the method - is most efficient when n is a product of small primes. - -x an array which contains the sequence to be transformed - -wsave a work array which must be dimensioned at least 3*n+15 - in the program that calls cosqf. the wsave array must be - initialized by calling subroutine cosqi(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - -output parameters - -x for i=1,...,n - - x(i) = x(1) plus the sum from k=2 to k=n of - - 2*x(k)*cos((2*i-1)*(k-1)*pi/(2*n)) - - a call of cosqf followed by a call of - cosqb will multiply the sequence x by 4*n. - therefore cosqb is the unnormalized inverse - of cosqf. - -wsave contains initialization calculations which must not - be destroyed between calls of cosqf or cosqb. - -****************************************************************** - -subroutine cosqb(n,x,wsave) - -****************************************************************** - -subroutine cosqb computes the fast fourier transform of quarter -wave data. that is , cosqb computes a sequence from its -representation in terms of a cosine series with odd wave numbers. -the transform is defined below at output parameter x. - -cosqb is the unnormalized inverse of cosqf since a call of cosqb -followed by a call of cosqf will multiply the input sequence x -by 4*n. - -the array wsave which is used by subroutine cosqb must be -initialized by calling subroutine cosqi(n,wsave). - - -input parameters - -n the length of the array x to be transformed. the method - is most efficient when n is a product of small primes. - -x an array which contains the sequence to be transformed - -wsave a work array that must be dimensioned at least 3*n+15 - in the program that calls cosqb. the wsave array must be - initialized by calling subroutine cosqi(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - -output parameters - -x for i=1,...,n - - x(i)= the sum from k=1 to k=n of - - 4*x(k)*cos((2*k-1)*(i-1)*pi/(2*n)) - - a call of cosqb followed by a call of - cosqf will multiply the sequence x by 4*n. - therefore cosqf is the unnormalized inverse - of cosqb. - -wsave contains initialization calculations which must not - be destroyed between calls of cosqb or cosqf. - -****************************************************************** - -subroutine cffti(n,wsave) - -****************************************************************** - -subroutine cffti initializes the array wsave which is used in -both cfftf and cfftb. the prime factorization of n together with -a tabulation of the trigonometric functions are computed and -stored in wsave. - -input parameter - -n the length of the sequence to be transformed - -output parameter - -wsave a work array which must be dimensioned at least 4*n+15 - the same work array can be used for both cfftf and cfftb - as long as n remains unchanged. different wsave arrays - are required for different values of n. the contents of - wsave must not be changed between calls of cfftf or cfftb. - -****************************************************************** - -subroutine cfftf(n,c,wsave) - -****************************************************************** - -subroutine cfftf computes the forward complex discrete fourier -transform (the fourier analysis). equivalently , cfftf computes -the fourier coefficients of a complex periodic sequence. -the transform is defined below at output parameter c. - -the transform is not normalized. to obtain a normalized transform -the output must be divided by n. otherwise a call of cfftf -followed by a call of cfftb will multiply the sequence by n. - -the array wsave which is used by subroutine cfftf must be -initialized by calling subroutine cffti(n,wsave). - -input parameters - - -n the length of the complex sequence c. the method is - more efficient when n is the product of small primes. n - -c a complex array of length n which contains the sequence - -wsave a real work array which must be dimensioned at least 4n+15 - in the program that calls cfftf. the wsave array must be - initialized by calling subroutine cffti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - the same wsave array can be used by cfftf and cfftb. - -output parameters - -c for j=1,...,n - - c(j)=the sum from k=1,...,n of - - c(k)*exp(-i*(j-1)*(k-1)*2*pi/n) - - where i=sqrt(-1) - -wsave contains initialization calculations which must not be - destroyed between calls of subroutine cfftf or cfftb - -****************************************************************** - -subroutine cfftb(n,c,wsave) - -****************************************************************** - -subroutine cfftb computes the backward complex discrete fourier -transform (the fourier synthesis). equivalently , cfftb computes -a complex periodic sequence from its fourier coefficients. -the transform is defined below at output parameter c. - -a call of cfftf followed by a call of cfftb will multiply the -sequence by n. - -the array wsave which is used by subroutine cfftb must be -initialized by calling subroutine cffti(n,wsave). - -input parameters - - -n the length of the complex sequence c. the method is - more efficient when n is the product of small primes. - -c a complex array of length n which contains the sequence - -wsave a real work array which must be dimensioned at least 4n+15 - in the program that calls cfftb. the wsave array must be - initialized by calling subroutine cffti(n,wsave) and a - different wsave array must be used for each different - value of n. this initialization does not have to be - repeated so long as n remains unchanged thus subsequent - transforms can be obtained faster than the first. - the same wsave array can be used by cfftf and cfftb. - -output parameters - -c for j=1,...,n - - c(j)=the sum from k=1,...,n of - - c(k)*exp(i*(j-1)*(k-1)*2*pi/n) - - where i=sqrt(-1) - -wsave contains initialization calculations which must not be - destroyed between calls of subroutine cfftf or cfftb - - - -["send index for vfftpk" describes a vectorized version of fftpack] - Deleted: branches/refactor_fft/scipy/fftpack/fftpack/rfftb.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/rfftb.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/rfftb.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,6 +0,0 @@ - SUBROUTINE RFFTB (N,R,WSAVE) - DIMENSION R(*) ,WSAVE(*) - IF (N .EQ. 1) RETURN - CALL RFFTB1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/rfftb1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/rfftb1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/rfftb1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,407 +0,0 @@ - SUBROUTINE RFFTB1 (N,C,CH,WA,IFAC) - DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*) - NF = IFAC(2) - NA = 0 - L1 = 1 - IW = 1 - DO 116 K1=1,NF - IP = IFAC(K1+2) - L2 = IP*L1 - IDO = N/L2 - IDL1 = IDO*L1 - IF (IP .NE. 4) GO TO 103 - IX2 = IW+IDO - IX3 = IX2+IDO - IF (NA .NE. 0) GO TO 101 - CALL RADB4 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3)) - GO TO 102 - 101 CALL RADB4 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3)) - 102 NA = 1-NA - GO TO 115 - 103 IF (IP .NE. 2) GO TO 106 - IF (NA .NE. 0) GO TO 104 - CALL RADB2 (IDO,L1,C,CH,WA(IW)) - GO TO 105 - 104 CALL RADB2 (IDO,L1,CH,C,WA(IW)) - 105 NA = 1-NA - GO TO 115 - 106 IF (IP .NE. 3) GO TO 109 - IX2 = IW+IDO - IF (NA .NE. 0) GO TO 107 - CALL RADB3 (IDO,L1,C,CH,WA(IW),WA(IX2)) - GO TO 108 - 107 CALL RADB3 (IDO,L1,CH,C,WA(IW),WA(IX2)) - 108 NA = 1-NA - GO TO 115 - 109 IF (IP .NE. 5) GO TO 112 - IX2 = IW+IDO - IX3 = IX2+IDO - IX4 = IX3+IDO - IF (NA .NE. 0) GO TO 110 - CALL RADB5 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - GO TO 111 - 110 CALL RADB5 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - 111 NA = 1-NA - GO TO 115 - 112 IF (NA .NE. 0) GO TO 113 - CALL RADBG (IDO,IP,L1,IDL1,C,C,C,CH,CH,WA(IW)) - GO TO 114 - 113 CALL RADBG (IDO,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW)) - 114 IF (IDO .EQ. 1) NA = 1-NA - 115 L1 = L2 - IW = IW+(IP-1)*IDO - 116 CONTINUE - IF (NA .EQ. 0) RETURN - DO 117 I=1,N - C(I) = CH(I) - 117 CONTINUE - RETURN - END - SUBROUTINE RADB2 (IDO,L1,CC,CH,WA1) - DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) , - 1 WA1(*) - DO 101 K=1,L1 - CH(1,K,1) = CC(1,1,K)+CC(IDO,2,K) - CH(1,K,2) = CC(1,1,K)-CC(IDO,2,K) - 101 CONTINUE - IF (IDO.lt.2) GO TO 107 - IF (IDO.eq.2) GO TO 105 - GO TO 102 - 102 IDP2 = IDO+2 - DO 104 K=1,L1 - DO 103 I=3,IDO,2 - IC = IDP2-I - CH(I-1,K,1) = CC(I-1,1,K)+CC(IC-1,2,K) - TR2 = CC(I-1,1,K)-CC(IC-1,2,K) - CH(I,K,1) = CC(I,1,K)-CC(IC,2,K) - TI2 = CC(I,1,K)+CC(IC,2,K) - CH(I-1,K,2) = WA1(I-2)*TR2-WA1(I-1)*TI2 - CH(I,K,2) = WA1(I-2)*TI2+WA1(I-1)*TR2 - 103 CONTINUE - 104 CONTINUE - IF (MOD(IDO,2) .EQ. 1) RETURN - 105 DO 106 K=1,L1 - CH(IDO,K,1) = CC(IDO,1,K)+CC(IDO,1,K) - CH(IDO,K,2) = -(CC(1,2,K)+CC(1,2,K)) - 106 CONTINUE - 107 RETURN - END - SUBROUTINE RADB3 (IDO,L1,CC,CH,WA1,WA2) - DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) , - 1 WA1(*) ,WA2(*) - DATA TAUR,TAUI /-.5,.866025403784439/ - DO 101 K=1,L1 - TR2 = CC(IDO,2,K)+CC(IDO,2,K) - CR2 = CC(1,1,K)+TAUR*TR2 - CH(1,K,1) = CC(1,1,K)+TR2 - CI3 = TAUI*(CC(1,3,K)+CC(1,3,K)) - CH(1,K,2) = CR2-CI3 - CH(1,K,3) = CR2+CI3 - 101 CONTINUE - IF (IDO .EQ. 1) RETURN - IDP2 = IDO+2 - DO 103 K=1,L1 - DO 102 I=3,IDO,2 - IC = IDP2-I - TR2 = CC(I-1,3,K)+CC(IC-1,2,K) - CR2 = CC(I-1,1,K)+TAUR*TR2 - CH(I-1,K,1) = CC(I-1,1,K)+TR2 - TI2 = CC(I,3,K)-CC(IC,2,K) - CI2 = CC(I,1,K)+TAUR*TI2 - CH(I,K,1) = CC(I,1,K)+TI2 - CR3 = TAUI*(CC(I-1,3,K)-CC(IC-1,2,K)) - CI3 = TAUI*(CC(I,3,K)+CC(IC,2,K)) - DR2 = CR2-CI3 - DR3 = CR2+CI3 - DI2 = CI2+CR3 - DI3 = CI2-CR3 - CH(I-1,K,2) = WA1(I-2)*DR2-WA1(I-1)*DI2 - CH(I,K,2) = WA1(I-2)*DI2+WA1(I-1)*DR2 - CH(I-1,K,3) = WA2(I-2)*DR3-WA2(I-1)*DI3 - CH(I,K,3) = WA2(I-2)*DI3+WA2(I-1)*DR3 - 102 CONTINUE - 103 CONTINUE - RETURN - END - SUBROUTINE RADB4 (IDO,L1,CC,CH,WA1,WA2,WA3) - DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) , - 1 WA1(*) ,WA2(*) ,WA3(*) - DATA SQRT2 /1.414213562373095/ - DO 101 K=1,L1 - TR1 = CC(1,1,K)-CC(IDO,4,K) - TR2 = CC(1,1,K)+CC(IDO,4,K) - TR3 = CC(IDO,2,K)+CC(IDO,2,K) - TR4 = CC(1,3,K)+CC(1,3,K) - CH(1,K,1) = TR2+TR3 - CH(1,K,2) = TR1-TR4 - CH(1,K,3) = TR2-TR3 - CH(1,K,4) = TR1+TR4 - 101 CONTINUE - IF (IDO.lt.2) GO TO 107 - IF (IDO.eq.2) GO TO 105 - GO TO 102 - 102 IDP2 = IDO+2 - DO 104 K=1,L1 - DO 103 I=3,IDO,2 - IC = IDP2-I - TI1 = CC(I,1,K)+CC(IC,4,K) - TI2 = CC(I,1,K)-CC(IC,4,K) - TI3 = CC(I,3,K)-CC(IC,2,K) - TR4 = CC(I,3,K)+CC(IC,2,K) - TR1 = CC(I-1,1,K)-CC(IC-1,4,K) - TR2 = CC(I-1,1,K)+CC(IC-1,4,K) - TI4 = CC(I-1,3,K)-CC(IC-1,2,K) - TR3 = CC(I-1,3,K)+CC(IC-1,2,K) - CH(I-1,K,1) = TR2+TR3 - CR3 = TR2-TR3 - CH(I,K,1) = TI2+TI3 - CI3 = TI2-TI3 - CR2 = TR1-TR4 - CR4 = TR1+TR4 - CI2 = TI1+TI4 - CI4 = TI1-TI4 - CH(I-1,K,2) = WA1(I-2)*CR2-WA1(I-1)*CI2 - CH(I,K,2) = WA1(I-2)*CI2+WA1(I-1)*CR2 - CH(I-1,K,3) = WA2(I-2)*CR3-WA2(I-1)*CI3 - CH(I,K,3) = WA2(I-2)*CI3+WA2(I-1)*CR3 - CH(I-1,K,4) = WA3(I-2)*CR4-WA3(I-1)*CI4 - CH(I,K,4) = WA3(I-2)*CI4+WA3(I-1)*CR4 - 103 CONTINUE - 104 CONTINUE - IF (MOD(IDO,2) .EQ. 1) RETURN - 105 CONTINUE - DO 106 K=1,L1 - TI1 = CC(1,2,K)+CC(1,4,K) - TI2 = CC(1,4,K)-CC(1,2,K) - TR1 = CC(IDO,1,K)-CC(IDO,3,K) - TR2 = CC(IDO,1,K)+CC(IDO,3,K) - CH(IDO,K,1) = TR2+TR2 - CH(IDO,K,2) = SQRT2*(TR1-TI1) - CH(IDO,K,3) = TI2+TI2 - CH(IDO,K,4) = -SQRT2*(TR1+TI1) - 106 CONTINUE - 107 RETURN - END - SUBROUTINE RADB5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4) - DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) , - 1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*) - DATA TR11,TI11,TR12,TI12 /.309016994374947,.951056516295154, - 1-.809016994374947,.587785252292473/ - DO 101 K=1,L1 - TI5 = CC(1,3,K)+CC(1,3,K) - TI4 = CC(1,5,K)+CC(1,5,K) - TR2 = CC(IDO,2,K)+CC(IDO,2,K) - TR3 = CC(IDO,4,K)+CC(IDO,4,K) - CH(1,K,1) = CC(1,1,K)+TR2+TR3 - CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3 - CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3 - CI5 = TI11*TI5+TI12*TI4 - CI4 = TI12*TI5-TI11*TI4 - CH(1,K,2) = CR2-CI5 - CH(1,K,3) = CR3-CI4 - CH(1,K,4) = CR3+CI4 - CH(1,K,5) = CR2+CI5 - 101 CONTINUE - IF (IDO .EQ. 1) RETURN - IDP2 = IDO+2 - DO 103 K=1,L1 - DO 102 I=3,IDO,2 - IC = IDP2-I - TI5 = CC(I,3,K)+CC(IC,2,K) - TI2 = CC(I,3,K)-CC(IC,2,K) - TI4 = CC(I,5,K)+CC(IC,4,K) - TI3 = CC(I,5,K)-CC(IC,4,K) - TR5 = CC(I-1,3,K)-CC(IC-1,2,K) - TR2 = CC(I-1,3,K)+CC(IC-1,2,K) - TR4 = CC(I-1,5,K)-CC(IC-1,4,K) - TR3 = CC(I-1,5,K)+CC(IC-1,4,K) - CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3 - CH(I,K,1) = CC(I,1,K)+TI2+TI3 - CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3 - CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3 - CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3 - CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3 - CR5 = TI11*TR5+TI12*TR4 - CI5 = TI11*TI5+TI12*TI4 - CR4 = TI12*TR5-TI11*TR4 - CI4 = TI12*TI5-TI11*TI4 - DR3 = CR3-CI4 - DR4 = CR3+CI4 - DI3 = CI3+CR4 - DI4 = CI3-CR4 - DR5 = CR2+CI5 - DR2 = CR2-CI5 - DI5 = CI2-CR5 - DI2 = CI2+CR5 - CH(I-1,K,2) = WA1(I-2)*DR2-WA1(I-1)*DI2 - CH(I,K,2) = WA1(I-2)*DI2+WA1(I-1)*DR2 - CH(I-1,K,3) = WA2(I-2)*DR3-WA2(I-1)*DI3 - CH(I,K,3) = WA2(I-2)*DI3+WA2(I-1)*DR3 - CH(I-1,K,4) = WA3(I-2)*DR4-WA3(I-1)*DI4 - CH(I,K,4) = WA3(I-2)*DI4+WA3(I-1)*DR4 - CH(I-1,K,5) = WA4(I-2)*DR5-WA4(I-1)*DI5 - CH(I,K,5) = WA4(I-2)*DI5+WA4(I-1)*DR5 - 102 CONTINUE - 103 CONTINUE - RETURN - END - SUBROUTINE RADBG (IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA) - DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) , - 1 C1(IDO,L1,IP) ,C2(IDL1,IP), - 2 CH2(IDL1,IP) ,WA(*) - DATA TPI/6.28318530717959/ - ARG = TPI/FLOAT(IP) - DCP = COS(ARG) - DSP = SIN(ARG) - IDP2 = IDO+2 - NBD = (IDO-1)/2 - IPP2 = IP+2 - IPPH = (IP+1)/2 - IF (IDO .LT. L1) GO TO 103 - DO 102 K=1,L1 - DO 101 I=1,IDO - CH(I,K,1) = CC(I,1,K) - 101 CONTINUE - 102 CONTINUE - GO TO 106 - 103 DO 105 I=1,IDO - DO 104 K=1,L1 - CH(I,K,1) = CC(I,1,K) - 104 CONTINUE - 105 CONTINUE - 106 DO 108 J=2,IPPH - JC = IPP2-J - J2 = J+J - DO 107 K=1,L1 - CH(1,K,J) = CC(IDO,J2-2,K)+CC(IDO,J2-2,K) - CH(1,K,JC) = CC(1,J2-1,K)+CC(1,J2-1,K) - 107 CONTINUE - 108 CONTINUE - IF (IDO .EQ. 1) GO TO 116 - IF (NBD .LT. L1) GO TO 112 - DO 111 J=2,IPPH - JC = IPP2-J - DO 110 K=1,L1 - DO 109 I=3,IDO,2 - IC = IDP2-I - CH(I-1,K,J) = CC(I-1,2*J-1,K)+CC(IC-1,2*J-2,K) - CH(I-1,K,JC) = CC(I-1,2*J-1,K)-CC(IC-1,2*J-2,K) - CH(I,K,J) = CC(I,2*J-1,K)-CC(IC,2*J-2,K) - CH(I,K,JC) = CC(I,2*J-1,K)+CC(IC,2*J-2,K) - 109 CONTINUE - 110 CONTINUE - 111 CONTINUE - GO TO 116 - 112 DO 115 J=2,IPPH - JC = IPP2-J - DO 114 I=3,IDO,2 - IC = IDP2-I - DO 113 K=1,L1 - CH(I-1,K,J) = CC(I-1,2*J-1,K)+CC(IC-1,2*J-2,K) - CH(I-1,K,JC) = CC(I-1,2*J-1,K)-CC(IC-1,2*J-2,K) - CH(I,K,J) = CC(I,2*J-1,K)-CC(IC,2*J-2,K) - CH(I,K,JC) = CC(I,2*J-1,K)+CC(IC,2*J-2,K) - 113 CONTINUE - 114 CONTINUE - 115 CONTINUE - 116 AR1 = 1. - AI1 = 0. - DO 120 L=2,IPPH - LC = IPP2-L - AR1H = DCP*AR1-DSP*AI1 - AI1 = DCP*AI1+DSP*AR1 - AR1 = AR1H - DO 117 IK=1,IDL1 - C2(IK,L) = CH2(IK,1)+AR1*CH2(IK,2) - C2(IK,LC) = AI1*CH2(IK,IP) - 117 CONTINUE - DC2 = AR1 - DS2 = AI1 - AR2 = AR1 - AI2 = AI1 - DO 119 J=3,IPPH - JC = IPP2-J - AR2H = DC2*AR2-DS2*AI2 - AI2 = DC2*AI2+DS2*AR2 - AR2 = AR2H - DO 118 IK=1,IDL1 - C2(IK,L) = C2(IK,L)+AR2*CH2(IK,J) - C2(IK,LC) = C2(IK,LC)+AI2*CH2(IK,JC) - 118 CONTINUE - 119 CONTINUE - 120 CONTINUE - DO 122 J=2,IPPH - DO 121 IK=1,IDL1 - CH2(IK,1) = CH2(IK,1)+CH2(IK,J) - 121 CONTINUE - 122 CONTINUE - DO 124 J=2,IPPH - JC = IPP2-J - DO 123 K=1,L1 - CH(1,K,J) = C1(1,K,J)-C1(1,K,JC) - CH(1,K,JC) = C1(1,K,J)+C1(1,K,JC) - 123 CONTINUE - 124 CONTINUE - IF (IDO .EQ. 1) GO TO 132 - IF (NBD .LT. L1) GO TO 128 - DO 127 J=2,IPPH - JC = IPP2-J - DO 126 K=1,L1 - DO 125 I=3,IDO,2 - CH(I-1,K,J) = C1(I-1,K,J)-C1(I,K,JC) - CH(I-1,K,JC) = C1(I-1,K,J)+C1(I,K,JC) - CH(I,K,J) = C1(I,K,J)+C1(I-1,K,JC) - CH(I,K,JC) = C1(I,K,J)-C1(I-1,K,JC) - 125 CONTINUE - 126 CONTINUE - 127 CONTINUE - GO TO 132 - 128 DO 131 J=2,IPPH - JC = IPP2-J - DO 130 I=3,IDO,2 - DO 129 K=1,L1 - CH(I-1,K,J) = C1(I-1,K,J)-C1(I,K,JC) - CH(I-1,K,JC) = C1(I-1,K,J)+C1(I,K,JC) - CH(I,K,J) = C1(I,K,J)+C1(I-1,K,JC) - CH(I,K,JC) = C1(I,K,J)-C1(I-1,K,JC) - 129 CONTINUE - 130 CONTINUE - 131 CONTINUE - 132 CONTINUE - IF (IDO .EQ. 1) RETURN - DO 133 IK=1,IDL1 - C2(IK,1) = CH2(IK,1) - 133 CONTINUE - DO 135 J=2,IP - DO 134 K=1,L1 - C1(1,K,J) = CH(1,K,J) - 134 CONTINUE - 135 CONTINUE - IF (NBD .GT. L1) GO TO 139 - IS = -IDO - DO 138 J=2,IP - IS = IS+IDO - IDIJ = IS - DO 137 I=3,IDO,2 - IDIJ = IDIJ+2 - DO 136 K=1,L1 - C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J) - C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J) - 136 CONTINUE - 137 CONTINUE - 138 CONTINUE - GO TO 143 - 139 IS = -IDO - DO 142 J=2,IP - IS = IS+IDO - DO 141 K=1,L1 - IDIJ = IS - DO 140 I=3,IDO,2 - IDIJ = IDIJ+2 - C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J) - C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J) - 140 CONTINUE - 141 CONTINUE - 142 CONTINUE - 143 RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/rfftf.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/rfftf.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/rfftf.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,6 +0,0 @@ - SUBROUTINE RFFTF (N,R,WSAVE) - DIMENSION R(*) ,WSAVE(*) - IF (N .EQ. 1) RETURN - CALL RFFTF1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/rfftf1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/rfftf1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/rfftf1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,403 +0,0 @@ - SUBROUTINE RFFTF1 (N,C,CH,WA,IFAC) - DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*) - NF = IFAC(2) - NA = 1 - L2 = N - IW = N - DO 111 K1=1,NF - KH = NF-K1 - IP = IFAC(KH+3) - L1 = L2/IP - IDO = N/L2 - IDL1 = IDO*L1 - IW = IW-(IP-1)*IDO - NA = 1-NA - IF (IP .NE. 4) GO TO 102 - IX2 = IW+IDO - IX3 = IX2+IDO - IF (NA .NE. 0) GO TO 101 - CALL RADF4 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3)) - GO TO 110 - 101 CALL RADF4 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3)) - GO TO 110 - 102 IF (IP .NE. 2) GO TO 104 - IF (NA .NE. 0) GO TO 103 - CALL RADF2 (IDO,L1,C,CH,WA(IW)) - GO TO 110 - 103 CALL RADF2 (IDO,L1,CH,C,WA(IW)) - GO TO 110 - 104 IF (IP .NE. 3) GO TO 106 - IX2 = IW+IDO - IF (NA .NE. 0) GO TO 105 - CALL RADF3 (IDO,L1,C,CH,WA(IW),WA(IX2)) - GO TO 110 - 105 CALL RADF3 (IDO,L1,CH,C,WA(IW),WA(IX2)) - GO TO 110 - 106 IF (IP .NE. 5) GO TO 108 - IX2 = IW+IDO - IX3 = IX2+IDO - IX4 = IX3+IDO - IF (NA .NE. 0) GO TO 107 - CALL RADF5 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - GO TO 110 - 107 CALL RADF5 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4)) - GO TO 110 - 108 IF (IDO .EQ. 1) NA = 1-NA - IF (NA .NE. 0) GO TO 109 - CALL RADFG (IDO,IP,L1,IDL1,C,C,C,CH,CH,WA(IW)) - NA = 1 - GO TO 110 - 109 CALL RADFG (IDO,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW)) - NA = 0 - 110 L2 = L1 - 111 CONTINUE - IF (NA .EQ. 1) RETURN - DO 112 I=1,N - C(I) = CH(I) - 112 CONTINUE - RETURN - END - SUBROUTINE RADF2 (IDO,L1,CC,CH,WA1) - DIMENSION CH(IDO,2,L1) ,CC(IDO,L1,2) , - 1 WA1(*) - DO 101 K=1,L1 - CH(1,1,K) = CC(1,K,1)+CC(1,K,2) - CH(IDO,2,K) = CC(1,K,1)-CC(1,K,2) - 101 CONTINUE - IF (IDO.lt.2) GO TO 107 - IF (IDO.eq.2) GO TO 105 - GO TO 102 - 102 IDP2 = IDO+2 - DO 104 K=1,L1 - DO 103 I=3,IDO,2 - IC = IDP2-I - TR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2) - TI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2) - CH(I,1,K) = CC(I,K,1)+TI2 - CH(IC,2,K) = TI2-CC(I,K,1) - CH(I-1,1,K) = CC(I-1,K,1)+TR2 - CH(IC-1,2,K) = CC(I-1,K,1)-TR2 - 103 CONTINUE - 104 CONTINUE - IF (MOD(IDO,2) .EQ. 1) RETURN - 105 DO 106 K=1,L1 - CH(1,2,K) = -CC(IDO,K,2) - CH(IDO,1,K) = CC(IDO,K,1) - 106 CONTINUE - 107 RETURN - END - SUBROUTINE RADF3 (IDO,L1,CC,CH,WA1,WA2) - DIMENSION CH(IDO,3,L1) ,CC(IDO,L1,3) , - 1 WA1(*) ,WA2(*) - DATA TAUR,TAUI /-.5,.866025403784439/ - DO 101 K=1,L1 - CR2 = CC(1,K,2)+CC(1,K,3) - CH(1,1,K) = CC(1,K,1)+CR2 - CH(1,3,K) = TAUI*(CC(1,K,3)-CC(1,K,2)) - CH(IDO,2,K) = CC(1,K,1)+TAUR*CR2 - 101 CONTINUE - IF (IDO .EQ. 1) RETURN - IDP2 = IDO+2 - DO 103 K=1,L1 - DO 102 I=3,IDO,2 - IC = IDP2-I - DR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2) - DI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2) - DR3 = WA2(I-2)*CC(I-1,K,3)+WA2(I-1)*CC(I,K,3) - DI3 = WA2(I-2)*CC(I,K,3)-WA2(I-1)*CC(I-1,K,3) - CR2 = DR2+DR3 - CI2 = DI2+DI3 - CH(I-1,1,K) = CC(I-1,K,1)+CR2 - CH(I,1,K) = CC(I,K,1)+CI2 - TR2 = CC(I-1,K,1)+TAUR*CR2 - TI2 = CC(I,K,1)+TAUR*CI2 - TR3 = TAUI*(DI2-DI3) - TI3 = TAUI*(DR3-DR2) - CH(I-1,3,K) = TR2+TR3 - CH(IC-1,2,K) = TR2-TR3 - CH(I,3,K) = TI2+TI3 - CH(IC,2,K) = TI3-TI2 - 102 CONTINUE - 103 CONTINUE - RETURN - END - SUBROUTINE RADF4 (IDO,L1,CC,CH,WA1,WA2,WA3) - DIMENSION CC(IDO,L1,4) ,CH(IDO,4,L1) , - 1 WA1(*) ,WA2(*) ,WA3(*) - DATA HSQT2 /.7071067811865475/ - DO 101 K=1,L1 - TR1 = CC(1,K,2)+CC(1,K,4) - TR2 = CC(1,K,1)+CC(1,K,3) - CH(1,1,K) = TR1+TR2 - CH(IDO,4,K) = TR2-TR1 - CH(IDO,2,K) = CC(1,K,1)-CC(1,K,3) - CH(1,3,K) = CC(1,K,4)-CC(1,K,2) - 101 CONTINUE - IF (IDO.lt.2) GO TO 107 - IF (IDO.eq.2) GO TO 105 - GO TO 102 - 102 IDP2 = IDO+2 - DO 104 K=1,L1 - DO 103 I=3,IDO,2 - IC = IDP2-I - CR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2) - CI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2) - CR3 = WA2(I-2)*CC(I-1,K,3)+WA2(I-1)*CC(I,K,3) - CI3 = WA2(I-2)*CC(I,K,3)-WA2(I-1)*CC(I-1,K,3) - CR4 = WA3(I-2)*CC(I-1,K,4)+WA3(I-1)*CC(I,K,4) - CI4 = WA3(I-2)*CC(I,K,4)-WA3(I-1)*CC(I-1,K,4) - TR1 = CR2+CR4 - TR4 = CR4-CR2 - TI1 = CI2+CI4 - TI4 = CI2-CI4 - TI2 = CC(I,K,1)+CI3 - TI3 = CC(I,K,1)-CI3 - TR2 = CC(I-1,K,1)+CR3 - TR3 = CC(I-1,K,1)-CR3 - CH(I-1,1,K) = TR1+TR2 - CH(IC-1,4,K) = TR2-TR1 - CH(I,1,K) = TI1+TI2 - CH(IC,4,K) = TI1-TI2 - CH(I-1,3,K) = TI4+TR3 - CH(IC-1,2,K) = TR3-TI4 - CH(I,3,K) = TR4+TI3 - CH(IC,2,K) = TR4-TI3 - 103 CONTINUE - 104 CONTINUE - IF (MOD(IDO,2) .EQ. 1) RETURN - 105 CONTINUE - DO 106 K=1,L1 - TI1 = -HSQT2*(CC(IDO,K,2)+CC(IDO,K,4)) - TR1 = HSQT2*(CC(IDO,K,2)-CC(IDO,K,4)) - CH(IDO,1,K) = TR1+CC(IDO,K,1) - CH(IDO,3,K) = CC(IDO,K,1)-TR1 - CH(1,2,K) = TI1-CC(IDO,K,3) - CH(1,4,K) = TI1+CC(IDO,K,3) - 106 CONTINUE - 107 RETURN - END - SUBROUTINE RADF5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4) - DIMENSION CC(IDO,L1,5) ,CH(IDO,5,L1) , - 1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*) - DATA TR11,TI11,TR12,TI12 /.309016994374947,.951056516295154, - 1-.809016994374947,.587785252292473/ - DO 101 K=1,L1 - CR2 = CC(1,K,5)+CC(1,K,2) - CI5 = CC(1,K,5)-CC(1,K,2) - CR3 = CC(1,K,4)+CC(1,K,3) - CI4 = CC(1,K,4)-CC(1,K,3) - CH(1,1,K) = CC(1,K,1)+CR2+CR3 - CH(IDO,2,K) = CC(1,K,1)+TR11*CR2+TR12*CR3 - CH(1,3,K) = TI11*CI5+TI12*CI4 - CH(IDO,4,K) = CC(1,K,1)+TR12*CR2+TR11*CR3 - CH(1,5,K) = TI12*CI5-TI11*CI4 - 101 CONTINUE - IF (IDO .EQ. 1) RETURN - IDP2 = IDO+2 - DO 103 K=1,L1 - DO 102 I=3,IDO,2 - IC = IDP2-I - DR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2) - DI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2) - DR3 = WA2(I-2)*CC(I-1,K,3)+WA2(I-1)*CC(I,K,3) - DI3 = WA2(I-2)*CC(I,K,3)-WA2(I-1)*CC(I-1,K,3) - DR4 = WA3(I-2)*CC(I-1,K,4)+WA3(I-1)*CC(I,K,4) - DI4 = WA3(I-2)*CC(I,K,4)-WA3(I-1)*CC(I-1,K,4) - DR5 = WA4(I-2)*CC(I-1,K,5)+WA4(I-1)*CC(I,K,5) - DI5 = WA4(I-2)*CC(I,K,5)-WA4(I-1)*CC(I-1,K,5) - CR2 = DR2+DR5 - CI5 = DR5-DR2 - CR5 = DI2-DI5 - CI2 = DI2+DI5 - CR3 = DR3+DR4 - CI4 = DR4-DR3 - CR4 = DI3-DI4 - CI3 = DI3+DI4 - CH(I-1,1,K) = CC(I-1,K,1)+CR2+CR3 - CH(I,1,K) = CC(I,K,1)+CI2+CI3 - TR2 = CC(I-1,K,1)+TR11*CR2+TR12*CR3 - TI2 = CC(I,K,1)+TR11*CI2+TR12*CI3 - TR3 = CC(I-1,K,1)+TR12*CR2+TR11*CR3 - TI3 = CC(I,K,1)+TR12*CI2+TR11*CI3 - TR5 = TI11*CR5+TI12*CR4 - TI5 = TI11*CI5+TI12*CI4 - TR4 = TI12*CR5-TI11*CR4 - TI4 = TI12*CI5-TI11*CI4 - CH(I-1,3,K) = TR2+TR5 - CH(IC-1,2,K) = TR2-TR5 - CH(I,3,K) = TI2+TI5 - CH(IC,2,K) = TI5-TI2 - CH(I-1,5,K) = TR3+TR4 - CH(IC-1,4,K) = TR3-TR4 - CH(I,5,K) = TI3+TI4 - CH(IC,4,K) = TI4-TI3 - 102 CONTINUE - 103 CONTINUE - RETURN - END - SUBROUTINE RADFG (IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA) - DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) , - 1 C1(IDO,L1,IP) ,C2(IDL1,IP), - 2 CH2(IDL1,IP) ,WA(*) - DATA TPI/6.28318530717959/ - ARG = TPI/FLOAT(IP) - DCP = COS(ARG) - DSP = SIN(ARG) - IPPH = (IP+1)/2 - IPP2 = IP+2 - IDP2 = IDO+2 - NBD = (IDO-1)/2 - IF (IDO .EQ. 1) GO TO 119 - DO 101 IK=1,IDL1 - CH2(IK,1) = C2(IK,1) - 101 CONTINUE - DO 103 J=2,IP - DO 102 K=1,L1 - CH(1,K,J) = C1(1,K,J) - 102 CONTINUE - 103 CONTINUE - IF (NBD .GT. L1) GO TO 107 - IS = -IDO - DO 106 J=2,IP - IS = IS+IDO - IDIJ = IS - DO 105 I=3,IDO,2 - IDIJ = IDIJ+2 - DO 104 K=1,L1 - CH(I-1,K,J) = WA(IDIJ-1)*C1(I-1,K,J)+WA(IDIJ)*C1(I,K,J) - CH(I,K,J) = WA(IDIJ-1)*C1(I,K,J)-WA(IDIJ)*C1(I-1,K,J) - 104 CONTINUE - 105 CONTINUE - 106 CONTINUE - GO TO 111 - 107 IS = -IDO - DO 110 J=2,IP - IS = IS+IDO - DO 109 K=1,L1 - IDIJ = IS - DO 108 I=3,IDO,2 - IDIJ = IDIJ+2 - CH(I-1,K,J) = WA(IDIJ-1)*C1(I-1,K,J)+WA(IDIJ)*C1(I,K,J) - CH(I,K,J) = WA(IDIJ-1)*C1(I,K,J)-WA(IDIJ)*C1(I-1,K,J) - 108 CONTINUE - 109 CONTINUE - 110 CONTINUE - 111 IF (NBD .LT. L1) GO TO 115 - DO 114 J=2,IPPH - JC = IPP2-J - DO 113 K=1,L1 - DO 112 I=3,IDO,2 - C1(I-1,K,J) = CH(I-1,K,J)+CH(I-1,K,JC) - C1(I-1,K,JC) = CH(I,K,J)-CH(I,K,JC) - C1(I,K,J) = CH(I,K,J)+CH(I,K,JC) - C1(I,K,JC) = CH(I-1,K,JC)-CH(I-1,K,J) - 112 CONTINUE - 113 CONTINUE - 114 CONTINUE - GO TO 121 - 115 DO 118 J=2,IPPH - JC = IPP2-J - DO 117 I=3,IDO,2 - DO 116 K=1,L1 - C1(I-1,K,J) = CH(I-1,K,J)+CH(I-1,K,JC) - C1(I-1,K,JC) = CH(I,K,J)-CH(I,K,JC) - C1(I,K,J) = CH(I,K,J)+CH(I,K,JC) - C1(I,K,JC) = CH(I-1,K,JC)-CH(I-1,K,J) - 116 CONTINUE - 117 CONTINUE - 118 CONTINUE - GO TO 121 - 119 DO 120 IK=1,IDL1 - C2(IK,1) = CH2(IK,1) - 120 CONTINUE - 121 DO 123 J=2,IPPH - JC = IPP2-J - DO 122 K=1,L1 - C1(1,K,J) = CH(1,K,J)+CH(1,K,JC) - C1(1,K,JC) = CH(1,K,JC)-CH(1,K,J) - 122 CONTINUE - 123 CONTINUE -C - AR1 = 1. - AI1 = 0. - DO 127 L=2,IPPH - LC = IPP2-L - AR1H = DCP*AR1-DSP*AI1 - AI1 = DCP*AI1+DSP*AR1 - AR1 = AR1H - DO 124 IK=1,IDL1 - CH2(IK,L) = C2(IK,1)+AR1*C2(IK,2) - CH2(IK,LC) = AI1*C2(IK,IP) - 124 CONTINUE - DC2 = AR1 - DS2 = AI1 - AR2 = AR1 - AI2 = AI1 - DO 126 J=3,IPPH - JC = IPP2-J - AR2H = DC2*AR2-DS2*AI2 - AI2 = DC2*AI2+DS2*AR2 - AR2 = AR2H - DO 125 IK=1,IDL1 - CH2(IK,L) = CH2(IK,L)+AR2*C2(IK,J) - CH2(IK,LC) = CH2(IK,LC)+AI2*C2(IK,JC) - 125 CONTINUE - 126 CONTINUE - 127 CONTINUE - DO 129 J=2,IPPH - DO 128 IK=1,IDL1 - CH2(IK,1) = CH2(IK,1)+C2(IK,J) - 128 CONTINUE - 129 CONTINUE -C - IF (IDO .LT. L1) GO TO 132 - DO 131 K=1,L1 - DO 130 I=1,IDO - CC(I,1,K) = CH(I,K,1) - 130 CONTINUE - 131 CONTINUE - GO TO 135 - 132 DO 134 I=1,IDO - DO 133 K=1,L1 - CC(I,1,K) = CH(I,K,1) - 133 CONTINUE - 134 CONTINUE - 135 DO 137 J=2,IPPH - JC = IPP2-J - J2 = J+J - DO 136 K=1,L1 - CC(IDO,J2-2,K) = CH(1,K,J) - CC(1,J2-1,K) = CH(1,K,JC) - 136 CONTINUE - 137 CONTINUE - IF (IDO .EQ. 1) RETURN - IF (NBD .LT. L1) GO TO 141 - DO 140 J=2,IPPH - JC = IPP2-J - J2 = J+J - DO 139 K=1,L1 - DO 138 I=3,IDO,2 - IC = IDP2-I - CC(I-1,J2-1,K) = CH(I-1,K,J)+CH(I-1,K,JC) - CC(IC-1,J2-2,K) = CH(I-1,K,J)-CH(I-1,K,JC) - CC(I,J2-1,K) = CH(I,K,J)+CH(I,K,JC) - CC(IC,J2-2,K) = CH(I,K,JC)-CH(I,K,J) - 138 CONTINUE - 139 CONTINUE - 140 CONTINUE - RETURN - 141 DO 144 J=2,IPPH - JC = IPP2-J - J2 = J+J - DO 143 I=3,IDO,2 - IC = IDP2-I - DO 142 K=1,L1 - CC(I-1,J2-1,K) = CH(I-1,K,J)+CH(I-1,K,JC) - CC(IC-1,J2-2,K) = CH(I-1,K,J)-CH(I-1,K,JC) - CC(I,J2-1,K) = CH(I,K,J)+CH(I,K,JC) - CC(IC,J2-2,K) = CH(I,K,JC)-CH(I,K,J) - 142 CONTINUE - 143 CONTINUE - 144 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/rffti.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/rffti.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/rffti.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,6 +0,0 @@ - SUBROUTINE RFFTI (N,WSAVE) - DIMENSION WSAVE(*) - IF (N .EQ. 1) RETURN - CALL RFFTI1 (N,WSAVE(N+1),WSAVE(2*N+1)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/rffti1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/rffti1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/rffti1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,59 +0,0 @@ - SUBROUTINE RFFTI1 (N,WA,IFAC) - DIMENSION WA(*) ,IFAC(*) ,NTRYH(4) - DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/4,2,3,5/ - NL = N - NF = 0 - J = 0 - 101 J = J+1 - IF (J.le.4) GO TO 102 - GO TO 103 - 102 NTRY = NTRYH(J) - GO TO 104 - 103 NTRY = NTRY+2 - 104 NQ = NL/NTRY - NR = NL-NTRY*NQ - IF (NR.eq.0) GO TO 105 - GO TO 101 - 105 NF = NF+1 - IFAC(NF+2) = NTRY - NL = NQ - IF (NTRY .NE. 2) GO TO 107 - IF (NF .EQ. 1) GO TO 107 - DO 106 I=2,NF - IB = NF-I+2 - IFAC(IB+2) = IFAC(IB+1) - 106 CONTINUE - IFAC(3) = 2 - 107 IF (NL .NE. 1) GO TO 104 - IFAC(1) = N - IFAC(2) = NF - TPI = 6.28318530717959 - ARGH = TPI/FLOAT(N) - IS = 0 - NFM1 = NF-1 - L1 = 1 - IF (NFM1 .EQ. 0) RETURN - DO 110 K1=1,NFM1 - IP = IFAC(K1+2) - LD = 0 - L2 = L1*IP - IDO = N/L2 - IPM = IP-1 - DO 109 J=1,IPM - LD = LD+L1 - I = IS - ARGLD = FLOAT(LD)*ARGH - FI = 0. - DO 108 II=3,IDO,2 - I = I+2 - FI = FI+1. - ARG = FI*ARGLD - WA(I-1) = COS(ARG) - WA(I) = SIN(ARG) - 108 CONTINUE - IS = IS+IDO - 109 CONTINUE - L1 = L2 - 110 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/sinqb.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/sinqb.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/sinqb.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,18 +0,0 @@ - SUBROUTINE SINQB (N,X,WSAVE) - DIMENSION X(*) ,WSAVE(*) - IF (N .GT. 1) GO TO 101 - X(1) = 4.*X(1) - RETURN - 101 NS2 = N/2 - DO 102 K=2,N,2 - X(K) = -X(K) - 102 CONTINUE - CALL COSQB (N,X,WSAVE) - DO 103 K=1,NS2 - KC = N-K - XHOLD = X(K) - X(K) = X(KC+1) - X(KC+1) = XHOLD - 103 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/sinqf.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/sinqf.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/sinqf.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,16 +0,0 @@ - SUBROUTINE SINQF (N,X,WSAVE) - DIMENSION X(*) ,WSAVE(*) - IF (N .EQ. 1) RETURN - NS2 = N/2 - DO 101 K=1,NS2 - KC = N-K - XHOLD = X(K) - X(K) = X(KC+1) - X(KC+1) = XHOLD - 101 CONTINUE - CALL COSQF (N,X,WSAVE) - DO 102 K=2,N,2 - X(K) = -X(K) - 102 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/sinqi.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/sinqi.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/sinqi.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,5 +0,0 @@ - SUBROUTINE SINQI (N,WSAVE) - DIMENSION WSAVE(*) - CALL COSQI (N,WSAVE) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/sint.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/sint.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/sint.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,9 +0,0 @@ - SUBROUTINE SINT (N,X,WSAVE) - DIMENSION X(*) ,WSAVE(*) - NP1 = N+1 - IW1 = N/2+1 - IW2 = IW1+NP1 - IW3 = IW2+NP1 - CALL SINT1(N,X,WSAVE,WSAVE(IW1),WSAVE(IW2),WSAVE(IW3)) - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/sint1.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/sint1.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/sint1.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,42 +0,0 @@ - SUBROUTINE SINT1(N,WAR,WAS,XH,X,IFAC) - DIMENSION WAR(*),WAS(*),X(*),XH(*),IFAC(*) - DATA SQRT3 /1.73205080756888/ - DO 100 I=1,N - XH(I) = WAR(I) - WAR(I) = X(I) - 100 CONTINUE - IF (N.lt.2) GO TO 101 - IF (N.eq.2) GO TO 102 - GO TO 103 - 101 XH(1) = XH(1)+XH(1) - GO TO 106 - 102 XHOLD = SQRT3*(XH(1)+XH(2)) - XH(2) = SQRT3*(XH(1)-XH(2)) - XH(1) = XHOLD - GO TO 106 - 103 NP1 = N+1 - NS2 = N/2 - X(1) = 0. - DO 104 K=1,NS2 - KC = NP1-K - T1 = XH(K)-XH(KC) - T2 = WAS(K)*(XH(K)+XH(KC)) - X(K+1) = T1+T2 - X(KC+1) = T2-T1 - 104 CONTINUE - MODN = MOD(N,2) - IF (MODN .NE. 0) X(NS2+2) = 4.*XH(NS2+1) - CALL RFFTF1 (NP1,X,XH,WAR,IFAC) - XH(1) = .5*X(1) - DO 105 I=3,N,2 - XH(I-1) = -X(I) - XH(I) = XH(I-2)+X(I-1) - 105 CONTINUE - IF (MODN .NE. 0) GO TO 106 - XH(N) = -X(N+1) - 106 DO 107 I=1,N - X(I) = WAR(I) - WAR(I) = XH(I) - 107 CONTINUE - RETURN - END Deleted: branches/refactor_fft/scipy/fftpack/fftpack/sinti.f =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/sinti.f 2008-05-15 12:46:07 UTC (rev 4343) +++ branches/refactor_fft/scipy/fftpack/fftpack/sinti.f 2008-05-15 14:03:42 UTC (rev 4344) @@ -1,13 +0,0 @@ - SUBROUTINE SINTI (N,WSAVE) - DIMENSION WSAVE(*) - DATA PI /3.14159265358979/ - IF (N .LE. 1) RETURN - NS2 = N/2 - NP1 = N+1 - DT = PI/FLOAT(NP1) - DO 101 K=1,NS2 - WSAVE(K) = 2.*SIN(K*DT) - 101 CONTINUE - CALL RFFTI (NP1,WSAVE(NS2+1)) - RETURN - END From scipy-svn at scipy.org Thu May 15 10:09:52 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 09:09:52 -0500 (CDT) Subject: [Scipy-svn] r4345 - in branches/refactor_fft/scipy/fftpack/fftpack: . DFFTPACK Message-ID: <20080515140952.974E539C080@scipy.org> Author: cdavid Date: 2008-05-15 09:09:14 -0500 (Thu, 15 May 2008) New Revision: 4345 Added: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/ branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosqb.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosqf.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosqi.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcost.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosti.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftb.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftb1.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftf.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftf1.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dffti.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dffti1.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/doc branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/doc.double branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinqb.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinqf.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinqi.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsint.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsint1.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinti.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftb.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftb1.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftf.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftf1.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zffti.f branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zffti1.f Log: Move sources of dfftpack in subdir Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosqb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dcosqb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosqf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dcosqf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosqi.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dcosqi.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcost.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dcost.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dcosti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dcosti.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dfftb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftb1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dfftb1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dfftf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dfftf1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dfftf1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dffti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dffti.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dffti1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dffti1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/doc (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/doc) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/doc.double (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/doc.double) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinqb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dsinqb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinqf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dsinqf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinqi.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dsinqi.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsint.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dsint.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsint1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dsint1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/dsinti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/dsinti.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftb.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/zfftb.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftb1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/zfftb1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftf.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/zfftf.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zfftf1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/zfftf1.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zffti.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/zffti.f) Copied: branches/refactor_fft/scipy/fftpack/fftpack/DFFTPACK/zffti1.f (from rev 4338, branches/refactor_fft/scipy/fftpack/dfftpack/zffti1.f) From scipy-svn at scipy.org Thu May 15 10:18:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 09:18:28 -0500 (CDT) Subject: [Scipy-svn] r4346 - in branches/refactor_fft/scipy/fftpack/fftpack: . src src/fftpack Message-ID: <20080515141828.CF6EE39C080@scipy.org> Author: cdavid Date: 2008-05-15 09:18:08 -0500 (Thu, 15 May 2008) New Revision: 4346 Added: branches/refactor_fft/scipy/fftpack/fftpack/src/ branches/refactor_fft/scipy/fftpack/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/cycliccache.h branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.h branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/ branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/api.h branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/common.h branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/convolve.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/drfft.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/zfft.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/zfftnd.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/zrfft.c Log: Move fftpack wrapper sources. Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/convolve.cxx (from rev 4338, branches/refactor_fft/scipy/fftpack/src/convolve.cxx) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/cycliccache.h (from rev 4338, branches/refactor_fft/scipy/fftpack/src/cycliccache.h) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/api.h (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack/api.h) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/common.h (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack/common.h) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/convolve.cxx (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack/convolve.cxx) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/drfft.cxx (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack/drfft.cxx) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/zfft.cxx (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack/zfft.cxx) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack/zfftnd.cxx (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack/zfftnd.cxx) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.cxx (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack.cxx) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.h (from rev 4338, branches/refactor_fft/scipy/fftpack/src/fftpack.h) Copied: branches/refactor_fft/scipy/fftpack/fftpack/src/zrfft.c (from rev 4338, branches/refactor_fft/scipy/fftpack/src/zrfft.c) From scipy-svn at scipy.org Thu May 15 10:36:06 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 09:36:06 -0500 (CDT) Subject: [Scipy-svn] r4347 - branches/refactor_fft/scipy/fftpack/fftpack Message-ID: <20080515143606.1BB3839C080@scipy.org> Author: cdavid Date: 2008-05-15 09:35:54 -0500 (Thu, 15 May 2008) New Revision: 4347 Added: branches/refactor_fft/scipy/fftpack/fftpack/__init__.py branches/refactor_fft/scipy/fftpack/fftpack/convolve.pyf branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf branches/refactor_fft/scipy/fftpack/fftpack/setup.py Log: Put fftpack + its wrapper in subdir, for easier backend customization. Added: branches/refactor_fft/scipy/fftpack/fftpack/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/__init__.py 2008-05-15 14:18:08 UTC (rev 4346) +++ branches/refactor_fft/scipy/fftpack/fftpack/__init__.py 2008-05-15 14:35:54 UTC (rev 4347) @@ -0,0 +1,3 @@ +from _fftpack import zfft_fftpack as zfft, \ + zfftnd_fftpack as zfftnd, \ + drfft_fftpack as drfft Copied: branches/refactor_fft/scipy/fftpack/fftpack/convolve.pyf (from rev 4338, branches/refactor_fft/scipy/fftpack/convolve.pyf) Copied: branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf (from rev 4338, branches/refactor_fft/scipy/fftpack/fftpack.pyf) Copied: branches/refactor_fft/scipy/fftpack/fftpack/setup.py (from rev 4338, branches/refactor_fft/scipy/fftpack/setup.py) =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:31:58 UTC (rev 4338) +++ branches/refactor_fft/scipy/fftpack/fftpack/setup.py 2008-05-15 14:35:54 UTC (rev 4347) @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Created by Pearu Peterson, August 2002 + +from os.path import join + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('fftpack',parent_package, top_path) + + config.add_library('dfftpack', + sources=[join('DFFTPACK','*.f')]) + + sources = ['fftpack.pyf', 'src/zrfft.c'] + for s in ["zfft.cxx", "zfftnd.cxx", "drfft.cxx"]: + sources.append(join('src/fftpack', s)) + + # Build the python extensions + config.add_extension('_fftpack', + sources=sources, + libraries = ["dfftpack"], + include_dirs = ['src'], + ) + + config.add_extension('convolve', + sources = ['convolve.pyf', 'src/fftpack/convolve.cxx'], + libraries = ["dfftpack"], + include_dirs = ['src'], + ) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Thu May 15 12:05:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 11:05:33 -0500 (CDT) Subject: [Scipy-svn] r4348 - branches/refactor_fft/scipy/fftpack/fftpack Message-ID: <20080515160533.2030239C45E@scipy.org> Author: cdavid Date: 2008-05-15 11:05:29 -0500 (Thu, 15 May 2008) New Revision: 4348 Modified: branches/refactor_fft/scipy/fftpack/fftpack/__init__.py Log: fftpack backend now exposes both fft and convolve. Modified: branches/refactor_fft/scipy/fftpack/fftpack/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/__init__.py 2008-05-15 14:35:54 UTC (rev 4347) +++ branches/refactor_fft/scipy/fftpack/fftpack/__init__.py 2008-05-15 16:05:29 UTC (rev 4348) @@ -1,3 +1,9 @@ from _fftpack import zfft_fftpack as zfft, \ zfftnd_fftpack as zfftnd, \ - drfft_fftpack as drfft + drfft_fftpack as drfft, \ + zrfft_fftpack as zrfft + +from convolve import convolve_fftpack as convolve, \ + convolve_z_fftpack as convolve_z, \ + init_convolution_kernel_fftpack as init_convolution_kernel, \ + destroy_convolve_cache_fftpack as destroy_convolve_cache From scipy-svn at scipy.org Thu May 15 12:09:37 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 11:09:37 -0500 (CDT) Subject: [Scipy-svn] r4349 - in branches/refactor_fft/scipy/fftpack/backends: . fftw3 Message-ID: <20080515160937.8FDC939C137@scipy.org> Author: cdavid Date: 2008-05-15 11:09:30 -0500 (Thu, 15 May 2008) New Revision: 4349 Added: branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py Log: More work on setup scripts for fftpack backends. Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py (from rev 4338, branches/refactor_fft/scipy/fftpack/backends/setup.py) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:31:58 UTC (rev 4338) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py 2008-05-15 16:09:30 UTC (rev 4349) @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# Created by Pearu Peterson, August 2002 + +from os.path import join + +def build_backends(config): + from numpy.distutils.system_info import get_info + src = [join('src', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] + info = get_info("fftw3") + if info: + config.add_library("fftw3_backend", + sources = src, + include_dirs = ["../common", + info['include_dirs']]) + config.add_extension("_fftw3", sources = ["fftw3.pyf"], extra_info = info, libraries = ["fftw3_backend"]) + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('fftw3', parent_package, top_path) + build_backends(config) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 16:05:29 UTC (rev 4348) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 16:09:30 UTC (rev 4349) @@ -3,36 +3,11 @@ from os.path import join -def build_backends(config): - from numpy.distutils.system_info import get_info - # Build backends for fftpack and convolve - backends_src = {} - backends_src['djbfft'] = [join('djbfft/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']] - backends_src['fftw3'] = [join('fftw3/src', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - backends_src['fftw2'] = [join('fftw/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] - backends_src['fftpack'] = [join('fftpack/', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']] - backends_src['mkl'] = [join('mkl/', i) for i in - ['zfft.cxx', 'zfftnd.cxx']] - - backends = ['mkl', 'djbfft', 'fftw3', 'fftw2'] - for backend in backends: - info = get_info(backend) - if info: - config.add_library("%s_backend" % backend, - sources = backends_src[backend], - include_dirs = ["common", - info['include_dirs']]) - config.add_extension("_%s" % backend, sources = [join(backend, "%s.pyf" % backend)], extra_info = info, libraries = ["%s_backend" % backend]) - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('backends', parent_package, top_path) - build_backends(config) + + config.add_subpackage("fftw3") return config From scipy-svn at scipy.org Thu May 15 12:10:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 11:10:46 -0500 (CDT) Subject: [Scipy-svn] r4350 - branches/refactor_fft/scipy/fftpack Message-ID: <20080515161046.7D17739C543@scipy.org> Author: cdavid Date: 2008-05-15 11:10:42 -0500 (Thu, 15 May 2008) New Revision: 4350 Modified: branches/refactor_fft/scipy/fftpack/setup.py Log: Do not build any extension at the top level of fftpack. Modified: branches/refactor_fft/scipy/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 16:09:30 UTC (rev 4349) +++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 16:10:42 UTC (rev 4350) @@ -10,26 +10,8 @@ config.add_data_dir('tests') config.add_data_dir('benchmarks') - config.add_library('dfftpack', - sources=[join('dfftpack','*.f')]) + config.add_subpackage('fftpack') - sources = ['fftpack.pyf', 'src/zrfft.c'] - for s in ["zfft.cxx", "zfftnd.cxx", "drfft.cxx"]: - sources.append(join('src/fftpack', s)) - - # Build the python extensions - config.add_extension('_fftpack', - sources=sources, - libraries = ["dfftpack"], - include_dirs = ['src'], - ) - - config.add_extension('convolve', - sources = ['convolve.pyf', 'src/fftpack/convolve.cxx'], - libraries = ["dfftpack"], - include_dirs = ['src'], - ) - # Build optional backends config.add_subpackage('backends') From scipy-svn at scipy.org Thu May 15 12:11:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 11:11:33 -0500 (CDT) Subject: [Scipy-svn] r4351 - branches/refactor_fft/scipy/fftpack Message-ID: <20080515161133.03B8339C543@scipy.org> Author: cdavid Date: 2008-05-15 11:11:28 -0500 (Thu, 15 May 2008) New Revision: 4351 Removed: branches/refactor_fft/scipy/fftpack/convolve.pyf branches/refactor_fft/scipy/fftpack/dfftpack/ branches/refactor_fft/scipy/fftpack/fftpack.pyf branches/refactor_fft/scipy/fftpack/src/ Log: More moving around. Deleted: branches/refactor_fft/scipy/fftpack/convolve.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/convolve.pyf 2008-05-15 16:10:42 UTC (rev 4350) +++ branches/refactor_fft/scipy/fftpack/convolve.pyf 2008-05-15 16:11:28 UTC (rev 4351) @@ -1,47 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, September 2002 - -python module convolve__user__routines - interface - real*8 function kernel_func(k) - intent(c) kernel_func - integer intent(in,c) :: k - end function kernel_func - end interface -end python module convolve__user__routines - -python module convolve - interface - - subroutine init_convolution_kernel_fftpack (n,omega,d,kernel_func,zero_nyquist) - intent(c) init_convolution_kernel_fftpack - use convolve__user__routines - external kernel_func - integer intent(in,c),check(n>0) :: n - integer intent(in,c),optional :: d = 0 - real*8 intent(out,c),dimension(n),depend(n) :: omega - integer intent(in,c),optional,depend(d) :: zero_nyquist = d%2 - end subroutine init_convolution_kernel_fftpack - - subroutine destroy_convolve_cache_fftpack() - intent(c) destroy_convolve_cache_fftpack - end subroutine destroy_convolve_cache_fftpack - - subroutine convolve_fftpack(n,x,omega,swap_real_imag) - intent(c) convolve_fftpack - integer intent(c,hide),depend (x) :: n = len(x) - real*8 intent(c,in,out,copy,out=y),dimension(n):: x - real*8 intent(c,in,cache),dimension(n),depend(n) :: omega - integer intent(c,in),optional :: swap_real_imag = 0 - end subroutine convolve_fftpack - - subroutine convolve_z_fftpack(n,x,omega_real,omega_imag) - intent(c) convolve_z_fftpack - integer intent(c,hide),depend (x) :: n = len(x) - real*8 intent(c,in,out,copy,out=y),dimension(n):: x - real*8 intent(c,in,cache),dimension(n),depend(n) :: omega_real - real*8 intent(c,in,cache),dimension(n),depend(n) :: omega_imag - end subroutine convolve_z_fftpack - - end interface -end python module convolve Deleted: branches/refactor_fft/scipy/fftpack/fftpack.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-15 16:10:42 UTC (rev 4350) +++ branches/refactor_fft/scipy/fftpack/fftpack.pyf 2008-05-15 16:11:28 UTC (rev 4351) @@ -1,77 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 - -python module _fftpack - interface - - subroutine zfft_fftpack(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft_fftpack - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft_fftpack - - subroutine drfft_fftpack(x,n,direction,howmany,normalize) - ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft_fftpack - real*8 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine drfft_fftpack - - subroutine zrfft_fftpack(x,n,direction,howmany,normalize) - ! y = zrfft(x[,n,direction,normalize,overwrite_x]) - intent(c) zrfft_fftpack - complex*16 intent(c,in,out,overwrite,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zrfft_fftpack - - subroutine zfftnd_fftpack(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd_fftpack - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i Author: oliphant Date: 2008-05-15 11:36:59 -0500 (Thu, 15 May 2008) New Revision: 4352 Modified: trunk/scipy/stats/stats.py Log: Fix stats.var for complex variables. Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2008-05-15 16:11:28 UTC (rev 4351) +++ trunk/scipy/stats/stats.py 2008-05-15 16:36:59 UTC (rev 4352) @@ -1191,7 +1191,7 @@ mn = np.expand_dims(mean(a,axis),axis) deviations = a - mn n = a.shape[axis] - vals = ss(deviations,axis)/(n-1.0) + vals = sum(abs(deviations)**2,axis)/(n-1.0) if bias: return vals * (n-1.0)/n else: From scipy-svn at scipy.org Thu May 15 23:31:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 May 2008 22:31:56 -0500 (CDT) Subject: [Scipy-svn] r4353 - branches/refactor_fft/scipy/fftpack Message-ID: <20080516033156.3927A39C142@scipy.org> Author: cdavid Date: 2008-05-15 22:31:39 -0500 (Thu, 15 May 2008) New Revision: 4353 Added: branches/refactor_fft/scipy/fftpack/common.py Log: Add backend loader. Added: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-15 16:36:59 UTC (rev 4352) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 03:31:39 UTC (rev 4353) @@ -0,0 +1,31 @@ +import fftpack as _DEF_BACKEND + +_FUNCS_NAMES = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", + "convolve", "convolve_z", "destroy_convolve_cache"] +_FUNCS = dict([(name, None) for name in _FUNCS_NAMES]) +_FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) + +def myimport(name): + mod = __import__(name) + comps = name.split('.')[1:] + for c in comps: + mod = getattr(mod, c) + return mod + +def load_backend(name): + try: + mod = myimport(name) + for f in _FUNCS.keys(): + try: + _FUNCS[f] = mod.__dict__[f] + print "loading %s from %s" % (f, name) + except KeyError: + _FUNCS[f] = _DEF_BACKEND.__dict__[f] + print "loading %s from %s" % (f, "def backend") + except ImportError, e: + print "%s: failed loading backend %s" % (e, name) + for f in _FUNCS.keys(): + _FUNCS[f] = _DEF_BACKEND.__dict__[f] + +load_backend("fftpack.backends.fftw3") + From scipy-svn at scipy.org Fri May 16 01:09:40 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 00:09:40 -0500 (CDT) Subject: [Scipy-svn] r4354 - branches/refactor_fft/scipy/fftpack Message-ID: <20080516050940.4620939C56E@scipy.org> Author: cdavid Date: 2008-05-16 00:09:35 -0500 (Fri, 16 May 2008) New Revision: 4354 Modified: branches/refactor_fft/scipy/fftpack/basic.py branches/refactor_fft/scipy/fftpack/common.py branches/refactor_fft/scipy/fftpack/pseudo_diffs.py Log: Use backend loader as _fftpack replacement. Modified: branches/refactor_fft/scipy/fftpack/basic.py =================================================================== --- branches/refactor_fft/scipy/fftpack/basic.py 2008-05-16 03:31:39 UTC (rev 4353) +++ branches/refactor_fft/scipy/fftpack/basic.py 2008-05-16 05:09:35 UTC (rev 4354) @@ -10,7 +10,7 @@ from numpy import asarray, zeros, swapaxes, integer, array import numpy -import _fftpack as fftpack +import common as fftimpl def istype(arr, typeclass): return issubclass(arr.dtype.type, typeclass) @@ -79,12 +79,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfft_fftpack + work_function = fftimpl.zfft elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zrfft_fftpack + work_function = fftimpl.zrfft #return _raw_fft(tmp,n,axis,1,overwrite_x,work_function) if n is None: @@ -117,12 +117,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfft_fftpack + work_function = fftimpl.zfft elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zrfft_fftpack + work_function = fftimpl.zrfft #return _raw_fft(tmp,n,axis,-1,overwrite_x,work_function) if n is None: @@ -169,7 +169,7 @@ tmp = asarray(x) if not numpy.isrealobj(tmp): raise TypeError,"1st argument must be real sequence" - work_function = fftpack.drfft_fftpack + work_function = fftimpl.drfft return _raw_fft(tmp,n,axis,1,overwrite_x,work_function) @@ -213,7 +213,7 @@ tmp = asarray(x) if not numpy.isrealobj(tmp): raise TypeError,"1st argument must be real sequence" - work_function = fftpack.drfft_fftpack + work_function = fftimpl.drfft return _raw_fft(tmp,n,axis,-1,overwrite_x,work_function) @@ -285,12 +285,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfftnd_fftpack + work_function = fftimpl.zfftnd elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zfftnd_fftpack + work_function = fftimpl.zfftnd return _raw_fftnd(tmp,shape,axes,1,overwrite_x,work_function) @@ -313,12 +313,12 @@ if istype(tmp, numpy.complex128): overwrite_x = overwrite_x or (tmp is not x and not \ hasattr(x,'__array__')) - work_function = fftpack.zfftnd_fftpack + work_function = fftimpl.zfftnd elif istype(tmp, numpy.complex64): raise NotImplementedError else: overwrite_x = 1 - work_function = fftpack.zfftnd_fftpack + work_function = fftimpl.zfftnd return _raw_fftnd(tmp,shape,axes,-1,overwrite_x,work_function) Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 03:31:39 UTC (rev 4353) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:09:35 UTC (rev 4354) @@ -1,8 +1,9 @@ import fftpack as _DEF_BACKEND -_FUNCS_NAMES = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", - "convolve", "convolve_z", "destroy_convolve_cache"] -_FUNCS = dict([(name, None) for name in _FUNCS_NAMES]) +__all__ = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", + "convolve", "convolve_z", "destroy_convolve_cache"] + +_FUNCS = dict([(name, None) for name in __all__]) _FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) def myimport(name): @@ -17,7 +18,7 @@ mod = myimport(name) for f in _FUNCS.keys(): try: - _FUNCS[f] = mod.__dict__[f] + _FUNCS[f] = mod.__dict__[f] print "loading %s from %s" % (f, name) except KeyError: _FUNCS[f] = _DEF_BACKEND.__dict__[f] @@ -29,3 +30,11 @@ load_backend("fftpack.backends.fftw3") +zfft = _FUNCS["zfft"] +drfft = _FUNCS["drfft"] +zfftnd = _FUNCS["zfftnd"] +zrfft = _FUNCS["zrfft"] +init_convolution_kernel = _FUNCS["init_convolution_kernel"] +convolve = _FUNCS["convolve"] +convolve_z = _FUNCS["convolve_z"] +destroy_convolve_cache = _FUNCS["destroy_convolve_cache"] Modified: branches/refactor_fft/scipy/fftpack/pseudo_diffs.py =================================================================== --- branches/refactor_fft/scipy/fftpack/pseudo_diffs.py 2008-05-16 03:31:39 UTC (rev 4353) +++ branches/refactor_fft/scipy/fftpack/pseudo_diffs.py 2008-05-16 05:09:35 UTC (rev 4354) @@ -9,10 +9,10 @@ 'shift'] from numpy import pi, asarray, sin, cos, sinh, cosh, tanh, iscomplexobj -import convolve +import common as fftimpl import atexit -atexit.register(convolve.destroy_convolve_cache_fftpack) +atexit.register(fftimpl.destroy_convolve_cache) del atexit @@ -60,11 +60,11 @@ if k: return pow(c*k,order) return 0 - omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=order, + omega = fftimpl.init_convolution_kernel(n,kernel,d=order, zero_nyquist=1) _cache[(n,order,c)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,swap_real_imag=order%2, + return fftimpl.convolve(tmp,omega,swap_real_imag=order%2, overwrite_x=overwrite_x) del _cache @@ -110,10 +110,10 @@ def kernel(k,h=h): if k: return 1.0/tanh(h*k) return 0 - omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) + omega = fftimpl.init_convolution_kernel(n,kernel,d=1) _cache[(n,h)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -146,10 +146,10 @@ def kernel(k,h=h): if k: return -tanh(h*k) return 0 - omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) + omega = fftimpl.init_convolution_kernel(n,kernel,d=1) _cache[(n,h)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -183,10 +183,10 @@ if k>0: return 1.0 elif k<0: return -1.0 return 0.0 - omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) + omega = fftimpl.init_convolution_kernel(n,kernel,d=1) _cache[n] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -242,10 +242,10 @@ def kernel(k,a=a,b=b): if k: return -cosh(a*k)/sinh(b*k) return 0 - omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) + omega = fftimpl.init_convolution_kernel(n,kernel,d=1) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -288,10 +288,10 @@ def kernel(k,a=a,b=b): if k: return sinh(a*k)/cosh(b*k) return 0 - omega = convolve.init_convolution_kernel_fftpack(n,kernel,d=1) + omega = fftimpl.init_convolution_kernel(n,kernel,d=1) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x) del _cache @@ -333,10 +333,10 @@ def kernel(k,a=a,b=b): if k: return sinh(a*k)/sinh(b*k) return float(a)/b - omega = convolve.init_convolution_kernel_fftpack(n,kernel) + omega = fftimpl.init_convolution_kernel(n,kernel) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,overwrite_x=overwrite_x) del _cache @@ -378,10 +378,10 @@ while _cache: _cache.popitem() def kernel(k,a=a,b=b): return cosh(a*k)/cosh(b*k) - omega = convolve.init_convolution_kernel_fftpack(n,kernel) + omega = fftimpl.init_convolution_kernel(n,kernel) _cache[(n,a,b)] = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_fftpack(tmp,omega,overwrite_x=overwrite_x) + return fftimpl.convolve(tmp,omega,overwrite_x=overwrite_x) del _cache _cache = {} @@ -412,15 +412,15 @@ while _cache: _cache.popitem() def kernel_real(k,a=a): return cos(a*k) def kernel_imag(k,a=a): return sin(a*k) - omega_real = convolve.init_convolution_kernel_fftpack(n,kernel_real,d=0, + omega_real = fftimpl.init_convolution_kernel(n,kernel_real,d=0, zero_nyquist=0) - omega_imag = convolve.init_convolution_kernel_fftpack(n,kernel_imag,d=1, + omega_imag = fftimpl.init_convolution_kernel(n,kernel_imag,d=1, zero_nyquist=0) _cache[(n,a)] = omega_real,omega_imag else: omega_real,omega_imag = omega overwrite_x = tmp is not x and not hasattr(x,'__array__') - return convolve.convolve_z_fftpack(tmp,omega_real,omega_imag, + return fftimpl.convolve_z(tmp,omega_real,omega_imag, overwrite_x=overwrite_x) del _cache From scipy-svn at scipy.org Fri May 16 01:11:34 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 00:11:34 -0500 (CDT) Subject: [Scipy-svn] r4355 - in branches/refactor_fft/scipy/fftpack/backends: . common djbfft fftw fftw3 fftw3/src mkl Message-ID: <20080516051134.60D6539C56E@scipy.org> Author: cdavid Date: 2008-05-16 00:11:26 -0500 (Fri, 16 May 2008) New Revision: 4355 Modified: branches/refactor_fft/scipy/fftpack/backends/ branches/refactor_fft/scipy/fftpack/backends/common/ branches/refactor_fft/scipy/fftpack/backends/djbfft/ branches/refactor_fft/scipy/fftpack/backends/fftw/ branches/refactor_fft/scipy/fftpack/backends/fftw3/ branches/refactor_fft/scipy/fftpack/backends/fftw3/src/ branches/refactor_fft/scipy/fftpack/backends/mkl/ Log: Ignore the usual junk in svn for backends subdir. Property changes on: branches/refactor_fft/scipy/fftpack/backends ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Property changes on: branches/refactor_fft/scipy/fftpack/backends/common ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Property changes on: branches/refactor_fft/scipy/fftpack/backends/djbfft ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Property changes on: branches/refactor_fft/scipy/fftpack/backends/fftw ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Property changes on: branches/refactor_fft/scipy/fftpack/backends/fftw3 ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Property changes on: branches/refactor_fft/scipy/fftpack/backends/fftw3/src ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Property changes on: branches/refactor_fft/scipy/fftpack/backends/mkl ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so From scipy-svn at scipy.org Fri May 16 01:47:37 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 00:47:37 -0500 (CDT) Subject: [Scipy-svn] r4356 - in branches/refactor_fft/scipy/fftpack: . backends backends/fftw3 Message-ID: <20080516054737.E8D8A39C74F@scipy.org> Author: cdavid Date: 2008-05-16 00:47:30 -0500 (Fri, 16 May 2008) New Revision: 4356 Added: branches/refactor_fft/scipy/fftpack/backends/__init__.py branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py Modified: branches/refactor_fft/scipy/fftpack/common.py Log: fftw3 backend can now be loaded. Added: branches/refactor_fft/scipy/fftpack/backends/__init__.py =================================================================== Added: branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py 2008-05-16 05:11:26 UTC (rev 4355) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py 2008-05-16 05:47:30 UTC (rev 4356) @@ -0,0 +1,3 @@ +from _fftw3 import zfft_fftw3 as zfft, \ + drfft_fftw3 as drfft, \ + zfftnd_fftw3 as zfftnd Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:11:26 UTC (rev 4355) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:47:30 UTC (rev 4356) @@ -1,5 +1,7 @@ import fftpack as _DEF_BACKEND +# XXX: this will break for many configurations, e.g. loading +# init_convolution_kernel of one backend, and convolve from another one... __all__ = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] @@ -7,15 +9,16 @@ _FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) def myimport(name): - mod = __import__(name) - comps = name.split('.')[1:] - for c in comps: - mod = getattr(mod, c) - return mod + """Load a fft backend from its name. + + Name should be fftw3, etc...""" + mod = __import__("scipy.fftpack.backends", fromlist = [name]) + return mod.__dict__[name] def load_backend(name): try: mod = myimport(name) + print mod for f in _FUNCS.keys(): try: _FUNCS[f] = mod.__dict__[f] @@ -28,7 +31,7 @@ for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] -load_backend("fftpack.backends.fftw3") +load_backend("fftw3") zfft = _FUNCS["zfft"] drfft = _FUNCS["drfft"] From scipy-svn at scipy.org Fri May 16 01:54:16 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 00:54:16 -0500 (CDT) Subject: [Scipy-svn] r4357 - branches/refactor_fft/scipy/fftpack Message-ID: <20080516055416.167D039C74F@scipy.org> Author: cdavid Date: 2008-05-16 00:54:13 -0500 (Fri, 16 May 2008) New Revision: 4357 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Split convolve/fft backends loading. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:47:30 UTC (rev 4356) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:54:13 UTC (rev 4357) @@ -5,6 +5,10 @@ __all__ = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] +_FFT_FUNCNAME = ["zfft", "drfft", "zfftnd", "zrfft"] +_CONVOLVE_FUNCNAME = ["init_convolution_kernel", + "convolve", "convolve_z", "destroy_convolve_cache"] + _FUNCS = dict([(name, None) for name in __all__]) _FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) @@ -18,15 +22,27 @@ def load_backend(name): try: mod = myimport(name) - print mod - for f in _FUNCS.keys(): + # Loading fft functions: each of them can be loaded independently + for f in _FFT_FUNCNAME: try: _FUNCS[f] = mod.__dict__[f] print "loading %s from %s" % (f, name) except KeyError: _FUNCS[f] = _DEF_BACKEND.__dict__[f] print "loading %s from %s" % (f, "def backend") + + # Loading convolve: we try to load all of them: if any failure, we use + # fallback for all of them + try: + for f in _CONVOLVE_FUNCNAME: + _FUNCS[f] = mod.__dict__[f] + print "loading %s from %s" % (f, name) + except KeyError: + for f in _CONVOLVE_FUNCNAME: + _FUNCS[f] = _DEF_BACKEND.__dict__[f] + print "loading %s from %s" % (f, "def backend") except ImportError, e: + # If cannot load backend, just use default backend (fftpack) print "%s: failed loading backend %s" % (e, name) for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] From scipy-svn at scipy.org Fri May 16 01:59:00 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 00:59:00 -0500 (CDT) Subject: [Scipy-svn] r4358 - branches/refactor_fft/scipy/fftpack Message-ID: <20080516055900.B063739C673@scipy.org> Author: cdavid Date: 2008-05-16 00:58:56 -0500 (Fri, 16 May 2008) New Revision: 4358 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: A bit more explanation of the magic in backend loading. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:54:13 UTC (rev 4357) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 05:58:56 UTC (rev 4358) @@ -1,7 +1,14 @@ +"""This module takes care of exposing the fft implementation from available +backends. + +The exposed implementation consists solely in the __all__ items. + +The functions are set up in load_backend function, which initialize the +dictionary _FUNCS with working functions. If a backend does not implement one +of the function, a fallback is automatically used.""" +# Default backend: fftpack. import fftpack as _DEF_BACKEND -# XXX: this will break for many configurations, e.g. loading -# init_convolution_kernel of one backend, and convolve from another one... __all__ = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] @@ -9,7 +16,9 @@ _CONVOLVE_FUNCNAME = ["init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] +# Dictionary of (name, callable) _FUNCS = dict([(name, None) for name in __all__]) + _FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) def myimport(name): From scipy-svn at scipy.org Fri May 16 02:03:03 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:03:03 -0500 (CDT) Subject: [Scipy-svn] r4359 - in branches/refactor_fft/scipy/fftpack/backends/fftw: . src Message-ID: <20080516060303.1A99C39C673@scipy.org> Author: cdavid Date: 2008-05-16 01:02:54 -0500 (Fri, 16 May 2008) New Revision: 4359 Added: branches/refactor_fft/scipy/fftpack/backends/fftw/src/ branches/refactor_fft/scipy/fftpack/backends/fftw/src/api.h branches/refactor_fft/scipy/fftpack/backends/fftw/src/common.h branches/refactor_fft/scipy/fftpack/backends/fftw/src/convolve.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/src/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/src/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/src/zfftnd.cxx Log: Move fftw src one dir deeper. Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/src/api.h (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/fftw/api.h) Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/src/common.h (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/fftw/common.h) Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/src/convolve.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx) Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/src/drfft.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/fftw/drfft.cxx) Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/src/zfft.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/fftw/zfft.cxx) Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/src/zfftnd.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx) From scipy-svn at scipy.org Fri May 16 02:03:51 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:03:51 -0500 (CDT) Subject: [Scipy-svn] r4360 - branches/refactor_fft/scipy/fftpack/backends/fftw Message-ID: <20080516060351.5A53139C779@scipy.org> Author: cdavid Date: 2008-05-16 01:03:43 -0500 (Fri, 16 May 2008) New Revision: 4360 Added: branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf branches/refactor_fft/scipy/fftpack/backends/fftw/setup.py Removed: branches/refactor_fft/scipy/fftpack/backends/fftw/api.h branches/refactor_fft/scipy/fftpack/backends/fftw/common.h branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/drfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx Log: fftw backend now builds Added: branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py 2008-05-16 06:02:54 UTC (rev 4359) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py 2008-05-16 06:03:43 UTC (rev 4360) @@ -0,0 +1,3 @@ +from _fftw import zfft_fftw as zfft, \ + drfft_fftw as drfft, \ + zfftnd_fftw as zfftnd Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/api.h 2008-05-16 06:02:54 UTC (rev 4359) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/api.h 2008-05-16 06:03:43 UTC (rev 4360) @@ -1,30 +0,0 @@ -#ifndef _SCIPY_FFTPACK_FFTW_API_H_ -#define _SCIPY_FFTPACK_FFTW_API_H_ - -#include "misc.h" - -/* - * straight FFT api - */ -void drfft_fftw(double * inout, int n, int direction, int howmany, - int normalize); - -void zfft_fftw(complex_double * inout, - int n, int direction, int howmany, int normalize); - -void zfftnd_fftw(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize); - -/* - * Convolution api - */ -void convolve_fftw(int n, double *inout, double *omega, int swap_real_imag); -void convolve_z_fftw(int n, double *inout, double *omega_real, - double* omega_imag); - -void init_convolution_kernel_fftw(int n, double *omega, int d, - double (*kernel_func) (int), - int zero_nyquist); - -#endif Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw/common.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/common.h 2008-05-16 06:02:54 UTC (rev 4359) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/common.h 2008-05-16 06:03:43 UTC (rev 4360) @@ -1,31 +0,0 @@ -#ifndef _SCIPY_FFTW_COMMON_H -#define _SCIPY_FFTW_COMMON_H - -#define COPYRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) { \ - *(DEST+2*n2-1) = *(SRC+n2); \ - if ((N)%2) \ - *(DEST+2*n2) = *(SRC+(N)-n2); \ - } \ -} -#define COPYINVRFFTW2STD(SRC,DEST,N) { \ - int j,n2=(N)/2; \ - *(DEST) = *(SRC); \ - for (j=1;j1) {\ - *(DEST+n2) = *(SRC+2*n2-1); \ - if ((N)%2) \ - *(DEST+(N)-n2) = *(SRC+2*n2); \ - } \ -} - -#endif Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx 2008-05-16 06:02:54 UTC (rev 4359) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/convolve.cxx 2008-05-16 06:03:43 UTC (rev 4360) @@ -1,183 +0,0 @@ -#include - -#include -#include - -#include "api.h" - -#include "cycliccache.h" - -using namespace fft; - -class DRFFTWCacheId : public CacheId { - public: - DRFFTWCacheId(int n); - -}; - -DRFFTWCacheId::DRFFTWCacheId(int n): - CacheId(n) -{ -} - -class DRFFTWCache : public Cache { - public: - DRFFTWCache(const DRFFTWCacheId& id); - virtual ~DRFFTWCache(); - - int convolve(double* inout, double* omega, - int swap_real_imag) const; - int convolve_z(double* inout, double* omega_real, - double* omega_imag) const; - - protected: - rfftw_plan m_plan1; - rfftw_plan m_plan2; -}; - -DRFFTWCache::DRFFTWCache(const DRFFTWCacheId& id) -: Cache(id) -{ - int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; - - m_plan1 = rfftw_create_plan(id.m_n, FFTW_REAL_TO_COMPLEX, flags); - if (m_plan1 == NULL) { - goto fail; - } - - m_plan2 = rfftw_create_plan(id.m_n, FFTW_COMPLEX_TO_REAL, flags); - if (m_plan2 == NULL) { - goto clean_plan1; - } - - return; - -clean_plan1: - rfftw_destroy_plan(m_plan1); -fail: - throw std::bad_alloc(); -} - -DRFFTWCache::~DRFFTWCache() -{ - rfftw_destroy_plan(m_plan2); - rfftw_destroy_plan(m_plan1); -} - -int DRFFTWCache::convolve(double* inout, double* omega, int swap_real_imag) - const -{ - int n = m_id.m_n; - int l = (n-1)/2+1; - int i; - double c; - - rfftw_one(m_plan1, (fftw_real *)inout, NULL); - if (swap_real_imag) { - inout[0] *= omega[0]; - if (!(n%2)) { - inout[n/2] *= omega[n/2]; - } - for(i=1;i drfftw_cmgr(20); - -/**************** convolve **********************/ -void convolve_fftw(int n,double* inout,double* omega,int swap_real_imag) -{ - DRFFTWCache *cache; - - cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); - cache->convolve(inout, omega, swap_real_imag); -} - -/**************** convolve **********************/ -void convolve_z_fftw(int n,double* inout,double* omega_real,double* omega_imag) -{ - DRFFTWCache *cache; - - cache = drfftw_cmgr.get_cache(DRFFTWCacheId(n)); - cache->convolve_z(inout, omega_real, omega_imag); -} - -void init_convolution_kernel_fftw(int n,double* omega, int d, - double (*kernel_func)(int), - int zero_nyquist) -{ - /* - * omega[k] = pow(sqrt(-1),d) * kernel_func(k) - * omega[0] = kernel_func(0) - * conjugate(omega[-k]) == omega[k] - */ - int k,l=(n-1)/2+1; - omega[0] = (*kernel_func)(0)/n;; - switch (d%4) { - case 0: - for (k=1;k - -#include -#include - -#include "cycliccache.h" -#include "api.h" -#include "common.h" - -using namespace fft; - -class RFFTWCacheId : public CacheId { - public: - RFFTWCacheId(int n, int dir, int flags); - - virtual bool operator==(const RFFTWCacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const RFFTWCacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && - m_flags == other.m_flags && - th->is_equal(*ot); - } - - public: - int m_dir; - int m_flags; -}; - -RFFTWCacheId::RFFTWCacheId(int n, int dir, int flags): - CacheId(n), - m_dir(dir), - m_flags(flags) -{ -} - -class RFFTWCache : public Cache { - public: - RFFTWCache(const RFFTWCacheId& id); - virtual ~RFFTWCache(); - - int compute(double* inout) const; - - protected: - rfftw_plan m_plan; - double *m_wrk; -}; - -RFFTWCache::RFFTWCache(const RFFTWCacheId& id) -: Cache(id) -{ - m_wrk = (double *) malloc(sizeof(double) * id.m_n); - if(m_wrk == NULL) { - goto fail; - } - - m_plan = rfftw_create_plan(id.m_n, - (id.m_dir > 0 ? FFTW_REAL_TO_COMPLEX : - FFTW_COMPLEX_TO_REAL), - id.m_flags); - - if (m_plan == NULL) { - goto clean_wrk; - } - - return; - -clean_wrk: - free(m_wrk); -fail: - throw std::bad_alloc(); -} - -RFFTWCache::~RFFTWCache() -{ - free(m_wrk); - rfftw_destroy_plan(m_plan); -} - -int RFFTWCache::compute(double* inout) const -{ - if(m_id.m_dir == 1) { - memcpy(m_wrk, inout, sizeof(double) * m_id.m_n); - rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); - COPYRFFTW2STD(m_wrk, inout, m_id.m_n); - } else { - COPYINVRFFTW2STD(inout, m_wrk, m_id.m_n); - rfftw(m_plan, 1, (fftw_real *) m_wrk, 1, 1, NULL, 1, 1); - memcpy(inout, m_wrk, sizeof(double) * m_id.m_n); - } - return 0; -}; - -CacheManager rfftw_cmgr(10); - -void drfft_fftw(double *inout, int n, int dir, - int howmany, int normalize) -{ - int i; - double *ptr = inout; - RFFTWCache *cache; - - cache = rfftw_cmgr.get_cache( - RFFTWCacheId(n, dir, FFTW_IN_PLACE | FFTW_ESTIMATE)); - - if (dir != -1 && dir != 1) { - fprintf(stderr, "drfft: invalid dir=%d\n", dir); - return; - } else { - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute(ptr); - } - } - - if (normalize) { - double d = 1.0 / n; - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - (*(ptr++)) *= d; - } - } -} Added: branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf 2008-05-16 06:02:54 UTC (rev 4359) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf 2008-05-16 06:03:43 UTC (rev 4360) @@ -0,0 +1,77 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _fftw + interface + + subroutine zfft_fftw(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_fftw + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_fftw + + subroutine drfft_fftw(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft_fftw + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft_fftw + +! subroutine zrfft_fftw(x,n,direction,howmany,normalize) +! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) zrfft_fftw +! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine zrfft_fftw + + subroutine zfftnd_fftw(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_fftw + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i - -#include -#include - -#include "cycliccache.h" -#include "api.h" - -using namespace fft; - -class FFTWCacheId : public CacheId { - public: - FFTWCacheId(int n, int dir) : CacheId(n), m_dir(dir) {}; - - virtual bool operator==(const FFTWCacheId& other) const - { - return is_equal(other); - } - - virtual bool is_equal(const FFTWCacheId& other) const - { - const CacheId *ot = &other; - const CacheId *th = this; - - return m_dir == other.m_dir && th->is_equal(*ot); - } - - public: - int m_dir; -}; - -class FFTWCache : public Cache { - public: - FFTWCache(const FFTWCacheId& id); - virtual ~FFTWCache(); - - int compute(fftw_complex* inout) - { - fftw_one(m_plan, inout, NULL); - return 0; - }; - - protected: - fftw_plan m_plan; -}; - -FFTWCache::FFTWCache(const FFTWCacheId& id) -: Cache(id) -{ - m_plan = fftw_create_plan(id.m_n, - (id.m_dir > 0 ? FFTW_FORWARD:FFTW_BACKWARD), - FFTW_ESTIMATE | FFTW_IN_PLACE); - - if (m_plan == NULL) { - goto fail; - } - - return ; - -fail: - throw std::bad_alloc(); -} - -FFTWCache::~FFTWCache() -{ - fftw_destroy_plan(m_plan); -} - -CacheManager fftw_cmgr(10); - -void zfft_fftw(complex_double * inout, int n, - int dir, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - FFTWCache* cache; - - cache = fftw_cmgr.get_cache(FFTWCacheId(n, dir)); - - if (dir != -1 && dir != 1) { - fprintf(stderr, "zfft: invalid dir=%d\n", dir); - } else { - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute((fftw_complex *) ptr); - } - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx 2008-05-16 06:02:54 UTC (rev 4359) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/zfftnd.cxx 2008-05-16 06:03:43 UTC (rev 4360) @@ -1,192 +0,0 @@ -/* - * fftw2 backend for multi dimensional fft - * - * Original code by Pearu Peaterson - * - * Last Change: Tue May 13 02:00 PM 2008 J - */ -#include -#include - -#include -#include - -#include -#include "api.h" - -using namespace fft; - -static int equal_dims(int rank,int *dims1,int *dims2) -{ - int i; - for (i = 0; i < rank; ++i) { - if (dims1[i] != dims2[i]) { - return 0; - } - } - return 1; -} - -class NDFFTWCacheId { - public: - NDFFTWCacheId(int rank, int *dims, int dir, int flags); - virtual ~NDFFTWCacheId(); - - NDFFTWCacheId(const NDFFTWCacheId &); - - virtual bool operator==(const NDFFTWCacheId & other) const { - return is_equal(other); - }; - - virtual bool is_equal(const NDFFTWCacheId & other) const; - - public: - int m_dir; - int m_rank; - int *m_dims; - int m_flags; - - private: - int init(int rank, int *dims); -}; - -int NDFFTWCacheId::init(int rank, int *dims) -{ - m_dims = (int *) malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); - - return 0; - -} - -NDFFTWCacheId::NDFFTWCacheId(int rank, int *dims, int dir, int flags) : - m_dir(dir), - m_rank(rank), - m_flags(flags) -{ - if (init(rank, dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTWCacheId::NDFFTWCacheId(const NDFFTWCacheId & copy) : - m_dir(copy.m_dir), - m_rank(copy.m_rank), - m_flags(copy.m_flags) -{ - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDFFTWCacheId::~NDFFTWCacheId() -{ - free(m_dims); -} - -bool NDFFTWCacheId::is_equal(const NDFFTWCacheId & other) const -{ - bool res; - - res = (other.m_dir == m_dir); - res = res && (other.m_flags == m_flags); - - if (m_rank == other.m_rank) { - res = res && equal_dims(m_rank, m_dims, other.m_dims); - } else { - return false; - } - - return res; -} - -class NDFFTWCache : public Cache < NDFFTWCacheId > { - public: - NDFFTWCache(const NDFFTWCacheId & id); - virtual ~ NDFFTWCache(); - - int compute(fftw_complex * inout) const - { - fftwnd_one(m_plan, inout, NULL); - return 0; - }; - - protected: - fftwnd_plan m_plan; -}; - -NDFFTWCache::NDFFTWCache(const NDFFTWCacheId & id) -: Cache < NDFFTWCacheId > (id) -{ - int flags = FFTW_ESTIMATE | FFTW_IN_PLACE; -#if 0 - int sz; - int i; - - sz = 1; - for (i = 0; i < m_id.m_rank; ++i) { - sz *= m_id.m_dims[i]; - } -#endif - - m_plan = fftwnd_create_plan(m_id.m_rank, - m_id.m_dims, - (id.m_dir > 0 ? - FFTW_FORWARD : FFTW_BACKWARD), - flags); - - if (m_plan == NULL) { - goto fail; - } - - return; - -fail: - throw std::bad_alloc(); -} - -NDFFTWCache::~NDFFTWCache() -{ - fftwnd_destroy_plan(m_plan); -} - -static CacheManager < NDFFTWCacheId, NDFFTWCache > fftwnd_cmgr(10); - -void zfftnd_fftw(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - NDFFTWCache *cache; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - cache = fftwnd_cmgr.get_cache( - NDFFTWCacheId(rank, dims, direction, - FFTW_IN_PLACE | FFTW_ESTIMATE)); - - for (i = 0; i < howmany; ++i, ptr += sz) { - cache->compute((fftw_complex*)ptr); - } - - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} From scipy-svn at scipy.org Fri May 16 02:13:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:13:36 -0500 (CDT) Subject: [Scipy-svn] r4361 - branches/refactor_fft/scipy/fftpack/backends/fftw/src Message-ID: <20080516061336.D393F39C21C@scipy.org> Author: cdavid Date: 2008-05-16 01:13:33 -0500 (Fri, 16 May 2008) New Revision: 4361 Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/src/api.h Log: Set C linkage for api of fftw backend (f2py). Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/src/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/src/api.h 2008-05-16 06:03:43 UTC (rev 4360) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/src/api.h 2008-05-16 06:13:33 UTC (rev 4361) @@ -3,6 +3,7 @@ #include "misc.h" +extern "C" { /* * straight FFT api */ @@ -26,5 +27,6 @@ void init_convolution_kernel_fftw(int n, double *omega, int d, double (*kernel_func) (int), int zero_nyquist); +}; #endif From scipy-svn at scipy.org Fri May 16 02:13:49 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:13:49 -0500 (CDT) Subject: [Scipy-svn] r4362 - branches/refactor_fft/scipy/fftpack/backends Message-ID: <20080516061349.44A8039C21C@scipy.org> Author: cdavid Date: 2008-05-16 01:13:45 -0500 (Fri, 16 May 2008) New Revision: 4362 Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py Log: Build fftw backend. Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-16 06:13:33 UTC (rev 4361) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-16 06:13:45 UTC (rev 4362) @@ -8,6 +8,7 @@ config = Configuration('backends', parent_package, top_path) config.add_subpackage("fftw3") + config.add_subpackage("fftw") return config From scipy-svn at scipy.org Fri May 16 02:16:27 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:16:27 -0500 (CDT) Subject: [Scipy-svn] r4363 - branches/refactor_fft/scipy/fftpack Message-ID: <20080516061627.9F6D139C21C@scipy.org> Author: cdavid Date: 2008-05-16 01:16:23 -0500 (Fri, 16 May 2008) New Revision: 4363 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Be more robust when no backend is found. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 06:13:45 UTC (rev 4362) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 06:16:23 UTC (rev 4363) @@ -26,7 +26,10 @@ Name should be fftw3, etc...""" mod = __import__("scipy.fftpack.backends", fromlist = [name]) - return mod.__dict__[name] + try: + ret = mod.__dict__[name] + except KeyError, e: + raise ImportError(e) def load_backend(name): try: From scipy-svn at scipy.org Fri May 16 02:17:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:17:32 -0500 (CDT) Subject: [Scipy-svn] r4364 - in branches/refactor_fft/scipy/fftpack/backends/mkl: . src Message-ID: <20080516061732.90D5739C21C@scipy.org> Author: cdavid Date: 2008-05-16 01:17:24 -0500 (Fri, 16 May 2008) New Revision: 4364 Added: branches/refactor_fft/scipy/fftpack/backends/mkl/src/ branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfftnd.cxx Removed: branches/refactor_fft/scipy/fftpack/backends/mkl/api.h branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx Log: Move mkl backend sources one dir deeper. Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-16 06:16:23 UTC (rev 4363) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-16 06:17:24 UTC (rev 4364) @@ -1,16 +0,0 @@ -#ifndef _SCIPY_FFTPACK_MKL_API_H_ -#define _SCIPY_FFTPACK_MKL_API_H_ - -#include "misc.h" - -/* - * straight FFT api - */ -void zfft_mkl(complex_double * inout, - int n, int direction, int howmany, int normalize); - -void zfftnd_mkl(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize); - -#endif Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/mkl/api.h) Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfft.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx) Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfftnd.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx) Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx 2008-05-16 06:16:23 UTC (rev 4363) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx 2008-05-16 06:17:24 UTC (rev 4364) @@ -1,92 +0,0 @@ -#include - -#include - -#include "api.h" -#include "cycliccache.h" - -using namespace fft; - -class MKLCacheId : public CacheId { - public: - MKLCacheId(int n) : CacheId(n) {}; -}; - - -class MKLCache: public Cache { - public: - MKLCache(const MKLCacheId& id); - virtual ~MKLCache(); - - int compute_forward(complex_double * inout) const; - int compute_backward(complex_double * inout) const; - - protected: - DFTI_DESCRIPTOR_HANDLE m_hdl; -}; - -MKLCache::MKLCache(const MKLCacheId& id) -: Cache(id) -{ - int n = id.m_n; - - DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n); - DftiCommitDescriptor(m_hdl); - - return; -} - -MKLCache::~MKLCache() -{ - DftiFreeDescriptor(&m_hdl); -} - -int MKLCache::compute_forward(complex_double *inout) const -{ - DftiComputeForward(m_hdl, (double *) inout); - return 0; -} - -int MKLCache::compute_backward(complex_double *inout) const -{ - DftiComputeBackward(m_hdl, (double *) inout); - return 0; -} - -CacheManager zmkl_cmgr(10); - -void zfft_mkl(complex_double * inout, - int n, int direction, int howmany, int normalize) -{ - int i; - complex_double *ptr = inout; - MKLCache *cache; - - cache = zmkl_cmgr.get_cache(MKLCacheId(n)); - - switch (direction) { - - case 1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_forward(ptr); - } - break; - - case -1: - for (i = 0; i < howmany; ++i, ptr += n) { - cache->compute_backward(ptr); - } - break; - - default: - fprintf(stderr, "zfft: invalid direction=%d\n", direction); - } - - if (normalize) { - ptr = inout; - for (i = n * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= n; - *((double *) (ptr++) + 1) /= n; - } - } -} Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx 2008-05-16 06:16:23 UTC (rev 4363) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx 2008-05-16 06:17:24 UTC (rev 4364) @@ -1,211 +0,0 @@ -/* - * MKL backend for multi dimensional fft - * - * Original code by David M. Cooke - * - * Last Change: Tue May 13 05:00 PM 2008 J - */ -#include - -#include - -#include "api.h" -#include "cycliccache.h" - -using namespace fft; - -static int equal_dims(int rank,int *dims1,int *dims2) -{ - int i; - for (i = 0; i < rank; ++i) { - if (dims1[i] != dims2[i]) { - return 0; - } - } - return 1; -} - -class NDMKLCacheId { - public: - NDMKLCacheId(int rank, int *dim); - virtual ~NDMKLCacheId(); - - NDMKLCacheId(const NDMKLCacheId &); - - virtual bool operator==(const NDMKLCacheId & other) const { - return is_equal(other); - }; - - virtual bool is_equal(const NDMKLCacheId & other) const; - - public: - int m_rank; - int *m_dims; - - private: - int init(int rank, int *dims); -}; - -int NDMKLCacheId::init(int rank, int *dims) -{ - m_dims = (int *) malloc(sizeof(int) * rank); - if (m_dims == NULL) { - return -1; - } - memcpy(m_dims, dims, rank * sizeof(*m_dims)); - - return 0; - -} - -NDMKLCacheId::NDMKLCacheId(int rank, int *dims) : - m_rank(rank) -{ - if (init(rank, dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDMKLCacheId::NDMKLCacheId(const NDMKLCacheId & copy) : - m_rank(copy.m_rank) -{ - if (init(copy.m_rank, copy.m_dims)) { - goto fail; - } - -fail: - std::bad_alloc(); -} - -NDMKLCacheId::~NDMKLCacheId() -{ - free(m_dims); -} - -bool NDMKLCacheId::is_equal(const NDMKLCacheId & other) const -{ - bool res; - - if (m_rank == other.m_rank) { - res = equal_dims(m_rank, m_dims, other.m_dims); - } else { - return false; - } - - return res; -} - -/* - * Cache class for nd-MKL - */ -class NDMKLCache:public Cache < NDMKLCacheId > { - public: - NDMKLCache(const NDMKLCacheId & id); - virtual ~ NDMKLCache(); - - int compute_forward(double * inout) const - { - DftiComputeForward(m_hdl, inout); - return 0; - }; - - int compute_backward(double * inout) const - { - DftiComputeBackward(m_hdl, inout); - return 0; - }; - - protected: - int m_rank; - int *m_dims; - long *m_ndims; - DFTI_DESCRIPTOR_HANDLE m_hdl; - - private: - long *convert_dims(int n, int *dims) const; - -}; - -NDMKLCache::NDMKLCache(const NDMKLCacheId & id) -: Cache < NDMKLCacheId > (id) -{ - m_rank = id.m_rank; - m_ndims = convert_dims(id.m_rank, id.m_dims); - m_dims = (int *) malloc(sizeof(int) * m_rank); - if (m_dims == NULL) { - goto fail; - } - - memcpy(m_dims, id.m_dims, sizeof(int) * m_rank); - DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, (long) m_rank, - m_ndims); - DftiCommitDescriptor(m_hdl); - - return; - -fail: - throw std::bad_alloc(); -} - -NDMKLCache::~NDMKLCache() -{ - DftiFreeDescriptor(&m_hdl); - free(m_dims); - free(m_ndims); -} - -long* NDMKLCache::convert_dims(int n, int *dims) const -{ - long *ndim; - int i; - - ndim = (long *) malloc(sizeof(*ndim) * n); - for (i = 0; i < n; i++) { - ndim[i] = (long) dims[i]; - } - return ndim; -} - -static CacheManager < NDMKLCacheId, NDMKLCache > ndmkl_cmgr(10); - -void zfftnd_mkl(complex_double * inout, int rank, - int *dims, int direction, int howmany, - int normalize) -{ - int i, sz; - complex_double *ptr = inout; - NDMKLCache *cache; - - sz = 1; - for (i = 0; i < rank; ++i) { - sz *= dims[i]; - } - - cache = ndmkl_cmgr.get_cache(NDMKLCacheId(rank, dims)); - switch(direction) { - case 1: - for (i = 0; i < howmany; ++i, ptr += sz) { - cache->compute_forward((double*)ptr); - } - break; - case -1: - for (i = 0; i < howmany; ++i, ptr += sz) { - cache->compute_backward((double*)ptr); - } - break; - default: - fprintf(stderr, - "nd mkl:Wrong direction (this is a bug)\n"); - return; - } - if (normalize) { - ptr = inout; - for (i = sz * howmany - 1; i >= 0; --i) { - *((double *) (ptr)) /= sz; - *((double *) (ptr++) + 1) /= sz; - } - } -} From scipy-svn at scipy.org Fri May 16 02:21:26 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:21:26 -0500 (CDT) Subject: [Scipy-svn] r4365 - branches/refactor_fft/scipy/fftpack/backends/mkl/src Message-ID: <20080516062126.A6BC539C21C@scipy.org> Author: cdavid Date: 2008-05-16 01:21:22 -0500 (Fri, 16 May 2008) New Revision: 4365 Modified: branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h Log: Set C linkage for public api of mkl backend. Modified: branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h 2008-05-16 06:17:24 UTC (rev 4364) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h 2008-05-16 06:21:22 UTC (rev 4365) @@ -6,11 +6,13 @@ /* * straight FFT api */ +extern "C" { void zfft_mkl(complex_double * inout, int n, int direction, int howmany, int normalize); void zfftnd_mkl(complex_double * inout, int rank, int *dims, int direction, int howmany, int normalize); +}; #endif From scipy-svn at scipy.org Fri May 16 02:21:43 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:21:43 -0500 (CDT) Subject: [Scipy-svn] r4366 - branches/refactor_fft/scipy/fftpack/backends/mkl Message-ID: <20080516062143.68D3A39C21C@scipy.org> Author: cdavid Date: 2008-05-16 01:21:37 -0500 (Fri, 16 May 2008) New Revision: 4366 Added: branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf branches/refactor_fft/scipy/fftpack/backends/mkl/setup.py Log: mkl backend now builds. Added: branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf 2008-05-16 06:21:22 UTC (rev 4365) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf 2008-05-16 06:21:37 UTC (rev 4366) @@ -0,0 +1,77 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _mkl + interface + + subroutine zfft_mkl(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_mkl + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_mkl + +! subroutine drfft_mkl(x,n,direction,howmany,normalize) +! ! y = drfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) drfft_mkl +! real*8 intent(c,in,out,copy,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine drfft_mkl + +! subroutine zrfft_mkl(x,n,direction,howmany,normalize) +! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) zrfft_mkl +! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine zrfft_mkl + + subroutine zfftnd_mkl(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_mkl + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i Author: cdavid Date: 2008-05-16 01:27:27 -0500 (Fri, 16 May 2008) New Revision: 4367 Added: branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py Log: MKL backend now works too. Added: branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py 2008-05-16 06:21:37 UTC (rev 4366) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py 2008-05-16 06:27:27 UTC (rev 4367) @@ -0,0 +1,2 @@ +from _mkl import zfft_mkl as zfft, \ + zfftnd_mkl as zfftnd Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-16 06:21:37 UTC (rev 4366) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-16 06:27:27 UTC (rev 4367) @@ -9,6 +9,7 @@ config.add_subpackage("fftw3") config.add_subpackage("fftw") + config.add_subpackage("mkl") return config From scipy-svn at scipy.org Fri May 16 02:28:25 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:28:25 -0500 (CDT) Subject: [Scipy-svn] r4368 - branches/refactor_fft/scipy/fftpack Message-ID: <20080516062825.B084F39C07C@scipy.org> Author: cdavid Date: 2008-05-16 01:28:21 -0500 (Fri, 16 May 2008) New Revision: 4368 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Return found module; not sure how it could work before... Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 06:27:27 UTC (rev 4367) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 06:28:21 UTC (rev 4368) @@ -28,6 +28,7 @@ mod = __import__("scipy.fftpack.backends", fromlist = [name]) try: ret = mod.__dict__[name] + return ret except KeyError, e: raise ImportError(e) From scipy-svn at scipy.org Fri May 16 02:46:57 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 01:46:57 -0500 (CDT) Subject: [Scipy-svn] r4369 - in branches/refactor_fft: . scipy/stats Message-ID: <20080516064657.9BF9B39C464@scipy.org> Author: cdavid Date: 2008-05-16 01:46:53 -0500 (Fri, 16 May 2008) New Revision: 4369 Modified: branches/refactor_fft/ branches/refactor_fft/scipy/stats/stats.py Log: Merged revisions 4327-4368 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r4352 | oliphant | 2008-05-16 01:36:59 +0900 (Fri, 16 May 2008) | 1 line Fix stats.var for complex variables. ........ Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4326 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4368 Modified: branches/refactor_fft/scipy/stats/stats.py =================================================================== --- branches/refactor_fft/scipy/stats/stats.py 2008-05-16 06:28:21 UTC (rev 4368) +++ branches/refactor_fft/scipy/stats/stats.py 2008-05-16 06:46:53 UTC (rev 4369) @@ -1191,7 +1191,7 @@ mn = np.expand_dims(mean(a,axis),axis) deviations = a - mn n = a.shape[axis] - vals = ss(deviations,axis)/(n-1.0) + vals = sum(abs(deviations)**2,axis)/(n-1.0) if bias: return vals * (n-1.0)/n else: From scipy-svn at scipy.org Fri May 16 03:56:40 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 02:56:40 -0500 (CDT) Subject: [Scipy-svn] r4370 - in branches/refactor_fft/scipy/fftpack/backends: fftw fftw3 mkl Message-ID: <20080516075640.DEA5539C77F@scipy.org> Author: cdavid Date: 2008-05-16 02:56:34 -0500 (Fri, 16 May 2008) New Revision: 4370 Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py Log: Do not fail backend import because of nosetests. Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py 2008-05-16 06:46:53 UTC (rev 4369) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py 2008-05-16 07:56:34 UTC (rev 4370) @@ -1,3 +1,10 @@ -from _fftw import zfft_fftw as zfft, \ - drfft_fftw as drfft, \ - zfftnd_fftw as zfftnd +"""This module should never be imported directly.""" + +# We wrap around ImportError because nosetest tries to import this +# module and generates an error when the backend is not built +try: + from _fftw import zfft_fftw as zfft, \ + drfft_fftw as drfft, \ + zfftnd_fftw as zfftnd +except ImportError: + pass Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py 2008-05-16 06:46:53 UTC (rev 4369) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py 2008-05-16 07:56:34 UTC (rev 4370) @@ -1,3 +1,11 @@ -from _fftw3 import zfft_fftw3 as zfft, \ - drfft_fftw3 as drfft, \ - zfftnd_fftw3 as zfftnd +"""This module should never be imported directly.""" + +# We wrap around ImportError because nosetest tries to import this +# module and generates an error when the backend is not built + +try: + from _fftw3 import zfft_fftw3 as zfft, \ + drfft_fftw3 as drfft, \ + zfftnd_fftw3 as zfftnd +except ImportError: + pass Modified: branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py 2008-05-16 06:46:53 UTC (rev 4369) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py 2008-05-16 07:56:34 UTC (rev 4370) @@ -1,2 +1,9 @@ -from _mkl import zfft_mkl as zfft, \ - zfftnd_mkl as zfftnd +"""This module should never be imported directly.""" + +# We wrap around ImportError because nosetest tries to import this +# module and generates an error when the backend is not built +try: + from _mkl import zfft_mkl as zfft, \ + zfftnd_mkl as zfftnd +except ImportError: + pass From scipy-svn at scipy.org Fri May 16 04:30:30 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 03:30:30 -0500 (CDT) Subject: [Scipy-svn] r4371 - in branches/refactor_fft/scipy/fftpack: . backends/fftw backends/fftw3 backends/mkl Message-ID: <20080516083030.291E839C799@scipy.org> Author: cdavid Date: 2008-05-16 03:30:14 -0500 (Fri, 16 May 2008) New Revision: 4371 Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py branches/refactor_fft/scipy/fftpack/common.py Log: Fix import of backends. Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py 2008-05-16 07:56:34 UTC (rev 4370) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/__init__.py 2008-05-16 08:30:14 UTC (rev 4371) @@ -6,5 +6,6 @@ from _fftw import zfft_fftw as zfft, \ drfft_fftw as drfft, \ zfftnd_fftw as zfftnd + IS_INIT = True except ImportError: - pass + IS_INIT = False Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py 2008-05-16 07:56:34 UTC (rev 4370) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/__init__.py 2008-05-16 08:30:14 UTC (rev 4371) @@ -7,5 +7,6 @@ from _fftw3 import zfft_fftw3 as zfft, \ drfft_fftw3 as drfft, \ zfftnd_fftw3 as zfftnd + IS_INIT = True except ImportError: - pass + IS_INIT = False Modified: branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py 2008-05-16 07:56:34 UTC (rev 4370) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/__init__.py 2008-05-16 08:30:14 UTC (rev 4371) @@ -5,5 +5,6 @@ try: from _mkl import zfft_mkl as zfft, \ zfftnd_mkl as zfftnd + IS_INIT = True except ImportError: - pass + IS_INIT = False Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 07:56:34 UTC (rev 4370) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-16 08:30:14 UTC (rev 4371) @@ -6,6 +6,7 @@ The functions are set up in load_backend function, which initialize the dictionary _FUNCS with working functions. If a backend does not implement one of the function, a fallback is automatically used.""" + # Default backend: fftpack. import fftpack as _DEF_BACKEND @@ -28,13 +29,44 @@ mod = __import__("scipy.fftpack.backends", fromlist = [name]) try: ret = mod.__dict__[name] - return ret + if ret.IS_INIT: + return ret + else: + raise ImportError("Could not import %s (was not initialized)"\ + % name) except KeyError, e: raise ImportError(e) -def load_backend(name): +def find_backend(): + """Try to import one of the backend, and return the first found. + + Returns the backend (module class), raise ImportError if nothing is + found.""" + for backend in ["mkl", "fftw3", "fftw"]: + try: + print "Trying backend ", backend + mod = myimport(backend) + return mod, backend + except ImportError: + pass + raise ImportError("No backend found") + +def load_backend(name = None): + """Load backend and set functions accordingly. + + If name is None, all backend are tried one after the other, as defined in + function find_backend. + + If the backend does not implement one function, function in _DEF_BACKEND is + used instead. + + If the backend is not found, fallback is used for all the functions.""" try: - mod = myimport(name) + if name: + mod = myimport(name) + else: + mod, name = find_backend() + # Loading fft functions: each of them can be loaded independently for f in _FFT_FUNCNAME: try: @@ -60,7 +92,7 @@ for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] -load_backend("fftw3") +load_backend() zfft = _FUNCS["zfft"] drfft = _FUNCS["drfft"] From scipy-svn at scipy.org Fri May 16 04:32:30 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 03:32:30 -0500 (CDT) Subject: [Scipy-svn] r4372 - branches/refactor_fft/scipy/fftpack/fftpack/src Message-ID: <20080516083230.355A139C798@scipy.org> Author: cdavid Date: 2008-05-16 03:32:20 -0500 (Fri, 16 May 2008) New Revision: 4372 Removed: branches/refactor_fft/scipy/fftpack/fftpack/src/convolve.cxx branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.cxx Log: Remove dead code. Deleted: branches/refactor_fft/scipy/fftpack/fftpack/src/convolve.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/src/convolve.cxx 2008-05-16 08:30:14 UTC (rev 4371) +++ branches/refactor_fft/scipy/fftpack/fftpack/src/convolve.cxx 2008-05-16 08:32:20 UTC (rev 4372) @@ -1,54 +0,0 @@ -/* - Generic functions for computing 1D convolutions of periodic sequences. - - Supported FFT libraries: - DJBFFT - optional, used for power-of-two length arrays - FFTW - optional - FFTPACK - used if any of the above libraries is not available - - Author: Pearu Peterson, September 2002 - */ - -#include "fftpack.h" - -#define GEN_CONVOLVE_API(name) \ -extern "C" void convolve(int n,double* inout,double* omega,int swap_real_imag) \ -{\ - convolve_##name(n, inout, omega, swap_real_imag);\ -}\ -extern "C" void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) \ -{\ - convolve_z_##name(n, inout, omega_real, omega_imag);\ -}\ -extern "C" void init_convolution_kernel(int n,double* omega, int d, \ - double (*kernel_func)(int), \ - int zero_nyquist) \ -{\ - init_convolution_kernel_##name(n,omega, d, kernel_func, zero_nyquist);\ -} \ -extern "C" void destroy_convolve_cache(void) \ -{\ -} - -/**************** FFTW *****************************/ -#ifdef WITH_FFTW - -#include "fftw/api.h" -#ifndef WITH_DJBFFT - GEN_CONVOLVE_API(fftw) -#endif - -#else -/**************** FFTPACK ZFFT **********************/ -#include "fftpack/api.h" - -#ifndef WITH_DJBFFT - GEN_CONVOLVE_API(fftpack) -#endif - -#endif - -#ifdef WITH_DJBFFT - #include "djbfft/api.h" - GEN_CONVOLVE_API(djbfft) -#endif Deleted: branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.cxx =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.cxx 2008-05-16 08:30:14 UTC (rev 4371) +++ branches/refactor_fft/scipy/fftpack/fftpack/src/fftpack.cxx 2008-05-16 08:32:20 UTC (rev 4372) @@ -1,72 +0,0 @@ -#include "fftpack.h" - -/* The following macro convert private backend specific function to the public - * functions exported by the module */ -#define GEN_ZFFT_API(name) \ -extern "C" void zfft(complex_double *inout, int n, \ - int direction, int howmany, int normalize)\ -{\ - zfft_##name(inout, n, direction, howmany, normalize);\ -} - -#define GEN_DRFFT_API(name) \ -extern "C" void drfft(double *inout, int n, \ - int direction, int howmany, int normalize)\ -{\ - drfft_##name(inout, n, direction, howmany, normalize);\ -} - -#define GEN_ZFFTND_API(name) \ -extern "C" void zfftnd(complex_double * inout, int rank,\ - int *dims, int direction, int howmany, int normalize)\ -{\ - zfftnd_##name(inout, rank, dims, direction, howmany, normalize);\ -} - - -/* - * Each backend define public functions in the backend specific api.h file, and - * depending on the options, we set the function called by the python extension - * to a backend specific one. - */ - -#ifdef WITH_FFTW3 - #include "fftw3/api.h" - #ifndef WITH_DJBFFT - GEN_ZFFT_API(fftw3) - GEN_DRFFT_API(fftw3) - GEN_ZFFTND_API(fftw3) - #endif -#elif defined WITH_FFTW - #include "fftw/api.h" - #ifndef WITH_DJBFFT - GEN_ZFFT_API(fftw) - GEN_DRFFT_API(fftw) - GEN_ZFFTND_API(fftw) - #endif -#elif defined WITH_MKL - #include "mkl/api.h" - #ifndef WITH_DJBFFT - GEN_ZFFT_API(mkl) - GEN_ZFFTND_API(mkl) - #endif - GEN_DRFFT_API(fftpack) -#endif - -#if (!defined WITH_DJBFFT) && (!defined WITH_MKL) \ - && (!defined WITH_FFTW) && (!defined WITH_FFTW3) -GEN_ZFFT_API(fftpack) -GEN_DRFFT_API(fftpack) -GEN_ZFFTND_API(fftpack) -#endif - -/* - * djbfft must be used at the end, because it needs another backend (defined - * above) for non 2^n * size - */ -#ifdef WITH_DJBFFT - #include "djbfft/api.h" - GEN_DRFFT_API(djbfft) - GEN_ZFFT_API(djbfft) - GEN_ZFFTND_API(fftpack) -#endif From scipy-svn at scipy.org Fri May 16 05:31:13 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 May 2008 04:31:13 -0500 (CDT) Subject: [Scipy-svn] r4373 - in branches/refactor_fft/scipy/fftpack: . fftpack Message-ID: <20080516093113.1A7EF39C3EE@scipy.org> Author: cdavid Date: 2008-05-16 04:31:01 -0500 (Fri, 16 May 2008) New Revision: 4373 Added: branches/refactor_fft/scipy/fftpack/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/fftpack/setupscons.py Removed: branches/refactor_fft/scipy/fftpack/SConstruct Modified: branches/refactor_fft/scipy/fftpack/fftpack/ branches/refactor_fft/scipy/fftpack/setupscons.py Log: Fix scons build of fftpack (no backend yet). Deleted: branches/refactor_fft/scipy/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-16 08:32:20 UTC (rev 4372) +++ branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-16 09:31:01 UTC (rev 4373) @@ -1,52 +0,0 @@ -# Last Change: Tue May 13 10:00 AM 2008 J -# vim:syntax=python -from os.path import join as pjoin - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment, write_info -from numscons import CheckFFT, IsMKL, IsFFTW2, IsFFTW3 -from numscons import CheckF77Clib - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') - -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -backends_paths = [pjoin(env['build_dir'], 'src', b) - for b in ["mkl", "fftw", "djbfft", "fftpack", "fftw3"]] -env.AppendUnique(CPPPATH = backends_paths) -env.AppendUnique(CPPPATH = [pjoin(env['build_dir'], "src")]) - -# Check fft implementation -config = env.NumpyConfigure(custom_tests = {'CheckFFT': CheckFFT, - 'CheckF77Clib' : CheckF77Clib}) -has_fft = config.CheckFFT() -if not config.CheckF77Clib(): - raise Exception("Could not get f77/c++ link information") -config.Finish() -write_info(env) - -# Tweak defineds depending on the fft used -if has_fft: - if IsMKL(env, 'fft'): - env.Append(CPPDEFINES = "SCIPY_MKL_H") - elif IsFFTW3(env, 'fft'): - env.Append(CPPDEFINES = "SCIPY_FFTW3_H") - elif IsFFTW2(env, 'fft'): - env.Append(CPPDEFINES = "SCIPY_FFTW2_H") - else: - pass - -# Build dfftpack -src = env.NumpyGlob(pjoin('dfftpack', '*.f')) -dfftpack = env.NumpyStaticExtLibrary('dfftpack', source = [str(s) for s in src]) -env.PrependUnique(LIBS = ['dfftpack']) -env.PrependUnique(LIBPATH = env['build_dir']) - -# Build _fftpack -src = ['src/zfft.cxx','src/drfft.cxx','src/zrfft.c', 'src/zfftnd.cxx', 'fftpack.pyf'] -env.NumpyPythonExtension('_fftpack', src) - -# Build convolve -src = ['src/convolve.cxx', 'convolve.pyf'] -env.NumpyPythonExtension('convolve', src) Property changes on: branches/refactor_fft/scipy/fftpack/fftpack ___________________________________________________________________ Name: svn:ignore - *.pyc *.swp *.pyd *.so + .sconsign.dblite *.pyc *.swp *.pyd *.so Copied: branches/refactor_fft/scipy/fftpack/fftpack/SConstruct (from rev 4369, branches/refactor_fft/scipy/fftpack/SConstruct) =================================================================== --- branches/refactor_fft/scipy/fftpack/SConstruct 2008-05-16 06:46:53 UTC (rev 4369) +++ branches/refactor_fft/scipy/fftpack/fftpack/SConstruct 2008-05-16 09:31:01 UTC (rev 4373) @@ -0,0 +1,33 @@ +# Last Change: Fri May 16 06:00 PM 2008 J +# vim:syntax=python +from os.path import join as pjoin + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numscons import GetNumpyEnvironment +from numscons import CheckF77Clib + +env = GetNumpyEnvironment(ARGUMENTS) +env.Tool('numpyf2py') + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +env.AppendUnique(CPPPATH = [pjoin(env['build_dir'], "src")]) + +config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib}) +if not config.CheckF77Clib(): + raise Exception("Could not get f77/c++ link information") +config.Finish() + +# Build dfftpack +src = env.NumpyGlob(pjoin('DFFTPACK', '*.f')) +dfftpack = env.NumpyStaticExtLibrary('dfftpack', source = [str(s) for s in src]) +env.PrependUnique(LIBS = ['dfftpack']) +env.PrependUnique(LIBPATH = env['build_dir']) + +# Build the fftpack wrapper +src = [pjoin("src/fftpack", i) for i in ['zfft.cxx','drfft.cxx', 'zfftnd.cxx']] +env.NumpyPythonExtension('_fftpack', src + ['fftpack.pyf', 'src/zrfft.c']) + +# Build convolve +src = ['src/fftpack/convolve.cxx', 'convolve.pyf'] +env.NumpyPythonExtension('convolve', src) Copied: branches/refactor_fft/scipy/fftpack/fftpack/setupscons.py (from rev 4369, branches/refactor_fft/scipy/fftpack/fftpack/setup.py) =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/setup.py 2008-05-16 06:46:53 UTC (rev 4369) +++ branches/refactor_fft/scipy/fftpack/fftpack/setupscons.py 2008-05-16 09:31:01 UTC (rev 4373) @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# Created by Pearu Peterson, August 2002 + +from os.path import join + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('fftpack',parent_package, top_path) + + config.add_sconscript("SConstruct") + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) Modified: branches/refactor_fft/scipy/fftpack/setupscons.py =================================================================== --- branches/refactor_fft/scipy/fftpack/setupscons.py 2008-05-16 08:32:20 UTC (rev 4372) +++ branches/refactor_fft/scipy/fftpack/setupscons.py 2008-05-16 09:31:01 UTC (rev 4373) @@ -6,11 +6,16 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info - config = Configuration('fftpack',parent_package, top_path) + config = Configuration('fftpack',parent_package, top_path, setup_name = 'setupscons.py') - config.add_sconscript('SConstruct') config.add_data_dir('tests') + config.add_data_dir('benchmarks') + config.add_subpackage('fftpack') + + # Build optional backends + config.add_subpackage('backends') + return config if __name__ == '__main__': From scipy-svn at scipy.org Sun May 18 05:42:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 18 May 2008 04:42:36 -0500 (CDT) Subject: [Scipy-svn] r4374 - branches/refactor_fft/scipy/fftpack/fftpack Message-ID: <20080518094236.8828A39C618@scipy.org> Author: cdavid Date: 2008-05-18 04:42:27 -0500 (Sun, 18 May 2008) New Revision: 4374 Added: branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf.src Removed: branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf Modified: branches/refactor_fft/scipy/fftpack/fftpack/SConstruct branches/refactor_fft/scipy/fftpack/fftpack/setup.py Log: Use a template pyf file for fftpack. Modified: branches/refactor_fft/scipy/fftpack/fftpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/SConstruct 2008-05-16 09:31:01 UTC (rev 4373) +++ branches/refactor_fft/scipy/fftpack/fftpack/SConstruct 2008-05-18 09:42:27 UTC (rev 4374) @@ -1,4 +1,4 @@ -# Last Change: Fri May 16 06:00 PM 2008 J +# Last Change: Sun May 18 06:00 PM 2008 J # vim:syntax=python from os.path import join as pjoin @@ -26,7 +26,8 @@ # Build the fftpack wrapper src = [pjoin("src/fftpack", i) for i in ['zfft.cxx','drfft.cxx', 'zfftnd.cxx']] -env.NumpyPythonExtension('_fftpack', src + ['fftpack.pyf', 'src/zrfft.c']) +src.append(env.NumpyFromFTemplate('fftpack.pyf', 'fftpack.pyf.src')) +env.NumpyPythonExtension('_fftpack', src + ['src/zrfft.c']) # Build convolve src = ['src/fftpack/convolve.cxx', 'convolve.pyf'] Copied: branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src (from rev 4373, branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf) =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf 2008-05-16 09:31:01 UTC (rev 4373) +++ branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src 2008-05-18 09:42:27 UTC (rev 4374) @@ -0,0 +1,75 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 +! This file is included by the files /.pyf.src +! ********************************************************************** +! NOTE: IF YOU UPDATE THIS FILE, YOU SHOULD UPDATE IT FOR BACKENDS TOO ! +! ********************************************************************** + + subroutine zfft(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft + + subroutine drfft(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft + + subroutine zrfft(x,n,direction,howmany,normalize) + ! y = zrfft(x[,n,direction,normalize,overwrite_x]) + intent(c) zrfft + complex*16 intent(c,in,out,overwrite,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zrfft + + subroutine zfftnd(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i_error, & + "inconsistency in x.shape and s argument"); & + } & + } + end subroutine zfftnd + +! See http://cens.ioc.ee/projects/f2py2e/ Deleted: branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf 2008-05-16 09:31:01 UTC (rev 4373) +++ branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf 2008-05-18 09:42:27 UTC (rev 4374) @@ -1,77 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 - -python module _fftpack - interface - - subroutine zfft_fftpack(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft_fftpack - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft_fftpack - - subroutine drfft_fftpack(x,n,direction,howmany,normalize) - ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft_fftpack - real*8 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine drfft_fftpack - - subroutine zrfft_fftpack(x,n,direction,howmany,normalize) - ! y = zrfft(x[,n,direction,normalize,overwrite_x]) - intent(c) zrfft_fftpack - complex*16 intent(c,in,out,overwrite,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zrfft_fftpack - - subroutine zfftnd_fftpack(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd_fftpack - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i + +python module _fftpack + interface + include 'fft_template.pyf.src' + end interface +end python module _fftpack Modified: branches/refactor_fft/scipy/fftpack/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/setup.py 2008-05-16 09:31:01 UTC (rev 4373) +++ branches/refactor_fft/scipy/fftpack/fftpack/setup.py 2008-05-18 09:42:27 UTC (rev 4374) @@ -10,7 +10,7 @@ config.add_library('dfftpack', sources=[join('DFFTPACK','*.f')]) - sources = ['fftpack.pyf', 'src/zrfft.c'] + sources = ['fftpack.pyf.src', 'src/zrfft.c'] for s in ["zfft.cxx", "zfftnd.cxx", "drfft.cxx"]: sources.append(join('src/fftpack', s)) From scipy-svn at scipy.org Sun May 18 06:52:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 18 May 2008 05:52:56 -0500 (CDT) Subject: [Scipy-svn] r4375 - in branches/refactor_fft/scipy/fftpack/backends: . fftw fftw3 mkl Message-ID: <20080518105256.23D6939C632@scipy.org> Author: cdavid Date: 2008-05-18 05:52:48 -0500 (Sun, 18 May 2008) New Revision: 4375 Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/setup.py branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py branches/refactor_fft/scipy/fftpack/backends/mkl/setup.py branches/refactor_fft/scipy/fftpack/backends/setup.py Log: Build extensions in backend dir instead of building in each backend. Modified: branches/refactor_fft/scipy/fftpack/backends/fftw/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/setup.py 2008-05-18 09:42:27 UTC (rev 4374) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/setup.py 2008-05-18 10:52:48 UTC (rev 4375) @@ -1,25 +1,10 @@ #!/usr/bin/env python # Created by Pearu Peterson, August 2002 -from os.path import join - -def build_backends(config): - from numpy.distutils.system_info import get_info - src = [join('src', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - info = get_info("fftw2") - if info: - config.add_library("fftw_backend", - sources = src, - include_dirs = ["../common", - info['include_dirs']]) - config.add_extension("_fftw", sources = ["fftw.pyf"], extra_info = info, libraries = ["fftw_backend"]) - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('fftw', parent_package, top_path) - build_backends(config) return config Modified: branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py 2008-05-18 09:42:27 UTC (rev 4374) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/setup.py 2008-05-18 10:52:48 UTC (rev 4375) @@ -1,25 +1,10 @@ #!/usr/bin/env python # Created by Pearu Peterson, August 2002 -from os.path import join - -def build_backends(config): - from numpy.distutils.system_info import get_info - src = [join('src', i) for i in - ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] - info = get_info("fftw3") - if info: - config.add_library("fftw3_backend", - sources = src, - include_dirs = ["../common", - info['include_dirs']]) - config.add_extension("_fftw3", sources = ["fftw3.pyf"], extra_info = info, libraries = ["fftw3_backend"]) - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('fftw3', parent_package, top_path) - build_backends(config) return config Modified: branches/refactor_fft/scipy/fftpack/backends/mkl/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/setup.py 2008-05-18 09:42:27 UTC (rev 4374) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/setup.py 2008-05-18 10:52:48 UTC (rev 4375) @@ -1,25 +1,10 @@ #!/usr/bin/env python # Created by Pearu Peterson, August 2002 -from os.path import join - -def build_backends(config): - from numpy.distutils.system_info import get_info - src = [join('src', i) for i in - ['zfft.cxx', 'zfftnd.cxx']] - info = get_info("mkl") - if info: - config.add_library("mkl_backend", - sources = src, - include_dirs = ["../common", - info['include_dirs']]) - config.add_extension("_mkl", sources = ["mkl.pyf"], extra_info = info, libraries = ["mkl_backend"]) - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('mkl', parent_package, top_path) - build_backends(config) return config Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-18 09:42:27 UTC (rev 4374) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-18 10:52:48 UTC (rev 4375) @@ -1,15 +1,43 @@ #!/usr/bin/env python -# Created by Pearu Peterson, August 2002 - from os.path import join +from numpy.distutils.system_info import get_info + +SRC = {} +SRC['fftw'] = [join('fftw/src', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] +SRC['fftw3'] = [join('fftw3/src', i) for i in + ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']] +SRC['mkl'] = [join('mkl/src', i) for i in + ['zfft.cxx', 'zfftnd.cxx']] + +def build_backend(config, name, config_name = None): + if config_name is None: + config_name = name + + info = get_info(config_name) + if info: + config.add_library("%s_backend" % name, + sources = SRC[name], + include_dirs = ["common", + info['include_dirs']]) + config.add_extension("%s._%s" % (name, name), + sources = ["%s/%s.pyf" % (name, name)], + extra_info = info, libraries = ["%s_backend" % name]) + + config.add_subpackage(name) + def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('backends', parent_package, top_path) - config.add_subpackage("fftw3") - config.add_subpackage("fftw") - config.add_subpackage("mkl") + # It is a bit of an hack: we build the extensions here, but we add + # subpackages. The reason why we build the extensions here is because we + # share files between backends, and scons cannot use sources outside its + # top directory. + build_backend(config, 'fftw', 'fftw2') + build_backend(config, 'fftw3') + build_backend(config, 'mkl') return config From scipy-svn at scipy.org Sun May 18 07:01:19 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 18 May 2008 06:01:19 -0500 (CDT) Subject: [Scipy-svn] r4376 - in branches/refactor_fft/scipy/fftpack/backends: . fftw fftw3 mkl Message-ID: <20080518110119.8D71139C4B1@scipy.org> Author: cdavid Date: 2008-05-18 06:01:08 -0500 (Sun, 18 May 2008) New Revision: 4376 Added: branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf.src branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf.src branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf.src Removed: branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py Log: Use template and common implementation file for pyf. Copied: branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src (from rev 4374, branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src) =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src 2008-05-18 09:42:27 UTC (rev 4374) +++ branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src 2008-05-18 11:01:08 UTC (rev 4376) @@ -0,0 +1,75 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 +! This file is included by the files /.pyf.src +! ********************************************************************** +! NOTE: IF YOU UPDATE THIS FILE, YOU SHOULD UPDATE IT FOR FFTPACK TOO ! +! ********************************************************************** + + subroutine zfft(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft + + subroutine drfft(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft + + subroutine zrfft(x,n,direction,howmany,normalize) + ! y = zrfft(x[,n,direction,normalize,overwrite_x]) + intent(c) zrfft + complex*16 intent(c,in,out,overwrite,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zrfft + + subroutine zfftnd(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i_error, & + "inconsistency in x.shape and s argument"); & + } & + } + end subroutine zfftnd + +! See http://cens.ioc.ee/projects/f2py2e/ Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf 2008-05-18 10:52:48 UTC (rev 4375) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf 2008-05-18 11:01:08 UTC (rev 4376) @@ -1,77 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 - -python module _fftw - interface - - subroutine zfft_fftw(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft_fftw - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft_fftw - - subroutine drfft_fftw(x,n,direction,howmany,normalize) - ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft_fftw - real*8 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine drfft_fftw - -! subroutine zrfft_fftw(x,n,direction,howmany,normalize) -! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) -! intent(c) zrfft_fftw -! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) -! integer optional,depend(x),intent(c,in) :: n=size(x) -! check(n>0&&n<=size(x)) n -! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n -! check(n*howmany==size(x)) howmany -! integer optional,intent(c,in) :: direction = 1 -! integer optional,intent(c,in),depend(direction) & -! :: normalize = (direction<0) -! end subroutine zrfft_fftw - - subroutine zfftnd_fftw(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd_fftw - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i + +python module _fftw + interface + include '../fft_template.pyf.src' + end interface +end python module _fftw Deleted: branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf 2008-05-18 10:52:48 UTC (rev 4375) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf 2008-05-18 11:01:08 UTC (rev 4376) @@ -1,77 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 - -python module _fftw3 - interface - - subroutine zfft_fftw3(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft_fftw3 - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft_fftw3 - - subroutine drfft_fftw3(x,n,direction,howmany,normalize) - ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft_fftw3 - real*8 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine drfft_fftw3 - -! subroutine zrfft_fftw3(x,n,direction,howmany,normalize) -! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) -! intent(c) zrfft_fftw3 -! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) -! integer optional,depend(x),intent(c,in) :: n=size(x) -! check(n>0&&n<=size(x)) n -! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n -! check(n*howmany==size(x)) howmany -! integer optional,intent(c,in) :: direction = 1 -! integer optional,intent(c,in),depend(direction) & -! :: normalize = (direction<0) -! end subroutine zrfft_fftw3 - - subroutine zfftnd_fftw3(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd_fftw3 - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i + +python module _fftw3 + interface + include '../fft_template.pyf.src' + end interface +end python module _fftw3 Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf 2008-05-18 10:52:48 UTC (rev 4375) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf 2008-05-18 11:01:08 UTC (rev 4376) @@ -1,77 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 - -python module _mkl - interface - - subroutine zfft_mkl(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft_mkl - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft_mkl - -! subroutine drfft_mkl(x,n,direction,howmany,normalize) -! ! y = drfft(x[,n,direction,normalize,overwrite_x]) -! intent(c) drfft_mkl -! real*8 intent(c,in,out,copy,out=y) :: x(*) -! integer optional,depend(x),intent(c,in) :: n=size(x) -! check(n>0&&n<=size(x)) n -! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n -! check(n*howmany==size(x)) howmany -! integer optional,intent(c,in) :: direction = 1 -! integer optional,intent(c,in),depend(direction) & -! :: normalize = (direction<0) -! end subroutine drfft_mkl - -! subroutine zrfft_mkl(x,n,direction,howmany,normalize) -! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) -! intent(c) zrfft_mkl -! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) -! integer optional,depend(x),intent(c,in) :: n=size(x) -! check(n>0&&n<=size(x)) n -! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n -! check(n*howmany==size(x)) howmany -! integer optional,intent(c,in) :: direction = 1 -! integer optional,intent(c,in),depend(direction) & -! :: normalize = (direction<0) -! end subroutine zrfft_mkl - - subroutine zfftnd_mkl(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd_mkl - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i + +python module _mkl + interface + include '../fft_template.pyf.src' + end interface +end python module _mkl Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-18 10:52:48 UTC (rev 4375) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-18 11:01:08 UTC (rev 4376) @@ -22,7 +22,7 @@ include_dirs = ["common", info['include_dirs']]) config.add_extension("%s._%s" % (name, name), - sources = ["%s/%s.pyf" % (name, name)], + sources = ["%s/%s.pyf.src" % (name, name)], extra_info = info, libraries = ["%s_backend" % name]) config.add_subpackage(name) From scipy-svn at scipy.org Wed May 21 18:52:29 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 May 2008 17:52:29 -0500 (CDT) Subject: [Scipy-svn] r4377 - in trunk/scipy/sparse: . sparsetools tests Message-ID: <20080521225229.8FFF439C3F0@scipy.org> Author: wnbell Date: 2008-05-21 17:52:19 -0500 (Wed, 21 May 2008) New Revision: 4377 Modified: trunk/scipy/sparse/lil.py trunk/scipy/sparse/sparsetools/bsr.py trunk/scipy/sparse/sparsetools/bsr_wrap.cxx trunk/scipy/sparse/sparsetools/complex_ops.h trunk/scipy/sparse/sparsetools/coo.py trunk/scipy/sparse/sparsetools/coo_wrap.cxx trunk/scipy/sparse/sparsetools/csc.py trunk/scipy/sparse/sparsetools/csc_wrap.cxx trunk/scipy/sparse/sparsetools/csr.py trunk/scipy/sparse/sparsetools/csr_wrap.cxx trunk/scipy/sparse/sparsetools/dia.py trunk/scipy/sparse/sparsetools/dia_wrap.cxx trunk/scipy/sparse/tests/test_base.py Log: resolves ticket #671, division error in complex_ops.h Modified: trunk/scipy/sparse/lil.py =================================================================== --- trunk/scipy/sparse/lil.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/lil.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -346,38 +346,39 @@ else: return self.tocsr() / other - def multiply(self, other): - """Point-wise multiplication by another lil_matrix. +## This code doesn't work with complex matrices +# def multiply(self, other): +# """Point-wise multiplication by another lil_matrix. +# +# """ +# if isscalar(other): +# return self.__mul__(other) +# +# if isspmatrix_lil(other): +# reference,target = self,other +# +# if reference.shape != target.shape: +# raise ValueError("Dimensions do not match.") +# +# if len(reference.data) > len(target.data): +# reference,target = target,reference +# +# new = lil_matrix(reference.shape) +# for r,row in enumerate(reference.rows): +# tr = target.rows[r] +# td = target.data[r] +# rd = reference.data[r] +# L = len(tr) +# for c,column in enumerate(row): +# ix = bisect_left(tr,column) +# if ix < L and tr[ix] == column: +# new.rows[r].append(column) +# new.data[r].append(rd[c] * td[ix]) +# return new +# else: +# raise ValueError("Point-wise multiplication only allowed " +# "with another lil_matrix.") - """ - if isscalar(other): - return self.__mul__(other) - - if isspmatrix_lil(other): - reference,target = self,other - - if reference.shape != target.shape: - raise ValueError("Dimensions do not match.") - - if len(reference.data) > len(target.data): - reference,target = target,reference - - new = lil_matrix(reference.shape) - for r,row in enumerate(reference.rows): - tr = target.rows[r] - td = target.data[r] - rd = reference.data[r] - L = len(tr) - for c,column in enumerate(row): - ix = bisect_left(tr,column) - if ix < L and tr[ix] == column: - new.rows[r].append(column) - new.data[r].append(rd[c] * td[ix]) - return new - else: - raise ValueError("Point-wise multiplication only allowed " - "with another lil_matrix.") - def copy(self): new = lil_matrix(self.shape, dtype=self.dtype) new.data = copy.deepcopy(self.data) Modified: trunk/scipy/sparse/sparsetools/bsr.py =================================================================== --- trunk/scipy/sparse/sparsetools/bsr.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/bsr.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -51,441 +51,442 @@ def bsr_diagonal(*args): + """ + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Yx) """ - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Yx) - """ - return _bsr.bsr_diagonal(*args) + return _bsr.bsr_diagonal(*args) def bsr_scale_rows(*args): + """ + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) """ - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) - """ - return _bsr.bsr_scale_rows(*args) + return _bsr.bsr_scale_rows(*args) def bsr_scale_columns(*args): + """ + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) """ - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) - """ - return _bsr.bsr_scale_columns(*args) + return _bsr.bsr_scale_columns(*args) def bsr_transpose(*args): + """ + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx) """ - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx) - """ - return _bsr.bsr_transpose(*args) + return _bsr.bsr_transpose(*args) def bsr_matmat_pass2(*args): + """ + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, short Ax, int Bp, int Bj, short Bx, + int Cp, int Cj, short Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned short Ax, int Bp, int Bj, + unsigned short Bx, int Cp, int Cj, unsigned short Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, int Ax, int Bp, int Bj, int Bx, int Cp, + int Cj, int Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned long long Ax, int Bp, int Bj, + unsigned long long Bx, int Cp, int Cj, unsigned long long Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, float Ax, int Bp, int Bj, float Bx, + int Cp, int Cj, float Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, double Ax, int Bp, int Bj, double Bx, + int Cp, int Cj, double Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, npy_cfloat_wrapper Ax, int Bp, int Bj, + npy_cfloat_wrapper Bx, int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, npy_cdouble_wrapper Ax, int Bp, int Bj, + npy_cdouble_wrapper Bx, int Cp, int Cj, + npy_cdouble_wrapper Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, npy_clongdouble_wrapper Ax, int Bp, + int Bj, npy_clongdouble_wrapper Bx, int Cp, + int Cj, npy_clongdouble_wrapper Cx) """ - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, short Ax, int Bp, int Bj, short Bx, - int Cp, int Cj, short Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned short Ax, int Bp, int Bj, - unsigned short Bx, int Cp, int Cj, unsigned short Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, int Ax, int Bp, int Bj, int Bx, int Cp, - int Cj, int Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned long long Ax, int Bp, int Bj, - unsigned long long Bx, int Cp, int Cj, unsigned long long Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, float Ax, int Bp, int Bj, float Bx, - int Cp, int Cj, float Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, double Ax, int Bp, int Bj, double Bx, - int Cp, int Cj, double Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, npy_cfloat_wrapper Ax, int Bp, int Bj, - npy_cfloat_wrapper Bx, int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, npy_cdouble_wrapper Ax, int Bp, int Bj, - npy_cdouble_wrapper Bx, int Cp, int Cj, - npy_cdouble_wrapper Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, npy_clongdouble_wrapper Ax, int Bp, - int Bj, npy_clongdouble_wrapper Bx, int Cp, - int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_matmat_pass2(*args) + return _bsr.bsr_matmat_pass2(*args) def bsr_matvec(*args): + """ + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Xx, signed char Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Xx, unsigned char Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Xx, short Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Xx, unsigned short Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Xx, int Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Xx, unsigned int Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Xx, long long Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Xx, + unsigned long long Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Xx, float Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Xx, double Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Xx, long double Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) """ - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Xx, signed char Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Xx, unsigned char Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Xx, short Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Xx, unsigned short Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Xx, int Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Xx, unsigned int Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Xx, long long Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Xx, - unsigned long long Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Xx, float Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Xx, double Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Xx, long double Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - npy_cfloat_wrapper Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - npy_cdouble_wrapper Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, - npy_clongdouble_wrapper Yx) - """ - return _bsr.bsr_matvec(*args) + return _bsr.bsr_matvec(*args) def bsr_elmul_bsr(*args): + """ + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_elmul_bsr(*args) + return _bsr.bsr_elmul_bsr(*args) def bsr_eldiv_bsr(*args): + """ + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_eldiv_bsr(*args) + return _bsr.bsr_eldiv_bsr(*args) def bsr_plus_bsr(*args): + """ + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_plus_bsr(*args) + return _bsr.bsr_plus_bsr(*args) def bsr_minus_bsr(*args): + """ + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_minus_bsr(*args) + return _bsr.bsr_minus_bsr(*args) def bsr_sort_indices(*args): + """ + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax) """ - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax) - """ - return _bsr.bsr_sort_indices(*args) + return _bsr.bsr_sort_indices(*args) + Modified: trunk/scipy/sparse/sparsetools/bsr_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-05-21 22:52:19 UTC (rev 4377) @@ -36966,3 +36966,4 @@ } + Modified: trunk/scipy/sparse/sparsetools/complex_ops.h =================================================================== --- trunk/scipy/sparse/sparsetools/complex_ops.h 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/complex_ops.h 2008-05-21 22:52:19 UTC (rev 4377) @@ -34,8 +34,8 @@ complex_wrapper operator/(const complex_wrapper& B) const { complex_wrapper result; c_type denom = 1.0 / (B.real * B.real + B.imag * B.imag); - result.real = (npy_type::real * npy_type::real + npy_type::imag * B.imag) * denom; - result.imag = (npy_type::real * npy_type::imag - npy_type::imag * B.real) * denom; + result.real = (npy_type::real * B.real + npy_type::imag * B.imag) * denom; + result.imag = (npy_type::imag * B.real - npy_type::real * B.imag) * denom; return result; } complex_wrapper& operator+=(const complex_wrapper & B){ @@ -57,7 +57,7 @@ complex_wrapper& operator/=(const complex_wrapper & B){ c_type denom = 1.0 / (B.real * B.real + B.imag * B.imag); c_type temp = (npy_type::real * B.real + npy_type::imag * B.imag) * denom; - npy_type::imag = (npy_type::real * B.imag - npy_type::imag * B.real) * denom; + npy_type::imag = (npy_type::imag * B.real - npy_type::real * B.imag) * denom; npy_type::real = temp; return (*this); } Modified: trunk/scipy/sparse/sparsetools/coo.py =================================================================== --- trunk/scipy/sparse/sparsetools/coo.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/coo.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -51,100 +51,101 @@ def coo_tocsr(*args): + """ + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, + int Bp, int Bj, short Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, + int Bp, int Bj, int Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, + int Bp, int Bj, long long Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, + int Bp, int Bj, float Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, + int Bp, int Bj, double Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, + int Bp, int Bj, long double Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx) """ - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, - int Bp, int Bj, short Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, - int Bp, int Bj, int Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, - int Bp, int Bj, long long Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, - int Bp, int Bj, float Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, - int Bp, int Bj, double Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, - int Bp, int Bj, long double Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx) - """ - return _coo.coo_tocsr(*args) + return _coo.coo_tocsr(*args) def coo_tocsc(*args): + """ + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, + int Bp, int Bi, signed char Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, + int Bp, int Bi, unsigned char Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, + int Bp, int Bi, short Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, + int Bp, int Bi, unsigned short Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, + int Bp, int Bi, int Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, + int Bp, int Bi, unsigned int Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, + int Bp, int Bi, long long Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, + int Bp, int Bi, float Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, + int Bp, int Bi, double Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, + int Bp, int Bi, long double Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx) """ - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, - int Bp, int Bi, signed char Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, - int Bp, int Bi, unsigned char Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, - int Bp, int Bi, short Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, - int Bp, int Bi, unsigned short Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, - int Bp, int Bi, int Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, - int Bp, int Bi, unsigned int Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, - int Bp, int Bi, long long Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, - int Bp, int Bi, float Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, - int Bp, int Bi, double Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, - int Bp, int Bi, long double Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx) - """ - return _coo.coo_tocsc(*args) + return _coo.coo_tocsc(*args) def coo_todense(*args): + """ + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, + signed char Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, + unsigned char Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, + short Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, + unsigned short Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, + int Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, + unsigned int Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, + long long Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, + unsigned long long Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, + float Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, + double Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, + long double Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Bx) """ - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, - signed char Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, - unsigned char Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, - short Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, - unsigned short Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, - int Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, - unsigned int Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, - long long Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, - unsigned long long Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, - float Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, - double Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, - long double Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Bx) - """ - return _coo.coo_todense(*args) + return _coo.coo_todense(*args) + Modified: trunk/scipy/sparse/sparsetools/coo_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/coo_wrap.cxx 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/coo_wrap.cxx 2008-05-21 22:52:19 UTC (rev 4377) @@ -10815,3 +10815,4 @@ } + Modified: trunk/scipy/sparse/sparsetools/csc.py =================================================================== --- trunk/scipy/sparse/sparsetools/csc.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/csc.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -50,319 +50,320 @@ def csc_matmat_pass1(*args): + """ + csc_matmat_pass1(int n_row, int n_col, int Ap, int Ai, int Bp, int Bi, + int Cp) """ - csc_matmat_pass1(int n_row, int n_col, int Ap, int Ai, int Bp, int Bi, - int Cp) - """ - return _csc.csc_matmat_pass1(*args) + return _csc.csc_matmat_pass1(*args) def csc_diagonal(*args): + """ + csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Yx) """ - csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Yx) - """ - return _csc.csc_diagonal(*args) + return _csc.csc_diagonal(*args) def csc_tocsr(*args): + """ + csc_tocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bj, signed char Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bj, unsigned char Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bj, short Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bj, unsigned short Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bj, int Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bj, unsigned int Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bj, long long Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bj, float Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bj, double Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bj, long double Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx) """ - csc_tocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bj, signed char Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bj, unsigned char Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bj, short Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bj, unsigned short Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bj, int Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bj, unsigned int Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bj, long long Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bj, float Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bj, double Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bj, long double Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx) - """ - return _csc.csc_tocsr(*args) + return _csc.csc_tocsr(*args) def csc_matmat_pass2(*args): + """ + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_matmat_pass2(*args) + return _csc.csc_matmat_pass2(*args) def csc_matvec(*args): + """ + csc_matvec(int n_row, int n_col, int Ap, int Ai, signed char Ax, + signed char Xx, signed char Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + unsigned char Xx, unsigned char Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, + short Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + unsigned short Xx, unsigned short Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, + int Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + unsigned int Xx, unsigned int Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, long long Ax, + long long Xx, long long Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + unsigned long long Xx, unsigned long long Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, + float Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, + double Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, long double Ax, + long double Xx, long double Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) """ - csc_matvec(int n_row, int n_col, int Ap, int Ai, signed char Ax, - signed char Xx, signed char Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - unsigned char Xx, unsigned char Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, - short Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - unsigned short Xx, unsigned short Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, - int Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - unsigned int Xx, unsigned int Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, long long Ax, - long long Xx, long long Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - unsigned long long Xx, unsigned long long Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, - float Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, - double Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, long double Ax, - long double Xx, long double Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) - """ - return _csc.csc_matvec(*args) + return _csc.csc_matvec(*args) def csc_elmul_csc(*args): + """ + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_elmul_csc(*args) + return _csc.csc_elmul_csc(*args) def csc_eldiv_csc(*args): + """ + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_eldiv_csc(*args) + return _csc.csc_eldiv_csc(*args) def csc_plus_csc(*args): + """ + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_plus_csc(*args) + return _csc.csc_plus_csc(*args) def csc_minus_csc(*args): + """ + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_minus_csc(*args) + return _csc.csc_minus_csc(*args) + Modified: trunk/scipy/sparse/sparsetools/csc_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/csc_wrap.cxx 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/csc_wrap.cxx 2008-05-21 22:52:19 UTC (rev 4377) @@ -27099,3 +27099,4 @@ } + Modified: trunk/scipy/sparse/sparsetools/csr.py =================================================================== --- trunk/scipy/sparse/sparsetools/csr.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/csr.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -50,531 +50,532 @@ def expandptr(*args): - """expandptr(int n_row, int Ap, int Bi)""" - return _csr.expandptr(*args) + """expandptr(int n_row, int Ap, int Bi)""" + return _csr.expandptr(*args) def csr_count_blocks(*args): - """csr_count_blocks(int n_row, int n_col, int R, int C, int Ap, int Aj) -> int""" - return _csr.csr_count_blocks(*args) + """csr_count_blocks(int n_row, int n_col, int R, int C, int Ap, int Aj) -> int""" + return _csr.csr_count_blocks(*args) def csr_matmat_pass1(*args): + """ + csr_matmat_pass1(int n_row, int n_col, int Ap, int Aj, int Bp, int Bj, + int Cp) """ - csr_matmat_pass1(int n_row, int n_col, int Ap, int Aj, int Bp, int Bj, - int Cp) - """ - return _csr.csr_matmat_pass1(*args) + return _csr.csr_matmat_pass1(*args) def csr_has_sorted_indices(*args): - """csr_has_sorted_indices(int n_row, int Ap, int Aj) -> bool""" - return _csr.csr_has_sorted_indices(*args) + """csr_has_sorted_indices(int n_row, int Ap, int Aj) -> bool""" + return _csr.csr_has_sorted_indices(*args) def csr_diagonal(*args): + """ + csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Yx) """ - csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Yx) - """ - return _csr.csr_diagonal(*args) + return _csr.csr_diagonal(*args) def csr_scale_rows(*args): + """ + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx) """ - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx) - """ - return _csr.csr_scale_rows(*args) + return _csr.csr_scale_rows(*args) def csr_scale_columns(*args): + """ + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx) """ - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx) - """ - return _csr.csr_scale_columns(*args) + return _csr.csr_scale_columns(*args) def csr_tocsc(*args): + """ + csr_tocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bi, signed char Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bi, unsigned char Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bi, short Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bi, unsigned short Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bi, int Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bi, unsigned int Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bi, long long Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bi, float Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bi, double Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bi, long double Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx) """ - csr_tocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bi, signed char Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bi, unsigned char Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bi, short Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bi, unsigned short Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bi, int Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bi, unsigned int Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bi, long long Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bi, float Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bi, double Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bi, long double Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx) - """ - return _csr.csr_tocsc(*args) + return _csr.csr_tocsc(*args) def csr_tobsr(*args): + """ + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx) """ - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx) - """ - return _csr.csr_tobsr(*args) + return _csr.csr_tobsr(*args) def csr_matmat_pass2(*args): + """ + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_matmat_pass2(*args) + return _csr.csr_matmat_pass2(*args) def csr_matvec(*args): + """ + csr_matvec(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx, signed char Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx, unsigned char Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, + short Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Xx, unsigned short Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, + int Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Xx, unsigned int Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx, long long Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx, unsigned long long Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, + float Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, + double Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx, long double Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) """ - csr_matvec(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx, signed char Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx, unsigned char Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, - short Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Xx, unsigned short Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, - int Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Xx, unsigned int Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx, long long Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Xx, unsigned long long Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, - float Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, - double Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx, long double Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) - """ - return _csr.csr_matvec(*args) + return _csr.csr_matvec(*args) def csr_elmul_csr(*args): + """ + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_elmul_csr(*args) + return _csr.csr_elmul_csr(*args) def csr_eldiv_csr(*args): + """ + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_eldiv_csr(*args) + return _csr.csr_eldiv_csr(*args) def csr_plus_csr(*args): + """ + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_plus_csr(*args) + return _csr.csr_plus_csr(*args) def csr_minus_csr(*args): + """ + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_minus_csr(*args) + return _csr.csr_minus_csr(*args) def csr_sort_indices(*args): + """ + csr_sort_indices(int n_row, int Ap, int Aj, signed char Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned char Ax) + csr_sort_indices(int n_row, int Ap, int Aj, short Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned short Ax) + csr_sort_indices(int n_row, int Ap, int Aj, int Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned int Ax) + csr_sort_indices(int n_row, int Ap, int Aj, long long Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned long long Ax) + csr_sort_indices(int n_row, int Ap, int Aj, float Ax) + csr_sort_indices(int n_row, int Ap, int Aj, double Ax) + csr_sort_indices(int n_row, int Ap, int Aj, long double Ax) + csr_sort_indices(int n_row, int Ap, int Aj, npy_cfloat_wrapper Ax) + csr_sort_indices(int n_row, int Ap, int Aj, npy_cdouble_wrapper Ax) + csr_sort_indices(int n_row, int Ap, int Aj, npy_clongdouble_wrapper Ax) """ - csr_sort_indices(int n_row, int Ap, int Aj, signed char Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned char Ax) - csr_sort_indices(int n_row, int Ap, int Aj, short Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned short Ax) - csr_sort_indices(int n_row, int Ap, int Aj, int Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned int Ax) - csr_sort_indices(int n_row, int Ap, int Aj, long long Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned long long Ax) - csr_sort_indices(int n_row, int Ap, int Aj, float Ax) - csr_sort_indices(int n_row, int Ap, int Aj, double Ax) - csr_sort_indices(int n_row, int Ap, int Aj, long double Ax) - csr_sort_indices(int n_row, int Ap, int Aj, npy_cfloat_wrapper Ax) - csr_sort_indices(int n_row, int Ap, int Aj, npy_cdouble_wrapper Ax) - csr_sort_indices(int n_row, int Ap, int Aj, npy_clongdouble_wrapper Ax) - """ - return _csr.csr_sort_indices(*args) + return _csr.csr_sort_indices(*args) def csr_eliminate_zeros(*args): + """ + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, signed char Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, short Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, int Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long long Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, float Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, double Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long double Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) """ - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, signed char Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, short Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, int Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long long Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, float Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, double Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long double Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) - """ - return _csr.csr_eliminate_zeros(*args) + return _csr.csr_eliminate_zeros(*args) def csr_sum_duplicates(*args): + """ + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long double Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) """ - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long double Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) - """ - return _csr.csr_sum_duplicates(*args) + return _csr.csr_sum_duplicates(*args) def get_csr_submatrix(*args): + """ + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(signed char)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(unsigned char)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, short Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(short)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(unsigned short)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, int Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(int)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(unsigned int)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long long Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(long long)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned long long)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, float Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, double Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long double Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(long double)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_clongdouble_wrapper)> Bx) """ - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(signed char)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(unsigned char)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, short Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(short)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(unsigned short)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, int Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(int)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(unsigned int)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long long Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(long long)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned long long)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, float Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, double Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long double Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(long double)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_clongdouble_wrapper)> Bx) - """ - return _csr.get_csr_submatrix(*args) + return _csr.get_csr_submatrix(*args) + Modified: trunk/scipy/sparse/sparsetools/csr_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/csr_wrap.cxx 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/csr_wrap.cxx 2008-05-21 22:52:19 UTC (rev 4377) @@ -40812,3 +40812,4 @@ } + Modified: trunk/scipy/sparse/sparsetools/dia.py =================================================================== --- trunk/scipy/sparse/sparsetools/dia.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/dia.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -51,39 +51,40 @@ def dia_matvec(*args): + """ + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + signed char diags, signed char Xx, signed char Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned char diags, unsigned char Xx, unsigned char Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + short diags, short Xx, short Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned short diags, unsigned short Xx, + unsigned short Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + int diags, int Xx, int Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned int diags, unsigned int Xx, unsigned int Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + long long diags, long long Xx, long long Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned long long diags, unsigned long long Xx, + unsigned long long Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + float diags, float Xx, float Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + double diags, double Xx, double Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + long double diags, long double Xx, long double Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + npy_cfloat_wrapper diags, npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + npy_cdouble_wrapper diags, npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + npy_clongdouble_wrapper diags, npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) """ - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - signed char diags, signed char Xx, signed char Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned char diags, unsigned char Xx, unsigned char Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - short diags, short Xx, short Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned short diags, unsigned short Xx, - unsigned short Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - int diags, int Xx, int Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned int diags, unsigned int Xx, unsigned int Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - long long diags, long long Xx, long long Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned long long diags, unsigned long long Xx, - unsigned long long Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - float diags, float Xx, float Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - double diags, double Xx, double Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - long double diags, long double Xx, long double Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - npy_cfloat_wrapper diags, npy_cfloat_wrapper Xx, - npy_cfloat_wrapper Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - npy_cdouble_wrapper diags, npy_cdouble_wrapper Xx, - npy_cdouble_wrapper Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - npy_clongdouble_wrapper diags, npy_clongdouble_wrapper Xx, - npy_clongdouble_wrapper Yx) - """ - return _dia.dia_matvec(*args) + return _dia.dia_matvec(*args) + Modified: trunk/scipy/sparse/sparsetools/dia_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/dia_wrap.cxx 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/sparsetools/dia_wrap.cxx 2008-05-21 22:52:19 UTC (rev 4377) @@ -5992,3 +5992,4 @@ } + Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-05-18 11:01:08 UTC (rev 4376) +++ trunk/scipy/sparse/tests/test_base.py 2008-05-21 22:52:19 UTC (rev 4377) @@ -221,6 +221,13 @@ c = temp.multiply(self.datsp) assert_array_equal(c.todense(),[[1,0,0,4],[9,0,1,0],[0,4,0,0]]) + # complex + A = array([[1-2j,0+5j,-1+0j],[4-3j,-3+6j,5]]) + B = array([[5+2j,7-3j,-2+1j],[0-1j,-4+2j,9]]) + Asp = self.spmatrix(A) + Bsp = self.spmatrix(B) + assert_almost_equal( Asp.multiply(Bsp).todense(), A*B) + def test_eldiv(self): expected = [[1,0,0,1],[1,0,1,0],[0,1,0,0]] assert_array_equal((self.datsp / self.datsp).todense(),expected) @@ -229,6 +236,13 @@ res = matrix([[1,0,0,0.5],[-3,0,numpy.inf,0],[0,0.25,0,0]],'d') assert_array_equal((self.datsp / denom).todense(),res) + # complex + A = array([[1-2j,0+5j,-1+0j],[4-3j,-3+6j,5]]) + B = array([[5+2j,7-3j,-2+1j],[0-1j,-4+2j,9]]) + Asp = self.spmatrix(A) + Bsp = self.spmatrix(B) + assert_almost_equal( (Asp / Bsp).todense(), A/B) + def test_pow(self): A = matrix([[1,0,2,0],[0,3,4,0],[0,5,0,0],[0,6,7,8]]) B = self.spmatrix( A ) From scipy-svn at scipy.org Thu May 22 02:01:16 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 22 May 2008 01:01:16 -0500 (CDT) Subject: [Scipy-svn] r4378 - trunk/scipy/sparse/sparsetools Message-ID: <20080522060116.0676139C5DC@scipy.org> Author: wnbell Date: 2008-05-22 01:01:12 -0500 (Thu, 22 May 2008) New Revision: 4378 Modified: trunk/scipy/sparse/sparsetools/numpy.i Log: add parens to make icc happy Modified: trunk/scipy/sparse/sparsetools/numpy.i =================================================================== --- trunk/scipy/sparse/sparsetools/numpy.i 2008-05-21 22:52:19 UTC (rev 4377) +++ trunk/scipy/sparse/sparsetools/numpy.i 2008-05-22 06:01:12 UTC (rev 4378) @@ -383,7 +383,7 @@ $1 = (type*) array->data; } %typemap(freearg) type* IN_ARRAY1 { - if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); + if (is_new_object$argnum && array$argnum) { Py_DECREF(array$argnum); } } %enddef @@ -401,7 +401,7 @@ $1 = (type*) array->data; } %typemap(freearg) (type* IN_ARRAY2) { - if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); + if (is_new_object$argnum && array$argnum) { Py_DECREF(array$argnum); } } %enddef From scipy-svn at scipy.org Sat May 24 06:45:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 05:45:18 -0500 (CDT) Subject: [Scipy-svn] r4379 - in branches/refactor_fft: . scipy/sparse scipy/sparse/sparsetools scipy/sparse/tests Message-ID: <20080524104518.5AD9439C0EE@scipy.org> Author: cdavid Date: 2008-05-24 05:44:59 -0500 (Sat, 24 May 2008) New Revision: 4379 Modified: branches/refactor_fft/ branches/refactor_fft/scipy/sparse/lil.py branches/refactor_fft/scipy/sparse/sparsetools/bsr.py branches/refactor_fft/scipy/sparse/sparsetools/bsr_wrap.cxx branches/refactor_fft/scipy/sparse/sparsetools/complex_ops.h branches/refactor_fft/scipy/sparse/sparsetools/coo.py branches/refactor_fft/scipy/sparse/sparsetools/coo_wrap.cxx branches/refactor_fft/scipy/sparse/sparsetools/csc.py branches/refactor_fft/scipy/sparse/sparsetools/csc_wrap.cxx branches/refactor_fft/scipy/sparse/sparsetools/csr.py branches/refactor_fft/scipy/sparse/sparsetools/csr_wrap.cxx branches/refactor_fft/scipy/sparse/sparsetools/dia.py branches/refactor_fft/scipy/sparse/sparsetools/dia_wrap.cxx branches/refactor_fft/scipy/sparse/sparsetools/numpy.i branches/refactor_fft/scipy/sparse/tests/test_base.py Log: Merged revisions 4369-4378 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r4377 | wnbell | 2008-05-22 07:52:19 +0900 (Thu, 22 May 2008) | 2 lines resolves ticket #671, division error in complex_ops.h ........ r4378 | wnbell | 2008-05-22 15:01:12 +0900 (Thu, 22 May 2008) | 2 lines add parens to make icc happy ........ Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4368 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4378 Modified: branches/refactor_fft/scipy/sparse/lil.py =================================================================== --- branches/refactor_fft/scipy/sparse/lil.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/lil.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -346,38 +346,39 @@ else: return self.tocsr() / other - def multiply(self, other): - """Point-wise multiplication by another lil_matrix. +## This code doesn't work with complex matrices +# def multiply(self, other): +# """Point-wise multiplication by another lil_matrix. +# +# """ +# if isscalar(other): +# return self.__mul__(other) +# +# if isspmatrix_lil(other): +# reference,target = self,other +# +# if reference.shape != target.shape: +# raise ValueError("Dimensions do not match.") +# +# if len(reference.data) > len(target.data): +# reference,target = target,reference +# +# new = lil_matrix(reference.shape) +# for r,row in enumerate(reference.rows): +# tr = target.rows[r] +# td = target.data[r] +# rd = reference.data[r] +# L = len(tr) +# for c,column in enumerate(row): +# ix = bisect_left(tr,column) +# if ix < L and tr[ix] == column: +# new.rows[r].append(column) +# new.data[r].append(rd[c] * td[ix]) +# return new +# else: +# raise ValueError("Point-wise multiplication only allowed " +# "with another lil_matrix.") - """ - if isscalar(other): - return self.__mul__(other) - - if isspmatrix_lil(other): - reference,target = self,other - - if reference.shape != target.shape: - raise ValueError("Dimensions do not match.") - - if len(reference.data) > len(target.data): - reference,target = target,reference - - new = lil_matrix(reference.shape) - for r,row in enumerate(reference.rows): - tr = target.rows[r] - td = target.data[r] - rd = reference.data[r] - L = len(tr) - for c,column in enumerate(row): - ix = bisect_left(tr,column) - if ix < L and tr[ix] == column: - new.rows[r].append(column) - new.data[r].append(rd[c] * td[ix]) - return new - else: - raise ValueError("Point-wise multiplication only allowed " - "with another lil_matrix.") - def copy(self): new = lil_matrix(self.shape, dtype=self.dtype) new.data = copy.deepcopy(self.data) Modified: branches/refactor_fft/scipy/sparse/sparsetools/bsr.py =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/bsr.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/bsr.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -51,441 +51,442 @@ def bsr_diagonal(*args): + """ + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Yx) + bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Yx) """ - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Yx) - bsr_diagonal(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Yx) - """ - return _bsr.bsr_diagonal(*args) + return _bsr.bsr_diagonal(*args) def bsr_scale_rows(*args): + """ + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) + bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) """ - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) - bsr_scale_rows(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) - """ - return _bsr.bsr_scale_rows(*args) + return _bsr.bsr_scale_rows(*args) def bsr_scale_columns(*args): + """ + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) + bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) """ - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx) - bsr_scale_columns(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx) - """ - return _bsr.bsr_scale_columns(*args) + return _bsr.bsr_scale_columns(*args) def bsr_transpose(*args): + """ + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) + bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx) """ - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) - bsr_transpose(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx) - """ - return _bsr.bsr_transpose(*args) + return _bsr.bsr_transpose(*args) def bsr_matmat_pass2(*args): + """ + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, short Ax, int Bp, int Bj, short Bx, + int Cp, int Cj, short Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned short Ax, int Bp, int Bj, + unsigned short Bx, int Cp, int Cj, unsigned short Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, int Ax, int Bp, int Bj, int Bx, int Cp, + int Cj, int Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, unsigned long long Ax, int Bp, int Bj, + unsigned long long Bx, int Cp, int Cj, unsigned long long Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, float Ax, int Bp, int Bj, float Bx, + int Cp, int Cj, float Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, double Ax, int Bp, int Bj, double Bx, + int Cp, int Cj, double Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, npy_cfloat_wrapper Ax, int Bp, int Bj, + npy_cfloat_wrapper Bx, int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, npy_cdouble_wrapper Ax, int Bp, int Bj, + npy_cdouble_wrapper Bx, int Cp, int Cj, + npy_cdouble_wrapper Cx) + bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, + int Aj, npy_clongdouble_wrapper Ax, int Bp, + int Bj, npy_clongdouble_wrapper Bx, int Cp, + int Cj, npy_clongdouble_wrapper Cx) """ - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, short Ax, int Bp, int Bj, short Bx, - int Cp, int Cj, short Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned short Ax, int Bp, int Bj, - unsigned short Bx, int Cp, int Cj, unsigned short Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, int Ax, int Bp, int Bj, int Bx, int Cp, - int Cj, int Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, unsigned long long Ax, int Bp, int Bj, - unsigned long long Bx, int Cp, int Cj, unsigned long long Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, float Ax, int Bp, int Bj, float Bx, - int Cp, int Cj, float Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, double Ax, int Bp, int Bj, double Bx, - int Cp, int Cj, double Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, npy_cfloat_wrapper Ax, int Bp, int Bj, - npy_cfloat_wrapper Bx, int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, npy_cdouble_wrapper Ax, int Bp, int Bj, - npy_cdouble_wrapper Bx, int Cp, int Cj, - npy_cdouble_wrapper Cx) - bsr_matmat_pass2(int n_brow, int n_bcol, int R, int C, int N, int Ap, - int Aj, npy_clongdouble_wrapper Ax, int Bp, - int Bj, npy_clongdouble_wrapper Bx, int Cp, - int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_matmat_pass2(*args) + return _bsr.bsr_matmat_pass2(*args) def bsr_matvec(*args): + """ + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax, signed char Xx, signed char Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax, unsigned char Xx, unsigned char Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax, short Xx, short Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax, unsigned short Xx, unsigned short Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax, int Xx, int Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax, unsigned int Xx, unsigned int Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax, long long Xx, long long Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax, unsigned long long Xx, + unsigned long long Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax, float Xx, float Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax, double Xx, double Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax, long double Xx, long double Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) """ - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax, signed char Xx, signed char Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax, unsigned char Xx, unsigned char Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax, short Xx, short Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax, unsigned short Xx, unsigned short Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax, int Xx, int Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax, unsigned int Xx, unsigned int Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax, long long Xx, long long Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax, unsigned long long Xx, - unsigned long long Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax, float Xx, float Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax, double Xx, double Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax, long double Xx, long double Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - npy_cfloat_wrapper Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - npy_cdouble_wrapper Yx) - bsr_matvec(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, - npy_clongdouble_wrapper Yx) - """ - return _bsr.bsr_matvec(*args) + return _bsr.bsr_matvec(*args) def bsr_elmul_bsr(*args): + """ + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_elmul_bsr(*args) + return _bsr.bsr_elmul_bsr(*args) def bsr_eldiv_bsr(*args): + """ + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_eldiv_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_eldiv_bsr(*args) + return _bsr.bsr_eldiv_bsr(*args) def bsr_plus_bsr(*args): + """ + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_plus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_plus_bsr(*args) + return _bsr.bsr_plus_bsr(*args) def bsr_minus_bsr(*args): + """ + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx, + int Cp, int Cj, signed char Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx, + int Cp, int Cj, unsigned char Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx, int Cp, + int Cj, short Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx, + int Cp, int Cj, unsigned short Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, + int Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx, + int Cp, int Cj, unsigned int Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx, + int Cp, int Cj, long long Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx, int Cp, + int Cj, float Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx, int Cp, + int Cj, double Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx, + int Cp, int Cj, long double Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx, - int Cp, int Cj, signed char Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx, - int Cp, int Cj, unsigned char Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx, int Cp, - int Cj, short Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx, - int Cp, int Cj, unsigned short Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx, int Cp, int Cj, - int Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx, - int Cp, int Cj, unsigned int Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx, - int Cp, int Cj, long long Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx, int Cp, - int Cj, float Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx, int Cp, - int Cj, double Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx, - int Cp, int Cj, long double Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - bsr_minus_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx, int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _bsr.bsr_minus_bsr(*args) + return _bsr.bsr_minus_bsr(*args) def bsr_sort_indices(*args): + """ + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + signed char Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned char Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + short Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned short Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + int Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned int Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long long Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + unsigned long long Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + float Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + double Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + long double Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax) + bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax) """ - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - signed char Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned char Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - short Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned short Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - int Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned int Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long long Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - unsigned long long Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - float Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - double Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - long double Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax) - bsr_sort_indices(int n_brow, int n_bcol, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax) - """ - return _bsr.bsr_sort_indices(*args) + return _bsr.bsr_sort_indices(*args) + Modified: branches/refactor_fft/scipy/sparse/sparsetools/bsr_wrap.cxx =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-05-24 10:44:59 UTC (rev 4379) @@ -36966,3 +36966,4 @@ } + Modified: branches/refactor_fft/scipy/sparse/sparsetools/complex_ops.h =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/complex_ops.h 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/complex_ops.h 2008-05-24 10:44:59 UTC (rev 4379) @@ -34,8 +34,8 @@ complex_wrapper operator/(const complex_wrapper& B) const { complex_wrapper result; c_type denom = 1.0 / (B.real * B.real + B.imag * B.imag); - result.real = (npy_type::real * npy_type::real + npy_type::imag * B.imag) * denom; - result.imag = (npy_type::real * npy_type::imag - npy_type::imag * B.real) * denom; + result.real = (npy_type::real * B.real + npy_type::imag * B.imag) * denom; + result.imag = (npy_type::imag * B.real - npy_type::real * B.imag) * denom; return result; } complex_wrapper& operator+=(const complex_wrapper & B){ @@ -57,7 +57,7 @@ complex_wrapper& operator/=(const complex_wrapper & B){ c_type denom = 1.0 / (B.real * B.real + B.imag * B.imag); c_type temp = (npy_type::real * B.real + npy_type::imag * B.imag) * denom; - npy_type::imag = (npy_type::real * B.imag - npy_type::imag * B.real) * denom; + npy_type::imag = (npy_type::imag * B.real - npy_type::real * B.imag) * denom; npy_type::real = temp; return (*this); } Modified: branches/refactor_fft/scipy/sparse/sparsetools/coo.py =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/coo.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/coo.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -51,100 +51,101 @@ def coo_tocsr(*args): + """ + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, + int Bp, int Bj, short Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, + int Bp, int Bj, int Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, + int Bp, int Bj, long long Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, + int Bp, int Bj, float Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, + int Bp, int Bj, double Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, + int Bp, int Bj, long double Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx) + coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx) """ - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, - int Bp, int Bj, short Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, - int Bp, int Bj, int Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, - int Bp, int Bj, long long Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, - int Bp, int Bj, float Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, - int Bp, int Bj, double Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, - int Bp, int Bj, long double Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx) - coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx) - """ - return _coo.coo_tocsr(*args) + return _coo.coo_tocsr(*args) def coo_tocsc(*args): + """ + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, + int Bp, int Bi, signed char Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, + int Bp, int Bi, unsigned char Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, + int Bp, int Bi, short Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, + int Bp, int Bi, unsigned short Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, + int Bp, int Bi, int Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, + int Bp, int Bi, unsigned int Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, + int Bp, int Bi, long long Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, + int Bp, int Bi, float Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, + int Bp, int Bi, double Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, + int Bp, int Bi, long double Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx) + coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx) """ - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, - int Bp, int Bi, signed char Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, - int Bp, int Bi, unsigned char Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, - int Bp, int Bi, short Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, - int Bp, int Bi, unsigned short Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, - int Bp, int Bi, int Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, - int Bp, int Bi, unsigned int Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, - int Bp, int Bi, long long Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, - int Bp, int Bi, float Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, - int Bp, int Bi, double Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, - int Bp, int Bi, long double Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx) - coo_tocsc(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx) - """ - return _coo.coo_tocsc(*args) + return _coo.coo_tocsc(*args) def coo_todense(*args): + """ + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, + signed char Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, + unsigned char Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, + short Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, + unsigned short Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, + int Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, + unsigned int Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, + long long Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, + unsigned long long Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, + float Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, + double Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, + long double Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Bx) + coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Bx) """ - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, - signed char Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned char Ax, - unsigned char Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, short Ax, - short Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned short Ax, - unsigned short Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, int Ax, - int Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned int Ax, - unsigned int Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long long Ax, - long long Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, unsigned long long Ax, - unsigned long long Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, float Ax, - float Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, double Ax, - double Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, long double Ax, - long double Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Bx) - coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Bx) - """ - return _coo.coo_todense(*args) + return _coo.coo_todense(*args) + Modified: branches/refactor_fft/scipy/sparse/sparsetools/coo_wrap.cxx =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/coo_wrap.cxx 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/coo_wrap.cxx 2008-05-24 10:44:59 UTC (rev 4379) @@ -10815,3 +10815,4 @@ } + Modified: branches/refactor_fft/scipy/sparse/sparsetools/csc.py =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/csc.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/csc.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -50,319 +50,320 @@ def csc_matmat_pass1(*args): + """ + csc_matmat_pass1(int n_row, int n_col, int Ap, int Ai, int Bp, int Bi, + int Cp) """ - csc_matmat_pass1(int n_row, int n_col, int Ap, int Ai, int Bp, int Bi, - int Cp) - """ - return _csc.csc_matmat_pass1(*args) + return _csc.csc_matmat_pass1(*args) def csc_diagonal(*args): + """ + csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Yx) + csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Yx) """ - csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Yx) - csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Yx) - """ - return _csc.csc_diagonal(*args) + return _csc.csc_diagonal(*args) def csc_tocsr(*args): + """ + csc_tocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bj, signed char Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bj, unsigned char Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bj, short Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bj, unsigned short Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bj, int Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bj, unsigned int Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bj, long long Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bj, float Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bj, double Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bj, long double Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx) + csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx) """ - csc_tocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bj, signed char Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bj, unsigned char Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bj, short Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bj, unsigned short Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bj, int Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bj, unsigned int Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bj, long long Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bj, float Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bj, double Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bj, long double Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx) - csc_tocsr(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx) - """ - return _csc.csc_tocsr(*args) + return _csc.csc_tocsr(*args) def csc_matmat_pass2(*args): + """ + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_matmat_pass2(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_matmat_pass2(*args) + return _csc.csc_matmat_pass2(*args) def csc_matvec(*args): + """ + csc_matvec(int n_row, int n_col, int Ap, int Ai, signed char Ax, + signed char Xx, signed char Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + unsigned char Xx, unsigned char Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, + short Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + unsigned short Xx, unsigned short Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, + int Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + unsigned int Xx, unsigned int Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, long long Ax, + long long Xx, long long Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + unsigned long long Xx, unsigned long long Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, + float Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, + double Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, long double Ax, + long double Xx, long double Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) + csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) """ - csc_matvec(int n_row, int n_col, int Ap, int Ai, signed char Ax, - signed char Xx, signed char Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - unsigned char Xx, unsigned char Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, - short Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - unsigned short Xx, unsigned short Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, - int Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - unsigned int Xx, unsigned int Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, long long Ax, - long long Xx, long long Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - unsigned long long Xx, unsigned long long Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, - float Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, - double Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, long double Ax, - long double Xx, long double Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) - csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) - """ - return _csc.csc_matvec(*args) + return _csc.csc_matvec(*args) def csc_elmul_csc(*args): + """ + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_elmul_csc(*args) + return _csc.csc_elmul_csc(*args) def csc_eldiv_csc(*args): + """ + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_eldiv_csc(*args) + return _csc.csc_eldiv_csc(*args) def csc_plus_csc(*args): + """ + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_plus_csc(*args) + return _csc.csc_plus_csc(*args) def csc_minus_csc(*args): + """ + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, int Cp, int Ci, + signed char Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, int Cp, + int Ci, unsigned char Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, int Cp, int Ci, short Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, + int Bp, int Bi, unsigned short Bx, int Cp, + int Ci, unsigned short Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, int Cp, int Ci, int Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, + int Bp, int Bi, unsigned int Bx, int Cp, + int Ci, unsigned int Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, int Cp, int Ci, + long long Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx, + int Cp, int Ci, unsigned long long Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, int Cp, int Ci, float Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, int Cp, int Ci, double Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, int Cp, int Ci, + long double Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + int Cp, int Ci, npy_cfloat_wrapper Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + int Cp, int Ci, npy_cdouble_wrapper Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx, + int Cp, int Ci, npy_clongdouble_wrapper Cx) """ - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, int Cp, int Ci, - signed char Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, int Cp, - int Ci, unsigned char Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, int Cp, int Ci, short Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned short Ax, - int Bp, int Bi, unsigned short Bx, int Cp, - int Ci, unsigned short Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, int Cp, int Ci, int Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned int Ax, - int Bp, int Bi, unsigned int Bx, int Cp, - int Ci, unsigned int Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, int Cp, int Ci, - long long Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx, - int Cp, int Ci, unsigned long long Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, int Cp, int Ci, float Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, int Cp, int Ci, double Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, int Cp, int Ci, - long double Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - int Cp, int Ci, npy_cfloat_wrapper Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - int Cp, int Ci, npy_cdouble_wrapper Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx, - int Cp, int Ci, npy_clongdouble_wrapper Cx) - """ - return _csc.csc_minus_csc(*args) + return _csc.csc_minus_csc(*args) + Modified: branches/refactor_fft/scipy/sparse/sparsetools/csc_wrap.cxx =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/csc_wrap.cxx 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/csc_wrap.cxx 2008-05-24 10:44:59 UTC (rev 4379) @@ -27099,3 +27099,4 @@ } + Modified: branches/refactor_fft/scipy/sparse/sparsetools/csr.py =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/csr.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/csr.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -50,531 +50,532 @@ def expandptr(*args): - """expandptr(int n_row, int Ap, int Bi)""" - return _csr.expandptr(*args) + """expandptr(int n_row, int Ap, int Bi)""" + return _csr.expandptr(*args) def csr_count_blocks(*args): - """csr_count_blocks(int n_row, int n_col, int R, int C, int Ap, int Aj) -> int""" - return _csr.csr_count_blocks(*args) + """csr_count_blocks(int n_row, int n_col, int R, int C, int Ap, int Aj) -> int""" + return _csr.csr_count_blocks(*args) def csr_matmat_pass1(*args): + """ + csr_matmat_pass1(int n_row, int n_col, int Ap, int Aj, int Bp, int Bj, + int Cp) """ - csr_matmat_pass1(int n_row, int n_col, int Ap, int Aj, int Bp, int Bj, - int Cp) - """ - return _csr.csr_matmat_pass1(*args) + return _csr.csr_matmat_pass1(*args) def csr_has_sorted_indices(*args): - """csr_has_sorted_indices(int n_row, int Ap, int Aj) -> bool""" - return _csr.csr_has_sorted_indices(*args) + """csr_has_sorted_indices(int n_row, int Ap, int Aj) -> bool""" + return _csr.csr_has_sorted_indices(*args) def csr_diagonal(*args): + """ + csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Yx) + csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Yx) """ - csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, short Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, int Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, float Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, double Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Yx) - csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Yx) - """ - return _csr.csr_diagonal(*args) + return _csr.csr_diagonal(*args) def csr_scale_rows(*args): + """ + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx) + csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx) """ - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx) - csr_scale_rows(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx) - """ - return _csr.csr_scale_rows(*args) + return _csr.csr_scale_rows(*args) def csr_scale_columns(*args): + """ + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx) + csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx) """ - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx) - csr_scale_columns(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx) - """ - return _csr.csr_scale_columns(*args) + return _csr.csr_scale_columns(*args) def csr_tocsc(*args): + """ + csr_tocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bi, signed char Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bi, unsigned char Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bi, short Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bi, unsigned short Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bi, int Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bi, unsigned int Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bi, long long Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bi, unsigned long long Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bi, float Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bi, double Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bi, long double Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx) + csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bi, npy_clongdouble_wrapper Bx) """ - csr_tocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bi, signed char Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bi, unsigned char Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bi, short Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bi, unsigned short Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bi, int Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bi, unsigned int Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bi, long long Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bi, unsigned long long Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bi, float Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bi, double Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bi, long double Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx) - csr_tocsc(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bi, npy_clongdouble_wrapper Bx) - """ - return _csr.csr_tocsc(*args) + return _csr.csr_tocsc(*args) def csr_tobsr(*args): + """ + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + signed char Ax, int Bp, int Bj, signed char Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned char Ax, int Bp, int Bj, unsigned char Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + short Ax, int Bp, int Bj, short Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned short Ax, int Bp, int Bj, unsigned short Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + int Ax, int Bp, int Bj, int Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned int Ax, int Bp, int Bj, unsigned int Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long long Ax, int Bp, int Bj, long long Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + float Ax, int Bp, int Bj, float Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + double Ax, int Bp, int Bj, double Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + long double Ax, int Bp, int Bj, long double Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) + csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, + npy_clongdouble_wrapper Ax, int Bp, int Bj, + npy_clongdouble_wrapper Bx) """ - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - signed char Ax, int Bp, int Bj, signed char Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned char Ax, int Bp, int Bj, unsigned char Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - short Ax, int Bp, int Bj, short Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned short Ax, int Bp, int Bj, unsigned short Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - int Ax, int Bp, int Bj, int Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned int Ax, int Bp, int Bj, unsigned int Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long long Ax, int Bp, int Bj, long long Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - unsigned long long Ax, int Bp, int Bj, unsigned long long Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - float Ax, int Bp, int Bj, float Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - double Ax, int Bp, int Bj, double Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - long double Ax, int Bp, int Bj, long double Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cfloat_wrapper Ax, int Bp, int Bj, npy_cfloat_wrapper Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_cdouble_wrapper Ax, int Bp, int Bj, npy_cdouble_wrapper Bx) - csr_tobsr(int n_row, int n_col, int R, int C, int Ap, int Aj, - npy_clongdouble_wrapper Ax, int Bp, int Bj, - npy_clongdouble_wrapper Bx) - """ - return _csr.csr_tobsr(*args) + return _csr.csr_tobsr(*args) def csr_matmat_pass2(*args): + """ + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_matmat_pass2(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_matmat_pass2(*args) + return _csr.csr_matmat_pass2(*args) def csr_matvec(*args): + """ + csr_matvec(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx, signed char Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx, unsigned char Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, + short Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + unsigned short Xx, unsigned short Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, + int Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + unsigned int Xx, unsigned int Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx, long long Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx, unsigned long long Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, + float Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, + double Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx, long double Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) + csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) """ - csr_matvec(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx, signed char Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx, unsigned char Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, - short Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - unsigned short Xx, unsigned short Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, - int Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - unsigned int Xx, unsigned int Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx, long long Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - unsigned long long Xx, unsigned long long Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, - float Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, - double Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx, long double Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, npy_cfloat_wrapper Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, npy_cdouble_wrapper Yx) - csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) - """ - return _csr.csr_matvec(*args) + return _csr.csr_matvec(*args) def csr_elmul_csr(*args): + """ + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_elmul_csr(*args) + return _csr.csr_elmul_csr(*args) def csr_eldiv_csr(*args): + """ + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_eldiv_csr(*args) + return _csr.csr_eldiv_csr(*args) def csr_plus_csr(*args): + """ + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_plus_csr(*args) + return _csr.csr_plus_csr(*args) def csr_minus_csr(*args): + """ + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, int Cp, int Cj, + signed char Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, int Cp, + int Cj, unsigned char Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, int Cp, int Cj, short Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int Bp, int Bj, unsigned short Bx, int Cp, + int Cj, unsigned short Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, int Cp, int Cj, int Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int Bp, int Bj, unsigned int Bx, int Cp, + int Cj, unsigned int Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, int Cp, int Cj, + long long Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int Bp, int Bj, unsigned long long Bx, + int Cp, int Cj, unsigned long long Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, int Cp, int Cj, float Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, int Cp, int Cj, double Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, int Cp, int Cj, + long double Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + int Cp, int Cj, npy_cfloat_wrapper Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + int Cp, int Cj, npy_cdouble_wrapper Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int Bp, int Bj, npy_clongdouble_wrapper Bx, + int Cp, int Cj, npy_clongdouble_wrapper Cx) """ - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, int Cp, int Cj, - signed char Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, int Cp, - int Cj, unsigned char Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, int Cp, int Cj, short Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int Bp, int Bj, unsigned short Bx, int Cp, - int Cj, unsigned short Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, int Cp, int Cj, int Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int Bp, int Bj, unsigned int Bx, int Cp, - int Cj, unsigned int Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, int Cp, int Cj, - long long Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int Bp, int Bj, unsigned long long Bx, - int Cp, int Cj, unsigned long long Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, int Cp, int Cj, float Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, int Cp, int Cj, double Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, int Cp, int Cj, - long double Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - int Cp, int Cj, npy_cfloat_wrapper Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - int Cp, int Cj, npy_cdouble_wrapper Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int Bp, int Bj, npy_clongdouble_wrapper Bx, - int Cp, int Cj, npy_clongdouble_wrapper Cx) - """ - return _csr.csr_minus_csr(*args) + return _csr.csr_minus_csr(*args) def csr_sort_indices(*args): + """ + csr_sort_indices(int n_row, int Ap, int Aj, signed char Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned char Ax) + csr_sort_indices(int n_row, int Ap, int Aj, short Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned short Ax) + csr_sort_indices(int n_row, int Ap, int Aj, int Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned int Ax) + csr_sort_indices(int n_row, int Ap, int Aj, long long Ax) + csr_sort_indices(int n_row, int Ap, int Aj, unsigned long long Ax) + csr_sort_indices(int n_row, int Ap, int Aj, float Ax) + csr_sort_indices(int n_row, int Ap, int Aj, double Ax) + csr_sort_indices(int n_row, int Ap, int Aj, long double Ax) + csr_sort_indices(int n_row, int Ap, int Aj, npy_cfloat_wrapper Ax) + csr_sort_indices(int n_row, int Ap, int Aj, npy_cdouble_wrapper Ax) + csr_sort_indices(int n_row, int Ap, int Aj, npy_clongdouble_wrapper Ax) """ - csr_sort_indices(int n_row, int Ap, int Aj, signed char Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned char Ax) - csr_sort_indices(int n_row, int Ap, int Aj, short Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned short Ax) - csr_sort_indices(int n_row, int Ap, int Aj, int Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned int Ax) - csr_sort_indices(int n_row, int Ap, int Aj, long long Ax) - csr_sort_indices(int n_row, int Ap, int Aj, unsigned long long Ax) - csr_sort_indices(int n_row, int Ap, int Aj, float Ax) - csr_sort_indices(int n_row, int Ap, int Aj, double Ax) - csr_sort_indices(int n_row, int Ap, int Aj, long double Ax) - csr_sort_indices(int n_row, int Ap, int Aj, npy_cfloat_wrapper Ax) - csr_sort_indices(int n_row, int Ap, int Aj, npy_cdouble_wrapper Ax) - csr_sort_indices(int n_row, int Ap, int Aj, npy_clongdouble_wrapper Ax) - """ - return _csr.csr_sort_indices(*args) + return _csr.csr_sort_indices(*args) def csr_eliminate_zeros(*args): + """ + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, signed char Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, short Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, int Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long long Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, float Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, double Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long double Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) """ - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, signed char Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, short Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, int Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long long Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, float Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, double Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, long double Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - csr_eliminate_zeros(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) - """ - return _csr.csr_eliminate_zeros(*args) + return _csr.csr_eliminate_zeros(*args) def csr_sum_duplicates(*args): + """ + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long double Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) """ - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned short Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned int Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, long double Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - csr_sum_duplicates(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax) - """ - return _csr.csr_sum_duplicates(*args) + return _csr.csr_sum_duplicates(*args) def get_csr_submatrix(*args): + """ + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(signed char)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(unsigned char)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, short Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(short)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(unsigned short)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, int Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(int)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(unsigned int)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long long Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(long long)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned long long)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, float Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, double Ax, int ir0, + int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long double Ax, + int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(long double)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, + int ir0, int ir1, int ic0, int ic1, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_clongdouble_wrapper)> Bx) """ - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(signed char)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(unsigned char)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, short Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(short)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned short Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(unsigned short)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, int Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(int)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned int Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(unsigned int)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long long Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(long long)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, unsigned long long Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned long long)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, float Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, double Ax, int ir0, - int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, long double Ax, - int ir0, int ir1, int ic0, int ic1, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(long double)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - get_csr_submatrix(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, - int ir0, int ir1, int ic0, int ic1, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_clongdouble_wrapper)> Bx) - """ - return _csr.get_csr_submatrix(*args) + return _csr.get_csr_submatrix(*args) + Modified: branches/refactor_fft/scipy/sparse/sparsetools/csr_wrap.cxx =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/csr_wrap.cxx 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/csr_wrap.cxx 2008-05-24 10:44:59 UTC (rev 4379) @@ -40812,3 +40812,4 @@ } + Modified: branches/refactor_fft/scipy/sparse/sparsetools/dia.py =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/dia.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/dia.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -51,39 +51,40 @@ def dia_matvec(*args): + """ + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + signed char diags, signed char Xx, signed char Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned char diags, unsigned char Xx, unsigned char Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + short diags, short Xx, short Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned short diags, unsigned short Xx, + unsigned short Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + int diags, int Xx, int Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned int diags, unsigned int Xx, unsigned int Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + long long diags, long long Xx, long long Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + unsigned long long diags, unsigned long long Xx, + unsigned long long Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + float diags, float Xx, float Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + double diags, double Xx, double Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + long double diags, long double Xx, long double Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + npy_cfloat_wrapper diags, npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + npy_cdouble_wrapper diags, npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, + npy_clongdouble_wrapper diags, npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) """ - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - signed char diags, signed char Xx, signed char Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned char diags, unsigned char Xx, unsigned char Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - short diags, short Xx, short Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned short diags, unsigned short Xx, - unsigned short Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - int diags, int Xx, int Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned int diags, unsigned int Xx, unsigned int Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - long long diags, long long Xx, long long Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - unsigned long long diags, unsigned long long Xx, - unsigned long long Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - float diags, float Xx, float Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - double diags, double Xx, double Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - long double diags, long double Xx, long double Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - npy_cfloat_wrapper diags, npy_cfloat_wrapper Xx, - npy_cfloat_wrapper Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - npy_cdouble_wrapper diags, npy_cdouble_wrapper Xx, - npy_cdouble_wrapper Yx) - dia_matvec(int n_row, int n_col, int n_diags, int L, int offsets, - npy_clongdouble_wrapper diags, npy_clongdouble_wrapper Xx, - npy_clongdouble_wrapper Yx) - """ - return _dia.dia_matvec(*args) + return _dia.dia_matvec(*args) + Modified: branches/refactor_fft/scipy/sparse/sparsetools/dia_wrap.cxx =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/dia_wrap.cxx 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/dia_wrap.cxx 2008-05-24 10:44:59 UTC (rev 4379) @@ -5992,3 +5992,4 @@ } + Modified: branches/refactor_fft/scipy/sparse/sparsetools/numpy.i =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/numpy.i 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/sparsetools/numpy.i 2008-05-24 10:44:59 UTC (rev 4379) @@ -383,7 +383,7 @@ $1 = (type*) array->data; } %typemap(freearg) type* IN_ARRAY1 { - if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); + if (is_new_object$argnum && array$argnum) { Py_DECREF(array$argnum); } } %enddef @@ -401,7 +401,7 @@ $1 = (type*) array->data; } %typemap(freearg) (type* IN_ARRAY2) { - if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); + if (is_new_object$argnum && array$argnum) { Py_DECREF(array$argnum); } } %enddef Modified: branches/refactor_fft/scipy/sparse/tests/test_base.py =================================================================== --- branches/refactor_fft/scipy/sparse/tests/test_base.py 2008-05-22 06:01:12 UTC (rev 4378) +++ branches/refactor_fft/scipy/sparse/tests/test_base.py 2008-05-24 10:44:59 UTC (rev 4379) @@ -221,6 +221,13 @@ c = temp.multiply(self.datsp) assert_array_equal(c.todense(),[[1,0,0,4],[9,0,1,0],[0,4,0,0]]) + # complex + A = array([[1-2j,0+5j,-1+0j],[4-3j,-3+6j,5]]) + B = array([[5+2j,7-3j,-2+1j],[0-1j,-4+2j,9]]) + Asp = self.spmatrix(A) + Bsp = self.spmatrix(B) + assert_almost_equal( Asp.multiply(Bsp).todense(), A*B) + def test_eldiv(self): expected = [[1,0,0,1],[1,0,1,0],[0,1,0,0]] assert_array_equal((self.datsp / self.datsp).todense(),expected) @@ -229,6 +236,13 @@ res = matrix([[1,0,0,0.5],[-3,0,numpy.inf,0],[0,0.25,0,0]],'d') assert_array_equal((self.datsp / denom).todense(),res) + # complex + A = array([[1-2j,0+5j,-1+0j],[4-3j,-3+6j,5]]) + B = array([[5+2j,7-3j,-2+1j],[0-1j,-4+2j,9]]) + Asp = self.spmatrix(A) + Bsp = self.spmatrix(B) + assert_almost_equal( (Asp / Bsp).todense(), A/B) + def test_pow(self): A = matrix([[1,0,2,0],[0,3,4,0],[0,5,0,0],[0,6,7,8]]) B = self.spmatrix( A ) From scipy-svn at scipy.org Sat May 24 11:15:59 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 10:15:59 -0500 (CDT) Subject: [Scipy-svn] r4380 - branches/refactor_fft/scipy/fftpack/fftpack Message-ID: <20080524151559.C2D1F39C7E7@scipy.org> Author: cdavid Date: 2008-05-24 10:15:52 -0500 (Sat, 24 May 2008) New Revision: 4380 Added: branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf Removed: branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf.src Modified: branches/refactor_fft/scipy/fftpack/fftpack/setup.py Log: Do not use template anymore: it brings too much complexity for too little benefit. Deleted: branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src 2008-05-24 10:44:59 UTC (rev 4379) +++ branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src 2008-05-24 15:15:52 UTC (rev 4380) @@ -1,75 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 -! This file is included by the files /.pyf.src -! ********************************************************************** -! NOTE: IF YOU UPDATE THIS FILE, YOU SHOULD UPDATE IT FOR BACKENDS TOO ! -! ********************************************************************** - - subroutine zfft(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft - - subroutine drfft(x,n,direction,howmany,normalize) - ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft - real*8 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine drfft - - subroutine zrfft(x,n,direction,howmany,normalize) - ! y = zrfft(x[,n,direction,normalize,overwrite_x]) - intent(c) zrfft - complex*16 intent(c,in,out,overwrite,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zrfft - - subroutine zfftnd(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i_error, & - "inconsistency in x.shape and s argument"); & - } & - } - end subroutine zfftnd - -! See http://cens.ioc.ee/projects/f2py2e/ Copied: branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf (from rev 4379, branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src) =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/fft_template.pyf.src 2008-05-24 10:44:59 UTC (rev 4379) +++ branches/refactor_fft/scipy/fftpack/fftpack/fftpack.pyf 2008-05-24 15:15:52 UTC (rev 4380) @@ -0,0 +1,77 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _fftpack + interface + + subroutine zfft_fftpack(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_fftpack + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_fftpack + + subroutine drfft_fftpack(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft_fftpack + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft_fftpack + + subroutine zrfft_fftpack(x,n,direction,howmany,normalize) + ! y = zrfft(x[,n,direction,normalize,overwrite_x]) + intent(c) zrfft_fftpack + complex*16 intent(c,in,out,overwrite,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zrfft_fftpack + + subroutine zfftnd_fftpack(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_fftpack + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i - -python module _fftpack - interface - include 'fft_template.pyf.src' - end interface -end python module _fftpack Modified: branches/refactor_fft/scipy/fftpack/fftpack/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/fftpack/setup.py 2008-05-24 10:44:59 UTC (rev 4379) +++ branches/refactor_fft/scipy/fftpack/fftpack/setup.py 2008-05-24 15:15:52 UTC (rev 4380) @@ -10,7 +10,7 @@ config.add_library('dfftpack', sources=[join('DFFTPACK','*.f')]) - sources = ['fftpack.pyf.src', 'src/zrfft.c'] + sources = ['fftpack.pyf', 'src/zrfft.c'] for s in ["zfft.cxx", "zfftnd.cxx", "drfft.cxx"]: sources.append(join('src/fftpack', s)) From scipy-svn at scipy.org Sat May 24 11:16:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 10:16:28 -0500 (CDT) Subject: [Scipy-svn] r4381 - branches/refactor_fft/scipy/fftpack Message-ID: <20080524151628.55204C7C0C0@scipy.org> Author: cdavid Date: 2008-05-24 10:16:23 -0500 (Sat, 24 May 2008) New Revision: 4381 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Record which func uses which backend in fftpack. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:15:52 UTC (rev 4380) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:16:23 UTC (rev 4381) @@ -9,6 +9,7 @@ # Default backend: fftpack. import fftpack as _DEF_BACKEND +_DEF_BACKEND_NAME = "fftpack" __all__ = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] @@ -22,6 +23,9 @@ _FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) +# Dictionary to keep func -> used backend association +_BACK_PER_FUNC = {} + def myimport(name): """Load a fft backend from its name. @@ -47,8 +51,8 @@ print "Trying backend ", backend mod = myimport(backend) return mod, backend - except ImportError: - pass + except ImportError, e: + print " --> %s" % e raise ImportError("No backend found") def load_backend(name = None): @@ -72,9 +76,11 @@ try: _FUNCS[f] = mod.__dict__[f] print "loading %s from %s" % (f, name) + _BACK_PER_FUNC[f] = name except KeyError: _FUNCS[f] = _DEF_BACKEND.__dict__[f] print "loading %s from %s" % (f, "def backend") + _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME # Loading convolve: we try to load all of them: if any failure, we use # fallback for all of them @@ -82,15 +88,18 @@ for f in _CONVOLVE_FUNCNAME: _FUNCS[f] = mod.__dict__[f] print "loading %s from %s" % (f, name) + _BACK_PER_FUNC[f] = name except KeyError: for f in _CONVOLVE_FUNCNAME: _FUNCS[f] = _DEF_BACKEND.__dict__[f] print "loading %s from %s" % (f, "def backend") + _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME except ImportError, e: # If cannot load backend, just use default backend (fftpack) print "%s: failed loading backend %s" % (e, name) for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] + _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME load_backend() From scipy-svn at scipy.org Sat May 24 11:28:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 10:28:28 -0500 (CDT) Subject: [Scipy-svn] r4382 - in branches/refactor_fft/scipy/fftpack/backends: . fftw fftw3 mkl Message-ID: <20080524152828.9133439C14A@scipy.org> Author: cdavid Date: 2008-05-24 10:28:10 -0500 (Sat, 24 May 2008) New Revision: 4382 Added: branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf Removed: branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf.src branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf.src branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf.src Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py Log: Do not use template anymore in fft backends: it brings too much complexity for too little benefit. Copied: branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf (from rev 4379, branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf.src) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf.src 2008-05-24 10:44:59 UTC (rev 4379) +++ branches/refactor_fft/scipy/fftpack/backends/fftw/fftw.pyf 2008-05-24 15:28:10 UTC (rev 4382) @@ -0,0 +1,77 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _fftw + interface + + subroutine zfft_fftw(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_fftw + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_fftw + + subroutine drfft_fftw(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft_fftw + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft_fftw + +! subroutine zrfft_fftw(x,n,direction,howmany,normalize) +! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) zrfft_fftw +! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine zrfft_fftw + + subroutine zfftnd_fftw(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_fftw + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i - -python module _fftw - interface - include '../fft_template.pyf.src' - end interface -end python module _fftw Copied: branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf (from rev 4379, branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf.src) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf.src 2008-05-24 10:44:59 UTC (rev 4379) +++ branches/refactor_fft/scipy/fftpack/backends/fftw3/fftw3.pyf 2008-05-24 15:28:10 UTC (rev 4382) @@ -0,0 +1,78 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _fftw3 + interface + + subroutine zfft_fftw3(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_fftw3 + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_fftw3 + + subroutine drfft_fftw3(x,n,direction,howmany,normalize) + ! y = drfft(x[,n,direction,normalize,overwrite_x]) + intent(c) drfft_fftw3 + real*8 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0&&n<=size(x)) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine drfft_fftw3 + +! subroutine zrfft_fftw3(x,n,direction,howmany,normalize) +! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) zrfft_fftw3 +! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine zrfft_fftw3 + + subroutine zfftnd_fftw3(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_fftw3 + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i - -python module _fftw3 - interface - include '../fft_template.pyf.src' - end interface -end python module _fftw3 Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf (from rev 4379, branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf.src) =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf.src 2008-05-24 10:44:59 UTC (rev 4379) +++ branches/refactor_fft/scipy/fftpack/backends/mkl/mkl.pyf 2008-05-24 15:28:10 UTC (rev 4382) @@ -0,0 +1,78 @@ +!%f90 -*- f90 -*- +! Author: Pearu Peterson, August 2002 + +python module _mkl + interface + + subroutine zfft_mkl(x,n,direction,howmany,normalize) + ! y = fft(x[,n,direction,normalize,overwrite_x]) + intent(c) zfft_mkl + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer optional,depend(x),intent(c,in) :: n=size(x) + check(n>0) n + integer depend(x,n),intent(c,hide) :: howmany = size(x)/n + check(n*howmany==size(x)) howmany + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) & + :: normalize = (direction<0) + end subroutine zfft_mkl + +! subroutine drfft_mkl(x,n,direction,howmany,normalize) +! ! y = drfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) drfft_mkl +! real*8 intent(c,in,out,copy,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine drfft_mkl + +! subroutine zrfft_mkl(x,n,direction,howmany,normalize) +! ! y = zrfft(x[,n,direction,normalize,overwrite_x]) +! intent(c) zrfft_mkl +! complex*16 intent(c,in,out,overwrite,out=y) :: x(*) +! integer optional,depend(x),intent(c,in) :: n=size(x) +! check(n>0&&n<=size(x)) n +! integer depend(x,n),intent(c,hide) :: howmany = size(x)/n +! check(n*howmany==size(x)) howmany +! integer optional,intent(c,in) :: direction = 1 +! integer optional,intent(c,in),depend(direction) & +! :: normalize = (direction<0) +! end subroutine zrfft_mkl + + subroutine zfftnd_mkl(x,r,s,direction,howmany,normalize,j) + ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) + intent(c) zfftnd_mkl + complex*16 intent(c,in,out,copy,out=y) :: x(*) + integer intent(c,hide),depend(x) :: r=old_rank(x) + integer intent(c,hide) :: j=0 + integer optional,depend(r),dimension(r),intent(c,in) & + :: s=old_shape(x,j++) + check(r>=len(s)) s + integer intent(c,hide) :: howmany = 1 + integer optional,intent(c,in) :: direction = 1 + integer optional,intent(c,in),depend(direction) :: & + normalize = (direction<0) + callprotoargument complex_double*,int,int*,int,int,int + callstatement {& + int i,sz=1,xsz=size(x); & + for (i=0;i - -python module _mkl - interface - include '../fft_template.pyf.src' - end interface -end python module _mkl Modified: branches/refactor_fft/scipy/fftpack/backends/setup.py =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-24 15:16:23 UTC (rev 4381) +++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-24 15:28:10 UTC (rev 4382) @@ -22,7 +22,7 @@ include_dirs = ["common", info['include_dirs']]) config.add_extension("%s._%s" % (name, name), - sources = ["%s/%s.pyf.src" % (name, name)], + sources = ["%s/%s.pyf" % (name, name)], extra_info = info, libraries = ["%s_backend" % name]) config.add_subpackage(name) From scipy-svn at scipy.org Sat May 24 11:34:47 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 10:34:47 -0500 (CDT) Subject: [Scipy-svn] r4383 - branches/refactor_fft/scipy/fftpack/backends Message-ID: <20080524153447.657D839C14A@scipy.org> Author: cdavid Date: 2008-05-24 10:34:43 -0500 (Sat, 24 May 2008) New Revision: 4383 Removed: branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src Log: Remove unused code. Deleted: branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src =================================================================== --- branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src 2008-05-24 15:28:10 UTC (rev 4382) +++ branches/refactor_fft/scipy/fftpack/backends/fft_template.pyf.src 2008-05-24 15:34:43 UTC (rev 4383) @@ -1,75 +0,0 @@ -!%f90 -*- f90 -*- -! Author: Pearu Peterson, August 2002 -! This file is included by the files /.pyf.src -! ********************************************************************** -! NOTE: IF YOU UPDATE THIS FILE, YOU SHOULD UPDATE IT FOR FFTPACK TOO ! -! ********************************************************************** - - subroutine zfft(x,n,direction,howmany,normalize) - ! y = fft(x[,n,direction,normalize,overwrite_x]) - intent(c) zfft - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zfft - - subroutine drfft(x,n,direction,howmany,normalize) - ! y = drfft(x[,n,direction,normalize,overwrite_x]) - intent(c) drfft - real*8 intent(c,in,out,copy,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine drfft - - subroutine zrfft(x,n,direction,howmany,normalize) - ! y = zrfft(x[,n,direction,normalize,overwrite_x]) - intent(c) zrfft - complex*16 intent(c,in,out,overwrite,out=y) :: x(*) - integer optional,depend(x),intent(c,in) :: n=size(x) - check(n>0&&n<=size(x)) n - integer depend(x,n),intent(c,hide) :: howmany = size(x)/n - check(n*howmany==size(x)) howmany - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) & - :: normalize = (direction<0) - end subroutine zrfft - - subroutine zfftnd(x,r,s,direction,howmany,normalize,j) - ! y = zfftnd(x[,s,direction,normalize,overwrite_x]) - intent(c) zfftnd - complex*16 intent(c,in,out,copy,out=y) :: x(*) - integer intent(c,hide),depend(x) :: r=old_rank(x) - integer intent(c,hide) :: j=0 - integer optional,depend(r),dimension(r),intent(c,in) & - :: s=old_shape(x,j++) - check(r>=len(s)) s - integer intent(c,hide) :: howmany = 1 - integer optional,intent(c,in) :: direction = 1 - integer optional,intent(c,in),depend(direction) :: & - normalize = (direction<0) - callprotoargument complex_double*,int,int*,int,int,int - callstatement {& - int i,sz=1,xsz=size(x); & - for (i=0;i_error, & - "inconsistency in x.shape and s argument"); & - } & - } - end subroutine zfftnd - -! See http://cens.ioc.ee/projects/f2py2e/ From scipy-svn at scipy.org Sat May 24 11:38:54 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 10:38:54 -0500 (CDT) Subject: [Scipy-svn] r4384 - branches/refactor_fft/scipy/fftpack Message-ID: <20080524153854.56A3F39C14A@scipy.org> Author: cdavid Date: 2008-05-24 10:38:50 -0500 (Sat, 24 May 2008) New Revision: 4384 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Remove debug print in backend loading. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:34:43 UTC (rev 4383) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:38:50 UTC (rev 4384) @@ -48,11 +48,10 @@ found.""" for backend in ["mkl", "fftw3", "fftw"]: try: - print "Trying backend ", backend mod = myimport(backend) return mod, backend except ImportError, e: - print " --> %s" % e + pass raise ImportError("No backend found") def load_backend(name = None): @@ -75,11 +74,9 @@ for f in _FFT_FUNCNAME: try: _FUNCS[f] = mod.__dict__[f] - print "loading %s from %s" % (f, name) _BACK_PER_FUNC[f] = name except KeyError: _FUNCS[f] = _DEF_BACKEND.__dict__[f] - print "loading %s from %s" % (f, "def backend") _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME # Loading convolve: we try to load all of them: if any failure, we use @@ -87,16 +84,13 @@ try: for f in _CONVOLVE_FUNCNAME: _FUNCS[f] = mod.__dict__[f] - print "loading %s from %s" % (f, name) _BACK_PER_FUNC[f] = name except KeyError: for f in _CONVOLVE_FUNCNAME: _FUNCS[f] = _DEF_BACKEND.__dict__[f] - print "loading %s from %s" % (f, "def backend") _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME except ImportError, e: # If cannot load backend, just use default backend (fftpack) - print "%s: failed loading backend %s" % (e, name) for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME From scipy-svn at scipy.org Sat May 24 11:55:32 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 10:55:32 -0500 (CDT) Subject: [Scipy-svn] r4385 - branches/refactor_fft/scipy/fftpack Message-ID: <20080524155532.75C7639C7E0@scipy.org> Author: cdavid Date: 2008-05-24 10:55:28 -0500 (Sat, 24 May 2008) New Revision: 4385 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Improve docstring for backend loader. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:38:50 UTC (rev 4384) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:55:28 UTC (rev 4385) @@ -42,7 +42,8 @@ raise ImportError(e) def find_backend(): - """Try to import one of the backend, and return the first found. + """Try to import one of the backend from the list of possible backends, and + return the first found. Returns the backend (module class), raise ImportError if nothing is found.""" @@ -60,10 +61,11 @@ If name is None, all backend are tried one after the other, as defined in function find_backend. - If the backend does not implement one function, function in _DEF_BACKEND is - used instead. + If the backend does not implement one function, the implementation in + _DEF_BACKEND is used instead. - If the backend is not found, fallback is used for all the functions.""" + If no optimized backend is found, fallback is used for all the + functions.""" try: if name: mod = myimport(name) @@ -84,17 +86,20 @@ try: for f in _CONVOLVE_FUNCNAME: _FUNCS[f] = mod.__dict__[f] - _BACK_PER_FUNC[f] = name + _BACK_PER_FUNC[f] = name except KeyError: for f in _CONVOLVE_FUNCNAME: _FUNCS[f] = _DEF_BACKEND.__dict__[f] - _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME + _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME except ImportError, e: # If cannot load backend, just use default backend (fftpack) for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME +def show_backend(): + return _BACK_PER_FUNC + load_backend() zfft = _FUNCS["zfft"] From scipy-svn at scipy.org Sat May 24 12:29:11 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 May 2008 11:29:11 -0500 (CDT) Subject: [Scipy-svn] r4386 - branches/refactor_fft/scipy/fftpack Message-ID: <20080524162911.3495739C73F@scipy.org> Author: cdavid Date: 2008-05-24 11:29:04 -0500 (Sat, 24 May 2008) New Revision: 4386 Modified: branches/refactor_fft/scipy/fftpack/__init__.py branches/refactor_fft/scipy/fftpack/common.py Log: Add functions to get name of used backend. Modified: branches/refactor_fft/scipy/fftpack/__init__.py =================================================================== --- branches/refactor_fft/scipy/fftpack/__init__.py 2008-05-24 15:55:28 UTC (rev 4385) +++ branches/refactor_fft/scipy/fftpack/__init__.py 2008-05-24 16:29:04 UTC (rev 4386) @@ -8,6 +8,7 @@ from fftpack_version import fftpack_version as __version__ from basic import * +from common import backend, detailed_backend from pseudo_diffs import * from helper import * Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 15:55:28 UTC (rev 4385) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 16:29:04 UTC (rev 4386) @@ -12,14 +12,15 @@ _DEF_BACKEND_NAME = "fftpack" __all__ = ["zfft", "drfft", "zfftnd", "zrfft", "init_convolution_kernel", - "convolve", "convolve_z", "destroy_convolve_cache"] + "convolve", "convolve_z", "destroy_convolve_cache", "backend", + "detailed_backend"] _FFT_FUNCNAME = ["zfft", "drfft", "zfftnd", "zrfft"] -_CONVOLVE_FUNCNAME = ["init_convolution_kernel", +_CONVOLVE_FUNCNAME = ["init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] # Dictionary of (name, callable) -_FUNCS = dict([(name, None) for name in __all__]) +_FUNCS = dict([(name, None) for name in _FFT_FUNCNAME + _CONVOLVE_FUNCNAME]) _FALLBACK = dict([(name, _DEF_BACKEND.__dict__[f]) for f in _FUNCS.keys()]) @@ -28,7 +29,7 @@ def myimport(name): """Load a fft backend from its name. - + Name should be fftw3, etc...""" mod = __import__("scipy.fftpack.backends", fromlist = [name]) try: @@ -92,15 +93,21 @@ _FUNCS[f] = _DEF_BACKEND.__dict__[f] _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME except ImportError, e: + name = _DEF_BACKEND_NAME # If cannot load backend, just use default backend (fftpack) for f in _FUNCS.keys(): _FUNCS[f] = _DEF_BACKEND.__dict__[f] _BACK_PER_FUNC[f] = _DEF_BACKEND_NAME -def show_backend(): + return name + +def backend(): + return _BACKEND_NAME + +def detailed_backend(): return _BACK_PER_FUNC -load_backend() +_BACKEND_NAME = load_backend() zfft = _FUNCS["zfft"] drfft = _FUNCS["drfft"] From scipy-svn at scipy.org Wed May 28 01:16:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 00:16:20 -0500 (CDT) Subject: [Scipy-svn] r4387 - branches/refactor_fft/scipy/fftpack Message-ID: <20080528051620.9F20839CB6B@scipy.org> Author: cdavid Date: 2008-05-28 00:16:12 -0500 (Wed, 28 May 2008) New Revision: 4387 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Improve a bit doc for fftpack module loader. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-24 16:29:04 UTC (rev 4386) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-28 05:16:12 UTC (rev 4387) @@ -1,11 +1,12 @@ """This module takes care of exposing the fft implementation from available -backends. +backends to scipy.fftpack. -The exposed implementation consists solely in the __all__ items. +For each backend, the exposed implementation consists solely of the items in +__all__ . The functions are set up in load_backend function, which initialize the dictionary _FUNCS with working functions. If a backend does not implement one -of the function, a fallback is automatically used.""" +of the function, a fallback from _DEF_BACKEND is automatically used.""" # Default backend: fftpack. import fftpack as _DEF_BACKEND @@ -16,6 +17,9 @@ "detailed_backend"] _FFT_FUNCNAME = ["zfft", "drfft", "zfftnd", "zrfft"] + +# Convolve needs to be treated as a whole, not per function, we keep the +# convolve functions separately. _CONVOLVE_FUNCNAME = ["init_convolution_kernel", "convolve", "convolve_z", "destroy_convolve_cache"] @@ -102,9 +106,13 @@ return name def backend(): + """Return backend name.""" return _BACKEND_NAME def detailed_backend(): + """Return backend name for each function. + + The return value is a dictionary of (func name, backend)""" return _BACK_PER_FUNC _BACKEND_NAME = load_backend() From scipy-svn at scipy.org Wed May 28 01:32:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 00:32:53 -0500 (CDT) Subject: [Scipy-svn] r4388 - branches/refactor_fft/scipy/fftpack Message-ID: <20080528053253.CE14C39C5DC@scipy.org> Author: cdavid Date: 2008-05-28 00:32:41 -0500 (Wed, 28 May 2008) New Revision: 4388 Modified: branches/refactor_fft/scipy/fftpack/common.py Log: Add comment on how we load backends. Modified: branches/refactor_fft/scipy/fftpack/common.py =================================================================== --- branches/refactor_fft/scipy/fftpack/common.py 2008-05-28 05:16:12 UTC (rev 4387) +++ branches/refactor_fft/scipy/fftpack/common.py 2008-05-28 05:32:41 UTC (rev 4388) @@ -36,6 +36,9 @@ Name should be fftw3, etc...""" mod = __import__("scipy.fftpack.backends", fromlist = [name]) + + # Because of nose trying to import backends, we do not generate ImporError + # in backends, but we only set IS_INIT to true if the backend is available try: ret = mod.__dict__[name] if ret.IS_INIT: From scipy-svn at scipy.org Wed May 28 16:17:49 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 15:17:49 -0500 (CDT) Subject: [Scipy-svn] r4389 - trunk/scipy/ndimage/tests Message-ID: <20080528201749.41FE3C7C026@scipy.org> Author: chris.burns Date: 2008-05-28 15:17:44 -0500 (Wed, 28 May 2008) New Revision: 4389 Modified: trunk/scipy/ndimage/tests/test_segment.py Log: Fix nose call to run test. Modified: trunk/scipy/ndimage/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/tests/test_segment.py 2008-05-28 05:32:41 UTC (rev 4388) +++ trunk/scipy/ndimage/tests/test_segment.py 2008-05-28 20:17:44 UTC (rev 4389) @@ -155,5 +155,5 @@ return if __name__ == "__main__": - inittest.main() + nose.runmodule() From scipy-svn at scipy.org Wed May 28 16:34:48 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 15:34:48 -0500 (CDT) Subject: [Scipy-svn] r4390 - trunk/scipy/ndimage Message-ID: <20080528203448.BE939C7C016@scipy.org> Author: chris.burns Date: 2008-05-28 15:34:43 -0500 (Wed, 28 May 2008) New Revision: 4390 Modified: trunk/scipy/ndimage/_registration.py Log: Modify imports to match scipy standards. Modified: trunk/scipy/ndimage/_registration.py =================================================================== --- trunk/scipy/ndimage/_registration.py 2008-05-28 20:17:44 UTC (rev 4389) +++ trunk/scipy/ndimage/_registration.py 2008-05-28 20:34:43 UTC (rev 4390) @@ -1,10 +1,12 @@ import math -import os -import numpy as NP -import scipy.ndimage._register as R -import scipy.special as SP -import scipy.ndimage as NDI -import scipy.optimize as OPT + +import numpy as np +from scipy.special import erf +from scipy.ndimage import correlate1d +from scipy.optimize import fmin_powell, fmin_cg + +import scipy.ndimage._register as reg + import time import glob @@ -66,29 +68,29 @@ """ - Z = NP.zeros(3, dtype=NP.float64); + Z = np.zeros(3, dtype=np.float64); # get the zoom Z[0] = imageG['mat'][0][0] / imageF_mat[0][0] Z[1] = imageG['mat'][1][1] / imageF_mat[1][1] Z[2] = imageG['mat'][2][2] / imageF_mat[2][2] # new volume dimensions (rounded) - D = NP.zeros(3, dtype=NP.int32); + D = np.zeros(3, dtype=np.int32); D[0] = int(float(imageG['dim'][0])*Z[0]+0.5) D[1] = int(float(imageG['dim'][1])*Z[1]+0.5) D[2] = int(float(imageG['dim'][2])*Z[2]+0.5) - M = NP.eye(4, dtype=NP.float64); + M = np.eye(4, dtype=np.float64); # for the test data, set the xyz voxel sizes for fMRI volume M[0][0] = imageG['mat'][0][0]/Z[0] M[1][1] = imageG['mat'][1][1]/Z[1] M[2][2] = imageG['mat'][2][2]/Z[2] - image = NP.zeros(D[2]*D[1]*D[0], dtype=NP.uint8).reshape(D[2], D[0], D[1]) + image = np.zeros(D[2]*D[1]*D[0], dtype=np.uint8).reshape(D[2], D[0], D[1]) mode = 2 scale = 0 - R.register_volume_resample(imageG['data'], image, Z, scale, mode) - F = NP.zeros(3, dtype=NP.float64); + reg.register_volume_resample(imageG['data'], image, Z, scale, mode) + F = np.zeros(3, dtype=np.float64); zoom_image = {'data' : image, 'mat' : M, 'dim' : D, 'fwhm' : F} return zoom_image @@ -134,17 +136,17 @@ M_inverse = get_inverse_mappings(parm_vector) (layers, rows, cols) = image['data'].shape # allocate the zero image - remaped_image = NP.zeros(layers*rows*cols, dtype=NP.uint8).reshape(layers, rows, cols) + remaped_image = np.zeros(layers*rows*cols, dtype=np.uint8).reshape(layers, rows, cols) remaped_image = {'data' : remaped_image, 'mat' : image['mat'], 'dim' : image['dim'], 'fwhm' : image['fwhm']} imdata = build_structs() if resample == 'linear': # trilinear interpolation mapping. - R.register_linear_resample(image['data'], remaped_image['data'], M_inverse, imdata['step']) + reg.register_linear_resample(image['data'], remaped_image['data'], M_inverse, imdata['step']) elif resample == 'cubic': # tricubic convolve interpolation mapping. - R.register_cubic_resample(image['data'], remaped_image['data'], M_inverse, imdata['step']) + reg.register_cubic_resample(image['data'], remaped_image['data'], M_inverse, imdata['step']) return remaped_image @@ -168,7 +170,7 @@ >>> import numpy as NP >>> import _registration as reg - >>> array = NP.zeros(6, dtype=float) + >>> array = np.zeros(6, dtype=float) >>> M = reg.get_inverse_mappings(array) >>> M @@ -324,12 +326,12 @@ if opt_method=='powell': print 'POWELL multi-res registration step size ', step print 'vector ', x - x = OPT.fmin_powell(optimize_function, x, args=p_args, + x = fmin_powell(optimize_function, x, args=p_args, callback=callback_powell) elif opt_method=='cg': print 'CG multi-res registration step size ', step print 'vector ', x - x = OPT.fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) + x = fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) elif opt_method=='hybrid': if i==0: print 'Hybrid POWELL multi-res registration step size ', step @@ -338,7 +340,7 @@ optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, method, ret_histo) p_args = (optfunc_args,) - x = OPT.fmin_powell(optimize_function, x, args=p_args, callback=callback_powell) + x = fmin_powell(optimize_function, x, args=p_args, callback=callback_powell) elif i==1: print 'Hybrid CG multi-res registration step size ', step print 'vector ', x @@ -346,7 +348,7 @@ optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, method, ret_histo) p_args = (optfunc_args,) - x = OPT.fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) + x = fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) return x @@ -395,8 +397,8 @@ >>> import _registration as reg >>> fwhm = 3 >>> ftype = 2 - >>> p = NP.ceil(2*fwhm).astype(int) - >>> x = NP.array(range(-p, p+1)) + >>> p = np.ceil(2*fwhm).astype(int) + >>> x = np.array(range(-p, p+1)) >>> kernel = reg.smooth_kernel(fwhm, x, ktype=ftype) >>> kernel @@ -409,19 +411,21 @@ """ eps = 0.00001 - s = NP.square((fwhm/math.sqrt(8.0*math.log(2.0)))) + eps + s = np.square((fwhm/math.sqrt(8.0*math.log(2.0)))) + eps if ktype==1: # from SPM: Gauss kernel convolved with 1st degree B spline w1 = 0.5 * math.sqrt(2.0/s) w2 = -0.5 / s w3 = math.sqrt((s*math.pi) /2.0) - kernel = 0.5*(SP.erf(w1*(x+1))*(x+1) + SP.erf(w1*(x-1))*(x-1) - 2.0*SP.erf(w1*(x))*(x) + - w3*(NP.exp(w2*NP.square(x+1))) + NP.exp(w2*(NP.square(x-1))) - 2.0*NP.exp(w2*NP.square(x))) + kernel = 0.5*(erf(w1*(x+1))*(x+1) + erf(w1*(x-1))*(x-1) + - 2.0*erf(w1*(x))*(x) + w3*(np.exp(w2*np.square(x+1))) + + np.exp(w2*(np.square(x-1))) + - 2.0*np.exp(w2*np.square(x))) kernel[kernel<0] = 0 kernel = kernel / kernel.sum() else: # Gauss kernel - kernel = (1.0/math.sqrt(2.0*math.pi*s)) * NP.exp(-NP.square(x)/(2.0*s)) + kernel = (1.0/math.sqrt(2.0*math.pi*s)) * np.exp(-np.square(x)/(2.0*s)) kernel = kernel / kernel.sum() return kernel @@ -455,23 +459,23 @@ >>> image1['data'] = image_Filter_xyz """ - p = NP.ceil(2*fwhm[0]).astype(int) - x = NP.array(range(-p, p+1)) + p = np.ceil(2*fwhm[0]).astype(int) + x = np.array(range(-p, p+1)) kernel_x = smooth_kernel(fwhm[0], x, ktype=ftype) - p = NP.ceil(2*fwhm[1]).astype(int) - x = NP.array(range(-p, p+1)) + p = np.ceil(2*fwhm[1]).astype(int) + x = np.array(range(-p, p+1)) kernel_y = smooth_kernel(fwhm[1], x, ktype=ftype) - p = NP.ceil(2*fwhm[2]).astype(int) - x = NP.array(range(-p, p+1)) + p = np.ceil(2*fwhm[2]).astype(int) + x = np.array(range(-p, p+1)) kernel_z = smooth_kernel(fwhm[2], x, ktype=ftype) output=None # 3D filter in 3 1D separable stages axis = 0 - image_F_x = NDI.correlate1d(imageRaw, kernel_x, axis, output) + image_F_x = correlate1d(imageRaw, kernel_x, axis, output) axis = 1 - image_F_xy = NDI.correlate1d(image_F_x, kernel_y, axis, output) + image_F_xy = correlate1d(image_F_x, kernel_y, axis, output) axis = 2 - image_F_xyz = NDI.correlate1d(image_F_xy, kernel_z, axis, output) + image_F_xyz = correlate1d(image_F_xy, kernel_z, axis, output) return image_F_xyz def build_fwhm(M, S): @@ -504,15 +508,15 @@ >>> image1['fwhm'] = reg.build_fwhm(image1['mat'], imdata['step']) """ - view_3x3 = NP.square(M[0:3, 0:3]) + view_3x3 = np.square(M[0:3, 0:3]) # sum the elements inn the first row - vxg = NP.sqrt(view_3x3.sum(axis=0)) + vxg = np.sqrt(view_3x3.sum(axis=0)) # assumes that sampling is the same for xyz - size = NP.array([1,1,1])*S[0] - x = NP.square(size) - NP.square(vxg) + size = np.array([1,1,1])*S[0] + x = np.square(size) - np.square(vxg) # clip x[x<0] = 0 - fwhm = NP.sqrt(x) / vxg + fwhm = np.sqrt(x) / vxg # pathology when stepsize = 1 for MAT equal to the identity matrix fwhm[fwhm==0] = 1 # return the 3D Gaussian kernel width (xyz) @@ -596,7 +600,7 @@ >>> smhist = 0 >>> ret_histo = 1 >>> optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, method, ret_histo) - >>> x = NP.zeros(6, dtype=NP.float64) + >>> x = np.zeros(6, dtype=np.float64) >>> return cost, joint_histogram = reg.optimize_function(x, optfunc_args) @@ -619,9 +623,9 @@ # rot_matrix is the 4x4 constructed (current angles and translates) transform matrix # sample_vector is the subsample vector for x-y-z - F_inv = NP.linalg.inv(image_F['mat']) - composite = NP.dot(F_inv, image_G['mat']) - composite = NP.dot(composite, rot_matrix) + F_inv = np.linalg.inv(image_F['mat']) + composite = np.dot(F_inv, image_G['mat']) + composite = np.dot(composite, rot_matrix) if method == 'mse': # @@ -630,12 +634,12 @@ (layers, rows, cols) = image_F['data'].shape # allocate the zero image - remap_image_F = NP.zeros(layers*rows*cols, dtype=NP.uint8).reshape(layers, rows, cols) + remap_image_F = np.zeros(layers*rows*cols, dtype=np.uint8).reshape(layers, rows, cols) imdata = build_structs() # trilinear interpolation mapping. - R.register_linear_resample(image_F['data'], remap_image_F, composite, + reg.register_linear_resample(image_F['data'], remap_image_F, composite, imdata['step']) - cost = (NP.square(image_G['data']-remap_image_F)).mean() + cost = (np.square(image_G['data']-remap_image_F)).mean() return cost @@ -645,29 +649,29 @@ # # allocate memory for 2D histogram - joint_histogram = NP.zeros([256, 256], dtype=NP.float64); + joint_histogram = np.zeros([256, 256], dtype=np.float64); if do_lite: - R.register_histogram_lite(image_F['data'], image_G['data'], composite, + reg.register_histogram_lite(image_F['data'], image_G['data'], composite, sample_vector, joint_histogram) else: - R.register_histogram(image_F['data'], image_G['data'], composite, + reg.register_histogram(image_F['data'], image_G['data'], composite, sample_vector, joint_histogram) # smooth the histogram if smooth: - p = NP.ceil(2*fwhm[0]).astype(int) - x = NP.array(range(-p, p+1)) + p = np.ceil(2*fwhm[0]).astype(int) + x = np.array(range(-p, p+1)) kernel1 = smooth_kernel(fwhm[0], x) - p = NP.ceil(2*fwhm[1]).astype(int) - x = NP.array(range(-p, p+1)) + p = np.ceil(2*fwhm[1]).astype(int) + x = np.array(range(-p, p+1)) kernel2 = smooth_kernel(fwhm[1], x) output=None # 2D filter in 1D separable stages axis = 0 - result = NDI.correlate1d(joint_histogram, kernel1, axis, output) + result = correlate1d(joint_histogram, kernel1, axis, output) axis = 1 - joint_histogram = NDI.correlate1d(result, kernel1, axis, output) + joint_histogram = correlate1d(result, kernel1, axis, output) joint_histogram += epsilon # prevent log(0) # normalize the joint histogram @@ -678,44 +682,44 @@ if method == 'mi': # mutual information - marginal_outer = NP.outer(marginal_col, marginal_row) - H = joint_histogram * NP.log(joint_histogram / marginal_outer) + marginal_outer = np.outer(marginal_col, marginal_row) + H = joint_histogram * np.log(joint_histogram / marginal_outer) mutual_information = H.sum() cost = -mutual_information elif method == 'ecc': # entropy correlation coefficient - marginal_outer = NP.outer(marginal_col, marginal_row) - H = joint_histogram * NP.log(joint_histogram / marginal_outer) + marginal_outer = np.outer(marginal_col, marginal_row) + H = joint_histogram * np.log(joint_histogram / marginal_outer) mutual_information = H.sum() - row_entropy = marginal_row * NP.log(marginal_row) - col_entropy = marginal_col * NP.log(marginal_col) + row_entropy = marginal_row * np.log(marginal_row) + col_entropy = marginal_col * np.log(marginal_col) ecc = -2.0*mutual_information/(row_entropy.sum() + col_entropy.sum()) cost = -ecc elif method == 'nmi': # normalized mutual information - row_entropy = marginal_row * NP.log(marginal_row) - col_entropy = marginal_col * NP.log(marginal_col) - H = joint_histogram * NP.log(joint_histogram) + row_entropy = marginal_row * np.log(marginal_row) + col_entropy = marginal_col * np.log(marginal_col) + H = joint_histogram * np.log(joint_histogram) nmi = (row_entropy.sum() + col_entropy.sum()) / (H.sum()) cost = -nmi elif method == 'ncc': # cross correlation from the joint histogram r, c = joint_histogram.shape - i = NP.array(range(1,c+1)) - j = NP.array(range(1,r+1)) + i = np.array(range(1,c+1)) + j = np.array(range(1,r+1)) m1 = (marginal_row * i).sum() m2 = (marginal_col * j).sum() - sig1 = NP.sqrt((marginal_row*(NP.square(i-m1))).sum()) - sig2 = NP.sqrt((marginal_col*(NP.square(j-m2))).sum()) - [a, b] = NP.mgrid[1:c+1, 1:r+1] + sig1 = np.sqrt((marginal_row*(np.square(i-m1))).sum()) + sig2 = np.sqrt((marginal_col*(np.square(j-m2))).sum()) + [a, b] = np.mgrid[1:c+1, 1:r+1] a = a - m1 b = b - m2 # element multiplies in the joint histogram and grids H = ((joint_histogram * a) * b).sum() - ncc = H / (NP.dot(sig1, sig2)) + ncc = H / (np.dot(sig1, sig2)) cost = -ncc if ret_histo: @@ -751,11 +755,11 @@ """ # build image data structures here - P = NP.zeros(6, dtype=NP.float64); - T = NP.zeros(6, dtype=NP.float64); - F = NP.zeros(2, dtype=NP.int32); - S = NP.ones(3, dtype=NP.int32); - sample = NP.zeros(2, dtype=NP.int32); + P = np.zeros(6, dtype=np.float64); + T = np.zeros(6, dtype=np.float64); + F = np.zeros(2, dtype=np.int32); + S = np.ones(3, dtype=np.int32); + sample = np.zeros(2, dtype=np.int32); S[0] = step S[1] = step S[2] = step @@ -804,7 +808,7 @@ >>> import numpy as NP >>> import _registration as reg >>> imdata = reg.build_structs() - >>> x = NP.zeros(6, dtype=NP.float64) + >>> x = np.zeros(6, dtype=np.float64) >>> M = reg.build_rotate_matrix(x) >>> M array([[ 1., 0., 0., 0.], @@ -815,10 +819,10 @@ """ - R1 = NP.zeros([4,4], dtype=NP.float64); - R2 = NP.zeros([4,4], dtype=NP.float64); - R3 = NP.zeros([4,4], dtype=NP.float64); - T = NP.eye(4, dtype=NP.float64); + R1 = np.zeros([4,4], dtype=np.float64); + R2 = np.zeros([4,4], dtype=np.float64); + R3 = np.zeros([4,4], dtype=np.float64); + T = np.eye(4, dtype=np.float64); alpha = math.radians(img_data_parms[0]) beta = math.radians(img_data_parms[1]) @@ -853,9 +857,9 @@ T[1][3] = img_data_parms[4] T[2][3] = img_data_parms[5] - rot_matrix = NP.dot(T, R1); - rot_matrix = NP.dot(rot_matrix, R2); - rot_matrix = NP.dot(rot_matrix, R3); + rot_matrix = np.dot(T, R1); + rot_matrix = np.dot(rot_matrix, R2); + rot_matrix = np.dot(rot_matrix, R3); return rot_matrix @@ -928,49 +932,49 @@ # autoscale is using integrated histogram to deal with outlier high amplitude voxels if imagename == None: # imagename of none means to create a blank image - ImageVolume = NP.zeros(imagedesc['layers']*imagedesc['rows']*imagedesc['cols'], - dtype=NP.uint16).reshape(imagedesc['layers'], imagedesc['rows'], imagedesc['cols']) + ImageVolume = np.zeros(imagedesc['layers']*imagedesc['rows']*imagedesc['cols'], + dtype=np.uint16).reshape(imagedesc['layers'], imagedesc['rows'], imagedesc['cols']) else: - ImageVolume = NP.fromfile(imagename, - dtype=NP.uint16).reshape(imagedesc['layers'], imagedesc['rows'], imagedesc['cols']); + ImageVolume = np.fromfile(imagename, + dtype=np.uint16).reshape(imagedesc['layers'], imagedesc['rows'], imagedesc['cols']); # the mat (voxel to physical) matrix - M = NP.eye(4, dtype=NP.float64); + M = np.eye(4, dtype=np.float64); # for now just the sample size (mm units) in x, y and z M[0][0] = imagedesc['sample_x'] M[1][1] = imagedesc['sample_y'] M[2][2] = imagedesc['sample_z'] # dimensions - D = NP.zeros(3, dtype=NP.int32); + D = np.zeros(3, dtype=np.int32); # Gaussian kernel - fill in with build_fwhm() - F = NP.zeros(3, dtype=NP.float64); + F = np.zeros(3, dtype=np.float64); D[0] = imagedesc['rows'] D[1] = imagedesc['cols'] D[2] = imagedesc['layers'] if imagename == None: # no voxels to scale to 8 bits - ImageVolume = ImageVolume.astype(NP.uint8) + ImageVolume = ImageVolume.astype(np.uint8) image = {'data' : ImageVolume, 'mat' : M, 'dim' : D, 'fwhm' : F} return image # 8 bit scale with threshold clip of the volume integrated histogram max = ImageVolume.max() min = ImageVolume.min() - ih = NP.zeros(max-min+1, dtype=NP.float64); - h = NP.zeros(max-min+1, dtype=NP.float64); + ih = np.zeros(max-min+1, dtype=np.float64); + h = np.zeros(max-min+1, dtype=np.float64); if threshold <= 0: threshold = 0.999 elif threshold > 1.0: threshold = 1.0 # get the integrated histogram of the volume and get max from # the threshold crossing in the integrated histogram - index = R.register_image_threshold(ImageVolume, h, ih, threshold) + index = reg.register_image_threshold(ImageVolume, h, ih, threshold) scale = 255.0 / (index-min) # generate the scaled 8 bit image - images = (scale*(ImageVolume.astype(NP.float)-min)) + images = (scale*(ImageVolume.astype(np.float)-min)) images[images>255] = 255 - image = {'data' : images.astype(NP.uint8), 'mat' : M, 'dim' : D, 'fwhm' : F} + image = {'data' : images.astype(np.uint8), 'mat' : M, 'dim' : D, 'fwhm' : F} if debug == 1: return image, h, ih, index else: @@ -1041,16 +1045,16 @@ (layers, rows, cols) = image['data'].shape M = image['mat'] * scale # dimensions - D = NP.zeros(3, dtype=NP.int32); + D = np.zeros(3, dtype=np.int32); # Gaussian kernel - fill in with build_fwhm() - F = NP.zeros(3, dtype=NP.float64); - Z = NP.zeros(3, dtype=NP.float64); + F = np.zeros(3, dtype=np.float64); + Z = np.zeros(3, dtype=np.float64); D[0] = rows/scale D[1] = cols/scale D[2] = layers/scale - image2 = NP.zeros(D[2]*D[1]*D[0], dtype=NP.uint8).reshape(D[2], D[0], D[1]); + image2 = np.zeros(D[2]*D[1]*D[0], dtype=np.uint8).reshape(D[2], D[0], D[1]); mode = 1; - R.register_volume_resample(image['data'], image2, Z, scale, mode) + reg.register_volume_resample(image['data'], image2, Z, scale, mode) scaled_image = {'data' : image2, 'mat' : M, 'dim' : D, 'fwhm' : F} return scaled_image @@ -1102,7 +1106,7 @@ imdata['parms'][5] = Tz M = build_rotate_matrix(imdata['parms']) # rotate volume. linear interpolation means the volume is low pass filtered - R.register_linear_resample(image1['data'], image2['data'], M, imdata['step']) + reg.register_linear_resample(image1['data'], image2['data'], M, imdata['step']) # subsample volume image3 = build_scale_image(image2, scale) return image1, image3, imdata @@ -1124,10 +1128,12 @@ imdata['parms'][5] = x[5] # Tz M = build_rotate_matrix(imdata['parms']) # rotate volume. cubic spline interpolation means the volume is NOT low pass filtered - R.register_cubic_resample(fMRIVol['data'], image['data'], M, imdata['step']) + reg.register_cubic_resample(fMRIVol['data'], image['data'], M, imdata['step']) return image -def demo_MRI_coregistration(optimizer_method='powell', histo_method=1, smooth_histo=0, smooth_image=0, ftype=1): +def demo_MRI_coregistration(anatfile, funclist, optimizer_method='powell', + histo_method=1, smooth_histo=0, smooth_image=0, + ftype=1): """ demo with (must have file ANAT1_V0001.img and fMRI directory fMRIData) @@ -1163,26 +1169,28 @@ # read the anatomical MRI volume anat_desc = load_anatMRI_desc() - imageF_anat = load_volume(anat_desc, imagename='ANAT1_V0001.img') + imageF_anat = load_volume(anat_desc, imagename=anatfile) # the sampling structure imdata = build_structs() # the volume filter imageF_anat['fwhm'] = build_fwhm(imageF_anat['mat'], imdata['step']) # read in the file list of the fMRI data - metric_test = NP.dtype([('cost', 'f'), + metric_test = np.dtype([('cost', 'f'), ('align_cost', 'f'), ('rotate', 'f', 6), ('align_rotate', 'f', 6)]) - fMRIdata = read_fMRI_directory('fMRIData\*.img') + #fMRIdata = read_fMRI_directory('fMRIData\*.img') + #fMRIdata = read_fMRI_directory(funcdir + '/*.img') + fMRIdata = funclist fmri_desc = load_fMRI_desc() fmri_series = {} - ave_fMRI_volume = NP.zeros(fmri_desc['layers']*fmri_desc['rows']*fmri_desc['cols'], - dtype=NP.float64).reshape(fmri_desc['layers'], fmri_desc['rows'], fmri_desc['cols']) + ave_fMRI_volume = np.zeros(fmri_desc['layers']*fmri_desc['rows']*fmri_desc['cols'], + dtype=np.float64).reshape(fmri_desc['layers'], fmri_desc['rows'], fmri_desc['cols']) count = 0 number_volumes = len(fMRIdata) - measures = NP.zeros(number_volumes, dtype=metric_test) + measures = np.zeros(number_volumes, dtype=metric_test) # load and perturb (rotation, translation) the fMRI volumes for i in fMRIdata: image = load_volume(fmri_desc, i) @@ -1192,7 +1200,7 @@ fmri_series[count] = image count = count + 1 else: - x = NP.random.random(6) - 0.5 + x = np.random.random(6) - 0.5 x = 10.0 * x fmri_series[count] = demo_rotate_fMRI_volume(image, x) measures[count]['rotate'][0:6] = x[0:6] @@ -1218,15 +1226,15 @@ # align the volumes and average them for co-registration with the anatomical MRI - ave_fMRI_volume = fmri_series[0]['data'].astype(NP.float64) + ave_fMRI_volume = fmri_series[0]['data'].astype(np.float64) for i in range(1, number_volumes): image = fmri_series[i] x[0:6] = measures[i]['align_rotate'][0:6] # overwrite the fMRI volume with the aligned volume fmri_series[i] = remap_image(image, x, resample='cubic') - ave_fMRI_volume = ave_fMRI_volume + fmri_series[i]['data'].astype(NP.float64) + ave_fMRI_volume = ave_fMRI_volume + fmri_series[i]['data'].astype(np.float64) - ave_fMRI_volume = (ave_fMRI_volume / float(number_volumes)).astype(NP.uint8) + ave_fMRI_volume = (ave_fMRI_volume / float(number_volumes)).astype(np.uint8) ave_fMRI_volume = {'data' : ave_fMRI_volume, 'mat' : imageF['mat'], 'dim' : imageF['dim'], 'fwhm' : imageF['fwhm']} # register (using normalized mutual information) with the anatomical MRI From scipy-svn at scipy.org Wed May 28 19:47:03 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 18:47:03 -0500 (CDT) Subject: [Scipy-svn] r4391 - in trunk/scipy: optimize signal Message-ID: <20080528234703.23E6839C661@scipy.org> Author: oliphant Date: 2008-05-28 18:46:58 -0500 (Wed, 28 May 2008) New Revision: 4391 Modified: trunk/scipy/optimize/minpack.py trunk/scipy/signal/signaltools.py Log: Add filtfilt function to scipy. Make fixed_point into a vectorized function. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2008-05-28 20:34:43 UTC (rev 4390) +++ trunk/scipy/optimize/minpack.py 2008-05-28 23:46:58 UTC (rev 4391) @@ -1,7 +1,8 @@ import _minpack from numpy import atleast_1d, dot, take, triu, shape, eye, \ - transpose, zeros, product, greater, array + transpose, zeros, product, greater, array, \ + any, all, where, isscalar, asarray, ndarray error = _minpack.error @@ -103,7 +104,7 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder + fixed_point -- scalar and vector fixed-point finder """ x0 = array(x0,ndmin=1) @@ -256,7 +257,7 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder + fixed_point -- scalar and vector fixed-point finder """ x0 = array(x0,ndmin=1) @@ -372,8 +373,8 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder - + fixed_point -- scalar and vector fixed-point finder + """ if fprime is not None: @@ -412,9 +413,14 @@ # Steffensen's Method using Aitken's Del^2 convergence acceleration. def fixed_point(func, x0, args=(), xtol=1e-10, maxiter=500): - """Given a function of one variable and a starting point, find a + """Find the point where func(x) == x + + Given a function of one or more variables and a starting point, find a fixed-point of the function: i.e. where func(x)=x. + Uses Steffensen's Method using Aitken's Del^2 convergence acceleration. + See Burden, Faires, "Numerical Analysis", 5th edition, pg. 80 + See also: fmin, fmin_powell, fmin_cg, @@ -432,22 +438,25 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder - """ - + if not isscalar(x0): + x0 = asarray(x0) p0 = x0 for iter in range(maxiter): - p1 = func(*((p0,)+args)) - p2 = func(*((p1,)+args)) + p1 = func(p0, *args) + p2 = func(p1, *args) d = p2 - 2.0 * p1 + p0 - if d == 0.0: - print "Warning: Difference in estimates is %g" % (abs(p2-p1)) - return p2 + if isinstance(x0, ndarray): + p = where(d == 0, p2, p0 - (p1 - p0)*(p1-p0) / d) + if all(abs(p-p0) < xtol): + return p else: - p = p0 - (p1 - p0)*(p1-p0) / d - if abs(p-p0) < xtol: - return p + if d == 0.0: + return p2 + else: + p = p0 - (p1 - p0)*(p1-p0) / d + if abs(p-p0) < xtol: + return p p0 = p raise RuntimeError, "Failed to converge after %d iterations, value is %f" % (maxiter,p) @@ -473,7 +482,7 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder + fixed_point -- scalar and vector fixed-point finder """ i = 1 Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2008-05-28 20:34:43 UTC (rev 4390) +++ trunk/scipy/signal/signaltools.py 2008-05-28 23:46:58 UTC (rev 4391) @@ -1446,3 +1446,35 @@ olddims = vals[:axis] + [0] + vals[axis:] ret = transpose(ret,tuple(olddims)) return ret + +def filtfilt(b,a,x): + # FIXME: For now only accepting 1d arrays + ntaps=max(len(a),len(b)) + edge=ntaps*3 + + if x.ndim != 1: + raise ValueError, "Filiflit is only accepting 1 dimension arrays." + + #x must be bigger than edge + if x.size < edge: + raise ValueError, "Input vector needs to be bigger than 3 * max(len(a),len(b)." + + if len(a) < ntaps: + a=r_[a,zeros(len(b)-len(a))] + + if len(b) < ntaps: + b=r_[b,zeros(len(a)-len(b))] + + zi=lfilter_zi(b,a) + + #Grow the signal to have edges for stabilizing + #the filter with inverted replicas of the signal + s=r_[2*x[0]-x[edge:1:-1],x,2*x[-1]-x[-1:-edge:-1]] + #in the case of one go we only need one of the extrems + # both are needed for filtfilt + + (y,zf)=lfilter(b,a,s,-1,zi*s[0]) + + (y,zf)=lfilter(b,a,flipud(y),-1,zi*y[-1]) + + return flipud(y[edge-1:-edge+1]) From scipy-svn at scipy.org Wed May 28 19:58:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 18:58:53 -0500 (CDT) Subject: [Scipy-svn] r4392 - trunk/scipy/ndimage/src/register Message-ID: <20080528235853.9B0FD39C64A@scipy.org> Author: tom.waite Date: 2008-05-28 18:58:51 -0500 (Wed, 28 May 2008) New Revision: 4392 Modified: trunk/scipy/ndimage/src/register/Register_EXT.c Log: Added lower triangular tensor product for NIPY normalize Modified: trunk/scipy/ndimage/src/register/Register_EXT.c =================================================================== --- trunk/scipy/ndimage/src/register/Register_EXT.c 2008-05-28 23:46:58 UTC (rev 4391) +++ trunk/scipy/ndimage/src/register/Register_EXT.c 2008-05-28 23:58:51 UTC (rev 4392) @@ -629,9 +629,108 @@ } +static PyObject *Register_Complete_Symmetry(PyObject *self, PyObject *args) +{ + int nx; + int ny; + int nz; + int ni; + double *A; + PyObject *AlphaArray = NULL; + + if(!PyArg_ParseTuple(args, "Oiiii", &AlphaArray, &nx, &ny, &nz, &ni)) + goto exit; + + A = (double *)PyArray_DATA(AlphaArray); + + if(!NI_Complete_Symmetry(A, nx, ny, nz, ni)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + + +static PyObject *Register_LT_Tensor_Product(PyObject *self, PyObject *args) +{ + int M1; + int M2; + int rows; + int cur_row; + int coeff_1; + int coeff_2; + double *A1; + double *A2; + double *B1; + double *B2; + double *Basis; + PyObject *AlphaArray1 = NULL; + PyObject *AlphaArray2 = NULL; + PyObject *BetaArray1 = NULL; + PyObject *BetaArray2 = NULL; + PyObject *BasisArray = NULL; + + if(!PyArg_ParseTuple(args, "OOOOOiiiiii", &AlphaArray1, &AlphaArray2, &BetaArray1, &BetaArray2, + &BasisArray, &M1, &M2, &rows, &cur_row, &coeff_1, &coeff_2)) + goto exit; + + A1 = (double *)PyArray_DATA(AlphaArray1); + A2 = (double *)PyArray_DATA(AlphaArray2); + B1 = (double *)PyArray_DATA(BetaArray1); + B2 = (double *)PyArray_DATA(BetaArray2); + Basis = (double *)PyArray_DATA(BasisArray); + + if(!NI_LT_Tensor_Product(A1, A2, B1, B2, Basis, M1, M2, rows, cur_row, coeff_1, coeff_2)) + goto exit; + + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + + +static PyObject *Register_LT_Mrqcof(PyObject *self, PyObject *args) +{ + + int M1; + double wt; + double value; + double *A; + double *B; + double *V; + PyObject *AlphaArray = NULL; + PyObject *BetaArray = NULL; + PyObject *VArray = NULL; + + if(!PyArg_ParseTuple(args, "OOOddi", &AlphaArray, &BetaArray, &VArray, &wt, &value, &M1)) + goto exit; + + A = (double *)PyArray_DATA(AlphaArray); + B = (double *)PyArray_DATA(BetaArray); + V = (double *)PyArray_DATA(VArray); + + if(!NI_LT_Mrqcof(A, B, V, wt, value, M1)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + static PyMethodDef RegisterMethods[] = { + { "register_complete_symmetry", Register_Complete_Symmetry, METH_VARARGS, NULL }, + { "register_lt_mrqcof", Register_LT_Mrqcof, METH_VARARGS, NULL }, + { "register_lt_tensor_product", Register_LT_Tensor_Product, METH_VARARGS, NULL }, { "register_find_mask", Register_Find_Mask, METH_VARARGS, NULL }, { "register_resample_coords", Register_Resample_Coords, METH_VARARGS, NULL }, { "register_resample_gradient_coords", Register_Resample_Gradient_Coords, METH_VARARGS, NULL }, From scipy-svn at scipy.org Wed May 28 19:59:19 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 May 2008 18:59:19 -0500 (CDT) Subject: [Scipy-svn] r4393 - trunk/scipy/ndimage/src/register Message-ID: <20080528235919.144A039C64A@scipy.org> Author: tom.waite Date: 2008-05-28 18:59:15 -0500 (Wed, 28 May 2008) New Revision: 4393 Modified: trunk/scipy/ndimage/src/register/Register_IMPL.c Log: Added lower triangular tensor product for NIPY normalize Modified: trunk/scipy/ndimage/src/register/Register_IMPL.c =================================================================== --- trunk/scipy/ndimage/src/register/Register_IMPL.c 2008-05-28 23:58:51 UTC (rev 4392) +++ trunk/scipy/ndimage/src/register/Register_IMPL.c 2008-05-28 23:59:15 UTC (rev 4393) @@ -1203,3 +1203,167 @@ +int NI_LT_Mrqcof(double *alpha, double *beta, double *V, double wt, double value, int M1){ + + int i, j; + double v1; + int status; + + for(i = 0; i < M1; ++i){ + v1 = V[i]; + beta[i] = v1 * value * wt; + for(j = 0; j <= i; ++j){ + alpha[M1*i+j] = v1 * V[j]; + } + } + + status = 1; + + return status; + +} + + +int NI_LT_Tensor_Product(double *alpha_1, double *alpha_2, double *beta_1, double *beta_2, double *basis, + int M1, int M2, int rows, int row_number, int coeff_1, int coeff_2){ + + + // + // lower triangular tensor product + // + + int i, j, k, m; + int loop3_outer, loop3_inner; + int status; + double wt1; + double wt2; + double *ptr1; + double *ptr2; + + for(i = 0; i < coeff_1; ++i){ + wt1 = basis[rows*i + row_number]; + for(loop3_outer = 0; loop3_outer < 3; ++loop3_outer){ + // + // spatial-spatial covariances + // + for(loop3_inner = 0; loop3_inner <= loop3_outer; ++loop3_inner){ + for(j = 0; j <= i; ++j){ + // + // outer product of basis array + // + wt2 = wt1 * basis[rows*j + row_number]; + ptr1 = &alpha_1[coeff_2*(M1*(coeff_1*loop3_outer+i)+(coeff_1*loop3_inner)+j)]; + ptr2 = &alpha_2[coeff_2*(M2*loop3_outer+loop3_inner)]; + for(k = 0; k < coeff_2; ++k){ + for(m = 0; m <= k; ++m){ + ptr1[M1*k+m] += (wt2 * ptr2[M2*k+m]); + } + } + } + // + // spatial-intensity covariances (single G volume assumed) + // + ptr1 = &alpha_1[coeff_2*(M1*coeff_1*3+(coeff_1*loop3_inner)+i)]; + ptr2 = &alpha_2[coeff_2*(M2*3+loop3_outer)]; + for(k = 0; k < coeff_2; ++k){ + ptr1[M1+k] += (wt1 * ptr2[M2+k]); + } + // + // spatial component of beta + // + for(k = 0; k < coeff_2; ++k){ + beta_1[k+coeff_2*(coeff_1*loop3_outer+i)] += (wt1 * beta_2[coeff_2*loop3_outer+k]); + } + } + } + } + + // + // intensity-intensity covariances + // + ptr1 = &alpha_1[coeff_2*(M1*coeff_1*3+(coeff_1*3))]; + ptr2 = &alpha_2[coeff_2*(M2*3+3)]; + for(k = 0; k < coeff_2; ++k){ + ptr1[k] += ptr2[k]; + } + + // + // intensity component of beta + // + + beta_1[coeff_2*coeff_1*3] += beta_2[coeff_2*3]; + + status = 1; + + return status; + +} + + + +int NI_Complete_Symmetry(double *Alpha, int nx, int ny, int nz, int ni4){ + + // + // complete symmetry of Alpha matrix over the 3D brain volume + // + + int z1, z2; + int y1, y2; + int x1, x2; + int loop3_outer, loop3_inner; + int M1; + int status; + double *ptrx; + double *ptry; + double *ptrz; + + M1 = 3*nx*ny*nz + ni4; + + for(loop3_outer = 0; loop3_outer < 3; ++loop3_outer){ + for(loop3_inner = 0; loop3_inner <= loop3_outer; ++loop3_inner){ + ptrz = &Alpha[nx*ny*nz*(M1*loop3_outer+loop3_inner)]; + for(z1 = 0; z1 < nz; ++z1){ + for(z2 = 0; z2 <= z1; ++z2){ + ptry = ptrz + nx*ny*(M1*z1 + z2); + for(y1 = 0; y1 < ny; ++y1){ + for(y2 = 0; y2 <= y1; ++y2){ + ptrx = ptry + nx*(M1*y1 + y2); + for(x1 = 0; x1 <= nx; ++x1){ + for(y2 = 0; y2 <= y1; ++y2){ + ptrx[M1*x2+x1] = ptrx[M1*x1+x2]; + } + } + } + } + for(x1 = 0; x1 < nx*ny; ++x1){ + for(x2 = 0; x2 < x1; ++x2){ + ptry[M1*x2+x1] = ptry[M1*x1+x2]; + } + } + } + for(x1 = 0; x1 < nx*ny*nz; ++x1){ + for(x2 = 0; x2 < x1; ++x2){ + ptrz[M1*x2+x1] = ptrz[M1*x1+x2]; + } + } + + } + } + } + + for(x1 = 0; x1 < nx*ny*nz*3+ni4; ++x1){ + for(x2 = 0; x2 < x1; ++x2){ + Alpha[M1*x2+x1] = Alpha[M1*x1+x2]; + } + } + + + status = 1; + + return status; + +} + + + + From scipy-svn at scipy.org Thu May 29 21:21:39 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 May 2008 20:21:39 -0500 (CDT) Subject: [Scipy-svn] r4394 - trunk/scipy/ndimage/src/register Message-ID: <20080530012139.C54D239C55D@scipy.org> Author: tom.waite Date: 2008-05-29 20:21:37 -0500 (Thu, 29 May 2008) New Revision: 4394 Modified: trunk/scipy/ndimage/src/register/Register_IMPL.c Log: removed the integer truncation of image resample gradients. Modified: trunk/scipy/ndimage/src/register/Register_IMPL.c =================================================================== --- trunk/scipy/ndimage/src/register/Register_IMPL.c 2008-05-28 23:59:15 UTC (rev 4393) +++ trunk/scipy/ndimage/src/register/Register_IMPL.c 2008-05-30 01:21:37 UTC (rev 4394) @@ -936,9 +936,9 @@ V110 * (dx1) * (dy1) * (-1.0) + V111 * (dx1) * (dy1) * (1.0); - gradientX[sliceD+rowD+(int)x] = (int)(gradX*scale[(int)zp]); - gradientY[sliceD+rowD+(int)x] = (int)(gradY*scale[(int)zp]); - gradientZ[sliceD+rowD+(int)x] = (int)(gradZ*scale[(int)zp]); + gradientX[sliceD+rowD+(int)x] = (gradX*scale[(int)zp]); + gradientY[sliceD+rowD+(int)x] = (gradY*scale[(int)zp]); + gradientZ[sliceD+rowD+(int)x] = (gradZ*scale[(int)zp]); } } @@ -1083,9 +1083,9 @@ V111 * (dx1) * (dy1) * (1.0); /* gradients saved in the unrolled clipped gradient volume */ - gradientX[i] = (int)(gradX*scale[(int)zp]); - gradientY[i] = (int)(gradY*scale[(int)zp]); - gradientZ[i] = (int)(gradZ*scale[(int)zp]); + gradientX[i] = (gradX*scale[(int)zp]); + gradientY[i] = (gradY*scale[(int)zp]); + gradientZ[i] = (gradZ*scale[(int)zp]); } From scipy-svn at scipy.org Thu May 29 22:23:28 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 May 2008 21:23:28 -0500 (CDT) Subject: [Scipy-svn] r4395 - trunk/scipy/cluster/tests Message-ID: <20080530022328.27907C7C167@scipy.org> Author: damian.eads Date: 2008-05-29 21:23:09 -0500 (Thu, 29 May 2008) New Revision: 4395 Added: trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt trunk/scipy/cluster/tests/inconsistent-single-tdist.txt trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt trunk/scipy/cluster/tests/linkage-X.txt trunk/scipy/cluster/tests/linkage-average-tdist.txt trunk/scipy/cluster/tests/linkage-complete-tdist.txt trunk/scipy/cluster/tests/linkage-single-tdist.txt trunk/scipy/cluster/tests/linkage-weighted-tdist.txt Modified: trunk/scipy/cluster/tests/test_hierarchy.py Log: Added some more test data. Added: trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 4.0000000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 4.1200000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 9.9600000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 Added: trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.6900000e+02 1.8526198e+02 2.0000000e+00 7.0710678e-01 + 3.1550000e+02 1.3647161e+02 2.0000000e+00 7.0710678e-01 + 6.0266667e+02 3.4068950e+02 3.0000000e+00 1.1545215e+00 Added: trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.6900000e+02 1.8526198e+02 2.0000000e+00 7.0710678e-01 + 3.1550000e+02 1.3647161e+02 2.0000000e+00 7.0710678e-01 + 4.3300000e+02 3.3590177e+02 5.0000000e+00 1.6760852e+00 Added: trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.6900000e+02 1.8526198e+02 2.0000000e+00 7.0710678e-01 + 3.1550000e+02 1.3647161e+02 2.0000000e+00 7.0710678e-01 + 4.3300000e+02 3.3590177e+02 5.0000000e+00 1.6760852e+00 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.5500000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.6800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.9500000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.5500000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.6800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.9500000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.3700000e+02 2.5455844e+01 2.0000000e+00 7.0710678e-01 + 2.6150000e+02 9.1923882e+00 2.0000000e+00 7.0710678e-01 + 2.3366667e+02 8.3942441e+01 3.0000000e+00 7.3065940e-01 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.3700000e+02 2.5455844e+01 2.0000000e+00 7.0710678e-01 + 2.4733333e+02 2.5383722e+01 3.0000000e+00 8.1417007e-01 + 2.3900000e+02 6.9363775e+01 4.0000000e+00 8.0733783e-01 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.3700000e+02 2.5455844e+01 2.0000000e+00 7.0710678e-01 + 2.4733333e+02 2.5383722e+01 3.0000000e+00 8.1417007e-01 + 2.3500000e+02 6.0733022e+01 5.0000000e+00 9.8793042e-01 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.3700000e+02 2.5455844e+01 2.0000000e+00 7.0710678e-01 + 2.4733333e+02 2.5383722e+01 3.0000000e+00 8.1417007e-01 + 2.3500000e+02 6.0733022e+01 5.0000000e+00 9.8793042e-01 Added: trunk/scipy/cluster/tests/inconsistent-single-tdist.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-single-tdist.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-single-tdist.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.3700000e+02 2.5455844e+01 2.0000000e+00 7.0710678e-01 + 2.6150000e+02 9.1923882e+00 2.0000000e+00 7.0710678e-01 + 2.3366667e+02 8.3942441e+01 3.0000000e+00 7.3065940e-01 Added: trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 3.3350000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 3.4750000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 6.7012500e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 Added: trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.7625000e+02 8.0963726e+01 2.0000000e+00 7.0710678e-01 + 2.4275000e+02 1.4813887e+02 2.0000000e+00 7.0710678e-01 + 4.5037500e+02 1.9043778e+02 3.0000000e+00 1.1539202e+00 Added: trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.7625000e+02 8.0963726e+01 2.0000000e+00 7.0710678e-01 + 2.4275000e+02 1.4813887e+02 2.0000000e+00 7.0710678e-01 + 3.4162500e+02 2.0280090e+02 5.0000000e+00 1.6198153e+00 Added: trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt =================================================================== --- trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.7625000e+02 8.0963726e+01 2.0000000e+00 7.0710678e-01 + 2.4275000e+02 1.4813887e+02 2.0000000e+00 7.0710678e-01 + 3.4162500e+02 2.0280090e+02 5.0000000e+00 1.6198153e+00 Added: trunk/scipy/cluster/tests/linkage-X.txt =================================================================== --- trunk/scipy/cluster/tests/linkage-X.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/linkage-X.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,117 @@ + 6.6200000e+02 8.7700000e+02 2.5500000e+02 4.1200000e+02 9.9600000e+02 2.9500000e+02 4.6800000e+02 2.6800000e+02 4.0000000e+02 7.5400000e+02 5.6400000e+02 1.3800000e+02 2.1900000e+02 8.6900000e+02 6.6900000e+02 + 1.3800000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.1900000e+02 0.0000000e+00 1.0000000e+00 0.0000000e+00 + 2.7625000e+02 8.0963726e+01 2.0000000e+00 7.0710678e-01 + 2.4275000e+02 1.4813887e+02 2.0000000e+00 7.0710678e-01 + 3.4162500e+02 2.0280090e+02 5.0000000e+00 1.6198153e+00 + 9.5012929e-01 5.8279168e-01 4.3979086e-01 3.6031117e-01 + 2.3113851e-01 4.2349626e-01 3.4004795e-01 5.4851281e-01 + 6.0684258e-01 5.1551175e-01 3.1421731e-01 2.6176957e-01 + 4.8598247e-01 3.3395148e-01 3.6507839e-01 5.9734485e-01 + 8.9129897e-01 4.3290660e-01 3.9323955e-01 4.9277997e-02 + 7.6209683e-01 2.2594987e-01 5.9152520e-01 5.7105749e-01 + 4.5646767e-01 5.7980687e-01 1.1974662e-01 7.0085723e-01 + 1.8503643e-02 7.6036501e-01 3.8128797e-02 9.6228826e-01 + 8.2140716e-01 5.2982312e-01 4.5859795e-01 7.5051823e-01 + 4.4470336e-01 6.4052650e-01 8.6986735e-01 7.3999305e-01 + 6.1543235e-01 2.0906940e-01 9.3423652e-01 4.3187339e-01 + 7.9193704e-01 3.7981837e-01 2.6444917e-01 6.3426596e-01 + 9.2181297e-01 7.8332865e-01 1.6030034e-01 8.0302634e-01 + 7.3820725e-01 6.8084575e-01 8.7285526e-01 8.3881007e-02 + 1.7626614e-01 4.6109513e-01 2.3788031e-01 9.4546279e-01 + 4.0570621e-01 5.6782871e-01 6.4583125e-01 9.1594246e-01 + 9.3546970e-01 7.9421065e-01 9.6688742e-01 6.0198742e-01 + 9.1690444e-01 5.9182593e-02 6.6493121e-01 2.5356058e-01 + 4.1027021e-01 6.0286909e-01 8.7038103e-01 8.7345081e-01 + 8.9364953e-01 5.0268804e-02 9.9273048e-03 5.1340071e-01 + 5.7891305e-02 4.1537486e-01 1.3700989e-01 7.3265065e-01 + 3.5286813e-01 3.0499868e-01 8.1875583e-01 4.2222659e-01 + 8.1316650e-01 8.7436717e-01 4.3016605e-01 9.6137000e-01 + 9.8613007e-03 1.5009499e-02 8.9032172e-01 7.2059239e-02 + 1.3889088e-01 7.6795039e-01 7.3490821e-01 5.5340797e-01 + 2.0276522e-01 9.7084494e-01 6.8732359e-01 2.9198392e-01 + 1.9872174e-01 9.9008259e-01 3.4611197e-01 8.5796351e-01 + 6.0379248e-01 7.8886169e-01 1.6603474e-01 3.3575514e-01 + 2.7218792e-01 4.3865853e-01 1.5561258e-01 6.8020385e-01 + 1.9881427e-01 4.9831130e-01 1.9111631e-01 5.3444421e-02 + 1.5273927e-02 2.1396333e-01 4.2245153e-01 3.5665554e-01 + 7.4678568e-01 6.4349229e-01 8.5597571e-01 4.9830460e-01 + 4.4509643e-01 3.2003558e-01 4.9024999e-01 4.3444054e-01 + 9.3181458e-01 9.6009860e-01 8.1593477e-01 5.6245842e-01 + 4.6599434e-01 7.2663177e-01 4.6076983e-01 6.1662113e-01 + 4.1864947e-01 4.1195321e-01 4.5735438e-01 1.1333998e-01 + 8.4622142e-01 7.4456578e-01 4.5068888e-01 8.9825174e-01 + 5.2515250e-01 2.6794725e-01 4.1221906e-01 7.5455138e-01 + 2.0264736e-01 4.3992431e-01 9.0160982e-01 7.9112320e-01 + 6.7213747e-01 9.3338011e-01 5.5839392e-03 8.1495207e-01 + 8.3811845e-01 6.8333232e-01 2.9740568e-01 6.7000386e-01 + 1.9639514e-02 2.1255986e-01 4.9162489e-02 2.0087641e-01 + 6.8127716e-01 8.3923824e-01 6.9318045e-01 2.7308816e-01 + 3.7948102e-01 6.2878460e-01 6.5010641e-01 6.2623464e-01 + 8.3179602e-01 1.3377275e-01 9.8298778e-01 5.3685169e-01 + 5.0281288e-01 2.0713273e-01 5.5267324e-01 5.9504051e-02 + 7.0947139e-01 6.0719894e-01 4.0007352e-01 8.8961759e-02 + 4.2889237e-01 6.2988785e-01 1.9878852e-01 2.7130817e-01 + 3.0461737e-01 3.7047683e-01 6.2520102e-01 4.0907232e-01 + 1.8965375e-01 5.7514778e-01 7.3336280e-01 4.7404145e-01 + 1.9343116e-01 4.5142483e-01 3.7588548e-01 9.0898935e-01 + 6.8222322e-01 4.3895325e-02 9.8764629e-03 5.9624714e-01 + 3.0276440e-01 2.7185123e-02 4.1985781e-01 3.2895530e-01 + 5.4167385e-01 3.1268505e-01 7.5366963e-01 4.7819443e-01 + 1.5087298e-01 1.2862575e-02 7.9387177e-01 5.9717078e-01 + 6.9789848e-01 3.8396729e-01 9.1995721e-01 1.6144875e-01 + 3.7837300e-01 6.8311597e-01 8.4472150e-01 8.2947425e-01 + 8.6001160e-01 9.2842462e-02 3.6775288e-01 9.5612241e-01 + 8.5365513e-01 3.5338324e-02 6.2080133e-01 5.9554800e-01 + 5.9356291e-01 6.1239548e-01 7.3127726e-01 2.8748213e-02 + 4.9655245e-01 6.0854036e-01 1.9389318e-01 8.1211782e-01 + 8.9976918e-01 1.5759818e-02 9.0481233e-01 6.1011358e-01 + 8.2162916e-01 1.6354934e-02 5.6920575e-01 7.0149260e-01 + 6.4491038e-01 1.9007459e-01 6.3178993e-01 9.2196203e-02 + 8.1797434e-01 5.8691847e-01 2.3441296e-01 4.2488914e-01 + 6.6022756e-01 5.7581090e-02 5.4878213e-01 3.7557666e-01 + 3.4197062e-01 3.6756804e-01 9.3158335e-01 1.6615408e-01 + 2.8972590e-01 6.3145116e-01 3.3519743e-01 8.3315146e-01 + 3.4119357e-01 7.1763442e-01 6.5553106e-01 8.3863970e-01 + 5.3407902e-01 6.9266939e-01 3.9190421e-01 4.5161403e-01 + 7.2711322e-01 8.4079061e-02 6.2731479e-01 9.5660138e-01 + 3.0929016e-01 4.5435515e-01 6.9908014e-01 1.4715324e-01 + 8.3849604e-01 4.4182830e-01 3.9718395e-01 8.6993293e-01 + 5.6807246e-01 3.5325046e-01 4.1362890e-01 7.6943640e-01 + 3.7041356e-01 1.5360636e-01 6.5521295e-01 4.4416162e-01 + 7.0273991e-01 6.7564465e-01 8.3758510e-01 6.2062012e-01 + 5.4657115e-01 6.9921333e-01 3.7160803e-01 9.5168928e-01 + 4.4488020e-01 7.2750913e-01 4.2525316e-01 6.4000966e-01 + 6.9456724e-01 4.7838438e-01 5.9466337e-01 2.4732763e-01 + 6.2131013e-01 5.5484199e-01 5.6573857e-01 3.5270199e-01 + 7.9482108e-01 1.2104711e-01 7.1654240e-01 1.8786048e-01 + 9.5684345e-01 4.5075394e-01 5.1131145e-01 4.9064436e-01 + 5.2259035e-01 7.1588295e-01 7.7640121e-01 4.0927433e-01 + 8.8014221e-01 8.9284161e-01 4.8934548e-01 4.6352558e-01 + 1.7295614e-01 2.7310247e-01 1.8590445e-01 6.1094355e-01 + 9.7974690e-01 2.5476930e-01 7.0063541e-01 7.1168466e-02 + 2.7144726e-01 8.6560348e-01 9.8270880e-01 3.1428029e-01 + 2.5232935e-01 2.3235037e-01 8.0663775e-01 6.0838366e-01 + 8.7574190e-01 8.0487174e-01 7.0356766e-01 1.7502018e-01 + 7.3730599e-01 9.0839754e-01 4.8496372e-01 6.2102743e-01 + 1.3651874e-01 2.3189432e-01 1.1461282e-01 2.4595993e-01 + 1.1756687e-02 2.3931256e-01 6.6485557e-01 5.8735822e-01 + 8.9389797e-01 4.9754484e-02 3.6537389e-01 5.0605345e-01 + 1.9913807e-01 7.8384075e-02 1.4004446e-01 4.6477892e-01 + 2.9872301e-01 6.4081541e-01 5.6677280e-01 5.4141893e-01 + 6.6144258e-01 1.9088657e-01 8.2300831e-01 9.4232657e-01 + 2.8440859e-01 8.4386950e-01 6.7394863e-01 3.4175909e-01 + 4.6922429e-01 1.7390025e-01 9.9944730e-01 4.0180434e-01 + 6.4781123e-02 1.7079281e-01 9.6163641e-01 3.0768794e-01 + 9.8833494e-01 9.9429549e-01 5.8862165e-02 4.1156796e-01 + 6.6200000e+02 8.7700000e+02 2.5500000e+02 4.1200000e+02 9.9600000e+02 2.9500000e+02 4.6800000e+02 2.6800000e+02 4.0000000e+02 7.5400000e+02 5.6400000e+02 1.3800000e+02 2.1900000e+02 8.6900000e+02 6.6900000e+02 + 3.0000000e+00 6.0000000e+00 1.3800000e+02 + 4.0000000e+00 5.0000000e+00 2.1900000e+02 + 1.0000000e+00 8.0000000e+00 3.3350000e+02 + 2.0000000e+00 7.0000000e+00 3.4750000e+02 + 9.0000000e+00 1.0000000e+01 6.7012500e+02 + 3.0000000e+00 6.0000000e+00 1.3800000e+02 + 4.0000000e+00 5.0000000e+00 2.1900000e+02 + 1.0000000e+00 8.0000000e+00 2.5500000e+02 + 2.0000000e+00 9.0000000e+00 2.6800000e+02 + 7.0000000e+00 1.0000000e+01 2.9500000e+02 Added: trunk/scipy/cluster/tests/linkage-average-tdist.txt =================================================================== --- trunk/scipy/cluster/tests/linkage-average-tdist.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/linkage-average-tdist.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 3.0000000e+00 6.0000000e+00 1.3800000e+02 + 4.0000000e+00 5.0000000e+00 2.1900000e+02 + 1.0000000e+00 8.0000000e+00 3.3350000e+02 + 2.0000000e+00 7.0000000e+00 3.4750000e+02 + 9.0000000e+00 1.0000000e+01 6.8077778e+02 Added: trunk/scipy/cluster/tests/linkage-complete-tdist.txt =================================================================== --- trunk/scipy/cluster/tests/linkage-complete-tdist.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/linkage-complete-tdist.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 3.0000000e+00 6.0000000e+00 1.3800000e+02 + 4.0000000e+00 5.0000000e+00 2.1900000e+02 + 2.0000000e+00 7.0000000e+00 4.0000000e+02 + 1.0000000e+00 8.0000000e+00 4.1200000e+02 + 9.0000000e+00 1.0000000e+01 9.9600000e+02 Added: trunk/scipy/cluster/tests/linkage-single-tdist.txt =================================================================== --- trunk/scipy/cluster/tests/linkage-single-tdist.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/linkage-single-tdist.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 3.0000000e+00 6.0000000e+00 1.3800000e+02 + 4.0000000e+00 5.0000000e+00 2.1900000e+02 + 1.0000000e+00 8.0000000e+00 2.5500000e+02 + 2.0000000e+00 9.0000000e+00 2.6800000e+02 + 7.0000000e+00 1.0000000e+01 2.9500000e+02 Added: trunk/scipy/cluster/tests/linkage-weighted-tdist.txt =================================================================== --- trunk/scipy/cluster/tests/linkage-weighted-tdist.txt 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/linkage-weighted-tdist.txt 2008-05-30 02:23:09 UTC (rev 4395) @@ -0,0 +1,5 @@ + 3.0000000e+00 6.0000000e+00 1.3800000e+02 + 4.0000000e+00 5.0000000e+00 2.1900000e+02 + 1.0000000e+00 8.0000000e+00 3.3350000e+02 + 2.0000000e+00 7.0000000e+00 3.4750000e+02 + 9.0000000e+00 1.0000000e+01 6.7012500e+02 Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 01:21:37 UTC (rev 4394) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 02:23:09 UTC (rev 4395) @@ -66,6 +66,13 @@ "pdist-chebychev-ml.txt", "pdist-chebychev-ml-iris.txt"] +_tdist = np.array([[0, 662, 877, 255, 412, 996], + [662, 0, 295, 468, 268, 400], + [877, 295, 0, 754, 564, 138], + [255, 468, 754, 0, 219, 869], + [412, 268, 564, 219, 0, 669], + [996, 400, 138, 869, 669, 0 ]]) + # A hashmap of expected output arrays for the tests. These arrays # come from a list of text files, which are read prior to testing. @@ -554,3 +561,4 @@ if __name__ == "__main__": nose.run(argv=['', __file__]) + From scipy-svn at scipy.org Fri May 30 15:37:06 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 14:37:06 -0500 (CDT) Subject: [Scipy-svn] r4396 - in trunk/scipy/cluster: . src tests Message-ID: <20080530193706.DB9E839C8DB@scipy.org> Author: damian.eads Date: 2008-05-30 14:36:47 -0500 (Fri, 30 May 2008) New Revision: 4396 Modified: trunk/scipy/cluster/hierarchy.py trunk/scipy/cluster/src/hierarchy.c trunk/scipy/cluster/tests/test_hierarchy.py Log: Added some initial tests for hierarchy.linkage and hierarchy.squareform Modified: trunk/scipy/cluster/hierarchy.py =================================================================== --- trunk/scipy/cluster/hierarchy.py 2008-05-30 02:23:09 UTC (rev 4395) +++ trunk/scipy/cluster/hierarchy.py 2008-05-30 19:36:47 UTC (rev 4396) @@ -735,7 +735,6 @@ # is indeed a binomial coefficient. d = int(np.ceil(np.sqrt(X.shape[0] * 2))) - print d, s[0] # Check that v is of valid dimensions. if d * (d - 1) / 2 != int(s[0]): raise ValueError('Incompatible vector size. It must be a binomial coefficient n choose 2 for some integer n >= 2.') @@ -760,9 +759,9 @@ raise ValueError('The matrix argument must be square.') if checks: if np.sum(np.sum(X == X.transpose())) != np.product(X.shape): - raise ValueError('The distance matrix must be symmetrical.') + raise ValueError('The distance matrix array must be symmetrical.') if (X.diagonal() != 0).any(): - raise ValueError('The distance matrix must have zeros along the diagonal.') + raise ValueError('The distance matrix array must have zeros along the diagonal.') # One-side of the dimensions is set here. d = s[0] @@ -780,7 +779,7 @@ elif len(s) != 2 and force.lower() == 'tomatrix': raise ValueError("Forcing 'tomatrix' but input X is not a distance vector.") else: - raise ValueError('The first argument must be a vector or matrix. A %d-dimensional array is not permitted' % len(s)) + raise ValueError('The first argument must be one or two dimensional array. A %d-dimensional array is not permitted' % len(s)) def minkowski(u, v, p): """ @@ -1607,7 +1606,6 @@ the number of original observations (leaves) in the non-singleton cluster i. """ - is_valid_linkage(Z, throw=True, name='Z') Zs = Z.shape Zpart = Z[:,0:2] Zd = Z[:,2].reshape(Zs[0], 1) Modified: trunk/scipy/cluster/src/hierarchy.c =================================================================== --- trunk/scipy/cluster/src/hierarchy.c 2008-05-30 02:23:09 UTC (rev 4395) +++ trunk/scipy/cluster/src/hierarchy.c 2008-05-30 19:36:47 UTC (rev 4396) @@ -734,7 +734,7 @@ xi = inds[i]; cnode *xnd = info->nodes + xi; xn = xnd->n; - mply = 1.0 / (((double)xn) * rscnt); + mply = (double)1.0 / (((double)xn) * rscnt); *bit = mply * ((drx * (rc * xn)) + (dsx * (sc * xn))); } for (i = mini + 1; i < minj; i++, bit++) { @@ -743,7 +743,7 @@ xi = inds[i]; cnode *xnd = info->nodes + xi; xn = xnd->n; - mply = 1.0 / (((double)xn) * rscnt); + mply = (double)1.0 / (((double)xn) * rscnt); *bit = mply * ((drx * (rc * xn)) + (dsx * (sc * xn))); } for (i = minj + 1; i < np; i++, bit++) { @@ -752,7 +752,7 @@ xi = inds[i]; cnode *xnd = info->nodes + xi; xn = xnd->n; - mply = 1.0 / (((double)xn) * rscnt); + mply = (double)1.0 / (((double)xn) * rscnt); *bit = mply * ((drx * (rc * xn)) + (dsx * (sc * xn))); } } Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 02:23:09 UTC (rev 4395) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 19:36:47 UTC (rev 4396) @@ -37,7 +37,7 @@ import sys import os.path from scipy.testing import * -from scipy.cluster.hierarchy import pdist +from scipy.cluster.hierarchy import pdist, squareform, linkage, from_mlab_linkage import numpy #import math @@ -64,15 +64,21 @@ "pdist-euclidean-ml.txt", "pdist-euclidean-ml-iris.txt", "pdist-chebychev-ml.txt", - "pdist-chebychev-ml-iris.txt"] + "pdist-chebychev-ml-iris.txt", + "linkage-single-tdist.txt", + "linkage-complete-tdist.txt", + "linkage-average-tdist.txt", + "linkage-weighted-tdist.txt"] -_tdist = np.array([[0, 662, 877, 255, 412, 996], - [662, 0, 295, 468, 268, 400], - [877, 295, 0, 754, 564, 138], - [255, 468, 754, 0, 219, 869], - [412, 268, 564, 219, 0, 669], - [996, 400, 138, 869, 669, 0 ]]) +_tdist = numpy.array([[0, 662, 877, 255, 412, 996], + [662, 0, 295, 468, 268, 400], + [877, 295, 0, 754, 564, 138], + [255, 468, 754, 0, 219, 869], + [412, 268, 564, 219, 0, 669], + [996, 400, 138, 869, 669, 0 ]], dtype='double') +_ytdist = squareform(_tdist) + # A hashmap of expected output arrays for the tests. These arrays # come from a list of text files, which are read prior to testing. @@ -556,6 +562,104 @@ #print "test-chebychev-iris", numpy.abs(Y_test2 - Y_right).max() self.failUnless(within_tol(Y_test2, Y_right, eps)) + def test_pdist_chebychev_iris_nonC(self): + "Tests pdist(X, 'test_chebychev') [the non-C implementation] on the Iris data set." + eps = 1e-15 + # Get the data: the input matrix and the right output. + X = eo['iris'] + Y_right = eo['pdist-chebychev-iris'] + Y_test2 = pdist(X, 'test_chebychev') + #print "test-chebychev-iris", numpy.abs(Y_test2 - Y_right).max() + self.failUnless(within_tol(Y_test2, Y_right, eps)) + + def test_squareform_empty_matrix(self): + "Tests squareform on an empty matrix." + A = numpy.zeros((0,0)) + rA = squareform(numpy.array(A, dtype='double')) + self.failUnless(rA.shape == (0,)) + + def test_squareform_empty_vector(self): + v = numpy.zeros((0,)) + rv = squareform(numpy.array(v, dtype='double')) + self.failUnless(rv.shape == (0,0)) + + def test_squareform_1by1_matrix(self): + "Tests squareform on a 1x1 matrix." + A = numpy.zeros((1,1)) + rA = squareform(numpy.array(A, dtype='double')) + self.failUnless(rA.shape == (0,)) + + def test_squareform_one_vector(self): + "Tests squareform on a 1-D array, length=1." + v = numpy.ones((1,)) * 8.3 + rv = squareform(numpy.array(v, dtype='double')) + self.failUnless(rv.shape == (2,2)) + self.failUnless(rv[0,1] == 8.3) + self.failUnless(rv[1,0] == 8.3) + + def test_squareform_2by2_matrix(self): + "Tests squareform on a 2x2 matrix." + A = numpy.zeros((2,2)) + A[0,1]=0.8 + A[1,0]=0.8 + rA = squareform(numpy.array(A, dtype='double')) + self.failUnless(rA.shape == (1,)) + self.failUnless(rA[0] == 0.8) + + def test_squareform_multi_matrix(self): + "Tests squareform on a square matrices of multiple sizes." + for n in xrange(2, 5): + X = numpy.random.rand(n, 4) + Y = pdist(X) + A = squareform(Y) + Yr = squareform(A) + s = A.shape + k = 0 + #print A.shape, Y.shape, Yr.shape + for i in xrange(0, s[0]): + for j in xrange(i+1, s[1]): + if i != j: + #print i, j, k, A[i, j], Y[k] + self.failUnless(A[i, j] == Y[k]) + self.failUnless(Yr[k] == Y[k]) + k += 1 + else: + self.failUnless(A[i, j] == 0) + + def test_linkage_single_tdist(self): + "Tests linkage(Y, 'single') on the tdist data set." + Z = linkage(_ytdist, 'single') + Zmlab = eo['linkage-single-tdist'] + eps = 1e-10 + expectedZ = from_mlab_linkage(Zmlab) + self.failUnless(within_tol(Z, expectedZ, eps)) + + def test_linkage_complete_tdist(self): + "Tests linkage(Y, 'complete') on the tdist data set." + Z = linkage(_ytdist, 'complete') + Zmlab = eo['linkage-complete-tdist'] + eps = 1e-10 + expectedZ = from_mlab_linkage(Zmlab) + self.failUnless(within_tol(Z, expectedZ, eps)) + + def test_linkage_average_tdist(self): + "Tests linkage(Y, 'average') on the tdist data set." + Z = linkage(_ytdist, 'average') + Zmlab = eo['linkage-average-tdist'] + eps = 1e-05 + expectedZ = from_mlab_linkage(Zmlab) + #print Z, expectedZ, numpy.abs(Z - expectedZ).max() + self.failUnless(within_tol(Z, expectedZ, eps)) + + def test_linkage_weighted_tdist(self): + "Tests linkage(Y, 'weighted') on the tdist data set." + Z = linkage(_ytdist, 'weighted') + Zmlab = eo['linkage-weighted-tdist'] + eps = 1e-10 + expectedZ = from_mlab_linkage(Zmlab) + #print Z, expectedZ, numpy.abs(Z - expectedZ).max() + self.failUnless(within_tol(Z, expectedZ, eps)) + def within_tol(a, b, tol): return numpy.abs(a - b).max() < tol From scipy-svn at scipy.org Fri May 30 16:30:29 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 15:30:29 -0500 (CDT) Subject: [Scipy-svn] r4397 - in trunk/scipy/cluster: . tests Message-ID: <20080530203029.0476F39C603@scipy.org> Author: damian.eads Date: 2008-05-30 15:30:15 -0500 (Fri, 30 May 2008) New Revision: 4397 Modified: trunk/scipy/cluster/hierarchy.py trunk/scipy/cluster/tests/test_hierarchy.py Log: Fixed bug in hierarchy.is_valid_linkage. Wrote tests for hierarchy.numobs. Modified: trunk/scipy/cluster/hierarchy.py =================================================================== --- trunk/scipy/cluster/hierarchy.py 2008-05-30 19:36:47 UTC (rev 4396) +++ trunk/scipy/cluster/hierarchy.py 2008-05-30 20:30:15 UTC (rev 4397) @@ -1735,12 +1735,13 @@ else: raise ValueError('Linkage matrix must have 4 columns.') n = Z.shape[0] - if not ((Z[:,0]-xrange(n-1, n*2-1) < 0).any()) or \ - not (Z[:,1]-xrange(n-1, n*2-1) < 0).any(): - if name: - raise ValueError('Linkage \'%s\' contains negative indices.' % name) - else: - raise ValueError('Linkage contains negative indices.') + if n > 1: + if ((Z[:,0] < 0).any() or + (Z[:,1] < 0).any()): + if name: + raise ValueError('Linkage \'%s\' contains negative indices.' % name) + else: + raise ValueError('Linkage contains negative indices.') except Exception, e: if throw: raise @@ -1805,7 +1806,7 @@ return valid -def is_valid_dm(D, t=0.0): +def is_valid_dm(D, tol=0.0, throw=False, name="D"): """ is_valid_dm(D) @@ -1813,12 +1814,12 @@ Distance matrices must be 2-dimensional numpy arrays containing doubles. They must have a zero-diagonal, and they must be symmetric. - is_valid_dm(D, t) + is_valid_dm(D, tol) Returns True if the variable D passed is a valid distance matrix. Small numerical differences in D and D.T and non-zeroness of the diagonal are ignored if they are within the tolerance specified - by t. + by tol. is_valid_dm(..., warning=True, name='V') @@ -1841,6 +1842,7 @@ raise TypeError('\'%s\' passed as a distance matrix is not a numpy array.' % name) else: raise TypeError('Variable is not a numpy array.') + s = D.shape if D.dtype != np.double: if name: raise TypeError('Distance matrix \'%s\' must contain doubles (float64).' % name) @@ -1851,7 +1853,7 @@ raise ValueError('Distance matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) else: raise ValueError('Distance matrix must have shape=2 (i.e. be two-dimensional).') - if t == 0.0: + if tol == 0.0: if not (D == D.T).all(): if name: raise ValueError('Distance matrix \'%s\' must be symmetric.' % name) @@ -1863,16 +1865,16 @@ else: raise ValueError('Distance matrix diagonal must be zero.') else: - if not (D - D.T <= t).all(): + if not (D - D.T <= tol).all(): if name: - raise ValueError('Distance matrix \'%s\' must be symmetric within tolerance %d.' % (name, t)) + raise ValueError('Distance matrix \'%s\' must be symmetric within tolerance %d.' % (name, tol)) else: - raise ValueError('Distance matrix must be symmetric within tolerance %d.' % t) - if not (D[xrange(0, s[0]), xrange(0, s[0])] <= t).all(): + raise ValueError('Distance matrix must be symmetric within tolerance %5.5f.' % tol) + if not (D[xrange(0, s[0]), xrange(0, s[0])] <= tol).all(): if name: - raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %d.' % (name, t)) + raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %5.5f.' % (name, tol)) else: - raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %d.' % t) + raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %5.5f.' % tol) except Exception, e: if throw: raise @@ -1887,7 +1889,7 @@ linkage matrix Z. """ is_valid_linkage(Z, throw=True, name='Z') - return (Z.shape[0] - 1) + return (Z.shape[0] + 1) def numobs_dm(D): """ @@ -1896,7 +1898,7 @@ Returns the number of original observations that correspond to a square, non-condensed distance matrix D. """ - is_valid_dm(D, tol=Inf, throw=True, name='D') + is_valid_dm(D, tol=scipy.inf, throw=True, name='D') return D.shape[0] def numobs_y(Y): @@ -1906,8 +1908,8 @@ Returns the number of original observations that correspond to a condensed distance matrix Y. """ - is_valid_y(y, throw=True, name='Y') - d = int(np.ceil(np.sqrt(y.shape[0] * 2))) + is_valid_y(Y, throw=True, name='Y') + d = int(np.ceil(np.sqrt(Y.shape[0] * 2))) return d def Z_y_correspond(Z, Y): Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 19:36:47 UTC (rev 4396) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 20:30:15 UTC (rev 4397) @@ -37,7 +37,7 @@ import sys import os.path from scipy.testing import * -from scipy.cluster.hierarchy import pdist, squareform, linkage, from_mlab_linkage +from scipy.cluster.hierarchy import pdist, squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage import numpy #import math @@ -572,6 +572,8 @@ #print "test-chebychev-iris", numpy.abs(Y_test2 - Y_right).max() self.failUnless(within_tol(Y_test2, Y_right, eps)) + ################### squareform + def test_squareform_empty_matrix(self): "Tests squareform on an empty matrix." A = numpy.zeros((0,0)) @@ -611,10 +613,14 @@ for n in xrange(2, 5): X = numpy.random.rand(n, 4) Y = pdist(X) + self.failUnless(len(Y.shape) == 1) A = squareform(Y) Yr = squareform(A) s = A.shape k = 0 + self.failUnless(len(s) == 2) + self.failUnless(len(Yr.shape) == 1) + self.failUnless(s[0] == s[1]) #print A.shape, Y.shape, Yr.shape for i in xrange(0, s[0]): for j in xrange(i+1, s[1]): @@ -626,6 +632,37 @@ else: self.failUnless(A[i, j] == 0) + ############## numobs_dm + + def test_numobs_dm_multi_matrix(self): + "Tests numobs_dm with observation matrices of multiple sizes." + for n in xrange(2, 10): + X = numpy.random.rand(n, 4) + Y = pdist(X) + A = squareform(Y) + #print A.shape, Y.shape, Yr.shape + self.failUnless(numobs_dm(A) == n) + + def test_numobs_y_multi_matrix(self): + "Tests numobs_y with observation matrices of multiple sizes." + for n in xrange(2, 10): + X = numpy.random.rand(n, 4) + Y = pdist(X) + #print A.shape, Y.shape, Yr.shape + self.failUnless(numobs_y(Y) == n) + + def test_numobs_linkage_multi_matrix(self): + "Tests numobs_linkage with observation matrices of multiple sizes." + for n in xrange(2, 10): + X = numpy.random.rand(n, 4) + Y = pdist(X) + Z = linkage(Y) + #print Z + #print A.shape, Y.shape, Yr.shape + self.failUnless(numobs_linkage(Z) == n) + + ################### linkage + def test_linkage_single_tdist(self): "Tests linkage(Y, 'single') on the tdist data set." Z = linkage(_ytdist, 'single') @@ -659,6 +696,7 @@ expectedZ = from_mlab_linkage(Zmlab) #print Z, expectedZ, numpy.abs(Z - expectedZ).max() self.failUnless(within_tol(Z, expectedZ, eps)) + def within_tol(a, b, tol): return numpy.abs(a - b).max() < tol From scipy-svn at scipy.org Fri May 30 16:57:30 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 15:57:30 -0500 (CDT) Subject: [Scipy-svn] r4398 - in trunk/scipy/cluster: . tests Message-ID: <20080530205730.7D30539C92A@scipy.org> Author: damian.eads Date: 2008-05-30 15:57:27 -0500 (Fri, 30 May 2008) New Revision: 4398 Modified: trunk/scipy/cluster/hierarchy.py trunk/scipy/cluster/tests/test_hierarchy.py Log: Fixed a boundary condition bug in hierarchy.squareform with 0-length pdist arrays. Modified: trunk/scipy/cluster/hierarchy.py =================================================================== --- trunk/scipy/cluster/hierarchy.py 2008-05-30 20:30:15 UTC (rev 4397) +++ trunk/scipy/cluster/hierarchy.py 2008-05-30 20:57:27 UTC (rev 4398) @@ -730,6 +730,9 @@ # X = squareform(v) if len(s) == 1 and force != 'tomatrix': + if X.shape[0] == 0: + return np.zeros((1,1), dtype=np.double) + # Grab the closest value to the square root of the number # of elements times 2 to see if the number of elements # is indeed a binomial coefficient. @@ -766,6 +769,9 @@ # One-side of the dimensions is set here. d = s[0] + if d <= 1: + return np.array([], dtype=np.double) + # Create a vector. v = np.zeros(((d * (d - 1) / 2),), dtype=np.double) @@ -1662,9 +1668,9 @@ raise TypeError('Variable passed as inconsistency matrix is not a numpy array.') if R.dtype != np.double: if name: - raise TypeError('Inconsistency matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Inconsistency matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Inconsistency matrix must contain doubles (float64).') + raise TypeError('Inconsistency matrix must contain doubles (double).') if len(R.shape) != 2: if name: raise ValueError('Inconsistency matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) @@ -1721,9 +1727,9 @@ raise TypeError('Variable is not a valid array.') if Z.dtype != np.double: if name: - raise TypeError('Linkage matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Linkage matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Linkage matrix must contain doubles (float64).') + raise TypeError('Linkage matrix must contain doubles (double).') if len(Z.shape) != 2: if name: raise ValueError('Linkage matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) @@ -1782,9 +1788,9 @@ raise TypeError('Variable is not a numpy array.') if y.dtype != np.double: if name: - raise TypeError('Condensed distance matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Condensed distance matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Condensed distance matrix must contain doubles (float64).') + raise TypeError('Condensed distance matrix must contain doubles (double).') if len(y.shape) != 1: if name: raise ValueError('Condensed distance matrix \'%s\' must have shape=1 (i.e. be one-dimensional).' % name) @@ -1845,9 +1851,9 @@ s = D.shape if D.dtype != np.double: if name: - raise TypeError('Distance matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Distance matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Distance matrix must contain doubles (float64).') + raise TypeError('Distance matrix must contain doubles (double).') if len(D.shape) != 2: if name: raise ValueError('Distance matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 20:30:15 UTC (rev 4397) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 20:57:27 UTC (rev 4398) @@ -574,6 +574,8 @@ ################### squareform +class TestSquareForm(TestCase): + def test_squareform_empty_matrix(self): "Tests squareform on an empty matrix." A = numpy.zeros((0,0)) @@ -583,7 +585,8 @@ def test_squareform_empty_vector(self): v = numpy.zeros((0,)) rv = squareform(numpy.array(v, dtype='double')) - self.failUnless(rv.shape == (0,0)) + self.failUnless(rv.shape == (1,1)) + self.failUnless(rv[0, 0] == 0) def test_squareform_1by1_matrix(self): "Tests squareform on a 1x1 matrix." @@ -618,29 +621,29 @@ Yr = squareform(A) s = A.shape k = 0 + print A.shape, Y.shape, Yr.shape self.failUnless(len(s) == 2) self.failUnless(len(Yr.shape) == 1) self.failUnless(s[0] == s[1]) - #print A.shape, Y.shape, Yr.shape for i in xrange(0, s[0]): for j in xrange(i+1, s[1]): if i != j: #print i, j, k, A[i, j], Y[k] self.failUnless(A[i, j] == Y[k]) - self.failUnless(Yr[k] == Y[k]) k += 1 else: self.failUnless(A[i, j] == 0) +class TestNumObs(TestCase): + ############## numobs_dm - def test_numobs_dm_multi_matrix(self): "Tests numobs_dm with observation matrices of multiple sizes." - for n in xrange(2, 10): + for n in xrange(1, 10): X = numpy.random.rand(n, 4) Y = pdist(X) A = squareform(Y) - #print A.shape, Y.shape, Yr.shape + print A.shape, Y.shape self.failUnless(numobs_dm(A) == n) def test_numobs_y_multi_matrix(self): @@ -661,8 +664,9 @@ #print A.shape, Y.shape, Yr.shape self.failUnless(numobs_linkage(Z) == n) +class TestLinkage(TestCase): + ################### linkage - def test_linkage_single_tdist(self): "Tests linkage(Y, 'single') on the tdist data set." Z = linkage(_ytdist, 'single') From scipy-svn at scipy.org Fri May 30 17:38:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 16:38:33 -0500 (CDT) Subject: [Scipy-svn] r4399 - in trunk/scipy/cluster: . tests Message-ID: <20080530213833.1AD1639C624@scipy.org> Author: damian.eads Date: 2008-05-30 16:38:29 -0500 (Fri, 30 May 2008) New Revision: 4399 Modified: trunk/scipy/cluster/hierarchy.py trunk/scipy/cluster/tests/test_hierarchy.py Log: Added tests for hierarchy.{yule,sokalsneath,matching,jaccard} Modified: trunk/scipy/cluster/hierarchy.py =================================================================== --- trunk/scipy/cluster/hierarchy.py 2008-05-30 20:57:27 UTC (rev 4398) +++ trunk/scipy/cluster/hierarchy.py 2008-05-30 21:38:29 UTC (rev 4399) @@ -969,12 +969,26 @@ return abs(u-v).sum() / (abs(u).sum() + abs(v).sum()) def _nbool_correspond_all(u, v): - not_u = scipy.bitwise_not(u) - not_v = scipy.bitwise_not(v) - nff = scipy.bitwise_and(not_u, not_v).sum() - nft = scipy.bitwise_and(not_u, v).sum() - ntf = scipy.bitwise_and(u, not_v).sum() - ntt = scipy.bitwise_and(u, v).sum() + if u.dtype != v.dtype: + raise TypeError("Arrays being compared must be of the same data type.") + + if u.dtype == np.int or u.dtype == np.float_ or u.dtype == np.double: + not_u = 1.0 - u + not_v = 1.0 - v + nff = (not_u * not_v).sum() + nft = (not_u * v).sum() + ntf = (u * not_v).sum() + ntt = (u * v).sum() + elif u.dtype == np.bool: + not_u = scipy.bitwise_not(u) + not_v = scipy.bitwise_not(v) + nff = scipy.bitwise_and(not_u, not_v).sum() + nft = scipy.bitwise_and(not_u, v).sum() + ntf = scipy.bitwise_and(u, not_v).sum() + ntt = scipy.bitwise_and(u, v).sum() + else: + raise TypeError("Arrays being compared have unknown type.") + return (nff, nft, ntf, ntt) def _nbool_correspond_ft_tf(u, v): @@ -1002,6 +1016,7 @@ R = 2.0 * (c_{TF} + c_{FT}). """ (nff, nft, ntf, ntt) = _nbool_correspond_all(u, v) + print nff, nft, ntf, ntt return float(2.0 * ntf * nft) / float(ntt * nff + ntf * nft) def matching(u, v): Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 20:57:27 UTC (rev 4398) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 21:38:29 UTC (rev 4399) @@ -37,7 +37,7 @@ import sys import os.path from scipy.testing import * -from scipy.cluster.hierarchy import pdist, squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage +from scipy.cluster.hierarchy import pdist, squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage, matching, jaccard, dice, sokalsneath, rogerstanimoto, russellrao, yule import numpy #import math @@ -572,10 +572,105 @@ #print "test-chebychev-iris", numpy.abs(Y_test2 - Y_right).max() self.failUnless(within_tol(Y_test2, Y_right, eps)) - ################### squareform + def test_pdist_matching_mtica1(self): + "Tests matching(*,*) with mtica example #1." + m = matching(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = matching(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + self.failUnless(numpy.abs(m - 0.6) <= 1e-10) + self.failUnless(numpy.abs(m2 - 0.6) <= 1e-10) + def test_pdist_matching_mtica2(self): + "Tests matching(*,*) with mtica example #2." + m = matching(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = matching(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + self.failUnless(numpy.abs(m - (2.0/3.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (2.0/3.0)) <= 1e-10) + + def test_pdist_jaccard_mtica1(self): + "Tests jaccard(*,*) with mtica example #1." + m = jaccard(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = jaccard(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + self.failUnless(numpy.abs(m - 0.6) <= 1e-10) + self.failUnless(numpy.abs(m2 - 0.6) <= 1e-10) + + def test_pdist_jaccard_mtica2(self): + "Tests jaccard(*,*) with mtica example #2." + m = jaccard(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = jaccard(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + self.failUnless(numpy.abs(m - (2.0/3.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (2.0/3.0)) <= 1e-10) + + def test_pdist_yule_mtica1(self): + "Tests yule(*,*) with mtica example #1." + m = yule(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = yule(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - 2.0) <= 1e-10) + self.failUnless(numpy.abs(m2 - 2.0) <= 1e-10) + + def test_pdist_yule_mtica2(self): + "Tests yule(*,*) with mtica example #2." + m = yule(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = yule(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - 2.0) <= 1e-10) + self.failUnless(numpy.abs(m2 - 2.0) <= 1e-10) + + def test_pdist_dice_mtica1(self): + "Tests dice(*,*) with mtica example #1." + m = dice(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = dice(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (3.0/7.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (3.0/7.0)) <= 1e-10) + + def test_pdist_dice_mtica2(self): + "Tests dice(*,*) with mtica example #2." + m = dice(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = dice(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - 0.5) <= 1e-10) + self.failUnless(numpy.abs(m2 - 0.5) <= 1e-10) + + def test_pdist_sokalsneath_mtica1(self): + "Tests sokalsneath(*,*) with mtica example #1." + m = sokalsneath(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = sokalsneath(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (3.0/4.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (3.0/4.0)) <= 1e-10) + + def test_pdist_sokalsneath_mtica2(self): + "Tests sokalsneath(*,*) with mtica example #2." + m = sokalsneath(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = sokalsneath(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (4.0/5.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (4.0/5.0)) <= 1e-10) + class TestSquareForm(TestCase): + ################### squareform def test_squareform_empty_matrix(self): "Tests squareform on an empty matrix." A = numpy.zeros((0,0)) @@ -700,7 +795,6 @@ expectedZ = from_mlab_linkage(Zmlab) #print Z, expectedZ, numpy.abs(Z - expectedZ).max() self.failUnless(within_tol(Z, expectedZ, eps)) - def within_tol(a, b, tol): return numpy.abs(a - b).max() < tol From scipy-svn at scipy.org Fri May 30 17:57:13 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 16:57:13 -0500 (CDT) Subject: [Scipy-svn] r4400 - trunk/scipy/cluster/tests Message-ID: <20080530215713.8E30E39C8E7@scipy.org> Author: damian.eads Date: 2008-05-30 16:57:10 -0500 (Fri, 30 May 2008) New Revision: 4400 Modified: trunk/scipy/cluster/tests/test_hierarchy.py Log: Polishing some tests. Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 21:38:29 UTC (rev 4399) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-05-30 21:57:10 UTC (rev 4400) @@ -573,7 +573,7 @@ self.failUnless(within_tol(Y_test2, Y_right, eps)) def test_pdist_matching_mtica1(self): - "Tests matching(*,*) with mtica example #1." + "Tests matching(*,*) with mtica example #1 (nums)." m = matching(numpy.array([1, 0, 1, 1, 0]), numpy.array([1, 1, 0, 1, 1])) m2 = matching(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), @@ -668,6 +668,47 @@ self.failUnless(numpy.abs(m - (4.0/5.0)) <= 1e-10) self.failUnless(numpy.abs(m2 - (4.0/5.0)) <= 1e-10) + def test_pdist_rogerstanimoto_mtica1(self): + "Tests rogerstanimoto(*,*) with mtica example #1." + m = rogerstanimoto(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = rogerstanimoto(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (3.0/4.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (3.0/4.0)) <= 1e-10) + + def test_pdist_rogerstanimoto_mtica2(self): + "Tests rogerstanimoto(*,*) with mtica example #2." + m = rogerstanimoto(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = rogerstanimoto(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (4.0/5.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (4.0/5.0)) <= 1e-10) + + + def test_pdist_russellrao_mtica1(self): + "Tests russellrao(*,*) with mtica example #1." + m = russellrao(numpy.array([1, 0, 1, 1, 0]), + numpy.array([1, 1, 0, 1, 1])) + m2 = russellrao(numpy.array([1, 0, 1, 1, 0], dtype=numpy.bool), + numpy.array([1, 1, 0, 1, 1], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (3.0/5.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (3.0/5.0)) <= 1e-10) + + def test_pdist_russellrao_mtica2(self): + "Tests russellrao(*,*) with mtica example #2." + m = russellrao(numpy.array([1, 0, 1]), + numpy.array([1, 1, 0])) + m2 = russellrao(numpy.array([1, 0, 1], dtype=numpy.bool), + numpy.array([1, 1, 0], dtype=numpy.bool)) + print m + self.failUnless(numpy.abs(m - (2.0/3.0)) <= 1e-10) + self.failUnless(numpy.abs(m2 - (2.0/3.0)) <= 1e-10) + class TestSquareForm(TestCase): ################### squareform @@ -709,26 +750,29 @@ def test_squareform_multi_matrix(self): "Tests squareform on a square matrices of multiple sizes." for n in xrange(2, 5): - X = numpy.random.rand(n, 4) - Y = pdist(X) - self.failUnless(len(Y.shape) == 1) - A = squareform(Y) - Yr = squareform(A) - s = A.shape - k = 0 - print A.shape, Y.shape, Yr.shape - self.failUnless(len(s) == 2) - self.failUnless(len(Yr.shape) == 1) - self.failUnless(s[0] == s[1]) - for i in xrange(0, s[0]): - for j in xrange(i+1, s[1]): - if i != j: - #print i, j, k, A[i, j], Y[k] - self.failUnless(A[i, j] == Y[k]) - k += 1 - else: - self.failUnless(A[i, j] == 0) + yield self.check_squareform_multi_matrix(n) + def check_squareform_multi_matrix(self, n): + X = numpy.random.rand(n, 4) + Y = pdist(X) + self.failUnless(len(Y.shape) == 1) + A = squareform(Y) + Yr = squareform(A) + s = A.shape + k = 0 + print A.shape, Y.shape, Yr.shape + self.failUnless(len(s) == 2) + self.failUnless(len(Yr.shape) == 1) + self.failUnless(s[0] == s[1]) + for i in xrange(0, s[0]): + for j in xrange(i+1, s[1]): + if i != j: + #print i, j, k, A[i, j], Y[k] + self.failUnless(A[i, j] == Y[k]) + k += 1 + else: + self.failUnless(A[i, j] == 0) + class TestNumObs(TestCase): ############## numobs_dm From scipy-svn at scipy.org Fri May 30 19:51:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 18:51:36 -0500 (CDT) Subject: [Scipy-svn] r4401 - trunk/scipy/optimize Message-ID: <20080530235136.C655639C018@scipy.org> Author: oliphant Date: 2008-05-30 18:51:35 -0500 (Fri, 30 May 2008) New Revision: 4401 Modified: trunk/scipy/optimize/minpack.py Log: Re-factor scipy.optimize.fixed_point to handle vector and scalar portions separately. Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2008-05-30 21:57:10 UTC (rev 4400) +++ trunk/scipy/optimize/minpack.py 2008-05-30 23:51:35 UTC (rev 4401) @@ -412,7 +412,7 @@ # Steffensen's Method using Aitken's Del^2 convergence acceleration. -def fixed_point(func, x0, args=(), xtol=1e-10, maxiter=500): +def fixed_point(func, x0, args=(), xtol=1e-8, maxiter=500): """Find the point where func(x) == x Given a function of one or more variables and a starting point, find a @@ -421,6 +421,17 @@ Uses Steffensen's Method using Aitken's Del^2 convergence acceleration. See Burden, Faires, "Numerical Analysis", 5th edition, pg. 80 + Example + ------- + >>> from numpy import sqrt, array + >>> from scipy.optimize import fixed_point + >>> def func(x, c1, c2): + return sqrt(c1/(x+c2)) + >>> c1 = array([10,12.]) + >>> c2 = array([3, 5.]) + >>> fixed_point(func, [1.2, 1.3], args=(c1,c2)) + array([ 1.4920333 , 1.37228132]) + See also: fmin, fmin_powell, fmin_cg, @@ -441,24 +452,34 @@ """ if not isscalar(x0): x0 = asarray(x0) - p0 = x0 - for iter in range(maxiter): - p1 = func(p0, *args) - p2 = func(p1, *args) - d = p2 - 2.0 * p1 + p0 - if isinstance(x0, ndarray): + p0 = x0 + for iter in range(maxiter): + p1 = func(p0, *args) + p2 = func(p1, *args) + d = p2 - 2.0 * p1 + p0 p = where(d == 0, p2, p0 - (p1 - p0)*(p1-p0) / d) - if all(abs(p-p0) < xtol): + relerr = where(p0 == 0, p, (p-p0)/p0) + if all(relerr < xtol): return p - else: + p0 = p + else: + p0 = x0 + for iter in range(maxiter): + p1 = func(p0, *args) + p2 = func(p1, *args) + d = p2 - 2.0 * p1 + p0 if d == 0.0: return p2 else: p = p0 - (p1 - p0)*(p1-p0) / d - if abs(p-p0) < xtol: + if p0 == 0: + relerr = p + else: + relerr = (p-p0)/p0 + if relerr < xtol: return p - p0 = p - raise RuntimeError, "Failed to converge after %d iterations, value is %f" % (maxiter,p) + p0 = p + raise RuntimeError, "Failed to converge after %d iterations, value is %s" % (maxiter,p) def bisection(func, a, b, args=(), xtol=1e-10, maxiter=400): From scipy-svn at scipy.org Fri May 30 20:15:47 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 30 May 2008 19:15:47 -0500 (CDT) Subject: [Scipy-svn] r4402 - trunk/scipy/io Message-ID: <20080531001547.2B9A239C04C@scipy.org> Author: oliphant Date: 2008-05-30 19:15:46 -0500 (Fri, 30 May 2008) New Revision: 4402 Modified: trunk/scipy/io/wavfile.py Log: Fix wavfile reading for 64-bit platforms. Modified: trunk/scipy/io/wavfile.py =================================================================== --- trunk/scipy/io/wavfile.py 2008-05-30 23:51:35 UTC (rev 4401) +++ trunk/scipy/io/wavfile.py 2008-05-31 00:15:46 UTC (rev 4402) @@ -15,7 +15,7 @@ # assumes file pointer is immediately # after the 'data' id def _read_data_chunk(fid, noc, bits): - size = struct.unpack('l',fid.read(4))[0] + size = struct.unpack('i',fid.read(4))[0] if bits == 8: data = numpy.fromfile(fid, dtype=numpy.ubyte, count=size) if noc > 1: @@ -30,7 +30,7 @@ def _read_riff_chunk(fid): str1 = fid.read(4) - fsize = struct.unpack('L', fid.read(4))[0] + 8 + fsize = struct.unpack('I', fid.read(4))[0] + 8 str2 = fid.read(4) if (str1 != 'RIFF' or str2 != 'WAVE'): raise ValueError, "Not a WAV file." @@ -64,7 +64,7 @@ data = _read_data_chunk(fid, noc, bits) else: print "Warning: %s chunk not understood" - size = struct.unpack('L',fid.read(4))[0] + size = struct.unpack('I',fid.read(4))[0] bytes = fid.read(size) fid.close() return rate, data @@ -99,11 +99,11 @@ fid.write(struct.pack('lhHLLHH', 16, 1, noc, rate, sbytes, ba, bits)) # data chunk fid.write('data') - fid.write(struct.pack('l', data.nbytes)) + fid.write(struct.pack('i', data.nbytes)) data.tofile(fid) # Determine file size and place it in correct # position at start of the file. size = fid.tell() fid.seek(4) - fid.write(struct.pack('l', size-8)) + fid.write(struct.pack('i', size-8)) fid.close()