From scipy-svn at scipy.org Thu Nov 1 07:36:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 06:36:04 -0500 (CDT) Subject: [Scipy-svn] r3479 - in trunk/scipy/sandbox/montecarlo: . src tests Message-ID: <20071101113604.9289939C37D@new.scipy.org> Author: edschofield Date: 2007-11-01 06:35:51 -0500 (Thu, 01 Nov 2007) New Revision: 3479 Modified: trunk/scipy/sandbox/montecarlo/montecarlo.py trunk/scipy/sandbox/montecarlo/src/compact5table.c trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py Log: Clean up Monte Carlo code; make unit-test class names lowercase so they run Modified: trunk/scipy/sandbox/montecarlo/montecarlo.py =================================================================== --- trunk/scipy/sandbox/montecarlo/montecarlo.py 2007-11-01 01:31:37 UTC (rev 3478) +++ trunk/scipy/sandbox/montecarlo/montecarlo.py 2007-11-01 11:35:51 UTC (rev 3479) @@ -3,13 +3,12 @@ # Copyright: Ed Schofield, 2005-2006 # License: BSD-style (see LICENSE.txt at root of scipy tree) -__author__ = "Ed Schofield" - from __future__ import division import numpy import scipy from scipy.sandbox.montecarlo._intsampler import _intsampler +__author__ = "Ed Schofield" class genericsampler(object): """A base class for other samplers. Modified: trunk/scipy/sandbox/montecarlo/src/compact5table.c =================================================================== --- trunk/scipy/sandbox/montecarlo/src/compact5table.c 2007-11-01 01:31:37 UTC (rev 3478) +++ trunk/scipy/sandbox/montecarlo/src/compact5table.c 2007-11-01 11:35:51 UTC (rev 3479) @@ -97,16 +97,6 @@ break; } } - // if (sampler->prob1event == -1) - // { - // /* This has been tested above, so I think this should never - // occur... */ - // fprintf(stderr, "Error: invalid arguments to init_sampler5tbl()." \ - // "The sum of the probabilities is zero. Aborting!\n"); - // free(P); - // free(sampler); - // return NULL; - // } } else { @@ -207,11 +197,12 @@ */ if (j - sampler->t4 >= sampler->sizeEE) { - /* The random number generated is larger than the sizes of all tables. - * This should happen only very rarely. For now, just generate another - * random number. */ - fprintf(stderr, - "Debug: random number is larger than the sizes of all tables!"); + /* The random number generated is larger than the sizes of all + * tables. Why does this happen? Debug this! For now, just generate + * another random number. + */ + /* fprintf(stderr, + "Debug: random number (%d) is larger than the sizes of all tables!\n", j); */ return Dran(sampler); } else @@ -256,11 +247,11 @@ else if (j - sampler->t4 >= sampler->sizeEE) { /* The random number generated is larger than the sizes of all - * tables. This should happen only very rarely. For now, just - * generate another random number. + * tables. Why does this happen? Debug this! For now, just generate + * another random number. */ - fprintf(stderr, - "Debug: random number is larger than the sizes of all tables!"); + /* fprintf(stderr, + "Debug: random number (%d) is larger than the sizes of all tables\n!", j); */ i--; } else Modified: trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py =================================================================== --- trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py 2007-11-01 01:31:37 UTC (rev 3478) +++ trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py 2007-11-01 11:35:51 UTC (rev 3479) @@ -21,7 +21,7 @@ import unittest -class TestDictSampler(NumpyTestCase): +class test_dict_sampler(NumpyTestCase): def check_simple(self): """ # Sample from this discrete distribution: Modified: trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py =================================================================== --- trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py 2007-11-01 01:31:37 UTC (rev 3478) +++ trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py 2007-11-01 11:35:51 UTC (rev 3479) @@ -2,8 +2,7 @@ """ Test functions for generic discrete sampler 'intsampler' -Author: Ed Schofield, 2003-2006 -Copyright: Ed Schofield, 2003-2006 +Author: Ed Schofield """ @@ -22,15 +21,12 @@ from numpy.testing import * set_package_path() from numpy import * -#from scipy.montecarlo import * from scipy.sandbox.montecarlo import * from scipy import stats restore_path() -import unittest - -class TestIntSampler(NumpyTestCase): +class test_int_sampler(NumpyTestCase): def check_simple(self): # Sample from a Poisson distribution, P(lambda = 10.0) lam = 10.0 From scipy-svn at scipy.org Thu Nov 1 07:57:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 06:57:04 -0500 (CDT) Subject: [Scipy-svn] r3480 - in trunk/scipy/sandbox/montecarlo: . examples Message-ID: <20071101115704.DCF0739C38A@new.scipy.org> Author: edschofield Date: 2007-11-01 06:56:59 -0500 (Thu, 01 Nov 2007) New Revision: 3480 Added: trunk/scipy/sandbox/montecarlo/examples/ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py Log: Add examples (simple benchmarks) of using the montecarlo module Added: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-01 11:35:51 UTC (rev 3479) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-01 11:56:59 UTC (rev 3480) @@ -0,0 +1,20 @@ +"""Generates 10**8 random variates (strings) drawn from a discrete distribution +on the sample space {'a', 'b', 'c'}. + +Run this script with timeit to get an idea of how the speed compares with +sampling strings and/or integers over a much larger sample space. + +The point of the montecarlo module's compact 5-table sampler is for the time +for simulating variates to be independent (or nearly so) of the size of the +sample space. +""" + +from scipy import * +from scipy.sandbox import montecarlo + +d = {'a':0.2,'b':0.3,'c':0.5} + +s = montecarlo.dictsampler(d) +for i in range(10): + temp = s.sample(10**7) + Added: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-01 11:35:51 UTC (rev 3479) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-01 11:56:59 UTC (rev 3480) @@ -0,0 +1,11 @@ +from scipy import * +from scipy.sandbox import montecarlo + +k = [str(x) for x in range(10**6)] +v = rand(10**6) +d = dict(zip(k, v)) + +s = montecarlo.dictsampler(d) +for i in range(10): + temp = s.sample(10**7) + Added: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-01 11:35:51 UTC (rev 3479) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-01 11:56:59 UTC (rev 3480) @@ -0,0 +1,9 @@ +from scipy import * +from scipy.sandbox import montecarlo + +v = rand(10**6) + +s = montecarlo.intsampler(v) +for i in range(10): + temp = s.sample(10**7) + Added: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-01 11:35:51 UTC (rev 3479) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-01 11:56:59 UTC (rev 3480) @@ -0,0 +1,9 @@ +from scipy import * +from scipy.sandbox import montecarlo + +v = rand(10) + +s = montecarlo.intsampler(v) +for i in range(10): + temp = s.sample(10**7) + From scipy-svn at scipy.org Thu Nov 1 10:25:18 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 09:25:18 -0500 (CDT) Subject: [Scipy-svn] r3481 - in trunk/scipy/stats: . tests Message-ID: <20071101142518.568FE39C434@new.scipy.org> Author: cookedm Date: 2007-11-01 09:25:15 -0500 (Thu, 01 Nov 2007) New Revision: 3481 Modified: trunk/scipy/stats/stats.py trunk/scipy/stats/tests/test_stats.py Log: Fix #526 -- scipy.stats.gmean cannot handle large numbers - also minor fixes in stats/tests/test_stats.py Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2007-11-01 11:56:59 UTC (rev 3480) +++ trunk/scipy/stats/stats.py 2007-11-01 14:25:15 UTC (rev 3481) @@ -348,8 +348,9 @@ Parameters ---------- - a : array + a : array of positive values axis : int or None + zero_sub : value to substitute for zero values. Default is 0. Returns ------- @@ -357,12 +358,11 @@ all values in the array if axis==None. """ a, axis = _chk_asarray(a, axis) - size = a.shape[axis] - prod = np.product(a, axis) - return np.power(prod, 1./size) + log_a = np.log(a) + return np.exp(log_a.mean(axis=axis)) -def hmean(a, axis=0): +def hmean(a, axis=0, zero_sub=0): """Calculates the harmonic mean of the values in the passed array. That is: n / (1/x1 + 1/x2 + ... + 1/xn) Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2007-11-01 11:56:59 UTC (rev 3480) +++ trunk/scipy/stats/tests/test_stats.py 2007-11-01 14:25:15 UTC (rev 3481) @@ -500,18 +500,19 @@ a = (1,2,3,4) actual= stats.gmean(a) desired = power(1*2*3*4,1./4.) - assert_almost_equal(desired,actual,decimal=14) + assert_almost_equal(actual, desired,decimal=14) desired1 = stats.gmean(a,axis=-1) - assert_almost_equal(desired1,actual,decimal=14) + assert_almost_equal(actual, desired1, decimal=14) + def check_1D_array(self): a = array((1,2,3,4), float32) actual= stats.gmean(a) desired = power(1*2*3*4,1./4.) - assert_almost_equal(desired,actual,decimal=7) + assert_almost_equal(actual, desired, decimal=7) desired1 = stats.gmean(a,axis=-1) - assert_almost_equal(desired1,actual,decimal=7) + assert_almost_equal(actual, desired1, decimal=7) def check_2D_array_default(self): a = array(((1,2,3,4), @@ -519,10 +520,10 @@ (1,2,3,4))) actual= stats.gmean(a) desired = array((1,2,3,4)) - assert_array_almost_equal(desired,actual,decimal=14) + assert_array_almost_equal(actual, desired, decimal=14) desired1 = stats.gmean(a,axis=0) - assert_array_almost_equal(desired1,actual,decimal=14) + assert_array_almost_equal(actual, desired1, decimal=14) def check_2D_array_dim1(self): a = array(((1,2,3,4), @@ -531,25 +532,30 @@ actual= stats.gmean(a, axis=1) v = power(1*2*3*4,1./4.) desired = array((v,v,v)) - assert_array_almost_equal(desired,actual,decimal=14) + assert_array_almost_equal(actual, desired, decimal=14) + def check_large_values(self): + a = array([1e100, 1e200, 1e300]) + actual = stats.gmean(a) + assert_approx_equal(actual, 1e200, significant=14) + class TestHMean(NumpyTestCase): def check_1D_list(self): a = (1,2,3,4) actual= stats.hmean(a) desired = 4. / (1./1 + 1./2 + 1./3 + 1./4) - assert_almost_equal(desired,actual,decimal=14) + assert_almost_equal(actual, desired, decimal=14) desired1 = stats.hmean(array(a),axis=-1) - assert_almost_equal(desired1,actual,decimal=14) + assert_almost_equal(actual, desired1, decimal=14) def check_1D_array(self): a = array((1,2,3,4), float64) actual= stats.hmean(a) desired = 4. / (1./1 + 1./2 + 1./3 + 1./4) - assert_almost_equal(desired,actual,decimal=14) + assert_almost_equal(actual, desired, decimal=14) desired1 = stats.hmean(a,axis=-1) - assert_almost_equal(desired1,actual,decimal=14) + assert_almost_equal(actual, desired1, decimal=14) def check_2D_array_default(self): a = array(((1,2,3,4), @@ -557,10 +563,10 @@ (1,2,3,4))) actual = stats.hmean(a) desired = array((1.,2.,3.,4.)) - assert_array_almost_equal(desired,actual,decimal=14) + assert_array_almost_equal(actual, desired, decimal=14) actual1 = stats.hmean(a,axis=0) - assert_array_almost_equal(desired,actual1,decimal=14) + assert_array_almost_equal(actual1, desired, decimal=14) def check_2D_array_dim1(self): a = array(((1,2,3,4), @@ -570,7 +576,7 @@ v = 4. / (1./1 + 1./2 + 1./3 + 1./4) desired1 = array((v,v,v)) actual1 = stats.hmean(a, axis=1) - assert_array_almost_equal(desired1,actual1,decimal=14) + assert_array_almost_equal(actual1, desired1, decimal=14) class TestMean(NumpyTestCase): @@ -592,16 +598,18 @@ a = [[1.0, 2.0, 3.0], [2.0, 4.0, 6.0], [8.0, 12.0, 7.0]] - A = array(a,'d') - N1,N2 = (3,3) - mn1 = zeros(N2,'d') + A = array(a) + N1, N2 = (3, 3) + mn1 = zeros(N2, dtype=float) for k in range(N1): mn1 += A[k,:] / N1 - allclose(stats.mean(a),mn1,rtol=1e-13,atol=1e-13) - mn2 = zeros(N1,'d') + assert_almost_equal(stats.mean(a, axis=0), mn1, decimal=13) + assert_almost_equal(stats.mean(a), mn1, decimal=13) + mn2 = zeros(N1, dtype=float) for k in range(N2): - mn2 += A[:,k] / N2 - allclose(stats.mean(a,axis=0),mn2,rtol=1e-13,atol=1e-13) + mn2 += A[:,k] + mn2 /= N2 + assert_almost_equal(stats.mean(a, axis=1), mn2, decimal=13) def check_ravel(self): a = rand(5,3,5) From scipy-svn at scipy.org Thu Nov 1 10:41:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 09:41:22 -0500 (CDT) Subject: [Scipy-svn] r3482 - trunk/scipy/stats/models/robust Message-ID: <20071101144122.2BF3739C444@new.scipy.org> Author: cookedm Date: 2007-11-01 09:41:20 -0500 (Thu, 01 Nov 2007) New Revision: 3482 Modified: trunk/scipy/stats/models/robust/scale.py Log: Fix error in scipy/stats/models/robust/scale.py by making unsqueeze return a view of the correct shape. Modified: trunk/scipy/stats/models/robust/scale.py =================================================================== --- trunk/scipy/stats/models/robust/scale.py 2007-11-01 14:25:15 UTC (rev 3481) +++ trunk/scipy/stats/models/robust/scale.py 2007-11-01 14:41:20 UTC (rev 3482) @@ -11,7 +11,7 @@ >>> m = mean(x, axis=1) >>> m.shape (3, 5) - >>> unsqueeze(m, 1, x.shape) + >>> m = unsqueeze(m, 1, x.shape) >>> m.shape (3, 1, 5) >>> @@ -19,7 +19,7 @@ newshape = list(oldshape) newshape[axis] = 1 - data.shape = newshape + return data.reshape(newshape) def MAD(a, c=0.6745, axis=0): @@ -32,7 +32,7 @@ a = N.asarray(a, N.float64) d = median(a, axis=axis) - unsqueeze(d, axis, a.shape) + d = unsqueeze(d, axis, a.shape) return median(N.fabs(a - d) / c, axis=axis) @@ -49,7 +49,7 @@ tmp = 2 * norm.cdf(c) - 1 gamma = tmp + c**2 * (1 - tmp) - 2 * c * norm.pdf(c) - del(tmp) + del tmp niter = 30 @@ -76,8 +76,8 @@ else: self.scale = scale - unsqueeze(self.scale, self.axis, self.a.shape) - unsqueeze(self.mu, self.axis, self.a.shape) + self.scale = unsqueeze(self.scale, self.axis, self.a.shape) + self.mu = unsqueeze(self.mu, self.axis, self.a.shape) for donothing in self: pass @@ -97,7 +97,7 @@ mu = N.sum(subset * a + (1 - Huber.c) * subset, axis=self.axis) / a.shape[self.axis] else: mu = self.mu - unsqueeze(mu, self.axis, self.a.shape) + self.axis = unsqueeze(mu, self.axis, self.a.shape) scale = N.sum(subset * (a - mu)**2, axis=self.axis) / (self.n * Huber.gamma - N.sum(1. - subset, axis=self.axis) * Huber.c**2) @@ -111,7 +111,7 @@ self.scale = scale self.mu = mu - unsqueeze(self.scale, self.axis, self.a.shape) + self.scale = unsqueeze(self.scale, self.axis, self.a.shape) if self.iter >= self.niter: raise StopIteration From scipy-svn at scipy.org Thu Nov 1 17:37:39 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 16:37:39 -0500 (CDT) Subject: [Scipy-svn] r3483 - trunk/scipy/io Message-ID: <20071101213739.E335839C11C@new.scipy.org> Author: chris.burns Date: 2007-11-01 16:37:37 -0500 (Thu, 01 Nov 2007) New Revision: 3483 Modified: trunk/scipy/io/datasource.py Log: Fix bug in DataSource.abspath. Update documentation. Modified: trunk/scipy/io/datasource.py =================================================================== --- trunk/scipy/io/datasource.py 2007-11-01 14:41:20 UTC (rev 3482) +++ trunk/scipy/io/datasource.py 2007-11-01 21:37:37 UTC (rev 3483) @@ -4,6 +4,9 @@ low-level details. Through datasource, a researcher can obtain and use a file with one function call, regardless of location of the file. +DataSource is meant to augment standard python libraries, not replace them. +It should work seemlessly with standard file IO operations and the os module. + DataSource files can originate locally or remotely: - local files : '/home/guido/src/local/data.txt' @@ -14,18 +17,18 @@ Example: - >>> # Create a DataSource and use '/home/guido/tmpdata/' for local storage. - >>> ds = datasource.DataSource('/home/guido/tmpdata/') + >>> # Create a DataSource, use os.curdir (default) for local storage. + >>> ds = datasource.DataSource() >>> - >>> # Open a remote, gzipped file. + >>> # Open a remote file. >>> # DataSource downloads the file, stores it locally in: - >>> # '/home/guido/tmpdata/www.scipy.org/not/real/data.txt.gz' - >>> # opens the file with the gzip module and returns a file-like object. - >>> - >>> fp = ds.open('http://www.scipy.org/not/real/data.txt.gz') - >>> fp.read() # Use the file + >>> # './www.google.com/index.html' + >>> # opens the file and returns a file object. + >>> fp = ds.open('http://www.google.com/index.html') + >>> + >>> # Use the file as you normally would + >>> fp.read() >>> fp.close() - >>> del ds, fp """ @@ -79,12 +82,13 @@ >>> ds.open('/home/guido/foobar.txt') Opened file exists in tempdir like: /tmp/tmpUnhcvM/foobar.txt + Temporary directories are deleted when the DataSource is deleted. """ def __init__(self, destpath=os.curdir): if destpath: - self._destpath = destpath + self._destpath = os.path.abspath(destpath) self._istmpdest = False else: self._destpath = tempfile.mkdtemp() @@ -103,7 +107,7 @@ def _iswritemode(self, mode): """Test if the given mode will open a file for writing.""" - # Currently only used to test the bz2 files. Not thoroughly tested! + # Currently only used to test the bz2 files. _writemodes = ("w", "+") for c in mode: if c in _writemodes: @@ -193,8 +197,20 @@ return None def abspath(self, path): - """Return an absolute path in the DataSource destination directory. + """Return absolute path in the DataSource destination directory. + Functionality is idential to os.path.abspath. Returned path is not + guaranteed to exist. + + *Parameters*: + + path : {string} + Can be a local file or a remote URL. + + *Returns*: + + Complete path, rooted in the DataSource destination directory. + """ # handle case where path includes self._destpath @@ -207,8 +223,33 @@ def exists(self, path): """Test if path exists. - Tests for local files, locally cached URLs and remote URLs. + Test if path exists as (in this order): + - a local file + - a remote URLs that have been downloaded and stored locally in the + DataSource directory + - a remote URL that has not been downloaded, but is valid and + accessible. + When path is an URL, `exist` will return True if it's stored + locally in the DataSource directory, or is a valid remote URL. + + *Parameters*: + + path : {string} + Can be a local file or a remote URL. + + *Returns*: + + boolean + + *See Also*: + + `abspath` + + *Examples* + + >>> ds = datasource.DataSource() + >>> ds.exists('http://www.google.com') """ upath = self.abspath(path) From scipy-svn at scipy.org Thu Nov 1 20:23:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 19:23:34 -0500 (CDT) Subject: [Scipy-svn] r3484 - trunk/scipy/io Message-ID: <20071102002334.A096B39C1AC@new.scipy.org> Author: chris.burns Date: 2007-11-01 19:23:31 -0500 (Thu, 01 Nov 2007) New Revision: 3484 Modified: trunk/scipy/io/datasource.py Log: Update datasource documentation. Modified: trunk/scipy/io/datasource.py =================================================================== --- trunk/scipy/io/datasource.py 2007-11-01 21:37:37 UTC (rev 3483) +++ trunk/scipy/io/datasource.py 2007-11-02 00:23:31 UTC (rev 3484) @@ -62,31 +62,54 @@ class DataSource (object): - """A generic data source (file, http, ftp, ...). + """A generic data source file (file, http, ftp, ...). - DataSource could be from a local file or remote file/URL. The file may - also be compressed or uncompressed. + DataSources could be local files or remote files/URLs. The files may + also be compressed or uncompressed. DataSource hides some of the low-level + details of downloading the file, allowing you to simply pass in a valid + file path (or URL) and obtain a file object. - Ex URL DataSources: - Initialize DataSource with a local directory. Default is os.curdir + Methods: - >>> ds = DataSource('/home/guido') - >>> ds.open('http://fake.xyz.web/site/xyz.txt') + - exists : test if the file exists locally or remotely + - abspath : get absolute path of the file in the DataSource directory + - open : open the file - Opened file exists here: /home/guido/site/xyz.txt + Example URL DataSource:: - Ex using DataSource for temporary files: - Initialize DataSource with 'None' for local directory. + # Initialize DataSource with a local directory, default is os.curdir. + ds = DataSource('/home/guido') + + # Open remote file. + # File will be downloaded and opened from here: + # /home/guido/site/xyz.txt + ds.open('http://fake.xyz.web/site/xyz.txt') + + Example using DataSource for temporary files:: - >>> ds = DataSource(None) - >>> ds.open('/home/guido/foobar.txt') + # Initialize DataSource with 'None' for the local directory. + ds = DataSource(None) + + # Open local file. + # Opened file exists in a temporary directory like: + # /tmp/tmpUnhcvM/foobar.txt + # Temporary directories are deleted when the DataSource is deleted. + ds.open('/home/guido/foobar.txt') - Opened file exists in tempdir like: /tmp/tmpUnhcvM/foobar.txt - Temporary directories are deleted when the DataSource is deleted. + *Notes*: + BUG : URLs require a scheme string ('http://') to be used. + www.google.com will fail. + + >>> repos.exists('www.google.com/index.html') + False + >>> repos.exists('http://www.google.com/index.html') + True + """ def __init__(self, destpath=os.curdir): + """Create a DataSource with a local path at destpath.""" if destpath: self._destpath = os.path.abspath(destpath) self._istmpdest = False @@ -117,7 +140,7 @@ def _splitzipext(self, filename): """Split zip extension from filename and return filename. - Returns: + *Returns*: base, zip_ext : {tuple} """ @@ -138,6 +161,13 @@ def _isurl(self, path): """Test if path is a net location. Tests the scheme and netloc.""" + + # BUG : URLs require a scheme string ('http://') to be used. + # www.google.com will fail. + # Should we prepend the scheme for those that don't have it and + # test that also? Similar to the way we append .gz and test for + # for compressed versions of files. + scheme, netloc, upath, uparams, uquery, ufrag = urlparse(path) return bool(scheme and netloc) @@ -171,7 +201,7 @@ return upath def _findfile(self, path): - """Searches for path and returns full path if found. + """Searches for ``path`` and returns full path if found. If path is an URL, _findfile will cache a local copy and return the path to the cached file. @@ -197,11 +227,14 @@ return None def abspath(self, path): - """Return absolute path in the DataSource destination directory. + """Return absolute path of ``path`` in the DataSource directory. - Functionality is idential to os.path.abspath. Returned path is not - guaranteed to exist. + If ``path`` is an URL, the ``abspath`` will be either the location + the file exists locally or the location it would exist when opened + using the ``open`` method. + The functionality is idential to os.path.abspath. + *Parameters*: path : {string} @@ -211,6 +244,10 @@ Complete path, rooted in the DataSource destination directory. + *See Also*: + + `open` : Method that downloads and opens files. + """ # handle case where path includes self._destpath @@ -221,18 +258,16 @@ return os.path.join(self._destpath, netloc, upath.strip(os.sep)) def exists(self, path): - """Test if path exists. + """Test if ``path`` exists. - Test if path exists as (in this order): - - a local file - - a remote URLs that have been downloaded and stored locally in the - DataSource directory + Test if ``path`` exists as (and in this order): + + - a local file. + - a remote URL that have been downloaded and stored locally in the + DataSource directory. - a remote URL that has not been downloaded, but is valid and accessible. - When path is an URL, `exist` will return True if it's stored - locally in the DataSource directory, or is a valid remote URL. - *Parameters*: path : {string} @@ -246,10 +281,13 @@ `abspath` - *Examples* + *Notes* - >>> ds = datasource.DataSource() - >>> ds.exists('http://www.google.com') + When ``path`` is an URL, ``exist`` will return True if it's either + stored locally in the DataSource directory, or is a valid remote + URL. DataSource does not discriminate between to two, the file + is accessible if it exists in either location. + """ upath = self.abspath(path) @@ -267,17 +305,30 @@ return False def open(self, path, mode='r'): - """Open path and return file object. + """Open ``path`` with ``mode`` and return the file object. - If path is an URL, it will be downloaded, stored in the DataSource - directory and opened. + If ``path`` is an URL, it will be downloaded, stored in the DataSource + directory and opened from there. - TODO: Currently only opening for reading has been tested. There is no - support for opening a file for writing which doesn't exist yet - (creating a file). + *Parameters*: + path : {string} + + mode : {string}, optional + + + *Returns*: + + file object + """ + # TODO: There is no support for opening a file for writing which + # doesn't exist yet (creating a file). Should there be? + + # TODO: Add a ``subdir`` parameter for specifying the subdirectory + # used to store URLs in self._destpath. + if self._isurl(path) and self._iswritemode(mode): raise ValueError("URLs are not writeable") @@ -293,30 +344,39 @@ class Repository (DataSource): - """A data repository where multiple DataSource's share one base URL. + """A data repository where multiple DataSource's share a base URL/directory. Use a Repository when you will be working with multiple files from one base URL or directory. Initialize the Respository with the base URL, then refer to each file only by it's filename. - >>> repos = Repository('/home/user/data/dir/') - >>> fp = repos.open('data01.txt') - >>> fp.analyze() - >>> fp.close() + Methods: - Similarly you could use a URL for a repository: - >>> repos = Repository('http://www.xyz.edu/data') + - exists : test if the file exists locally or remotely + - abspath : get absolute path of the file in the DataSource directory + - open : open the file + Toy example:: + + # Analyze all files in the repository. + repos = Repository('/home/user/data/dir/') + for filename in filelist: + fp = repos.open(filename) + fp.analyze() + fp.close() + + # Similarly you could use a URL for a repository. + repos = Repository('http://www.xyz.edu/data') + """ def __init__(self, baseurl, destpath=os.curdir): + """Create a Repository with a shared url or directory of baseurl.""" DataSource.__init__(self, destpath=destpath) self._baseurl = baseurl def _fullpath(self, path): - '''Return complete path for path. Prepends baseurl if necessary.''' - #print 'Repository._fullpath:', path - #print ' ._baseurl: ', self._baseurl + """Return complete path for path. Prepends baseurl if necessary.""" splitpath = path.split(self._baseurl, 2) if len(splitpath) == 1: result = os.path.join(self._baseurl, path) @@ -325,17 +385,21 @@ return result def _findfile(self, path): + """Extend DataSource method to add baseurl to ``path``.""" #print 'Repository._findfile:', path return DataSource._findfile(self, self._fullpath(path)) def abspath(self, path): + """Extend DataSource method to add baseurl to ``path``.""" return DataSource.abspath(self, self._fullpath(path)) - def exists(self, path): + def exists(self, path): + """Extend DataSource method to add baseurl to ``path``.""" #print 'Respository.exists:', path return DataSource.exists(self, self._fullpath(path)) def open(self, path, mode='r'): + """Extend DataSource method to add baseurl to ``path``.""" #print 'Repository.open:', path return DataSource.open(self, self._fullpath(path), mode) From scipy-svn at scipy.org Fri Nov 2 00:18:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Nov 2007 23:18:07 -0500 (CDT) Subject: [Scipy-svn] r3485 - trunk/scipy/sparse Message-ID: <20071102041807.467C139C048@new.scipy.org> Author: wnbell Date: 2007-11-01 23:18:04 -0500 (Thu, 01 Nov 2007) New Revision: 3485 Modified: trunk/scipy/sparse/sparse.py Log: refactoring of csr_matrix and csc_matrix constructors Modified: trunk/scipy/sparse/sparse.py =================================================================== --- trunk/scipy/sparse/sparse.py 2007-11-02 00:23:31 UTC (rev 3484) +++ trunk/scipy/sparse/sparse.py 2007-11-02 04:18:04 UTC (rev 3485) @@ -506,6 +506,17 @@ class _cs_matrix(spmatrix): """base matrix class for compressed row and column oriented matrices""" + def _set_self(self, other, copy=False): + if copy: + other = other.copy() + + self.data = other.data + self.indices = other.indices + self.indptr = other.indptr + self.shape = other.shape + self.dtype = other.data.dtype + + def _check_format(self, orientation, full_check): # some functions pass floats self.shape = tuple([int(x) for x in self.shape]) @@ -926,32 +937,12 @@ else: raise ValueError, "dense array must have rank 1 or 2" elif isspmatrix(arg1): - s = arg1 - self.dtype = getdtype(dtype, s) - if isinstance(s, csc_matrix): - # do nothing but copy information - self.shape = s.shape - if copy: - self.data = s.data.copy() - self.indices = s.indices.copy() - self.indptr = s.indptr.copy() - else: - self.data = s.data - self.indices = s.indices - self.indptr = s.indptr - elif isinstance(s, csr_matrix): - self.shape = s.shape - self.indptr, self.indices, self.data = csrtocsc(s.shape[0], - s.shape[1], - s.indptr, - s.indices, - s.data) + try: + other = arg1.tocsc(copy=copy) + except AttributeError: + raise AttributeError,'all sparse matrices must have .tocsc()' else: - temp = s.tocsc() - self.data = temp.data - self.indices = temp.indices - self.indptr = temp.indptr - self.shape = temp.shape + self._set_self( other ) elif isinstance(arg1, tuple): if isshape(arg1): self.dtype = getdtype(dtype, default=float) @@ -964,34 +955,30 @@ else: try: # Try interpreting it as (data, ij) - (s, ij) = arg1 + (data, ij) = arg1 assert isinstance(ij, ndarray) and (rank(ij) == 2) \ - and (shape(ij) == (2, len(s))) + and (shape(ij) == (2, len(data))) except (AssertionError, TypeError, ValueError): try: - # Try interpreting it as (data, rowind, indptr) - (s, rowind, indptr) = arg1 - self.dtype = getdtype(dtype, s) + # Try interpreting it as (data, indices, indptr) + (data, indices, indptr) = arg1 + self.dtype = getdtype(dtype, data) if copy: - self.data = array(s) - self.indices = array(rowind) - self.indptr = array(indptr) + self.data = array(data) + self.indices = array(indices) + self.indptr = array(indptr) else: - self.data = asarray(s) - self.indices = asarray(rowind) - self.indptr = asarray(indptr) + self.data = asarray(data) + self.indices = asarray(indices) + self.indptr = asarray(indptr) except: raise ValueError, "unrecognized form for csc_matrix constructor" else: # (data, ij) format - self.dtype = getdtype(dtype, s) + self.dtype = getdtype(dtype, data) ijnew = array(ij, copy=copy) - temp = coo_matrix((s, ijnew), dims=dims, \ - dtype=self.dtype).tocsc() - self.shape = temp.shape - self.data = temp.data - self.indices = temp.indices - self.indptr = temp.indptr + self._set_self( coo_matrix((data, ijnew), dims=dims, \ + dtype=self.dtype).tocsc() ) else: raise ValueError, "unrecognized form for csc_matrix constructor" @@ -1238,6 +1225,7 @@ """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): _cs_matrix.__init__(self) + if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format @@ -1251,28 +1239,12 @@ else: raise ValueError, "dense array must have rank 1 or 2" elif isspmatrix(arg1): - s = arg1 - self.dtype = getdtype(dtype, s) - if isinstance(s, csr_matrix): - # do nothing but copy information - self.shape = s.shape - if copy: - self.data = s.data.copy() - self.indices = s.indices.copy() - self.indptr = s.indptr.copy() - else: - self.data = s.data - self.indices = s.indices - self.indptr = s.indptr + try: + other = arg1.tocsr(copy=copy) + except AttributeError: + raise AttributeError,'all sparse matrices must have .tocsr()' else: - try: - temp = s.tocsr() - except AttributeError: - temp = csr_matrix(s.tocsc()) - self.data = temp.data - self.indices = temp.indices - self.indptr = temp.indptr - self.shape = temp.shape + self._set_self( other ) elif isinstance(arg1, tuple): if isshape(arg1): # It's a tuple of matrix dimensions (M, N) @@ -1285,35 +1257,31 @@ else: try: # Try interpreting it as (data, ij) - (s, ij) = arg1 + (data, ij) = arg1 assert isinstance(ij, ndarray) and (rank(ij) == 2) \ - and (shape(ij) == (2, len(s))) + and (shape(ij) == (2, len(data))) except (AssertionError, TypeError, ValueError, AttributeError): try: - # Try interpreting it as (data, colind, indptr) - (s, colind, indptr) = arg1 + # Try interpreting it as (data, indices, indptr) + (data, indices, indptr) = arg1 except (TypeError, ValueError): raise ValueError, "unrecognized form for csr_matrix constructor" else: - self.dtype = getdtype(dtype, s) + self.dtype = getdtype(dtype, data) if copy: - self.data = array(s, dtype=self.dtype) - self.indices = array(colind) + self.data = array(data, dtype=self.dtype) + self.indices = array(indices) self.indptr = array(indptr) else: - self.data = asarray(s, dtype=self.dtype) - self.indices = asarray(colind) - self.indptr = asarray(indptr) + self.data = asarray(data, dtype=self.dtype) + self.indices = asarray(indices) + self.indptr = asarray(indptr) else: # (data, ij) format - self.dtype = getdtype(dtype, s) + self.dtype = getdtype(dtype, data) ijnew = array(ij, copy=copy) - temp = coo_matrix((s, ijnew), dims=dims, \ - dtype=self.dtype).tocsr() - self.shape = temp.shape - self.data = temp.data - self.indices = temp.indices - self.indptr = temp.indptr + self._set_self( coo_matrix((data, ijnew), dims=dims, \ + dtype=self.dtype).tocsr() ) else: raise ValueError, "unrecognized form for csr_matrix constructor" From scipy-svn at scipy.org Fri Nov 2 01:19:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 00:19:19 -0500 (CDT) Subject: [Scipy-svn] r3486 - trunk/scipy/sparse Message-ID: <20071102051919.5A9DD39C03C@new.scipy.org> Author: wnbell Date: 2007-11-02 00:19:17 -0500 (Fri, 02 Nov 2007) New Revision: 3486 Modified: trunk/scipy/sparse/sparse.py Log: further refactoring of csr/csc constructors Modified: trunk/scipy/sparse/sparse.py =================================================================== --- trunk/scipy/sparse/sparse.py 2007-11-02 04:18:04 UTC (rev 3485) +++ trunk/scipy/sparse/sparse.py 2007-11-02 05:19:17 UTC (rev 3486) @@ -91,10 +91,19 @@ self.allocsize = allocsize def set_shape(self,shape): - s = tuple(shape) - if len(s) != 2: + shape = tuple(shape) + + if len(shape) != 2: raise ValueError("Only two-dimensional sparse arrays " - "are supported.") + "are supported.") + try: + shape = int(shape[0]),int(shape[1]) #floats, other weirdness + except: + raise TypeError,'invalid shape' + + if not (shape[0] >= 1 and shape[1] >= 1): + raise TypeError,'invalid shape' + if (self._shape != shape) and (self._shape is not None): try: self = self.reshape(shape) @@ -506,7 +515,10 @@ class _cs_matrix(spmatrix): """base matrix class for compressed row and column oriented matrices""" + def _set_self(self, other, copy=False): + """take the member variables of other and assign them to self""" + if copy: other = other.copy() @@ -983,32 +995,19 @@ raise ValueError, "unrecognized form for csc_matrix constructor" - # Read matrix dimensions given, if any if dims is not None: - try: - (M, N) = dims - M,N = int(M),int(N) - except (TypeError, ValueError), e: - raise TypeError, "dimensions not understood" + self.shape = dims else: - # Read existing matrix dimensions - try: - (oldM, oldN) = self.shape - except: - oldM = oldN = None + if self.shape is None: + # shape not already set, try to infer dimensions + try: + M = self.indices.max() + 1 + N = len(self.indptr) - 1 + self.shape = (M,N) + except: + raise ValueError,'unable to infer matrix dimensions' - # Expand if necessary - M = N = None - N = max(0, oldN, N, len(self.indptr) - 1) - if len(self.indices) > 0: - M = max(oldM, M, int(amax(self.indices)) + 1) - else: - # Matrix is completely empty - M = max(oldM, M) - - self.shape = (M, N) - self.check_format(full_check=False) def check_format(self,full_check=True): @@ -1285,30 +1284,19 @@ else: raise ValueError, "unrecognized form for csr_matrix constructor" - # Read matrix dimensions given, if any if dims is not None: - try: - (M, N) = dims - except (TypeError, ValueError), e: - raise TypeError, "dimensions not understood" + self.shape = dims else: - # Read existing matrix dimensions - try: - (oldM, oldN) = self.shape - except: - oldM = oldN = None + if self.shape is None: + # shape not already set, try to infer dimensions + try: + M = len(self.indptr) - 1 + N = self.indices.max() + 1 + self.shape = (M,N) + except: + raise ValueError,'unable to infer matrix dimensions' - M = N = None - M = max(0, oldM, M, len(self.indptr) - 1) - if len(self.indices) > 0: - N = max(oldN, N, int(amax(self.indices)) + 1) - else: - # Matrix is completely empty - N = max(oldN, N) - - self.shape = (M, N) - self.check_format(full_check=False) def check_format(self,full_check=True): From scipy-svn at scipy.org Fri Nov 2 02:09:30 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 01:09:30 -0500 (CDT) Subject: [Scipy-svn] r3487 - trunk/scipy/sparse Message-ID: <20071102060930.C5AE539C038@new.scipy.org> Author: wnbell Date: 2007-11-02 01:09:29 -0500 (Fri, 02 Nov 2007) New Revision: 3487 Modified: trunk/scipy/sparse/sparse.py Log: almost finished with unification of csr/csc constructors Modified: trunk/scipy/sparse/sparse.py =================================================================== --- trunk/scipy/sparse/sparse.py 2007-11-02 05:19:17 UTC (rev 3486) +++ trunk/scipy/sparse/sparse.py 2007-11-02 06:09:29 UTC (rev 3487) @@ -938,7 +938,7 @@ if isdense(arg1): self.dtype = getdtype(dtype, arg1) - # Convert the dense array or matrix arg1 to CSC format + # Convert the dense array or matrix arg1 to sparse format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) @@ -948,32 +948,34 @@ densetocsr(arg1.shape[1], arg1.shape[0], arg1.T) else: raise ValueError, "dense array must have rank 1 or 2" + elif isspmatrix(arg1): - try: - other = arg1.tocsc(copy=copy) - except AttributeError: - raise AttributeError,'all sparse matrices must have .tocsc()' - else: - self._set_self( other ) + if copy: + arg1 = arg1.copy() + self._set_self( self._tothis(arg1) ) + elif isinstance(arg1, tuple): if isshape(arg1): - self.dtype = getdtype(dtype, default=float) # It's a tuple of matrix dimensions (M, N) - M, N = arg1 + self.shape = arg1 #spmatrix checks for errors here + M, N = self.shape + self.dtype = getdtype(dtype, default=float) self.data = zeros((nzmax,), self.dtype) self.indices = zeros((nzmax,), intc) self.indptr = zeros((N+1,), intc) - self.shape = (M, N) else: try: # Try interpreting it as (data, ij) (data, ij) = arg1 assert isinstance(ij, ndarray) and (rank(ij) == 2) \ and (shape(ij) == (2, len(data))) - except (AssertionError, TypeError, ValueError): + except (AssertionError, TypeError, ValueError, AttributeError): try: # Try interpreting it as (data, indices, indptr) (data, indices, indptr) = arg1 + except: + raise ValueError, "unrecognized form for csc_matrix constructor" + else: self.dtype = getdtype(dtype, data) if copy: self.data = array(data) @@ -983,21 +985,19 @@ self.data = asarray(data) self.indices = asarray(indices) self.indptr = asarray(indptr) - except: - raise ValueError, "unrecognized form for csc_matrix constructor" else: # (data, ij) format - self.dtype = getdtype(dtype, data) - ijnew = array(ij, copy=copy) - self._set_self( coo_matrix((data, ijnew), dims=dims, \ - dtype=self.dtype).tocsc() ) + other = coo_matrix((data, ij), dims=dims ) + other = self._tothis(other) + self._set_self( other ) + else: - raise ValueError, "unrecognized form for csc_matrix constructor" + raise ValueError, "unrecognized form for csc_matrix constructor" # Read matrix dimensions given, if any if dims is not None: - self.shape = dims + self.shape = dims # spmatrix will check for errors else: if self.shape is None: # shape not already set, try to infer dimensions @@ -1227,7 +1227,7 @@ if isdense(arg1): self.dtype = getdtype(dtype, arg1) - # Convert the dense array or matrix arg1 to CSR format + # Convert the dense array or matrix arg1 to sparse format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) @@ -1237,22 +1237,21 @@ densetocsr(arg1.shape[0], arg1.shape[1], arg1) else: raise ValueError, "dense array must have rank 1 or 2" + elif isspmatrix(arg1): - try: - other = arg1.tocsr(copy=copy) - except AttributeError: - raise AttributeError,'all sparse matrices must have .tocsr()' - else: - self._set_self( other ) + if copy: + arg1 = arg1.copy() + self._set_self( self._tothis(arg1) ) + elif isinstance(arg1, tuple): if isshape(arg1): # It's a tuple of matrix dimensions (M, N) - M, N = arg1 + self.shape = arg1 #spmatrix checks for errors here + M, N = self.shape self.dtype = getdtype(dtype, default=float) self.data = zeros((nzmax,), self.dtype) self.indices = zeros((nzmax,), intc) self.indptr = zeros((M+1,), intc) - self.shape = (M, N) else: try: # Try interpreting it as (data, ij) @@ -1263,7 +1262,7 @@ try: # Try interpreting it as (data, indices, indptr) (data, indices, indptr) = arg1 - except (TypeError, ValueError): + except: raise ValueError, "unrecognized form for csr_matrix constructor" else: self.dtype = getdtype(dtype, data) @@ -1277,16 +1276,16 @@ self.indptr = asarray(indptr) else: # (data, ij) format - self.dtype = getdtype(dtype, data) - ijnew = array(ij, copy=copy) - self._set_self( coo_matrix((data, ijnew), dims=dims, \ - dtype=self.dtype).tocsr() ) + other = coo_matrix((data, ij), dims=dims ) + other = self._tothis(other) + self._set_self( other ) + else: raise ValueError, "unrecognized form for csr_matrix constructor" # Read matrix dimensions given, if any if dims is not None: - self.shape = dims + self.shape = dims # spmatrix will check for errors else: if self.shape is None: # shape not already set, try to infer dimensions From scipy-svn at scipy.org Fri Nov 2 02:39:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 01:39:34 -0500 (CDT) Subject: [Scipy-svn] r3488 - trunk/scipy/sparse Message-ID: <20071102063934.5FA5C39C0C6@new.scipy.org> Author: wnbell Date: 2007-11-02 01:39:32 -0500 (Fri, 02 Nov 2007) New Revision: 3488 Modified: trunk/scipy/sparse/sparse.py Log: small edit Modified: trunk/scipy/sparse/sparse.py =================================================================== --- trunk/scipy/sparse/sparse.py 2007-11-02 06:09:29 UTC (rev 3487) +++ trunk/scipy/sparse/sparse.py 2007-11-02 06:39:32 UTC (rev 3488) @@ -959,10 +959,10 @@ # It's a tuple of matrix dimensions (M, N) self.shape = arg1 #spmatrix checks for errors here M, N = self.shape - self.dtype = getdtype(dtype, default=float) - self.data = zeros((nzmax,), self.dtype) + self.dtype = getdtype(dtype, default=float) + self.data = zeros((nzmax,), self.dtype) self.indices = zeros((nzmax,), intc) - self.indptr = zeros((N+1,), intc) + self.indptr = zeros((N+1,), intc) else: try: # Try interpreting it as (data, ij) @@ -977,14 +977,10 @@ raise ValueError, "unrecognized form for csc_matrix constructor" else: self.dtype = getdtype(dtype, data) - if copy: - self.data = array(data) - self.indices = array(indices) - self.indptr = array(indptr) - else: - self.data = asarray(data) - self.indices = asarray(indices) - self.indptr = asarray(indptr) + self.dtype = getdtype(dtype, data) + self.data = array(data, copy=copy, dtype=self.dtype) + self.indices = array(indices, copy=copy) + self.indptr = array(indptr, copy=copy) else: # (data, ij) format other = coo_matrix((data, ij), dims=dims ) @@ -1248,10 +1244,10 @@ # It's a tuple of matrix dimensions (M, N) self.shape = arg1 #spmatrix checks for errors here M, N = self.shape - self.dtype = getdtype(dtype, default=float) - self.data = zeros((nzmax,), self.dtype) + self.dtype = getdtype(dtype, default=float) + self.data = zeros((nzmax,), self.dtype) self.indices = zeros((nzmax,), intc) - self.indptr = zeros((M+1,), intc) + self.indptr = zeros((M+1,), intc) else: try: # Try interpreting it as (data, ij) @@ -1265,15 +1261,10 @@ except: raise ValueError, "unrecognized form for csr_matrix constructor" else: - self.dtype = getdtype(dtype, data) - if copy: - self.data = array(data, dtype=self.dtype) - self.indices = array(indices) - self.indptr = array(indptr) - else: - self.data = asarray(data, dtype=self.dtype) - self.indices = asarray(indices) - self.indptr = asarray(indptr) + self.dtype = getdtype(dtype, data) + self.data = array(data, copy=copy, dtype=self.dtype) + self.indices = array(indices, copy=copy) + self.indptr = array(indptr, copy=copy) else: # (data, ij) format other = coo_matrix((data, ij), dims=dims ) From scipy-svn at scipy.org Fri Nov 2 11:51:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 10:51:00 -0500 (CDT) Subject: [Scipy-svn] r3489 - trunk/scipy/stats Message-ID: <20071102155100.C7D5839C00C@new.scipy.org> Author: oliphant Date: 2007-11-02 10:50:57 -0500 (Fri, 02 Nov 2007) New Revision: 3489 Modified: trunk/scipy/stats/morestats.py Log: Fix ticket #526: return values for bayes_mvs. Modified: trunk/scipy/stats/morestats.py =================================================================== --- trunk/scipy/stats/morestats.py 2007-11-02 06:39:32 UTC (rev 3488) +++ trunk/scipy/stats/morestats.py 2007-11-02 15:50:57 UTC (rev 3489) @@ -69,7 +69,7 @@ term = fac2*val sta = st - term stb = st + term - return mp, (ma, mb), vp, (va, vb), st, (sta, stb) + return (mp, (ma, mb)), (vp, (va, vb)), (st, (sta, stb)) ## Assumes all is known is that mean, and std (variance,axis=0) exist @@ -98,7 +98,7 @@ assert(n > 1) assert(alpha < 1 and alpha > 0) n = float(n) - if (n > 1000): # just a guess. The curves look similar at this point. + if (n > 1000): # just a guess. The curves look very similar at this point. return _gauss_mvs(x, n, alpha) xbar = x.mean() C = x.var() From scipy-svn at scipy.org Fri Nov 2 11:53:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 10:53:42 -0500 (CDT) Subject: [Scipy-svn] r3490 - in trunk/scipy/stats/models: . tests Message-ID: <20071102155342.C8E0F39C00C@new.scipy.org> Author: cookedm Date: 2007-11-02 10:53:40 -0500 (Fri, 02 Nov 2007) New Revision: 3490 Modified: trunk/scipy/stats/models/formula.py trunk/scipy/stats/models/tests/test_formula.py Log: scipy.stats.models: Python 2.3 workaround for 'set'. Fixes #528. Modified: trunk/scipy/stats/models/formula.py =================================================================== --- trunk/scipy/stats/models/formula.py 2007-11-02 15:50:57 UTC (rev 3489) +++ trunk/scipy/stats/models/formula.py 2007-11-02 15:53:40 UTC (rev 3490) @@ -5,6 +5,11 @@ import types import numpy as N +try: + set +except NameError: + from sets import Set as set + __docformat__ = 'restructuredtext' default_namespace = {} Modified: trunk/scipy/stats/models/tests/test_formula.py =================================================================== --- trunk/scipy/stats/models/tests/test_formula.py 2007-11-02 15:50:57 UTC (rev 3489) +++ trunk/scipy/stats/models/tests/test_formula.py 2007-11-02 15:53:40 UTC (rev 3490) @@ -187,26 +187,26 @@ def test_factor1(self): f = ['a','b','c']*10 - fac = formula.Factor('ff', set(f)) + fac = formula.Factor('ff', f) fac.namespace = {'ff':f} self.assertEquals(list(fac.values()), f) def test_factor2(self): f = ['a','b','c']*10 - fac = formula.Factor('ff', set(f)) + fac = formula.Factor('ff', f) fac.namespace = {'ff':f} self.assertEquals(fac().shape, (3,30)) def test_factor3(self): f = ['a','b','c']*10 - fac = formula.Factor('ff', set(f)) + fac = formula.Factor('ff', f) fac.namespace = {'ff':f} m = fac.main_effect(reference=1) self.assertEquals(m().shape, (2,30)) def test_factor4(self): f = ['a','b','c']*10 - fac = formula.Factor('ff', set(f)) + fac = formula.Factor('ff', f) fac.namespace = {'ff':f} m = fac.main_effect(reference=2) r = N.array([N.identity(3)]*10) From scipy-svn at scipy.org Fri Nov 2 15:51:47 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 14:51:47 -0500 (CDT) Subject: [Scipy-svn] r3491 - branches Message-ID: <20071102195147.3236439C034@new.scipy.org> Author: tom.waite Date: 2007-11-02 14:51:44 -0500 (Fri, 02 Nov 2007) New Revision: 3491 Added: branches/ndimage_segmenter/ Log: Create NDImage Segmenter branch. Copied: branches/ndimage_segmenter (from rev 3490, trunk) From scipy-svn at scipy.org Fri Nov 2 16:09:21 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 15:09:21 -0500 (CDT) Subject: [Scipy-svn] r3492 - in branches/ndimage_segmenter/scipy: . NDISegmenter Message-ID: <20071102200921.366EB39C122@new.scipy.org> Author: tom.waite Date: 2007-11-02 15:09:04 -0500 (Fri, 02 Nov 2007) New Revision: 3492 Added: branches/ndimage_segmenter/scipy/NDISegmenter/ branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter.py branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_EXT.c branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_IMPL.c branches/ndimage_segmenter/scipy/NDISegmenter/__multiarray_api.h branches/ndimage_segmenter/scipy/NDISegmenter/__ufunc_api.h branches/ndimage_segmenter/scipy/NDISegmenter/arrayobject.h branches/ndimage_segmenter/scipy/NDISegmenter/arrayscalars.h branches/ndimage_segmenter/scipy/NDISegmenter/config.h branches/ndimage_segmenter/scipy/NDISegmenter/control.py branches/ndimage_segmenter/scipy/NDISegmenter/ndImage_Segmenter_structs.h branches/ndimage_segmenter/scipy/NDISegmenter/ndarrayobject.h branches/ndimage_segmenter/scipy/NDISegmenter/noprefix.h branches/ndimage_segmenter/scipy/NDISegmenter/npy_interrupt.h branches/ndimage_segmenter/scipy/NDISegmenter/old_defines.h branches/ndimage_segmenter/scipy/NDISegmenter/oldnumeric.h branches/ndimage_segmenter/scipy/NDISegmenter/setup.py branches/ndimage_segmenter/scipy/NDISegmenter/slice112.raw branches/ndimage_segmenter/scipy/NDISegmenter/testShenCastan.py branches/ndimage_segmenter/scipy/NDISegmenter/ufuncobject.h branches/ndimage_segmenter/scipy/NDISegmenter/volumeInput.py Log: Add NDISegmenter code. Added: branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter.py =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter.py 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter.py 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,129 @@ +import numpy as N +import NDI_Segmenter as S +import volumeInput as V +import struct + +def ShenCastan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): + datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), + ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), + ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), + ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), + ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] + labeledEdges, numberObjects = S.ShenCastanEdges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=datatype) + # return the bounding box for each connected edge + S.SetObjectStats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def Sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): + datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), + ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), + ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), + ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), + ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.SobelEdges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=datatype) + # return the bounding box for each connected edge + S.GetObjectStats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.MorphoThinFilt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def Canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, + BPHigh=10.0, apearture=21, dust=16): + datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), + ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), + ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), + ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), + ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.CannyEdges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=datatype) + # return the bounding box for each connected edge + S.GetObjectStats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def GetShapeMask(labeledEdges, ROIList): + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.BuildBoundary(labeledEdges, ROIList) + return + +def GetVoxelMeasures(rawImage, labeledEdges, ROIList): + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.VoxelMeasures(rawImage, labeledEdges, ROIList) + return + +def GetTextureMeasures(rawImage, labeledEdges, ROIList): + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list + # + S.TextureMeasures(rawImage, labeledEdges, ROIList) + return + +def SegmentRegions(volSlice=112): + # get slice from the CT volume + image = GetSliceFromVolume(volSlice) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = Sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + GetShapeMask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + GetVoxelMeasures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + GetTextureMeasures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList + +def GrowRegions(volSlice=112): + # get slice from the CT volume + image = GetSliceFromVolume(volSlice) + regionMask, numberRegions = RegionGrow(image) + return regionMask, numberRegions + + +def RegionGrow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.RegionGrow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + + +def GetSlice(imageName='junk.raw', bytes=2, rows=512, columns=512): + # get a slice alrady extracted from the CT volume + image = open(imageName, 'rb') + slice = image.read(rows*columns*bytes) + values = struct.unpack('h'*rows*columns, slice) + ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + return (ImageSlice) + +def GetSliceFromVolume(mySlice, rows=512, columns=512, bytes=2): + # extract a slice the CT volume. Hardwirred + image = open('C:\PythonStuff\CardiacCT.vol', 'rb') + image.seek(mySlice*rows*columns*bytes) + slice = image.read(rows*columns*bytes) + values = struct.unpack('h'*rows*columns, slice) + ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + return (ImageSlice+2048) + +def SaveSlice(mySlice, filename='junk.raw', rows=512, columns=512, bytes=2): + # just save the slice to a fixed file + slice = mySlice.astype(int) + image = open(filename, 'wb') + image.write(slice) + image.close() + return + + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter.py ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_EXT.c =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_EXT.c 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_EXT.c 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,445 @@ +#include "ndImage_Segmenter_structs.h" +#include "Python.h" +#include "noprefix.h" + +static PyObject *NDI_Segmenter_CannyEdges(PyObject *self, PyObject *args) +{ + + double sigma; + double cannyLow; + double cannyHigh; + double BPHigh; + int lowThreshold; + int highThreshold; + int apearture; + int num; + int nd; + int type; + int itype; + int mode; + int groups; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + // + // pass in 2D LPF coefficients + if(!PyArg_Parse(args, "(dddiiidiO)", &sigma, &cannyLow, &cannyHigh, &mode, &lowThreshold, &highThreshold, + &BPHigh, &apearture, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + itype = 4; + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + if(!NI_CannyEdges(num, (int)dims[0], (int)dims[1], sigma, cannyLow, cannyHigh, mode, lowThreshold, + highThreshold, BPHigh, apearture, fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups); + +} + +static PyObject *NDI_Segmenter_SobelEdges(PyObject *self, PyObject *args) +{ + + double sobelLow; + double BPHigh; + int lowThreshold; + int highThreshold; + int apearture; + int num; + int nd; + int type; + int itype; + int groups; + int mode; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + // + // pass in 2D LPF coefficients + if(!PyArg_Parse(args, "(diiidiO)", &sobelLow, &mode, &lowThreshold, &highThreshold, &BPHigh, &apearture, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // this is int type and hard-wirred. pass this in from Python code + itype = 4; // unsigned short + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + + if(!NI_SobelEdges(num, (int)dims[0], (int)dims[1], sobelLow, mode, lowThreshold, highThreshold, BPHigh, apearture, + fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + +} + + + +static PyObject *NDI_Segmenter_ShenCastanEdges(PyObject *self, PyObject *args) +{ + int window; + int lowThreshold; + int highThreshold; + double ShenCastanLow; + double b; + int num; + int nd; + int type; + int itype; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + int groups; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + if(!PyArg_Parse(args, "(ddiiiO)", &ShenCastanLow, &b, &window, &lowThreshold, &highThreshold, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // this is int type and hard-wirred. pass this in from Python code + itype = 4; // unsigned short + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + if(!NI_ShenCastanEdges(num, (int)dims[0], (int)dims[1], b, ShenCastanLow, window, lowThreshold, highThreshold, + fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + +} + +static PyObject *NDI_Segmenter_GetObjectStats(PyObject *self, PyObject *args) +{ + + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + unsigned short *fP1; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + objStruct *myData; + + if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + goto exit; + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(nArray)) + goto exit; + + // + // PyArray_ContiguousFromObject or PyArray_ContiguousFromAny to be explored + // for non-contiguous + // + + + // pointer to the edge-labeled image + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + fP1 = (unsigned short *)PyArray_DATA(iArray); + + // the object descriptor array that was allocated from numpy + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + myData = (objStruct*)PyArray_DATA(nArray); + + if(!NI_GetObjectStats((int)dims[0], (int)dims[1], (int)objNumber[0], fP1, myData)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_MorphoThinFilt(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + unsigned short *fP1; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + goto exit; + + fP1 = (unsigned short *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + if(!NI_ThinFilter(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_BuildBoundary(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + unsigned short *fP1; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + goto exit; + + fP1 = (unsigned short *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + // + // this is int type and hard-wirred. pass this in from Python code + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + // + // pass in ROI list and labeled edges + // return an augmented ROI list + // replace the edgeImage with maskImage + // + if(!NI_BuildBoundary(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + +static PyObject *NDI_Segmenter_VoxelMeasures(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + PyObject *eArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OOO)", &iArray, &eArray, &nArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // eArray and iArray are same dims + fP2 = (unsigned short *)PyArray_DATA(eArray); + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + // + // pass in ROI list and labeled edges + // return an augmented ROI list + // replace the edgeImage with maskImage + // + + if(!NI_VoxelMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_TextureMeasures(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + PyObject *eArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OOO)", &iArray, &eArray, &nArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // eArray and iArray are same dims + fP2 = (unsigned short *)PyArray_DATA(eArray); + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + // + // pass in ROI list and labeled edges + // return an augmented ROI list + // replace the edgeImage with maskImage + // + + if(!NI_TextureMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_RegionGrow(PyObject *self, PyObject *args) +{ + + int lowThreshold; + int highThreshold; + int closeWindow; + int openWindow; + int num; + int nd; + int type; + int itype; + int groups; + int mode; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + // + // pass in 2D LPF coefficients + if(!PyArg_Parse(args, "(iiiiO)", &lowThreshold, &highThreshold, &closeWindow, &openWindow, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // this is int type and hard-wirred. pass this in from Python code + itype = 4; // unsigned short + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + + if(!NI_RegionGrow(num, (int)dims[0], (int)dims[1], lowThreshold, highThreshold, closeWindow, openWindow, + fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + +} + +static PyMethodDef NDI_SegmenterMethods[] = +{ + { "CannyEdges", NDI_Segmenter_CannyEdges, METH_VARARGS }, + { "ShenCastanEdges", NDI_Segmenter_ShenCastanEdges, METH_VARARGS }, + { "SobelEdges", NDI_Segmenter_SobelEdges, METH_VARARGS }, + { "GetObjectStats", NDI_Segmenter_GetObjectStats, METH_VARARGS }, + { "MorphoThinFilt", NDI_Segmenter_MorphoThinFilt, METH_VARARGS }, + { "BuildBoundary", NDI_Segmenter_BuildBoundary, METH_VARARGS }, + { "VoxelMeasures", NDI_Segmenter_VoxelMeasures, METH_VARARGS }, + { "TextureMeasures", NDI_Segmenter_TextureMeasures, METH_VARARGS }, + { "RegionGrow", NDI_Segmenter_RegionGrow, METH_VARARGS }, + { NULL, NULL }, +}; + +void initNDI_Segmenter() +{ + Py_InitModule("NDI_Segmenter", NDI_SegmenterMethods); + import_array(); +} + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_EXT.c ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_IMPL.c =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_IMPL.c 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_IMPL.c 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,2965 @@ +#include +#include +#include +#include +#include "ndImage_Segmenter_structs.h" + +// these are for this standalone and come out with the full build +// +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define FALSE 0 +#define TRUE 1 + +int NI_GetObjectStats(int rows, int cols, int numberObjects, unsigned short *labeledEdges, objStruct objectMetrics[]){ + + int i, j, k, m; + int offset; + int count; + int LowX; + int LowY; + int HighX; + int HighY; + int status; + float centerX; + float centerY; + + for(k = 1; k < numberObjects; ++k){ + offset = cols; + LowX = 32767; + LowY = 32767; + HighX = 0; + HighY = 0; + count = 0; + centerX = (float)0.0; + centerY = (float)0.0; + for(i = 1; i < (rows-1); ++i){ + for(j = 1; j < (cols-1); ++j){ + m = labeledEdges[offset+j]; + if(k == m){ + if(i < LowY) LowY = i; + if(j < LowX) LowX = j; + if(i > HighY) HighY = i; + if(j > HighX) HighX = j; + centerX += (float)j; + centerY += (float)i; + ++count; + } + } + offset += cols; + } + // the bounding box for the 2D blob + objectMetrics[k-1].L = LowX; + objectMetrics[k-1].R = HighX; + objectMetrics[k-1].B = LowY; + objectMetrics[k-1].T = HighY; + objectMetrics[k-1].Area = count; + objectMetrics[k-1].cX = centerX/(float)count; + objectMetrics[k-1].cY = centerY/(float)count; + objectMetrics[k-1].Label = k; + } + + status = numberObjects; + return status; + +} + + +void buildKernel(double BPHigh, int HalfFilterTaps, int apearture, float *kernel){ + + int i, j; + float r, t1, t2, t3, t4; + float LC, HC, tLOW, tHIGH; + float pi = (float)3.14159, rad = (float)0.01745; + + LC = (float)0.0; + HC = BPHigh * rad; + t2 = (float)2.0*pi; + t1 = (float)2.0*HalfFilterTaps + (float)1.0; + // + // build the Filter Kernel + // the kernel starts at 1 only because it is linked to the internal filter2D routine + // the code is not a Fortran code + // + j = 1; + for(i = -HalfFilterTaps; i <= HalfFilterTaps; ++i){ + r = (float)i; + if(r == (float)0.0){ + tLOW = LC; + tHIGH = HC; + } + else{ + tLOW = (float)(sin(r*LC))/r; + tHIGH = (float)(sin(r*HC))/r; + } + t3 = (float)0.54 + (float)0.46*((float)cos(r*t2/t1)); + t4 = t3*(tHIGH-tLOW); + kernel[j++] = t4; + } + + // normalize the kernel so unity gain (as is LP filter this is easy) + t1 = (float)0.0; + for(j = 1; j <= apearture; ++j){ + t1 += kernel[j]; + } + for(j = 1; j <= apearture; ++j){ + kernel[j] /= t1; + } + + t1 = (float)0.0; + for(j = 1; j <= apearture; ++j){ + t1 += kernel[j]; + } + return; +} + +void filter2D(int HalfFilterTaps, int rows, int cols, int lowThreshold, int highThreshold, float *kernel, double *Image){ + + int i, j, k, n, num1; + int offset; + float sum, value; + float buffer[1024]; + + num1 = HalfFilterTaps + 1; + offset = 0; + for(i = 0; i < rows; ++i){ + // copy image row to local buffer + for(j = 0; j < cols; ++j){ + buffer[num1+j] = Image[offset+j]; + } + // constant pad the ends of the buffer + for(j = 0; j < num1; ++j){ + buffer[j] = buffer[num1]; + } + for(j = cols+num1; j < cols+2*num1; ++j){ + buffer[j] = buffer[cols-1+num1]; + } + + // Perform Symmetric Convolution in the X dimension. + for(n = 0, j = num1; j < (cols+num1); ++j, ++n){ + sum = buffer[j] * kernel[num1]; + for(k = 1; k < num1; ++k){ + sum += kernel[num1-k] * (buffer[j+k] + buffer[j-k]); + } + Image[offset+n] = sum; + } + offset += cols; + } + + offset = 0; + for(i = 0; i < cols; ++i){ + // copy image column to local buffer + offset = 0; + for(j = 0; j < rows; ++j){ + buffer[num1+j] = Image[offset+i]; + offset += cols; + } + // constant pad the ends of the buffer + for(j = 0; j < num1; ++j){ + buffer[j] = buffer[num1]; + } + for(j = rows+num1; j < rows+2*num1; ++j){ + buffer[j] = buffer[rows-1+num1]; + } + + // Perform Symmetric Convolution in the Y dimension. + offset = 0; + for(j = num1; j < (rows+num1); ++j){ + sum = buffer[j] * kernel[num1]; + for(k = 1; k < num1; ++k){ + sum += kernel[num1-k] * (buffer[j+k] + buffer[j-k]); + } + Image[offset+i] = sum; + offset += cols; + } + } + + // threshold the image + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = Image[offset+j]; + if(value < (float)lowThreshold) value = (float)0.0; + if(value > (float)highThreshold) value = (float)0.0; + Image[offset+j] = value; + } + offset += cols; + } + + return; + +} + +void doPreProcess(int samples, int rows, int cols, double *rawImage, double BPHigh, int apearture, int lowThreshold, int highThreshold){ + + // + // 2D low pass filter using bisinc and threshold + // this specific example is on cardiac CT and focuses on segmenting the + // aorta and blood-filled chambers. for MRI the threshold will be different + // + + float *kernel; + int HalfFilterTaps = (apearture-1)/2; + kernel = calloc(apearture+16, sizeof(float)); + + buildKernel(BPHigh, HalfFilterTaps, apearture, kernel); + filter2D(HalfFilterTaps, rows, cols, lowThreshold, highThreshold, kernel, rawImage); + + free(kernel); + + return; + +} + + +int ConnectedEdgePoints(int rows, int cols, unsigned short *connectedEdges){ + + int i, j, k, l, m; + int offset; + int Label; + int Classes[4096]; + bool NewLabel; + bool Change; + unsigned short T[12]; + + // + // connected components labeling. pixels touch within 3x3 mask for edge connectedness. + // + Label = 1; + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(connectedEdges[offset+j] == 1){ + connectedEdges[offset+j] = Label++; + } + } + offset += cols; + } + + while(1){ + Change = FALSE; + // + // TOP-DOWN Pass for labeling + // + offset = cols; + for(i = 1; i < rows-1; ++i){ + for(j = 1; j < cols-1; ++j){ + if(connectedEdges[offset+j] != 0){ + T[0] = connectedEdges[offset+j]; + T[1] = connectedEdges[offset+j+1]; + T[2] = connectedEdges[offset-cols+j+1]; + T[3] = connectedEdges[offset-cols+j]; + T[4] = connectedEdges[offset-cols+j-1]; + T[5] = connectedEdges[offset+j-1]; + T[6] = connectedEdges[offset+cols+j-1]; + T[7] = connectedEdges[offset+cols+j]; + T[8] = connectedEdges[offset+cols+j+1]; + m = T[0]; + for(l = 1; l < 9; ++l){ + if(T[l] != 0){ + if(T[l] < m) m = T[l]; + } + } + if(m != connectedEdges[offset+j]){ + Change = TRUE; + connectedEdges[offset+j] = m; + } + } + } + offset += cols; + } + // + // BOTTOM-UP Pass for labeling + // + offset = (rows-1)*cols; + for(i = (rows-1); i > 1; --i){ + for(j = (cols-1); j > 1; --j){ + if(connectedEdges[offset+j] != 0){ + T[0] = connectedEdges[offset+j]; + T[1] = connectedEdges[offset+j+1]; + T[2] = connectedEdges[offset-cols+j+1]; + T[3] = connectedEdges[offset-cols+j]; + T[4] = connectedEdges[offset-cols+j-1]; + T[5] = connectedEdges[offset+j-1]; + T[6] = connectedEdges[offset+cols+j-1]; + T[7] = connectedEdges[offset+cols+j]; + T[8] = connectedEdges[offset+cols+j+1]; + m = T[0]; + for(l = 1; l < 9; ++l){ + if(T[l] != 0){ + if(T[l] < m) m = T[l]; + } + } + if(m != connectedEdges[offset+j]){ + Change = TRUE; + connectedEdges[offset+j] = m; + } + } + } + offset -= cols; + } + if(!Change) break; + } // end while loop + + Classes[0] = 0; + Label = 1; + offset = cols; + for(i = 1; i < (rows-1); ++i){ + for(j = 1; j < (cols-1); ++j){ + m = connectedEdges[offset+j]; + if(m > 0){ + NewLabel = TRUE; + for(k = 1; k < Label; ++k){ + if(Classes[k] == m) NewLabel = FALSE; + } + if(NewLabel){ + Classes[Label++] = m; + if(Label > 4000){ + return 0; // too many labeled regions. this is a pathology in the image slice + } + } + } + } + offset += cols; + } + + // + // re-label the connected blobs in continuous label order + // + offset = cols; + for(i = 1; i < (rows-1); ++i){ + for(j = 1; j < (cols-1); ++j){ + m = connectedEdges[offset+j]; + if(m > 0){ + for(k = 1; k < Label; ++k){ + if(Classes[k] == m){ + connectedEdges[offset+j] = (unsigned short)k; + break; + } + } + } + } + offset += cols; + } + + return Label; +} + +float magnitude(float X, float Y){ + + return (float)sqrt(X*X + Y*Y); +} + +int traceEdge(int i, int j, int rows, int cols, double cannyLow, float *magImage, float *HYSImage){ + + int n, m; + int ptr; + int flag; + + ptr = i * cols; + if(HYSImage[ptr+j] == (float)0.0){ + // + // this point is above high threshold + // + HYSImage[ptr+j] = (float)1.0; + flag = 0; + for(n = -1; n <= 1; ++n){ + for(m = -1; m <= 1; ++m){ + if(n == 0 && m == 0) continue; + if(((i+n) > 0) && ((j+m) > 0) && ((i+n) < rows) && ((j+m) < cols)){ + ptr = (i+n) * cols; + if(magImage[ptr+j+m] > cannyLow){ + // + // this point is above low threshold + // + if(traceEdge(i+n, j+m, rows, cols, cannyLow, magImage, HYSImage)){ + flag = 1; + break; + } + } + } + } + if(flag) break; + } + return(1); + } + + return(0); + +} + + +void edgeThreshold(int rows, int cols, double cannyLow, float *magImage, float *HYSImage){ + + int i, j; + int ptr; + + for(i = 0; i < rows; ++i){ + ptr = i * cols; + for(j = 0; j < cols; ++j){ + if(magImage[ptr+j] > cannyLow){ + HYSImage[ptr+j] = (float)1.0; + } + } + } + + return; + +} + +void edgeHysteresis(int rows, int cols, double cannyLow, double cannyHigh, float *magImage, float *HYSImage){ + + int i, j; + int ptr; + + for(i = 0; i < rows; ++i){ + ptr = i * cols; + for(j = 0; j < cols; ++j){ + if(magImage[ptr+j] > cannyHigh){ + traceEdge(i, j, rows, cols, cannyLow, magImage, HYSImage); + } + } + } + + return; + +} + +void nonMaxSupress(int rows, int cols, float aveXValue, float aveYValue, double *cannyLow, double *cannyHigh, + int mode, float *hDGImage, float *vDGImage, float *magImage){ + + int i, j; + int ptr, ptr_m1, ptr_p1; + float xSlope, ySlope, G1, G2, G3, G4, G, xC, yC; + float scale; + float maxValue = (float)0.0; + float minValue = (float)-1.0; + int histogram[256]; + int value; + int mValue; + int mIndex; + int count; + double step; + double tAve; + + for(i = 1; i < rows-1; ++i){ + ptr = i * cols; + ptr_m1 = ptr - cols; + ptr_p1 = ptr + cols; + for(j = 1; j < cols; ++j){ + magImage[ptr+j] = (float)0.0; + xC = hDGImage[ptr+j]; + yC = vDGImage[ptr+j]; + if((fabs(xC) < aveXValue) && (fabs(yC) < aveYValue)) continue; + G = magnitude(xC, yC); + if(fabs(yC) > fabs(xC)){ + // vertical gradient + xSlope = (float)(fabs(xC) / fabs(yC)); + ySlope = (float)1.0; + G2 = magnitude(hDGImage[ptr_m1+j], vDGImage[ptr_m1+j]); + G4 = magnitude(hDGImage[ptr_p1+j], vDGImage[ptr_p1+j]); + if((xC*yC) > (float)0.0){ + G1 = magnitude(hDGImage[ptr_m1+j-1], vDGImage[ptr_m1+j-1]); + G3 = magnitude(hDGImage[ptr_p1+j+1], vDGImage[ptr_p1+j+1]); + } + else{ + G1 = magnitude(hDGImage[ptr_m1+j+1], vDGImage[ptr_m1+j+1]); + G3 = magnitude(hDGImage[ptr_p1+j-1], vDGImage[ptr_p1+j-1]); + } + } + else{ + // horizontal gradient + xSlope = (float)(fabs(yC) / fabs(xC)); + ySlope = (float)1.0; + G2 = magnitude(hDGImage[ptr+j+1], vDGImage[ptr+j+1]); + G4 = magnitude(hDGImage[ptr+j-1], vDGImage[ptr+j-1]); + if((xC*yC) > (float)0.0){ + G1 = magnitude(hDGImage[ptr_p1+j+1], vDGImage[ptr_p1+j+1]); + G3 = magnitude(hDGImage[ptr_m1+j-1], vDGImage[ptr_m1+j-1]); + } + else{ + G1 = magnitude(hDGImage[ptr_m1+j+1], vDGImage[ptr_m1+j+1]); + G3 = magnitude(hDGImage[ptr_p1+j-1], vDGImage[ptr_p1+j-1]); + } + } + if( (G > (xSlope*G1 + (ySlope-xSlope)*G2)) && (G > (xSlope*G3 + (ySlope-xSlope)*G4)) ){ + magImage[ptr+j] = G; + } + if(magImage[ptr+j] > maxValue) maxValue = magImage[ptr+j]; + if(magImage[ptr+j] < minValue) minValue = magImage[ptr+j]; + } + } + + scale = (float)1.0 / (maxValue-minValue); + ptr = 0; + count = 0; + tAve = 0.0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + magImage[ptr] = scale * (magImage[ptr]-minValue); + if(magImage[ptr] > 0.0){ + tAve += magImage[ptr]; + ++count; + } + ++ptr; + } + } + tAve /= (float)count; + + step = 255.0; + for(i = 0; i < 256; ++i){ + histogram[i] = 0; + } + ptr = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = (int)(step*(magImage[ptr])); + ++histogram[value]; + ++ptr; + } + } + // + // now get the max after skipping the low values + // + mValue = -1; + mIndex = 0; + for(i = 10; i < 256; ++i){ + if(histogram[i] > mValue){ + mValue = histogram[i]; + mIndex = i; + } + } + + if(mode == 1){ + // based on the mean value of edge energy + *cannyLow = ((*cannyLow) * tAve); + *cannyHigh = ((*cannyHigh) * tAve); + } + else{ + // based on the mode value of edge energy + *cannyLow = ((*cannyLow) * ((float)mIndex/step)); + *cannyHigh = ((*cannyHigh) * ((float)mIndex/step)); + } + + return; + +} + +void DGFilters(int samples, int rows, int cols, double cannySigma, int gWidth, + float *aveXValue, float *aveYValue, double *rawImage, + double *dgKernel, float *hDGImage, float *vDGImage){ + + // + // implements the derivative of Gaussian filter. kernel set by CannyEdges + // + int i, j, k; + int ptr; + int mLength; + int count; + float *tBuffer = NULL; + double sum; + + *aveXValue = (float)0.0; + *aveYValue = (float)0.0; + + mLength = MAX(rows, cols) + 64; + tBuffer = calloc(mLength, sizeof(float)); + + // + // filter X + // + count = 0; + for(i = 0; i < rows; ++i){ + ptr = i * cols; + for(j = gWidth; j < cols-gWidth; ++j){ + sum = dgKernel[0] * rawImage[ptr+j]; + for(k = 1; k < gWidth; ++k){ + sum += dgKernel[k] * (-rawImage[ptr+j+k] + rawImage[ptr+j-k]); + } + hDGImage[ptr+j] = (float)sum; + if(sum != (float)0.0){ + ++count; + *aveXValue += (float)fabs(sum); + } + } + } + if(count){ + *aveXValue /= (float)count; + *aveXValue = (float)0.5 * (*aveXValue); + // this is 50% of the max, hardwirred for now, and is part of the threshold + } + // + // filter Y + // + count = 0; + for(i = 0; i < cols; ++i){ + for(j = 0; j < rows; ++j){ + ptr = j * cols; + tBuffer[j] = rawImage[ptr+i]; + } + for(j = gWidth; j < rows-gWidth; ++j){ + ptr = j * cols; + sum = dgKernel[0] * tBuffer[j]; + for(k = 1; k < gWidth; ++k){ + sum += dgKernel[k] * (-tBuffer[j+k] + tBuffer[j-k]); + } + vDGImage[ptr+i] = sum; + if(sum != (float)0.0){ + ++count; + *aveYValue += (float)fabs(sum); + } + } + } + if(count){ + *aveYValue /= (float)count; + *aveYValue = (float)0.5 * (*aveYValue); + // this is 50% of the max, hardwirred for now, and is part of the threshold + } + + free(tBuffer); + + return; + +} + + +int NI_CannyEdges(int samples, int rows, int cols, double cannySigma, double cannyLow, double cannyHigh, int mode, + int lowThreshold, int highThreshold, double BPHigh, int apearture, double *rawImage, + unsigned short *edgeImage, int *groups){ + + int i, j; + int offset; + int doHysteresis = 0; + int gWidth; + int mLength; + int status; + float aveXValue; + float aveYValue; + double t; + double dgKernel[20]; + float *HYSImage = NULL; + float *hDGImage = NULL; + float *vDGImage = NULL; + float *magImage = NULL; + float *tBuffer = NULL; + + // filter + printf("do preProcess\n"); + doPreProcess(samples, rows, cols, rawImage, BPHigh, apearture, lowThreshold, highThreshold); + printf("do Canny\n"); + + // + // memory for magnitude, horizontal and vertical derivative of Gaussian filter + // + mLength = MAX(rows, cols) + 64; + HYSImage = calloc(samples, sizeof(float)); + hDGImage = calloc(samples, sizeof(float)); + vDGImage = calloc(samples, sizeof(float)); + magImage = calloc(samples, sizeof(float)); + tBuffer = calloc(mLength, sizeof(float)); + + // + // build derivative of Gaussian filter kernel + // kernel is anti-symmetric so convolution is k[j]*(v[i+j] - v[i-j]) + // + gWidth = 20; + for(i = 0; i < gWidth; ++i){ + t = (float)i; + dgKernel[i] = (float)exp((double)((-t*t)/((float)2.0 * cannySigma * cannySigma))); + dgKernel[i] *= -(t / (cannySigma * cannySigma)); + } + for(i = 0; i < samples; ++i){ + HYSImage[i] = (float)0.0; + } + + DGFilters(samples, rows, cols, cannySigma, gWidth, &aveXValue, &aveYValue, rawImage, dgKernel, hDGImage, vDGImage); + nonMaxSupress(rows, cols, aveXValue, aveYValue, &cannyLow, &cannyHigh, mode, hDGImage, vDGImage, magImage); + if(doHysteresis){ + edgeHysteresis(rows, cols, cannyLow, cannyHigh, magImage, HYSImage); + } + else{ + edgeThreshold(rows, cols, cannyLow, magImage, HYSImage); + } + + // + // edge image + // + for(i = 0; i < samples; ++i){ + edgeImage[i] = (unsigned short)HYSImage[i]; + } + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + + free(tBuffer); + free(hDGImage); + free(vDGImage); + free(magImage); + free(HYSImage); + + status = *groups; + return status; + +} + +void doSobel(int samples, int rows, int cols, double sobelLow, int mode, double *rawImage, unsigned short *edgeImage){ + + int i, j; + int p, m, n; + int offset; + int offsetM1; + int offsetP1; + int minValue, maxValue; + int pAve = 0; + int count = 0; + int histogram[256]; + int value; + int maxIndex; + float pThreshold; + double scale; + double step; + float *filteredImage = NULL; + + filteredImage = calloc(samples, sizeof(float)); + + minValue = 10000; + maxValue = -10000; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + filteredImage[offset+j] = 0; + edgeImage[offset+j] = 0; + } + offset += cols; + } + + // + // Sobel + // + offset = cols; + for(i = 1; i < rows-1; ++i){ + offsetM1 = offset - cols; + offsetP1 = offset + cols; + for(j = 1; j < cols-1; ++j){ + n = 2*rawImage[offsetM1+j] + rawImage[offsetM1+j-1] + rawImage[offsetM1+j+1] - + 2*rawImage[offsetP1+j] - rawImage[offsetP1+j-1] - rawImage[offsetP1+j+1]; + m = 2*rawImage[offset+j-1] + rawImage[offsetM1+j-1] + rawImage[offsetP1+j-1] - + 2*rawImage[offset+j+1] - rawImage[offsetM1+j+1] - rawImage[offsetP1+j+1]; + p = (int)sqrt((float)(m*m) + (float)(n*n)); + if(p > 0){ + pAve += p; + ++count; + if(p > maxValue) maxValue = p; + if(p < minValue) minValue = p; + } + filteredImage[offset+j] = p; + } + offset += cols; + } + + // threshold based on ave + pAve /= count; + scale = 1.0 / maxValue; + + step = 255.0/(maxValue-minValue); + for(i = 0; i < 256; ++i){ + histogram[i] = 0; + } + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = (int)(step*(filteredImage[offset+j]-minValue)); + ++histogram[value]; + } + offset += cols; + } + // + // now get the max after skipping the low values + // + maxValue = -1; + maxIndex = 0; + for(i = 10; i < 256; ++i){ + if(histogram[i] > maxValue){ + maxValue = histogram[i]; + maxIndex = i; + } + } + + if(mode == 1){ + // based on the mean value of edge energy + pThreshold = (int)(sobelLow * (float)pAve); + } + else{ + // based on the mode value of edge energy + pThreshold = (sobelLow * (minValue + ((float)maxIndex/step))); + } + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(filteredImage[offset+j] > pThreshold){ + edgeImage[offset+j] = 1; + } + else{ + edgeImage[offset+j] = 0; + } + filteredImage[offset+j] *= scale; + } + offset += cols; + } + + free(filteredImage); + + return; + + +} + +void estimateThreshold(float *lowThreshold, float *highThreshold, float ShenCastanLow, int rows, int cols, float *SourceImage){ + + int i, j; + int offset; + int value; + int mIndex; + int histogram[256]; + float low, high; + float scale; + + low = (float)1000.0; + high = (float)-1000.0; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(fabs(SourceImage[offset+j]) > high) high = fabs(SourceImage[offset+j]); + if(fabs(SourceImage[offset+j]) < low) low = fabs(SourceImage[offset+j]); + } + offset += cols; + } + + scale = (float)255.0 / (high-low); + for(i = 0; i < 256; ++i){ + histogram[i] = 0; + } + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = (int)(scale*(fabs(SourceImage[offset+j]) - low)); + ++histogram[value]; + } + offset += cols; + } + + // + // now get the edge energy mode + // + value = 0; + mIndex = 10; + for(i = 10; i < 256; ++i){ + if(histogram[i] > value){ + value = histogram[i]; + mIndex = i; + } + } + + *highThreshold = ((float)mIndex / scale) + low; + *lowThreshold = ((float)mIndex / scale) + low; + + *highThreshold *= ShenCastanLow; + *lowThreshold *= ShenCastanLow; + + return; + +} + +void thresholdEdges(float *SourceImage, unsigned short *EdgeImage, double ShenCastanLow, int rows, int cols){ + + int i, j; + int offset; + float tLow, tHigh; + + // + // SourceImage contains the adaptive gradient + // get threshold from the mode of the edge energy + // + estimateThreshold(&tLow, &tHigh, ShenCastanLow, rows, cols, SourceImage); + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(SourceImage[offset+j] > tLow){ + EdgeImage[offset+j] = 1; + } + else{ + EdgeImage[offset+j] = 0; + } + } + offset += cols; + } + + return; + +} + +float adaptiveGradient(float *BLImage, float *FilterImage, int nrow, int ncol, int cols, int window){ + + int i, j; + int offset; + int numOn, numOff; + int hWindow = window/2; + float sumOn, sumOff; + float aveOn, aveOff; + + numOn = 0; + numOff = 0; + + sumOn = (float)0.0; + sumOff = (float)0.0; + + aveOn = (float)0.0; + aveOff = (float)0.0; + + offset = nrow * cols; + for(i = -hWindow; i < hWindow; ++i){ + for(j = -hWindow; j < hWindow; ++j){ + if(BLImage[offset+(i*cols)+(j+ncol)] == 1){ + sumOn += FilterImage[offset+(i*cols)+(j+ncol)]; + ++numOn; + } + else{ + sumOff += FilterImage[offset+(i*cols)+(j+ncol)]; + ++numOff; + } + } + } + + if(numOn){ + aveOn = sumOn / numOn; + } + + if(numOff){ + aveOff = sumOff / numOff; + } + + return (aveOff-aveOn); + +} + +void getZeroCrossings(float *SourceImage, float *FilterImage, float *BLImage, int rows, int cols, int window){ + + int i, j; + int offset; + bool validEdge; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + SourceImage[offset+j] = 0.0; + } + offset += cols; + } + + offset = window*cols; + for(i = window; i < rows-window; ++i){ + for(j = window; j < cols-window; ++j){ + validEdge = FALSE; + if((BLImage[offset+j] == 1) && (BLImage[offset+cols+j] == 0)){ + if((FilterImage[offset+cols+j] - FilterImage[offset-cols+j]) > 0.0){ + validEdge = TRUE; + } + } + else if((BLImage[offset+j] == 1) && (BLImage[offset+j+1] == 0)){ + if((FilterImage[offset+j+1] - FilterImage[offset+j-1]) > 0.0){ + validEdge = TRUE; + } + } + else if((BLImage[offset+j] == 1) && (BLImage[offset-cols+j] == 0)){ + if((FilterImage[offset+cols+j] - FilterImage[offset-cols+j]) < 0.0){ + validEdge = TRUE; + } + } + else if((BLImage[offset+j] == 1) && (BLImage[offset+j-1] == 0)){ + if((FilterImage[offset+j+1] - FilterImage[offset+j-1]) < 0.0){ + validEdge = TRUE; + } + } + if(validEdge){ + // adaptive gradeint is signed + SourceImage[offset+j] = (float)fabs(adaptiveGradient(BLImage, FilterImage, i, j, cols, window)); + } + } + offset += cols; + } + + return; + +} + + +void computeBandedLaplacian(float *image1, float *image2, float *BLImage, int rows, int cols){ + + int i, j; + int offset; + float t; + + // + // like an unsharp mask + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + t = image1[offset+j] - image2[offset+j]; + if(t < (float)0.0){ + t = (float)0.0; + } + else{ + t = (float)1.0; + } + BLImage[offset+j] = t; + } + offset += cols; + } + + return; + +} + +void thresholdImage(float *Raw, float *Filtered, int rows, int cols, int tLow, int tHigh){ + + int i, j; + int ptr; + + ptr = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(Raw[ptr] > tHigh){ + Raw[ptr] = 0.0; + Filtered[ptr] = 0.0; + } + if(Raw[ptr] < tLow){ + Raw[ptr] = 0.0; + Filtered[ptr] = 0.0; + } + ++ptr; + } + } + + return; + +} + +void ISEF_Vertical(float *SourceImage, float *FilterImage, float *A, float *B, int rows, int cols, double b){ + + + int i, j; + int offset; + float b1, b2; + + b1 = ((float)1.0 - b)/((float)1.0 + b); + b2 = b * b1; + + // + // set the boundaries + // + offset = (rows-1)*cols; + for(i = 0; i < cols; ++i){ + // process row 0 + A[i] = b1 * SourceImage[i]; + // process row N-1 + B[offset+i] = b2 * SourceImage[offset+i]; + } + + // + // causal component of IIR filter + // + offset = cols; + for(i = 1; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + // + // IIR ISEF filter applied across rows + // + A[offset+j] = (b * A[offset-cols+j]) + (b1 * SourceImage[offset+j]); + } + offset += cols; + } + + // + // anti-causal component of IIR filter + // + offset = (rows-2)*cols; + for(i = rows-2; i >= 0; --i){ + for(j = 0; j < cols; ++j){ + // + // IIR ISEF filter applied across rows + // + B[offset+j] = (b * B[offset+cols+j]) + (b2 * SourceImage[offset+j]); + } + offset -= cols; + } + + offset = (rows-1)*cols; + for(j = 0; j < cols-1; ++j){ + FilterImage[offset+j] = A[offset+j]; + } + + // + // add causal and anti-causal IIR parts + // + offset = 0; + for(i = 1; i < rows-2; ++i){ + for(j = 0; j < cols-1; ++j){ + FilterImage[offset+j] = A[offset+j] + B[offset+cols+j]; + } + offset += cols; + } + + return; + +} + +void ISEF_Horizontal(float *SourceImage, float *FilterImage, float *A, float *B, int rows, int cols, double b){ + + + // + // source and smooth are the same in this pass of the 2D IIR + // + + int i, j; + int offset; + float b1, b2; + + b1 = ((float)1.0 - b)/((float)1.0 + b); + b2 = b * b1; + + // + // columns boundaries + // + offset = 0; + for(i = 0; i < rows; ++i){ + // col 0 + A[offset] = b1 * SourceImage[offset]; + // col N-1 + B[offset+cols-1] = b2 * SourceImage[offset+cols-1]; + } + + // + // causal IIR part + // + offset = 0; + for(j = 1; j < cols; ++j){ + for(i = 0; i < rows; ++i){ + A[offset+j] = (b * A[offset+j-1]) + (b1 * SourceImage[offset+j]); + } + offset += cols; + } + + // + // anti-causal IIR part + // + offset = 0; + for(j = cols-2; j > 0; --j){ + for(i = 0; i < rows; ++i){ + B[offset+j] = (b * B[offset+j+1]) + (b2 * SourceImage[offset+j]); + } + offset += cols; + } + + // + // filtered output. this is 2-pass IIR and pass 1 is vertical + // + offset = 0; + for(i = 0; i < rows; ++i){ + FilterImage[offset+cols-1] = A[offset+cols-1]; + } + + // + // add causal and anti-causal IIR parts + // + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols-1; ++j){ + FilterImage[offset+j] = A[offset+j] + B[offset+j+1]; + } + offset += cols; + } + + return; + +} + + +void computeISEF(float *SourceImage, float *FilterImage, int rows, int cols, double b){ + + int imageSize = rows*cols; + float *A; + float *B; + + A = calloc(imageSize, sizeof(float)); + B = calloc(imageSize, sizeof(float)); + + ISEF_Vertical(SourceImage, FilterImage, A, B, rows, cols, b); + ISEF_Horizontal(FilterImage, FilterImage, A, B, rows, cols, b); + + free(A); + free(B); + + return; + +} + +void Shen_Castan(double b, double ShenCastanLow, int rows, int cols, int window, int lowThreshold, int highThreshold, + double *RawImage, unsigned short *EdgeImage){ + + int i; + int imageSize = rows*cols; + float *FilterImage; + float *BinaryLaplacianImage; + float *SourceImage; + + FilterImage = calloc(imageSize, sizeof(float)); + BinaryLaplacianImage = calloc(imageSize, sizeof(float)); + SourceImage = calloc(imageSize, sizeof(float)); + + for(i = 0; i < imageSize; ++i){ + SourceImage[i] = RawImage[i]; + } + computeISEF(SourceImage, FilterImage, rows, cols, b); + // optional thresholding based on low, high + thresholdImage(SourceImage, FilterImage, rows, cols, lowThreshold, highThreshold); + computeBandedLaplacian(FilterImage, SourceImage, BinaryLaplacianImage, rows, cols); + // the new source image is now the adaptive gradient + getZeroCrossings(SourceImage, FilterImage, BinaryLaplacianImage, rows, cols, window); + thresholdEdges(SourceImage, EdgeImage, ShenCastanLow, rows, cols); + + free(FilterImage); + free(BinaryLaplacianImage); + free(SourceImage); + + return; + +} + +int NI_ShenCastanEdges(int samples, int rows, int cols, double b, double ShenCastanLow, int window, int lowThreshold, + int highThreshold, double *rawImage, unsigned short *edgeImage, int *groups){ + + + int i, j; + int offset; + int status = 0; + + Shen_Castan(b, ShenCastanLow, rows, cols, window, lowThreshold, highThreshold, rawImage, edgeImage); + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + status = *groups; + + return status; + +} + +void buildBinaryImage(int rows, int cols, double *rawImage, unsigned short *edgeImage, int lowThreshold, int highThreshold){ + + int i, j; + int offset; + double value; + int maskValue; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = rawImage[offset+j]; + maskValue = 1; + if(value < (double)lowThreshold) maskValue = 0; + if(value > (double)highThreshold) maskValue = 0; + edgeImage[offset+j] = maskValue; + } + offset += cols; + } + + return; + +} + + + +void morphoFilterBinaryImage(int rows, int cols, unsigned short *edgeImage, int CloseSize, int OpenSize){ + + + int i, j; + int offset, offset2; + unsigned short cmask[11][11]; + unsigned short omask[11][11]; + int olapValuesC[4]; + int olapValuesO[4]; + int CloseMaskSize; + int OpenMaskSize; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + int spadSize; + unsigned char *ImageE; + unsigned char *ImageC; + + spadSize = MAX(rows, cols); + + ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + + // + // Close filter + // + if(CloseSize){ + CloseMaskSize = (CloseSize-1)/2; + for(i = 0; i < 2*CloseMaskSize+1; ++i){ + for(j = 0; j < 2*CloseMaskSize+1; ++j){ + cmask[i][j] = 1; + } + } + LowValue1 = 0; + HighValue1 = 1; + LowValue2 = 1; + HighValue2 = 0; + olapValuesC[0] = LowValue1; + olapValuesC[1] = HighValue1; + olapValuesC[2] = LowValue2; + olapValuesC[3] = HighValue2; + } + + // + // Open filter + // + if(OpenSize){ + OpenMaskSize = (OpenSize-1)/2; + for(i = 0; i < 2*OpenMaskSize+1; ++i){ + for(j = 0; j < 2*OpenMaskSize+1; ++j){ + omask[i][j] = 1; + } + } + LowValue1 = 1; + HighValue1 = 0; + LowValue2 = 0; + HighValue2 = 1; + olapValuesO[0] = LowValue1; + olapValuesO[1] = HighValue1; + olapValuesO[2] = LowValue2; + olapValuesO[3] = HighValue2; + } + + offset = 0; + offset2 = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + ImageE[offset2+j] = (unsigned char)edgeImage[offset+j]; + } + offset2 += spadSize; + offset += cols; + } + + if(OpenSize){ + OpenCloseFilter(olapValuesO, OpenMaskSize, rows, cols, spadSize, ImageE, ImageC, omask); + } + + if(CloseSize){ + OpenCloseFilter(olapValuesC, CloseMaskSize, rows, cols, spadSize, ImageE, ImageC, cmask); + } + + offset = 0; + offset2 = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(ImageE[offset2+j] == 1){ + // this will activate some original off-pixels + edgeImage[offset+j] = 1; + } + else{ + // this will zero some original on-pixels + edgeImage[offset+j] = 0; + } + } + offset2 += spadSize; + offset += cols; + } + + free(ImageE); + free(ImageC); + + return; + +} + +void doRegionGrow(int samples, int rows, int cols, double *rawImage, unsigned short *edgeImage, int lowThreshold, + int highThreshold, int closeWindow, int openWindow){ + + buildBinaryImage(rows, cols, rawImage, edgeImage, lowThreshold, highThreshold); + morphoFilterBinaryImage(rows, cols, edgeImage, closeWindow, openWindow); + + return; + +} + +int NI_RegionGrow(int samples, int rows, int cols, int lowThreshold, int highThreshold, int closeWindow, + int openWindow, double *rawImage, unsigned short *edgeImage, int *groups){ + + int i, j; + int offset; + int status; + + doRegionGrow(samples, rows, cols, rawImage, edgeImage, lowThreshold, highThreshold, closeWindow, openWindow); + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + status = *groups; + return status; + +} + +int NI_SobelEdges(int samples, int rows, int cols, double sobelLow, int mode, int lowThreshold, int highThreshold, double BPHigh, + int apearture, double *rawImage, unsigned short *edgeImage, int *groups){ + + + int i, j; + int offset; + int status; + + doPreProcess(samples, rows, cols, rawImage, BPHigh, apearture, lowThreshold, highThreshold); + doSobel(samples, rows, cols, sobelLow, mode, rawImage, edgeImage); + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + status = *groups; + return status; + +} + +void initThinFilter(int J_mask[3][30], int K_mask[3][30]){ + + int i, j; + int Column; + + for(i = 0; i < 3; ++i){ + for(j = 0; j < 30; ++j){ + J_mask[i][j] = 0; + K_mask[i][j] = 0; + } + } + + Column = 0; + J_mask[0][Column+0] = 1; + J_mask[0][Column+1] = 1; + J_mask[0][Column+2] = 1; + J_mask[1][Column+1] = 1; + + Column += 3; + J_mask[0][Column+1] = 1; + J_mask[1][Column+1] = 1; + J_mask[1][Column+2] = 1; + + Column += 3; + J_mask[0][Column+0] = 1; + J_mask[1][Column+0] = 1; + J_mask[2][Column+0] = 1; + J_mask[1][Column+1] = 1; + + Column += 3; + J_mask[0][Column+1] = 1; + J_mask[1][Column+0] = 1; + J_mask[1][Column+1] = 1; + + Column += 3; + J_mask[0][Column+2] = 1; + J_mask[1][Column+1] = 1; + J_mask[1][Column+2] = 1; + J_mask[2][Column+2] = 1; + + Column += 3; + J_mask[1][Column+0] = 1; + J_mask[1][Column+1] = 1; + J_mask[2][Column+1] = 1; + + Column += 3; + J_mask[1][Column+1] = 1; + J_mask[2][Column+0] = 1; + J_mask[2][Column+1] = 1; + J_mask[2][Column+2] = 1; + + Column += 3; + J_mask[1][Column+1] = 1; + J_mask[1][Column+2] = 1; + J_mask[2][Column+1] = 1; + + Column = 0; + K_mask[2][Column+0] = 1; + K_mask[2][Column+1] = 1; + K_mask[2][Column+2] = 1; + + Column += 3; + K_mask[1][Column+0] = 1; + K_mask[2][Column+0] = 1; + K_mask[2][Column+1] = 1; + + Column += 3; + K_mask[0][Column+2] = 1; + K_mask[1][Column+2] = 1; + K_mask[2][Column+2] = 1; + + Column += 3; + K_mask[1][Column+2] = 1; + K_mask[2][Column+1] = 1; + K_mask[2][Column+2] = 1; + + Column += 3; + K_mask[0][Column+0] = 1; + K_mask[1][Column+0] = 1; + K_mask[2][Column+0] = 1; + + Column += 3; + K_mask[0][Column+1] = 1; + K_mask[0][Column+2] = 1; + K_mask[1][Column+2] = 1; + + Column += 3; + K_mask[0][Column+0] = 1; + K_mask[0][Column+1] = 1; + K_mask[0][Column+2] = 1; + + Column += 3; + K_mask[0][Column+0] = 1; + K_mask[0][Column+1] = 1; + K_mask[1][Column+0] = 1; + + return; + +} + +void ThinningFilter(int regRows, int regColumns, int spadSize, int J_mask[3][30], int K_mask[3][30], + unsigned char *Input, unsigned char *CInput, unsigned char *ErosionStage, + unsigned char *DialationStage, unsigned char *HMT, unsigned char *Copy){ + + int i, j, k, l, m, n, overlap, hit; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + int Column, T, nloop; + int Offset; + int N, M; + int j_mask[3][3]; + int k_mask[3][3]; + + N = regRows; + M = regColumns; + + LowValue1 = 1; + HighValue1 = 0; + + LowValue2 = 0; + HighValue2 = 1; + + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + Copy[Offset+j] = Input[Offset+j]; + } + Offset += spadSize; + } + + nloop = 0; + while(1){ + // erode + Column = 0; + for(n = 0; n < 8; ++n){ + for(i = 0; i < 3; ++i){ + for(j = 0; j < 3; ++j){ + j_mask[i][j] = J_mask[i][Column+j]; + } + } + for(i = 0; i < 3; ++i){ + for(j = 0; j < 3; ++j){ + k_mask[i][j] = K_mask[i][Column+j]; + } + } + Column += 3; + + Offset = spadSize; + for(i = 1; i < N-1; ++i){ + for(j = 1; j < M-1; ++j){ + hit = LowValue1; + for(k = -1; k < 2; ++k){ + for(l = -1; l < 2; ++l){ + T = j_mask[k+1][l+1]; + if(T == 1){ + overlap = T*Input[Offset+(k*spadSize)+j+l]; + if(overlap == HighValue1) hit = HighValue1; + } + } + } + ErosionStage[Offset+j] = hit; + } + Offset += spadSize; + } + + // dialate + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + CInput[Offset+j] = (~Input[Offset+j]) & 0x1; + } + Offset += spadSize; + } + + Offset = spadSize; + for(i = 1; i < N-1; ++i){ + for(j = 1; j < M-1; ++j){ + hit = LowValue1; + for(k = -1; k < 2; ++k){ + for(l = -1; l < 2; ++l){ + T = k_mask[k+1][l+1]; + if(T == 1){ + overlap = T*CInput[Offset+(k*spadSize)+j+l]; + if(overlap == HighValue1) hit = HighValue1; + } + } + } + DialationStage[Offset+j] = hit; + } + Offset += spadSize; + } + + // form the HMT + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + m = (ErosionStage[Offset+j]*DialationStage[Offset+j]); + HMT[Offset+j] = m; + } + Offset += spadSize; + } + + // Thin for stage n + + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + HMT[Offset+j] = (~HMT[Offset+j]) & 0x1; + } + Offset += spadSize; + } + + Offset = 0; + for (i = 0; i < N; ++i){ + for (j = 0; j < M; ++j){ + m = (Input[Offset+j]*HMT[Offset+j]); + Input[Offset+j] = m; + } + Offset += spadSize; + } + } + + // check for the NULL set + hit = 0; + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + hit += abs(Copy[Offset+j]-Input[Offset+j]); + } + Offset += spadSize; + } + if(!hit) break; + + hit = 0; + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + Copy[Offset+j] = Input[Offset+j]; + if(Input[Offset+j]) ++hit; + } + Offset += spadSize; + } + ++nloop; + } + + + return; + +} + + +int NI_ThinFilter(int samples, int rows, int cols, int numberObjects, unsigned short *edgeImage, objStruct objectMetrics[]){ + + int i, j; + int loop; + int label; + int left, right, top, bottom; + int roiRows, roiCols; + int srcOffset; + int dstOffset; + int status; + int inflate = 1; + int J_mask[3][30]; + int K_mask[3][30]; + + unsigned char *Input; + unsigned char *CInput; + unsigned char *ErosionStage; + unsigned char *DialationStage; + unsigned char *HMT; + unsigned char *Copy; + unsigned short *thinEdgeImage; + + // + // scratch pad (spad) memory + // + Input = calloc(samples, sizeof(unsigned char)); + CInput = calloc(samples, sizeof(unsigned char)); + ErosionStage = calloc(samples, sizeof(unsigned char)); + DialationStage = calloc(samples, sizeof(unsigned char)); + HMT = calloc(samples, sizeof(unsigned char)); + Copy = calloc(samples, sizeof(unsigned char)); + thinEdgeImage = calloc(samples, sizeof(unsigned short)); + + initThinFilter(J_mask, K_mask); + for(loop = 0; loop < numberObjects; ++loop){ + label = objectMetrics[loop].Label; + left = objectMetrics[loop].L; + right = objectMetrics[loop].R; + top = objectMetrics[loop].T; + bottom = objectMetrics[loop].B; + roiRows = top-bottom+2*inflate; + roiCols = right-left+2*inflate; + + // + // clear the scratch pad + // + srcOffset = 0; + for(i = 0; i < roiRows; ++i){ + for(j = 0; j < roiCols; ++j){ + Input[srcOffset+j] = 0; + } + srcOffset += cols; + } + + // + // copy the ROI for MAT (medial axis transformation) filter + // + dstOffset = inflate*rows; + for(i = bottom; i < top; ++i){ + srcOffset = i*cols; + for(j = left; j < right; ++j){ + if(edgeImage[srcOffset+j] == label){ + Input[dstOffset+j-left+inflate] = 1; + } + } + dstOffset += cols; + } + ThinningFilter(roiRows, roiCols, cols, J_mask, K_mask, Input, CInput, ErosionStage, DialationStage, HMT, Copy); + + // + // copy the MAT roi to the new edgeImage (clip the inflate border) + // + dstOffset = inflate*rows; + for(i = bottom; i < top; ++i){ + srcOffset = i*cols; + for(j = left; j < right; ++j){ + if(Input[dstOffset+j-left+inflate]){ + thinEdgeImage[srcOffset+j] = label; + } + } + dstOffset += cols; + } + } + + // + // copy the MAT edges and return the thinned edges + // this will prune the isolated edge points from the edgeImage source + // + for(i = 0; i < rows*cols; ++i){ + edgeImage[i] = thinEdgeImage[i]; + } + + free(Input); + free(CInput); + free(ErosionStage); + free(DialationStage); + free(HMT); + free(Copy); + free(thinEdgeImage); + + status = 1; + + return status; + +} + + +void generateMask(unsigned char *ImageH, bPOINT *boundary, int newSamples, int label, int cols){ + + // + // get the boundary point pairs (left, right) for each line + // if there is no pair, then the boundary is open + // then fill the image in with the current label + // + + int i, j, k, m; + int list[512]; + int distance; + int neighbor = 4; + int index; + int offset; + int maxDistance = 1024; + int x, y; + int low, high; + + for(i = 0; i < newSamples; ++i){ + boundary[i].haveLink = FALSE; + boundary[i].linkIndex = -1; + } + + for(i = 0; i < newSamples; ++i){ + if(!boundary[i].haveLink){ + boundary[i].haveLink = TRUE; + x = boundary[i].x; + y = boundary[i].y; + for(k = 0, j = 0; j < newSamples; ++j){ + if((j != i)){ + if(boundary[j].y == y){ + list[k] = j; + ++k; + } + } + } + // now get the closest boundary + if(k){ + distance = maxDistance; + index = -1; + for(j = 0; j < k; ++j){ + m = abs(x - boundary[list[j]].x); + if((m < distance) && (m > neighbor)){ + distance = m; + index = list[j]; + } + else if(m <= neighbor){ + boundary[list[j]].haveLink = TRUE; + } + } + if(index != -1){ + boundary[i].linkIndex = index; + boundary[index].linkIndex = i; + boundary[index].haveLink = TRUE; + if(boundary[i].x < boundary[index].x){ + low = boundary[i].x; + high = boundary[index].x; + } + else{ + low = boundary[index].x; + high = boundary[i].x; + } + // + // do the fill + // + offset = y * cols; + for(j = low; j <= high; ++j){ + ImageH[offset+j] = label; + } + } + } + else{ + // boundary point is isolated + boundary[i].linkIndex = i; + } + } + } + + return; + +} + +void getBoundaryMetrics(bPOINT *boundary, float *length, float *minRadius, float *maxRadius, float *aveRadius, + float Xcenter, float Ycenter, int newSamples){ + + int j; + float dX, dY; + float distance; + + if(newSamples < 2){ + *length = (float)0.0; + *minRadius = (float)0.0; + *maxRadius = (float)0.0; + *aveRadius = (float)0.0; + return; + } + + *length = (float)0.0; + for(j = 1; j < newSamples; ++j){ + dX = (float)(boundary[j].x - boundary[j-1].x); + dY = (float)(boundary[j].y - boundary[j-1].y); + distance = (float)sqrt(dX*dX + dY*dY); + *length += distance; + } + + *minRadius = (float)10000.0; + *maxRadius = (float)-10000.0; + *aveRadius = (float)0.0; + for(j = 0; j < newSamples; ++j){ + dX = (float)(boundary[j].x - Xcenter); + dY = (float)(boundary[j].y - Ycenter); + distance = (float)sqrt(dX*dX + dY*dY); + *aveRadius += distance; + if(distance < *minRadius) *minRadius = distance; + if(distance > *maxRadius) *maxRadius = distance; + } + + if(newSamples){ + *aveRadius /= (float)newSamples; + } + + return; + +} + +void trackBoundary(unsigned char *Input, blobBoundary lBoundary[], int mcount, int spadSize, + blobBoundary seedValue, int searchWindow){ + + + int i, j, k, m, p; + int offset; + int CurI; + int CurJ; + int StrI; + int StrJ; + int NewI; + int NewJ; + int MinD; + int inflate = searchWindow; + + CurI = seedValue.xy.x; + CurJ = seedValue.xy.y; + StrI = CurI; + StrJ = CurJ; + + p = 0; + lBoundary[p].xy.x = StrI; + lBoundary[p].xy.y = StrJ; + offset = StrI * spadSize; + + p = 1; + while(p <= mcount){ + offset = (CurI-inflate)*spadSize; + MinD = 1024; + NewI = 0; + NewJ = 0; + for(i = CurI-inflate; i < CurI+inflate; ++i){ + for(j = CurJ-inflate; j < CurJ+inflate; ++j){ + m = Input[offset+j]; + if(m == 1){ + // city block distance + k = abs(i-CurI) + abs(j-CurJ); + if(k < MinD){ + MinD = k; + NewI = i; + NewJ = j; + } + } + } + offset += spadSize; + } + CurI = NewI; + CurJ = NewJ; + offset = CurI * spadSize; + Input[offset+CurJ] = 0; + lBoundary[p].xy.x = CurJ; + lBoundary[p].xy.y = CurI; + ++p; + } + + return; + +} + + +void OpenCloseFilter(int olapValues[], int maskSize, int rows, int columns, int spadSize, + unsigned char *input, unsigned char *output, unsigned short mask[11][11]){ + + + // + // do morphological open/close image filtering. the olapValues array determines + // if the filter is Open or Close. + // + int i, j, k, l, m, overlap, hit; + int offset; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + + LowValue1 = olapValues[0]; + HighValue1 = olapValues[1]; + LowValue2 = olapValues[2]; + HighValue2 = olapValues[3]; + + // close - step 1 is dialate + // open - step 1 is erode + offset = maskSize*spadSize; + for(i = maskSize; i < rows-maskSize; ++i){ + for(j = maskSize; j < columns-maskSize; ++j){ + hit = LowValue1; + for(k = -maskSize; k < maskSize; ++k){ + m = k*spadSize; + for(l = -maskSize; l < maskSize; ++l){ + overlap = mask[k+maskSize][l+maskSize]*input[offset+m+j+l]; + if(overlap == HighValue1){ + hit = HighValue1; + } + } + } + output[offset+j] = hit; + } + offset += spadSize; + } + + // close - step 2 is erode + // open - step 2 is dialate + offset = maskSize*spadSize; + for(i = maskSize; i < rows-maskSize; ++i){ + for(j = maskSize; j < columns-maskSize; ++j){ + hit = LowValue2; + for(k = -maskSize; k < maskSize; ++k){ + m = k*spadSize; + for(l = -maskSize; l < maskSize; ++l){ + overlap = mask[k+maskSize][l+maskSize]*output[offset+m+j+l]; + if(overlap == HighValue2){ + hit = HighValue2; + } + } + } + input[offset+j] = hit; + } + offset += spadSize; + } + + return; +} + +void getCompactness(unsigned char *Input, RECT roi, int label, int spadSize, float *vCompactness, float length){ + + int i, j; + int maskOffset; + int area; + static float fpi = (float)(4.0 * 3.14159); + + area = 0; + for(i = roi.bottom; i < roi.top; ++i){ + maskOffset = i*spadSize; + for(j = roi.left; j < roi.right; ++j){ + if(Input[maskOffset+j] == label){ + ++area; + } + } + } + if(area && (length != (float)0.0)){ + *vCompactness = (fpi * (float)area) / (length*length); + } + else{ + *vCompactness = (float)0.0; + } + + return; +} + + +void doMorphology(unsigned char *Input, unsigned char *ImageE, unsigned char *ImageC, unsigned char *ImageH, + int olapValuesC[],int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], + RECT roi, int label, int CloseMaskSize, int OpenMaskSize, int spadSize){ + + int i, j; + int rows, cols; + int srcOffset; + int dstOffset; + int maskSize; + + cols = roi.right - roi.left; + rows = roi.top - roi.bottom; + + for(i = 0; i < spadSize*spadSize; ++i){ + ImageE[i] = 0; + ImageC[i] = 0; + } + + // + // put the ROI in the ImageE array centered in ULC + // + dstOffset = 0; + for(i = roi.bottom; i < roi.top; ++i){ + srcOffset = i*spadSize; + for(j = roi.left; j < roi.right; ++j){ + if(ImageH[srcOffset+j] == label){ + ImageE[dstOffset+j-roi.left] = 1; + } + } + dstOffset += spadSize; + } + + // + // open + // + maskSize = OpenMaskSize; + OpenCloseFilter(olapValuesO, maskSize, rows, cols, spadSize, ImageE, ImageC, omask); + // + // close + // + maskSize = CloseMaskSize; + OpenCloseFilter(olapValuesC, maskSize, rows, cols, spadSize, ImageE, ImageC, cmask); + + // + // put the closed ROI (in ImageE) back in its roi space + // + + srcOffset = 0; + for(i = roi.bottom; i < roi.top+2*maskSize+1; ++i){ + dstOffset = (i-(2*maskSize+1))*spadSize; + for(j = roi.left-maskSize-1; j < roi.right+maskSize+1; ++j){ + if(ImageE[srcOffset+j-roi.left] == 1){ + Input[dstOffset+j-maskSize+1] = label; + } + } + srcOffset += spadSize; + } + + return; + +} + + +void getBoundary(unsigned short *ThinEdgeImage, unsigned char *Input, blobBoundary *pBoundary, blobBoundary *lBoundary, + boundaryIndex *pBoundaryIndex, RECT boundBox, int label, int bBox, int nextSlot, int memOffset, + int spadSize, int searchWindow){ + + int i, j; + int dstOffset; + int srcOffset; + int mcount; + int rows; + int columns; + bool first; + blobBoundary value; + int inflate = 1; + int count; + + pBoundaryIndex[bBox+1].rectangle.left = boundBox.left; + pBoundaryIndex[bBox+1].rectangle.right = boundBox.right; + pBoundaryIndex[bBox+1].rectangle.top = boundBox.top; + pBoundaryIndex[bBox+1].rectangle.bottom = boundBox.bottom; + + for(i = 0; i < spadSize*spadSize; ++i){ + Input[i] = 0; + } + + // copy to spad + count = 0; + rows = boundBox.top-boundBox.bottom+2*inflate; + columns = boundBox.right-boundBox.left+2*inflate; + dstOffset = inflate*spadSize; + for(i = boundBox.bottom; i < boundBox.top; ++i){ + srcOffset = i*spadSize; + for(j = boundBox.left; j < boundBox.right; ++j){ + if(ThinEdgeImage[srcOffset+j] == label){ + Input[dstOffset+j-boundBox.left+inflate] = 1; + ++count; + } + } + dstOffset += spadSize; + } + + mcount = 0; + first = TRUE; + srcOffset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < columns; ++j){ + if(Input[srcOffset+j]){ + if(first){ + first = FALSE; + // index of the seed sample + value.xy.x = i; + value.xy.y = j; + } + ++mcount; + } + } + srcOffset += spadSize; + } + + trackBoundary(Input, lBoundary, mcount, spadSize, value, searchWindow); + + pBoundaryIndex[nextSlot].numberPoints = mcount; + for(i = 0; i < mcount; ++i){ + value.xy.x = lBoundary[i].xy.x + boundBox.left - inflate; + value.xy.y = lBoundary[i].xy.y + boundBox.bottom - inflate + 1; + pBoundary[memOffset].xy.x = value.xy.x; + pBoundary[memOffset].xy.y = value.xy.y; + ++memOffset; + } + + return; + +} + + +void buildBoundary(objStruct objectMetrics[], int searchWindow, unsigned short *ThinEdgeImage, + int numberObjects, int srcRows, int srcCols){ + + + int i, j, k; + int count; + int numBoundaries; + int numSamples; + int offset; + int offset2; + int end; + int label; + int distance; + // these should be setup parameters + int closureDistance = 12; + int CloseSize = 5; + int OpenSize = 5; + int threshold = 3; + int newSamples; + int spadSize; + POINT rectPoint[4]; + int in[4]; + float length; + float minRadius; + float maxRadius; + float aveRadius; + float vCompactness; + // for morphological close of mask. max structuring element is 11x11 + unsigned short cmask[11][11]; + unsigned short omask[11][11]; + int olapValuesC[4]; + int olapValuesO[4]; + int CloseMaskSize; + int OpenMaskSize; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + + // + // Close filter + // + CloseMaskSize = (CloseSize-1)/2; + for(i = 0; i < 2*CloseMaskSize+1; ++i){ + for(j = 0; j < 2*CloseMaskSize+1; ++j){ + cmask[i][j] = 1; + } + } + LowValue1 = 0; + HighValue1 = 1; + LowValue2 = 1; + HighValue2 = 0; + olapValuesC[0] = LowValue1; + olapValuesC[1] = HighValue1; + olapValuesC[2] = LowValue2; + olapValuesC[3] = HighValue2; + + // + // Open filter + // + OpenMaskSize = (OpenSize-1)/2; + for(i = 0; i < 2*OpenMaskSize+1; ++i){ + for(j = 0; j < 2*OpenMaskSize+1; ++j){ + omask[i][j] = 1; + } + } + LowValue1 = 1; + HighValue1 = 0; + LowValue2 = 0; + HighValue2 = 1; + olapValuesO[0] = LowValue1; + olapValuesO[1] = HighValue1; + olapValuesO[2] = LowValue2; + olapValuesO[3] = HighValue2; + + RECT bBox; + boundaryIndex *pBoundaryIndex; + blobBoundary *pBoundary; + blobBoundary *lBoundary; + bPOINT *boundary; + unsigned char *Input; + unsigned char *ImageE; + unsigned char *ImageC; + unsigned char *ImageH; + + spadSize = MAX(srcRows, srcCols); + pBoundaryIndex = calloc(srcRows+srcCols, sizeof(boundaryIndex)); + Input = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageH = calloc(spadSize*spadSize, sizeof(unsigned char)); + pBoundary = calloc(srcRows*srcCols, sizeof(blobBoundary)); + lBoundary = calloc(32767, sizeof(blobBoundary)); + boundary = calloc(32767, sizeof(POINT)); + + for(i = 0; i < (srcRows+srcCols); ++i){ + pBoundaryIndex[i].numberPoints = 0; + pBoundaryIndex[i].curveClose = 0; + pBoundaryIndex[i].isWithin = FALSE; + pBoundaryIndex[i].criticalSize = FALSE; + pBoundaryIndex[i].closedCurve = FALSE; + } + + for(i = 0; i < numberObjects; ++i){ + ++pBoundaryIndex[0].numberPoints; + count = 0; + j = 1; + while(pBoundaryIndex[j].numberPoints){ + count += pBoundaryIndex[j++].numberPoints; + } + bBox.left = objectMetrics[i].L; + bBox.right = objectMetrics[i].R; + bBox.top = objectMetrics[i].T; + bBox.bottom = objectMetrics[i].B; + label = objectMetrics[i].Label; + pBoundaryIndex[i+1].Label = label; + getBoundary(ThinEdgeImage, Input, pBoundary, lBoundary, pBoundaryIndex, bBox, label, + i, pBoundaryIndex[0].numberPoints, count, spadSize, searchWindow); + } + + // + // Input will now be used in the fill. Copy the labeled edge image + // + + // + // numBoundaries = numberObjects + // + offset = 0; + numBoundaries = pBoundaryIndex[0].numberPoints; + for(i = 0; i < numBoundaries; ++i){ + numSamples = pBoundaryIndex[i+1].numberPoints; + end = numSamples-2; + newSamples = numSamples-1; + for(j = 0; j < numSamples; ++j){ + boundary[j].x = pBoundary[offset+j+1].xy.x; + boundary[j].y = pBoundary[offset+j+1].xy.y; + } + + // + // clip off the ends where stray boundary pixels were left over + // + while(1){ + distance = abs(boundary[end].x-boundary[end-1].x) + abs(boundary[end].y-boundary[end-1].y); + if(distance > threshold){ + --end; + --newSamples; + } + else{ + break; + } + } + + distance = abs(boundary[0].x-boundary[end-2].x) + abs(boundary[0].y-boundary[end-2].y); + pBoundaryIndex[i+1].curveClose = distance; + + if(pBoundaryIndex[i+1].curveClose < closureDistance){ + pBoundaryIndex[i+1].closedCurve = TRUE; + } + pBoundaryIndex[i+1].centroid.x = 0; + pBoundaryIndex[i+1].centroid.y = 0; + for(j = 0; j < newSamples; ++j){ + pBoundaryIndex[i+1].centroid.x += boundary[j].x; + pBoundaryIndex[i+1].centroid.y += boundary[j].y; + } + if(newSamples){ + pBoundaryIndex[i+1].centroid.x /= newSamples; + pBoundaryIndex[i+1].centroid.y /= newSamples; + } + getBoundaryMetrics(boundary, &length, &minRadius, &maxRadius, &aveRadius, + (float)pBoundaryIndex[i+1].centroid.x, (float)pBoundaryIndex[i+1].centroid.y, newSamples); + pBoundaryIndex[i+1].boundaryLength = length; + pBoundaryIndex[i+1].minRadius = minRadius; + pBoundaryIndex[i+1].maxRadius = maxRadius; + pBoundaryIndex[i+1].aveRadius = aveRadius; + if(minRadius != 0.0){ + pBoundaryIndex[i+1].ratio = maxRadius / minRadius; + } + else{ + pBoundaryIndex[i+1].ratio = -1.0; + } + + // + // augment the ROI boundary + // + pBoundaryIndex[i+1].rectangle.left -= 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.right += 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.bottom -= 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.top += 2*CloseMaskSize; + label = pBoundaryIndex[i+1].Label; + + // + // mask goes in ImageH. morpho filter the mask first + // + generateMask(ImageH, boundary, newSamples, label, spadSize); + + // + // open-close the mask + // + doMorphology(Input, ImageE, ImageC, ImageH, olapValuesC, olapValuesO, cmask, omask, + pBoundaryIndex[i+1].rectangle, label, CloseMaskSize, OpenMaskSize, spadSize); + + // + // now get the compactness metrics + // + getCompactness(Input, pBoundaryIndex[i+1].rectangle, label, spadSize, &vCompactness, length); + pBoundaryIndex[i+1].compactness = vCompactness; + + // + // reset the ROI boundary + // + pBoundaryIndex[i+1].rectangle.left += 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.right -= 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.bottom += 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.top -= 2*CloseMaskSize; + offset += numSamples; + } + + + for(i = 0; i < numBoundaries; ++i){ + for(j = 0; j < numBoundaries; ++j){ + if(j != i){ + rectPoint[0].x = pBoundaryIndex[j+1].rectangle.left; + rectPoint[0].y = pBoundaryIndex[j+1].rectangle.bottom; + rectPoint[1].x = pBoundaryIndex[j+1].rectangle.left; + rectPoint[1].y = pBoundaryIndex[j+1].rectangle.top; + rectPoint[2].x = pBoundaryIndex[j+1].rectangle.right; + rectPoint[2].y = pBoundaryIndex[j+1].rectangle.bottom; + rectPoint[3].x = pBoundaryIndex[j+1].rectangle.right; + rectPoint[3].y = pBoundaryIndex[j+1].rectangle.top; + in[0] = 0; + in[1] = 0; + in[2] = 0; + in[3] = 0; + for(k = 0; k < 4; ++k){ + if((rectPoint[k].x > pBoundaryIndex[i+1].rectangle.left) && + (rectPoint[k].x < pBoundaryIndex[i+1].rectangle.right)){ + if((rectPoint[k].y > pBoundaryIndex[i+1].rectangle.bottom) && + (rectPoint[k].y < pBoundaryIndex[i+1].rectangle.top)){ + in[k] = 1; + } + } + } + if(in[0] && in[1] && in[2] && in[3]){ + pBoundaryIndex[j+1].isWithin = TRUE; + } + } + } + } + + // + // fill in the Python features + // + for(i = 0; i < numBoundaries; ++i){ + objectMetrics[i].curveClose = pBoundaryIndex[i+1].curveClose; + objectMetrics[i].cXBoundary = pBoundaryIndex[i+1].centroid.x; + objectMetrics[i].cYBoundary = pBoundaryIndex[i+1].centroid.y; + objectMetrics[i].boundaryLength = pBoundaryIndex[i+1].boundaryLength; + objectMetrics[i].minRadius = pBoundaryIndex[i+1].minRadius; + objectMetrics[i].maxRadius = pBoundaryIndex[i+1].maxRadius; + objectMetrics[i].aveRadius = pBoundaryIndex[i+1].aveRadius; + objectMetrics[i].ratio = pBoundaryIndex[i+1].ratio; + objectMetrics[i].compactness = pBoundaryIndex[i+1].compactness; + } + + // debug only + if(0){ + for(i = 0; i < numBoundaries; ++i){ + if(pBoundaryIndex[i+1].boundaryLength != (float)0.0){ + printf("boundary %d:\n", i); + printf("\t\tRect (%d, %d, %d, %d)\n", pBoundaryIndex[i+1].rectangle.left, + pBoundaryIndex[i+1].rectangle.right, + pBoundaryIndex[i+1].rectangle.top, + pBoundaryIndex[i+1].rectangle.bottom); + printf("\t\tCentroid (%d, %d)\n", pBoundaryIndex[i+1].centroid.x, pBoundaryIndex[i+1].centroid.y); + printf("\t\tLength (%f)\n", pBoundaryIndex[i+1].boundaryLength); + printf("\t\tRatio (%f)\n", pBoundaryIndex[i+1].ratio); + printf("\t\taveRadius (%f)\n", pBoundaryIndex[i+1].aveRadius); + printf("\t\tLabel (%d)\n", pBoundaryIndex[i+1].Label); + printf("\t\tCompactness (%f)\n", pBoundaryIndex[i+1].compactness); + printf("\t\tCurveClose (%d)\n", pBoundaryIndex[i+1].curveClose); + if(pBoundaryIndex[i+1].isWithin){ + printf("\t\tContained (T)\n"); + } + else{ + printf("\t\tContained (F)\n"); + } + if(pBoundaryIndex[i+1].closedCurve){ + printf("\t\tclosedCurve (T)\n"); + } + else{ + printf("\t\tclosedCurve (F)\n"); + } + } + } + } + + // + // need to return input which is now mask image + // + offset = 0; + offset2 = 0; + for(i = 0; i < srcRows; ++i){ + for(j = 0; j < srcCols; ++j){ + ThinEdgeImage[offset+j] = (unsigned short)Input[offset2+j]; + } + offset += srcCols; + offset2 += spadSize; + } + + free(pBoundaryIndex); + free(Input); + free(ImageE); + free(ImageC); + free(ImageH); + free(pBoundary); + free(lBoundary); + free(boundary); + + return; + +} + + +void initLaws(LawsFilter7 *lawsFilter){ + + int i; + float sum; + float L7[7] = { 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0}; + float E7[7] = {-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0}; + float S7[7] = {-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0}; + float W7[7] = {-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0}; + float R7[7] = { 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0}; + float O7[7] = {-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0}; + + lawsFilter->numberKernels = 6; + lawsFilter->kernelLength = 7; + lawsFilter->numberFilterLayers = 21; + lawsFilter->name[0] = 'L'; + lawsFilter->name[1] = 'E'; + lawsFilter->name[2] = 'S'; + lawsFilter->name[3] = 'W'; + lawsFilter->name[4] = 'R'; + lawsFilter->name[5] = 'O'; + for(i = 0; i < 7; ++i){ + lawsFilter->lawsKernel[0][i] = L7[i]; + lawsFilter->lawsKernel[1][i] = E7[i]; + lawsFilter->lawsKernel[2][i] = S7[i]; + lawsFilter->lawsKernel[3][i] = W7[i]; + lawsFilter->lawsKernel[4][i] = R7[i]; + lawsFilter->lawsKernel[5][i] = O7[i]; + } + + // DC filter is unity gain + sum = (float)0.0; + for(i = 0; i < 7; ++i){ + sum += lawsFilter->lawsKernel[0][i]; + } + for(i = 0; i < 7; ++i){ + lawsFilter->lawsKernel[0][i] /= sum; + } + + return; + +} + +float lawsConvolution(float *image, float *rowFilter, float *colFilter, int kernelSize){ + + int i, j; + int offset; + float result[7]; + float sum; + + // filter rows + for(i = 0; i < kernelSize; ++i){ + sum = (float)0.0; + offset = i * kernelSize; + for(j = 0; j < kernelSize; ++j){ + sum += (rowFilter[j]*image[offset+j]); + } + result[i] = sum; + } + + // filter columns + sum = (float)0.0; + for(j = 0; j < kernelSize; ++j){ + sum += (rowFilter[j]*result[j]); + } + + return(sum); + +} + + +void getLawsTexture(LawsFilter7 lawsFilter, tTEM LawsFeatures[], objStruct objectMetrics[], double *sourceImage, + unsigned short *MaskImage, int numberObjects, int srcRows, int srcCols){ + + int i, j; + int label; + RECT bBox; + int aperature = (lawsFilter.kernelLength-1)/2; + unsigned char *ImageH; + float *ImageT; + float *lawsImage; + + /* + // TO DO. return all 21 filter slices from a user selected blob + int debugBlob = 8; + int index; + int offset; + int layerStep = srcRows*srcCols; + */ + + ImageH = calloc(srcRows*srcCols, sizeof(unsigned char)); + ImageT = calloc(srcRows*srcCols, sizeof(float)); + lawsImage = calloc(lawsFilter.numberFilterLayers*srcRows*srcCols, sizeof(float)); + + for(i = 0; i < numberObjects; ++i){ + bBox.left = objectMetrics[i].L; + bBox.right = objectMetrics[i].R; + bBox.top = objectMetrics[i].T; + bBox.bottom = objectMetrics[i].B; + label = objectMetrics[i].Label; + if(objectMetrics[i].voxelMean != (float)0.0){ + // + // valid size region + // + computeLaws(lawsFilter, LawsFeatures, bBox, label, aperature, srcRows, srcCols, ImageH, ImageT, + MaskImage, lawsImage, sourceImage); + for(j = 1; j < lawsFilter.numberFilterLayers; ++j){ + objectMetrics[i].TEM[j-1] = LawsFeatures[j].Variance; + } + /* + if(label == debugBlob){ + index = 0; + for(j = 1; j < lawsFilter.numberFilterLayers; ++j){ + if(LawsFeatures[j].Variance == (float)1.0) index = j; + } + // overwrite the raw image with the texture filter that has the largest variance + offset = index * layerStep; + for(j = 0; j < layerStep; ++j){ + sourceImage[j] = lawsImage[offset+j]; + } + } + */ + } + } + + free(ImageH); + free(ImageT); + free(lawsImage); + + return; + +} + +void computeLaws(LawsFilter7 lawsFilter, tTEM LawsFeatures[], RECT roi, int label, int aperature, int srcRows, int srcCols, + unsigned char *ImageH, float *ImageT, unsigned short *MaskImage, float *lawsImage, double *sourceImage){ + + // + // hard-wirred to Law's 7 kernels + // + int i, j, k; + int lawsLayer; + int column, row; + int offset; + int maskOffset[7]; + int dataOffset[7]; + float myImage[49]; + int count; + int outerKernelNumber; + int innerKernelNumber; + int rowNumber; + int kernelSize = lawsFilter.kernelLength; + int fullMask = kernelSize*kernelSize; + int layerStep = srcRows*srcCols; + float *rowFilter; + float *colFilter; + float filterResult1; + float filterResult2; + float lawsLL; + float t; + float maxValue; + float scale; + char I, J; + char combo[24]; + char dual[24]; + + + // zero the laws mask memory first + for(i = 0; i < srcRows*srcCols; ++i){ + ImageH[i] = 0; + } + for(j = 0; j < lawsFilter.numberFilterLayers; ++j){ + LawsFeatures[j].Mean = (float)0.0; + LawsFeatures[j].Variance = (float)0.0; + } + + for(i = roi.bottom+aperature; i < roi.top-aperature; ++i){ + // get the row array offset for mask and data source. + for(row = -aperature; row <= aperature; ++row){ + maskOffset[row+aperature] = (i+row)*srcCols; + dataOffset[row+aperature] = maskOffset[row+aperature]; + } + for(j = roi.left+aperature; j < roi.right-aperature; ++j){ + // + // get 7x7 segment and make sure have 100% mask coverage + // + count = 0; + for(row = -aperature; row <= aperature; ++row){ + rowNumber = (row+aperature)*kernelSize; + for(column = -aperature; column <= aperature; ++column){ + if(MaskImage[maskOffset[row+aperature]+j+column] == label){ + myImage[rowNumber+column+aperature] = sourceImage[dataOffset[row+aperature]+j+column]; + ++count; + } + } + } + if(count == fullMask){ + // + // full mask. 100% coverage. now do the Law's texture filters + // + ImageH[i*srcCols+j] = 1; + lawsLayer = 0; + for(outerKernelNumber = 0; outerKernelNumber < lawsFilter.numberKernels; ++outerKernelNumber){ + // + // outer loop pulls the i'th kernel. kernel 0 is the LP kernel + // the outer loop is the iso-kernel + // + I = lawsFilter.name[outerKernelNumber]; + sprintf(dual, "%c_%c", I, I); + rowFilter = &lawsFilter.lawsKernel[outerKernelNumber][0]; + colFilter = &lawsFilter.lawsKernel[outerKernelNumber][0]; + filterResult1 = lawsConvolution(myImage, rowFilter, colFilter, kernelSize); + // lawsLayer 0 is the LP and needs to be used to scale. + if(outerKernelNumber){ + lawsImage[lawsLayer*layerStep + i*srcCols + j] = (float)2.0 * filterResult1 / lawsLL; + } + else{ + lawsLL = (float)2.0 * filterResult1; + lawsImage[lawsLayer*layerStep + i*srcCols + j] = (float)2.0 * filterResult1; + } + strcpy(&LawsFeatures[lawsLayer].filterName[0], dual); + ++lawsLayer; + // + // now do the inner loop and get the column filters for the other laws kernels + // + for(innerKernelNumber = outerKernelNumber+1; innerKernelNumber < lawsFilter.numberKernels; ++innerKernelNumber){ + J = lawsFilter.name[innerKernelNumber]; + sprintf(combo, "%c_%c", I, J); + strcpy(&LawsFeatures[lawsLayer].filterName[0], combo); + colFilter = &lawsFilter.lawsKernel[innerKernelNumber][0]; + filterResult1 = lawsConvolution(myImage, rowFilter, colFilter, kernelSize); + filterResult2 = lawsConvolution(myImage, colFilter, rowFilter, kernelSize); + lawsImage[lawsLayer*layerStep + i*srcCols + j] = (filterResult1 / lawsLL) + (filterResult2 / lawsLL); + ++lawsLayer; + } + } + } + } + } + + for(i = 0; i < lawsFilter.numberFilterLayers; ++i){ + LawsFeatures[i].Mean = (float)0.0; + LawsFeatures[i].Variance = (float)0.0; + } + + count = 0; + for(i = roi.bottom+aperature; i < roi.top-aperature; ++i){ + row = i * srcCols; + for(j = roi.left+aperature; j < roi.right-aperature; ++j){ + if(ImageH[row+j]){ + ++count; + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + offset = k * layerStep + row; + LawsFeatures[k].Mean += lawsImage[offset+j]; + } + } + } + } + + if(count == 0){ + //printf("no samples for texture\n"); + return; + } + + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + LawsFeatures[k].Mean /= (float)count; + } + for(i = roi.bottom+aperature; i < roi.top-aperature; ++i){ + row = i * srcCols; + for(j = roi.left+aperature; j < roi.right-aperature; ++j){ + if(ImageH[row+j]){ + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + offset = k * layerStep + row; + t = lawsImage[offset+j] - LawsFeatures[k].Mean; + LawsFeatures[k].Variance += (t * t); + } + } + } + } + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + LawsFeatures[k].Variance /= (float)count; + LawsFeatures[k].Variance = (float)(sqrt(LawsFeatures[k].Variance)); + } + + // + // now normalize the variance feature (TEM) + // + maxValue = (float)0.0; + for(i = 1; i < lawsFilter.numberFilterLayers; ++i){ + if((LawsFeatures[i].Variance) > maxValue) maxValue = LawsFeatures[i].Variance; + } + scale = (float)1.0 / maxValue; + for(i = 1; i < lawsFilter.numberFilterLayers; ++i){ + LawsFeatures[i].Variance = scale * LawsFeatures[i].Variance; + } + + + return; + +} + +void getVoxelMeasures(objStruct objectMetrics[], double *sourceImage, unsigned short *MaskImage, + int numberObjects, int srcRows, int srcCols){ + + int i, j, k; + int label; + int offset; + int count; + float mean, std, t; + RECT bBox; + + for(i = 0; i < numberObjects; ++i){ + bBox.left = objectMetrics[i].L; + bBox.right = objectMetrics[i].R; + bBox.top = objectMetrics[i].T; + bBox.bottom = objectMetrics[i].B; + label = objectMetrics[i].Label; + count = 0; + mean = (float)0.0; + for(j = bBox.bottom; j < bBox.top; ++j){ + offset = j * srcCols; + for(k = bBox.left; k < bBox.right; ++k){ + if(MaskImage[offset+k] == label){ + mean += sourceImage[offset+k]; + ++count; + } + } + } + if(count){ + mean /= (float)count; + std = (float)0.0; + for(j = bBox.bottom; j < bBox.top; ++j){ + offset = j * srcCols; + for(k = bBox.left; k < bBox.right; ++k){ + if(MaskImage[offset+k] == label){ + t = (sourceImage[offset+k]-mean); + std += (t * t); + } + } + } + } + if(count){ + std /= (float)count; + std = sqrt(std); + objectMetrics[i].voxelMean = mean - 2048.0; // the 2048 is only for the cardiac CT volume + objectMetrics[i].voxelVar = std; + } + else{ + objectMetrics[i].voxelMean = 0.0; + objectMetrics[i].voxelVar = 0.0; + } + if(0) printf("(%d) mean %f, std %f\n", label, objectMetrics[i].voxelMean, objectMetrics[i].voxelVar); + } + + return; + +} + +int NI_BuildBoundary(int samples, int rows, int cols, int numberObjects, unsigned short *edgeImage, + objStruct objectMetrics[]){ + + int searchWindow = 5; // 5 is good value for Sobel - (should be 13 for Canny edges) + int status = 1; + + buildBoundary(objectMetrics, searchWindow, edgeImage, numberObjects, rows, cols); + + return status; + +} + +int NI_VoxelMeasures(int samples, int rows, int cols, int numberObjects, double *sourceImage, + unsigned short *maskImage, objStruct objectMetrics[]){ + + int status = 1; + getVoxelMeasures(objectMetrics, sourceImage, maskImage, numberObjects, rows, cols); + + return status; + +} + + +int NI_TextureMeasures(int samples, int rows, int cols, int numberObjects, double *sourceImage, + unsigned short *maskImage, objStruct objectMetrics[]){ + + int status = 1; + LawsFilter7 lawsFilter; + tTEM LawsFeatures[21]; + + initLaws(&lawsFilter); + getLawsTexture(lawsFilter, LawsFeatures, objectMetrics, sourceImage, maskImage, numberObjects, rows, cols); + + return status; + +} + + + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/Segmenter_IMPL.c ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/__multiarray_api.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/__multiarray_api.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/__multiarray_api.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,974 @@ + +#ifdef _MULTIARRAYMODULE + +typedef struct { + PyObject_HEAD + npy_bool obval; +} PyBoolScalarObject; + + +static unsigned int PyArray_GetNDArrayCVersion (void); +static PyTypeObject PyBigArray_Type; +static PyTypeObject PyArray_Type; +static PyTypeObject PyArrayDescr_Type; +static PyTypeObject PyArrayFlags_Type; +static PyTypeObject PyArrayIter_Type; +static PyTypeObject PyArrayMapIter_Type; +static PyTypeObject PyArrayMultiIter_Type; +static int NPY_NUMUSERTYPES=0; +static PyTypeObject PyBoolArrType_Type; +static PyBoolScalarObject _PyArrayScalar_BoolValues[2]; + +static PyTypeObject PyGenericArrType_Type; +static PyTypeObject PyNumberArrType_Type; +static PyTypeObject PyIntegerArrType_Type; +static PyTypeObject PySignedIntegerArrType_Type; +static PyTypeObject PyUnsignedIntegerArrType_Type; +static PyTypeObject PyInexactArrType_Type; +static PyTypeObject PyFloatingArrType_Type; +static PyTypeObject PyComplexFloatingArrType_Type; +static PyTypeObject PyFlexibleArrType_Type; +static PyTypeObject PyCharacterArrType_Type; +static PyTypeObject PyByteArrType_Type; +static PyTypeObject PyShortArrType_Type; +static PyTypeObject PyIntArrType_Type; +static PyTypeObject PyLongArrType_Type; +static PyTypeObject PyLongLongArrType_Type; +static PyTypeObject PyUByteArrType_Type; +static PyTypeObject PyUShortArrType_Type; +static PyTypeObject PyUIntArrType_Type; +static PyTypeObject PyULongArrType_Type; +static PyTypeObject PyULongLongArrType_Type; +static PyTypeObject PyFloatArrType_Type; +static PyTypeObject PyDoubleArrType_Type; +static PyTypeObject PyLongDoubleArrType_Type; +static PyTypeObject PyCFloatArrType_Type; +static PyTypeObject PyCDoubleArrType_Type; +static PyTypeObject PyCLongDoubleArrType_Type; +static PyTypeObject PyObjectArrType_Type; +static PyTypeObject PyStringArrType_Type; +static PyTypeObject PyUnicodeArrType_Type; +static PyTypeObject PyVoidArrType_Type; +static int PyArray_SetNumericOps \ + (PyObject *); +static PyObject * PyArray_GetNumericOps \ + (void); +static int PyArray_INCREF \ + (PyArrayObject *); +static int PyArray_XDECREF \ + (PyArrayObject *); +static void PyArray_SetStringFunction \ + (PyObject *, int); +static PyArray_Descr * PyArray_DescrFromType \ + (int); +static PyObject * PyArray_TypeObjectFromType \ + (int); +static char * PyArray_Zero \ + (PyArrayObject *); +static char * PyArray_One \ + (PyArrayObject *); +static PyObject * PyArray_CastToType \ + (PyArrayObject *, PyArray_Descr *, int); +static int PyArray_CastTo \ + (PyArrayObject *, PyArrayObject *); +static int PyArray_CastAnyTo \ + (PyArrayObject *, PyArrayObject *); +static int PyArray_CanCastSafely \ + (int, int); +static npy_bool PyArray_CanCastTo \ + (PyArray_Descr *, PyArray_Descr *); +static int PyArray_ObjectType \ + (PyObject *, int); +static PyArray_Descr * PyArray_DescrFromObject \ + (PyObject *, PyArray_Descr *); +static PyArrayObject ** PyArray_ConvertToCommonType \ + (PyObject *, int *); +static PyArray_Descr * PyArray_DescrFromScalar \ + (PyObject *); +static PyArray_Descr * PyArray_DescrFromTypeObject \ + (PyObject *); +static npy_intp PyArray_Size \ + (PyObject *); +static PyObject * PyArray_Scalar \ + (void *, PyArray_Descr *, PyObject *); +static PyObject * PyArray_FromScalar \ + (PyObject *, PyArray_Descr *); +static void PyArray_ScalarAsCtype \ + (PyObject *, void *); +static int PyArray_CastScalarToCtype \ + (PyObject *, void *, PyArray_Descr *); +static int PyArray_CastScalarDirect \ + (PyObject *, PyArray_Descr *, void *, int); +static PyObject * PyArray_ScalarFromObject \ + (PyObject *); +static PyArray_VectorUnaryFunc * PyArray_GetCastFunc \ + (PyArray_Descr *, int); +static PyObject * PyArray_FromDims \ + (int, int *, int); +static PyObject * PyArray_FromDimsAndDataAndDescr \ + (int, int *, PyArray_Descr *, char *); +static PyObject * PyArray_FromAny \ + (PyObject *, PyArray_Descr *, int, int, int, PyObject *); +static PyObject * PyArray_EnsureArray \ + (PyObject *); +static PyObject * PyArray_EnsureAnyArray \ + (PyObject *); +static PyObject * PyArray_FromFile \ + (FILE *, PyArray_Descr *, npy_intp, char *); +static PyObject * PyArray_FromString \ + (char *, npy_intp, PyArray_Descr *, npy_intp, char *); +static PyObject * PyArray_FromBuffer \ + (PyObject *, PyArray_Descr *, npy_intp, npy_intp); +static PyObject * PyArray_FromIter \ + (PyObject *, PyArray_Descr *, npy_intp); +static PyObject * PyArray_Return \ + (PyArrayObject *); +static PyObject * PyArray_GetField \ + (PyArrayObject *, PyArray_Descr *, int); +static int PyArray_SetField \ + (PyArrayObject *, PyArray_Descr *, int, PyObject *); +static PyObject * PyArray_Byteswap \ + (PyArrayObject *, npy_bool); +static PyObject * PyArray_Resize \ + (PyArrayObject *, PyArray_Dims *, int, NPY_ORDER); +static int PyArray_MoveInto \ + (PyArrayObject *, PyArrayObject *); +static int PyArray_CopyInto \ + (PyArrayObject *, PyArrayObject *); +static int PyArray_CopyAnyInto \ + (PyArrayObject *, PyArrayObject *); +static int PyArray_CopyObject \ + (PyArrayObject *, PyObject *); +static PyObject * PyArray_NewCopy \ + (PyArrayObject *, NPY_ORDER); +static PyObject * PyArray_ToList \ + (PyArrayObject *); +static PyObject * PyArray_ToString \ + (PyArrayObject *, NPY_ORDER); +static int PyArray_ToFile \ + (PyArrayObject *, FILE *, char *, char *); +static int PyArray_Dump \ + (PyObject *, PyObject *, int); +static PyObject * PyArray_Dumps \ + (PyObject *, int); +static int PyArray_ValidType \ + (int); +static void PyArray_UpdateFlags \ + (PyArrayObject *, int); +static PyObject * PyArray_New \ + (PyTypeObject *, int, npy_intp *, int, npy_intp *, void *, int, int, PyObject *); +static PyObject * PyArray_NewFromDescr \ + (PyTypeObject *, PyArray_Descr *, int, npy_intp *, npy_intp *, void *, int, PyObject *); +static PyArray_Descr * PyArray_DescrNew \ + (PyArray_Descr *); +static PyArray_Descr * PyArray_DescrNewFromType \ + (int); +static double PyArray_GetPriority \ + (PyObject *, double); +static PyObject * PyArray_IterNew \ + (PyObject *); +static PyObject * PyArray_MultiIterNew \ + (int, ...); +static int PyArray_PyIntAsInt \ + (PyObject *); +static npy_intp PyArray_PyIntAsIntp \ + (PyObject *); +static int PyArray_Broadcast \ + (PyArrayMultiIterObject *); +static void PyArray_FillObjectArray \ + (PyArrayObject *, PyObject *); +static int PyArray_FillWithScalar \ + (PyArrayObject *, PyObject *); +static npy_bool PyArray_CheckStrides \ + (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *); +static PyArray_Descr * PyArray_DescrNewByteorder \ + (PyArray_Descr *, char); +static PyObject * PyArray_IterAllButAxis \ + (PyObject *, int *); +static PyObject * PyArray_CheckFromAny \ + (PyObject *, PyArray_Descr *, int, int, int, PyObject *); +static PyObject * PyArray_FromArray \ + (PyArrayObject *, PyArray_Descr *, int); +static PyObject * PyArray_FromInterface \ + (PyObject *); +static PyObject * PyArray_FromStructInterface \ + (PyObject *); +static PyObject * PyArray_FromArrayAttr \ + (PyObject *, PyArray_Descr *, PyObject *); +static NPY_SCALARKIND PyArray_ScalarKind \ + (int, PyArrayObject **); +static int PyArray_CanCoerceScalar \ + (int, int, NPY_SCALARKIND); +static PyObject * PyArray_NewFlagsObject \ + (PyObject *); +static npy_bool PyArray_CanCastScalar \ + (PyTypeObject *, PyTypeObject *); +static int PyArray_CompareUCS4 \ + (npy_ucs4 *, npy_ucs4 *, register size_t); +static int PyArray_RemoveSmallest \ + (PyArrayMultiIterObject *); +static int PyArray_ElementStrides \ + (PyObject *); +static void PyArray_Item_INCREF \ + (char *, PyArray_Descr *); +static void PyArray_Item_XDECREF \ + (char *, PyArray_Descr *); +static PyObject * PyArray_FieldNames \ + (PyObject *); +static PyObject * PyArray_Transpose \ + (PyArrayObject *, PyArray_Dims *); +static PyObject * PyArray_TakeFrom \ + (PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE); +static PyObject * PyArray_PutTo \ + (PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE); +static PyObject * PyArray_PutMask \ + (PyArrayObject *, PyObject*, PyObject*); +static PyObject * PyArray_Repeat \ + (PyArrayObject *, PyObject *, int); +static PyObject * PyArray_Choose \ + (PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE); +static int PyArray_Sort \ + (PyArrayObject *, int, NPY_SORTKIND); +static PyObject * PyArray_ArgSort \ + (PyArrayObject *, int, NPY_SORTKIND); +static PyObject * PyArray_SearchSorted \ + (PyArrayObject *, PyObject *, NPY_SEARCHSIDE); +static PyObject * PyArray_ArgMax \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_ArgMin \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_Reshape \ + (PyArrayObject *, PyObject *); +static PyObject * PyArray_Newshape \ + (PyArrayObject *, PyArray_Dims *, NPY_ORDER); +static PyObject * PyArray_Squeeze \ + (PyArrayObject *); +static PyObject * PyArray_View \ + (PyArrayObject *, PyArray_Descr *, PyTypeObject *); +static PyObject * PyArray_SwapAxes \ + (PyArrayObject *, int, int); +static PyObject * PyArray_Max \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_Min \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_Ptp \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_Mean \ + (PyArrayObject *, int, int, PyArrayObject *); +static PyObject * PyArray_Trace \ + (PyArrayObject *, int, int, int, int, PyArrayObject *); +static PyObject * PyArray_Diagonal \ + (PyArrayObject *, int, int, int); +static PyObject * PyArray_Clip \ + (PyArrayObject *, PyObject *, PyObject *, PyArrayObject *); +static PyObject * PyArray_Conjugate \ + (PyArrayObject *, PyArrayObject *); +static PyObject * PyArray_Nonzero \ + (PyArrayObject *); +static PyObject * PyArray_Std \ + (PyArrayObject *, int, int, PyArrayObject *, int); +static PyObject * PyArray_Sum \ + (PyArrayObject *, int, int, PyArrayObject *); +static PyObject * PyArray_CumSum \ + (PyArrayObject *, int, int, PyArrayObject *); +static PyObject * PyArray_Prod \ + (PyArrayObject *, int, int, PyArrayObject *); +static PyObject * PyArray_CumProd \ + (PyArrayObject *, int, int, PyArrayObject *); +static PyObject * PyArray_All \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_Any \ + (PyArrayObject *, int, PyArrayObject *); +static PyObject * PyArray_Compress \ + (PyArrayObject *, PyObject *, int, PyArrayObject *); +static PyObject * PyArray_Flatten \ + (PyArrayObject *, NPY_ORDER); +static PyObject * PyArray_Ravel \ + (PyArrayObject *, NPY_ORDER); +static npy_intp PyArray_MultiplyList \ + (register npy_intp *, register int); +static int PyArray_MultiplyIntList \ + (register int *, register int); +static void * PyArray_GetPtr \ + (PyArrayObject *, register npy_intp*); +static int PyArray_CompareLists \ + (npy_intp *, npy_intp *, int); +static int PyArray_AsCArray \ + (PyObject **, void *, npy_intp *, int, PyArray_Descr*); +static int PyArray_As1D \ + (PyObject **, char **, int *, int); +static int PyArray_As2D \ + (PyObject **, char ***, int *, int *, int); +static int PyArray_Free \ + (PyObject *, void *); +static int PyArray_Converter \ + (PyObject *, PyObject **); +static int PyArray_IntpFromSequence \ + (PyObject *, npy_intp *, int); +static PyObject * PyArray_Concatenate \ + (PyObject *, int); +static PyObject * PyArray_InnerProduct \ + (PyObject *, PyObject *); +static PyObject * PyArray_MatrixProduct \ + (PyObject *, PyObject *); +static PyObject * PyArray_CopyAndTranspose \ + (PyObject *); +static PyObject * PyArray_Correlate \ + (PyObject *, PyObject *, int); +static int PyArray_TypestrConvert \ + (int, int); +static int PyArray_DescrConverter \ + (PyObject *, PyArray_Descr **); +static int PyArray_DescrConverter2 \ + (PyObject *, PyArray_Descr **); +static int PyArray_IntpConverter \ + (PyObject *, PyArray_Dims *); +static int PyArray_BufferConverter \ + (PyObject *, PyArray_Chunk *); +static int PyArray_AxisConverter \ + (PyObject *, int *); +static int PyArray_BoolConverter \ + (PyObject *, npy_bool *); +static int PyArray_ByteorderConverter \ + (PyObject *, char *); +static int PyArray_OrderConverter \ + (PyObject *, NPY_ORDER *); +static unsigned char PyArray_EquivTypes \ + (PyArray_Descr *, PyArray_Descr *); +static PyObject * PyArray_Zeros \ + (int, npy_intp *, PyArray_Descr *, int); +static PyObject * PyArray_Empty \ + (int, npy_intp *, PyArray_Descr *, int); +static PyObject * PyArray_Where \ + (PyObject *, PyObject *, PyObject *); +static PyObject * PyArray_Arange \ + (double, double, double, int); +static PyObject * PyArray_ArangeObj \ + (PyObject *, PyObject *, PyObject *, PyArray_Descr *); +static int PyArray_SortkindConverter \ + (PyObject *, NPY_SORTKIND *); +static PyObject * PyArray_LexSort \ + (PyObject *, int); +static PyObject * PyArray_Round \ + (PyArrayObject *, int, PyArrayObject *); +static unsigned char PyArray_EquivTypenums \ + (int, int); +static int PyArray_RegisterDataType \ + (PyArray_Descr *); +static int PyArray_RegisterCastFunc \ + (PyArray_Descr *, int, PyArray_VectorUnaryFunc *); +static int PyArray_RegisterCanCast \ + (PyArray_Descr *, int, NPY_SCALARKIND); +static void PyArray_InitArrFuncs \ + (PyArray_ArrFuncs *); +static PyObject * PyArray_IntTupleFromIntp \ + (int, npy_intp *); +static int PyArray_TypeNumFromName \ + (char *); +static int PyArray_ClipmodeConverter \ + (PyObject *, NPY_CLIPMODE *); +static int PyArray_OutputConverter \ + (PyObject *, PyArrayObject **); +static PyObject * PyArray_BroadcastToShape \ + (PyObject *, npy_intp *, int); +static void _PyArray_SigintHandler \ + (int); +static void* _PyArray_GetSigintBuf \ + (void); +static int PyArray_DescrAlignConverter \ + (PyObject *, PyArray_Descr **); +static int PyArray_DescrAlignConverter2 \ + (PyObject *, PyArray_Descr **); +static int PyArray_SearchsideConverter \ + (PyObject *, void *); + +#else + +#if defined(PY_ARRAY_UNIQUE_SYMBOL) +#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL +#endif + +#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY) +extern void **PyArray_API; +#else +#if defined(PY_ARRAY_UNIQUE_SYMBOL) +void **PyArray_API; +#else +static void **PyArray_API=NULL; +#endif +#endif + +#define PyArray_GetNDArrayCVersion (*(unsigned int (*)(void)) PyArray_API[0]) +#define PyBigArray_Type (*(PyTypeObject *)PyArray_API[1]) +#define PyArray_Type (*(PyTypeObject *)PyArray_API[2]) +#define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[3]) +#define PyArrayFlags_Type (*(PyTypeObject *)PyArray_API[4]) +#define PyArrayIter_Type (*(PyTypeObject *)PyArray_API[5]) +#define PyArrayMultiIter_Type (*(PyTypeObject *)PyArray_API[6]) +#define NPY_NUMUSERTYPES (*(int *)PyArray_API[7]) +#define PyBoolArrType_Type (*(PyTypeObject *)PyArray_API[8]) +#define _PyArrayScalar_BoolValues ((PyBoolScalarObject *)PyArray_API[9]) + +#define PyGenericArrType_Type (*(PyTypeObject *)PyArray_API[10]) +#define PyNumberArrType_Type (*(PyTypeObject *)PyArray_API[11]) +#define PyIntegerArrType_Type (*(PyTypeObject *)PyArray_API[12]) +#define PySignedIntegerArrType_Type (*(PyTypeObject *)PyArray_API[13]) +#define PyUnsignedIntegerArrType_Type (*(PyTypeObject *)PyArray_API[14]) +#define PyInexactArrType_Type (*(PyTypeObject *)PyArray_API[15]) +#define PyFloatingArrType_Type (*(PyTypeObject *)PyArray_API[16]) +#define PyComplexFloatingArrType_Type (*(PyTypeObject *)PyArray_API[17]) +#define PyFlexibleArrType_Type (*(PyTypeObject *)PyArray_API[18]) +#define PyCharacterArrType_Type (*(PyTypeObject *)PyArray_API[19]) +#define PyByteArrType_Type (*(PyTypeObject *)PyArray_API[20]) +#define PyShortArrType_Type (*(PyTypeObject *)PyArray_API[21]) +#define PyIntArrType_Type (*(PyTypeObject *)PyArray_API[22]) +#define PyLongArrType_Type (*(PyTypeObject *)PyArray_API[23]) +#define PyLongLongArrType_Type (*(PyTypeObject *)PyArray_API[24]) +#define PyUByteArrType_Type (*(PyTypeObject *)PyArray_API[25]) +#define PyUShortArrType_Type (*(PyTypeObject *)PyArray_API[26]) +#define PyUIntArrType_Type (*(PyTypeObject *)PyArray_API[27]) +#define PyULongArrType_Type (*(PyTypeObject *)PyArray_API[28]) +#define PyULongLongArrType_Type (*(PyTypeObject *)PyArray_API[29]) +#define PyFloatArrType_Type (*(PyTypeObject *)PyArray_API[30]) +#define PyDoubleArrType_Type (*(PyTypeObject *)PyArray_API[31]) +#define PyLongDoubleArrType_Type (*(PyTypeObject *)PyArray_API[32]) +#define PyCFloatArrType_Type (*(PyTypeObject *)PyArray_API[33]) +#define PyCDoubleArrType_Type (*(PyTypeObject *)PyArray_API[34]) +#define PyCLongDoubleArrType_Type (*(PyTypeObject *)PyArray_API[35]) +#define PyObjectArrType_Type (*(PyTypeObject *)PyArray_API[36]) +#define PyStringArrType_Type (*(PyTypeObject *)PyArray_API[37]) +#define PyUnicodeArrType_Type (*(PyTypeObject *)PyArray_API[38]) +#define PyVoidArrType_Type (*(PyTypeObject *)PyArray_API[39]) +#define PyArray_SetNumericOps \ + (*(int (*)(PyObject *)) \ + PyArray_API[40]) +#define PyArray_GetNumericOps \ + (*(PyObject * (*)(void)) \ + PyArray_API[41]) +#define PyArray_INCREF \ + (*(int (*)(PyArrayObject *)) \ + PyArray_API[42]) +#define PyArray_XDECREF \ + (*(int (*)(PyArrayObject *)) \ + PyArray_API[43]) +#define PyArray_SetStringFunction \ + (*(void (*)(PyObject *, int)) \ + PyArray_API[44]) +#define PyArray_DescrFromType \ + (*(PyArray_Descr * (*)(int)) \ + PyArray_API[45]) +#define PyArray_TypeObjectFromType \ + (*(PyObject * (*)(int)) \ + PyArray_API[46]) +#define PyArray_Zero \ + (*(char * (*)(PyArrayObject *)) \ + PyArray_API[47]) +#define PyArray_One \ + (*(char * (*)(PyArrayObject *)) \ + PyArray_API[48]) +#define PyArray_CastToType \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \ + PyArray_API[49]) +#define PyArray_CastTo \ + (*(int (*)(PyArrayObject *, PyArrayObject *)) \ + PyArray_API[50]) +#define PyArray_CastAnyTo \ + (*(int (*)(PyArrayObject *, PyArrayObject *)) \ + PyArray_API[51]) +#define PyArray_CanCastSafely \ + (*(int (*)(int, int)) \ + PyArray_API[52]) +#define PyArray_CanCastTo \ + (*(npy_bool (*)(PyArray_Descr *, PyArray_Descr *)) \ + PyArray_API[53]) +#define PyArray_ObjectType \ + (*(int (*)(PyObject *, int)) \ + PyArray_API[54]) +#define PyArray_DescrFromObject \ + (*(PyArray_Descr * (*)(PyObject *, PyArray_Descr *)) \ + PyArray_API[55]) +#define PyArray_ConvertToCommonType \ + (*(PyArrayObject ** (*)(PyObject *, int *)) \ + PyArray_API[56]) +#define PyArray_DescrFromScalar \ + (*(PyArray_Descr * (*)(PyObject *)) \ + PyArray_API[57]) +#define PyArray_DescrFromTypeObject \ + (*(PyArray_Descr * (*)(PyObject *)) \ + PyArray_API[58]) +#define PyArray_Size \ + (*(npy_intp (*)(PyObject *)) \ + PyArray_API[59]) +#define PyArray_Scalar \ + (*(PyObject * (*)(void *, PyArray_Descr *, PyObject *)) \ + PyArray_API[60]) +#define PyArray_FromScalar \ + (*(PyObject * (*)(PyObject *, PyArray_Descr *)) \ + PyArray_API[61]) +#define PyArray_ScalarAsCtype \ + (*(void (*)(PyObject *, void *)) \ + PyArray_API[62]) +#define PyArray_CastScalarToCtype \ + (*(int (*)(PyObject *, void *, PyArray_Descr *)) \ + PyArray_API[63]) +#define PyArray_CastScalarDirect \ + (*(int (*)(PyObject *, PyArray_Descr *, void *, int)) \ + PyArray_API[64]) +#define PyArray_ScalarFromObject \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[65]) +#define PyArray_GetCastFunc \ + (*(PyArray_VectorUnaryFunc * (*)(PyArray_Descr *, int)) \ + PyArray_API[66]) +#define PyArray_FromDims \ + (*(PyObject * (*)(int, int *, int)) \ + PyArray_API[67]) +#define PyArray_FromDimsAndDataAndDescr \ + (*(PyObject * (*)(int, int *, PyArray_Descr *, char *)) \ + PyArray_API[68]) +#define PyArray_FromAny \ + (*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) \ + PyArray_API[69]) +#define PyArray_EnsureArray \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[70]) +#define PyArray_EnsureAnyArray \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[71]) +#define PyArray_FromFile \ + (*(PyObject * (*)(FILE *, PyArray_Descr *, npy_intp, char *)) \ + PyArray_API[72]) +#define PyArray_FromString \ + (*(PyObject * (*)(char *, npy_intp, PyArray_Descr *, npy_intp, char *)) \ + PyArray_API[73]) +#define PyArray_FromBuffer \ + (*(PyObject * (*)(PyObject *, PyArray_Descr *, npy_intp, npy_intp)) \ + PyArray_API[74]) +#define PyArray_FromIter \ + (*(PyObject * (*)(PyObject *, PyArray_Descr *, npy_intp)) \ + PyArray_API[75]) +#define PyArray_Return \ + (*(PyObject * (*)(PyArrayObject *)) \ + PyArray_API[76]) +#define PyArray_GetField \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \ + PyArray_API[77]) +#define PyArray_SetField \ + (*(int (*)(PyArrayObject *, PyArray_Descr *, int, PyObject *)) \ + PyArray_API[78]) +#define PyArray_Byteswap \ + (*(PyObject * (*)(PyArrayObject *, npy_bool)) \ + PyArray_API[79]) +#define PyArray_Resize \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Dims *, int, NPY_ORDER)) \ + PyArray_API[80]) +#define PyArray_MoveInto \ + (*(int (*)(PyArrayObject *, PyArrayObject *)) \ + PyArray_API[81]) +#define PyArray_CopyInto \ + (*(int (*)(PyArrayObject *, PyArrayObject *)) \ + PyArray_API[82]) +#define PyArray_CopyAnyInto \ + (*(int (*)(PyArrayObject *, PyArrayObject *)) \ + PyArray_API[83]) +#define PyArray_CopyObject \ + (*(int (*)(PyArrayObject *, PyObject *)) \ + PyArray_API[84]) +#define PyArray_NewCopy \ + (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \ + PyArray_API[85]) +#define PyArray_ToList \ + (*(PyObject * (*)(PyArrayObject *)) \ + PyArray_API[86]) +#define PyArray_ToString \ + (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \ + PyArray_API[87]) +#define PyArray_ToFile \ + (*(int (*)(PyArrayObject *, FILE *, char *, char *)) \ + PyArray_API[88]) +#define PyArray_Dump \ + (*(int (*)(PyObject *, PyObject *, int)) \ + PyArray_API[89]) +#define PyArray_Dumps \ + (*(PyObject * (*)(PyObject *, int)) \ + PyArray_API[90]) +#define PyArray_ValidType \ + (*(int (*)(int)) \ + PyArray_API[91]) +#define PyArray_UpdateFlags \ + (*(void (*)(PyArrayObject *, int)) \ + PyArray_API[92]) +#define PyArray_New \ + (*(PyObject * (*)(PyTypeObject *, int, npy_intp *, int, npy_intp *, void *, int, int, PyObject *)) \ + PyArray_API[93]) +#define PyArray_NewFromDescr \ + (*(PyObject * (*)(PyTypeObject *, PyArray_Descr *, int, npy_intp *, npy_intp *, void *, int, PyObject *)) \ + PyArray_API[94]) +#define PyArray_DescrNew \ + (*(PyArray_Descr * (*)(PyArray_Descr *)) \ + PyArray_API[95]) +#define PyArray_DescrNewFromType \ + (*(PyArray_Descr * (*)(int)) \ + PyArray_API[96]) +#define PyArray_GetPriority \ + (*(double (*)(PyObject *, double)) \ + PyArray_API[97]) +#define PyArray_IterNew \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[98]) +#define PyArray_MultiIterNew \ + (*(PyObject * (*)(int, ...)) \ + PyArray_API[99]) +#define PyArray_PyIntAsInt \ + (*(int (*)(PyObject *)) \ + PyArray_API[100]) +#define PyArray_PyIntAsIntp \ + (*(npy_intp (*)(PyObject *)) \ + PyArray_API[101]) +#define PyArray_Broadcast \ + (*(int (*)(PyArrayMultiIterObject *)) \ + PyArray_API[102]) +#define PyArray_FillObjectArray \ + (*(void (*)(PyArrayObject *, PyObject *)) \ + PyArray_API[103]) +#define PyArray_FillWithScalar \ + (*(int (*)(PyArrayObject *, PyObject *)) \ + PyArray_API[104]) +#define PyArray_CheckStrides \ + (*(npy_bool (*)(int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)) \ + PyArray_API[105]) +#define PyArray_DescrNewByteorder \ + (*(PyArray_Descr * (*)(PyArray_Descr *, char)) \ + PyArray_API[106]) +#define PyArray_IterAllButAxis \ + (*(PyObject * (*)(PyObject *, int *)) \ + PyArray_API[107]) +#define PyArray_CheckFromAny \ + (*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) \ + PyArray_API[108]) +#define PyArray_FromArray \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \ + PyArray_API[109]) +#define PyArray_FromInterface \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[110]) +#define PyArray_FromStructInterface \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[111]) +#define PyArray_FromArrayAttr \ + (*(PyObject * (*)(PyObject *, PyArray_Descr *, PyObject *)) \ + PyArray_API[112]) +#define PyArray_ScalarKind \ + (*(NPY_SCALARKIND (*)(int, PyArrayObject **)) \ + PyArray_API[113]) +#define PyArray_CanCoerceScalar \ + (*(int (*)(int, int, NPY_SCALARKIND)) \ + PyArray_API[114]) +#define PyArray_NewFlagsObject \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[115]) +#define PyArray_CanCastScalar \ + (*(npy_bool (*)(PyTypeObject *, PyTypeObject *)) \ + PyArray_API[116]) +#define PyArray_CompareUCS4 \ + (*(int (*)(npy_ucs4 *, npy_ucs4 *, register size_t)) \ + PyArray_API[117]) +#define PyArray_RemoveSmallest \ + (*(int (*)(PyArrayMultiIterObject *)) \ + PyArray_API[118]) +#define PyArray_ElementStrides \ + (*(int (*)(PyObject *)) \ + PyArray_API[119]) +#define PyArray_Item_INCREF \ + (*(void (*)(char *, PyArray_Descr *)) \ + PyArray_API[120]) +#define PyArray_Item_XDECREF \ + (*(void (*)(char *, PyArray_Descr *)) \ + PyArray_API[121]) +#define PyArray_FieldNames \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[122]) +#define PyArray_Transpose \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Dims *)) \ + PyArray_API[123]) +#define PyArray_TakeFrom \ + (*(PyObject * (*)(PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE)) \ + PyArray_API[124]) +#define PyArray_PutTo \ + (*(PyObject * (*)(PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE)) \ + PyArray_API[125]) +#define PyArray_PutMask \ + (*(PyObject * (*)(PyArrayObject *, PyObject*, PyObject*)) \ + PyArray_API[126]) +#define PyArray_Repeat \ + (*(PyObject * (*)(PyArrayObject *, PyObject *, int)) \ + PyArray_API[127]) +#define PyArray_Choose \ + (*(PyObject * (*)(PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE)) \ + PyArray_API[128]) +#define PyArray_Sort \ + (*(int (*)(PyArrayObject *, int, NPY_SORTKIND)) \ + PyArray_API[129]) +#define PyArray_ArgSort \ + (*(PyObject * (*)(PyArrayObject *, int, NPY_SORTKIND)) \ + PyArray_API[130]) +#define PyArray_SearchSorted \ + (*(PyObject * (*)(PyArrayObject *, PyObject *, NPY_SEARCHSIDE)) \ + PyArray_API[131]) +#define PyArray_ArgMax \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[132]) +#define PyArray_ArgMin \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[133]) +#define PyArray_Reshape \ + (*(PyObject * (*)(PyArrayObject *, PyObject *)) \ + PyArray_API[134]) +#define PyArray_Newshape \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Dims *, NPY_ORDER)) \ + PyArray_API[135]) +#define PyArray_Squeeze \ + (*(PyObject * (*)(PyArrayObject *)) \ + PyArray_API[136]) +#define PyArray_View \ + (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, PyTypeObject *)) \ + PyArray_API[137]) +#define PyArray_SwapAxes \ + (*(PyObject * (*)(PyArrayObject *, int, int)) \ + PyArray_API[138]) +#define PyArray_Max \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[139]) +#define PyArray_Min \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[140]) +#define PyArray_Ptp \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[141]) +#define PyArray_Mean \ + (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \ + PyArray_API[142]) +#define PyArray_Trace \ + (*(PyObject * (*)(PyArrayObject *, int, int, int, int, PyArrayObject *)) \ + PyArray_API[143]) +#define PyArray_Diagonal \ + (*(PyObject * (*)(PyArrayObject *, int, int, int)) \ + PyArray_API[144]) +#define PyArray_Clip \ + (*(PyObject * (*)(PyArrayObject *, PyObject *, PyObject *, PyArrayObject *)) \ + PyArray_API[145]) +#define PyArray_Conjugate \ + (*(PyObject * (*)(PyArrayObject *, PyArrayObject *)) \ + PyArray_API[146]) +#define PyArray_Nonzero \ + (*(PyObject * (*)(PyArrayObject *)) \ + PyArray_API[147]) +#define PyArray_Std \ + (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *, int)) \ + PyArray_API[148]) +#define PyArray_Sum \ + (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \ + PyArray_API[149]) +#define PyArray_CumSum \ + (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \ + PyArray_API[150]) +#define PyArray_Prod \ + (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \ + PyArray_API[151]) +#define PyArray_CumProd \ + (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \ + PyArray_API[152]) +#define PyArray_All \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[153]) +#define PyArray_Any \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[154]) +#define PyArray_Compress \ + (*(PyObject * (*)(PyArrayObject *, PyObject *, int, PyArrayObject *)) \ + PyArray_API[155]) +#define PyArray_Flatten \ + (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \ + PyArray_API[156]) +#define PyArray_Ravel \ + (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \ + PyArray_API[157]) +#define PyArray_MultiplyList \ + (*(npy_intp (*)(register npy_intp *, register int)) \ + PyArray_API[158]) +#define PyArray_MultiplyIntList \ + (*(int (*)(register int *, register int)) \ + PyArray_API[159]) +#define PyArray_GetPtr \ + (*(void * (*)(PyArrayObject *, register npy_intp*)) \ + PyArray_API[160]) +#define PyArray_CompareLists \ + (*(int (*)(npy_intp *, npy_intp *, int)) \ + PyArray_API[161]) +#define PyArray_AsCArray \ + (*(int (*)(PyObject **, void *, npy_intp *, int, PyArray_Descr*)) \ + PyArray_API[162]) +#define PyArray_As1D \ + (*(int (*)(PyObject **, char **, int *, int)) \ + PyArray_API[163]) +#define PyArray_As2D \ + (*(int (*)(PyObject **, char ***, int *, int *, int)) \ + PyArray_API[164]) +#define PyArray_Free \ + (*(int (*)(PyObject *, void *)) \ + PyArray_API[165]) +#define PyArray_Converter \ + (*(int (*)(PyObject *, PyObject **)) \ + PyArray_API[166]) +#define PyArray_IntpFromSequence \ + (*(int (*)(PyObject *, npy_intp *, int)) \ + PyArray_API[167]) +#define PyArray_Concatenate \ + (*(PyObject * (*)(PyObject *, int)) \ + PyArray_API[168]) +#define PyArray_InnerProduct \ + (*(PyObject * (*)(PyObject *, PyObject *)) \ + PyArray_API[169]) +#define PyArray_MatrixProduct \ + (*(PyObject * (*)(PyObject *, PyObject *)) \ + PyArray_API[170]) +#define PyArray_CopyAndTranspose \ + (*(PyObject * (*)(PyObject *)) \ + PyArray_API[171]) +#define PyArray_Correlate \ + (*(PyObject * (*)(PyObject *, PyObject *, int)) \ + PyArray_API[172]) +#define PyArray_TypestrConvert \ + (*(int (*)(int, int)) \ + PyArray_API[173]) +#define PyArray_DescrConverter \ + (*(int (*)(PyObject *, PyArray_Descr **)) \ + PyArray_API[174]) +#define PyArray_DescrConverter2 \ + (*(int (*)(PyObject *, PyArray_Descr **)) \ + PyArray_API[175]) +#define PyArray_IntpConverter \ + (*(int (*)(PyObject *, PyArray_Dims *)) \ + PyArray_API[176]) +#define PyArray_BufferConverter \ + (*(int (*)(PyObject *, PyArray_Chunk *)) \ + PyArray_API[177]) +#define PyArray_AxisConverter \ + (*(int (*)(PyObject *, int *)) \ + PyArray_API[178]) +#define PyArray_BoolConverter \ + (*(int (*)(PyObject *, npy_bool *)) \ + PyArray_API[179]) +#define PyArray_ByteorderConverter \ + (*(int (*)(PyObject *, char *)) \ + PyArray_API[180]) +#define PyArray_OrderConverter \ + (*(int (*)(PyObject *, NPY_ORDER *)) \ + PyArray_API[181]) +#define PyArray_EquivTypes \ + (*(unsigned char (*)(PyArray_Descr *, PyArray_Descr *)) \ + PyArray_API[182]) +#define PyArray_Zeros \ + (*(PyObject * (*)(int, npy_intp *, PyArray_Descr *, int)) \ + PyArray_API[183]) +#define PyArray_Empty \ + (*(PyObject * (*)(int, npy_intp *, PyArray_Descr *, int)) \ + PyArray_API[184]) +#define PyArray_Where \ + (*(PyObject * (*)(PyObject *, PyObject *, PyObject *)) \ + PyArray_API[185]) +#define PyArray_Arange \ + (*(PyObject * (*)(double, double, double, int)) \ + PyArray_API[186]) +#define PyArray_ArangeObj \ + (*(PyObject * (*)(PyObject *, PyObject *, PyObject *, PyArray_Descr *)) \ + PyArray_API[187]) +#define PyArray_SortkindConverter \ + (*(int (*)(PyObject *, NPY_SORTKIND *)) \ + PyArray_API[188]) +#define PyArray_LexSort \ + (*(PyObject * (*)(PyObject *, int)) \ + PyArray_API[189]) +#define PyArray_Round \ + (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \ + PyArray_API[190]) +#define PyArray_EquivTypenums \ + (*(unsigned char (*)(int, int)) \ + PyArray_API[191]) +#define PyArray_RegisterDataType \ + (*(int (*)(PyArray_Descr *)) \ + PyArray_API[192]) +#define PyArray_RegisterCastFunc \ + (*(int (*)(PyArray_Descr *, int, PyArray_VectorUnaryFunc *)) \ + PyArray_API[193]) +#define PyArray_RegisterCanCast \ + (*(int (*)(PyArray_Descr *, int, NPY_SCALARKIND)) \ + PyArray_API[194]) +#define PyArray_InitArrFuncs \ + (*(void (*)(PyArray_ArrFuncs *)) \ + PyArray_API[195]) +#define PyArray_IntTupleFromIntp \ + (*(PyObject * (*)(int, npy_intp *)) \ + PyArray_API[196]) +#define PyArray_TypeNumFromName \ + (*(int (*)(char *)) \ + PyArray_API[197]) +#define PyArray_ClipmodeConverter \ + (*(int (*)(PyObject *, NPY_CLIPMODE *)) \ + PyArray_API[198]) +#define PyArray_OutputConverter \ + (*(int (*)(PyObject *, PyArrayObject **)) \ + PyArray_API[199]) +#define PyArray_BroadcastToShape \ + (*(PyObject * (*)(PyObject *, npy_intp *, int)) \ + PyArray_API[200]) +#define _PyArray_SigintHandler \ + (*(void (*)(int)) \ + PyArray_API[201]) +#define _PyArray_GetSigintBuf \ + (*(void* (*)(void)) \ + PyArray_API[202]) +#define PyArray_DescrAlignConverter \ + (*(int (*)(PyObject *, PyArray_Descr **)) \ + PyArray_API[203]) +#define PyArray_DescrAlignConverter2 \ + (*(int (*)(PyObject *, PyArray_Descr **)) \ + PyArray_API[204]) +#define PyArray_SearchsideConverter \ + (*(int (*)(PyObject *, void *)) \ + PyArray_API[205]) + +#if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT) +static int +_import_array(void) +{ + PyObject *numpy = PyImport_ImportModule("numpy.core.multiarray"); + PyObject *c_api = NULL; + if (numpy == NULL) return -1; + c_api = PyObject_GetAttrString(numpy, "_ARRAY_API"); + if (c_api == NULL) {Py_DECREF(numpy); return -1;} + if (PyCObject_Check(c_api)) { + PyArray_API = (void **)PyCObject_AsVoidPtr(c_api); + } + Py_DECREF(c_api); + Py_DECREF(numpy); + if (PyArray_API == NULL) return -1; + /* Perform runtime check of C API version */ + if (NPY_VERSION != PyArray_GetNDArrayCVersion()) { + PyErr_Format(PyExc_RuntimeError, "module compiled against "\ + "version %x of C-API but this version of numpy is %x", \ + (int) NPY_VERSION, (int) PyArray_GetNDArrayCVersion()); + return -1; + } + return 0; +} + +#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return; } } + +#define import_array1(ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return ret; } } + +#define import_array2(msg, ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, msg); return ret; } } + +#endif + +#endif Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/__multiarray_api.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/__ufunc_api.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/__ufunc_api.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/__ufunc_api.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,203 @@ + +#ifdef _UMATHMODULE + +static PyTypeObject PyUFunc_Type; + +static PyObject * PyUFunc_FromFuncAndData \ + (PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int); +static int PyUFunc_RegisterLoopForType \ + (PyUFuncObject *, int, PyUFuncGenericFunction, int *, void *); +static int PyUFunc_GenericFunction \ + (PyUFuncObject *, PyObject *, PyObject *, PyArrayObject **); +static void PyUFunc_f_f_As_d_d \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_d_d \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_f_f \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_g_g \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_F_F_As_D_D \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_F_F \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_D_D \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_G_G \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_O_O \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_ff_f_As_dd_d \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_ff_f \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_dd_d \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_gg_g \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_FF_F_As_DD_D \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_DD_D \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_FF_F \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_GG_G \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_OO_O \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_O_O_method \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_OO_O_method \ + (char **, npy_intp *, npy_intp *, void *); +static void PyUFunc_On_Om \ + (char **, npy_intp *, npy_intp *, void *); +static int PyUFunc_GetPyValues \ + (char *, int *, int *, PyObject **); +static int PyUFunc_checkfperr \ + (int, PyObject *, int *); +static void PyUFunc_clearfperr \ + (void); +static int PyUFunc_getfperr \ + (void); +static int PyUFunc_handlefperr \ + (int, PyObject *, int, int *); +static int PyUFunc_ReplaceLoopBySignature \ + (PyUFuncObject *, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *); + +#else + +#if defined(PY_UFUNC_UNIQUE_SYMBOL) +#define PyUFunc_API PY_UFUNC_UNIQUE_SYMBOL +#endif + +#if defined(NO_IMPORT) || defined(NO_IMPORT_UFUNC) +extern void **PyUFunc_API; +#else +#if defined(PY_UFUNC_UNIQUE_SYMBOL) +void **PyUFunc_API; +#else +static void **PyUFunc_API=NULL; +#endif +#endif + +#define PyUFunc_Type (*(PyTypeObject *)PyUFunc_API[0]) + +#define PyUFunc_FromFuncAndData \ + (*(PyObject * (*)(PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int)) \ + PyUFunc_API[1]) +#define PyUFunc_RegisterLoopForType \ + (*(int (*)(PyUFuncObject *, int, PyUFuncGenericFunction, int *, void *)) \ + PyUFunc_API[2]) +#define PyUFunc_GenericFunction \ + (*(int (*)(PyUFuncObject *, PyObject *, PyObject *, PyArrayObject **)) \ + PyUFunc_API[3]) +#define PyUFunc_f_f_As_d_d \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[4]) +#define PyUFunc_d_d \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[5]) +#define PyUFunc_f_f \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[6]) +#define PyUFunc_g_g \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[7]) +#define PyUFunc_F_F_As_D_D \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[8]) +#define PyUFunc_F_F \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[9]) +#define PyUFunc_D_D \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[10]) +#define PyUFunc_G_G \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[11]) +#define PyUFunc_O_O \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[12]) +#define PyUFunc_ff_f_As_dd_d \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[13]) +#define PyUFunc_ff_f \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[14]) +#define PyUFunc_dd_d \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[15]) +#define PyUFunc_gg_g \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[16]) +#define PyUFunc_FF_F_As_DD_D \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[17]) +#define PyUFunc_DD_D \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[18]) +#define PyUFunc_FF_F \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[19]) +#define PyUFunc_GG_G \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[20]) +#define PyUFunc_OO_O \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[21]) +#define PyUFunc_O_O_method \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[22]) +#define PyUFunc_OO_O_method \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[23]) +#define PyUFunc_On_Om \ + (*(void (*)(char **, npy_intp *, npy_intp *, void *)) \ + PyUFunc_API[24]) +#define PyUFunc_GetPyValues \ + (*(int (*)(char *, int *, int *, PyObject **)) \ + PyUFunc_API[25]) +#define PyUFunc_checkfperr \ + (*(int (*)(int, PyObject *, int *)) \ + PyUFunc_API[26]) +#define PyUFunc_clearfperr \ + (*(void (*)(void)) \ + PyUFunc_API[27]) +#define PyUFunc_getfperr \ + (*(int (*)(void)) \ + PyUFunc_API[28]) +#define PyUFunc_handlefperr \ + (*(int (*)(int, PyObject *, int, int *)) \ + PyUFunc_API[29]) +#define PyUFunc_ReplaceLoopBySignature \ + (*(int (*)(PyUFuncObject *, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)) \ + PyUFunc_API[30]) + +static int +_import_umath(void) +{ + PyObject *numpy = PyImport_ImportModule("numpy.core.umath"); + PyObject *c_api = NULL; + + if (numpy == NULL) return -1; + c_api = PyObject_GetAttrString(numpy, "_UFUNC_API"); + if (c_api == NULL) {Py_DECREF(numpy); return -1;} + if (PyCObject_Check(c_api)) { + PyUFunc_API = (void **)PyCObject_AsVoidPtr(c_api); + } + Py_DECREF(c_api); + Py_DECREF(numpy); + if (PyUFunc_API == NULL) return -1; + return 0; +} + +#define import_umath() { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); return; }} + +#define import_umath1(ret) { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); return ret; }} + +#define import_umath2(msg, ret) { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, msg); return ret; }} + +#define import_ufunc() { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); }} + + +#endif Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/__ufunc_api.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/arrayobject.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/arrayobject.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/arrayobject.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,21 @@ + +/* This expects the following variables to be defined (besides + the usual ones from pyconfig.h + + SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no + long double is present on platform. + CHAR_BIT -- number of bits in a char (usually 8) + (should be in limits.h) + +*/ + +#ifndef Py_ARRAYOBJECT_H +#define Py_ARRAYOBJECT_H +#include "ndarrayobject.h" +#ifdef NPY_NO_PREFIX +#include "noprefix.h" +#endif + +#include "npy_interrupt.h" + +#endif Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/arrayobject.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/arrayscalars.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/arrayscalars.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/arrayscalars.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,152 @@ +#ifndef _MULTIARRAYMODULE +typedef struct { + PyObject_HEAD + npy_bool obval; +} PyBoolScalarObject; +#endif + + +typedef struct { + PyObject_HEAD + signed char obval; +} PyByteScalarObject; + + +typedef struct { + PyObject_HEAD + short obval; +} PyShortScalarObject; + + +typedef struct { + PyObject_HEAD + int obval; +} PyIntScalarObject; + + +typedef struct { + PyObject_HEAD + long obval; +} PyLongScalarObject; + + +typedef struct { + PyObject_HEAD + npy_longlong obval; +} PyLongLongScalarObject; + + +typedef struct { + PyObject_HEAD + unsigned char obval; +} PyUByteScalarObject; + + +typedef struct { + PyObject_HEAD + unsigned short obval; +} PyUShortScalarObject; + + +typedef struct { + PyObject_HEAD + unsigned int obval; +} PyUIntScalarObject; + + +typedef struct { + PyObject_HEAD + unsigned long obval; +} PyULongScalarObject; + + +typedef struct { + PyObject_HEAD + npy_ulonglong obval; +} PyULongLongScalarObject; + + +typedef struct { + PyObject_HEAD + float obval; +} PyFloatScalarObject; + + +typedef struct { + PyObject_HEAD + double obval; +} PyDoubleScalarObject; + + +typedef struct { + PyObject_HEAD + npy_longdouble obval; +} PyLongDoubleScalarObject; + + +typedef struct { + PyObject_HEAD + npy_cfloat obval; +} PyCFloatScalarObject; + + +typedef struct { + PyObject_HEAD + npy_cdouble obval; +} PyCDoubleScalarObject; + + +typedef struct { + PyObject_HEAD + npy_clongdouble obval; +} PyCLongDoubleScalarObject; + + +typedef struct { + PyObject_HEAD + PyObject * obval; +} PyObjectScalarObject; + + +typedef struct { + PyObject_HEAD + char obval; +} PyScalarObject; + +#define PyStringScalarObject PyStringObject +#define PyUnicodeScalarObject PyUnicodeObject + +typedef struct { + PyObject_VAR_HEAD + char *obval; + PyArray_Descr *descr; + int flags; + PyObject *base; +} PyVoidScalarObject; + +/* Macros + PyScalarObject + PyArrType_Type + are defined in ndarrayobject.h +*/ + +#define PyArrayScalar_False ((PyObject *)(&(_PyArrayScalar_BoolValues[0]))) +#define PyArrayScalar_True ((PyObject *)(&(_PyArrayScalar_BoolValues[1]))) +#define PyArrayScalar_FromLong(i) \ + ((PyObject *)(&(_PyArrayScalar_BoolValues[((i)!=0)]))) +#define PyArrayScalar_RETURN_BOOL_FROM_LONG(i) \ + return Py_INCREF(PyArrayScalar_FromLong(i)), \ + PyArrayScalar_FromLong(i) +#define PyArrayScalar_RETURN_FALSE \ + return Py_INCREF(PyArrayScalar_False), \ + PyArrayScalar_False +#define PyArrayScalar_RETURN_TRUE \ + return Py_INCREF(PyArrayScalar_True), \ + PyArrayScalar_True + +#define PyArrayScalar_New(cls) \ + Py##cls##ArrType_Type.tp_alloc(&Py##cls##ArrType_Type, 0) +#define PyArrayScalar_VAL(obj, cls) \ + ((Py##cls##ScalarObject *)obj)->obval +#define PyArrayScalar_ASSIGN(obj, cls, val) \ + PyArrayScalar_VAL(obj, cls) = val Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/arrayscalars.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/config.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/config.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/config.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,22 @@ +/* #define SIZEOF_SHORT 2 */ +/* #define SIZEOF_INT 4 */ +/* #define SIZEOF_LONG 4 */ +/* #define SIZEOF_FLOAT 4 */ +/* #define SIZEOF_DOUBLE 8 */ +#define SIZEOF_LONG_DOUBLE 12 +#define SIZEOF_PY_INTPTR_T 4 +/* #define SIZEOF_LONG_LONG 8 */ +#define SIZEOF_PY_LONG_LONG 8 +/* #define CHAR_BIT 8 */ +#define MATHLIB +#define HAVE_FLOAT_FUNCS +#define HAVE_LOG1P +#define HAVE_EXPM1 +#define HAVE_INVERSE_HYPERBOLIC +#define HAVE_INVERSE_HYPERBOLIC_FLOAT +#define HAVE_RINT +#ifdef WITH_THREAD +#define NPY_ALLOW_THREADS 1 +#else +#define NPY_ALLOW_THREADS 0 +#endif Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/config.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/control.py =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/control.py 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/control.py 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,51 @@ +import volumeInput as V +import Segmenter as S +image = V.getFilteredSlice('slice112.raw') +sourceImage = image.copy() +edges, objects = S.Sobel(image) +S.GetShapeMask(edges, objects) +S.GetVoxelMeasures(sourceImage, edges, objects) +S.GetTextureMeasures(sourceImage, edges, objects) + +import volumeInput as V +import Segmenter as S +sourceImage, labeledMask, ROIList = S.SegmentRegions() + + + +image = S.GetSliceFromVolume() +edges, objects = S.Canny(image) + +ShenCastanLow = 0.3 +b = 0.5 +window = 7 +lowThreshold = 220 + 2048 +highThreshold = 600 + 2048 +edges, groups = S.ShenCastan(image, ShenCastanLow, b, window, lowThreshold, highThreshold) + + +import Segmenter as S +image, mask, list = S.SegmentRegions() + + +import Segmenter as S +regionMask, numberRegions = S.GrowRegions() +regionMask.max() + +S.SaveSlice(regionMask, 'regionMask.raw') + +// for display of dumped .raw files using matplotlib + + +import volumeInput as V +rawslice = V.getFilteredSlice("source.raw", bytes=4) +edgeslice = V.getFilteredSlice("labeledMask.raw", bytes=4) + +pylab.figure(1) +pylab.title('raw Image') +pylab.imshow(rawslice) +pylab.figure(3) +pylab.title('Edge Image') +pylab.imshow(edgeslice) + + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/control.py ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/ndImage_Segmenter_structs.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/ndImage_Segmenter_structs.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/ndImage_Segmenter_structs.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,155 @@ +#ifndef V1_STRUCTSH +#define V1_STRUCTSH + +#define bool unsigned char + +typedef struct{ + int x; + int y; +}POINT; + +typedef struct{ + int x; + int y; + int linkIndex; + bool haveLink; +}bPOINT; + +typedef struct{ + int left; + int right; + int top; + int bottom; +}RECT; + +typedef struct{ + char filterName[20]; + float Mean; + float Variance; +}tTEM; + +typedef struct{ + int numberKernels; + int kernelLength; + int numberFilterLayers; + float lawsKernel[6][7]; + char name[7]; +}LawsFilter7; + +typedef struct{ + // filled in GetObjectStats + int L; + int R; + int T; + int B; + int Label; + int Area; + float cX; + float cY; + // filled in BuildBoundary + int curveClose; + float cXBoundary; + float cYBoundary; + float boundaryLength; + float minRadius; + float maxRadius; + float aveRadius; + float ratio; + float compactness; + // filled in VoxelMeasures + float voxelMean; + float voxelVar; + // filled in TextureMeasures + float TEM[20]; +}objStruct; + +typedef struct{ + int numberPoints; + int curveClose; + int classify; + float boundaryLength; + float minRadius; + float maxRadius; + float aveRadius; + float ratio; + float compactness; + float voxelMean; + float voxelVar; + RECT rectangle; + POINT centroid; + bool isWithin; + bool closedCurve; + bool criticalSize; + int Label; +}boundaryIndex; + + +typedef struct{ + POINT xy; +}blobBoundary; + + +// +// prototypes +// +int NI_RegionGrow(int, int, int, int, int, int, int, double *, unsigned short *, int *); +int NI_TextureMeasures(int, int, int, int, double *, unsigned short *, objStruct objectMetrics[]); +int NI_VoxelMeasures(int, int, int, int, double *, unsigned short *, objStruct objectMetrics[]); +int NI_BuildBoundary(int, int, int, int, unsigned short *, objStruct objectMetrics[]); +int NI_GetObjectStats(int, int, int, unsigned short *, objStruct objectMetrics[]); +int NI_ThinFilter(int, int, int, int, unsigned short *, objStruct objectMetrics[]); +int NI_SobelEdges(int, int, int, double, int, int, int, double, int, double *, unsigned short *, int *); +int NI_ShenCastanEdges(int, int, int, double, double, int, int, int, double *, unsigned short *, int *); +int NI_CannyEdges(int, int, int, double, double, double, int, int, int, double, int, + double *, unsigned short *, int *); + +void computeLaws(LawsFilter7, tTEM LawsFeatures[], RECT, int, int, int, int, unsigned char *, float *, + unsigned short *, float *, double *); +float lawsConvolution(float *, float *, float *, int); +void initLaws(LawsFilter7*); +void getVoxelMeasures(objStruct objectMetrics[], double *, unsigned short *, int, int, int); +void getLawsTexture(LawsFilter7, tTEM LawsFeatures[], objStruct objectMetrics[], double *, unsigned short *, int, int, int); + +void morphoFilterBinaryImage(int, int, unsigned short *, int, int); +void buildBinaryImage(int, int, double *, unsigned short *, int, int); +void doRegionGrow(int, int, int, double *, unsigned short *, int, int, int, int); +void buildBoundary(objStruct objectMetrics[], int, unsigned short *, int, int, int); +void getBoundary(unsigned short *, unsigned char *, blobBoundary *, blobBoundary *, + boundaryIndex *, RECT, int, int, int, int, int, int); +void doMorphology(unsigned char *, unsigned char *, unsigned char *, unsigned char *, int olapValuesC[], + int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], + RECT, int, int, int, int); +void getCompactness(unsigned char *, RECT, int, int, float *, float); +void OpenCloseFilter(int olapValues[], int, int, int, int, unsigned char *, + unsigned char *, unsigned short mask[11][11]); +void trackBoundary(unsigned char *, blobBoundary lBoundary[], int, int, blobBoundary, int); +void getBoundaryMetrics(bPOINT *, float *, float *, float *, float *, float, float, int); +void generateMask(unsigned char *, bPOINT *, int, int, int); +void ThinningFilter(int, int, int, int J_mask[3][30], int K_mask[3][30], unsigned char *, + unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *); +void initThinFilter(int J_mask[3][30], int K_mask[3][30]); +void Shen_Castan(double, double, int, int, int, int, int, double *, unsigned short *); +void computeISEF(float *, float *, int, int, double); +void ISEF_Horizontal(float *, float *, float *, float *, int, int, double); +void ISEF_Vertical(float *, float *, float *, float *, int, int, double); +void thresholdImage(float *, float *, int, int, int, int); +void computeBandedLaplacian(float *, float *, float *, int, int); +void getZeroCrossings(float *, float *, float *, int, int, int); +float adaptiveGradient(float *, float *, int, int, int, int); +void thresholdEdges(float *, unsigned short *, double, int, int); +void estimateThreshold(float *, float *, float, int, int, float *); +void doSobel(int, int, int, double, int, double *, unsigned short *); +void DGFilters(int, int, int, double, int, float *, float *, double *, double *, float *, float *); +void nonMaxSupress(int, int, float, float, double *, double *, int, float *, float *, float *); +void edgeHysteresis(int, int, double, double, float *, float *); +void edgeThreshold(int, int, double, float *, float *); +int traceEdge(int, int, int, int, double, float *, float *); +float magnitude(float, float); +int ConnectedEdgePoints(int, int, unsigned short *); +void doPreProcess(int, int, int, double *, double, int, int, int); +void filter2D(int, int, int, int, int, float *, double *); +void buildKernel(double, int, int, float *); + + + +#endif Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/ndImage_Segmenter_structs.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/ndarrayobject.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/ndarrayobject.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/ndarrayobject.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,1995 @@ +/* DON'T INCLUDE THIS DIRECTLY. + */ + +#ifndef NPY_NDARRAYOBJECT_H +#define NPY_NDARRAYOBJECT_H +#ifdef __cplusplus +#define CONFUSE_EMACS { +#define CONFUSE_EMACS2 } +extern "C" CONFUSE_EMACS +#undef CONFUSE_EMACS +#undef CONFUSE_EMACS2 +/* ... otherwise a semi-smart identer (like emacs) tries to indent + everything when you're typing */ +#endif +/* This is auto-generated by the installer */ +#include "config.h" + +/* There are several places in the code where an array of dimensions is + * allocated statically. This is the size of that static allocation. + * + * The array creation itself could have arbitrary dimensions but + * all the places where static allocation is used would need to + * be changed to dynamic (including inside of several structures) + */ + +#define NPY_MAXDIMS 32 +#define NPY_MAXARGS 32 + +/* Used for Converter Functions "O&" code in ParseTuple */ +#define NPY_FAIL 0 +#define NPY_SUCCEED 1 + + /* Helpful to distinguish what is installed */ +#define NPY_VERSION 0x01000009 + + /* Some platforms don't define bool, long long, or long double. + Handle that here. + */ + +#define NPY_BYTE_FMT "hhd" +#define NPY_UBYTE_FMT "hhu" +#define NPY_SHORT_FMT "hd" +#define NPY_USHORT_FMT "hu" +#define NPY_INT_FMT "d" +#define NPY_UINT_FMT "u" +#define NPY_LONG_FMT "ld" +#define NPY_ULONG_FMT "lu" +#define NPY_FLOAT_FMT "g" +#define NPY_DOUBLE_FMT "g" + +#ifdef PY_LONG_LONG +typedef PY_LONG_LONG npy_longlong; +typedef unsigned PY_LONG_LONG npy_ulonglong; +# ifdef _MSC_VER +# define NPY_LONGLONG_FMT "I64d" +# define NPY_ULONGLONG_FMT "I64u" +# define NPY_LONGLONG_SUFFIX(x) (x##i64) +# define NPY_ULONGLONG_SUFFIX(x) (x##Ui64) +# else + /* #define LONGLONG_FMT "lld" Another possible variant + #define ULONGLONG_FMT "llu" + + #define LONGLONG_FMT "qd" -- BSD perhaps? + #define ULONGLONG_FMT "qu" + */ +# define NPY_LONGLONG_FMT "Ld" +# define NPY_ULONGLONG_FMT "Lu" +# define NPY_LONGLONG_SUFFIX(x) (x##LL) +# define NPY_ULONGLONG_SUFFIX(x) (x##ULL) +# endif +#else +typedef long npy_longlong; +typedef unsigned long npy_ulonglong; +# define NPY_LONGLONG_SUFFIX(x) (x##L) +# define NPY_ULONGLONG_SUFFIX(x) (x##UL) +#endif + + +typedef unsigned char npy_bool; +#define NPY_FALSE 0 +#define NPY_TRUE 1 + +#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE + typedef double npy_longdouble; + #define NPY_LONGDOUBLE_FMT "g" +#else + typedef long double npy_longdouble; + #define NPY_LONGDOUBLE_FMT "Lg" +#endif + +#ifndef Py_USING_UNICODE +#error Must use Python with unicode enabled. +#endif + + +typedef signed char npy_byte; +typedef unsigned char npy_ubyte; +typedef unsigned short npy_ushort; +typedef unsigned int npy_uint; +typedef unsigned long npy_ulong; + +/* These are for completeness */ +typedef float npy_float; +typedef double npy_double; +typedef short npy_short; +typedef int npy_int; +typedef long npy_long; + +typedef struct { float real, imag; } npy_cfloat; +typedef struct { double real, imag; } npy_cdouble; +typedef struct {npy_longdouble real, imag;} npy_clongdouble; + +enum NPY_TYPES { NPY_BOOL=0, + NPY_BYTE, NPY_UBYTE, + NPY_SHORT, NPY_USHORT, + NPY_INT, NPY_UINT, + NPY_LONG, NPY_ULONG, + NPY_LONGLONG, NPY_ULONGLONG, + NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE, + NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE, + NPY_OBJECT=17, + NPY_STRING, NPY_UNICODE, + NPY_VOID, + NPY_NTYPES, + NPY_NOTYPE, + NPY_CHAR, /* special flag */ + NPY_USERDEF=256 /* leave room for characters */ +}; + +/* basetype array priority */ +#define NPY_PRIORITY 0.0 + +/* default subtype priority */ +#define NPY_SUBTYPE_PRIORITY 1.0 + +/* default scalar priority */ +#define NPY_SCALAR_PRIORITY -1000000.0 + +/* How many floating point types are there */ +#define NPY_NUM_FLOATTYPE 3 + +/* We need to match npy_intp to a signed integer of the same size as + a pointer variable. npy_uintp to the equivalent unsigned integer +*/ + + +/* These characters correspond to the array type and the + struct module */ + +/* except 'p' -- signed integer for pointer type */ + +enum NPY_TYPECHAR { NPY_BOOLLTR = '?', + NPY_BYTELTR = 'b', + NPY_UBYTELTR = 'B', + NPY_SHORTLTR = 'h', + NPY_USHORTLTR = 'H', + NPY_INTLTR = 'i', + NPY_UINTLTR = 'I', + NPY_LONGLTR = 'l', + NPY_ULONGLTR = 'L', + NPY_LONGLONGLTR = 'q', + NPY_ULONGLONGLTR = 'Q', + NPY_FLOATLTR = 'f', + NPY_DOUBLELTR = 'd', + NPY_LONGDOUBLELTR = 'g', + NPY_CFLOATLTR = 'F', + NPY_CDOUBLELTR = 'D', + NPY_CLONGDOUBLELTR = 'G', + NPY_OBJECTLTR = 'O', + NPY_STRINGLTR = 'S', + NPY_STRINGLTR2 = 'a', + NPY_UNICODELTR = 'U', + NPY_VOIDLTR = 'V', + NPY_CHARLTR = 'c', + + /* No Descriptor, just a define -- this let's + Python users specify an array of integers + large enough to hold a pointer on the platform*/ + NPY_INTPLTR = 'p', + NPY_UINTPLTR = 'P', + + NPY_GENBOOLLTR ='b', + NPY_SIGNEDLTR = 'i', + NPY_UNSIGNEDLTR = 'u', + NPY_FLOATINGLTR = 'f', + NPY_COMPLEXLTR = 'c' +}; + +typedef enum { + NPY_QUICKSORT=0, + NPY_HEAPSORT=1, + NPY_MERGESORT=2, +} NPY_SORTKIND; +#define NPY_NSORTS (NPY_MERGESORT + 1) + + +typedef enum { + NPY_SEARCHLEFT=0, + NPY_SEARCHRIGHT=1, +} NPY_SEARCHSIDE; +#define NPY_NSEARCHSIDES (NPY_SEARCHRIGHT + 1) + + +typedef enum { + NPY_NOSCALAR=-1, + NPY_BOOL_SCALAR, + NPY_INTPOS_SCALAR, + NPY_INTNEG_SCALAR, + NPY_FLOAT_SCALAR, + NPY_COMPLEX_SCALAR, + NPY_OBJECT_SCALAR, +} NPY_SCALARKIND; +#define NPY_NSCALARKINDS (NPY_OBJECT_SCALAR + 1) + +typedef enum { + NPY_ANYORDER=-1, + NPY_CORDER=0, + NPY_FORTRANORDER=1 +} NPY_ORDER; + + +typedef enum { + NPY_CLIP=0, + NPY_WRAP=1, + NPY_RAISE=2 +} NPY_CLIPMODE; + + /* Define bit-width array types and typedefs */ + +#define NPY_MAX_INT8 127 +#define NPY_MIN_INT8 -128 +#define NPY_MAX_UINT8 255 +#define NPY_MAX_INT16 32767 +#define NPY_MIN_INT16 -32768 +#define NPY_MAX_UINT16 65535 +#define NPY_MAX_INT32 2147483647 +#define NPY_MIN_INT32 (-NPY_MAX_INT32 - 1) +#define NPY_MAX_UINT32 4294967295U +#define NPY_MAX_INT64 NPY_LONGLONG_SUFFIX(9223372036854775807) +#define NPY_MIN_INT64 (-NPY_MAX_INT64 - NPY_LONGLONG_SUFFIX(1)) +#define NPY_MAX_UINT64 NPY_ULONGLONG_SUFFIX(18446744073709551615) +#define NPY_MAX_INT128 NPY_LONGLONG_SUFFIX(85070591730234615865843651857942052864) +#define NPY_MIN_INT128 (-NPY_MAX_INT128 - NPY_LONGLONG_SUFFIX(1)) +#define NPY_MAX_UINT128 NPY_ULONGLONG_SUFFIX(170141183460469231731687303715884105728) +#define NPY_MAX_INT256 NPY_LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967) +#define NPY_MIN_INT256 (-NPY_MAX_INT256 - NPY_LONGLONG_SUFFIX(1)) +#define NPY_MAX_UINT256 NPY_ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935) + + /* Need to find the number of bits for each type and + make definitions accordingly. + + C states that sizeof(char) == 1 by definition + + So, just using the sizeof keyword won't help. + + It also looks like Python itself uses sizeof(char) quite a + bit, which by definition should be 1 all the time. + + Idea: Make Use of CHAR_BIT which should tell us how many + BITS per CHARACTER + */ + + /* Include platform definitions -- These are in the C89/90 standard */ +#include +#define NPY_MAX_BYTE SCHAR_MAX +#define NPY_MIN_BYTE SCHAR_MIN +#define NPY_MAX_UBYTE UCHAR_MAX +#define NPY_MAX_SHORT SHRT_MAX +#define NPY_MIN_SHORT SHRT_MIN +#define NPY_MAX_USHORT USHRT_MAX +#define NPY_MAX_INT INT_MAX +#ifndef INT_MIN +#define INT_MIN (-INT_MAX - 1) +#endif +#define NPY_MIN_INT INT_MIN +#define NPY_MAX_UINT UINT_MAX +#define NPY_MAX_LONG LONG_MAX +#define NPY_MIN_LONG LONG_MIN +#define NPY_MAX_ULONG ULONG_MAX + + +#define NPY_SIZEOF_LONG SIZEOF_LONG +#define NPY_SIZEOF_INT SIZEOF_INT +#define NPY_SIZEOF_SHORT SIZEOF_SHORT +#define NPY_SIZEOF_FLOAT SIZEOF_FLOAT +#define NPY_SIZEOF_DOUBLE SIZEOF_DOUBLE +#define NPY_SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE +#define NPY_SIZEOF_LONGLONG SIZEOF_LONG_LONG +#define NPY_BITSOF_BOOL (sizeof(npy_bool)*CHAR_BIT) +#define NPY_BITSOF_CHAR CHAR_BIT +#define NPY_BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT) +#define NPY_BITSOF_INT (SIZEOF_INT*CHAR_BIT) +#define NPY_BITSOF_LONG (SIZEOF_LONG*CHAR_BIT) +#define NPY_BITSOF_LONGLONG (NPY_SIZEOF_LONGLONG*CHAR_BIT) +#define NPY_BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT) +#define NPY_BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT) +#define NPY_BITSOF_LONGDOUBLE (NPY_SIZEOF_LONGDOUBLE*CHAR_BIT) + +#if NPY_BITSOF_LONG == 8 +#define NPY_INT8 NPY_LONG +#define NPY_UINT8 NPY_ULONG + typedef long npy_int8; + typedef unsigned long npy_uint8; +#define PyInt8ScalarObject PyLongScalarObject +#define PyInt8ArrType_Type PyLongArrType_Type +#define PyUInt8ScalarObject PyULongScalarObject +#define PyUInt8ArrType_Type PyULongArrType_Type +#define NPY_INT8_FMT NPY_LONG_FMT +#define NPY_UINT8_FMT NPY_ULONG_FMT +#elif NPY_BITSOF_LONG == 16 +#define NPY_INT16 NPY_LONG +#define NPY_UINT16 NPY_ULONG + typedef long npy_int16; + typedef unsigned long npy_uint16; +#define PyInt16ScalarObject PyLongScalarObject +#define PyInt16ArrType_Type PyLongArrType_Type +#define PyUInt16ScalarObject PyULongScalarObject +#define PyUInt16ArrType_Type PyULongArrType_Type +#define NPY_INT16_FMT NPY_LONG_FMT +#define NPY_UINT16_FMT NPY_ULONG_FMT +#elif NPY_BITSOF_LONG == 32 +#define NPY_INT32 NPY_LONG +#define NPY_UINT32 NPY_ULONG + typedef long npy_int32; + typedef unsigned long npy_uint32; + typedef unsigned long npy_ucs4; +#define PyInt32ScalarObject PyLongScalarObject +#define PyInt32ArrType_Type PyLongArrType_Type +#define PyUInt32ScalarObject PyULongScalarObject +#define PyUInt32ArrType_Type PyULongArrType_Type +#define NPY_INT32_FMT NPY_LONG_FMT +#define NPY_UINT32_FMT NPY_ULONG_FMT +#elif NPY_BITSOF_LONG == 64 +#define NPY_INT64 NPY_LONG +#define NPY_UINT64 NPY_ULONG + typedef long npy_int64; + typedef unsigned long npy_uint64; +#define PyInt64ScalarObject PyLongScalarObject +#define PyInt64ArrType_Type PyLongArrType_Type +#define PyUInt64ScalarObject PyULongScalarObject +#define PyUInt64ArrType_Type PyULongArrType_Type +#define NPY_INT64_FMT NPY_LONG_FMT +#define NPY_UINT64_FMT NPY_ULONG_FMT +#elif NPY_BITSOF_LONG == 128 +#define NPY_INT128 NPY_LONG +#define NPY_UINT128 NPY_ULONG + typedef long npy_int128; + typedef unsigned long npy_uint128; +#define PyInt128ScalarObject PyLongScalarObject +#define PyInt128ArrType_Type PyLongArrType_Type +#define PyUInt128ScalarObject PyULongScalarObject +#define PyUInt128ArrType_Type PyULongArrType_Type +#define NPY_INT128_FMT NPY_LONG_FMT +#define NPY_UINT128_FMT NPY_ULONG_FMT +#endif + +#if NPY_BITSOF_LONGLONG == 8 +# ifndef NPY_INT8 +# define NPY_INT8 NPY_LONGLONG +# define NPY_UINT8 NPY_ULONGLONG + typedef npy_longlong npy_int8; + typedef npy_ulonglong npy_uint8; +# define PyInt8ScalarObject PyLongLongScalarObject +# define PyInt8ArrType_Type PyLongLongArrType_Type +# define PyUInt8ScalarObject PyULongLongScalarObject +# define PyUInt8ArrType_Type PyULongLongArrType_Type +#define NPY_INT8_FMT NPY_LONGLONG_FMT +#define NPY_UINT8_FMT NPY_ULONGLONG_FMT +# endif +# define NPY_MAX_LONGLONG NPY_MAX_INT8 +# define NPY_MIN_LONGLONG NPY_MIN_INT8 +# define NPY_MAX_ULONGLONG NPY_MAX_UINT8 +#elif NPY_BITSOF_LONGLONG == 16 +# ifndef NPY_INT16 +# define NPY_INT16 NPY_LONGLONG +# define NPY_UINT16 NPY_ULONGLONG + typedef npy_longlong npy_int16; + typedef npy_ulonglong npy_uint16; +# define PyInt16ScalarObject PyLongLongScalarObject +# define PyInt16ArrType_Type PyLongLongArrType_Type +# define PyUInt16ScalarObject PyULongLongScalarObject +# define PyUInt16ArrType_Type PyULongLongArrType_Type +#define NPY_INT16_FMT NPY_LONGLONG_FMT +#define NPY_UINT16_FMT NPY_ULONGLONG_FMT +# endif +# define NPY_MAX_LONGLONG NPY_MAX_INT16 +# define NPY_MIN_LONGLONG NPY_MIN_INT16 +# define NPY_MAX_ULONGLONG NPY_MAX_UINT16 +#elif NPY_BITSOF_LONGLONG == 32 +# ifndef NPY_INT32 +# define NPY_INT32 NPY_LONGLONG +# define NPY_UINT32 NPY_ULONGLONG + typedef npy_longlong npy_int32; + typedef npy_ulonglong npy_uint32; + typedef npy_ulonglong npy_ucs4; +# define PyInt32ScalarObject PyLongLongScalarObject +# define PyInt32ArrType_Type PyLongLongArrType_Type +# define PyUInt32ScalarObject PyULongLongScalarObject +# define PyUInt32ArrType_Type PyULongLongArrType_Type +#define NPY_INT32_FMT NPY_LONGLONG_FMT +#define NPY_UINT32_FMT NPY_ULONGLONG_FMT +# endif +# define NPY_MAX_LONGLONG NPY_MAX_INT32 +# define NPY_MIN_LONGLONG NPY_MIN_INT32 +# define NPY_MAX_ULONGLONG NPY_MAX_UINT32 +#elif NPY_BITSOF_LONGLONG == 64 +# ifndef NPY_INT64 +# define NPY_INT64 NPY_LONGLONG +# define NPY_UINT64 NPY_ULONGLONG + typedef npy_longlong npy_int64; + typedef npy_ulonglong npy_uint64; +# define PyInt64ScalarObject PyLongLongScalarObject +# define PyInt64ArrType_Type PyLongLongArrType_Type +# define PyUInt64ScalarObject PyULongLongScalarObject +# define PyUInt64ArrType_Type PyULongLongArrType_Type +#define NPY_INT64_FMT NPY_LONGLONG_FMT +#define NPY_UINT64_FMT NPY_ULONGLONG_FMT +# endif +# define NPY_MAX_LONGLONG NPY_MAX_INT64 +# define NPY_MIN_LONGLONG NPY_MIN_INT64 +# define NPY_MAX_ULONGLONG NPY_MAX_UINT64 +#elif NPY_BITSOF_LONGLONG == 128 +# ifndef NPY_INT128 +# define NPY_INT128 NPY_LONGLONG +# define NPY_UINT128 NPY_ULONGLONG + typedef npy_longlong npy_int128; + typedef npy_ulonglong npy_uint128; +# define PyInt128ScalarObject PyLongLongScalarObject +# define PyInt128ArrType_Type PyLongLongArrType_Type +# define PyUInt128ScalarObject PyULongLongScalarObject +# define PyUInt128ArrType_Type PyULongLongArrType_Type +#define NPY_INT128_FMT NPY_LONGLONG_FMT +#define NPY_UINT128_FMT NPY_ULONGLONG_FMT +# endif +# define NPY_MAX_LONGLONG NPY_MAX_INT128 +# define NPY_MIN_LONGLONG NPY_MIN_INT128 +# define NPY_MAX_ULONGLONG NPY_MAX_UINT128 +#elif NPY_BITSOF_LONGLONG == 256 +# define NPY_INT256 NPY_LONGLONG +# define NPY_UINT256 NPY_ULONGLONG + typedef npy_longlong npy_int256; + typedef npy_ulonglong npy_uint256; +# define PyInt256ScalarObject PyLongLongScalarObject +# define PyInt256ArrType_Type PyLongLongArrType_Type +# define PyUInt256ScalarObject PyULongLongScalarObject +# define PyUInt256ArrType_Type PyULongLongArrType_Type +#define NPY_INT256_FMT NPY_LONGLONG_FMT +#define NPY_UINT256_FMT NPY_ULONGLONG_FMT +# define NPY_MAX_LONGLONG NPY_MAX_INT256 +# define NPY_MIN_LONGLONG NPY_MIN_INT256 +# define NPY_MAX_ULONGLONG NPY_MAX_UINT256 +#endif + +#if NPY_BITSOF_INT == 8 +#ifndef NPY_INT8 +#define NPY_INT8 NPY_INT +#define NPY_UINT8 NPY_UINT + typedef int npy_int8; + typedef unsigned int npy_uint8; +# define PyInt8ScalarObject PyIntScalarObject +# define PyInt8ArrType_Type PyIntArrType_Type +# define PyUInt8ScalarObject PyUIntScalarObject +# define PyUInt8ArrType_Type PyUIntArrType_Type +#define NPY_INT8_FMT NPY_INT_FMT +#define NPY_UINT8_FMT NPY_UINT_FMT +#endif +#elif NPY_BITSOF_INT == 16 +#ifndef NPY_INT16 +#define NPY_INT16 NPY_INT +#define NPY_UINT16 NPY_UINT + typedef int npy_int16; + typedef unsigned int npy_uint16; +# define PyInt16ScalarObject PyIntScalarObject +# define PyInt16ArrType_Type PyIntArrType_Type +# define PyUInt16ScalarObject PyIntUScalarObject +# define PyUInt16ArrType_Type PyIntUArrType_Type +#define NPY_INT16_FMT NPY_INT_FMT +#define NPY_UINT16_FMT NPY_UINT_FMT +#endif +#elif NPY_BITSOF_INT == 32 +#ifndef NPY_INT32 +#define NPY_INT32 NPY_INT +#define NPY_UINT32 NPY_UINT + typedef int npy_int32; + typedef unsigned int npy_uint32; + typedef unsigned int npy_ucs4; +# define PyInt32ScalarObject PyIntScalarObject +# define PyInt32ArrType_Type PyIntArrType_Type +# define PyUInt32ScalarObject PyUIntScalarObject +# define PyUInt32ArrType_Type PyUIntArrType_Type +#define NPY_INT32_FMT NPY_INT_FMT +#define NPY_UINT32_FMT NPY_UINT_FMT +#endif +#elif NPY_BITSOF_INT == 64 +#ifndef NPY_INT64 +#define NPY_INT64 NPY_INT +#define NPY_UINT64 NPY_UINT + typedef int npy_int64; + typedef unsigned int npy_uint64; +# define PyInt64ScalarObject PyIntScalarObject +# define PyInt64ArrType_Type PyIntArrType_Type +# define PyUInt64ScalarObject PyUIntScalarObject +# define PyUInt64ArrType_Type PyUIntArrType_Type +#define NPY_INT64_FMT NPY_INT_FMT +#define NPY_UINT64_FMT NPY_UINT_FMT +#endif +#elif NPY_BITSOF_INT == 128 +#ifndef NPY_INT128 +#define NPY_INT128 NPY_INT +#define NPY_UINT128 NPY_UINT + typedef int npy_int128; + typedef unsigned int npy_uint128; +# define PyInt128ScalarObject PyIntScalarObject +# define PyInt128ArrType_Type PyIntArrType_Type +# define PyUInt128ScalarObject PyUIntScalarObject +# define PyUInt128ArrType_Type PyUIntArrType_Type +#define NPY_INT128_FMT NPY_INT_FMT +#define NPY_UINT128_FMT NPY_UINT_FMT +#endif +#endif + +#if NPY_BITSOF_SHORT == 8 +#ifndef NPY_INT8 +#define NPY_INT8 NPY_SHORT +#define NPY_UINT8 NPY_USHORT + typedef short npy_int8; + typedef unsigned short npy_uint8; +# define PyInt8ScalarObject PyShortScalarObject +# define PyInt8ArrType_Type PyShortArrType_Type +# define PyUInt8ScalarObject PyUShortScalarObject +# define PyUInt8ArrType_Type PyUShortArrType_Type +#define NPY_INT8_FMT NPY_SHORT_FMT +#define NPY_UINT8_FMT NPY_USHORT_FMT +#endif +#elif NPY_BITSOF_SHORT == 16 +#ifndef NPY_INT16 +#define NPY_INT16 NPY_SHORT +#define NPY_UINT16 NPY_USHORT + typedef short npy_int16; + typedef unsigned short npy_uint16; +# define PyInt16ScalarObject PyShortScalarObject +# define PyInt16ArrType_Type PyShortArrType_Type +# define PyUInt16ScalarObject PyUShortScalarObject +# define PyUInt16ArrType_Type PyUShortArrType_Type +#define NPY_INT16_FMT NPY_SHORT_FMT +#define NPY_UINT16_FMT NPY_USHORT_FMT +#endif +#elif NPY_BITSOF_SHORT == 32 +#ifndef NPY_INT32 +#define NPY_INT32 NPY_SHORT +#define NPY_UINT32 NPY_USHORT + typedef short npy_int32; + typedef unsigned short npy_uint32; + typedef unsigned short npy_ucs4; +# define PyInt32ScalarObject PyShortScalarObject +# define PyInt32ArrType_Type PyShortArrType_Type +# define PyUInt32ScalarObject PyUShortScalarObject +# define PyUInt32ArrType_Type PyUShortArrType_Type +#define NPY_INT32_FMT NPY_SHORT_FMT +#define NPY_UINT32_FMT NPY_USHORT_FMT +#endif +#elif NPY_BITSOF_SHORT == 64 +#ifndef NPY_INT64 +#define NPY_INT64 NPY_SHORT +#define NPY_UINT64 NPY_USHORT + typedef short npy_int64; + typedef unsigned short npy_uint64; +# define PyInt64ScalarObject PyShortScalarObject +# define PyInt64ArrType_Type PyShortArrType_Type +# define PyUInt64ScalarObject PyUShortScalarObject +# define PyUInt64ArrType_Type PyUShortArrType_Type +#define NPY_INT64_FMT NPY_SHORT_FMT +#define NPY_UINT64_FMT NPY_USHORT_FMT +#endif +#elif NPY_BITSOF_SHORT == 128 +#ifndef NPY_INT128 +#define NPY_INT128 NPY_SHORT +#define NPY_UINT128 NPY_USHORT + typedef short npy_int128; + typedef unsigned short npy_uint128; +# define PyInt128ScalarObject PyShortScalarObject +# define PyInt128ArrType_Type PyShortArrType_Type +# define PyUInt128ScalarObject PyUShortScalarObject +# define PyUInt128ArrType_Type PyUShortArrType_Type +#define NPY_INT128_FMT NPY_SHORT_FMT +#define NPY_UINT128_FMT NPY_USHORT_FMT +#endif +#endif + + +#if NPY_BITSOF_CHAR == 8 +#ifndef NPY_INT8 +#define NPY_INT8 NPY_BYTE +#define NPY_UINT8 NPY_UBYTE + typedef signed char npy_int8; + typedef unsigned char npy_uint8; +# define PyInt8ScalarObject PyByteScalarObject +# define PyInt8ArrType_Type PyByteArrType_Type +# define PyUInt8ScalarObject PyUByteScalarObject +# define PyUInt8ArrType_Type PyUByteArrType_Type +#define NPY_INT8_FMT NPY_BYTE_FMT +#define NPY_UINT8_FMT NPY_UBYTE_FMT +#endif +#elif NPY_BITSOF_CHAR == 16 +#ifndef NPY_INT16 +#define NPY_INT16 NPY_BYTE +#define NPY_UINT16 NPY_UBYTE + typedef signed char npy_int16; + typedef unsigned char npy_uint16; +# define PyInt16ScalarObject PyByteScalarObject +# define PyInt16ArrType_Type PyByteArrType_Type +# define PyUInt16ScalarObject PyUByteScalarObject +# define PyUInt16ArrType_Type PyUByteArrType_Type +#define NPY_INT16_FMT NPY_BYTE_FMT +#define NPY_UINT16_FMT NPY_UBYTE_FMT +#endif +#elif NPY_BITSOF_CHAR == 32 +#ifndef NPY_INT32 +#define NPY_INT32 NPY_BYTE +#define NPY_UINT32 NPY_UBYTE + typedef signed char npy_int32; + typedef unsigned char npy_uint32; + typedef unsigned char npy_ucs4; +# define PyInt32ScalarObject PyByteScalarObject +# define PyInt32ArrType_Type PyByteArrType_Type +# define PyUInt32ScalarObject PyUByteScalarObject +# define PyUInt32ArrType_Type PyUByteArrType_Type +#define NPY_INT32_FMT NPY_BYTE_FMT +#define NPY_UINT32_FMT NPY_UBYTE_FMT +#endif +#elif NPY_BITSOF_CHAR == 64 +#ifndef NPY_INT64 +#define NPY_INT64 NPY_BYTE +#define NPY_UINT64 NPY_UBYTE + typedef signed char npy_int64; + typedef unsigned char npy_uint64; +# define PyInt64ScalarObject PyByteScalarObject +# define PyInt64ArrType_Type PyByteArrType_Type +# define PyUInt64ScalarObject PyUByteScalarObject +# define PyUInt64ArrType_Type PyUByteArrType_Type +#define NPY_INT64_FMT NPY_BYTE_FMT +#define NPY_UINT64_FMT NPY_UBYTE_FMT +#endif +#elif NPY_BITSOF_CHAR == 128 +#ifndef NPY_INT128 +#define NPY_INT128 NPY_BYTE +#define NPY_UINT128 NPY_UBYTE + typedef signed char npy_int128; + typedef unsigned char npy_uint128; +# define PyInt128ScalarObject PyByteScalarObject +# define PyInt128ArrType_Type PyByteArrType_Type +# define PyUInt128ScalarObject PyUByteScalarObject +# define PyUInt128ArrType_Type PyUByteArrType_Type +#define NPY_INT128_FMT NPY_BYTE_FMT +#define NPY_UINT128_FMT NPY_UBYTE_FMT +#endif +#endif + + + +#if NPY_BITSOF_DOUBLE == 16 +#ifndef NPY_FLOAT16 +#define NPY_FLOAT16 NPY_DOUBLE +#define NPY_COMPLEX32 NPY_CDOUBLE + typedef double npy_float16; + typedef npy_cdouble npy_complex32; +# define PyFloat16ScalarObject PyDoubleScalarObject +# define PyComplex32ScalarObject PyCDoubleScalarObject +# define PyFloat16ArrType_Type PyDoubleArrType_Type +# define PyComplex32ArrType_Type PyCDoubleArrType_Type +#define NPY_FLOAT16_FMT NPY_DOUBLE_FMT +#define NPY_COMPLEX32_FMT NPY_CDOUBLE_FMT +#endif +#elif NPY_BITSOF_DOUBLE == 32 +#ifndef NPY_FLOAT32 +#define NPY_FLOAT32 NPY_DOUBLE +#define NPY_COMPLEX64 NPY_CDOUBLE + typedef double npy_float32; + typedef npy_cdouble npy_complex64; +# define PyFloat32ScalarObject PyDoubleScalarObject +# define PyComplex64ScalarObject PyCDoubleScalarObject +# define PyFloat32ArrType_Type PyDoubleArrType_Type +# define PyComplex64ArrType_Type PyCDoubleArrType_Type +#define NPY_FLOAT32_FMT NPY_DOUBLE_FMT +#define NPY_COMPLEX64_FMT NPY_CDOUBLE_FMT +#endif +#elif NPY_BITSOF_DOUBLE == 64 +#ifndef NPY_FLOAT64 +#define NPY_FLOAT64 NPY_DOUBLE +#define NPY_COMPLEX128 NPY_CDOUBLE + typedef double npy_float64; + typedef npy_cdouble npy_complex128; +# define PyFloat64ScalarObject PyDoubleScalarObject +# define PyComplex128ScalarObject PyCDoubleScalarObject +# define PyFloat64ArrType_Type PyDoubleArrType_Type +# define PyComplex128ArrType_Type PyCDoubleArrType_Type +#define NPY_FLOAT64_FMT NPY_DOUBLE_FMT +#define NPY_COMPLEX128_FMT NPY_CDOUBLE_FMT +#endif +#elif NPY_BITSOF_DOUBLE == 80 +#ifndef NPY_FLOAT80 +#define NPY_FLOAT80 NPY_DOUBLE +#define NPY_COMPLEX160 NPY_CDOUBLE + typedef double npy_float80; + typedef npy_cdouble npy_complex160; +# define PyFloat80ScalarObject PyDoubleScalarObject +# define PyComplex160ScalarObject PyCDoubleScalarObject +# define PyFloat80ArrType_Type PyDoubleArrType_Type +# define PyComplex160ArrType_Type PyCDoubleArrType_Type +#define NPY_FLOAT80_FMT NPY_DOUBLE_FMT +#define NPY_COMPLEX160_FMT NPY_CDOUBLE_FMT +#endif +#elif NPY_BITSOF_DOUBLE == 96 +#ifndef NPY_FLOAT96 +#define NPY_FLOAT96 NPY_DOUBLE +#define NPY_COMPLEX192 NPY_CDOUBLE + typedef double npy_float96; + typedef npy_cdouble npy_complex192; +# define PyFloat96ScalarObject PyDoubleScalarObject +# define PyComplex192ScalarObject PyCDoubleScalarObject +# define PyFloat96ArrType_Type PyDoubleArrType_Type +# define PyComplex192ArrType_Type PyCDoubleArrType_Type +#define NPY_FLOAT96_FMT NPY_DOUBLE_FMT +#define NPY_COMPLEX192_FMT NPY_CDOUBLE_FMT +#endif +#elif NPY_BITSOF_DOUBLE == 128 +#ifndef NPY_FLOAT128 +#define NPY_FLOAT128 NPY_DOUBLE +#define NPY_COMPLEX256 NPY_CDOUBLE + typedef double npy_float128; + typedef npy_cdouble npy_complex256; +# define PyFloat128ScalarObject PyDoubleScalarObject +# define PyComplex256ScalarObject PyCDoubleScalarObject +# define PyFloat128ArrType_Type PyDoubleArrType_Type +# define PyComplex256ArrType_Type PyCDoubleArrType_Type +#define NPY_FLOAT128_FMT NPY_DOUBLE_FMT +#define NPY_COMPLEX256_FMT NPY_CDOUBLE_FMT +#endif +#endif + + + +#if NPY_BITSOF_FLOAT == 16 +#ifndef NPY_FLOAT16 +#define NPY_FLOAT16 NPY_FLOAT +#define NPY_COMPLEX32 NPY_CFLOAT + typedef float npy_float16; + typedef npy_cfloat npy_complex32; +# define PyFloat16ScalarObject PyFloatScalarObject +# define PyComplex32ScalarObject PyCFloatScalarObject +# define PyFloat16ArrType_Type PyFloatArrType_Type +# define PyComplex32ArrType_Type PyCFloatArrType_Type +#define NPY_FLOAT16_FMT NPY_FLOAT_FMT +#define NPY_COMPLEX32_FMT NPY_CFLOAT_FMT +#endif +#elif NPY_BITSOF_FLOAT == 32 +#ifndef NPY_FLOAT32 +#define NPY_FLOAT32 NPY_FLOAT +#define NPY_COMPLEX64 NPY_CFLOAT + typedef float npy_float32; + typedef npy_cfloat npy_complex64; +# define PyFloat32ScalarObject PyFloatScalarObject +# define PyComplex64ScalarObject PyCFloatScalarObject +# define PyFloat32ArrType_Type PyFloatArrType_Type +# define PyComplex64ArrType_Type PyCFloatArrType_Type +#define NPY_FLOAT32_FMT NPY_FLOAT_FMT +#define NPY_COMPLEX64_FMT NPY_CFLOAT_FMT +#endif +#elif NPY_BITSOF_FLOAT == 64 +#ifndef NPY_FLOAT64 +#define NPY_FLOAT64 NPY_FLOAT +#define NPY_COMPLEX128 NPY_CFLOAT + typedef float npy_float64; + typedef npy_cfloat npy_complex128; +# define PyFloat64ScalarObject PyFloatScalarObject +# define PyComplex128ScalarObject PyCFloatScalarObject +# define PyFloat64ArrType_Type PyFloatArrType_Type +# define PyComplex128ArrType_Type PyCFloatArrType_Type +#define NPY_FLOAT64_FMT NPY_FLOAT_FMT +#define NPY_COMPLEX128_FMT NPY_CFLOAT_FMT +#endif +#elif NPY_BITSOF_FLOAT == 80 +#ifndef NPY_FLOAT80 +#define NPY_FLOAT80 NPY_FLOAT +#define NPY_COMPLEX160 NPY_CFLOAT + typedef float npy_float80; + typedef npy_cfloat npy_complex160; +# define PyFloat80ScalarObject PyFloatScalarObject +# define PyComplex160ScalarObject PyCFloatScalarObject +# define PyFloat80ArrType_Type PyFloatArrType_Type +# define PyComplex160ArrType_Type PyCFloatArrType_Type +#define NPY_FLOAT80_FMT NPY_FLOAT_FMT +#define NPY_COMPLEX160_FMT NPY_CFLOAT_FMT +#endif +#elif NPY_BITSOF_FLOAT == 96 +#ifndef NPY_FLOAT96 +#define NPY_FLOAT96 NPY_FLOAT +#define NPY_COMPLEX192 NPY_CFLOAT + typedef float npy_float96; + typedef npy_cfloat npy_complex192; +# define PyFloat96ScalarObject PyFloatScalarObject +# define PyComplex192ScalarObject PyCFloatScalarObject +# define PyFloat96ArrType_Type PyFloatArrType_Type +# define PyComplex192ArrType_Type PyCFloatArrType_Type +#define NPY_FLOAT96_FMT NPY_FLOAT_FMT +#define NPY_COMPLEX192_FMT NPY_CFLOAT_FMT +#endif +#elif NPY_BITSOF_FLOAT == 128 +#ifndef NPY_FLOAT128 +#define NPY_FLOAT128 NPY_FLOAT +#define NPY_COMPLEX256 NPY_CFLOAT + typedef float npy_float128; + typedef npy_cfloat npy_complex256; +# define PyFloat128ScalarObject PyFloatScalarObject +# define PyComplex256ScalarObject PyCFloatScalarObject +# define PyFloat128ArrType_Type PyFloatArrType_Type +# define PyComplex256ArrType_Type PyCFloatArrType_Type +#define NPY_FLOAT128_FMT NPY_FLOAT_FMT +#define NPY_COMPLEX256_FMT NPY_CFLOAT_FMT +#endif +#endif + + +#if NPY_BITSOF_LONGDOUBLE == 16 +#ifndef NPY_FLOAT16 +#define NPY_FLOAT16 NPY_LONGDOUBLE +#define NPY_COMPLEX32 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float16; + typedef npy_clongdouble npy_complex32; +# define PyFloat16ScalarObject PyLongDoubleScalarObject +# define PyComplex32ScalarObject PyCLongDoubleScalarObject +# define PyFloat16ArrType_Type PyLongDoubleArrType_Type +# define PyComplex32ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT16_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX32_FMT NPY_CLONGDOUBLE_FMT +#endif +#elif NPY_BITSOF_LONGDOUBLE == 32 +#ifndef NPY_FLOAT32 +#define NPY_FLOAT32 NPY_LONGDOUBLE +#define NPY_COMPLEX64 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float32; + typedef npy_clongdouble npy_complex64; +# define PyFloat32ScalarObject PyLongDoubleScalarObject +# define PyComplex64ScalarObject PyCLongDoubleScalarObject +# define PyFloat32ArrType_Type PyLongDoubleArrType_Type +# define PyComplex64ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT32_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX64_FMT NPY_CLONGDOUBLE_FMT +#endif +#elif NPY_BITSOF_LONGDOUBLE == 64 +#ifndef NPY_FLOAT64 +#define NPY_FLOAT64 NPY_LONGDOUBLE +#define NPY_COMPLEX128 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float64; + typedef npy_clongdouble npy_complex128; +# define PyFloat64ScalarObject PyLongDoubleScalarObject +# define PyComplex128ScalarObject PyCLongDoubleScalarObject +# define PyFloat64ArrType_Type PyLongDoubleArrType_Type +# define PyComplex128ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT64_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX128_FMT NPY_CLONGDOUBLE_FMT +#endif +#elif NPY_BITSOF_LONGDOUBLE == 80 +#ifndef NPY_FLOAT80 +#define NPY_FLOAT80 NPY_LONGDOUBLE +#define NPY_COMPLEX160 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float80; + typedef npy_clongdouble npy_complex160; +# define PyFloat80ScalarObject PyLongDoubleScalarObject +# define PyComplex160ScalarObject PyCLongDoubleScalarObject +# define PyFloat80ArrType_Type PyLongDoubleArrType_Type +# define PyComplex160ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT80_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX160_FMT NPY_CLONGDOUBLE_FMT +#endif +#elif NPY_BITSOF_LONGDOUBLE == 96 +#ifndef NPY_FLOAT96 +#define NPY_FLOAT96 NPY_LONGDOUBLE +#define NPY_COMPLEX192 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float96; + typedef npy_clongdouble npy_complex192; +# define PyFloat96ScalarObject PyLongDoubleScalarObject +# define PyComplex192ScalarObject PyCLongDoubleScalarObject +# define PyFloat96ArrType_Type PyLongDoubleArrType_Type +# define PyComplex192ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT96_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX192_FMT NPY_CLONGDOUBLE_FMT +#endif +#elif NPY_BITSOF_LONGDOUBLE == 128 +#ifndef NPY_FLOAT128 +#define NPY_FLOAT128 NPY_LONGDOUBLE +#define NPY_COMPLEX256 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float128; + typedef npy_clongdouble npy_complex256; +# define PyFloat128ScalarObject PyLongDoubleScalarObject +# define PyComplex256ScalarObject PyCLongDoubleScalarObject +# define PyFloat128ArrType_Type PyLongDoubleArrType_Type +# define PyComplex256ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT128_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX256_FMT NPY_CLONGDOUBLE_FMT +#endif +#elif NPY_BITSOF_LONGDOUBLE == 256 +#define NPY_FLOAT256 NPY_LONGDOUBLE +#define NPY_COMPLEX512 NPY_CLONGDOUBLE + typedef npy_longdouble npy_float256; + typedef npy_clongdouble npy_complex512; +# define PyFloat256ScalarObject PyLongDoubleScalarObject +# define PyComplex512ScalarObject PyCLongDoubleScalarObject +# define PyFloat256ArrType_Type PyLongDoubleArrType_Type +# define PyComplex512ArrType_Type PyCLongDoubleArrType_Type +#define NPY_FLOAT256_FMT NPY_LONGDOUBLE_FMT +#define NPY_COMPLEX512_FMT NPY_CLONGDOUBLE_FMT +#endif + +/* End of typedefs for numarray style bit-width names */ + +/* This is to typedef npy_intp to the appropriate pointer size for this + * platform. Py_intptr_t, Py_uintptr_t are defined in pyport.h. */ +typedef Py_intptr_t npy_intp; +typedef Py_uintptr_t npy_uintp; +#define NPY_SIZEOF_INTP SIZEOF_PY_INTPTR_T +#define NPY_SIZEOF_UINTP SIZEOF_PY_INTPTR_T + +#ifdef constchar +#undef constchar +#endif + +#if (PY_VERSION_HEX < 0x02050000) + #ifndef PY_SSIZE_T_MIN + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #endif +#define NPY_SSIZE_T_PYFMT "i" +#undef PyIndex_Check +#define constchar const char +#define PyIndex_Check(op) 0 +#else +#define NPY_SSIZE_T_PYFMT "n" +#define constchar char +#endif + +#if SIZEOF_PY_INTPTR_T == SIZEOF_INT + #define NPY_INTP NPY_INT + #define NPY_UINTP NPY_UINT + #define PyIntpArrType_Type PyIntArrType_Type + #define PyUIntpArrType_Type PyUIntArrType_Type + #define NPY_MAX_INTP NPY_MAX_INT + #define NPY_MIN_INTP NPY_MIN_INT + #define NPY_MAX_UINTP NPY_MAX_UINT + #define NPY_INTP_FMT "d" +#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG + #define NPY_INTP NPY_LONG + #define NPY_UINTP NPY_ULONG + #define PyIntpArrType_Type PyLongArrType_Type + #define PyUIntpArrType_Type PyULongArrType_Type + #define NPY_MAX_INTP NPY_MAX_LONG + #define NPY_MIN_INTP MIN_LONG + #define NPY_MAX_UINTP NPY_MAX_ULONG + #define NPY_INTP_FMT "ld" +#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG) + #define NPY_INTP NPY_LONGLONG + #define NPY_UINTP NPY_ULONGLONG + #define PyIntpArrType_Type PyLongLongArrType_Type + #define PyUIntpArrType_Type PyULongLongArrType_Type + #define NPY_MAX_INTP NPY_MAX_LONGLONG + #define NPY_MIN_INTP NPY_MIN_LONGLONG + #define NPY_MAX_UINTP NPY_MAX_ULONGLONG + #define NPY_INTP_FMT "Ld" +#endif + +#define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr); +#define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr); + +#define NPY_STRINGIFY(x) #x +#define NPY_TOSTRING(x) NPY_STRINGIFY(x) + + /* Macros to define how array, and dimension/strides data is + allocated. + */ + + /* Data buffer */ +#define PyDataMem_NEW(size) ((char *)malloc(size)) +#define PyDataMem_FREE(ptr) free(ptr) +#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size)) + +#define NPY_USE_PYMEM 1 + +#if NPY_USE_PYMEM == 1 +#define PyArray_malloc PyMem_Malloc +#define PyArray_free PyMem_Free +#define PyArray_realloc PyMem_Realloc +#else +#define PyArray_malloc malloc +#define PyArray_free free +#define PyArray_realloc realloc +#endif + +/* Dimensions and strides */ +#define PyDimMem_NEW(size) \ + ((npy_intp *)PyArray_malloc(size*sizeof(npy_intp))) + +#define PyDimMem_FREE(ptr) PyArray_free(ptr) + +#define PyDimMem_RENEW(ptr,size) \ + ((npy_intp *)PyArray_realloc(ptr,size*sizeof(npy_intp))) + +/* forward declaration */ +struct _PyArray_Descr; + + /* These must deal with unaligned and swapped data if necessary */ +typedef PyObject * (PyArray_GetItemFunc) (void *, void *); +typedef int (PyArray_SetItemFunc)(PyObject *, void *, void *); + +typedef void (PyArray_CopySwapNFunc)(void *, npy_intp, void *, npy_intp, + npy_intp, int, void *); + +typedef void (PyArray_CopySwapFunc)(void *, void *, int, void *); +typedef npy_bool (PyArray_NonzeroFunc)(void *, void *); + + + /* These assume aligned and notswapped data -- a buffer will be + used before or contiguous data will be obtained + */ +typedef int (PyArray_CompareFunc)(const void *, const void *, void *); +typedef int (PyArray_ArgFunc)(void*, npy_intp, npy_intp*, void *); + +typedef void (PyArray_DotFunc)(void *, npy_intp, void *, npy_intp, void *, + npy_intp, void *); + +typedef void (PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, + void *); + +/* XXX the ignore argument should be removed next time the API version + is bumped. It used to be the separator. */ +typedef int (PyArray_ScanFunc)(FILE *fp, void *dptr, + char *ignore, struct _PyArray_Descr *); +typedef int (PyArray_FromStrFunc)(char *s, void *dptr, char **endptr, + struct _PyArray_Descr *); + +typedef int (PyArray_FillFunc)(void *, npy_intp, void *); + +typedef int (PyArray_SortFunc)(void *, npy_intp, void *); +typedef int (PyArray_ArgSortFunc)(void *, npy_intp *, npy_intp, void *); + +typedef int (PyArray_FillWithScalarFunc)(void *, npy_intp, void *, void *); + +typedef int (PyArray_ScalarKindFunc)(void *); + +typedef void (PyArray_FastClipFunc)(void *in, npy_intp n_in, void *min, + void *max, void *out); + +typedef struct { + npy_intp *ptr; + int len; +} PyArray_Dims; + +typedef struct { + /* Functions to cast to all other standard types*/ + /* Can have some NULL entries */ + PyArray_VectorUnaryFunc *cast[NPY_NTYPES]; + + /* The next four functions *cannot* be NULL */ + + /* Functions to get and set items with standard + Python types -- not array scalars */ + PyArray_GetItemFunc *getitem; + PyArray_SetItemFunc *setitem; + + /* Copy and/or swap data. Memory areas may not overlap */ + /* Use memmove first if they might */ + PyArray_CopySwapNFunc *copyswapn; + PyArray_CopySwapFunc *copyswap; + + /* Function to compare items */ + /* Can be NULL + */ + PyArray_CompareFunc *compare; + + /* Function to select largest + Can be NULL + */ + PyArray_ArgFunc *argmax; + + /* Function to compute dot product */ + /* Can be NULL */ + PyArray_DotFunc *dotfunc; + + /* Function to scan an ASCII file and + place a single value plus possible separator + Can be NULL + */ + PyArray_ScanFunc *scanfunc; + + /* Function to read a single value from a string */ + /* and adjust the pointer; Can be NULL */ + PyArray_FromStrFunc *fromstr; + + /* Function to determine if data is zero or not */ + /* If NULL a default version is */ + /* used at Registration time. */ + PyArray_NonzeroFunc *nonzero; + + /* Used for arange. Can be NULL.*/ + PyArray_FillFunc *fill; + + /* Function to fill arrays with scalar values + Can be NULL*/ + PyArray_FillWithScalarFunc *fillwithscalar; + + /* Sorting functions; Can be NULL*/ + PyArray_SortFunc *sort[NPY_NSORTS]; + PyArray_ArgSortFunc *argsort[NPY_NSORTS]; + + /* Dictionary of additional casting functions + PyArray_VectorUnaryFuncs + which can be populated to support casting + to other registered types. Can be NULL*/ + PyObject *castdict; + + /* Functions useful for generalizing + the casting rules. Can be NULL; + */ + PyArray_ScalarKindFunc *scalarkind; + int **cancastscalarkindto; + int *cancastto; + + PyArray_FastClipFunc *fastclip; +} PyArray_ArrFuncs; + +#define NPY_ITEM_REFCOUNT 0x01 /* The item must be reference counted + when it is inserted or extracted. */ +#define NPY_ITEM_HASOBJECT 0x01 /* Same as needing REFCOUNT */ + +#define NPY_LIST_PICKLE 0x02 /* Convert to list for pickling */ +#define NPY_ITEM_IS_POINTER 0x04 /* The item is a POINTER */ + +#define NPY_NEEDS_INIT 0x08 /* memory needs to be initialized + for this data-type */ + +#define NPY_NEEDS_PYAPI 0x10 /* operations need Python C-API + so don't give-up thread. */ + +#define NPY_USE_GETITEM 0x20 /* Use f.getitem when extracting elements + of this data-type */ + +#define NPY_USE_SETITEM 0x40 /* Use f.setitem when setting creating + 0-d array from this data-type. + */ + +/* These are inherited for global data-type if any data-types in the field + have them */ +#define NPY_FROM_FIELDS (NPY_NEEDS_INIT | NPY_LIST_PICKLE | \ + NPY_ITEM_REFCOUNT | NPY_NEEDS_PYAPI) + +#define NPY_OBJECT_DTYPE_FLAGS (NPY_LIST_PICKLE | NPY_USE_GETITEM | \ + NPY_ITEM_IS_POINTER | NPY_ITEM_REFCOUNT | \ + NPY_NEEDS_INIT | NPY_NEEDS_PYAPI) + +#define PyDataType_FLAGCHK(dtype, flag) \ + (((dtype)->hasobject & (flag)) == (flag)) + +#define PyDataType_REFCHK(dtype) \ + PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT) + +/* Change dtype hasobject to 32-bit in 1.1 and change its name */ +typedef struct _PyArray_Descr { + PyObject_HEAD + PyTypeObject *typeobj; /* the type object representing an + instance of this type -- should not + be two type_numbers with the same type + object. */ + char kind; /* kind for this type */ + char type; /* unique-character representing this type */ + char byteorder; /* '>' (big), '<' (little), '|' + (not-applicable), or '=' (native). */ + char hasobject; /* non-zero if it has object arrays + in fields */ + int type_num; /* number representing this type */ + int elsize; /* element size for this type */ + int alignment; /* alignment needed for this type */ + struct _arr_descr \ + *subarray; /* Non-NULL if this type is + is an array (C-contiguous) + of some other type + */ + PyObject *fields; /* The fields dictionary for this type */ + /* For statically defined descr this + is always Py_None */ + + PyObject *names; /* An ordered tuple of field names or NULL + if no fields are defined */ + + PyArray_ArrFuncs *f; /* a table of functions specific for each + basic data descriptor */ +} PyArray_Descr; + +typedef struct _arr_descr { + PyArray_Descr *base; + PyObject *shape; /* a tuple */ +} PyArray_ArrayDescr; + +/* + The main array object structure. It is recommended to use the macros + defined below (PyArray_DATA and friends) access fields here, instead + of the members themselves. + */ + +typedef struct PyArrayObject { + PyObject_HEAD + char *data; /* pointer to raw data buffer */ + int nd; /* number of dimensions, also called ndim */ + npy_intp *dimensions; /* size in each dimension */ + npy_intp *strides; /* bytes to jump to get to the + next element in each dimension */ + PyObject *base; /* This object should be decref'd + upon deletion of array */ + /* For views it points to the original array */ + /* For creation from buffer object it points + to an object that shold be decref'd on + deletion */ + /* For UPDATEIFCOPY flag this is an array + to-be-updated upon deletion of this one */ + PyArray_Descr *descr; /* Pointer to type structure */ + int flags; /* Flags describing array -- see below*/ + PyObject *weakreflist; /* For weakreferences */ +} PyArrayObject; + +#define NPY_AO PyArrayObject + +#define fortran fortran_ /* For some compilers */ + +/* Array Flags Object */ +typedef struct PyArrayFlagsObject { + PyObject_HEAD + PyObject *arr; + int flags; +} PyArrayFlagsObject; + +/* Mirrors buffer object to ptr */ + +typedef struct { + PyObject_HEAD + PyObject *base; + void *ptr; + npy_intp len; + int flags; +} PyArray_Chunk; + +typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); + +/* Means c-style contiguous (last index varies the fastest). The + data elements right after each other. */ +#define NPY_CONTIGUOUS 0x0001 +/* set if array is a contiguous Fortran array: the first index + varies the fastest in memory (strides array is reverse of + C-contiguous array)*/ +#define NPY_FORTRAN 0x0002 + +#define NPY_C_CONTIGUOUS NPY_CONTIGUOUS +#define NPY_F_CONTIGUOUS NPY_FORTRAN + +/* + Note: all 0-d arrays are CONTIGUOUS and FORTRAN contiguous. If a + 1-d array is CONTIGUOUS it is also FORTRAN contiguous +*/ + +/* If set, the array owns the data: it will be free'd when the array + is deleted. */ +#define NPY_OWNDATA 0x0004 + +/* An array never has the next four set; they're only used as parameter + flags to the the various FromAny functions */ + +/* Cause a cast to occur regardless of whether or not it is safe. */ +#define NPY_FORCECAST 0x0010 + +/* Always copy the array. Returned arrays are always CONTIGUOUS, ALIGNED, + and WRITEABLE. */ +#define NPY_ENSURECOPY 0x0020 + +/* Make sure the returned array is an ndarray or a bigndarray */ +#define NPY_ENSUREARRAY 0x0040 + +/* Make sure that the strides are in units of the element size + Needed for some operations with record-arrays. +*/ +#define NPY_ELEMENTSTRIDES 0x0080 + +/* Array data is aligned on the appropiate memory address for the + type stored according to how the compiler would align things + (e.g., an array of integers (4 bytes each) starts on + a memory address that's a multiple of 4) */ +#define NPY_ALIGNED 0x0100 +/* Array data has the native endianness */ +#define NPY_NOTSWAPPED 0x0200 +/* Array data is writeable */ +#define NPY_WRITEABLE 0x0400 +/* If this flag is set, then base contains a pointer to an array of + the same size that should be updated with the current contents of + this array when this array is deallocated +*/ +#define NPY_UPDATEIFCOPY 0x1000 + +/* This flag is for the array interface */ +#define NPY_ARR_HAS_DESCR 0x0800 + + +#define NPY_BEHAVED (NPY_ALIGNED | NPY_WRITEABLE) +#define NPY_BEHAVED_NS (NPY_ALIGNED | NPY_WRITEABLE | NPY_NOTSWAPPED) +#define NPY_CARRAY (NPY_CONTIGUOUS | NPY_BEHAVED) +#define NPY_CARRAY_RO (NPY_CONTIGUOUS | NPY_ALIGNED) +#define NPY_FARRAY (NPY_FORTRAN | NPY_BEHAVED) +#define NPY_FARRAY_RO (NPY_FORTRAN | NPY_ALIGNED) +#define NPY_DEFAULT NPY_CARRAY +#define NPY_IN_ARRAY NPY_CARRAY_RO +#define NPY_OUT_ARRAY NPY_CARRAY +#define NPY_INOUT_ARRAY (NPY_CARRAY | NPY_UPDATEIFCOPY) +#define NPY_IN_FARRAY NPY_FARRAY_RO +#define NPY_OUT_FARRAY NPY_FARRAY +#define NPY_INOUT_FARRAY (NPY_FARRAY | NPY_UPDATEIFCOPY) + +#define NPY_UPDATE_ALL (NPY_CONTIGUOUS | NPY_FORTRAN | NPY_ALIGNED) + + +/* Size of internal buffers used for alignment */ +/* Make BUFSIZE a multiple of sizeof(cdouble) -- ususally 16 */ +/* So that ufunc buffers are aligned */ +#define NPY_MIN_BUFSIZE ((int)sizeof(cdouble)) +#define NPY_MAX_BUFSIZE (((int)sizeof(cdouble))*1000000) +#define NPY_BUFSIZE 10000 +/* #define NPY_BUFSIZE 80*/ + +#define PyArray_MAX(a,b) (((a)>(b))?(a):(b)) +#define PyArray_MIN(a,b) (((a)<(b))?(a):(b)) +#define PyArray_CLT(p,q) ((((p).real==(q).real) ? ((p).imag < (q).imag) : \ + ((p).real < (q).real))) +#define PyArray_CGT(p,q) ((((p).real==(q).real) ? ((p).imag > (q).imag) : \ + ((p).real > (q).real))) +#define PyArray_CLE(p,q) ((((p).real==(q).real) ? ((p).imag <= (q).imag) : \ + ((p).real <= (q).real))) +#define PyArray_CGE(p,q) ((((p).real==(q).real) ? ((p).imag >= (q).imag) : \ + ((p).real >= (q).real))) +#define PyArray_CEQ(p,q) (((p).real==(q).real) && ((p).imag == (q).imag)) +#define PyArray_CNE(p,q) (((p).real!=(q).real) || ((p).imag != (q).imag)) + +/* + * C API: consists of Macros and functions. The MACROS are defined here. + */ + + +#define PyArray_CHKFLAGS(m, FLAGS) \ + ((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS)) + +#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, NPY_CONTIGUOUS) +#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, NPY_WRITEABLE) +#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, NPY_ALIGNED) + + +#if NPY_ALLOW_THREADS +#define NPY_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS +#define NPY_END_ALLOW_THREADS Py_END_ALLOW_THREADS +#define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL; +#define NPY_BEGIN_THREADS _save = PyEval_SaveThread(); +#define NPY_END_THREADS if (_save) PyEval_RestoreThread(_save); + +#define NPY_BEGIN_THREADS_DESCR(dtype) \ + if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \ + NPY_BEGIN_THREADS + +#define NPY_END_THREADS_DESCR(dtype) \ + if (!(PyDataType_FLAGCHK(dtype, NPY_NEEDS_PYAPI))) \ + NPY_END_THREADS + +#define NPY_ALLOW_C_API_DEF PyGILState_STATE __save__; +#define NPY_ALLOW_C_API __save__ = PyGILState_Ensure(); +#define NPY_DISABLE_C_API PyGILState_Release(__save__); +#else +#define NPY_BEGIN_ALLOW_THREADS +#define NPY_END_ALLOW_THREADS +#define NPY_BEGIN_THREADS_DEF +#define NPY_BEGIN_THREADS +#define NPY_END_THREADS +#define NPY_BEGIN_THREADS_DESCR(dtype) +#define NPY_END_THREADS_DESCR(dtype) +#define NPY_ALLOW_C_API_DEF +#define NPY_ALLOW_C_API +#define NPY_DISABLE_C_API +#endif + +typedef struct { + PyObject_HEAD + int nd_m1; /* number of dimensions - 1 */ + npy_intp index, size; + npy_intp coordinates[NPY_MAXDIMS];/* N-dimensional loop */ + npy_intp dims_m1[NPY_MAXDIMS]; /* ao->dimensions - 1 */ + npy_intp strides[NPY_MAXDIMS]; /* ao->strides or fake */ + npy_intp backstrides[NPY_MAXDIMS];/* how far to jump back */ + npy_intp factors[NPY_MAXDIMS]; /* shape factors */ + PyArrayObject *ao; + char *dataptr; /* pointer to current item*/ + npy_bool contiguous; +} PyArrayIterObject; + + +/* Iterator API */ +#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type) + +#define _PyAIT(it) ((PyArrayIterObject *)(it)) +#define PyArray_ITER_RESET(it) { \ + _PyAIT(it)->index = 0; \ + _PyAIT(it)->dataptr = _PyAIT(it)->ao->data; \ + memset(_PyAIT(it)->coordinates, 0, \ + (_PyAIT(it)->nd_m1+1)*sizeof(npy_intp)); \ +} + +#define _PyArray_ITER_NEXT1(it) { \ + (it)->dataptr += _PyAIT(it)->strides[0]; \ + (it)->coordinates[0]++; \ +} + +#define _PyArray_ITER_NEXT2(it) { \ + if ((it)->coordinates[1] < (it)->dims_m1[1]) { \ + (it)->coordinates[1]++; \ + (it)->dataptr += (it)->strides[1]; \ + } \ + else { \ + (it)->coordinates[1] = 0; \ + (it)->coordinates[0]++; \ + (it)->dataptr += (it)->strides[0] - \ + (it)->backstrides[1]; \ + } \ +} + +#define _PyArray_ITER_NEXT3(it) { \ + if ((it)->coordinates[2] < (it)->dims_m1[2]) { \ + (it)->coordinates[2]++; \ + (it)->dataptr += (it)->strides[2]; \ + } \ + else { \ + (it)->coordinates[2] = 0; \ + (it)->dataptr -= (it)->backstrides[2]; \ + if ((it)->coordinates[1] < (it)->dims_m1[1]) { \ + (it)->coordinates[1]++; \ + (it)->dataptr += (it)->strides[1]; \ + } \ + else { \ + (it)->coordinates[1] = 0; \ + (it)->coordinates[0]++; \ + (it)->dataptr += (it)->strides[0] - \ + (it)->backstrides[1]; \ + } \ + } \ +} + +#define PyArray_ITER_NEXT(it) { \ + _PyAIT(it)->index++; \ + if (_PyAIT(it)->nd_m1 == 0) { \ + _PyArray_ITER_NEXT1(_PyAIT(it)); \ + } \ + else if (_PyAIT(it)->contiguous) \ + _PyAIT(it)->dataptr += _PyAIT(it)->ao->descr->elsize; \ + else if (_PyAIT(it)->nd_m1 == 1) { \ + _PyArray_ITER_NEXT2(_PyAIT(it)); \ + } \ + else { \ + int __npy_i; \ + for (__npy_i=_PyAIT(it)->nd_m1; __npy_i >= 0; __npy_i--) { \ + if (_PyAIT(it)->coordinates[__npy_i] < \ + _PyAIT(it)->dims_m1[__npy_i]) { \ + _PyAIT(it)->coordinates[__npy_i]++; \ + _PyAIT(it)->dataptr += \ + _PyAIT(it)->strides[__npy_i]; \ + break; \ + } \ + else { \ + _PyAIT(it)->coordinates[__npy_i] = 0; \ + _PyAIT(it)->dataptr -= \ + _PyAIT(it)->backstrides[__npy_i]; \ + } \ + } \ + } \ +} + +#define PyArray_ITER_GOTO(it, destination) { \ + int __npy_i; \ + _PyAIT(it)->index = 0; \ + _PyAIT(it)->dataptr = _PyAIT(it)->ao->data; \ + for (__npy_i = _PyAIT(it)->nd_m1; __npy_i>=0; __npy_i--) { \ + if (destination[__npy_i] < 0) { \ + destination[__npy_i] += \ + _PyAIT(it)->dims_m1[__npy_i]+1; \ + } \ + _PyAIT(it)->dataptr += destination[__npy_i] * \ + _PyAIT(it)->strides[__npy_i]; \ + _PyAIT(it)->coordinates[__npy_i] = \ + destination[__npy_i]; \ + _PyAIT(it)->index += destination[__npy_i] * \ + ( __npy_i==_PyAIT(it)->nd_m1 ? 1 : \ + _PyAIT(it)->dims_m1[__npy_i+1]+1) ; \ + } \ +} + +#define PyArray_ITER_GOTO1D(it, ind) { \ + int __npy_i; \ + npy_intp __npy_ind = (npy_intp) (ind); \ + if (__npy_ind < 0) __npy_ind += _PyAIT(it)->size; \ + _PyAIT(it)->index = __npy_ind; \ + if (_PyAIT(it)->nd_m1 == 0) { \ + _PyAIT(it)->dataptr = _PyAIT(it)->ao->data + \ + __npy_ind * _PyAIT(it)->strides[0]; \ + } \ + else if (_PyAIT(it)->contiguous) \ + _PyAIT(it)->dataptr = _PyAIT(it)->ao->data + \ + __npy_ind * _PyAIT(it)->ao->descr->elsize; \ + else { \ + _PyAIT(it)->dataptr = _PyAIT(it)->ao->data; \ + for (__npy_i = 0; __npy_i<=_PyAIT(it)->nd_m1; \ + __npy_i++) { \ + _PyAIT(it)->dataptr += \ + (__npy_ind / _PyAIT(it)->factors[__npy_i]) \ + * _PyAIT(it)->strides[__npy_i]; \ + __npy_ind %= _PyAIT(it)->factors[__npy_i]; \ + } \ + } \ +} + +#define PyArray_ITER_DATA(it) ((void *)(_PyAIT(it)->dataptr)) + +#define PyArray_ITER_NOTDONE(it) (_PyAIT(it)->index < _PyAIT(it)->size) + + +/* + Any object passed to PyArray_Broadcast must be binary compatible with + this structure. +*/ + +typedef struct { + PyObject_HEAD + int numiter; /* number of iters */ + npy_intp size; /* broadcasted size */ + npy_intp index; /* current index */ + int nd; /* number of dims */ + npy_intp dimensions[NPY_MAXDIMS]; /* dimensions */ + PyArrayIterObject *iters[NPY_MAXARGS]; /* iterators */ +} PyArrayMultiIterObject; + +#define _PyMIT(m) ((PyArrayMultiIterObject *)(m)) +#define PyArray_MultiIter_RESET(multi) { \ + int __npy_mi; \ + _PyMIT(multi)->index = 0; \ + for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \ + PyArray_ITER_RESET(_PyMIT(multi)->iters[__npy_mi]); \ + } \ +} + +#define PyArray_MultiIter_NEXT(multi) { \ + int __npy_mi; \ + _PyMIT(multi)->index++; \ + for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \ + PyArray_ITER_NEXT(_PyMIT(multi)->iters[__npy_mi]); \ + } \ +} + +#define PyArray_MultiIter_GOTO(multi, dest) { \ + int __npy_mi; \ + for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \ + PyArray_ITER_GOTO(_PyMIT(multi)->iters[__npy_mi], dest); \ + } \ + _PyMIT(multi)->index = _PyMIT(multi)->iters[0]->index; \ +} + +#define PyArray_MultiIter_GOTO1D(multi, ind) { \ + int __npy_mi; \ + for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \ + PyArray_ITER_GOTO1D(_PyMIT(multi)->iters[__npy_mi], ind); \ + } \ + _PyMIT(multi)->index = _PyMIT(multi)->iters[0]->index; \ +} + +#define PyArray_MultiIter_DATA(multi, i) \ + ((void *)(_PyMIT(multi)->iters[i]->dataptr)) + +#define PyArray_MultiIter_NEXTi(multi, i) \ + PyArray_ITER_NEXT(_PyMIT(multi)->iters[i]) + +#define PyArray_MultiIter_NOTDONE(multi) \ + (_PyMIT(multi)->index < _PyMIT(multi)->size) + +/* Store the information needed for fancy-indexing over an array */ + +typedef struct { + PyObject_HEAD + /* Multi-iterator portion --- needs to be present in this order to + work with PyArray_Broadcast */ + + int numiter; /* number of index-array + iterators */ + npy_intp size; /* size of broadcasted + result */ + npy_intp index; /* current index */ + int nd; /* number of dims */ + npy_intp dimensions[NPY_MAXDIMS]; /* dimensions */ + PyArrayIterObject *iters[NPY_MAXDIMS]; /* index object + iterators */ + PyArrayIterObject *ait; /* flat Iterator for + underlying array */ + + /* flat iterator for subspace (when numiter < nd) */ + PyArrayIterObject *subspace; + + /* if subspace iteration, then this is the array of + axes in the underlying array represented by the + index objects */ + int iteraxes[NPY_MAXDIMS]; + /* if subspace iteration, the these are the coordinates + to the start of the subspace. + */ + npy_intp bscoord[NPY_MAXDIMS]; + + PyObject *indexobj; /* creating obj */ + int consec; + char *dataptr; + +} PyArrayMapIterObject; + +/* The default array type + */ +#define NPY_DEFAULT_TYPE NPY_DOUBLE +#define PyArray_DEFAULT NPY_DEFAULT_TYPE +/* All sorts of useful ways to look into a PyArrayObject. + These are the recommended over casting to PyArrayObject and accessing + the members directly. + */ + +#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd) +#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || \ + PyArray_CHKFLAGS(m, NPY_CONTIGUOUS) || \ + PyArray_CHKFLAGS(m, NPY_FORTRAN)) + +#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, NPY_FORTRAN) && \ + (PyArray_NDIM(m) > 1)) + +#define PyArray_FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, NPY_FORTRAN) ? \ + NPY_FORTRAN : 0)) + +#define FORTRAN_IF PyArray_FORTRAN_IF +#define PyArray_DATA(obj) ((void *)(((PyArrayObject *)(obj))->data)) +#define PyArray_BYTES(obj) (((PyArrayObject *)(obj))->data) +#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions) +#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides) +#define PyArray_DIM(obj,n) (PyArray_DIMS(obj)[n]) +#define PyArray_STRIDE(obj,n) (PyArray_STRIDES(obj)[n]) +#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base) +#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr) +#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags) +#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize) +#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num) + +#define PyArray_GETITEM(obj,itemptr) \ + ((PyArrayObject *)(obj))->descr->f->getitem((char *)(itemptr), \ + (PyArrayObject *)(obj)); + +#define PyArray_SETITEM(obj,itemptr,v) \ + ((PyArrayObject *)(obj))->descr->f->setitem((PyObject *)(v), \ + (char *)(itemptr), \ + (PyArrayObject *)(obj)); + + +#define PyTypeNum_ISBOOL(type) ((type) == NPY_BOOL) + +#define PyTypeNum_ISUNSIGNED(type) (((type) == NPY_UBYTE) || \ + ((type) == NPY_USHORT) || \ + ((type) == NPY_UINT) || \ + ((type) == NPY_ULONG) || \ + ((type) == NPY_ULONGLONG)) + +#define PyTypeNum_ISSIGNED(type) (((type) == NPY_BYTE) || \ + ((type) == NPY_SHORT) || \ + ((type) == NPY_INT) || \ + ((type) == NPY_LONG) || \ + ((type) == NPY_LONGLONG)) + +#define PyTypeNum_ISINTEGER(type) (((type) >= NPY_BYTE) && \ + ((type) <= NPY_ULONGLONG)) + +#define PyTypeNum_ISFLOAT(type) (((type) >= NPY_FLOAT) && \ + ((type) <= NPY_LONGDOUBLE)) + +#define PyTypeNum_ISNUMBER(type) ((type) <= NPY_CLONGDOUBLE) + +#define PyTypeNum_ISSTRING(type) (((type) == NPY_STRING) || \ + ((type) == NPY_UNICODE)) + +#define PyTypeNum_ISCOMPLEX(type) (((type) >= NPY_CFLOAT) && \ + ((type) <= NPY_CLONGDOUBLE)) + +#define PyTypeNum_ISPYTHON(type) (((type) == NPY_LONG) || \ + ((type) == NPY_DOUBLE) || \ + ((type) == NPY_CDOUBLE) || \ + ((type) == NPY_BOOL) || \ + ((type) == NPY_OBJECT )) + +#define PyTypeNum_ISFLEXIBLE(type) (((type) >=NPY_STRING) && \ + ((type) <=NPY_VOID)) + +#define PyTypeNum_ISUSERDEF(type) (((type) >= NPY_USERDEF) && \ + ((type) < NPY_USERDEF+ \ + NPY_NUMUSERTYPES)) + +#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \ + PyTypeNum_ISUSERDEF(type)) + +#define PyTypeNum_ISOBJECT(type) ((type) == NPY_OBJECT) + + +#define PyDataType_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj)) +#define PyDataType_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISSIGNED(obj) PyTypeNum_ISSIGNED(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISINTEGER(obj) PyTypeNum_ISINTEGER(((PyArray_Descr*)(obj))->type_num ) +#define PyDataType_ISFLOAT(obj) PyTypeNum_ISFLOAT(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISNUMBER(obj) PyTypeNum_ISNUMBER(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISSTRING(obj) PyTypeNum_ISSTRING(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISPYTHON(obj) PyTypeNum_ISPYTHON(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_ISOBJECT(obj) PyTypeNum_ISOBJECT(((PyArray_Descr*)(obj))->type_num) +#define PyDataType_HASFIELDS(obj) (((PyArray_Descr *)(obj))->names != NULL) + +#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj)) +#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj)) +#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj)) +#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj)) +#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj)) +#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj)) +#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj)) +#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj)) +#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj)) +#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj)) +#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj)) +#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj)) +#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj)) +#define PyArray_HASFIELDS(obj) PyDataType_HASFIELDS(PyArray_DESCR(obj)) + +#define NPY_LITTLE '<' +#define NPY_BIG '>' +#define NPY_NATIVE '=' +#define NPY_SWAP 's' +#define NPY_IGNORE '|' + +#ifdef WORDS_BIGENDIAN +#define NPY_NATBYTE NPY_BIG +#define NPY_OPPBYTE NPY_LITTLE +#else +#define NPY_NATBYTE NPY_LITTLE +#define NPY_OPPBYTE NPY_BIG +#endif + +#define PyArray_ISNBO(arg) ((arg) != NPY_OPPBYTE) +#define PyArray_IsNativeByteOrder PyArray_ISNBO +#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder) +#define PyArray_ISBYTESWAPPED(m) (!PyArray_ISNOTSWAPPED(m)) + +#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) && \ + PyArray_ISNOTSWAPPED(m)) + +#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, NPY_CARRAY) +#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, NPY_CARRAY_RO) +#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, NPY_FARRAY) +#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, NPY_FARRAY_RO) +#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, NPY_BEHAVED) +#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, NPY_ALIGNED) + + +#define PyDataType_ISNOTSWAPPED(d) PyArray_ISNBO(((PyArray_Descr *)(d))->byteorder) +#define PyDataType_ISBYTESWAPPED(d) (!PyDataType_ISNOTSWAPPED(d)) + + +/* This is the form of the struct that's returned pointed by the + PyCObject attribute of an array __array_struct__. See + http://numpy.scipy.org/array_interface.shtml for the full + documentation. */ +typedef struct { + int two; /* contains the integer 2 as a sanity check */ + int nd; /* number of dimensions */ + char typekind; /* kind in array --- character code of typestr */ + int itemsize; /* size of each element */ + int flags; /* how should be data interpreted. Valid + flags are CONTIGUOUS (1), FORTRAN (2), + ALIGNED (0x100), NOTSWAPPED (0x200), and + WRITEABLE (0x400). + ARR_HAS_DESCR (0x800) states that arrdescr + field is present in structure */ + npy_intp *shape; /* A length-nd array of shape information */ + npy_intp *strides; /* A length-nd array of stride information */ + void *data; /* A pointer to the first element of the array */ + PyObject *descr; /* A list of fields or NULL (ignored if flags + does not have ARR_HAS_DESCR flag set) */ +} PyArrayInterface; + + +/* Includes the "function" C-API -- these are all stored in a + list of pointers --- one for each file + The two lists are concatenated into one in multiarray. + + They are available as import_array() +*/ + +#include "__multiarray_api.h" + + +/* C-API that requries previous API to be defined */ + +#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type) + +#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \ + PyObject_TypeCheck(op, &PyArray_Type)) + +#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type) + +#define PyArray_HasArrayInterfaceType(op, type, context, out) \ + ((((out)=PyArray_FromStructInterface(op)) != Py_NotImplemented) || \ + (((out)=PyArray_FromInterface(op)) != Py_NotImplemented) || \ + (((out)=PyArray_FromArrayAttr(op, type, context)) != \ + Py_NotImplemented)) + +#define PyArray_HasArrayInterface(op, out) \ + PyArray_HasArrayInterfaceType(op, NULL, NULL, out) + +#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0)) + +#define PyArray_IsScalar(obj, cls) \ + (PyObject_TypeCheck(obj, &Py##cls##ArrType_Type)) + +#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \ + PyArray_IsZeroDim(m)) + +#define PyArray_IsPythonNumber(obj) \ + (PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \ + PyLong_Check(obj) || PyBool_Check(obj)) + +#define PyArray_IsPythonScalar(obj) \ + (PyArray_IsPythonNumber(obj) || PyString_Check(obj) || \ + PyUnicode_Check(obj)) + +#define PyArray_IsAnyScalar(obj) \ + (PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj)) + +#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \ + PyArray_CheckScalar(obj)) + +#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? \ + Py_INCREF(m), (m) : \ + (PyArrayObject *)(PyArray_Copy(m))) + +#define PyArray_SAMESHAPE(a1,a2) ((PyArray_NDIM(a1) == PyArray_NDIM(a2)) && \ + PyArray_CompareLists(PyArray_DIMS(a1), \ + PyArray_DIMS(a2), \ + PyArray_NDIM(a1))) + +#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m)) +#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m)) +#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL) + +#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, \ + NULL) + +#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, \ + PyArray_DescrFromType(type), 0, 0, 0, NULL); + +#define PyArray_FROM_OTF(m, type, flags) \ + PyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \ + (((flags) & NPY_ENSURECOPY) ? \ + ((flags) | NPY_DEFAULT) : (flags)), NULL) + +#define PyArray_FROMANY(m, type, min, max, flags) \ + PyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \ + (((flags) & NPY_ENSURECOPY) ? \ + (flags) | NPY_DEFAULT : (flags)), NULL) + +#define PyArray_ZEROS(m, dims, type, fortran) \ + PyArray_Zeros(m, dims, PyArray_DescrFromType(type), fortran) + +#define PyArray_EMPTY(m, dims, type, fortran) \ + PyArray_Empty(m, dims, PyArray_DescrFromType(type), fortran) + +#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), val, \ + PyArray_NBYTES(obj)) + +#define PyArray_REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt) +#define NPY_REFCOUNT PyArray_REFCOUNT +#define NPY_MAX_ELSIZE (2*SIZEOF_LONGDOUBLE) + +#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \ + PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \ + max_depth, NPY_DEFAULT, NULL) + +#define PyArray_EquivArrTypes(a1, a2) \ + PyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2)) + +#define PyArray_EquivByteorders(b1, b2) \ + (((b1) == (b2)) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2))) + +#define PyArray_SimpleNew(nd, dims, typenum) \ + PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL) + +#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \ + PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, \ + data, 0, NPY_CARRAY, NULL) + +#define PyArray_SimpleNewFromDescr(nd, dims, descr) \ + PyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, \ + NULL, NULL, 0, NULL) + +#define PyArray_ToScalar(data, arr) \ + PyArray_Scalar(data, PyArray_DESCR(arr), (PyObject *)arr) + + +/* These might be faster without the dereferencing of obj + going on inside -- of course an optimizing compiler should + inline the constants inside a for loop making it a moot point +*/ + +#define PyArray_GETPTR1(obj, i) ((void *)(PyArray_BYTES(obj) + \ + (i)*PyArray_STRIDES(obj)[0])) + +#define PyArray_GETPTR2(obj, i, j) ((void *)(PyArray_BYTES(obj) + \ + (i)*PyArray_STRIDES(obj)[0] + \ + (j)*PyArray_STRIDES(obj)[1])) + +#define PyArray_GETPTR3(obj, i, j, k) ((void *)(PyArray_BYTES(obj) + \ + (i)*PyArray_STRIDES(obj)[0] + \ + (j)*PyArray_STRIDES(obj)[1] + \ + (k)*PyArray_STRIDES(obj)[2])) + +#define PyArray_GETPTR4(obj, i, j, k, l) ((void *)(PyArray_BYTES(obj) + \ + (i)*PyArray_STRIDES(obj)[0] + \ + (j)*PyArray_STRIDES(obj)[1] + \ + (k)*PyArray_STRIDES(obj)[2] + \ + (l)*PyArray_STRIDES(obj)[3])) + +#define PyArray_XDECREF_ERR(obj) \ + if (obj && (PyArray_FLAGS(obj) & NPY_UPDATEIFCOPY)) { \ + PyArray_FLAGS(PyArray_BASE(obj)) |= NPY_WRITEABLE; \ + PyArray_FLAGS(obj) &= ~NPY_UPDATEIFCOPY; \ + } \ + Py_XDECREF(obj) + +#define PyArray_DESCR_REPLACE(descr) do { \ + PyArray_Descr *_new_; \ + _new_ = PyArray_DescrNew(descr); \ + Py_XDECREF(descr); \ + descr = _new_; \ + } while(0) + +/* Copy should always return contiguous array */ +#define PyArray_Copy(obj) PyArray_NewCopy(obj, NPY_CORDER) + +#define PyArray_FromObject(op, type, min_depth, max_depth) \ + PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \ + max_depth, NPY_BEHAVED | NPY_ENSUREARRAY, NULL) + +#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth) \ + PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \ + max_depth, NPY_DEFAULT | NPY_ENSUREARRAY, NULL) + +#define PyArray_CopyFromObject(op, type, min_depth, max_depth) \ + PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \ + max_depth, NPY_ENSURECOPY | NPY_DEFAULT | \ + NPY_ENSUREARRAY, NULL) + +#define PyArray_Cast(mp, type_num) \ + PyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0) + +#define PyArray_Take(ap, items, axis) \ + PyArray_TakeFrom(ap, items, axis, NULL, NPY_RAISE) + +#define PyArray_Put(ap, items, values) \ + PyArray_PutTo(ap, items, values, NPY_RAISE) + +/* Compatibility with old Numeric stuff -- don't use in new code */ + +#define PyArray_FromDimsAndData(nd, d, type, data) \ + PyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \ + data) + +#include "old_defines.h" + +#ifdef __cplusplus +} +#endif + +#endif /* NPY_NDARRAYOBJECT_H */ Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/ndarrayobject.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/noprefix.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/noprefix.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/noprefix.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,191 @@ +#ifndef NPY_NOPREFIX_H +#define NPY_NOPREFIX_H + +/* You can directly include noprefix.h as a backward +compatibility measure*/ +#ifndef NPY_NO_PREFIX +#include "ndarrayobject.h" +#endif + +#define MAX_DIMS NPY_MAXDIMS + +#define longlong npy_longlong +#define ulonglong npy_ulonglong +#define Bool npy_bool +#define longdouble npy_longdouble +#define byte npy_byte + +#ifndef _BSD_SOURCE +#define ushort npy_ushort +#define uint npy_uint +#define ulong npy_ulong +#endif + +#define ubyte npy_ubyte +#define ushort npy_ushort +#define uint npy_uint +#define ulong npy_ulong +#define cfloat npy_cfloat +#define cdouble npy_cdouble +#define clongdouble npy_clongdouble +#define Int8 npy_int8 +#define UInt8 npy_uint8 +#define Int16 npy_int16 +#define UInt16 npy_uint16 +#define Int32 npy_int32 +#define UInt32 npy_uint32 +#define Int64 npy_int64 +#define UInt64 npy_uint64 +#define Int128 npy_int128 +#define UInt128 npy_uint128 +#define Int256 npy_int256 +#define UInt256 npy_uint256 +#define Float16 npy_float16 +#define Complex32 npy_complex32 +#define Float32 npy_float32 +#define Complex64 npy_complex64 +#define Float64 npy_float64 +#define Complex128 npy_complex128 +#define Float80 npy_float80 +#define Complex160 npy_complex160 +#define Float96 npy_float96 +#define Complex192 npy_complex192 +#define Float128 npy_float128 +#define Complex256 npy_complex256 +#define intp npy_intp +#define uintp npy_uintp + +#define SIZEOF_INTP NPY_SIZEOF_INTP +#define SIZEOF_UINTP NPY_SIZEOF_UINTP + +#define LONGLONG_FMT NPY_LONGLONG_FMT +#define ULONGLONG_FMT NPY_ULONGLONG_FMT +#define LONGLONG_SUFFIX NPY_LONGLONG_SUFFIX +#define ULONGLONG_SUFFIX NPY_ULONGLONG_SUFFIX(x) + +#define MAX_INT8 127 +#define MIN_INT8 -128 +#define MAX_UINT8 255 +#define MAX_INT16 32767 +#define MIN_INT16 -32768 +#define MAX_UINT16 65535 +#define MAX_INT32 2147483647 +#define MIN_INT32 (-MAX_INT32 - 1) +#define MAX_UINT32 4294967295U +#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807) +#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1)) +#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615) +#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864) +#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1)) +#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728) +#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967) +#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1)) +#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935) + +#define MAX_BYTE NPY_MAX_BYTE +#define MIN_BYTE NPY_MIN_BYTE +#define MAX_UBYTE NPY_MAX_UBYTE +#define MAX_SHORT NPY_MAX_SHORT +#define MIN_SHORT NPY_MIN_SHORT +#define MAX_USHORT NPY_MAX_USHORT +#define MAX_INT NPY_MAX_INT +#define MIN_INT NPY_MIN_INT +#define MAX_UINT NPY_MAX_UINT +#define MAX_LONG NPY_MAX_LONG +#define MIN_LONG NPY_MIN_LONG +#define MAX_ULONG NPY_MAX_ULONG +#define MAX_LONGLONG NPY_MAX_LONGLONG +#define MIN_LONGLONG NPY_MIN_LONGLONG +#define MAX_ULONGLONG NPY_MAX_ULONGLONG + +#define SIZEOF_LONGDOUBLE NPY_SIZEOF_LONGDOUBLE +#define SIZEOF_LONGLONG NPY_SIZEOF_LONGLONG +#define BITSOF_BOOL NPY_BITSOF_BOOL +#define BITSOF_CHAR NPY_BITSOF_CHAR +#define BITSOF_SHORT NPY_BITSOF_SHORT +#define BITSOF_INT NPY_BITSOF_INT +#define BITSOF_LONG NPY_BITSOF_LONG +#define BITSOF_LONGLONG NPY_BITSOF_LONGLONG +#define BITSOF_FLOAT NPY_BITSOF_FLOAT +#define BITSOF_DOUBLE NPY_BITSOF_DOUBLE +#define BITSOF_LONGDOUBLE NPY_BITSOF_LONGDOUBLE + +#define PyArray_UCS4 npy_ucs4 +#define _pya_malloc PyArray_malloc +#define _pya_free PyArray_free +#define _pya_realloc PyArray_realloc + +#define BEGIN_THREADS_DEF NPY_BEGIN_THREADS_DEF +#define BEGIN_THREADS NPY_BEGIN_THREADS +#define END_THREADS NPY_END_THREADS +#define ALLOW_C_API_DEF NPY_ALLOW_C_API_DEF +#define ALLOW_C_API NPY_ALLOW_C_API +#define DISABLE_C_API NPY_DISABLE_C_API + +#define PY_FAIL NPY_FAIL +#define PY_SUCCEED NPY_SUCCEED + +#ifndef TRUE +#define TRUE NPY_TRUE +#endif + +#ifndef FALSE +#define FALSE NPY_FALSE +#endif + +#define LONGDOUBLE_FMT NPY_LONGDOUBLE_FMT + +#define CONTIGUOUS NPY_CONTIGUOUS +#define C_CONTIGUOUS NPY_C_CONTIGUOUS +#define FORTRAN NPY_FORTRAN +#define F_CONTIGUOUS NPY_F_CONTIGUOUS +#define OWNDATA NPY_OWNDATA +#define FORCECAST NPY_FORCECAST +#define ENSURECOPY NPY_ENSURECOPY +#define ENSUREARRAY NPY_ENSUREARRAY +#define ELEMENTSTRIDES NPY_ELEMENTSTRIDES +#define ALIGNED NPY_ALIGNED +#define NOTSWAPPED NPY_NOTSWAPPED +#define WRITEABLE NPY_WRITEABLE +#define UPDATEIFCOPY NPY_UPDATEIFCOPY +#define ARR_HAS_DESCR NPY_ARR_HAS_DESCR +#define BEHAVED NPY_BEHAVED +#define BEHAVED_NS NPY_BEHAVED_NS +#define CARRAY NPY_CARRAY +#define CARRAY_RO NPY_CARRAY_RO +#define FARRAY NPY_FARRAY +#define FARRAY_RO NPY_FARRAY_RO +#define DEFAULT NPY_DEFAULT +#define IN_ARRAY NPY_IN_ARRAY +#define OUT_ARRAY NPY_OUT_ARRAY +#define INOUT_ARRAY NPY_INOUT_ARRAY +#define IN_FARRAY NPY_IN_FARRAY +#define OUT_FARRAY NPY_OUT_FARRAY +#define INOUT_FARRAY NPY_INOUT_FARRAY +#define UPDATE_ALL NPY_UPDATE_ALL + +#define OWN_DATA NPY_OWNDATA +#define BEHAVED_FLAGS NPY_BEHAVED +#define BEHAVED_FLAGS_NS NPY_BEHAVED_NS +#define CARRAY_FLAGS_RO NPY_CARRAY_RO +#define CARRAY_FLAGS NPY_CARRAY +#define FARRAY_FLAGS NPY_FARRAY +#define FARRAY_FLAGS_RO NPY_FARRAY_RO +#define DEFAULT_FLAGS NPY_DEFAULT +#define UPDATE_ALL_FLAGS NPY_UPDATE_ALL_FLAGS + +#ifndef MIN +#define MIN PyArray_MIN +#endif +#ifndef MAX +#define MAX PyArray_MAX +#endif +#define MAX_INTP NPY_MAX_INTP +#define MIN_INTP NPY_MIN_INTP +#define MAX_UINTP NPY_MAX_UINTP +#define INTP_FMT NPY_INTP_FMT + +#define REFCOUNT PyArray_REFCOUNT +#define MAX_ELSIZE NPY_MAX_ELSIZE + +#endif Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/noprefix.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/npy_interrupt.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/npy_interrupt.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/npy_interrupt.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,117 @@ + +/* Signal handling: + +This header file defines macros that allow your code to handle +interrupts received during processing. Interrupts that +could reasonably be handled: + +SIGINT, SIGABRT, SIGALRM, SIGSEGV + +****Warning*************** + +Do not allow code that creates temporary memory or increases reference +counts of Python objects to be interrupted unless you handle it +differently. + +************************** + +The mechanism for handling interrupts is conceptually simple: + + - replace the signal handler with our own home-grown version + and store the old one. + - run the code to be interrupted -- if an interrupt occurs + the handler should basically just cause a return to the + calling function for finish work. + - restore the old signal handler + +Of course, every code that allows interrupts must account for +returning via the interrupt and handle clean-up correctly. But, +even still, the simple paradigm is complicated by at least three +factors. + + 1) platform portability (i.e. Microsoft says not to use longjmp + to return from signal handling. They have a __try and __except + extension to C instead but what about mingw?). + + 2) how to handle threads: apparently whether signals are delivered to + every thread of the process or the "invoking" thread is platform + dependent. --- we don't handle threads for now. + + 3) do we need to worry about re-entrance. For now, assume the + code will not call-back into itself. + +Ideas: + + 1) Start by implementing an approach that works on platforms that + can use setjmp and longjmp functionality and does nothing + on other platforms. + + 2) Ignore threads --- i.e. do not mix interrupt handling and threads + + 3) Add a default signal_handler function to the C-API but have the rest + use macros. + + +Simple Interface: + + +In your C-extension: around a block of code you want to be interruptable +with a SIGINT + +NPY_SIGINT_ON +[code] +NPY_SIGINT_OFF + +In order for this to work correctly, the +[code] block must not allocate any memory or alter the reference count of any +Python objects. In other words [code] must be interruptible so that continuation +after NPY_SIGINT_OFF will only be "missing some computations" + +Interrupt handling does not work well with threads. + +*/ + +/* Add signal handling macros + Make the global variable and signal handler part of the C-API +*/ + +#ifndef NPY_INTERRUPT_H +#define NPY_INTERRUPT_H + +#ifndef NPY_NO_SIGNAL + +#include +#include + +#ifndef sigsetjmp + +#define SIGSETJMP(arg1, arg2) setjmp(arg1) +#define SIGLONGJMP(arg1, arg2) longjmp(arg1, arg2) +#define SIGJMP_BUF jmp_buf + +#else + +#define SIGSETJMP(arg1, arg2) sigsetjmp(arg1, arg2) +#define SIGLONGJMP(arg1, arg2) siglongjmp(arg1, arg2) +#define SIGJMP_BUF sigjmp_buf + +#endif + +# define NPY_SIGINT_ON { \ + PyOS_sighandler_t _npy_sig_save; \ + _npy_sig_save = PyOS_setsig(SIGINT, _PyArray_SigintHandler); \ + if (SIGSETJMP(*((SIGJMP_BUF *)_PyArray_GetSigintBuf()), \ + 1) == 0) { \ + +# define NPY_SIGINT_OFF } \ + PyOS_setsig(SIGINT, _npy_sig_save); \ + } + +#else /* NPY_NO_SIGNAL */ + +# define NPY_SIGINT_ON +# define NPY_SIGINT_OFF + +#endif /* HAVE_SIGSETJMP */ + +#endif /* NPY_INTERRUPT_H */ Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/npy_interrupt.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/old_defines.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/old_defines.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/old_defines.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,169 @@ +#define NDARRAY_VERSION NPY_VERSION + +#define PyArray_MIN_BUFSIZE NPY_MIN_BUFSIZE +#define PyArray_MAX_BUFSIZE NPY_MAX_BUFSIZE +#define PyArray_BUFSIZE NPY_BUFSIZE + +#define PyArray_PRIORITY NPY_PRIORITY +#define PyArray_SUBTYPE_PRIORITY NPY_PRIORITY +#define PyArray_NUM_FLOATTYPE NPY_NUM_FLOATTYPE + +#define NPY_MAX PyArray_MAX +#define NPY_MIN PyArray_MIN + +#define PyArray_TYPES NPY_TYPES +#define PyArray_BOOL NPY_BOOL +#define PyArray_BYTE NPY_BYTE +#define PyArray_UBYTE NPY_UBYTE +#define PyArray_SHORT NPY_SHORT +#define PyArray_USHORT NPY_USHORT +#define PyArray_INT NPY_INT +#define PyArray_UINT NPY_UINT +#define PyArray_LONG NPY_LONG +#define PyArray_ULONG NPY_ULONG +#define PyArray_LONGLONG NPY_LONGLONG +#define PyArray_ULONGLONG NPY_ULONGLONG +#define PyArray_FLOAT NPY_FLOAT +#define PyArray_DOUBLE NPY_DOUBLE +#define PyArray_LONGDOUBLE NPY_LONGDOUBLE +#define PyArray_CFLOAT NPY_CFLOAT +#define PyArray_CDOUBLE NPY_CDOUBLE +#define PyArray_CLONGDOUBLE NPY_CLONGDOUBLE +#define PyArray_OBJECT NPY_OBJECT +#define PyArray_STRING NPY_STRING +#define PyArray_UNICODE NPY_UNICODE +#define PyArray_VOID NPY_VOID +#define PyArray_NTYPES NPY_NTYPES +#define PyArray_NOTYPE NPY_NOTYPE +#define PyArray_CHAR NPY_CHAR +#define PyArray_USERDEF NPY_USERDEF +#define PyArray_NUMUSERTYPES NPY_NUMUSERTYPES + +#define PyArray_INTP NPY_INTP +#define PyArray_UINTP NPY_UINTP + +#define PyArray_INT8 NPY_INT8 +#define PyArray_UINT8 NPY_UINT8 +#define PyArray_INT16 NPY_INT16 +#define PyArray_UINT16 NPY_UINT16 +#define PyArray_INT32 NPY_INT32 +#define PyArray_UINT32 NPY_UINT32 + +#ifdef NPY_INT64 +#define PyArray_INT64 NPY_INT64 +#define PyArray_UINT64 NPY_UINT64 +#endif + +#ifdef NPY_INT128 +#define PyArray_INT128 NPY_INT128 +#define PyArray_UINT128 NPY_UINT128 +#endif + +#ifdef NPY_FLOAT16 +#define PyArray_FLOAT16 NPY_FLOAT16 +#define PyArray_COMPLEX32 NPY_COMPLEX32 +#endif + +#ifdef NPY_FLOAT80 +#define PyArray_FLOAT80 NPY_FLOAT80 +#define PyArray_COMPLEX160 NPY_COMPLEX160 +#endif + +#ifdef NPY_FLOAT96 +#define PyArray_FLOAT96 NPY_FLOAT96 +#define PyArray_COMPLEX192 NPY_COMPLEX192 +#endif + +#ifdef NPY_FLOAT128 +#define PyArray_FLOAT128 NPY_FLOAT128 +#define PyArray_COMPLEX256 NPY_COMPLEX256 +#endif + +#define PyArray_FLOAT32 NPY_FLOAT32 +#define PyArray_COMPLEX64 NPY_COMPLEX64 +#define PyArray_FLOAT64 NPY_FLOAT64 +#define PyArray_COMPLEX128 NPY_COMPLEX128 + + +#define PyArray_TYPECHAR NPY_TYPECHAR +#define PyArray_BOOLLTR NPY_BOOLLTR +#define PyArray_BYTELTR NPY_BYTELTR +#define PyArray_UBYTELTR NPY_UBYTELTR +#define PyArray_SHORTLTR NPY_SHORTLTR +#define PyArray_USHORTLTR NPY_USHORTLTR +#define PyArray_INTLTR NPY_INTLTR +#define PyArray_UINTLTR NPY_UINTLTR +#define PyArray_LONGLTR NPY_LONGLTR +#define PyArray_ULONGLTR NPY_ULONGLTR +#define PyArray_LONGLONGLTR NPY_LONGLONGLTR +#define PyArray_ULONGLONGLTR NPY_ULONGLONGLTR +#define PyArray_FLOATLTR NPY_FLOATLTR +#define PyArray_DOUBLELTR NPY_DOUBLELTR +#define PyArray_LONGDOUBLELTR NPY_LONGDOUBLELTR +#define PyArray_CFLOATLTR NPY_CFLOATLTR +#define PyArray_CDOUBLELTR NPY_CDOUBLELTR +#define PyArray_CLONGDOUBLELTR NPY_CLONGDOUBLELTR +#define PyArray_OBJECTLTR NPY_OBJECTLTR +#define PyArray_STRINGLTR NPY_STRINGLTR +#define PyArray_STRINGLTR2 NPY_STRINGLTR2 +#define PyArray_UNICODELTR NPY_UNICODELTR +#define PyArray_VOIDLTR NPY_VOIDLTR +#define PyArray_CHARLTR NPY_CHARLTR +#define PyArray_INTPLTR NPY_INTPLTR +#define PyArray_UINTPLTR NPY_UINTPLTR +#define PyArray_GENBOOLLTR NPY_GENBOOLLTR +#define PyArray_SIGNEDLTR NPY_SIGNEDLTR +#define PyArray_UNSIGNEDLTR NPY_UNSIGNEDLTR +#define PyArray_FLOATINGLTR NPY_FLOATINGLTR +#define PyArray_COMPLEXLTR NPY_COMPLEXLTR + +#define PyArray_QUICKSORT NPY_QUICKSORT +#define PyArray_HEAPSORT NPY_HEAPSORT +#define PyArray_MERGESORT NPY_MERGESORT +#define PyArray_SORTKIND NPY_SORTKIND +#define PyArray_NSORTS NPY_NSORTS + +#define PyArray_NOSCALAR NPY_NOSCALAR +#define PyArray_BOOL_SCALAR NPY_BOOL_SCALAR +#define PyArray_INTPOS_SCALAR NPY_INTPOS_SCALAR +#define PyArray_INTNEG_SCALAR NPY_INTNEG_SCALAR +#define PyArray_FLOAT_SCALAR NPY_FLOAT_SCALAR +#define PyArray_COMPLEX_SCALAR NPY_COMPLEX_SCALAR +#define PyArray_OBJECT_SCALAR NPY_OBJECT_SCALAR +#define PyArray_SCALARKIND NPY_SCALARKIND +#define PyArray_NSCALARKINDS NPY_NSCALARKINDS + +#define PyArray_ANYORDER NPY_ANYORDER +#define PyArray_CORDER NPY_CORDER +#define PyArray_FORTRANORDER NPY_FORTRANORDER +#define PyArray_ORDER NPY_ORDER + +#define PyDescr_ISBOOL PyDataType_ISBOOL +#define PyDescr_ISUNSIGNED PyDataType_ISUNSIGNED +#define PyDescr_ISSIGNED PyDataType_ISSIGNED +#define PyDescr_ISINTEGER PyDataType_ISINTEGER +#define PyDescr_ISFLOAT PyDataType_ISFLOAT +#define PyDescr_ISNUMBER PyDataType_ISNUMBER +#define PyDescr_ISSTRING PyDataType_ISSTRING +#define PyDescr_ISCOMPLEX PyDataType_ISCOMPLEX +#define PyDescr_ISPYTHON PyDataType_ISPYTHON +#define PyDescr_ISFLEXIBLE PyDataType_ISFLEXIBLE +#define PyDescr_ISUSERDEF PyDataType_ISUSERDEF +#define PyDescr_ISEXTENDED PyDataType_ISEXTENDED +#define PyDescr_ISOBJECT PyDataType_ISOBJECT +#define PyDescr_HASFIELDS PyDataType_HASFIELDS + +#define PyArray_LITTLE NPY_LITTLE +#define PyArray_BIG NPY_BIG +#define PyArray_NATIVE NPY_NATIVE +#define PyArray_SWAP NPY_SWAP +#define PyArray_IGNORE NPY_IGNORE + +#define PyArray_NATBYTE NPY_NATBYTE +#define PyArray_OPPBYTE NPY_OPPBYTE + +#define PyArray_MAX_ELSIZE NPY_MAX_ELSIZE + +#define PyArray_USE_PYMEM NPY_USE_PYMEM + +#define PyArray_RemoveLargest PyArray_RemoveSmallest Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/old_defines.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/oldnumeric.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/oldnumeric.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/oldnumeric.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,23 @@ +#include "arrayobject.h" + +#ifndef REFCOUNT +# define REFCOUNT NPY_REFCOUNT +# define MAX_ELSIZE 16 +#endif + +#define PyArray_UNSIGNED_TYPES +#define PyArray_SBYTE PyArray_BYTE +#define PyArray_CopyArray PyArray_CopyInto +#define _PyArray_multiply_list PyArray_MultiplyIntList +#define PyArray_ISSPACESAVER(m) NPY_FALSE +#define PyScalarArray_Check PyArray_CheckScalar + +#define CONTIGUOUS NPY_CONTIGUOUS +#define OWN_DIMENSIONS 0 +#define OWN_STRIDES 0 +#define OWN_DATA NPY_OWNDATA +#define SAVESPACE 0 +#define SAVESPACEBIT 0 + +#undef import_array +#define import_array() { if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); } } Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/oldnumeric.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/setup.py =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/setup.py 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/setup.py 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,8 @@ + +#!/usr/bin/env python + +from distutils.core import setup, Extension + +MOD = 'NDI_Segmenter' +setup(name=MOD, ext_modules=[Extension(MOD, sources=['Segmenter_EXT.c', 'Segmenter_IMPL.c'])]) + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/setup.py ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/slice112.raw =================================================================== (Binary files differ) Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/slice112.raw ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/ndimage_segmenter/scipy/NDISegmenter/testShenCastan.py =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/testShenCastan.py 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/testShenCastan.py 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,19 @@ +import numpy as N +import volumeInput as V +import EdgeFilters as E +import edgeSegmenter as S + +slice = V.getFilteredSlice('slice112.raw') + +edges, groups = S.Canny(slice) + +ShenCastanLow = 0.3 +b = 0.8 +window = 7 +lowThreshold = 220 + 2048 +highThreshold = 600 + 2048 + +edges, groups = S.ShenCastan(slice) + +edges, groups = E.ShenCastanEdges(ShenCastanLow, b, window, lowThreshold, highThreshold, slice) + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/testShenCastan.py ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/ufuncobject.h =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/ufuncobject.h 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/ufuncobject.h 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,365 @@ +#ifndef Py_UFUNCOBJECT_H +#define Py_UFUNCOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *); + +typedef struct { + PyObject_HEAD + int nin, nout, nargs; + int identity; + PyUFuncGenericFunction *functions; + void **data; + int ntypes; + int check_return; + char *name, *types; + char *doc; + void *ptr; + PyObject *obj; + PyObject *userloops; +} PyUFuncObject; + +#include "arrayobject.h" + +#define UFUNC_ERR_IGNORE 0 +#define UFUNC_ERR_WARN 1 +#define UFUNC_ERR_RAISE 2 +#define UFUNC_ERR_CALL 3 +#define UFUNC_ERR_PRINT 4 +#define UFUNC_ERR_LOG 5 + + /* Python side integer mask */ + +#define UFUNC_MASK_DIVIDEBYZERO 0x07 +#define UFUNC_MASK_OVERFLOW 0x3f +#define UFUNC_MASK_UNDERFLOW 0x1ff +#define UFUNC_MASK_INVALID 0xfff + +#define UFUNC_SHIFT_DIVIDEBYZERO 0 +#define UFUNC_SHIFT_OVERFLOW 3 +#define UFUNC_SHIFT_UNDERFLOW 6 +#define UFUNC_SHIFT_INVALID 9 + + +/* platform-dependent code translates floating point + status to an integer sum of these values +*/ +#define UFUNC_FPE_DIVIDEBYZERO 1 +#define UFUNC_FPE_OVERFLOW 2 +#define UFUNC_FPE_UNDERFLOW 4 +#define UFUNC_FPE_INVALID 8 + +#define UFUNC_ERR_DEFAULT 0 /* Error mode that avoids look-up (no checking) */ + + /* Default user error mode */ +#define UFUNC_ERR_DEFAULT2 \ + (UFUNC_ERR_PRINT << UFUNC_SHIFT_DIVIDEBYZERO) + \ + (UFUNC_ERR_PRINT << UFUNC_SHIFT_OVERFLOW) + \ + (UFUNC_ERR_PRINT << UFUNC_SHIFT_INVALID) + + /* Only internal -- not exported, yet*/ +typedef struct { + /* Multi-iterator portion --- needs to be present in this order + to work with PyArray_Broadcast */ + PyObject_HEAD + int numiter; + npy_intp size; + npy_intp index; + int nd; + npy_intp dimensions[NPY_MAXDIMS]; + PyArrayIterObject *iters[NPY_MAXARGS]; + /* End of Multi-iterator portion */ + + /* The ufunc */ + PyUFuncObject *ufunc; + + /* The error handling */ + int errormask; /* Integer showing desired error handling */ + PyObject *errobj; /* currently a tuple with + (string, func or obj with write method or None) + */ + int first; + + /* Specific function and data to use */ + PyUFuncGenericFunction function; + void *funcdata; + + /* Loop method */ + int meth; + + /* Whether we need to copy to a buffer or not.*/ + int needbuffer[NPY_MAXARGS]; + int leftover; + int ninnerloops; + int lastdim; + + /* Whether or not to swap */ + int swap[NPY_MAXARGS]; + + /* Buffers for the loop */ + char *buffer[NPY_MAXARGS]; + int bufsize; + npy_intp bufcnt; + char *dptr[NPY_MAXARGS]; + + /* For casting */ + char *castbuf[NPY_MAXARGS]; + PyArray_VectorUnaryFunc *cast[NPY_MAXARGS]; + + /* usually points to buffer but when a cast is to be + done it switches for that argument to castbuf. + */ + char *bufptr[NPY_MAXARGS]; + + /* Steps filled in from iters or sizeof(item) + depending on loop method. + */ + npy_intp steps[NPY_MAXARGS]; + + int obj; /* This loop uses object arrays */ + int notimplemented; /* The loop caused notimplemented */ + int objfunc; /* This loop calls object functions + (an inner-loop function with argument types */ +} PyUFuncLoopObject; + +/* Could make this more clever someday */ +#define UFUNC_MAXIDENTITY 32 + +typedef struct { + PyObject_HEAD + PyArrayIterObject *it; + PyArrayObject *ret; + PyArrayIterObject *rit; /* Needed for Accumulate */ + int outsize; + npy_intp index; + npy_intp size; + char idptr[UFUNC_MAXIDENTITY]; + + /* The ufunc */ + PyUFuncObject *ufunc; + + /* The error handling */ + int errormask; + PyObject *errobj; + int first; + + PyUFuncGenericFunction function; + void *funcdata; + int meth; + int swap; + + char *buffer; + int bufsize; + + char *castbuf; + PyArray_VectorUnaryFunc *cast; + + char *bufptr[3]; + npy_intp steps[3]; + + npy_intp N; + int instrides; + int insize; + char *inptr; + + /* For copying small arrays */ + PyObject *decref; + + int obj; + int retbase; + +} PyUFuncReduceObject; + + +#if NPY_ALLOW_THREADS +#define NPY_LOOP_BEGIN_THREADS if (!(loop->obj)) {_save = PyEval_SaveThread();} +#define NPY_LOOP_END_THREADS if (!(loop->obj)) {PyEval_RestoreThread(_save);} +#else +#define NPY_LOOP_BEGIN_THREADS +#define NPY_LOOP_END_THREADS +#endif + +#define PyUFunc_One 1 +#define PyUFunc_Zero 0 +#define PyUFunc_None -1 + +#define UFUNC_REDUCE 0 +#define UFUNC_ACCUMULATE 1 +#define UFUNC_REDUCEAT 2 +#define UFUNC_OUTER 3 + + +typedef struct { + int nin; + int nout; + PyObject *callable; +} PyUFunc_PyFuncData; + +/* A linked-list of function information for + user-defined 1-d loops. + */ +typedef struct _loop1d_info { + PyUFuncGenericFunction func; + void *data; + int *arg_types; + struct _loop1d_info *next; +} PyUFunc_Loop1d; + + +#include "__ufunc_api.h" + +#define UFUNC_PYVALS_NAME "UFUNC_PYVALS" + +#define UFUNC_CHECK_ERROR(arg) \ + if (((arg)->obj && PyErr_Occurred()) || \ + ((arg)->errormask && \ + PyUFunc_checkfperr((arg)->errormask, \ + (arg)->errobj, \ + &(arg)->first))) \ + goto fail + +/* This code checks the IEEE status flags in a platform-dependent way */ +/* Adapted from Numarray */ + +/* OSF/Alpha (Tru64) ---------------------------------------------*/ +#if defined(__osf__) && defined(__alpha) + +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + unsigned long fpstatus; \ + \ + fpstatus = ieee_get_fp_control(); \ + /* clear status bits as well as disable exception mode if on */ \ + ieee_set_fp_control( 0 ); \ + ret = ((IEEE_STATUS_DZE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((IEEE_STATUS_OVF & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((IEEE_STATUS_UNF & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((IEEE_STATUS_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + } + +/* MS Windows -----------------------------------------------------*/ +#elif defined(_MSC_VER) + +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + int fpstatus = (int) _clearfp(); \ + \ + ret = ((SW_ZERODIVIDE & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((SW_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((SW_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((SW_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + } + +#define isnan(x) (_isnan((double)(x))) +#define isinf(x) ((_fpclass((double)(x)) == _FPCLASS_PINF) || \ + (_fpclass((double)(x)) == _FPCLASS_NINF)) +#define isfinite(x) (_finite((double) x)) + +/* Solaris --------------------------------------------------------*/ +/* --------ignoring SunOS ieee_flags approach, someone else can +** deal with that! */ +#elif defined(sun) || defined(__BSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + int fpstatus; \ + \ + fpstatus = (int) fpgetsticky(); \ + ret = ((FP_X_DZ & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((FP_X_OFL & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((FP_X_UFL & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((FP_X_INV & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + (void) fpsetsticky(0); \ + } + +#elif defined(__GLIBC__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__MINGW32__) + +#if defined(__GLIBC__) || defined(__APPLE__) || defined(__MINGW32__) +#include +#elif defined(__CYGWIN__) +#include "fenv/fenv.c" +#endif + +#define UFUNC_CHECK_STATUS(ret) { \ + int fpstatus = (int) fetestexcept(FE_DIVBYZERO | FE_OVERFLOW | \ + FE_UNDERFLOW | FE_INVALID); \ + ret = ((FE_DIVBYZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((FE_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((FE_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((FE_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + (void) feclearexcept(FE_DIVBYZERO | FE_OVERFLOW | \ + FE_UNDERFLOW | FE_INVALID); \ +} + +#define generate_divbyzero_error() feraiseexcept(FE_DIVBYZERO) +#define generate_overflow_error() feraiseexcept(FE_OVERFLOW) + +#elif defined(_AIX) + +#include +#include + +#define UFUNC_CHECK_STATUS(ret) { \ + fpflag_t fpstatus; \ + \ + fpstatus = fp_read_flag(); \ + ret = ((FP_DIV_BY_ZERO & fpstatus) ? UFUNC_FPE_DIVIDEBYZERO : 0) \ + | ((FP_OVERFLOW & fpstatus) ? UFUNC_FPE_OVERFLOW : 0) \ + | ((FP_UNDERFLOW & fpstatus) ? UFUNC_FPE_UNDERFLOW : 0) \ + | ((FP_INVALID & fpstatus) ? UFUNC_FPE_INVALID : 0); \ + fp_swap_flag(0); \ +} + +#define generate_divbyzero_error() fp_raise_xcp(FP_DIV_BY_ZERO) +#define generate_overflow_error() fp_raise_xcp(FP_OVERFLOW) + +#else + +#define NO_FLOATING_POINT_SUPPORT +#define UFUNC_CHECK_STATUS(ret) { \ + ret = 0; \ + } + +#endif + +/* These should really be altered to just set the corresponding bit + in the floating point status flag. Need to figure out how to do that + on all the platforms... +*/ + +#if !defined(generate_divbyzero_error) +static int numeric_zero2 = 0; +static void generate_divbyzero_error(void) { + double dummy; + dummy = 1./numeric_zero2; + if (dummy) /* to prevent optimizer from eliminating expression */ + return; + else /* should never be called */ + numeric_zero2 += 1; + return; +} +#endif + +#if !defined(generate_overflow_error) +static double numeric_two = 2.0; +static void generate_overflow_error(void) { + double dummy; + dummy = pow(numeric_two,1000); + if (dummy) + return; + else + numeric_two += 0.1; + return; + return; +} +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_UFUNCOBJECT_H */ Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/ufuncobject.h ___________________________________________________________________ Name: svn:executable + * Added: branches/ndimage_segmenter/scipy/NDISegmenter/volumeInput.py =================================================================== --- branches/ndimage_segmenter/scipy/NDISegmenter/volumeInput.py 2007-11-02 19:51:44 UTC (rev 3491) +++ branches/ndimage_segmenter/scipy/NDISegmenter/volumeInput.py 2007-11-02 20:09:04 UTC (rev 3492) @@ -0,0 +1,85 @@ +import struct +import numpy as N + +def getFilteredSlice(imageName='junk.raw', bytes=2, rows=512, columns=512): + image = open(imageName, 'rb') + slice = image.read(rows*columns*bytes) + if bytes == 2: + values = struct.unpack('h'*rows*columns, slice) + else: + values = struct.unpack('i'*rows*columns, slice) + + ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + return (ImageSlice) + +def getSlice(mySlice, rows=512, columns=512, bytes=2): + image = open('C:\PythonStuff\CardiacCT.vol', 'rb') + image.seek(mySlice*rows*columns*bytes) + slice = image.read(rows*columns*bytes) + values = struct.unpack('h'*rows*columns, slice) + ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + return (ImageSlice+2048) + +def saveSlice(mySlice, filename='junk.raw', rows=512, columns=512, bytes=2): + # just save the slice to a fixed file + slice = mySlice.astype(int) + image = open(filename, 'wb') + image.write(slice) + image.close() + return + + +def buildDGaussKernel(gWidth, sigma): + + kernel = zeros((1+2*(gWidth-1)), dtype=float) + indices = range(1, gWidth) + + i = 0 + kernel[gWidth-1] = math.exp(((-i*i)/(2.0 * sigma * sigma))) + kernel[gWidth-1] *= -(i / (sigma * sigma)) + for i in indices: + kernel[gWidth-1+i] = math.exp(((-i*i)/(2.0 * sigma * sigma))) + kernel[gWidth-1+i] *= -(i / (sigma * sigma)) + kernel[gWidth-1-i] = -kernel[gWidth-1+i] # since using correlated1d that doesn't + # flip the kernel like in convolution + + return kernel + + +def build2DKernel(aperature, hiFilterCutoff): + rad = math.pi / 180.0 + HalfFilterTaps = (aperature-1) / 2 + kernel = zeros((aperature), dtype=float) + + LC = 0.0 + HC = hiFilterCutoff * rad + t2 = 2.0 * math.pi + t1 = 2.0 * HalfFilterTaps + 1.0 + indices = range(-HalfFilterTaps, HalfFilterTaps+1, 1) + # indices = arange(-HalfFilterTaps, HalfFilterTaps+1, 1) + # indicesNZ = indices[indices.nonzero()] + # indicesP = indices[indices>0] + + j = 0 + for i in indices: + if i == 0: + tLOW = LC + tHIGH = HC + else: + tLOW = math.sin(i*LC)/i + tHIGH = math.sin(i*HC)/i + t3 = 0.54 + 0.46*(math.cos(i*t2/t1)) + t4 = t3*(tHIGH-tLOW) + kernel[j] = t4 + j += 1 + + # normalize the kernel + sum = kernel.sum() + kernel /= sum + + return kernel + + + + + Property changes on: branches/ndimage_segmenter/scipy/NDISegmenter/volumeInput.py ___________________________________________________________________ Name: svn:executable + * From scipy-svn at scipy.org Fri Nov 2 19:33:52 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Nov 2007 18:33:52 -0500 (CDT) Subject: [Scipy-svn] r3493 - in trunk/scipy/io: . tests Message-ID: <20071102233352.A5BD739C063@new.scipy.org> Author: chris.burns Date: 2007-11-02 18:33:49 -0500 (Fri, 02 Nov 2007) New Revision: 3493 Modified: trunk/scipy/io/datasource.py trunk/scipy/io/tests/test_datasource.py Log: Add more datasource tests and documentation. Fix some path resolution bugs. Modified: trunk/scipy/io/datasource.py =================================================================== --- trunk/scipy/io/datasource.py 2007-11-02 20:09:04 UTC (rev 3492) +++ trunk/scipy/io/datasource.py 2007-11-02 23:33:49 UTC (rev 3493) @@ -1,7 +1,7 @@ """A file interface for handling local and remote data files. -The goal of datasource is to abstract some of the file system operations when +The goal of datasource is to abstract some of the file system operations when dealing with data files so the researcher doesn't have to know all the -low-level details. Through datasource, a researcher can obtain and use a +low-level details. Through datasource, a researcher can obtain and use a file with one function call, regardless of location of the file. DataSource is meant to augment standard python libraries, not replace them. @@ -25,7 +25,7 @@ >>> # './www.google.com/index.html' >>> # opens the file and returns a file object. >>> fp = ds.open('http://www.google.com/index.html') - >>> + >>> >>> # Use the file as you normally would >>> fp.read() >>> fp.close() @@ -61,6 +61,31 @@ _file_openers = {".gz":gzip.open, ".bz2":bz2.BZ2File, None:file} +def open(path, mode='r', destpath=os.curdir): + """Open ``path`` with ``mode`` and return the file object. + + If ``path`` is an URL, it will be downloaded, stored in the DataSource + directory and opened from there. + + *Parameters*: + + path : {string} + + mode : {string}, optional + + destpath : {string}, optional + Destination directory where URLs will be downloaded and stored. + + *Returns*: + + file object + + """ + + ds = DataSource(destpath) + return ds.open(path, mode) + + class DataSource (object): """A generic data source file (file, http, ftp, ...). @@ -69,27 +94,27 @@ details of downloading the file, allowing you to simply pass in a valid file path (or URL) and obtain a file object. - Methods: + *Methods*: - exists : test if the file exists locally or remotely - abspath : get absolute path of the file in the DataSource directory - open : open the file - Example URL DataSource:: + *Example URL DataSource*:: # Initialize DataSource with a local directory, default is os.curdir. ds = DataSource('/home/guido') - + # Open remote file. # File will be downloaded and opened from here: # /home/guido/site/xyz.txt ds.open('http://fake.xyz.web/site/xyz.txt') - - Example using DataSource for temporary files:: + *Example using DataSource for temporary files*:: + # Initialize DataSource with 'None' for the local directory. ds = DataSource(None) - + # Open local file. # Opened file exists in a temporary directory like: # /tmp/tmpUnhcvM/foobar.txt @@ -99,13 +124,13 @@ *Notes*: BUG : URLs require a scheme string ('http://') to be used. www.google.com will fail. - + >>> repos.exists('www.google.com/index.html') False >>> repos.exists('http://www.google.com/index.html') True - + """ def __init__(self, destpath=os.curdir): @@ -118,6 +143,7 @@ self._istmpdest = True def __del__(self): + # Remove temp directories if self._istmpdest: rmtree(self._destpath) @@ -161,7 +187,7 @@ def _isurl(self, path): """Test if path is a net location. Tests the scheme and netloc.""" - + # BUG : URLs require a scheme string ('http://') to be used. # www.google.com will fail. # Should we prepend the scheme for those that don't have it and @@ -214,9 +240,15 @@ """ # Build list of possible local file paths - filelist = self._possible_names(self.abspath(path)) - if self._isurl(path): - # Add list of possible remote urls + if not self._isurl(path): + # Valid local paths + filelist = self._possible_names(path) + # Paths in self._destpath + filelist += self._possible_names(self.abspath(path)) + else: + # Cached URLs in self._destpath + filelist = self._possible_names(self.abspath(path)) + # Remote URLs filelist = filelist + self._possible_names(path) for name in filelist: @@ -250,6 +282,13 @@ """ + # TODO: This should be more robust. Handles case where path includes + # the destpath, but not other sub-paths. Failing case: + # path = /home/guido/datafile.txt + # destpath = /home/alex/ + # upath = self.abspath(path) + # upath == '/home/alex/home/guido/datafile.txt' + # handle case where path includes self._destpath splitpath = path.split(self._destpath, 2) if len(splitpath) > 1: @@ -263,9 +302,9 @@ Test if ``path`` exists as (and in this order): - a local file. - - a remote URL that have been downloaded and stored locally in the + - a remote URL that have been downloaded and stored locally in the DataSource directory. - - a remote URL that has not been downloaded, but is valid and + - a remote URL that has not been downloaded, but is valid and accessible. *Parameters*: @@ -284,25 +323,30 @@ *Notes* When ``path`` is an URL, ``exist`` will return True if it's either - stored locally in the DataSource directory, or is a valid remote + stored locally in the DataSource directory, or is a valid remote URL. DataSource does not discriminate between to two, the file is accessible if it exists in either location. """ + # Test local path + if os.path.exists(path): + return True + + # Test cached url upath = self.abspath(path) if os.path.exists(upath): return True - elif self._isurl(path): + + # Test remote url + if self._isurl(path): try: netfile = urlopen(path) - # just validate existence, nothing more. del(netfile) return True except URLError: return False - else: - return False + return False def open(self, path, mode='r'): """Open ``path`` with ``mode`` and return the file object. @@ -323,11 +367,11 @@ """ - # TODO: There is no support for opening a file for writing which + # TODO: There is no support for opening a file for writing which # doesn't exist yet (creating a file). Should there be? # TODO: Add a ``subdir`` parameter for specifying the subdirectory - # used to store URLs in self._destpath. + # used to store URLs in self._destpath. if self._isurl(path) and self._iswritemode(mode): raise ValueError("URLs are not writeable") @@ -344,20 +388,21 @@ class Repository (DataSource): - """A data repository where multiple DataSource's share a base URL/directory. + """A data Repository where multiple DataSource's share a base URL/directory. - Use a Repository when you will be working with multiple files from one - base URL or directory. Initialize the Respository with the base URL, - then refer to each file only by it's filename. + Repository extends DataSource by prepending a base URL (or directory) to + all the files it handles. Use a Repository when you will be working with + multiple files from one base URL. Initialize the Respository with the + base URL, then refer to each file by it's filename only. - Methods: + *Methods*: - exists : test if the file exists locally or remotely - abspath : get absolute path of the file in the DataSource directory - open : open the file - Toy example:: - + *Toy example*:: + # Analyze all files in the repository. repos = Repository('/home/user/data/dir/') for filename in filelist: @@ -375,6 +420,9 @@ DataSource.__init__(self, destpath=destpath) self._baseurl = baseurl + def __del__(self): + DataSource.__del__(self) + def _fullpath(self, path): """Return complete path for path. Prepends baseurl if necessary.""" splitpath = path.split(self._baseurl, 2) @@ -385,27 +433,25 @@ return result def _findfile(self, path): - """Extend DataSource method to add baseurl to ``path``.""" - #print 'Repository._findfile:', path + """Extend DataSource method to prepend baseurl to ``path``.""" return DataSource._findfile(self, self._fullpath(path)) def abspath(self, path): - """Extend DataSource method to add baseurl to ``path``.""" + """Extend DataSource method to prepend baseurl to ``path``.""" return DataSource.abspath(self, self._fullpath(path)) - def exists(self, path): - """Extend DataSource method to add baseurl to ``path``.""" - #print 'Respository.exists:', path + def exists(self, path): + """Extend DataSource method to prepend baseurl to ``path``.""" return DataSource.exists(self, self._fullpath(path)) def open(self, path, mode='r'): - """Extend DataSource method to add baseurl to ``path``.""" - #print 'Repository.open:', path + """Extend DataSource method to prepend baseurl to ``path``.""" return DataSource.open(self, self._fullpath(path), mode) def listdir(self): '''List files in the source Repository.''' if self._isurl(self._baseurl): - raise NotImplementedError + raise NotImplementedError, \ + "Directory listing of URLs, not supported yet." else: return os.listdir(self._baseurl) Modified: trunk/scipy/io/tests/test_datasource.py =================================================================== --- trunk/scipy/io/tests/test_datasource.py 2007-11-02 20:09:04 UTC (rev 3492) +++ trunk/scipy/io/tests/test_datasource.py 2007-11-02 23:33:49 UTC (rev 3493) @@ -136,8 +136,14 @@ self.assertEqual(self.ds.exists(invalid_httpurl()), False) def test_ValidFile(self): + # Test valid file in destpath tmpfile = valid_textfile(self.tmpdir) assert self.ds.exists(tmpfile) + # Test valid local file not in destpath + localdir = mkdtemp() + tmpfile = valid_textfile(localdir) + assert self.ds.exists(tmpfile) + rmtree(localdir) def test_InvalidFile(self): tmpfile = invalid_textfile(self.tmpdir) @@ -183,9 +189,11 @@ class TestRespositoryAbspath(NumpyTestCase): def setUp(self): - self.repos = datasource.Repository(valid_baseurl(), None) + self.tmpdir = mkdtemp() + self.repos = datasource.Repository(valid_baseurl(), self.tmpdir) def tearDown(self): + rmtree(self.tmpdir) del self.repos def test_ValidHTTP(self): @@ -196,6 +204,54 @@ self.assertEqual(local_path, filepath) +class TestRepositoryExists(NumpyTestCase): + def setUp(self): + self.tmpdir = mkdtemp() + self.repos = datasource.Repository(valid_baseurl(), self.tmpdir) + + def tearDown(self): + rmtree(self.tmpdir) + del self.repos + + def test_ValidFile(self): + # Create local temp file + tmpfile = valid_textfile(self.tmpdir) + assert self.repos.exists(tmpfile) + + def test_InvalidFile(self): + tmpfile = invalid_textfile(self.tmpdir) + self.assertEqual(self.repos.exists(tmpfile), False) + + def test_RemoveHTTPFile(self): + assert self.repos.exists(valid_httpurl()) + + def test_CachedHTTPFile(self): + localfile = valid_httpurl() + # Create a locally cached temp file with an URL based + # directory structure. This is similar to what Repository.open + # would do. + scheme, netloc, upath, pms, qry, frg = urlparse(localfile) + local_path = os.path.join(self.repos._destpath, netloc) + os.mkdir(local_path, 0700) + tmpfile = valid_textfile(local_path) + assert self.repos.exists(tmpfile) + + +class TestOpenFunc(NumpyTestCase): + def setUp(self): + self.tmpdir = mkdtemp() + + def tearDown(self): + rmtree(self.tmpdir) + + def test_DataSourceOpen(self): + local_file = valid_textfile(self.tmpdir) + # Test case where destpath is passed in + assert datasource.open(local_file, destpath=self.tmpdir) + # Test case where default destpath is used + assert datasource.open(local_file) + + if __name__ == "__main__": NumpyTest().run() From scipy-svn at scipy.org Sat Nov 3 12:05:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 3 Nov 2007 11:05:32 -0500 (CDT) Subject: [Scipy-svn] r3494 - in trunk/scipy/special: . cephes docs Message-ID: <20071103160532.34EBE39C0AF@new.scipy.org> Author: cookedm Date: 2007-11-03 11:05:26 -0500 (Sat, 03 Nov 2007) New Revision: 3494 Modified: trunk/scipy/special/cephes.h trunk/scipy/special/cephes/mconf.h trunk/scipy/special/cephes_doc.h trunk/scipy/special/docs/included_functions.html trunk/scipy/special/gendoc.py trunk/scipy/special/setup.py trunk/scipy/special/ufunc_extras.h Log: Add include guards to header files in scipy.special, and add them as dependencies to the appropiate extensions. Modified: trunk/scipy/special/cephes/mconf.h =================================================================== --- trunk/scipy/special/cephes/mconf.h 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/cephes/mconf.h 2007-11-03 16:05:26 UTC (rev 3494) @@ -62,6 +62,9 @@ Copyright 1984, 1987, 1989, 1995 by Stephen L. Moshier */ +#ifndef CEPHES_MCONF_H +#define CEPHES_MCONF_H + #include "cephes_names.h" /* Constant definitions for math error conditions @@ -174,3 +177,5 @@ extern int merror; #define gamma Gamma + +#endif /* CEPHES_MCONF_H */ Modified: trunk/scipy/special/cephes.h =================================================================== --- trunk/scipy/special/cephes.h 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/cephes.h 2007-11-03 16:05:26 UTC (rev 3494) @@ -7,6 +7,9 @@ * Created: Fri Mar 31 19:17:33 1995 */ +#ifndef CEPHES_H +#define CEPHES_H + #include "cephes/cephes_names.h" extern int airy ( double x, double *ai, double *aip, double *bi, double *bip ); @@ -194,7 +197,4 @@ extern double kolmogorov ( double x ); extern double kolmogi ( double p ); - - - - +#endif /* CEPHES_H */ Modified: trunk/scipy/special/cephes_doc.h =================================================================== --- trunk/scipy/special/cephes_doc.h 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/cephes_doc.h 2007-11-03 16:05:26 UTC (rev 3494) @@ -1,3 +1,5 @@ +#ifndef CEPHES_DOC_H +#define CEPHES_DOC_H #define airy_doc "(Ai,Aip,Bi,Bip)=airy(z) calculates the Airy functions and their derivatives\nevaluated at real or complex number z. The Airy functions Ai and Bi \nare two independent solutions of y''(x)=xy. Aip and Bip are the first derivatives\nevaluated at x of Ai and Bi respectively." #define airye_doc "(Aie,Aipe,Bie,Bipe)=airye(z) calculates the exponentially scaled Airy functions and \ntheir derivatives evaluated at real or complex number z. \nairye(z)[0:1] = airy(z)[0:1] * exp(2.0/3.0*z*sqrt(z))\nairye(z)[2:3] = airy(z)[2:3] * exp(-abs((2.0/3.0*z*sqrt(z)).real))" #define bdtr_doc "y=bdtr(k,n,p) returns the sum of the terms 0 through k of the\nBinomial probability density: sum(nCj p**j (1-p)**(n-j),j=0..k)" @@ -96,12 +98,12 @@ #define lpmv_doc "y=lpmv(m,v,x) returns the associated legendre function of integer order\nm and nonnegative degree v: |x|<=1." #define mathieu_a_doc "lmbda=mathieu_a(m,q) returns the characteristic value for the even solution, \nce_m(z,q), of Mathieu's equation" #define mathieu_b_doc "lmbda=mathieu_b(m,q) returns the characteristic value for the odd solution, \nse_m(z,q), of Mathieu's equation" -#define mathieu_cem_doc "(y,yp)=mathieu_cem(m,q,x) returns the even Mathieu function, ce_m(x,q), \nof order m and parameter q evaluated at x (given in degrees). Also returns the derivative\nwith respect to x of ce_m(x,q)" -#define mathieu_modcem1_doc "(y,yp)=mathieu_modcem1(m,q,x) evaluates the even modified Matheiu function \nof the first kind, Mc1m(x,q), and its derivative at x (given in degrees) for order m and\nparameter q" -#define mathieu_modcem2_doc "(y,yp)=mathieu_modcem2(m,q,x) evaluates the even modified Matheiu function \nof the second kind, Mc2m(x,q), and its derivative at x (given in degrees) for order m and \nparameter q" -#define mathieu_modsem1_doc "(y,yp)=mathieu_modsem1(m,q,x) evaluates the odd modified Matheiu function \nof the first kind, Ms1m(x,q), and its derivative at x (given in degrees) for order m and \nparameter q" -#define mathieu_modsem2_doc "(y,yp)=mathieu_modsem2(m,q,x) evaluates the odd modified Matheiu function\nof the second kind, Ms2m(x,q), and its derivative at x (given in degrees) for order m and \nparameter q" -#define mathieu_sem_doc "(y,yp)=mathieu_sem(m,q,x) returns the odd Mathieu function, se_m(x,q), \nof order m and parameter q evaluated at x (given in degrees). Also returns the derivative\nwith respect to x (given in degrees) of se_m(x,q)" +#define mathieu_cem_doc "(y,yp)=mathieu_cem(m,q,x) returns the even Mathieu function, ce_m(x,q), \nof order m and parameter q evaluated at x (given in degrees).\nAlso returns the derivative with respect to x of ce_m(x,q)" +#define mathieu_modcem1_doc "(y,yp)=mathieu_modcem1(m,q,x) evaluates the even modified Matheiu function \nof the first kind, Mc1m(x,q), and its derivative at x for order m and\nparameter q." +#define mathieu_modcem2_doc "(y,yp)=mathieu_modcem2(m,q,x) evaluates the even modified Matheiu function \nof the second kind, Mc2m(x,q), and its derivative at x (given in degrees)\nfor order m and parameter q." +#define mathieu_modsem1_doc "(y,yp)=mathieu_modsem1(m,q,x) evaluates the odd modified Matheiu function \nof the first kind, Ms1m(x,q), and its derivative at x (given in degrees)\nfor order m and parameter q." +#define mathieu_modsem2_doc "(y,yp)=mathieu_modsem2(m,q,x) evaluates the odd modified Matheiu function\nof the second kind, Ms2m(x,q), and its derivative at x (given in degrees)\nfor order m and parameter q." +#define mathieu_sem_doc "(y,yp)=mathieu_sem(m,q,x) returns the odd Mathieu function, se_m(x,q), \nof order m and parameter q evaluated at x (given in degrees).\nAlso returns the derivative with respect to x of se_m(x,q)." #define modfresnelm_doc "(fm,km)=modfresnelp(x) returns the modified fresnel integrals F_-(x) amd K_-(x)\nas fp=integral(exp(-1j*t*t),t=x..inf) and kp=1/sqrt(pi)*exp(1j*(x*x+pi/4))*fp" #define modfresnelp_doc "(fp,kp)=modfresnelp(x) returns the modified fresnel integrals F_+(x) and K_+(x)\nas fp=integral(exp(1j*t*t),t=x..inf) and kp=1/sqrt(pi)*exp(-1j*(x*x+pi/4))*fp" #define modstruve_doc "y=modstruve(v,x) returns the modified Struve function Lv(x) of order\nv at x, x must be positive unless v is an integer and it is recommended\nthat |v|<=20." @@ -156,3 +158,4 @@ #define yve_doc "y=yve(v,z) returns the exponentially scaled Bessel function of the second \nkind of real order v at complex z: yve(v,z) = yv(v,z) * exp(-abs(z.imag))" #define zeta_doc "y=zeta(x,q) returns the Riemann zeta function of two arguments:\nsum((k+q)**(-x),k=0..inf)" #define zetac_doc "y=zetac(x) returns 1.0 - the Riemann zeta function: sum(k**(-x), k=2..inf)" +#endif /* CEPHES_DOC_H */ Modified: trunk/scipy/special/docs/included_functions.html =================================================================== --- trunk/scipy/special/docs/included_functions.html 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/docs/included_functions.html 2007-11-03 16:05:26 UTC (rev 3494) @@ -13,8 +13,8 @@
(Aie,Aipe,Bie,Bipe) = airye(z)
airye(z) calculates the exponentially scaled Airy functions and their derivatives evaluated at real or complex number z. -airye(z)[0:2] = airy(z)[0:2] * exp(2.0/3.0*z*sqrt(z)) -airye(z)[2:4] = airy(z)[2:4] * exp(-abs(real((2.0/3.0*z*sqrt(z))))) +airye(z)[0:1] = airy(z)[0:1] * exp(2.0/3.0*z*sqrt(z)) +airye(z)[2:3] = airy(z)[2:3] * exp(-abs((2.0/3.0*z*sqrt(z)).real))
(Apt,Bpt,Ant,Bnt) = itairy(x) @@ -467,33 +467,33 @@
(y,yp) = mathieu_cem(m,q,x)
mathieu_cem(m,q,x) returns the even Mathieu function, ce_m(x,q), -of order m and parameter q evaluated at x. Also returns the derivative -with respect to x of ce_m(x,q) +of order m and parameter q evaluated at x (given in degrees). +Also returns the derivative with respect to x of ce_m(x,q)
(y,yp) = mathieu_sem(m,q,x)
mathieu_sem(m,q,x) returns the odd Mathieu function, se_m(x,q), -of order m and parameter q evaluated at x. Also returns the derivative -with respect to x of se_m(x,q) +of order m and parameter q evaluated at x (given in degrees). +Also returns the derivative with respect to x of se_m(x,q).
(y,yp) = mathieu_modcem1(m,q,x)
mathieu_modcem1(m,q,x) evaluates the even modified Matheiu function -of the first kind, Mc1m(x,q), and its derivative at x for order m and -parameter q +of the first kind, Mc1m(x,q), and its derivative at x for order m and +parameter q.
(y,yp) = mathieu_modcem2(m,q,x)
mathieu_modcem2(m,q,x) evaluates the even modified Matheiu function -of the second kind, Mc2m(x,q), and its derivative at x for order m and -parameter q +of the second kind, Mc2m(x,q), and its derivative at x (given in degrees) +for order m and parameter q.
(y,yp) = mathieu_modsem1(m,q,x)
mathieu_modsem1(m,q,x) evaluates the odd modified Matheiu function -of the first kind, Ms1m(x,q), and its derivative at x for order m and -parameter q +of the first kind, Ms1m(x,q), and its derivative at x (given in degrees) +for order m and parameter q.
(y,yp) = mathieu_modsem2(m,q,x)
mathieu_modsem2(m,q,x) evaluates the odd modified Matheiu function -of the second kind, Ms2m(x,q), and its derivative at x for order m and -parameter q +of the second kind, Ms2m(x,q), and its derivative at x (given in degrees) +for order m and parameter q.

Spheroidal Wave Functions

Modified: trunk/scipy/special/gendoc.py =================================================================== --- trunk/scipy/special/gendoc.py 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/gendoc.py 2007-11-03 16:05:26 UTC (rev 3494) @@ -36,6 +36,9 @@ keys = d.keys() keys.sort() ofile=open("cephes_doc.h",'w') + ofile.write('#ifndef CEPHES_DOC_H\n') + ofile.write('#define CEPHES_DOC_H\n') for key in keys: ofile.write('#define %s_doc "%s"\n'%(key,repr(d[key])[1:-1])) + ofile.write('#endif /* CEPHES_DOC_H */\n') ofile.close() Modified: trunk/scipy/special/setup.py =================================================================== --- trunk/scipy/special/setup.py 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/setup.py 2007-11-03 16:05:26 UTC (rev 3494) @@ -35,6 +35,11 @@ config.add_extension('_cephes', sources=sources, libraries=['amos','toms','c_misc','cephes','mach', 'cdf', 'specfun'], + depends=["ufunc_extras.h", "cephes.h", + "amos_wrappers.h", "toms_wrappers.h", + "cdf_wrappers.h", "specfun_wrappers.h", + "c_misc/misc.h", "cephes_doc.h", + "cephes/mconf.h", "cephes/cephes_names.h"], define_macros = define_macros ) # Extension specfun Modified: trunk/scipy/special/ufunc_extras.h =================================================================== --- trunk/scipy/special/ufunc_extras.h 2007-11-02 23:33:49 UTC (rev 3493) +++ trunk/scipy/special/ufunc_extras.h 2007-11-03 16:05:26 UTC (rev 3494) @@ -1,3 +1,6 @@ +#ifndef UFUNC_EXTRAS_H +#define UFUNC_EXTRAS_H + #include "Python.h" #include "numpy/noprefix.h" @@ -76,4 +79,4 @@ extern void PyUFunc_ffff_ff_As_dddi_dd(char **args, intp *dimensions, intp *steps, void *func); extern void PyUFunc_dddd_dd_As_dddi_dd(char **args, intp *dimensions, intp *steps, void *func); - +#endif /* UFUNC_EXTRAS_H */ From scipy-svn at scipy.org Sun Nov 4 00:32:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 3 Nov 2007 23:32:27 -0500 (CDT) Subject: [Scipy-svn] r3495 - trunk/scipy/linsolve/SuperLU/SRC Message-ID: <20071104043227.0E9F839C068@new.scipy.org> Author: cookedm Date: 2007-11-03 23:32:23 -0500 (Sat, 03 Nov 2007) New Revision: 3495 Modified: trunk/scipy/linsolve/SuperLU/SRC/get_perm_c.c Log: Comment out some printfs in linsolve/SuperLU/SRC/get_perm_c.c Modified: trunk/scipy/linsolve/SuperLU/SRC/get_perm_c.c =================================================================== --- trunk/scipy/linsolve/SuperLU/SRC/get_perm_c.c 2007-11-03 16:05:26 UTC (rev 3494) +++ trunk/scipy/linsolve/SuperLU/SRC/get_perm_c.c 2007-11-04 04:32:23 UTC (rev 3495) @@ -372,12 +372,12 @@ switch ( ispec ) { case 0: /* Natural ordering */ for (i = 0; i < n; ++i) perm_c[i] = i; - printf("Use natural column ordering.\n"); + /*printf("Use natural column ordering.\n");*/ return; case 1: /* Minimum degree ordering on A'*A */ getata(m, n, Astore->nnz, Astore->colptr, Astore->rowind, &bnz, &b_colptr, &b_rowind); - printf("Use minimum degree ordering on A'*A.\n"); + /*printf("Use minimum degree ordering on A'*A.\n");*/ t = SuperLU_timer_() - t; /*printf("Form A'*A time = %8.3f\n", t);*/ break; @@ -385,14 +385,14 @@ if ( m != n ) ABORT("Matrix is not square"); at_plus_a(n, Astore->nnz, Astore->colptr, Astore->rowind, &bnz, &b_colptr, &b_rowind); - printf("Use minimum degree ordering on A'+A.\n"); + /*printf("Use minimum degree ordering on A'+A.\n");*/ t = SuperLU_timer_() - t; /*printf("Form A'+A time = %8.3f\n", t);*/ break; case 3: /* Approximate minimum degree column ordering. */ get_colamd(m, n, Astore->nnz, Astore->colptr, Astore->rowind, perm_c); - printf(".. Use approximate minimum degree column ordering.\n"); + /*printf(".. Use approximate minimum degree column ordering.\n");*/ return; default: ABORT("Invalid ISPEC"); From scipy-svn at scipy.org Sun Nov 4 00:33:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 3 Nov 2007 23:33:50 -0500 (CDT) Subject: [Scipy-svn] r3496 - trunk/scipy/stats Message-ID: <20071104043350.6B6CC39C068@new.scipy.org> Author: cookedm Date: 2007-11-03 23:33:48 -0500 (Sat, 03 Nov 2007) New Revision: 3496 Modified: trunk/scipy/stats/stats.py Log: scipy/stats/stats.py: fix spelling, and replace a print with a raise Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2007-11-04 04:32:23 UTC (rev 3495) +++ trunk/scipy/stats/stats.py 2007-11-04 04:33:48 UTC (rev 3496) @@ -1754,7 +1754,7 @@ arguments. rvs needs to accept the size= keyword if a function. rvs can also be a vector of RVs. - cdf can be a function or a string indicating the distriubtion type. + cdf can be a function or a string indicating the distribution type. if the p-value is greater than the significance level (say 5%), then we cannot reject the hypothesis that the data come from the given @@ -2031,8 +2031,7 @@ Returns: statistic, p-value ??? """ if len(para) != len(data): - print "data and para must be same length in aglm" - return + raise ValueError("data and para must be same length in aglm") n = len(para) p = _support.unique(para) x = zeros((n,len(p))) # design matrix @@ -2051,6 +2050,8 @@ t = dot(c,b) / np.sqrt(s_sq*fact) probs = betai(0.5*df,0.5,float(df)/(df+t*t)) return t, probs + else: + raise ValueError("only ttest_ind implemented") def f_value_wilks_lambda(ER, EF, dfnum, dfden, a, b): From scipy-svn at scipy.org Sun Nov 4 00:35:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 3 Nov 2007 23:35:13 -0500 (CDT) Subject: [Scipy-svn] r3497 - trunk/scipy/stats/tests Message-ID: <20071104043513.AFA0A39C068@new.scipy.org> Author: cookedm Date: 2007-11-03 23:35:10 -0500 (Sat, 03 Nov 2007) New Revision: 3497 Modified: trunk/scipy/stats/tests/test_distributions.py Log: scipy/stats/tests/test_distributions.py: Use %(var)s instead of %s when creating string for kstests on distributions. Modified: trunk/scipy/stats/tests/test_distributions.py =================================================================== --- trunk/scipy/stats/tests/test_distributions.py 2007-11-04 04:33:48 UTC (rev 3496) +++ trunk/scipy/stats/tests/test_distributions.py 2007-11-04 04:35:10 UTC (rev 3497) @@ -59,15 +59,15 @@ else: args = str(tuple(1.0+rand(nargs))) exstr = r""" -class Test%s(NumpyTestCase): +class Test%(dist)s(NumpyTestCase): def check_cdf(self): - D,pval = stats.kstest('%s','',args=%s,N=30) - if (pval < %f): - D,pval = stats.kstest('%s','',args=%s,N=30) - #if (pval < %f): - # D,pval = stats.kstest('%s','',args=%s,N=30) - assert (pval > %f), "D = " + str(D) + "; pval = " + str(pval) + "; alpha = " + str(alpha) + "\nargs = " + str(%s) -""" % (dist,dist,args,alpha,dist,args,alpha,dist,args,alpha,args) + D,pval = stats.kstest('%(dist)s','',args=%(args)s,N=30) + if (pval < %(alpha)f): + D,pval = stats.kstest('%(dist)s','',args=%(args)s,N=30) + #if (pval < %(alpha)f): + # D,pval = stats.kstest('%(dist)s','',args=%(args)s,N=30) + assert (pval > %(alpha)f), "D = " + str(D) + "; pval = " + str(pval) + "; alpha = " + str(alpha) + "\nargs = " + str(%(args)s) +""" % {'dist' : dist, 'args' : args, 'alpha' : alpha} exec exstr From scipy-svn at scipy.org Mon Nov 5 18:13:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Nov 2007 17:13:19 -0600 (CST) Subject: [Scipy-svn] r3498 - trunk/scipy/odr Message-ID: <20071105231319.0EA3639C276@new.scipy.org> Author: rkern Date: 2007-11-05 17:13:01 -0600 (Mon, 05 Nov 2007) New Revision: 3498 Modified: trunk/scipy/odr/__odrpack.c trunk/scipy/odr/odrpack.py Log: Use C-int arrays instead of C-long arrays. Fix #357. Modified: trunk/scipy/odr/__odrpack.c =================================================================== --- trunk/scipy/odr/__odrpack.c 2007-11-04 04:35:10 UTC (rev 3497) +++ trunk/scipy/odr/__odrpack.c 2007-11-05 23:13:01 UTC (rev 3498) @@ -920,7 +920,7 @@ if (pifixb == NULL) { dim1[0] = np; - ifixb = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_LONG); + ifixb = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_INT); *(int *)(ifixb->data) = -1; /* set first element negative */ } else @@ -928,7 +928,7 @@ /* pifixb is a sequence as checked before */ if ((ifixb = - (PyArrayObject *) PyArray_CopyFromObject(pifixb, PyArray_LONG, 1, + (PyArrayObject *) PyArray_CopyFromObject(pifixb, PyArray_INT, 1, 1)) == NULL) { PYERR(PyExc_ValueError, @@ -946,7 +946,7 @@ { dim2[0] = m; dim2[1] = 1; - ifixx = (PyArrayObject *) PyArray_FromDims(2, dim2, PyArray_LONG); + ifixx = (PyArrayObject *) PyArray_FromDims(2, dim2, PyArray_INT); *(int *)(ifixx->data) = -1; /* set first element negative */ ldifx = 1; } @@ -955,7 +955,7 @@ /* pifixx is a sequence as checked before */ if ((ifixx = - (PyArrayObject *) PyArray_CopyFromObject(pifixx, PyArray_LONG, 1, + (PyArrayObject *) PyArray_CopyFromObject(pifixx, PyArray_INT, 1, 2)) == NULL) { PYERR(PyExc_ValueError, @@ -1169,7 +1169,7 @@ if (piwork != NULL) { if ((iwork = - (PyArrayObject *) PyArray_CopyFromObject(piwork, PyArray_LONG, 1, + (PyArrayObject *) PyArray_CopyFromObject(piwork, PyArray_INT, 1, 1)) == NULL) { PYERR(PyExc_ValueError, @@ -1185,7 +1185,7 @@ { /* initialize our own iwork array */ dim1[0] = liwork; - iwork = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_LONG); + iwork = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_INT); } /* iwork */ /* check if what JOB requests can be done with what the user has Modified: trunk/scipy/odr/odrpack.py =================================================================== --- trunk/scipy/odr/odrpack.py 2007-11-04 04:35:10 UTC (rev 3497) +++ trunk/scipy/odr/odrpack.py 2007-11-05 23:13:01 UTC (rev 3498) @@ -107,14 +107,17 @@ odr_stop = __odrpack.odr_stop -def _conv(obj): +def _conv(obj, dtype=None): """ Convert an object to the preferred form for input to the odr routine. """ if obj is None: return obj else: - obj = numpy.asarray(obj) + if dtype is None: + obj = numpy.asarray(obj) + else: + obj = numpy.asarray(obj, dtype) if obj.shape == (): # Scalar. return obj.dtype.type(obj) @@ -708,8 +711,11 @@ self.beta0 = _conv(beta0) self.delta0 = _conv(delta0) - self.ifixx = _conv(ifixx) - self.ifixb = _conv(ifixb) + # These really are 32-bit integers in FORTRAN (gfortran), even on 64-bit + # platforms. + # XXX: some other FORTRAN compilers may not agree. + self.ifixx = _conv(ifixx, dtype=numpy.int32) + self.ifixb = _conv(ifixb, dtype=numpy.int32) self.job = job self.iprint = iprint self.errfile = errfile From scipy-svn at scipy.org Wed Nov 7 12:54:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 11:54:00 -0600 (CST) Subject: [Scipy-svn] r3499 - in trunk/scipy/ndimage: . segment tests Message-ID: <20071107175400.67D65C7C026@new.scipy.org> Author: tom.waite Date: 2007-11-07 11:53:37 -0600 (Wed, 07 Nov 2007) New Revision: 3499 Added: trunk/scipy/ndimage/segment/ trunk/scipy/ndimage/segment/Segmenter_EXT.c trunk/scipy/ndimage/segment/Segmenter_IMPL.c trunk/scipy/ndimage/segment/__init__.py trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h trunk/scipy/ndimage/segment/setup.py trunk/scipy/ndimage/tests/slice112.raw trunk/scipy/ndimage/tests/test_segmenter.py Log: Add beginning of Tom Waite's ndimage.segment package. Added: trunk/scipy/ndimage/segment/Segmenter_EXT.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-05 23:13:01 UTC (rev 3498) +++ trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-07 17:53:37 UTC (rev 3499) @@ -0,0 +1,467 @@ +#include "ndImage_Segmenter_structs.h" +#include "Python.h" +#include "numpy/arrayobject.h" + +static PyObject *NDI_Segmenter_CannyEdges(PyObject *self, PyObject *args) +{ + + double sigma; + double cannyLow; + double cannyHigh; + double BPHigh; + int lowThreshold; + int highThreshold; + int apearture; + int num; + int nd; + int type; + int itype; + int mode; + int groups; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + // + // pass in 2D LPF coefficients + if(!PyArg_Parse(args, "(dddiiidiO)", &sigma, &cannyLow, &cannyHigh, &mode, &lowThreshold, &highThreshold, + &BPHigh, &apearture, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + itype = 4; + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + if(!NI_CannyEdges(num, (int)dims[0], (int)dims[1], sigma, cannyLow, cannyHigh, mode, lowThreshold, + highThreshold, BPHigh, apearture, fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups); + +} + +static PyObject *NDI_Segmenter_SobelEdges(PyObject *self, PyObject *args) +{ + + double sobelLow; + double BPHigh; + int lowThreshold; + int highThreshold; + int apearture; + int num; + int nd; + int type; + int itype; + int groups; + int mode; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + // + // pass in 2D LPF coefficients + if(!PyArg_Parse(args, "(diiidiO)", &sobelLow, &mode, &lowThreshold, &highThreshold, &BPHigh, &apearture, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // this is int type and hard-wirred. pass this in from Python code + itype = 4; // unsigned short + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + + if(!NI_SobelEdges(num, (int)dims[0], (int)dims[1], sobelLow, mode, lowThreshold, highThreshold, BPHigh, apearture, + fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + +} + + + +static PyObject *NDI_Segmenter_ShenCastanEdges(PyObject *self, PyObject *args) +{ + int window; + int lowThreshold; + int highThreshold; + double ShenCastanLow; + double b; + int num; + int nd; + int type; + int itype; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + int groups; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + if(!PyArg_Parse(args, "(ddiiiO)", &ShenCastanLow, &b, &window, &lowThreshold, &highThreshold, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // this is int type and hard-wirred. pass this in from Python code + itype = 4; // unsigned short + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + if(!NI_ShenCastanEdges(num, (int)dims[0], (int)dims[1], b, ShenCastanLow, window, lowThreshold, highThreshold, + fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + +} + +static PyObject *NDI_Segmenter_GetObjectStats(PyObject *self, PyObject *args) +{ + + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + unsigned short *fP1; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + objStruct *myData; + + if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + goto exit; + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(nArray)) + goto exit; + + // + // PyArray_ContiguousFromObject or PyArray_ContiguousFromAny to be explored + // for non-contiguous + // + + + // pointer to the edge-labeled image + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + fP1 = (unsigned short *)PyArray_DATA(iArray); + + // the object descriptor array that was allocated from numpy + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + myData = (objStruct*)PyArray_DATA(nArray); + + if(!NI_GetObjectStats((int)dims[0], (int)dims[1], (int)objNumber[0], fP1, myData)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_MorphoThinFilt(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + unsigned short *fP1; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + goto exit; + + fP1 = (unsigned short *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + if(!NI_ThinFilter(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_BuildBoundary(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + unsigned short *fP1; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + goto exit; + + fP1 = (unsigned short *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + // + // this is int type and hard-wirred. pass this in from Python code + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + // + // pass in ROI list and labeled edges + // return an augmented ROI list + // replace the edgeImage with maskImage + // + if(!NI_BuildBoundary(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + +static PyObject *NDI_Segmenter_VoxelMeasures(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + PyObject *eArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OOO)", &iArray, &eArray, &nArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // eArray and iArray are same dims + fP2 = (unsigned short *)PyArray_DATA(eArray); + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + // + // pass in ROI list and labeled edges + // return an augmented ROI list + // replace the edgeImage with maskImage + // + + if(!NI_VoxelMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_TextureMeasures(PyObject *self, PyObject *args) +{ + + int num; + int nd; + int type; + npy_intp *dims; + npy_intp *objNumber; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *nArray = NULL; + PyObject *eArray = NULL; + objStruct *ROIList; + + if(!PyArg_Parse(args, "(OOO)", &iArray, &eArray, &nArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // eArray and iArray are same dims + fP2 = (unsigned short *)PyArray_DATA(eArray); + + objNumber = PyArray_DIMS(nArray); // this is the number of labels in the edge image + ROIList = (objStruct*)PyArray_DATA(nArray); + + if(!PyArray_ISCONTIGUOUS(iArray)) + goto exit; + + // + // pass in ROI list and labeled edges + // return an augmented ROI list + // replace the edgeImage with maskImage + // + + if(!NI_TextureMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + +static PyObject *NDI_Segmenter_RegionGrow(PyObject *self, PyObject *args) +{ + + int lowThreshold; + int highThreshold; + int closeWindow; + int openWindow; + int num; + int nd; + int type; + int itype; + int groups; + int mode; + npy_intp *dims; + double *fP1; + unsigned short *fP2; + PyObject *iArray = NULL; + PyObject *eArray = NULL; + + // + // pass in 2D LPF coefficients + if(!PyArg_Parse(args, "(iiiiO)", &lowThreshold, &highThreshold, &closeWindow, &openWindow, &iArray)) + goto exit; + + fP1 = (double *)PyArray_DATA(iArray); + nd = PyArray_NDIM(iArray); + dims = PyArray_DIMS(iArray); + type = PyArray_TYPE(iArray); + num = PyArray_SIZE(iArray); + + // this is int type and hard-wirred. pass this in from Python code + itype = 4; // unsigned short + eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); + fP2 = (unsigned short *)PyArray_DATA(eArray); + + if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) + goto exit; + + + if(!NI_RegionGrow(num, (int)dims[0], (int)dims[1], lowThreshold, highThreshold, closeWindow, openWindow, + fP1, fP2, &groups)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + +} + +static PyMethodDef NDI_SegmenterMethods[] = +{ + { "canny_edges", NDI_Segmenter_CannyEdges, METH_VARARGS }, + { "shen_castan_edges", NDI_Segmenter_ShenCastanEdges, METH_VARARGS }, + { "sobel_edges", NDI_Segmenter_SobelEdges, METH_VARARGS }, + { "get_object_stats", NDI_Segmenter_GetObjectStats, METH_VARARGS }, + { "morpho_thin_filt", NDI_Segmenter_MorphoThinFilt, METH_VARARGS }, + { "build_boundary", NDI_Segmenter_BuildBoundary, METH_VARARGS }, + { "voxel_measures", NDI_Segmenter_VoxelMeasures, METH_VARARGS }, + { "texture_measures", NDI_Segmenter_TextureMeasures, METH_VARARGS }, + { "region_grow", NDI_Segmenter_RegionGrow, METH_VARARGS }, + { NULL, NULL }, +}; + +void init_segmenter() +{ + Py_InitModule("_segmenter", NDI_SegmenterMethods); + import_array(); +} + +/* +static PyMethodDef NDI_SegmenterMethods[] = +{ + { "CannyEdges", NDI_Segmenter_CannyEdges, METH_VARARGS }, + { "ShenCastanEdges", NDI_Segmenter_ShenCastanEdges, METH_VARARGS }, + { "SobelEdges", NDI_Segmenter_SobelEdges, METH_VARARGS }, + { "GetObjectStats", NDI_Segmenter_GetObjectStats, METH_VARARGS }, + { "MorphoThinFilt", NDI_Segmenter_MorphoThinFilt, METH_VARARGS }, + { "BuildBoundary", NDI_Segmenter_BuildBoundary, METH_VARARGS }, + { "VoxelMeasures", NDI_Segmenter_VoxelMeasures, METH_VARARGS }, + { "TextureMeasures", NDI_Segmenter_TextureMeasures, METH_VARARGS }, + { "RegionGrow", NDI_Segmenter_RegionGrow, METH_VARARGS }, + { NULL, NULL }, +}; + +void initNDI_Segmenter() +{ + Py_InitModule("NDI_Segmenter", NDI_SegmenterMethods); + import_array(); +} +*/ + Added: trunk/scipy/ndimage/segment/Segmenter_IMPL.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-05 23:13:01 UTC (rev 3498) +++ trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-07 17:53:37 UTC (rev 3499) @@ -0,0 +1,2976 @@ +#include +#include +#include +#include +#include "ndImage_Segmenter_structs.h" + +// these are for this standalone and come out with the full build +// +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define FALSE 0 +#define TRUE 1 + +int NI_GetObjectStats(int rows, int cols, int numberObjects, unsigned short *labeledEdges, objStruct objectMetrics[]){ + + int i, j, k, m; + int offset; + int count; + int LowX; + int LowY; + int HighX; + int HighY; + int status; + float centerX; + float centerY; + + for(k = 1; k < numberObjects; ++k){ + offset = cols; + LowX = 32767; + LowY = 32767; + HighX = 0; + HighY = 0; + count = 0; + centerX = (float)0.0; + centerY = (float)0.0; + for(i = 1; i < (rows-1); ++i){ + for(j = 1; j < (cols-1); ++j){ + m = labeledEdges[offset+j]; + if(k == m){ + if(i < LowY) LowY = i; + if(j < LowX) LowX = j; + if(i > HighY) HighY = i; + if(j > HighX) HighX = j; + centerX += (float)j; + centerY += (float)i; + ++count; + } + } + offset += cols; + } + // the bounding box for the 2D blob + objectMetrics[k-1].L = LowX; + objectMetrics[k-1].R = HighX; + objectMetrics[k-1].B = LowY; + objectMetrics[k-1].T = HighY; + objectMetrics[k-1].Area = count; + objectMetrics[k-1].cX = centerX/(float)count; + objectMetrics[k-1].cY = centerY/(float)count; + objectMetrics[k-1].Label = k; + } + + status = numberObjects; + return status; + +} + + +void buildKernel(double BPHigh, int HalfFilterTaps, int apearture, float *kernel){ + + int i, j; + float r, t1, t2, t3, t4; + float LC, HC, tLOW, tHIGH; + float pi = (float)3.14159, rad = (float)0.01745; + + LC = (float)0.0; + HC = BPHigh * rad; + t2 = (float)2.0*pi; + t1 = (float)2.0*HalfFilterTaps + (float)1.0; + // + // build the Filter Kernel + // the kernel starts at 1 only because it is linked to the internal filter2D routine + // the code is not a Fortran code + // + j = 1; + for(i = -HalfFilterTaps; i <= HalfFilterTaps; ++i){ + r = (float)i; + if(r == (float)0.0){ + tLOW = LC; + tHIGH = HC; + } + else{ + tLOW = (float)(sin(r*LC))/r; + tHIGH = (float)(sin(r*HC))/r; + } + t3 = (float)0.54 + (float)0.46*((float)cos(r*t2/t1)); + t4 = t3*(tHIGH-tLOW); + kernel[j++] = t4; + } + + // normalize the kernel so unity gain (as is LP filter this is easy) + t1 = (float)0.0; + for(j = 1; j <= apearture; ++j){ + t1 += kernel[j]; + } + for(j = 1; j <= apearture; ++j){ + kernel[j] /= t1; + } + + t1 = (float)0.0; + for(j = 1; j <= apearture; ++j){ + t1 += kernel[j]; + } + return; +} + +void filter2D(int HalfFilterTaps, int rows, int cols, int lowThreshold, int highThreshold, float *kernel, double *Image){ + + int i, j, k, n, num1; + int offset; + float sum, value; + float buffer[1024]; + + num1 = HalfFilterTaps + 1; + offset = 0; + for(i = 0; i < rows; ++i){ + // copy image row to local buffer + for(j = 0; j < cols; ++j){ + buffer[num1+j] = Image[offset+j]; + } + // constant pad the ends of the buffer + for(j = 0; j < num1; ++j){ + buffer[j] = buffer[num1]; + } + for(j = cols+num1; j < cols+2*num1; ++j){ + buffer[j] = buffer[cols-1+num1]; + } + + // Perform Symmetric Convolution in the X dimension. + for(n = 0, j = num1; j < (cols+num1); ++j, ++n){ + sum = buffer[j] * kernel[num1]; + for(k = 1; k < num1; ++k){ + sum += kernel[num1-k] * (buffer[j+k] + buffer[j-k]); + } + Image[offset+n] = sum; + } + offset += cols; + } + + offset = 0; + for(i = 0; i < cols; ++i){ + // copy image column to local buffer + offset = 0; + for(j = 0; j < rows; ++j){ + buffer[num1+j] = Image[offset+i]; + offset += cols; + } + // constant pad the ends of the buffer + for(j = 0; j < num1; ++j){ + buffer[j] = buffer[num1]; + } + for(j = rows+num1; j < rows+2*num1; ++j){ + buffer[j] = buffer[rows-1+num1]; + } + + // Perform Symmetric Convolution in the Y dimension. + offset = 0; + for(j = num1; j < (rows+num1); ++j){ + sum = buffer[j] * kernel[num1]; + for(k = 1; k < num1; ++k){ + sum += kernel[num1-k] * (buffer[j+k] + buffer[j-k]); + } + Image[offset+i] = sum; + offset += cols; + } + } + + // threshold the image + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = Image[offset+j]; + if(value < (float)lowThreshold) value = (float)0.0; + if(value > (float)highThreshold) value = (float)0.0; + Image[offset+j] = value; + } + offset += cols; + } + + return; + +} + +void doPreProcess(int samples, int rows, int cols, double *rawImage, double BPHigh, int apearture, int lowThreshold, int highThreshold){ + + // + // 2D low pass filter using bisinc and threshold + // this specific example is on cardiac CT and focuses on segmenting the + // aorta and blood-filled chambers. for MRI the threshold will be different + // + + float *kernel; + int HalfFilterTaps = (apearture-1)/2; + kernel = calloc(apearture+16, sizeof(float)); + + buildKernel(BPHigh, HalfFilterTaps, apearture, kernel); + filter2D(HalfFilterTaps, rows, cols, lowThreshold, highThreshold, kernel, rawImage); + + free(kernel); + + return; + +} + + +int ConnectedEdgePoints(int rows, int cols, unsigned short *connectedEdges){ + + int i, j, k, l, m; + int offset; + int Label; + int Classes[4096]; + bool NewLabel; + bool Change; + unsigned short T[12]; + + // + // connected components labeling. pixels touch within 3x3 mask for edge connectedness. + // + Label = 1; + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(connectedEdges[offset+j] == 1){ + connectedEdges[offset+j] = Label++; + } + } + offset += cols; + } + + while(1){ + Change = FALSE; + // + // TOP-DOWN Pass for labeling + // + offset = cols; + for(i = 1; i < rows-1; ++i){ + for(j = 1; j < cols-1; ++j){ + if(connectedEdges[offset+j] != 0){ + T[0] = connectedEdges[offset+j]; + T[1] = connectedEdges[offset+j+1]; + T[2] = connectedEdges[offset-cols+j+1]; + T[3] = connectedEdges[offset-cols+j]; + T[4] = connectedEdges[offset-cols+j-1]; + T[5] = connectedEdges[offset+j-1]; + T[6] = connectedEdges[offset+cols+j-1]; + T[7] = connectedEdges[offset+cols+j]; + T[8] = connectedEdges[offset+cols+j+1]; + m = T[0]; + for(l = 1; l < 9; ++l){ + if(T[l] != 0){ + if(T[l] < m) m = T[l]; + } + } + if(m != connectedEdges[offset+j]){ + Change = TRUE; + connectedEdges[offset+j] = m; + } + } + } + offset += cols; + } + // + // BOTTOM-UP Pass for labeling + // + offset = (rows-1)*cols; + for(i = (rows-1); i > 1; --i){ + for(j = (cols-1); j > 1; --j){ + if(connectedEdges[offset+j] != 0){ + T[0] = connectedEdges[offset+j]; + T[1] = connectedEdges[offset+j+1]; + T[2] = connectedEdges[offset-cols+j+1]; + T[3] = connectedEdges[offset-cols+j]; + T[4] = connectedEdges[offset-cols+j-1]; + T[5] = connectedEdges[offset+j-1]; + T[6] = connectedEdges[offset+cols+j-1]; + T[7] = connectedEdges[offset+cols+j]; + T[8] = connectedEdges[offset+cols+j+1]; + m = T[0]; + for(l = 1; l < 9; ++l){ + if(T[l] != 0){ + if(T[l] < m) m = T[l]; + } + } + if(m != connectedEdges[offset+j]){ + Change = TRUE; + connectedEdges[offset+j] = m; + } + } + } + offset -= cols; + } + if(!Change) break; + } // end while loop + + Classes[0] = 0; + Label = 1; + offset = cols; + for(i = 1; i < (rows-1); ++i){ + for(j = 1; j < (cols-1); ++j){ + m = connectedEdges[offset+j]; + if(m > 0){ + NewLabel = TRUE; + for(k = 1; k < Label; ++k){ + if(Classes[k] == m) NewLabel = FALSE; + } + if(NewLabel){ + Classes[Label++] = m; + if(Label > 4000){ + return 0; // too many labeled regions. this is a pathology in the image slice + } + } + } + } + offset += cols; + } + + // + // re-label the connected blobs in continuous label order + // + offset = cols; + for(i = 1; i < (rows-1); ++i){ + for(j = 1; j < (cols-1); ++j){ + m = connectedEdges[offset+j]; + if(m > 0){ + for(k = 1; k < Label; ++k){ + if(Classes[k] == m){ + connectedEdges[offset+j] = (unsigned short)k; + break; + } + } + } + } + offset += cols; + } + + return Label; +} + +float magnitude(float X, float Y){ + + return (float)sqrt(X*X + Y*Y); +} + +int traceEdge(int i, int j, int rows, int cols, double cannyLow, float *magImage, float *HYSImage){ + + int n, m; + int ptr; + int flag; + + ptr = i * cols; + if(HYSImage[ptr+j] == (float)0.0){ + // + // this point is above high threshold + // + HYSImage[ptr+j] = (float)1.0; + flag = 0; + for(n = -1; n <= 1; ++n){ + for(m = -1; m <= 1; ++m){ + if(n == 0 && m == 0) continue; + if(((i+n) > 0) && ((j+m) > 0) && ((i+n) < rows) && ((j+m) < cols)){ + ptr = (i+n) * cols; + if(magImage[ptr+j+m] > cannyLow){ + // + // this point is above low threshold + // + if(traceEdge(i+n, j+m, rows, cols, cannyLow, magImage, HYSImage)){ + flag = 1; + break; + } + } + } + } + if(flag) break; + } + return(1); + } + + return(0); + +} + + +void edgeThreshold(int rows, int cols, double cannyLow, float *magImage, float *HYSImage){ + + int i, j; + int ptr; + + for(i = 0; i < rows; ++i){ + ptr = i * cols; + for(j = 0; j < cols; ++j){ + if(magImage[ptr+j] > cannyLow){ + HYSImage[ptr+j] = (float)1.0; + } + } + } + + return; + +} + +void edgeHysteresis(int rows, int cols, double cannyLow, double cannyHigh, float *magImage, float *HYSImage){ + + int i, j; + int ptr; + + for(i = 0; i < rows; ++i){ + ptr = i * cols; + for(j = 0; j < cols; ++j){ + if(magImage[ptr+j] > cannyHigh){ + traceEdge(i, j, rows, cols, cannyLow, magImage, HYSImage); + } + } + } + + return; + +} + +void nonMaxSupress(int rows, int cols, float aveXValue, float aveYValue, double *cannyLow, double *cannyHigh, + int mode, float *hDGImage, float *vDGImage, float *magImage){ + + int i, j; + int ptr, ptr_m1, ptr_p1; + float xSlope, ySlope, G1, G2, G3, G4, G, xC, yC; + float scale; + float maxValue = (float)0.0; + float minValue = (float)-1.0; + int histogram[256]; + int value; + int mValue; + int mIndex; + int count; + double step; + double tAve; + + for(i = 1; i < rows-1; ++i){ + ptr = i * cols; + ptr_m1 = ptr - cols; + ptr_p1 = ptr + cols; + for(j = 1; j < cols; ++j){ + magImage[ptr+j] = (float)0.0; + xC = hDGImage[ptr+j]; + yC = vDGImage[ptr+j]; + if((fabs(xC) < aveXValue) && (fabs(yC) < aveYValue)) continue; + G = magnitude(xC, yC); + if(fabs(yC) > fabs(xC)){ + // vertical gradient + xSlope = (float)(fabs(xC) / fabs(yC)); + ySlope = (float)1.0; + G2 = magnitude(hDGImage[ptr_m1+j], vDGImage[ptr_m1+j]); + G4 = magnitude(hDGImage[ptr_p1+j], vDGImage[ptr_p1+j]); + if((xC*yC) > (float)0.0){ + G1 = magnitude(hDGImage[ptr_m1+j-1], vDGImage[ptr_m1+j-1]); + G3 = magnitude(hDGImage[ptr_p1+j+1], vDGImage[ptr_p1+j+1]); + } + else{ + G1 = magnitude(hDGImage[ptr_m1+j+1], vDGImage[ptr_m1+j+1]); + G3 = magnitude(hDGImage[ptr_p1+j-1], vDGImage[ptr_p1+j-1]); + } + } + else{ + // horizontal gradient + xSlope = (float)(fabs(yC) / fabs(xC)); + ySlope = (float)1.0; + G2 = magnitude(hDGImage[ptr+j+1], vDGImage[ptr+j+1]); + G4 = magnitude(hDGImage[ptr+j-1], vDGImage[ptr+j-1]); + if((xC*yC) > (float)0.0){ + G1 = magnitude(hDGImage[ptr_p1+j+1], vDGImage[ptr_p1+j+1]); + G3 = magnitude(hDGImage[ptr_m1+j-1], vDGImage[ptr_m1+j-1]); + } + else{ + G1 = magnitude(hDGImage[ptr_m1+j+1], vDGImage[ptr_m1+j+1]); + G3 = magnitude(hDGImage[ptr_p1+j-1], vDGImage[ptr_p1+j-1]); + } + } + if( (G > (xSlope*G1 + (ySlope-xSlope)*G2)) && (G > (xSlope*G3 + (ySlope-xSlope)*G4)) ){ + magImage[ptr+j] = G; + } + if(magImage[ptr+j] > maxValue) maxValue = magImage[ptr+j]; + if(magImage[ptr+j] < minValue) minValue = magImage[ptr+j]; + } + } + + scale = (float)1.0 / (maxValue-minValue); + ptr = 0; + count = 0; + tAve = 0.0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + magImage[ptr] = scale * (magImage[ptr]-minValue); + if(magImage[ptr] > 0.0){ + tAve += magImage[ptr]; + ++count; + } + ++ptr; + } + } + tAve /= (float)count; + + step = 255.0; + for(i = 0; i < 256; ++i){ + histogram[i] = 0; + } + ptr = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = (int)(step*(magImage[ptr])); + ++histogram[value]; + ++ptr; + } + } + // + // now get the max after skipping the low values + // + mValue = -1; + mIndex = 0; + for(i = 10; i < 256; ++i){ + if(histogram[i] > mValue){ + mValue = histogram[i]; + mIndex = i; + } + } + + if(mode == 1){ + // based on the mean value of edge energy + *cannyLow = ((*cannyLow) * tAve); + *cannyHigh = ((*cannyHigh) * tAve); + } + else{ + // based on the mode value of edge energy + *cannyLow = ((*cannyLow) * ((float)mIndex/step)); + *cannyHigh = ((*cannyHigh) * ((float)mIndex/step)); + } + + return; + +} + +void DGFilters(int samples, int rows, int cols, double cannySigma, int gWidth, + float *aveXValue, float *aveYValue, double *rawImage, + double *dgKernel, float *hDGImage, float *vDGImage){ + + // + // implements the derivative of Gaussian filter. kernel set by CannyEdges + // + int i, j, k; + int ptr; + int mLength; + int count; + float *tBuffer = NULL; + double sum; + + *aveXValue = (float)0.0; + *aveYValue = (float)0.0; + + mLength = MAX(rows, cols) + 64; + tBuffer = calloc(mLength, sizeof(float)); + + // + // filter X + // + count = 0; + for(i = 0; i < rows; ++i){ + ptr = i * cols; + for(j = gWidth; j < cols-gWidth; ++j){ + sum = dgKernel[0] * rawImage[ptr+j]; + for(k = 1; k < gWidth; ++k){ + sum += dgKernel[k] * (-rawImage[ptr+j+k] + rawImage[ptr+j-k]); + } + hDGImage[ptr+j] = (float)sum; + if(sum != (float)0.0){ + ++count; + *aveXValue += (float)fabs(sum); + } + } + } + if(count){ + *aveXValue /= (float)count; + *aveXValue = (float)0.5 * (*aveXValue); + // this is 50% of the max, hardwirred for now, and is part of the threshold + } + // + // filter Y + // + count = 0; + for(i = 0; i < cols; ++i){ + for(j = 0; j < rows; ++j){ + ptr = j * cols; + tBuffer[j] = rawImage[ptr+i]; + } + for(j = gWidth; j < rows-gWidth; ++j){ + ptr = j * cols; + sum = dgKernel[0] * tBuffer[j]; + for(k = 1; k < gWidth; ++k){ + sum += dgKernel[k] * (-tBuffer[j+k] + tBuffer[j-k]); + } + vDGImage[ptr+i] = sum; + if(sum != (float)0.0){ + ++count; + *aveYValue += (float)fabs(sum); + } + } + } + if(count){ + *aveYValue /= (float)count; + *aveYValue = (float)0.5 * (*aveYValue); + // this is 50% of the max, hardwirred for now, and is part of the threshold + } + + free(tBuffer); + + return; + +} + + +int NI_CannyEdges(int samples, int rows, int cols, double cannySigma, double cannyLow, double cannyHigh, int mode, + int lowThreshold, int highThreshold, double BPHigh, int apearture, double *rawImage, + unsigned short *edgeImage, int *groups){ + + int i, j; + int offset; + int doHysteresis = 0; + int gWidth; + int mLength; + int status; + float aveXValue; + float aveYValue; + double t; + double dgKernel[20]; + float *HYSImage = NULL; + float *hDGImage = NULL; + float *vDGImage = NULL; + float *magImage = NULL; + float *tBuffer = NULL; + + // filter + printf("do preProcess\n"); + doPreProcess(samples, rows, cols, rawImage, BPHigh, apearture, lowThreshold, highThreshold); + printf("do Canny\n"); + + // + // memory for magnitude, horizontal and vertical derivative of Gaussian filter + // + mLength = MAX(rows, cols) + 64; + HYSImage = calloc(samples, sizeof(float)); + hDGImage = calloc(samples, sizeof(float)); + vDGImage = calloc(samples, sizeof(float)); + magImage = calloc(samples, sizeof(float)); + tBuffer = calloc(mLength, sizeof(float)); + + // + // build derivative of Gaussian filter kernel + // kernel is anti-symmetric so convolution is k[j]*(v[i+j] - v[i-j]) + // + gWidth = 20; + for(i = 0; i < gWidth; ++i){ + t = (float)i; + dgKernel[i] = (float)exp((double)((-t*t)/((float)2.0 * cannySigma * cannySigma))); + dgKernel[i] *= -(t / (cannySigma * cannySigma)); + } + for(i = 0; i < samples; ++i){ + HYSImage[i] = (float)0.0; + } + + DGFilters(samples, rows, cols, cannySigma, gWidth, &aveXValue, &aveYValue, rawImage, dgKernel, hDGImage, vDGImage); + nonMaxSupress(rows, cols, aveXValue, aveYValue, &cannyLow, &cannyHigh, mode, hDGImage, vDGImage, magImage); + if(doHysteresis){ + edgeHysteresis(rows, cols, cannyLow, cannyHigh, magImage, HYSImage); + } + else{ + edgeThreshold(rows, cols, cannyLow, magImage, HYSImage); + } + + // + // edge image + // + for(i = 0; i < samples; ++i){ + edgeImage[i] = (unsigned short)HYSImage[i]; + } + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + + free(tBuffer); + free(hDGImage); + free(vDGImage); + free(magImage); + free(HYSImage); + + status = *groups; + return status; + +} + +void doSobel(int samples, int rows, int cols, double sobelLow, int mode, double *rawImage, unsigned short *edgeImage){ + + int i, j; + int p, m, n; + int offset; + int offsetM1; + int offsetP1; + int minValue, maxValue; + int pAve = 0; + int count = 0; + int histogram[256]; + int value; + int maxIndex; + float pThreshold; + double scale; + double step; + float *filteredImage = NULL; + + filteredImage = calloc(samples, sizeof(float)); + + minValue = 10000; + maxValue = -10000; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + filteredImage[offset+j] = 0; + edgeImage[offset+j] = 0; + } + offset += cols; + } + + // + // Sobel + // + offset = cols; + for(i = 1; i < rows-1; ++i){ + offsetM1 = offset - cols; + offsetP1 = offset + cols; + for(j = 1; j < cols-1; ++j){ + n = 2*rawImage[offsetM1+j] + rawImage[offsetM1+j-1] + rawImage[offsetM1+j+1] - + 2*rawImage[offsetP1+j] - rawImage[offsetP1+j-1] - rawImage[offsetP1+j+1]; + m = 2*rawImage[offset+j-1] + rawImage[offsetM1+j-1] + rawImage[offsetP1+j-1] - + 2*rawImage[offset+j+1] - rawImage[offsetM1+j+1] - rawImage[offsetP1+j+1]; + p = (int)sqrt((float)(m*m) + (float)(n*n)); + if(p > 0){ + pAve += p; + ++count; + if(p > maxValue) maxValue = p; + if(p < minValue) minValue = p; + } + filteredImage[offset+j] = p; + } + offset += cols; + } + + // threshold based on ave + pAve /= count; + scale = 1.0 / maxValue; + + step = 255.0/(maxValue-minValue); + for(i = 0; i < 256; ++i){ + histogram[i] = 0; + } + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = (int)(step*(filteredImage[offset+j]-minValue)); + ++histogram[value]; + } + offset += cols; + } + // + // now get the max after skipping the low values + // + maxValue = -1; + maxIndex = 0; + for(i = 10; i < 256; ++i){ + if(histogram[i] > maxValue){ + maxValue = histogram[i]; + maxIndex = i; + } + } + + if(mode == 1){ + // based on the mean value of edge energy + pThreshold = (int)(sobelLow * (float)pAve); + } + else{ + // based on the mode value of edge energy + pThreshold = (sobelLow * (minValue + ((float)maxIndex/step))); + } + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(filteredImage[offset+j] > pThreshold){ + edgeImage[offset+j] = 1; + } + else{ + edgeImage[offset+j] = 0; + } + filteredImage[offset+j] *= scale; + } + offset += cols; + } + + free(filteredImage); + + return; + + +} + +void estimateThreshold(float *lowThreshold, float *highThreshold, float ShenCastanLow, int rows, int cols, float *SourceImage){ + + int i, j; + int offset; + int value; + int mIndex; + int histogram[256]; + float low, high; + float scale; + + low = (float)1000.0; + high = (float)-1000.0; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(fabs(SourceImage[offset+j]) > high) high = fabs(SourceImage[offset+j]); + if(fabs(SourceImage[offset+j]) < low) low = fabs(SourceImage[offset+j]); + } + offset += cols; + } + + scale = (float)255.0 / (high-low); + for(i = 0; i < 256; ++i){ + histogram[i] = 0; + } + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = (int)(scale*(fabs(SourceImage[offset+j]) - low)); + ++histogram[value]; + } + offset += cols; + } + + // + // now get the edge energy mode + // + value = 0; + mIndex = 10; + for(i = 10; i < 256; ++i){ + if(histogram[i] > value){ + value = histogram[i]; + mIndex = i; + } + } + + *highThreshold = ((float)mIndex / scale) + low; + *lowThreshold = ((float)mIndex / scale) + low; + + *highThreshold *= ShenCastanLow; + *lowThreshold *= ShenCastanLow; + + return; + +} + +void thresholdEdges(float *SourceImage, unsigned short *EdgeImage, double ShenCastanLow, int rows, int cols){ + + int i, j; + int offset; + float tLow, tHigh; + + // + // SourceImage contains the adaptive gradient + // get threshold from the mode of the edge energy + // + estimateThreshold(&tLow, &tHigh, ShenCastanLow, rows, cols, SourceImage); + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(SourceImage[offset+j] > tLow){ + EdgeImage[offset+j] = 1; + } + else{ + EdgeImage[offset+j] = 0; + } + } + offset += cols; + } + + return; + +} + +float adaptiveGradient(float *BLImage, float *FilterImage, int nrow, int ncol, int cols, int window){ + + int i, j; + int offset; + int numOn, numOff; + int hWindow = window/2; + float sumOn, sumOff; + float aveOn, aveOff; + + numOn = 0; + numOff = 0; + + sumOn = (float)0.0; + sumOff = (float)0.0; + + aveOn = (float)0.0; + aveOff = (float)0.0; + + offset = nrow * cols; + for(i = -hWindow; i < hWindow; ++i){ + for(j = -hWindow; j < hWindow; ++j){ + if(BLImage[offset+(i*cols)+(j+ncol)] == 1){ + sumOn += FilterImage[offset+(i*cols)+(j+ncol)]; + ++numOn; + } + else{ + sumOff += FilterImage[offset+(i*cols)+(j+ncol)]; + ++numOff; + } + } + } + + if(numOn){ + aveOn = sumOn / numOn; + } + + if(numOff){ + aveOff = sumOff / numOff; + } + + return (aveOff-aveOn); + +} + +void getZeroCrossings(float *SourceImage, float *FilterImage, float *BLImage, int rows, int cols, int window){ + + int i, j; + int offset; + bool validEdge; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + SourceImage[offset+j] = 0.0; + } + offset += cols; + } + + offset = window*cols; + for(i = window; i < rows-window; ++i){ + for(j = window; j < cols-window; ++j){ + validEdge = FALSE; + if((BLImage[offset+j] == 1) && (BLImage[offset+cols+j] == 0)){ + if((FilterImage[offset+cols+j] - FilterImage[offset-cols+j]) > 0.0){ + validEdge = TRUE; + } + } + else if((BLImage[offset+j] == 1) && (BLImage[offset+j+1] == 0)){ + if((FilterImage[offset+j+1] - FilterImage[offset+j-1]) > 0.0){ + validEdge = TRUE; + } + } + else if((BLImage[offset+j] == 1) && (BLImage[offset-cols+j] == 0)){ + if((FilterImage[offset+cols+j] - FilterImage[offset-cols+j]) < 0.0){ + validEdge = TRUE; + } + } + else if((BLImage[offset+j] == 1) && (BLImage[offset+j-1] == 0)){ + if((FilterImage[offset+j+1] - FilterImage[offset+j-1]) < 0.0){ + validEdge = TRUE; + } + } + if(validEdge){ + // adaptive gradeint is signed + SourceImage[offset+j] = (float)fabs(adaptiveGradient(BLImage, FilterImage, i, j, cols, window)); + } + } + offset += cols; + } + + return; + +} + + +void computeBandedLaplacian(float *image1, float *image2, float *BLImage, int rows, int cols){ + + int i, j; + int offset; + float t; + + // + // like an unsharp mask + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + t = image1[offset+j] - image2[offset+j]; + if(t < (float)0.0){ + t = (float)0.0; + } + else{ + t = (float)1.0; + } + BLImage[offset+j] = t; + } + offset += cols; + } + + return; + +} + +void thresholdImage(float *Raw, float *Filtered, int rows, int cols, int tLow, int tHigh){ + + int i, j; + int ptr; + + ptr = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(Raw[ptr] > tHigh){ + Raw[ptr] = 0.0; + Filtered[ptr] = 0.0; + } + if(Raw[ptr] < tLow){ + Raw[ptr] = 0.0; + Filtered[ptr] = 0.0; + } + ++ptr; + } + } + + return; + +} + +void ISEF_Vertical(float *SourceImage, float *FilterImage, float *A, float *B, int rows, int cols, double b){ + + + int i, j; + int offset; + float b1, b2; + + b1 = ((float)1.0 - b)/((float)1.0 + b); + b2 = b * b1; + + // + // set the boundaries + // + offset = (rows-1)*cols; + for(i = 0; i < cols; ++i){ + // process row 0 + A[i] = b1 * SourceImage[i]; + // process row N-1 + B[offset+i] = b2 * SourceImage[offset+i]; + } + + // + // causal component of IIR filter + // + offset = cols; + for(i = 1; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + // + // IIR ISEF filter applied across rows + // + A[offset+j] = (b * A[offset-cols+j]) + (b1 * SourceImage[offset+j]); + } + offset += cols; + } + + // + // anti-causal component of IIR filter + // + offset = (rows-2)*cols; + for(i = rows-2; i >= 0; --i){ + for(j = 0; j < cols; ++j){ + // + // IIR ISEF filter applied across rows + // + B[offset+j] = (b * B[offset+cols+j]) + (b2 * SourceImage[offset+j]); + } + offset -= cols; + } + + offset = (rows-1)*cols; + for(j = 0; j < cols-1; ++j){ + FilterImage[offset+j] = A[offset+j]; + } + + // + // add causal and anti-causal IIR parts + // + offset = 0; + for(i = 1; i < rows-2; ++i){ + for(j = 0; j < cols-1; ++j){ + FilterImage[offset+j] = A[offset+j] + B[offset+cols+j]; + } + offset += cols; + } + + return; + +} + +void ISEF_Horizontal(float *SourceImage, float *FilterImage, float *A, float *B, int rows, int cols, double b){ + + + // + // source and smooth are the same in this pass of the 2D IIR + // + + int i, j; + int offset; + float b1, b2; + + b1 = ((float)1.0 - b)/((float)1.0 + b); + b2 = b * b1; + + // + // columns boundaries + // + offset = 0; + for(i = 0; i < rows; ++i){ + // col 0 + A[offset] = b1 * SourceImage[offset]; + // col N-1 + B[offset+cols-1] = b2 * SourceImage[offset+cols-1]; + } + + // + // causal IIR part + // + offset = 0; + for(j = 1; j < cols; ++j){ + for(i = 0; i < rows; ++i){ + A[offset+j] = (b * A[offset+j-1]) + (b1 * SourceImage[offset+j]); + } + offset += cols; + } + + // + // anti-causal IIR part + // + offset = 0; + for(j = cols-2; j > 0; --j){ + for(i = 0; i < rows; ++i){ + B[offset+j] = (b * B[offset+j+1]) + (b2 * SourceImage[offset+j]); + } + offset += cols; + } + + // + // filtered output. this is 2-pass IIR and pass 1 is vertical + // + offset = 0; + for(i = 0; i < rows; ++i){ + FilterImage[offset+cols-1] = A[offset+cols-1]; + } + + // + // add causal and anti-causal IIR parts + // + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols-1; ++j){ + FilterImage[offset+j] = A[offset+j] + B[offset+j+1]; + } + offset += cols; + } + + return; + +} + + +void computeISEF(float *SourceImage, float *FilterImage, int rows, int cols, double b){ + + int imageSize = rows*cols; + float *A; + float *B; + + A = calloc(imageSize, sizeof(float)); + B = calloc(imageSize, sizeof(float)); + + ISEF_Vertical(SourceImage, FilterImage, A, B, rows, cols, b); + ISEF_Horizontal(FilterImage, FilterImage, A, B, rows, cols, b); + + free(A); + free(B); + + return; + +} + +void Shen_Castan(double b, double ShenCastanLow, int rows, int cols, int window, int lowThreshold, int highThreshold, + double *RawImage, unsigned short *EdgeImage){ + + int i; + int imageSize = rows*cols; + float *FilterImage; + float *BinaryLaplacianImage; + float *SourceImage; + + FilterImage = calloc(imageSize, sizeof(float)); + BinaryLaplacianImage = calloc(imageSize, sizeof(float)); + SourceImage = calloc(imageSize, sizeof(float)); + + for(i = 0; i < imageSize; ++i){ + SourceImage[i] = RawImage[i]; + } + computeISEF(SourceImage, FilterImage, rows, cols, b); + // optional thresholding based on low, high + thresholdImage(SourceImage, FilterImage, rows, cols, lowThreshold, highThreshold); + computeBandedLaplacian(FilterImage, SourceImage, BinaryLaplacianImage, rows, cols); + // the new source image is now the adaptive gradient + getZeroCrossings(SourceImage, FilterImage, BinaryLaplacianImage, rows, cols, window); + thresholdEdges(SourceImage, EdgeImage, ShenCastanLow, rows, cols); + + free(FilterImage); + free(BinaryLaplacianImage); + free(SourceImage); + + return; + +} + +int NI_ShenCastanEdges(int samples, int rows, int cols, double b, double ShenCastanLow, int window, int lowThreshold, + int highThreshold, double *rawImage, unsigned short *edgeImage, int *groups){ + + + int i, j; + int offset; + int status = 0; + + Shen_Castan(b, ShenCastanLow, rows, cols, window, lowThreshold, highThreshold, rawImage, edgeImage); + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + status = *groups; + + return status; + +} + +void buildBinaryImage(int rows, int cols, double *rawImage, unsigned short *edgeImage, int lowThreshold, int highThreshold){ + + int i, j; + int offset; + double value; + int maskValue; + + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + value = rawImage[offset+j]; + maskValue = 1; + if(value < (double)lowThreshold) maskValue = 0; + if(value > (double)highThreshold) maskValue = 0; + edgeImage[offset+j] = maskValue; + } + offset += cols; + } + + return; + +} + + + +void morphoFilterBinaryImage(int rows, int cols, unsigned short *edgeImage, int CloseSize, int OpenSize){ + + + int i, j; + int offset, offset2; + unsigned short cmask[11][11]; + unsigned short omask[11][11]; + int olapValuesC[4]; + int olapValuesO[4]; + int CloseMaskSize; + int OpenMaskSize; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + int spadSize; + unsigned char *ImageE; + unsigned char *ImageC; + + spadSize = MAX(rows, cols); + + ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + + // + // Close filter + // + if(CloseSize){ + CloseMaskSize = (CloseSize-1)/2; + for(i = 0; i < 2*CloseMaskSize+1; ++i){ + for(j = 0; j < 2*CloseMaskSize+1; ++j){ + cmask[i][j] = 1; + } + } + LowValue1 = 0; + HighValue1 = 1; + LowValue2 = 1; + HighValue2 = 0; + olapValuesC[0] = LowValue1; + olapValuesC[1] = HighValue1; + olapValuesC[2] = LowValue2; + olapValuesC[3] = HighValue2; + } + + // + // Open filter + // + if(OpenSize){ + OpenMaskSize = (OpenSize-1)/2; + for(i = 0; i < 2*OpenMaskSize+1; ++i){ + for(j = 0; j < 2*OpenMaskSize+1; ++j){ + omask[i][j] = 1; + } + } + LowValue1 = 1; + HighValue1 = 0; + LowValue2 = 0; + HighValue2 = 1; + olapValuesO[0] = LowValue1; + olapValuesO[1] = HighValue1; + olapValuesO[2] = LowValue2; + olapValuesO[3] = HighValue2; + } + + offset = 0; + offset2 = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + ImageE[offset2+j] = (unsigned char)edgeImage[offset+j]; + } + offset2 += spadSize; + offset += cols; + } + + if(OpenSize){ + OpenCloseFilter(olapValuesO, OpenMaskSize, rows, cols, spadSize, ImageE, ImageC, omask); + } + + if(CloseSize){ + OpenCloseFilter(olapValuesC, CloseMaskSize, rows, cols, spadSize, ImageE, ImageC, cmask); + } + + offset = 0; + offset2 = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(ImageE[offset2+j] == 1){ + // this will activate some original off-pixels + edgeImage[offset+j] = 1; + } + else{ + // this will zero some original on-pixels + edgeImage[offset+j] = 0; + } + } + offset2 += spadSize; + offset += cols; + } + + free(ImageE); + free(ImageC); + + return; + +} + +void doRegionGrow(int samples, int rows, int cols, double *rawImage, unsigned short *edgeImage, int lowThreshold, + int highThreshold, int closeWindow, int openWindow){ + + buildBinaryImage(rows, cols, rawImage, edgeImage, lowThreshold, highThreshold); + morphoFilterBinaryImage(rows, cols, edgeImage, closeWindow, openWindow); + + return; + +} + +int NI_RegionGrow(int samples, int rows, int cols, int lowThreshold, int highThreshold, int closeWindow, + int openWindow, double *rawImage, unsigned short *edgeImage, int *groups){ + + int i, j; + int offset; + int status; + + doRegionGrow(samples, rows, cols, rawImage, edgeImage, lowThreshold, highThreshold, closeWindow, openWindow); + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + status = *groups; + return status; + +} + +int NI_SobelEdges(int samples, int rows, int cols, double sobelLow, int mode, int lowThreshold, int highThreshold, double BPHigh, + int apearture, double *rawImage, unsigned short *edgeImage, int *groups){ + + + int i, j; + int offset; + int status; + + doPreProcess(samples, rows, cols, rawImage, BPHigh, apearture, lowThreshold, highThreshold); + doSobel(samples, rows, cols, sobelLow, mode, rawImage, edgeImage); + *groups = ConnectedEdgePoints(rows, cols, edgeImage); + + + // + // prune the isolated pixels + // + offset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < cols; ++j){ + if(edgeImage[offset+j] > (*groups)){ + edgeImage[offset+j] = 0; + } + } + offset += cols; + } + + status = *groups; + return status; + +} + +void initThinFilter(int J_mask[3][30], int K_mask[3][30]){ + + int i, j; + int Column; + + for(i = 0; i < 3; ++i){ + for(j = 0; j < 30; ++j){ + J_mask[i][j] = 0; + K_mask[i][j] = 0; + } + } + + Column = 0; + J_mask[0][Column+0] = 1; + J_mask[0][Column+1] = 1; + J_mask[0][Column+2] = 1; + J_mask[1][Column+1] = 1; + + Column += 3; + J_mask[0][Column+1] = 1; + J_mask[1][Column+1] = 1; + J_mask[1][Column+2] = 1; + + Column += 3; + J_mask[0][Column+0] = 1; + J_mask[1][Column+0] = 1; + J_mask[2][Column+0] = 1; + J_mask[1][Column+1] = 1; + + Column += 3; + J_mask[0][Column+1] = 1; + J_mask[1][Column+0] = 1; + J_mask[1][Column+1] = 1; + + Column += 3; + J_mask[0][Column+2] = 1; + J_mask[1][Column+1] = 1; + J_mask[1][Column+2] = 1; + J_mask[2][Column+2] = 1; + + Column += 3; + J_mask[1][Column+0] = 1; + J_mask[1][Column+1] = 1; + J_mask[2][Column+1] = 1; + + Column += 3; + J_mask[1][Column+1] = 1; + J_mask[2][Column+0] = 1; + J_mask[2][Column+1] = 1; + J_mask[2][Column+2] = 1; + + Column += 3; + J_mask[1][Column+1] = 1; + J_mask[1][Column+2] = 1; + J_mask[2][Column+1] = 1; + + Column = 0; + K_mask[2][Column+0] = 1; + K_mask[2][Column+1] = 1; + K_mask[2][Column+2] = 1; + + Column += 3; + K_mask[1][Column+0] = 1; + K_mask[2][Column+0] = 1; + K_mask[2][Column+1] = 1; + + Column += 3; + K_mask[0][Column+2] = 1; + K_mask[1][Column+2] = 1; + K_mask[2][Column+2] = 1; + + Column += 3; + K_mask[1][Column+2] = 1; + K_mask[2][Column+1] = 1; + K_mask[2][Column+2] = 1; + + Column += 3; + K_mask[0][Column+0] = 1; + K_mask[1][Column+0] = 1; + K_mask[2][Column+0] = 1; + + Column += 3; + K_mask[0][Column+1] = 1; + K_mask[0][Column+2] = 1; + K_mask[1][Column+2] = 1; + + Column += 3; + K_mask[0][Column+0] = 1; + K_mask[0][Column+1] = 1; + K_mask[0][Column+2] = 1; + + Column += 3; + K_mask[0][Column+0] = 1; + K_mask[0][Column+1] = 1; + K_mask[1][Column+0] = 1; + + return; + +} + +void ThinningFilter(int regRows, int regColumns, int spadSize, int J_mask[3][30], int K_mask[3][30], + unsigned char *Input, unsigned char *CInput, unsigned char *ErosionStage, + unsigned char *DialationStage, unsigned char *HMT, unsigned char *Copy){ + + int i, j, k, l, m, n, overlap, hit; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + int Column, T, nloop; + int Offset; + int N, M; + int j_mask[3][3]; + int k_mask[3][3]; + + N = regRows; + M = regColumns; + + LowValue1 = 1; + HighValue1 = 0; + + LowValue2 = 0; + HighValue2 = 1; + + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + Copy[Offset+j] = Input[Offset+j]; + } + Offset += spadSize; + } + + nloop = 0; + while(1){ + // erode + Column = 0; + for(n = 0; n < 8; ++n){ + for(i = 0; i < 3; ++i){ + for(j = 0; j < 3; ++j){ + j_mask[i][j] = J_mask[i][Column+j]; + } + } + for(i = 0; i < 3; ++i){ + for(j = 0; j < 3; ++j){ + k_mask[i][j] = K_mask[i][Column+j]; + } + } + Column += 3; + + Offset = spadSize; + for(i = 1; i < N-1; ++i){ + for(j = 1; j < M-1; ++j){ + hit = LowValue1; + for(k = -1; k < 2; ++k){ + for(l = -1; l < 2; ++l){ + T = j_mask[k+1][l+1]; + if(T == 1){ + overlap = T*Input[Offset+(k*spadSize)+j+l]; + if(overlap == HighValue1) hit = HighValue1; + } + } + } + ErosionStage[Offset+j] = hit; + } + Offset += spadSize; + } + + // dialate + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + CInput[Offset+j] = (~Input[Offset+j]) & 0x1; + } + Offset += spadSize; + } + + Offset = spadSize; + for(i = 1; i < N-1; ++i){ + for(j = 1; j < M-1; ++j){ + hit = LowValue1; + for(k = -1; k < 2; ++k){ + for(l = -1; l < 2; ++l){ + T = k_mask[k+1][l+1]; + if(T == 1){ + overlap = T*CInput[Offset+(k*spadSize)+j+l]; + if(overlap == HighValue1) hit = HighValue1; + } + } + } + DialationStage[Offset+j] = hit; + } + Offset += spadSize; + } + + // form the HMT + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + m = (ErosionStage[Offset+j]*DialationStage[Offset+j]); + HMT[Offset+j] = m; + } + Offset += spadSize; + } + + // Thin for stage n + + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + HMT[Offset+j] = (~HMT[Offset+j]) & 0x1; + } + Offset += spadSize; + } + + Offset = 0; + for (i = 0; i < N; ++i){ + for (j = 0; j < M; ++j){ + m = (Input[Offset+j]*HMT[Offset+j]); + Input[Offset+j] = m; + } + Offset += spadSize; + } + } + + // check for the NULL set + hit = 0; + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + hit += abs(Copy[Offset+j]-Input[Offset+j]); + } + Offset += spadSize; + } + if(!hit) break; + + hit = 0; + Offset = 0; + for(i = 0; i < N; ++i){ + for(j = 0; j < M; ++j){ + Copy[Offset+j] = Input[Offset+j]; + if(Input[Offset+j]) ++hit; + } + Offset += spadSize; + } + ++nloop; + } + + + return; + +} + + +int NI_ThinFilter(int samples, int rows, int cols, int numberObjects, unsigned short *edgeImage, objStruct objectMetrics[]){ + + int i, j; + int loop; + int label; + int left, right, top, bottom; + int roiRows, roiCols; + int srcOffset; + int dstOffset; + int status; + int inflate = 1; + int J_mask[3][30]; + int K_mask[3][30]; + + unsigned char *Input; + unsigned char *CInput; + unsigned char *ErosionStage; + unsigned char *DialationStage; + unsigned char *HMT; + unsigned char *Copy; + unsigned short *thinEdgeImage; + + // + // scratch pad (spad) memory + // + Input = calloc(samples, sizeof(unsigned char)); + CInput = calloc(samples, sizeof(unsigned char)); + ErosionStage = calloc(samples, sizeof(unsigned char)); + DialationStage = calloc(samples, sizeof(unsigned char)); + HMT = calloc(samples, sizeof(unsigned char)); + Copy = calloc(samples, sizeof(unsigned char)); + thinEdgeImage = calloc(samples, sizeof(unsigned short)); + + initThinFilter(J_mask, K_mask); + for(loop = 0; loop < numberObjects; ++loop){ + label = objectMetrics[loop].Label; + left = objectMetrics[loop].L; + right = objectMetrics[loop].R; + top = objectMetrics[loop].T; + bottom = objectMetrics[loop].B; + roiRows = top-bottom+2*inflate; + roiCols = right-left+2*inflate; + + // + // clear the scratch pad + // + srcOffset = 0; + for(i = 0; i < roiRows; ++i){ + for(j = 0; j < roiCols; ++j){ + Input[srcOffset+j] = 0; + } + srcOffset += cols; + } + + // + // copy the ROI for MAT (medial axis transformation) filter + // + dstOffset = inflate*rows; + for(i = bottom; i < top; ++i){ + srcOffset = i*cols; + for(j = left; j < right; ++j){ + if(edgeImage[srcOffset+j] == label){ + Input[dstOffset+j-left+inflate] = 1; + } + } + dstOffset += cols; + } + ThinningFilter(roiRows, roiCols, cols, J_mask, K_mask, Input, CInput, ErosionStage, DialationStage, HMT, Copy); + + // + // copy the MAT roi to the new edgeImage (clip the inflate border) + // + dstOffset = inflate*rows; + for(i = bottom; i < top; ++i){ + srcOffset = i*cols; + for(j = left; j < right; ++j){ + if(Input[dstOffset+j-left+inflate]){ + thinEdgeImage[srcOffset+j] = label; + } + } + dstOffset += cols; + } + } + + // + // copy the MAT edges and return the thinned edges + // this will prune the isolated edge points from the edgeImage source + // + for(i = 0; i < rows*cols; ++i){ + edgeImage[i] = thinEdgeImage[i]; + } + + free(Input); + free(CInput); + free(ErosionStage); + free(DialationStage); + free(HMT); + free(Copy); + free(thinEdgeImage); + + status = 1; + + return status; + +} + + +void generateMask(unsigned char *ImageH, bPOINT *boundary, int newSamples, int label, int cols){ + + // + // get the boundary point pairs (left, right) for each line + // if there is no pair, then the boundary is open + // then fill the image in with the current label + // + + int i, j, k, m; + int list[2048]; + int distance; + int neighbor = 4; + int index; + int offset; + int maxDistance = 1024; + int x, y; + int low, high; + + for(i = 0; i < newSamples; ++i){ + boundary[i].haveLink = FALSE; + boundary[i].linkIndex = -1; + } + + for(i = 0; i < newSamples; ++i){ + if(!boundary[i].haveLink){ + boundary[i].haveLink = TRUE; + x = boundary[i].x; + y = boundary[i].y; + for(k = 0, j = 0; j < newSamples; ++j){ + if((j != i)){ + if(boundary[j].y == y){ + list[k] = j; + ++k; + } + } + } + // now get the closest boundary + if(k){ + distance = maxDistance; + index = -1; + for(j = 0; j < k; ++j){ + m = abs(x - boundary[list[j]].x); + if((m < distance) && (m > neighbor)){ + distance = m; + index = list[j]; + } + else if(m <= neighbor){ + boundary[list[j]].haveLink = TRUE; + } + } + if(index != -1){ + boundary[i].linkIndex = index; + boundary[index].linkIndex = i; + boundary[index].haveLink = TRUE; + if(boundary[i].x < boundary[index].x){ + low = boundary[i].x; + high = boundary[index].x; + } + else{ + low = boundary[index].x; + high = boundary[i].x; + } + // + // do the fill + // + offset = y * cols; + for(j = low; j <= high; ++j){ + ImageH[offset+j] = label; + } + } + } + else{ + // boundary point is isolated + boundary[i].linkIndex = i; + } + } + } + + return; + +} + +void getBoundaryMetrics(bPOINT *boundary, float *length, float *minRadius, float *maxRadius, float *aveRadius, + float Xcenter, float Ycenter, int newSamples){ + + int j; + float dX, dY; + float distance; + + if(newSamples < 2){ + *length = (float)0.0; + *minRadius = (float)0.0; + *maxRadius = (float)0.0; + *aveRadius = (float)0.0; + return; + } + + *length = (float)0.0; + for(j = 1; j < newSamples; ++j){ + dX = (float)(boundary[j].x - boundary[j-1].x); + dY = (float)(boundary[j].y - boundary[j-1].y); + distance = (float)sqrt(dX*dX + dY*dY); + *length += distance; + } + + *minRadius = (float)10000.0; + *maxRadius = (float)-10000.0; + *aveRadius = (float)0.0; + for(j = 0; j < newSamples; ++j){ + dX = (float)(boundary[j].x - Xcenter); + dY = (float)(boundary[j].y - Ycenter); + distance = (float)sqrt(dX*dX + dY*dY); + *aveRadius += distance; + if(distance < *minRadius) *minRadius = distance; + if(distance > *maxRadius) *maxRadius = distance; + } + + if(newSamples){ + *aveRadius /= (float)newSamples; + } + + return; + +} + +void trackBoundary(unsigned char *Input, blobBoundary lBoundary[], int mcount, int spadSize, + blobBoundary seedValue, int searchWindow){ + + + int i, j, k, m, p; + int offset; + int CurI; + int CurJ; + int StrI; + int StrJ; + int NewI; + int NewJ; + int MinD; + int inflate = searchWindow; + + CurI = seedValue.xy.x; + CurJ = seedValue.xy.y; + StrI = CurI; + StrJ = CurJ; + + p = 0; + lBoundary[p].xy.x = StrI; + lBoundary[p].xy.y = StrJ; + offset = StrI * spadSize; + + p = 1; + while(p < mcount){ + offset = (CurI-inflate)*spadSize; + if(offset < 0){ + printf("offset < 0 "); + printf("CurI [%d]. p [%d]. mcount [%d]\n", CurI, p, mcount); + getchar(); + } + MinD = 1024; + NewI = -1; + NewJ = -1; + for(i = CurI-inflate; i < CurI+inflate; ++i){ + for(j = CurJ-inflate; j < CurJ+inflate; ++j){ + m = Input[offset+j]; + if(m == 1){ + // city block distance + k = abs(i-CurI) + abs(j-CurJ); + if(k < MinD){ + MinD = k; + NewI = i; + NewJ = j; + } + } + } + offset += spadSize; + } + if(NewI != -1) CurI = NewI; + if(NewJ != -1) CurJ = NewJ; + offset = CurI * spadSize; + Input[offset+CurJ] = 0; + lBoundary[p].xy.x = CurJ; + lBoundary[p].xy.y = CurI; + ++p; + } + + return; + +} + + +void OpenCloseFilter(int olapValues[], int maskSize, int rows, int columns, int spadSize, + unsigned char *input, unsigned char *output, unsigned short mask[11][11]){ + + + // + // do morphological open/close image filtering. the olapValues array determines + // if the filter is Open or Close. + // + int i, j, k, l, m, overlap, hit; + int offset; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + + LowValue1 = olapValues[0]; + HighValue1 = olapValues[1]; + LowValue2 = olapValues[2]; + HighValue2 = olapValues[3]; + + // close - step 1 is dialate + // open - step 1 is erode + offset = maskSize*spadSize; + for(i = maskSize; i < rows-maskSize; ++i){ + for(j = maskSize; j < columns-maskSize; ++j){ + hit = LowValue1; + for(k = -maskSize; k < maskSize; ++k){ + m = k*spadSize; + for(l = -maskSize; l < maskSize; ++l){ + overlap = mask[k+maskSize][l+maskSize]*input[offset+m+j+l]; + if(overlap == HighValue1){ + hit = HighValue1; + } + } + } + output[offset+j] = hit; + } + offset += spadSize; + } + + // close - step 2 is erode + // open - step 2 is dialate + offset = maskSize*spadSize; + for(i = maskSize; i < rows-maskSize; ++i){ + for(j = maskSize; j < columns-maskSize; ++j){ + hit = LowValue2; + for(k = -maskSize; k < maskSize; ++k){ + m = k*spadSize; + for(l = -maskSize; l < maskSize; ++l){ + overlap = mask[k+maskSize][l+maskSize]*output[offset+m+j+l]; + if(overlap == HighValue2){ + hit = HighValue2; + } + } + } + input[offset+j] = hit; + } + offset += spadSize; + } + + return; +} + +void getCompactness(unsigned char *Input, RECT roi, int label, int spadSize, float *vCompactness, float length){ + + int i, j; + int maskOffset; + int area; + static float fpi = (float)(4.0 * 3.14159); + + area = 0; + for(i = roi.bottom; i < roi.top; ++i){ + maskOffset = i*spadSize; + for(j = roi.left; j < roi.right; ++j){ + if(Input[maskOffset+j] == label){ + ++area; + } + } + } + if(area && (length != (float)0.0)){ + *vCompactness = (fpi * (float)area) / (length*length); + } + else{ + *vCompactness = (float)0.0; + } + + return; +} + + +void doMorphology(unsigned char *Input, unsigned char *ImageE, unsigned char *ImageC, unsigned char *ImageH, + int olapValuesC[],int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], + RECT roi, int label, int CloseMaskSize, int OpenMaskSize, int spadSize){ + + int i, j; + int rows, cols; + int srcOffset; + int dstOffset; + int maskSize; + + cols = roi.right - roi.left; + rows = roi.top - roi.bottom; + + for(i = 0; i < spadSize*spadSize; ++i){ + ImageE[i] = 0; + ImageC[i] = 0; + } + + // + // put the ROI in the ImageE array centered in ULC + // + dstOffset = 0; + for(i = roi.bottom; i < roi.top; ++i){ + srcOffset = i*spadSize; + for(j = roi.left; j < roi.right; ++j){ + if(ImageH[srcOffset+j] == label){ + ImageE[dstOffset+j-roi.left] = 1; + } + } + dstOffset += spadSize; + } + + // + // open + // + maskSize = OpenMaskSize; + OpenCloseFilter(olapValuesO, maskSize, rows, cols, spadSize, ImageE, ImageC, omask); + // + // close + // + maskSize = CloseMaskSize; + OpenCloseFilter(olapValuesC, maskSize, rows, cols, spadSize, ImageE, ImageC, cmask); + + // + // put the closed ROI (in ImageE) back in its roi space + // + + srcOffset = 0; + for(i = roi.bottom; i < roi.top+2*maskSize+1; ++i){ + dstOffset = (i-(2*maskSize+1))*spadSize; + for(j = roi.left-maskSize-1; j < roi.right+maskSize+1; ++j){ + if(ImageE[srcOffset+j-roi.left] == 1){ + Input[dstOffset+j-maskSize+1] = label; + } + } + srcOffset += spadSize; + } + + return; + +} + + +void getBoundary(unsigned short *ThinEdgeImage, unsigned char *Input, blobBoundary *pBoundary, blobBoundary *lBoundary, + boundaryIndex *pBoundaryIndex, RECT boundBox, int label, int bBox, int nextSlot, int memOffset, + int spadSize, int searchWindow){ + + int i, j; + int dstOffset; + int srcOffset; + int mcount; + int rows; + int columns; + bool first; + blobBoundary value; + int inflate = searchWindow+1; + int count; + + pBoundaryIndex[bBox+1].rectangle.left = boundBox.left; + pBoundaryIndex[bBox+1].rectangle.right = boundBox.right; + pBoundaryIndex[bBox+1].rectangle.top = boundBox.top; + pBoundaryIndex[bBox+1].rectangle.bottom = boundBox.bottom; + + for(i = 0; i < spadSize*spadSize; ++i){ + Input[i] = 0; + } + + //copy to spad + + count = 0; + rows = boundBox.top-boundBox.bottom+2*inflate; + columns = boundBox.right-boundBox.left+2*inflate; + dstOffset = inflate*spadSize; + for(i = boundBox.bottom; i < boundBox.top; ++i){ + srcOffset = i*spadSize; + for(j = boundBox.left; j < boundBox.right; ++j){ + if(ThinEdgeImage[srcOffset+j] == label){ + Input[dstOffset+j-boundBox.left+inflate] = 1; + ++count; + } + } + dstOffset += spadSize; + } + + mcount = 0; + first = TRUE; + srcOffset = 0; + for(i = 0; i < rows; ++i){ + for(j = 0; j < columns; ++j){ + if(Input[srcOffset+j]){ + if(first){ + first = FALSE; + // index of the seed sample + value.xy.x = i; + value.xy.y = j; + } + ++mcount; + } + } + srcOffset += spadSize; + } + + trackBoundary(Input, lBoundary, mcount, spadSize, value, searchWindow); + + pBoundaryIndex[nextSlot].numberPoints = mcount; + for(i = 0; i < mcount; ++i){ + value.xy.x = lBoundary[i].xy.x + boundBox.left - inflate; + value.xy.y = lBoundary[i].xy.y + boundBox.bottom - inflate + 1; + //printf("[%d, %d]\n", value.xy.x, value.xy.y); + pBoundary[memOffset].xy.x = value.xy.x; + pBoundary[memOffset].xy.y = value.xy.y; + ++memOffset; + } + //getchar(); + + return; + +} + + +void buildBoundary(objStruct objectMetrics[], int searchWindow, unsigned short *ThinEdgeImage, + int numberObjects, int srcRows, int srcCols){ + + int i, j, k; + int count; + int numBoundaries; + int numSamples; + int offset; + int offset2; + int end; + int label; + int distance; + // these should be setup parameters + int closureDistance = 12; + int CloseSize = 5; + int OpenSize = 5; + int threshold = 3; + int newSamples; + int spadSize; + POINT rectPoint[4]; + int in[4]; + float length; + float minRadius; + float maxRadius; + float aveRadius; + float vCompactness; + // for morphological close of mask. max structuring element is 11x11 + unsigned short cmask[11][11]; + unsigned short omask[11][11]; + int olapValuesC[4]; + int olapValuesO[4]; + int CloseMaskSize; + int OpenMaskSize; + int LowValue1, HighValue1; + int LowValue2, HighValue2; + RECT bBox; + + boundaryIndex *pBoundaryIndex; + blobBoundary *pBoundary; + blobBoundary *lBoundary; + bPOINT *boundary; + unsigned char *Input; + unsigned char *ImageE; + unsigned char *ImageC; + unsigned char *ImageH; + + // + // Close filter + // + CloseMaskSize = (CloseSize-1)/2; + for(i = 0; i < 2*CloseMaskSize+1; ++i){ + for(j = 0; j < 2*CloseMaskSize+1; ++j){ + cmask[i][j] = 1; + } + } + LowValue1 = 0; + HighValue1 = 1; + LowValue2 = 1; + HighValue2 = 0; + olapValuesC[0] = LowValue1; + olapValuesC[1] = HighValue1; + olapValuesC[2] = LowValue2; + olapValuesC[3] = HighValue2; + + // + // Open filter + // + OpenMaskSize = (OpenSize-1)/2; + for(i = 0; i < 2*OpenMaskSize+1; ++i){ + for(j = 0; j < 2*OpenMaskSize+1; ++j){ + omask[i][j] = 1; + } + } + LowValue1 = 1; + HighValue1 = 0; + LowValue2 = 0; + HighValue2 = 1; + olapValuesO[0] = LowValue1; + olapValuesO[1] = HighValue1; + olapValuesO[2] = LowValue2; + olapValuesO[3] = HighValue2; + + + //spadSize = MAX(srcRows, srcCols); + spadSize = srcCols; + + pBoundaryIndex = calloc(srcRows+srcCols, sizeof(boundaryIndex)); + Input = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageH = calloc(spadSize*spadSize, sizeof(unsigned char)); + pBoundary = calloc(srcRows*srcCols, sizeof(blobBoundary)); + lBoundary = calloc(32767, sizeof(blobBoundary)); + boundary = calloc(32767, sizeof(POINT)); + + for(i = 0; i < (srcRows+srcCols); ++i){ + pBoundaryIndex[i].numberPoints = 0; + pBoundaryIndex[i].curveClose = 0; + pBoundaryIndex[i].isWithin = FALSE; + pBoundaryIndex[i].criticalSize = FALSE; + pBoundaryIndex[i].closedCurve = FALSE; + } + + + for(i = 0; i < numberObjects; ++i){ + //for(i = 0; i < 1; ++i){ + ++pBoundaryIndex[0].numberPoints; + count = 0; + j = 1; + while(pBoundaryIndex[j].numberPoints){ + count += pBoundaryIndex[j++].numberPoints; + } + bBox.left = objectMetrics[i].L; + bBox.right = objectMetrics[i].R; + bBox.top = objectMetrics[i].T; + bBox.bottom = objectMetrics[i].B; + label = objectMetrics[i].Label; + pBoundaryIndex[i+1].Label = label; + //printf("(%d, %d, %d, %d [%d])\n", bBox.left, bBox.right, bBox.top, bBox.bottom, label); + getBoundary(ThinEdgeImage, Input, pBoundary, lBoundary, pBoundaryIndex, bBox, label, + i, pBoundaryIndex[0].numberPoints, count, spadSize, searchWindow); + } + + // + // Input will now be used in the fill. Copy the labeled edge image + // + + // + // numBoundaries = numberObjects + // + offset = 0; + numBoundaries = pBoundaryIndex[0].numberPoints; + //printf("numBoundaries [%d]\n", numBoundaries); + for(i = 0; i < numBoundaries; ++i){ + numSamples = pBoundaryIndex[i+1].numberPoints; + end = numSamples-2; + newSamples = numSamples-1; + for(j = 0; j < numSamples; ++j){ + boundary[j].x = pBoundary[offset+j+1].xy.x; + boundary[j].y = pBoundary[offset+j+1].xy.y; + } + + // + // clip off the ends where stray boundary pixels were left over + // + while(1){ + distance = abs(boundary[end].x-boundary[end-1].x) + abs(boundary[end].y-boundary[end-1].y); + if(distance > threshold){ + --end; + --newSamples; + } + else{ + break; + } + } + //printf("[%d] newSamples [%d]\n", i, newSamples); + + distance = abs(boundary[0].x-boundary[end-2].x) + abs(boundary[0].y-boundary[end-2].y); + pBoundaryIndex[i+1].curveClose = distance; + + if(pBoundaryIndex[i+1].curveClose < closureDistance){ + pBoundaryIndex[i+1].closedCurve = TRUE; + } + pBoundaryIndex[i+1].centroid.x = 0; + pBoundaryIndex[i+1].centroid.y = 0; + for(j = 0; j < newSamples; ++j){ + pBoundaryIndex[i+1].centroid.x += boundary[j].x; + pBoundaryIndex[i+1].centroid.y += boundary[j].y; + } + if(newSamples){ + pBoundaryIndex[i+1].centroid.x /= newSamples; + pBoundaryIndex[i+1].centroid.y /= newSamples; + } + getBoundaryMetrics(boundary, &length, &minRadius, &maxRadius, &aveRadius, + (float)pBoundaryIndex[i+1].centroid.x, (float)pBoundaryIndex[i+1].centroid.y, newSamples); + pBoundaryIndex[i+1].boundaryLength = length; + pBoundaryIndex[i+1].minRadius = minRadius; + pBoundaryIndex[i+1].maxRadius = maxRadius; + pBoundaryIndex[i+1].aveRadius = aveRadius; + if(minRadius != 0.0){ + pBoundaryIndex[i+1].ratio = maxRadius / minRadius; + } + else{ + pBoundaryIndex[i+1].ratio = -1.0; + } + + // + // augment the ROI boundary + // + pBoundaryIndex[i+1].rectangle.left -= 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.right += 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.bottom -= 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.top += 2*CloseMaskSize; + label = pBoundaryIndex[i+1].Label; + + // + // mask goes in ImageH. morpho filter the mask first + // + generateMask(ImageH, boundary, newSamples, label, spadSize); + + // + // open-close the mask + // + doMorphology(Input, ImageE, ImageC, ImageH, olapValuesC, olapValuesO, cmask, omask, + pBoundaryIndex[i+1].rectangle, label, CloseMaskSize, OpenMaskSize, spadSize); + + // + // now get the compactness metrics + // + getCompactness(Input, pBoundaryIndex[i+1].rectangle, label, spadSize, &vCompactness, length); + pBoundaryIndex[i+1].compactness = vCompactness; + + // + // reset the ROI boundary + // + pBoundaryIndex[i+1].rectangle.left += 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.right -= 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.bottom += 2*CloseMaskSize; + pBoundaryIndex[i+1].rectangle.top -= 2*CloseMaskSize; + offset += numSamples; + } + + + for(i = 0; i < numBoundaries; ++i){ + for(j = 0; j < numBoundaries; ++j){ + if(j != i){ + rectPoint[0].x = pBoundaryIndex[j+1].rectangle.left; + rectPoint[0].y = pBoundaryIndex[j+1].rectangle.bottom; + rectPoint[1].x = pBoundaryIndex[j+1].rectangle.left; + rectPoint[1].y = pBoundaryIndex[j+1].rectangle.top; + rectPoint[2].x = pBoundaryIndex[j+1].rectangle.right; + rectPoint[2].y = pBoundaryIndex[j+1].rectangle.bottom; + rectPoint[3].x = pBoundaryIndex[j+1].rectangle.right; + rectPoint[3].y = pBoundaryIndex[j+1].rectangle.top; + in[0] = 0; + in[1] = 0; + in[2] = 0; + in[3] = 0; + for(k = 0; k < 4; ++k){ + if((rectPoint[k].x > pBoundaryIndex[i+1].rectangle.left) && + (rectPoint[k].x < pBoundaryIndex[i+1].rectangle.right)){ + if((rectPoint[k].y > pBoundaryIndex[i+1].rectangle.bottom) && + (rectPoint[k].y < pBoundaryIndex[i+1].rectangle.top)){ + in[k] = 1; + } + } + } + if(in[0] && in[1] && in[2] && in[3]){ + pBoundaryIndex[j+1].isWithin = TRUE; + } + } + } + } + + // + // fill in the Python features + // + for(i = 0; i < numBoundaries; ++i){ + objectMetrics[i].curveClose = pBoundaryIndex[i+1].curveClose; + objectMetrics[i].cXBoundary = pBoundaryIndex[i+1].centroid.x; + objectMetrics[i].cYBoundary = pBoundaryIndex[i+1].centroid.y; + objectMetrics[i].boundaryLength = pBoundaryIndex[i+1].boundaryLength; + objectMetrics[i].minRadius = pBoundaryIndex[i+1].minRadius; + objectMetrics[i].maxRadius = pBoundaryIndex[i+1].maxRadius; + objectMetrics[i].aveRadius = pBoundaryIndex[i+1].aveRadius; + objectMetrics[i].ratio = pBoundaryIndex[i+1].ratio; + objectMetrics[i].compactness = pBoundaryIndex[i+1].compactness; + } + + // debug only + if(1){ + for(i = 0; i < numBoundaries; ++i){ + if(pBoundaryIndex[i+1].boundaryLength != (float)0.0){ + printf("boundary %d:\n", i); + printf("\t\tRect (%d, %d, %d, %d)\n", pBoundaryIndex[i+1].rectangle.left, + pBoundaryIndex[i+1].rectangle.right, + pBoundaryIndex[i+1].rectangle.top, + pBoundaryIndex[i+1].rectangle.bottom); + printf("\t\tCentroid (%d, %d)\n", pBoundaryIndex[i+1].centroid.x, pBoundaryIndex[i+1].centroid.y); + printf("\t\tLength (%f)\n", pBoundaryIndex[i+1].boundaryLength); + printf("\t\tRatio (%f)\n", pBoundaryIndex[i+1].ratio); + printf("\t\taveRadius (%f)\n", pBoundaryIndex[i+1].aveRadius); + printf("\t\tLabel (%d)\n", pBoundaryIndex[i+1].Label); + printf("\t\tCompactness (%f)\n", pBoundaryIndex[i+1].compactness); + printf("\t\tCurveClose (%d)\n", pBoundaryIndex[i+1].curveClose); + if(pBoundaryIndex[i+1].isWithin){ + printf("\t\tContained (T)\n"); + } + else{ + printf("\t\tContained (F)\n"); + } + if(pBoundaryIndex[i+1].closedCurve){ + printf("\t\tclosedCurve (T)\n"); + } + else{ + printf("\t\tclosedCurve (F)\n"); + } + } + } + } + + // + // need to return input which is now mask image + // + + offset = 0; + offset2 = 0; + for(i = 0; i < srcRows; ++i){ + for(j = 0; j < srcCols; ++j){ + ThinEdgeImage[offset+j] = (unsigned short)Input[offset2+j]; + } + offset += srcCols; + offset2 += spadSize; + } + + free(pBoundaryIndex); + free(Input); + free(ImageE); + free(ImageC); + free(ImageH); + free(pBoundary); + free(lBoundary); + free(boundary); + + return; + +} + + +void initLaws(LawsFilter7 *lawsFilter){ + + int i; + float sum; + float L7[7] = { 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0}; + float E7[7] = {-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0}; + float S7[7] = {-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0}; + float W7[7] = {-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0}; + float R7[7] = { 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0}; + float O7[7] = {-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0}; + + lawsFilter->numberKernels = 6; + lawsFilter->kernelLength = 7; + lawsFilter->numberFilterLayers = 21; + lawsFilter->name[0] = 'L'; + lawsFilter->name[1] = 'E'; + lawsFilter->name[2] = 'S'; + lawsFilter->name[3] = 'W'; + lawsFilter->name[4] = 'R'; + lawsFilter->name[5] = 'O'; + for(i = 0; i < 7; ++i){ + lawsFilter->lawsKernel[0][i] = L7[i]; + lawsFilter->lawsKernel[1][i] = E7[i]; + lawsFilter->lawsKernel[2][i] = S7[i]; + lawsFilter->lawsKernel[3][i] = W7[i]; + lawsFilter->lawsKernel[4][i] = R7[i]; + lawsFilter->lawsKernel[5][i] = O7[i]; + } + + // DC filter is unity gain + sum = (float)0.0; + for(i = 0; i < 7; ++i){ + sum += lawsFilter->lawsKernel[0][i]; + } + for(i = 0; i < 7; ++i){ + lawsFilter->lawsKernel[0][i] /= sum; + } + + return; + +} + +float lawsConvolution(float *image, float *rowFilter, float *colFilter, int kernelSize){ + + int i, j; + int offset; + float result[7]; + float sum; + + // filter rows + for(i = 0; i < kernelSize; ++i){ + sum = (float)0.0; + offset = i * kernelSize; + for(j = 0; j < kernelSize; ++j){ + sum += (rowFilter[j]*image[offset+j]); + } + result[i] = sum; + } + + //filter columns + sum = (float)0.0; + for(j = 0; j < kernelSize; ++j){ + sum += (rowFilter[j]*result[j]); + } + + return(sum); + +} + + +void getLawsTexture(LawsFilter7 lawsFilter, tTEM LawsFeatures[], objStruct objectMetrics[], double *sourceImage, + unsigned short *MaskImage, int numberObjects, int srcRows, int srcCols){ + + int i, j; + int label; + RECT bBox; + int aperature = (lawsFilter.kernelLength-1)/2; + unsigned char *ImageH; + float *ImageT; + float *lawsImage; + + ImageH = calloc(srcRows*srcCols, sizeof(unsigned char)); + ImageT = calloc(srcRows*srcCols, sizeof(float)); + lawsImage = calloc(lawsFilter.numberFilterLayers*srcRows*srcCols, sizeof(float)); + + for(i = 0; i < numberObjects; ++i){ + bBox.left = objectMetrics[i].L; + bBox.right = objectMetrics[i].R; + bBox.top = objectMetrics[i].T; + bBox.bottom = objectMetrics[i].B; + label = objectMetrics[i].Label; + if(objectMetrics[i].voxelMean != (float)0.0){ + // + // valid size region + // + computeLaws(lawsFilter, LawsFeatures, bBox, label, aperature, srcRows, srcCols, ImageH, ImageT, + MaskImage, lawsImage, sourceImage); + for(j = 1; j < lawsFilter.numberFilterLayers; ++j){ + objectMetrics[i].TEM[j-1] = LawsFeatures[j].Variance; + } + /* + int index; + int offset; + int layerStep = srcRows*srcCols; + if(label == debugBlob){ + index = 0; + for(j = 1; j < lawsFilter.numberFilterLayers; ++j){ + if(LawsFeatures[j].Variance == (float)1.0) index = j; + } + // overwrite the raw image + offset = index * layerStep; + for(j = 0; j < layerStep; ++j){ + sourceImage[j] = lawsImage[offset+j]; + } + } + */ + } + } + + free(ImageH); + free(ImageT); + free(lawsImage); + + return; + +} + +void computeLaws(LawsFilter7 lawsFilter, tTEM LawsFeatures[], RECT roi, int label, int aperature, int srcRows, int srcCols, + unsigned char *ImageH, float *ImageT, unsigned short *MaskImage, float *lawsImage, double *sourceImage){ + + // + // hard-wirred to Law's 7 kernels + // + int i, j, k; + int lawsLayer; + int column, row; + int offset; + int maskOffset[7]; + int dataOffset[7]; + float myImage[49]; + int count; + int outerKernelNumber; + int innerKernelNumber; + int rowNumber; + int kernelSize = lawsFilter.kernelLength; + int fullMask = kernelSize*kernelSize; + int layerStep = srcRows*srcCols; + float *rowFilter; + float *colFilter; + float filterResult1; + float filterResult2; + float lawsLL; + float t; + float maxValue; + float scale; + char I, J; + char combo[24]; + char dual[24]; + + + // zero the laws mask memory first + for(i = 0; i < srcRows*srcCols; ++i){ + ImageH[i] = 0; + } + for(j = 0; j < lawsFilter.numberFilterLayers; ++j){ + LawsFeatures[j].Mean = (float)0.0; + LawsFeatures[j].Variance = (float)0.0; + } + + for(i = roi.bottom+aperature; i < roi.top-aperature; ++i){ + // get the row array offset for mask and data source. + for(row = -aperature; row <= aperature; ++row){ + maskOffset[row+aperature] = (i+row)*srcCols; + dataOffset[row+aperature] = maskOffset[row+aperature]; + } + for(j = roi.left+aperature; j < roi.right-aperature; ++j){ + // + // get 7x7 segment and make sure have 100% mask coverage + // + count = 0; + for(row = -aperature; row <= aperature; ++row){ + rowNumber = (row+aperature)*kernelSize; + for(column = -aperature; column <= aperature; ++column){ + if(MaskImage[maskOffset[row+aperature]+j+column] == label){ + myImage[rowNumber+column+aperature] = sourceImage[dataOffset[row+aperature]+j+column]; + ++count; + } + } + } + if(count == fullMask){ + // + // full mask. 100% coverage. now do the Law's texture filters + // + ImageH[i*srcCols+j] = 1; + lawsLayer = 0; + for(outerKernelNumber = 0; outerKernelNumber < lawsFilter.numberKernels; ++outerKernelNumber){ + // + // outer loop pulls the i'th kernel. kernel 0 is the LP kernel + // the outer loop is the iso-kernel + // + I = lawsFilter.name[outerKernelNumber]; + sprintf(dual, "%c_%c", I, I); + rowFilter = &lawsFilter.lawsKernel[outerKernelNumber][0]; + colFilter = &lawsFilter.lawsKernel[outerKernelNumber][0]; + filterResult1 = lawsConvolution(myImage, rowFilter, colFilter, kernelSize); + // lawsLayer 0 is the LP and needs to be used to scale. + if(outerKernelNumber){ + lawsImage[lawsLayer*layerStep + i*srcCols + j] = (float)2.0 * filterResult1 / lawsLL; + } + else{ + lawsLL = (float)2.0 * filterResult1; + lawsImage[lawsLayer*layerStep + i*srcCols + j] = (float)2.0 * filterResult1; + } + strcpy(&LawsFeatures[lawsLayer].filterName[0], dual); + ++lawsLayer; + // + // now do the inner loop and get the column filters for the other laws kernels + // + for(innerKernelNumber = outerKernelNumber+1; innerKernelNumber < lawsFilter.numberKernels; ++innerKernelNumber){ + J = lawsFilter.name[innerKernelNumber]; + sprintf(combo, "%c_%c", I, J); + strcpy(&LawsFeatures[lawsLayer].filterName[0], combo); + colFilter = &lawsFilter.lawsKernel[innerKernelNumber][0]; + filterResult1 = lawsConvolution(myImage, rowFilter, colFilter, kernelSize); + filterResult2 = lawsConvolution(myImage, colFilter, rowFilter, kernelSize); + lawsImage[lawsLayer*layerStep + i*srcCols + j] = (filterResult1 / lawsLL) + (filterResult2 / lawsLL); + ++lawsLayer; + } + } + } + } + } + + for(i = 0; i < lawsFilter.numberFilterLayers; ++i){ + LawsFeatures[i].Mean = (float)0.0; + LawsFeatures[i].Variance = (float)0.0; + } + + count = 0; + for(i = roi.bottom+aperature; i < roi.top-aperature; ++i){ + row = i * srcCols; + for(j = roi.left+aperature; j < roi.right-aperature; ++j){ + if(ImageH[row+j]){ + ++count; + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + offset = k * layerStep + row; + LawsFeatures[k].Mean += lawsImage[offset+j]; + } + } + } + } + + if(count == 0){ + printf("no samples for texture\n"); + return; + } + + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + LawsFeatures[k].Mean /= (float)count; + } + for(i = roi.bottom+aperature; i < roi.top-aperature; ++i){ + row = i * srcCols; + for(j = roi.left+aperature; j < roi.right-aperature; ++j){ + if(ImageH[row+j]){ + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + offset = k * layerStep + row; + t = lawsImage[offset+j] - LawsFeatures[k].Mean; + LawsFeatures[k].Variance += (t * t); + } + } + } + } + for(k = 0; k < lawsFilter.numberFilterLayers; ++k){ + LawsFeatures[k].Variance /= (float)count; + LawsFeatures[k].Variance = (float)(sqrt(LawsFeatures[k].Variance)); + } + + // + // now normalize the variance feature (TEM) + // + maxValue = (float)0.0; + for(i = 1; i < lawsFilter.numberFilterLayers; ++i){ + if((LawsFeatures[i].Variance) > maxValue) maxValue = LawsFeatures[i].Variance; + } + scale = (float)1.0 / maxValue; + for(i = 1; i < lawsFilter.numberFilterLayers; ++i){ + LawsFeatures[i].Variance = scale * LawsFeatures[i].Variance; + } + + + return; + +} + +void getVoxelMeasures(objStruct objectMetrics[], double *sourceImage, unsigned short *MaskImage, + int numberObjects, int srcRows, int srcCols){ + + int i, j, k; + int label; + int offset; + int count; + float mean, std, t; + RECT bBox; + + for(i = 0; i < numberObjects; ++i){ + bBox.left = objectMetrics[i].L; + bBox.right = objectMetrics[i].R; + bBox.top = objectMetrics[i].T; + bBox.bottom = objectMetrics[i].B; + label = objectMetrics[i].Label; + count = 0; + mean = (float)0.0; + for(j = bBox.bottom; j < bBox.top; ++j){ + offset = j * srcCols; + for(k = bBox.left; k < bBox.right; ++k){ + if(MaskImage[offset+k] == label){ + mean += sourceImage[offset+k]; + ++count; + } + } + } + if(count){ + mean /= (float)count; + std = (float)0.0; + for(j = bBox.bottom; j < bBox.top; ++j){ + offset = j * srcCols; + for(k = bBox.left; k < bBox.right; ++k){ + if(MaskImage[offset+k] == label){ + t = (sourceImage[offset+k]-mean); + std += (t * t); + } + } + } + } + if(count){ + std /= (float)count; + std = sqrt(std); + objectMetrics[i].voxelMean = mean - 2048.0; // the 2048 is only for the cardiac CT volume + objectMetrics[i].voxelVar = std; + } + else{ + objectMetrics[i].voxelMean = 0.0; + objectMetrics[i].voxelVar = 0.0; + } + if(0) printf("(%d) mean %f, std %f\n", label, objectMetrics[i].voxelMean, objectMetrics[i].voxelVar); + } + + return; + +} + +int NI_BuildBoundary(int samples, int rows, int cols, int numberObjects, unsigned short *edgeImage, + objStruct objectMetrics[]){ + + int searchWindow = 5; // 5 is good value for Sobel - (should be 13 for Canny edges) + int status = 1; + + buildBoundary(objectMetrics, searchWindow, edgeImage, numberObjects, rows, cols); + + return status; + +} + +int NI_VoxelMeasures(int samples, int rows, int cols, int numberObjects, double *sourceImage, + unsigned short *maskImage, objStruct objectMetrics[]){ + + int status = 1; + getVoxelMeasures(objectMetrics, sourceImage, maskImage, numberObjects, rows, cols); + + return status; + +} + + +int NI_TextureMeasures(int samples, int rows, int cols, int numberObjects, double *sourceImage, + unsigned short *maskImage, objStruct objectMetrics[]){ + + int status = 1; + LawsFilter7 lawsFilter; + tTEM LawsFeatures[21]; + + initLaws(&lawsFilter); + getLawsTexture(lawsFilter, LawsFeatures, objectMetrics, sourceImage, maskImage, numberObjects, rows, cols); + + return status; + +} + + + Added: trunk/scipy/ndimage/segment/__init__.py =================================================================== --- trunk/scipy/ndimage/segment/__init__.py 2007-11-05 23:13:01 UTC (rev 3498) +++ trunk/scipy/ndimage/segment/__init__.py 2007-11-07 17:53:37 UTC (rev 3499) @@ -0,0 +1,3 @@ + +ver = '0.0.1' + Added: trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h =================================================================== --- trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h 2007-11-05 23:13:01 UTC (rev 3498) +++ trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h 2007-11-07 17:53:37 UTC (rev 3499) @@ -0,0 +1,155 @@ +#ifndef V1_STRUCTSH +#define V1_STRUCTSH + +#define bool unsigned char + +typedef struct{ + int x; + int y; +}POINT; + +typedef struct{ + int x; + int y; + int linkIndex; + bool haveLink; +}bPOINT; + +typedef struct{ + int left; + int right; + int top; + int bottom; +}RECT; + +typedef struct{ + char filterName[20]; + float Mean; + float Variance; +}tTEM; + +typedef struct{ + int numberKernels; + int kernelLength; + int numberFilterLayers; + float lawsKernel[6][7]; + char name[7]; +}LawsFilter7; + +typedef struct{ + // filled in GetObjectStats + int L; + int R; + int T; + int B; + int Label; + int Area; + float cX; + float cY; + // filled in BuildBoundary + int curveClose; + float cXBoundary; + float cYBoundary; + float boundaryLength; + float minRadius; + float maxRadius; + float aveRadius; + float ratio; + float compactness; + // filled in VoxelMeasures + float voxelMean; + float voxelVar; + // filled in TextureMeasures + float TEM[20]; +}objStruct; + +typedef struct{ + int numberPoints; + int curveClose; + int classify; + float boundaryLength; + float minRadius; + float maxRadius; + float aveRadius; + float ratio; + float compactness; + float voxelMean; + float voxelVar; + RECT rectangle; + POINT centroid; + bool isWithin; + bool closedCurve; + bool criticalSize; + int Label; +}boundaryIndex; + + +typedef struct{ + POINT xy; +}blobBoundary; + + +// +// prototypes +// +int NI_RegionGrow(int, int, int, int, int, int, int, double *, unsigned short *, int *); +int NI_TextureMeasures(int, int, int, int, double *, unsigned short *, objStruct objectMetrics[]); +int NI_VoxelMeasures(int, int, int, int, double *, unsigned short *, objStruct objectMetrics[]); +int NI_BuildBoundary(int, int, int, int, unsigned short *, objStruct objectMetrics[]); +int NI_GetObjectStats(int, int, int, unsigned short *, objStruct objectMetrics[]); +int NI_ThinFilter(int, int, int, int, unsigned short *, objStruct objectMetrics[]); +int NI_SobelEdges(int, int, int, double, int, int, int, double, int, double *, unsigned short *, int *); +int NI_ShenCastanEdges(int, int, int, double, double, int, int, int, double *, unsigned short *, int *); +int NI_CannyEdges(int, int, int, double, double, double, int, int, int, double, int, + double *, unsigned short *, int *); + +void computeLaws(LawsFilter7, tTEM LawsFeatures[], RECT, int, int, int, int, unsigned char *, float *, + unsigned short *, float *, double *); +float lawsConvolution(float *, float *, float *, int); +void initLaws(LawsFilter7*); +void getVoxelMeasures(objStruct objectMetrics[], double *, unsigned short *, int, int, int); +void getLawsTexture(LawsFilter7, tTEM LawsFeatures[], objStruct objectMetrics[], double *, unsigned short *, int, int, int); + +void morphoFilterBinaryImage(int, int, unsigned short *, int, int); +void buildBinaryImage(int, int, double *, unsigned short *, int, int); +void doRegionGrow(int, int, int, double *, unsigned short *, int, int, int, int); +void buildBoundary(objStruct objectMetrics[], int, unsigned short *, int, int, int); +void getBoundary(unsigned short *, unsigned char *, blobBoundary *, blobBoundary *, + boundaryIndex *, RECT, int, int, int, int, int, int); +void doMorphology(unsigned char *, unsigned char *, unsigned char *, unsigned char *, int olapValuesC[], + int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], + RECT, int, int, int, int); +void getCompactness(unsigned char *, RECT, int, int, float *, float); +void OpenCloseFilter(int olapValues[], int, int, int, int, unsigned char *, + unsigned char *, unsigned short mask[11][11]); +void trackBoundary(unsigned char *, blobBoundary lBoundary[], int, int, blobBoundary, int); +void getBoundaryMetrics(bPOINT *, float *, float *, float *, float *, float, float, int); +void generateMask(unsigned char *, bPOINT *, int, int, int); +void ThinningFilter(int, int, int, int J_mask[3][30], int K_mask[3][30], unsigned char *, + unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *); +void initThinFilter(int J_mask[3][30], int K_mask[3][30]); +void Shen_Castan(double, double, int, int, int, int, int, double *, unsigned short *); +void computeISEF(float *, float *, int, int, double); +void ISEF_Horizontal(float *, float *, float *, float *, int, int, double); +void ISEF_Vertical(float *, float *, float *, float *, int, int, double); +void thresholdImage(float *, float *, int, int, int, int); +void computeBandedLaplacian(float *, float *, float *, int, int); +void getZeroCrossings(float *, float *, float *, int, int, int); +float adaptiveGradient(float *, float *, int, int, int, int); +void thresholdEdges(float *, unsigned short *, double, int, int); +void estimateThreshold(float *, float *, float, int, int, float *); +void doSobel(int, int, int, double, int, double *, unsigned short *); +void DGFilters(int, int, int, double, int, float *, float *, double *, double *, float *, float *); +void nonMaxSupress(int, int, float, float, double *, double *, int, float *, float *, float *); +void edgeHysteresis(int, int, double, double, float *, float *); +void edgeThreshold(int, int, double, float *, float *); +int traceEdge(int, int, int, int, double, float *, float *); +float magnitude(float, float); +int ConnectedEdgePoints(int, int, unsigned short *); +void doPreProcess(int, int, int, double *, double, int, int, int); +void filter2D(int, int, int, int, int, float *, double *); +void buildKernel(double, int, int, float *); + + + +#endif Added: trunk/scipy/ndimage/segment/setup.py =================================================================== --- trunk/scipy/ndimage/segment/setup.py 2007-11-05 23:13:01 UTC (rev 3498) +++ trunk/scipy/ndimage/segment/setup.py 2007-11-07 17:53:37 UTC (rev 3499) @@ -0,0 +1,21 @@ + +#!/usr/bin/env python + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('segment', parent_package, top_path) + + config.add_extension('_segmenter', + sources=['Segmenter_EXT.c', + 'Segmenter_IMPL.c'], + depends = ['ndImage_Segmenter_structs.h'] + ) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) + + Added: trunk/scipy/ndimage/tests/slice112.raw =================================================================== (Binary files differ) Property changes on: trunk/scipy/ndimage/tests/slice112.raw ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/scipy/ndimage/tests/test_segmenter.py =================================================================== --- trunk/scipy/ndimage/tests/test_segmenter.py 2007-11-05 23:13:01 UTC (rev 3498) +++ trunk/scipy/ndimage/tests/test_segmenter.py 2007-11-07 17:53:37 UTC (rev 3499) @@ -0,0 +1,161 @@ + +import numpy as N +import scipy.ndimage.segment as S + +def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): + datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), + ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), + ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), + ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), + ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=datatype) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): + datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), + ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), + ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), + ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), + ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=datatype) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, + BPHigh=10.0, apearture=21, dust=16): + datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), + ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), + ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), + ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), + ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=datatype) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def get_shape_mask(labeledEdges, ROIList): + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return + +def get_voxel_measures(rawImage, labeledEdges, ROIList): + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return + +def get_texture_measures(rawImage, labeledEdges, ROIList): + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return + +def segment_regions(): + # get slice from the CT volume + image = get_slice('slice112.raw') + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList + +def grow_regions(): + # get slice from the CT volume + image = get_slice('slice112.raw') + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions + + +def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + + +def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) + +def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice + +def save_slice(mySlice, filename='junk.raw', bytes=4): + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) + + +# test 1 +def test1(): + import Segmenter as S + image = S.get_slice('slice112.raw') + sourceImage = image.copy() + edges, objects = S.sobel(image) + S.get_shape_mask(edges, objects) + S.get_voxel_measures(sourceImage, edges, objects) + S.get_texture_measures(sourceImage, edges, objects) + +# test 2 +def test2(): + import volumeInput as V + import Segmenter as S + sourceImage, labeledMask, ROIList = S.segment_regions() + + +# test 3 +def test3(): + import Segmenter as S + regionMask, numberRegions = S.grow_regions() + regionMask.max() + S.save_slice(regionMask, 'regionMask.raw') + + + +class TestSegmenter(NumpyTestCase): + def test_1(self): + + + From scipy-svn at scipy.org Wed Nov 7 13:31:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 12:31:19 -0600 (CST) Subject: [Scipy-svn] r3500 - in trunk/scipy/ndimage: . segment tests Message-ID: <20071107183119.2815039C047@new.scipy.org> Author: oliphant Date: 2007-11-07 12:31:18 -0600 (Wed, 07 Nov 2007) New Revision: 3500 Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c trunk/scipy/ndimage/segment/Segmenter_IMPL.c trunk/scipy/ndimage/segment/__init__.py trunk/scipy/ndimage/setup.py trunk/scipy/ndimage/tests/test_segmenter.py Log: Fix up segment code. Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-07 17:53:37 UTC (rev 3499) +++ trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-07 18:31:18 UTC (rev 3500) @@ -386,7 +386,6 @@ int type; int itype; int groups; - int mode; npy_intp *dims; double *fP1; unsigned short *fP2; @@ -437,7 +436,7 @@ { NULL, NULL }, }; -void init_segmenter() +void init_segmenter(void) { Py_InitModule("_segmenter", NDI_SegmenterMethods); import_array(); Modified: trunk/scipy/ndimage/segment/Segmenter_IMPL.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-07 17:53:37 UTC (rev 3499) +++ trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-07 18:31:18 UTC (rev 3500) @@ -1315,8 +1315,8 @@ unsigned short omask[11][11]; int olapValuesC[4]; int olapValuesO[4]; - int CloseMaskSize; - int OpenMaskSize; + int CloseMaskSize=1; + int OpenMaskSize=1; int LowValue1, HighValue1; int LowValue2, HighValue2; int spadSize; @@ -2735,7 +2735,7 @@ float *colFilter; float filterResult1; float filterResult2; - float lawsLL; + float lawsLL=1.0; float t; float maxValue; float scale; Modified: trunk/scipy/ndimage/segment/__init__.py =================================================================== --- trunk/scipy/ndimage/segment/__init__.py 2007-11-07 17:53:37 UTC (rev 3499) +++ trunk/scipy/ndimage/segment/__init__.py 2007-11-07 18:31:18 UTC (rev 3500) @@ -1,3 +1,5 @@ +# Segmentation package +# Author: Tom Waite, 2007 -ver = '0.0.1' - +from _segmenter import * +from objectdata import * Modified: trunk/scipy/ndimage/setup.py =================================================================== --- trunk/scipy/ndimage/setup.py 2007-11-07 17:53:37 UTC (rev 3499) +++ trunk/scipy/ndimage/setup.py 2007-11-07 18:31:18 UTC (rev 3500) @@ -14,6 +14,7 @@ include_dirs=['src']+[get_include()], ) + config.add_subpackage('segment') config.add_data_dir('tests') return config Modified: trunk/scipy/ndimage/tests/test_segmenter.py =================================================================== --- trunk/scipy/ndimage/tests/test_segmenter.py 2007-11-07 17:53:37 UTC (rev 3499) +++ trunk/scipy/ndimage/tests/test_segmenter.py 2007-11-07 18:31:18 UTC (rev 3500) @@ -1,30 +1,27 @@ import numpy as N +from numpy.testing import * import scipy.ndimage.segment as S +inputname = 'slice112.raw' + +import os +filename = os.path.join(os.path.split(__file__)[0],inputname) + + def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), - ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), - ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), - ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), - ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=datatype) + ROIList = N.zeros(numberObjects, dtype=S.objstruct) # return the bounding box for each connected edge S.get_object_stats(labeledEdges, ROIList) return labeledEdges, ROIList[ROIList['Area']>dust] def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), - ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), - ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), - ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), - ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] # get sobel edge points. return edges that are labeled (1..numberObjects) labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=datatype) + ROIList = N.zeros(numberObjects, dtype=S.objstruct) # return the bounding box for each connected edge S.get_object_stats(labeledEdges, ROIList) # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' @@ -33,16 +30,11 @@ def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - datatype = [('L', 'i', 1), ('R', 'i', 1), ('T', 'i', 1), ('B', 'i', 1), - ('Label', 'i', 1), ('Area', 'i', 1), ('cX', 'f', 1), ('cY', 'f', 1), - ('curveClose', 'i', 1), ('cXB', 'f', 1), ('cYB', 'f', 1), ('bLength', 'f', 1), - ('minRadius', 'f', 1), ('maxRadius', 'f', 1), ('aveRadius', 'f', 1), ('ratio', 'f', 1), - ('compactness', 'f', 1), ('voxelMean', 'f', 1), ('voxelVar', 'f', 1), ('TEM', 'f', 20)] # get canny edge points. return edges that are labeled (1..numberObjects) labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=datatype) + ROIList = N.zeros(numberObjects, dtype=S.objstruct) # return the bounding box for each connected edge S.get_object_stats(labeledEdges, ROIList) return labeledEdges, ROIList[ROIList['Area']>dust] @@ -73,7 +65,7 @@ def segment_regions(): # get slice from the CT volume - image = get_slice('slice112.raw') + image = get_slice(filename) # need a copy of original image as filtering will occur on the extracted slice sourceImage = image.copy() # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) @@ -89,7 +81,7 @@ def grow_regions(): # get slice from the CT volume - image = get_slice('slice112.raw') + image = get_slice(filename) regionMask, numberRegions = region_grow(image) return regionMask, numberRegions @@ -128,34 +120,23 @@ slice.tofile(filename) -# test 1 -def test1(): - import Segmenter as S - image = S.get_slice('slice112.raw') - sourceImage = image.copy() - edges, objects = S.sobel(image) - S.get_shape_mask(edges, objects) - S.get_voxel_measures(sourceImage, edges, objects) - S.get_texture_measures(sourceImage, edges, objects) - -# test 2 -def test2(): - import volumeInput as V - import Segmenter as S - sourceImage, labeledMask, ROIList = S.segment_regions() - - -# test 3 -def test3(): - import Segmenter as S - regionMask, numberRegions = S.grow_regions() - regionMask.max() - S.save_slice(regionMask, 'regionMask.raw') - - - class TestSegmenter(NumpyTestCase): def test_1(self): + image = get_slice(filename) + sourceImage = image.copy() + edges, objects = sobel(image) + get_shape_mask(edges, objects) + get_voxel_measures(sourceImage, edges, objects) + get_texture_measures(sourceImage, edges, objects) + def test_2(self): + sourceImage, labeledMask, ROIList = segment_regions() + def test_3(self): + regionMask, numberRegions = grow_regions() + regionMask.max() + #save_slice(regionMask, 'regionMask.raw') + +if __name__ == "__main__": + NumpyTest().run() From scipy-svn at scipy.org Wed Nov 7 13:31:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 12:31:53 -0600 (CST) Subject: [Scipy-svn] r3501 - trunk/scipy/ndimage/tests Message-ID: <20071107183153.934EA39C047@new.scipy.org> Author: oliphant Date: 2007-11-07 12:31:53 -0600 (Wed, 07 Nov 2007) New Revision: 3501 Added: trunk/scipy/ndimage/tests/test_segment.py Removed: trunk/scipy/ndimage/tests/test_segmenter.py Log: Rename test for ndimage.segment Copied: trunk/scipy/ndimage/tests/test_segment.py (from rev 3500, trunk/scipy/ndimage/tests/test_segmenter.py) Deleted: trunk/scipy/ndimage/tests/test_segmenter.py =================================================================== --- trunk/scipy/ndimage/tests/test_segmenter.py 2007-11-07 18:31:18 UTC (rev 3500) +++ trunk/scipy/ndimage/tests/test_segmenter.py 2007-11-07 18:31:53 UTC (rev 3501) @@ -1,142 +0,0 @@ - -import numpy as N -from numpy.testing import * -import scipy.ndimage.segment as S - -inputname = 'slice112.raw' - -import os -filename = os.path.join(os.path.split(__file__)[0],inputname) - - -def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] - -def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] - -def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, - BPHigh=10.0, apearture=21, dust=16): - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] - -def get_shape_mask(labeledEdges, ROIList): - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return - -def get_voxel_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return - -def get_texture_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return - -def segment_regions(): - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList - -def grow_regions(): - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions - - -def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - - -def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) - -def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - slice[505:512,:] = 0 - return slice - -def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) - - -class TestSegmenter(NumpyTestCase): - def test_1(self): - image = get_slice(filename) - sourceImage = image.copy() - edges, objects = sobel(image) - get_shape_mask(edges, objects) - get_voxel_measures(sourceImage, edges, objects) - get_texture_measures(sourceImage, edges, objects) - - def test_2(self): - sourceImage, labeledMask, ROIList = segment_regions() - - def test_3(self): - regionMask, numberRegions = grow_regions() - regionMask.max() - #save_slice(regionMask, 'regionMask.raw') - - -if __name__ == "__main__": - NumpyTest().run() From scipy-svn at scipy.org Wed Nov 7 13:38:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 12:38:16 -0600 (CST) Subject: [Scipy-svn] r3502 - trunk/scipy/ndimage/segment Message-ID: <20071107183816.CE13F39C295@new.scipy.org> Author: oliphant Date: 2007-11-07 12:38:16 -0600 (Wed, 07 Nov 2007) New Revision: 3502 Added: trunk/scipy/ndimage/segment/tests/ Log: Add testing directory for ndimage.segment From scipy-svn at scipy.org Wed Nov 7 13:38:46 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 12:38:46 -0600 (CST) Subject: [Scipy-svn] r3503 - trunk/scipy/ndimage/tests Message-ID: <20071107183846.28EA139C295@new.scipy.org> Author: oliphant Date: 2007-11-07 12:38:45 -0600 (Wed, 07 Nov 2007) New Revision: 3503 Modified: trunk/scipy/ndimage/tests/test_segment.py Log: Fix up tests before moving them. Modified: trunk/scipy/ndimage/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/tests/test_segment.py 2007-11-07 18:38:16 UTC (rev 3502) +++ trunk/scipy/ndimage/tests/test_segment.py 2007-11-07 18:38:45 UTC (rev 3503) @@ -120,8 +120,8 @@ slice.tofile(filename) -class TestSegmenter(NumpyTestCase): - def test_1(self): +class TestSegment(NumpyTestCase): + def test1(self): image = get_slice(filename) sourceImage = image.copy() edges, objects = sobel(image) @@ -129,10 +129,10 @@ get_voxel_measures(sourceImage, edges, objects) get_texture_measures(sourceImage, edges, objects) - def test_2(self): + def test2(self): sourceImage, labeledMask, ROIList = segment_regions() - def test_3(self): + def test3(self): regionMask, numberRegions = grow_regions() regionMask.max() #save_slice(regionMask, 'regionMask.raw') From scipy-svn at scipy.org Wed Nov 7 13:39:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 12:39:08 -0600 (CST) Subject: [Scipy-svn] r3504 - in trunk/scipy/ndimage: segment/tests tests Message-ID: <20071107183908.D769039C295@new.scipy.org> Author: oliphant Date: 2007-11-07 12:39:08 -0600 (Wed, 07 Nov 2007) New Revision: 3504 Added: trunk/scipy/ndimage/segment/tests/slice112.raw trunk/scipy/ndimage/segment/tests/test_segment.py Removed: trunk/scipy/ndimage/tests/slice112.raw trunk/scipy/ndimage/tests/test_segment.py Log: Move segment tests to its own sub-package. Copied: trunk/scipy/ndimage/segment/tests/slice112.raw (from rev 3500, trunk/scipy/ndimage/tests/slice112.raw) Copied: trunk/scipy/ndimage/segment/tests/test_segment.py (from rev 3503, trunk/scipy/ndimage/tests/test_segment.py) Deleted: trunk/scipy/ndimage/tests/slice112.raw =================================================================== (Binary files differ) Deleted: trunk/scipy/ndimage/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/tests/test_segment.py 2007-11-07 18:38:45 UTC (rev 3503) +++ trunk/scipy/ndimage/tests/test_segment.py 2007-11-07 18:39:08 UTC (rev 3504) @@ -1,142 +0,0 @@ - -import numpy as N -from numpy.testing import * -import scipy.ndimage.segment as S - -inputname = 'slice112.raw' - -import os -filename = os.path.join(os.path.split(__file__)[0],inputname) - - -def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] - -def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] - -def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, - BPHigh=10.0, apearture=21, dust=16): - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] - -def get_shape_mask(labeledEdges, ROIList): - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return - -def get_voxel_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return - -def get_texture_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return - -def segment_regions(): - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList - -def grow_regions(): - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions - - -def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - - -def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) - -def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - slice[505:512,:] = 0 - return slice - -def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) - - -class TestSegment(NumpyTestCase): - def test1(self): - image = get_slice(filename) - sourceImage = image.copy() - edges, objects = sobel(image) - get_shape_mask(edges, objects) - get_voxel_measures(sourceImage, edges, objects) - get_texture_measures(sourceImage, edges, objects) - - def test2(self): - sourceImage, labeledMask, ROIList = segment_regions() - - def test3(self): - regionMask, numberRegions = grow_regions() - regionMask.max() - #save_slice(regionMask, 'regionMask.raw') - - -if __name__ == "__main__": - NumpyTest().run() From scipy-svn at scipy.org Wed Nov 7 13:45:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 12:45:41 -0600 (CST) Subject: [Scipy-svn] r3505 - trunk/scipy/ndimage/segment Message-ID: <20071107184541.9060339C2A0@new.scipy.org> Author: oliphant Date: 2007-11-07 12:45:41 -0600 (Wed, 07 Nov 2007) New Revision: 3505 Modified: trunk/scipy/ndimage/segment/setup.py Log: Add tests as data_dir to ndimage.segment Modified: trunk/scipy/ndimage/segment/setup.py =================================================================== --- trunk/scipy/ndimage/segment/setup.py 2007-11-07 18:39:08 UTC (rev 3504) +++ trunk/scipy/ndimage/segment/setup.py 2007-11-07 18:45:41 UTC (rev 3505) @@ -12,6 +12,8 @@ depends = ['ndImage_Segmenter_structs.h'] ) + config.add_data_dir('tests') + return config if __name__ == '__main__': From scipy-svn at scipy.org Wed Nov 7 15:36:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 14:36:41 -0600 (CST) Subject: [Scipy-svn] r3506 - in trunk/scipy/ndimage: segment tests Message-ID: <20071107203641.4AC7539C047@new.scipy.org> Author: oliphant Date: 2007-11-07 14:36:40 -0600 (Wed, 07 Nov 2007) New Revision: 3506 Added: trunk/scipy/ndimage/segment/objectdata.py trunk/scipy/ndimage/tests/test_segment.py Log: Add missing files to ndimage.segment Added: trunk/scipy/ndimage/segment/objectdata.py =================================================================== --- trunk/scipy/ndimage/segment/objectdata.py 2007-11-07 18:45:41 UTC (rev 3505) +++ trunk/scipy/ndimage/segment/objectdata.py 2007-11-07 20:36:40 UTC (rev 3506) @@ -0,0 +1,25 @@ + +import numpy as N + +objstruct =N.dtype([('L', 'i'), + ('R', 'i'), + ('T', 'i'), + ('B', 'i'), + ('Label', 'i'), + ('Area', 'i'), + ('cX', 'f'), + ('cY', 'f'), + ('curveClose', 'i'), + ('cXB', 'f'), + ('cYB', 'f'), + ('bLength', 'f'), + ('minRadius', 'f'), + ('maxRadius', 'f'), + ('aveRadius', 'f'), + ('ratio', 'f'), + ('compactness', 'f'), + ('voxelMean', 'f'), + ('voxelVar', 'f'), + ('TEM', 'f', 20)] + ) + Added: trunk/scipy/ndimage/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/tests/test_segment.py 2007-11-07 18:45:41 UTC (rev 3505) +++ trunk/scipy/ndimage/tests/test_segment.py 2007-11-07 20:36:40 UTC (rev 3506) @@ -0,0 +1,142 @@ + +import numpy as N +from numpy.testing import * +import scipy.ndimage.segment as S + +inputname = 'slice112.raw' + +import os +filename = os.path.join(os.path.split(__file__)[0],inputname) + + +def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, + BPHigh=10.0, apearture=21, dust=16): + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def get_shape_mask(labeledEdges, ROIList): + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return + +def get_voxel_measures(rawImage, labeledEdges, ROIList): + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return + +def get_texture_measures(rawImage, labeledEdges, ROIList): + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return + +def segment_regions(): + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList + +def grow_regions(): + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions + + +def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + + +def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) + +def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice + +def save_slice(mySlice, filename='junk.raw', bytes=4): + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) + + +class TestSegment(NumpyTestCase): + def test1(self): + image = get_slice(filename) + sourceImage = image.copy() + edges, objects = sobel(image) + get_shape_mask(edges, objects) + get_voxel_measures(sourceImage, edges, objects) + get_texture_measures(sourceImage, edges, objects) + + def test2(self): + sourceImage, labeledMask, ROIList = segment_regions() + + def test3(self): + regionMask, numberRegions = grow_regions() + print regionMask.max() + #save_slice(regionMask, 'regionMask.raw') + + +if __name__ == "__main__": + NumpyTest().run() From scipy-svn at scipy.org Wed Nov 7 18:56:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 17:56:32 -0600 (CST) Subject: [Scipy-svn] r3507 - in trunk/scipy/ndimage: segment src Message-ID: <20071107235632.1F2D539C079@new.scipy.org> Author: oliphant Date: 2007-11-07 17:56:31 -0600 (Wed, 07 Nov 2007) New Revision: 3507 Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c trunk/scipy/ndimage/src/nd_image.c Log: Fix up some names and add NULL for future documentation expansions. Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-07 20:36:40 UTC (rev 3506) +++ trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-07 23:56:31 UTC (rev 3507) @@ -2,7 +2,7 @@ #include "Python.h" #include "numpy/arrayobject.h" -static PyObject *NDI_Segmenter_CannyEdges(PyObject *self, PyObject *args) +static PyObject *Segmenter_CannyEdges(PyObject *self, PyObject *args) { double sigma; @@ -26,7 +26,7 @@ // // pass in 2D LPF coefficients - if(!PyArg_Parse(args, "(dddiiidiO)", &sigma, &cannyLow, &cannyHigh, &mode, &lowThreshold, &highThreshold, + if(!PyArg_ParseTuple(args, "dddiiidiO", &sigma, &cannyLow, &cannyHigh, &mode, &lowThreshold, &highThreshold, &BPHigh, &apearture, &iArray)) goto exit; @@ -53,7 +53,7 @@ } -static PyObject *NDI_Segmenter_SobelEdges(PyObject *self, PyObject *args) +static PyObject *Segmenter_SobelEdges(PyObject *self, PyObject *args) { double sobelLow; @@ -75,7 +75,7 @@ // // pass in 2D LPF coefficients - if(!PyArg_Parse(args, "(diiidiO)", &sobelLow, &mode, &lowThreshold, &highThreshold, &BPHigh, &apearture, &iArray)) + if(!PyArg_ParseTuple(args, "diiidiO", &sobelLow, &mode, &lowThreshold, &highThreshold, &BPHigh, &apearture, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -105,7 +105,7 @@ -static PyObject *NDI_Segmenter_ShenCastanEdges(PyObject *self, PyObject *args) +static PyObject *Segmenter_ShenCastanEdges(PyObject *self, PyObject *args) { int window; int lowThreshold; @@ -123,7 +123,7 @@ PyObject *iArray = NULL; PyObject *eArray = NULL; - if(!PyArg_Parse(args, "(ddiiiO)", &ShenCastanLow, &b, &window, &lowThreshold, &highThreshold, &iArray)) + if(!PyArg_ParseTuple(args, "ddiiiO", &ShenCastanLow, &b, &window, &lowThreshold, &highThreshold, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -150,7 +150,7 @@ } -static PyObject *NDI_Segmenter_GetObjectStats(PyObject *self, PyObject *args) +static PyObject *Segmenter_GetObjectStats(PyObject *self, PyObject *args) { @@ -164,7 +164,7 @@ PyObject *nArray = NULL; objStruct *myData; - if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + if(!PyArg_ParseTuple(args, "OO", &iArray, &nArray)) goto exit; if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(nArray)) @@ -196,7 +196,7 @@ } -static PyObject *NDI_Segmenter_MorphoThinFilt(PyObject *self, PyObject *args) +static PyObject *Segmenter_MorphoThinFilt(PyObject *self, PyObject *args) { int num; @@ -209,7 +209,7 @@ PyObject *nArray = NULL; objStruct *ROIList; - if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + if(!PyArg_ParseTuple(args, "OO", &iArray, &nArray)) goto exit; fP1 = (unsigned short *)PyArray_DATA(iArray); @@ -233,7 +233,7 @@ } -static PyObject *NDI_Segmenter_BuildBoundary(PyObject *self, PyObject *args) +static PyObject *Segmenter_BuildBoundary(PyObject *self, PyObject *args) { int num; @@ -246,7 +246,7 @@ PyObject *nArray = NULL; objStruct *ROIList; - if(!PyArg_Parse(args, "(OO)", &iArray, &nArray)) + if(!PyArg_ParseTuple(args, "OO", &iArray, &nArray)) goto exit; fP1 = (unsigned short *)PyArray_DATA(iArray); @@ -278,7 +278,7 @@ } -static PyObject *NDI_Segmenter_VoxelMeasures(PyObject *self, PyObject *args) +static PyObject *Segmenter_VoxelMeasures(PyObject *self, PyObject *args) { int num; @@ -293,7 +293,7 @@ PyObject *eArray = NULL; objStruct *ROIList; - if(!PyArg_Parse(args, "(OOO)", &iArray, &eArray, &nArray)) + if(!PyArg_ParseTuple(args, "OOO", &iArray, &eArray, &nArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -326,7 +326,7 @@ } -static PyObject *NDI_Segmenter_TextureMeasures(PyObject *self, PyObject *args) +static PyObject *Segmenter_TextureMeasures(PyObject *self, PyObject *args) { int num; @@ -341,7 +341,7 @@ PyObject *eArray = NULL; objStruct *ROIList; - if(!PyArg_Parse(args, "(OOO)", &iArray, &eArray, &nArray)) + if(!PyArg_ParseTuple(args, "OOO", &iArray, &eArray, &nArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -374,7 +374,7 @@ } -static PyObject *NDI_Segmenter_RegionGrow(PyObject *self, PyObject *args) +static PyObject *Segmenter_RegionGrow(PyObject *self, PyObject *args) { int lowThreshold; @@ -394,7 +394,7 @@ // // pass in 2D LPF coefficients - if(!PyArg_Parse(args, "(iiiiO)", &lowThreshold, &highThreshold, &closeWindow, &openWindow, &iArray)) + if(!PyArg_ParseTuple(args, "iiiiO", &lowThreshold, &highThreshold, &closeWindow, &openWindow, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -422,45 +422,23 @@ } -static PyMethodDef NDI_SegmenterMethods[] = +static PyMethodDef SegmenterMethods[] = { - { "canny_edges", NDI_Segmenter_CannyEdges, METH_VARARGS }, - { "shen_castan_edges", NDI_Segmenter_ShenCastanEdges, METH_VARARGS }, - { "sobel_edges", NDI_Segmenter_SobelEdges, METH_VARARGS }, - { "get_object_stats", NDI_Segmenter_GetObjectStats, METH_VARARGS }, - { "morpho_thin_filt", NDI_Segmenter_MorphoThinFilt, METH_VARARGS }, - { "build_boundary", NDI_Segmenter_BuildBoundary, METH_VARARGS }, - { "voxel_measures", NDI_Segmenter_VoxelMeasures, METH_VARARGS }, - { "texture_measures", NDI_Segmenter_TextureMeasures, METH_VARARGS }, - { "region_grow", NDI_Segmenter_RegionGrow, METH_VARARGS }, - { NULL, NULL }, + { "canny_edges", Segmenter_CannyEdges, METH_VARARGS, NULL }, + { "shen_castan_edges", Segmenter_ShenCastanEdges, METH_VARARGS, NULL }, + { "sobel_edges", Segmenter_SobelEdges, METH_VARARGS, NULL }, + { "get_object_stats", Segmenter_GetObjectStats, METH_VARARGS, NULL }, + { "morpho_thin_filt", Segmenter_MorphoThinFilt, METH_VARARGS, NULL }, + { "build_boundary", Segmenter_BuildBoundary, METH_VARARGS, NULL }, + { "voxel_measures", Segmenter_VoxelMeasures, METH_VARARGS, NULL }, + { "texture_measures", Segmenter_TextureMeasures, METH_VARARGS, NULL }, + { "region_grow", Segmenter_RegionGrow, METH_VARARGS, NULL }, + { NULL, NULL, 0, NULL}, }; void init_segmenter(void) { - Py_InitModule("_segmenter", NDI_SegmenterMethods); + Py_InitModule("_segmenter", SegmenterMethods); import_array(); } -/* -static PyMethodDef NDI_SegmenterMethods[] = -{ - { "CannyEdges", NDI_Segmenter_CannyEdges, METH_VARARGS }, - { "ShenCastanEdges", NDI_Segmenter_ShenCastanEdges, METH_VARARGS }, - { "SobelEdges", NDI_Segmenter_SobelEdges, METH_VARARGS }, - { "GetObjectStats", NDI_Segmenter_GetObjectStats, METH_VARARGS }, - { "MorphoThinFilt", NDI_Segmenter_MorphoThinFilt, METH_VARARGS }, - { "BuildBoundary", NDI_Segmenter_BuildBoundary, METH_VARARGS }, - { "VoxelMeasures", NDI_Segmenter_VoxelMeasures, METH_VARARGS }, - { "TextureMeasures", NDI_Segmenter_TextureMeasures, METH_VARARGS }, - { "RegionGrow", NDI_Segmenter_RegionGrow, METH_VARARGS }, - { NULL, NULL }, -}; - -void initNDI_Segmenter() -{ - Py_InitModule("NDI_Segmenter", NDI_SegmenterMethods); - import_array(); -} -*/ - Modified: trunk/scipy/ndimage/src/nd_image.c =================================================================== --- trunk/scipy/ndimage/src/nd_image.c 2007-11-07 20:36:40 UTC (rev 3506) +++ trunk/scipy/ndimage/src/nd_image.c 2007-11-07 23:56:31 UTC (rev 3507) @@ -1262,53 +1262,54 @@ static PyMethodDef methods[] = { {"correlate1d", (PyCFunction)Py_Correlate1D, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"correlate", (PyCFunction)Py_Correlate, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"uniform_filter1d", (PyCFunction)Py_UniformFilter1D, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"min_or_max_filter1d", (PyCFunction)Py_MinOrMaxFilter1D, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"min_or_max_filter", (PyCFunction)Py_MinOrMaxFilter, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"rank_filter", (PyCFunction)Py_RankFilter, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"generic_filter", (PyCFunction)Py_GenericFilter, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"generic_filter1d", (PyCFunction)Py_GenericFilter1D, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"fourier_filter", (PyCFunction)Py_FourierFilter, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"fourier_shift", (PyCFunction)Py_FourierShift, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"spline_filter1d", (PyCFunction)Py_SplineFilter1D, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"geometric_transform", (PyCFunction)Py_GeometricTransform, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"zoom_shift", (PyCFunction)Py_ZoomShift, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"label", (PyCFunction)Py_Label, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"find_objects", (PyCFunction)Py_FindObjects, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"watershed_ift", (PyCFunction)Py_WatershedIFT, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"statistics", (PyCFunction)Py_Statistics, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"center_of_mass", (PyCFunction)Py_CenterOfMass, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"histogram", (PyCFunction)Py_Histogram, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"euclidean_feature_transform", - (PyCFunction)Py_EuclideanFeatureTransform, METH_VARARGS, ""}, + (PyCFunction)Py_EuclideanFeatureTransform, + METH_VARARGS, NULL}, {"binary_erosion", (PyCFunction)Py_BinaryErosion, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {"binary_erosion2", (PyCFunction)Py_BinaryErosion2, - METH_VARARGS, ""}, + METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; From scipy-svn at scipy.org Wed Nov 7 19:03:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 18:03:15 -0600 (CST) Subject: [Scipy-svn] r3508 - trunk/scipy/ndimage/segment Message-ID: <20071108000315.B72C339C16A@new.scipy.org> Author: oliphant Date: 2007-11-07 18:03:15 -0600 (Wed, 07 Nov 2007) New Revision: 3508 Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c Log: Fix some formating in ndimage.segment Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-07 23:56:31 UTC (rev 3507) +++ trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-08 00:03:15 UTC (rev 3508) @@ -24,10 +24,10 @@ PyObject *iArray = NULL; PyObject *eArray = NULL; - // - // pass in 2D LPF coefficients - if(!PyArg_ParseTuple(args, "dddiiidiO", &sigma, &cannyLow, &cannyHigh, &mode, &lowThreshold, &highThreshold, - &BPHigh, &apearture, &iArray)) + /* pass in 2D LPF coefficients */ + if(!PyArg_ParseTuple(args, "dddiiidiO", &sigma, &cannyLow, &cannyHigh, + &mode, &lowThreshold, &highThreshold, + &BPHigh, &apearture, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -43,13 +43,15 @@ if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) goto exit; - if(!NI_CannyEdges(num, (int)dims[0], (int)dims[1], sigma, cannyLow, cannyHigh, mode, lowThreshold, + if(!NI_CannyEdges(num, (int)dims[0], (int)dims[1], sigma, cannyLow, + cannyHigh, mode, lowThreshold, highThreshold, BPHigh, apearture, fP1, fP2, &groups)) goto exit; exit: - return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups); + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, + groups); } @@ -75,7 +77,8 @@ // // pass in 2D LPF coefficients - if(!PyArg_ParseTuple(args, "diiidiO", &sobelLow, &mode, &lowThreshold, &highThreshold, &BPHigh, &apearture, &iArray)) + if(!PyArg_ParseTuple(args, "diiidiO", &sobelLow, &mode, &lowThreshold, + &highThreshold, &BPHigh, &apearture, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -93,13 +96,15 @@ goto exit; - if(!NI_SobelEdges(num, (int)dims[0], (int)dims[1], sobelLow, mode, lowThreshold, highThreshold, BPHigh, apearture, + if(!NI_SobelEdges(num, (int)dims[0], (int)dims[1], sobelLow, mode, + lowThreshold, highThreshold, BPHigh, apearture, fP1, fP2, &groups)) goto exit; exit: - return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, + groups-1); } @@ -123,7 +128,8 @@ PyObject *iArray = NULL; PyObject *eArray = NULL; - if(!PyArg_ParseTuple(args, "ddiiiO", &ShenCastanLow, &b, &window, &lowThreshold, &highThreshold, &iArray)) + if(!PyArg_ParseTuple(args, "ddiiiO", &ShenCastanLow, &b, &window, + &lowThreshold, &highThreshold, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -140,13 +146,15 @@ if(!PyArray_ISCONTIGUOUS(iArray) || !PyArray_ISCONTIGUOUS(eArray)) goto exit; - if(!NI_ShenCastanEdges(num, (int)dims[0], (int)dims[1], b, ShenCastanLow, window, lowThreshold, highThreshold, + if(!NI_ShenCastanEdges(num, (int)dims[0], (int)dims[1], b, ShenCastanLow, + window, lowThreshold, highThreshold, fP1, fP2, &groups)) goto exit; exit: - return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, groups-1); + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue("Oi", eArray, + groups-1); } From scipy-svn at scipy.org Wed Nov 7 22:39:59 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 21:39:59 -0600 (CST) Subject: [Scipy-svn] r3509 - trunk/scipy/sandbox/timeseries/tests Message-ID: <20071108033959.E40B939C059@new.scipy.org> Author: mattknox_ca Date: 2007-11-07 21:39:56 -0600 (Wed, 07 Nov 2007) New Revision: 3509 Modified: trunk/scipy/sandbox/timeseries/tests/test_timeseries.py Log: removed reference to invalid 'keep_gap' keyword parameter in concatenate call Modified: trunk/scipy/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/scipy/sandbox/timeseries/tests/test_timeseries.py 2007-11-08 00:03:15 UTC (rev 3508) +++ trunk/scipy/sandbox/timeseries/tests/test_timeseries.py 2007-11-08 03:39:56 UTC (rev 3509) @@ -617,7 +617,7 @@ # ser_1 = time_series(data, _dates) ser_2 = time_series(data, dates=_dates+10) - newseries = concatenate((ser_1, ser_2), keep_gap=False) + newseries = concatenate((ser_1, ser_2)) assert_equal(newseries._data,[0,1,2,3,4,0,1,2,3,4]) assert_equal(newseries._mask,[1,0,0,0,0]+[1,0,0,0,0]) assert newseries.has_missing_dates() From scipy-svn at scipy.org Wed Nov 7 22:42:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Nov 2007 21:42:42 -0600 (CST) Subject: [Scipy-svn] r3510 - trunk/scipy/sandbox/timeseries Message-ID: <20071108034242.0E2F639C059@new.scipy.org> Author: mattknox_ca Date: 2007-11-07 21:42:40 -0600 (Wed, 07 Nov 2007) New Revision: 3510 Modified: trunk/scipy/sandbox/timeseries/tseries.py Log: added check for '._series' attribute in __call__ method of _tsmathmethod class to make TimeSeries objects work better with functions that aren't coded with TimeSeries in mind. In particular, this fixes a problem with calling numpy.median on a TimeSeries with an even number of elements. Modified: trunk/scipy/sandbox/timeseries/tseries.py =================================================================== --- trunk/scipy/sandbox/timeseries/tseries.py 2007-11-08 03:39:56 UTC (rev 3509) +++ trunk/scipy/sandbox/timeseries/tseries.py 2007-11-08 03:42:40 UTC (rev 3510) @@ -268,7 +268,11 @@ result = func(other, *args).view(type(instance)) result._dates = instance._dates else: - result = func(other, *args)._series + _result = func(other, *args) + if hasattr(_result, '_series'): + result = _result._series + else: + result = _result return result class _tsarraymethod(object): From scipy-svn at scipy.org Fri Nov 9 15:53:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 9 Nov 2007 14:53:58 -0600 (CST) Subject: [Scipy-svn] r3511 - in trunk/scipy/ndimage/segment: . tests Message-ID: <20071109205358.497B639C0B2@new.scipy.org> Author: tom.waite Date: 2007-11-09 14:53:50 -0600 (Fri, 09 Nov 2007) New Revision: 3511 Modified: trunk/scipy/ndimage/segment/Segmenter_IMPL.c trunk/scipy/ndimage/segment/tests/test_segment.py Log: Added doc string to test_segment.py. clean up column length in Segmenter_IMPL.c Modified: trunk/scipy/ndimage/segment/Segmenter_IMPL.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-08 03:42:40 UTC (rev 3510) +++ trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-09 20:53:50 UTC (rev 3511) @@ -10,7 +10,8 @@ #define FALSE 0 #define TRUE 1 -int NI_GetObjectStats(int rows, int cols, int numberObjects, unsigned short *labeledEdges, objStruct objectMetrics[]){ +int NI_GetObjectStats(int rows, int cols, int numberObjects, unsigned short *labeledEdges, + objStruct objectMetrics[]){ int i, j, k, m; int offset; @@ -47,7 +48,7 @@ } offset += cols; } - // the bounding box for the 2D blob + /* the bounding box for the 2D blob */ objectMetrics[k-1].L = LowX; objectMetrics[k-1].R = HighX; objectMetrics[k-1].B = LowY; @@ -75,11 +76,11 @@ HC = BPHigh * rad; t2 = (float)2.0*pi; t1 = (float)2.0*HalfFilterTaps + (float)1.0; - // + /* // build the Filter Kernel // the kernel starts at 1 only because it is linked to the internal filter2D routine // the code is not a Fortran code - // + */ j = 1; for(i = -HalfFilterTaps; i <= HalfFilterTaps; ++i){ r = (float)i; @@ -96,7 +97,7 @@ kernel[j++] = t4; } - // normalize the kernel so unity gain (as is LP filter this is easy) + /* normalize the kernel so unity gain (as is LP filter this is easy) */ t1 = (float)0.0; for(j = 1; j <= apearture; ++j){ t1 += kernel[j]; @@ -112,7 +113,8 @@ return; } -void filter2D(int HalfFilterTaps, int rows, int cols, int lowThreshold, int highThreshold, float *kernel, double *Image){ +void filter2D(int HalfFilterTaps, int rows, int cols, int lowThreshold, int highThreshold, + float *kernel, double *Image){ int i, j, k, n, num1; int offset; @@ -122,11 +124,11 @@ num1 = HalfFilterTaps + 1; offset = 0; for(i = 0; i < rows; ++i){ - // copy image row to local buffer + /* copy image row to local buffer */ for(j = 0; j < cols; ++j){ buffer[num1+j] = Image[offset+j]; } - // constant pad the ends of the buffer + /* constant pad the ends of the buffer */ for(j = 0; j < num1; ++j){ buffer[j] = buffer[num1]; } @@ -134,7 +136,7 @@ buffer[j] = buffer[cols-1+num1]; } - // Perform Symmetric Convolution in the X dimension. + /* Perform Symmetric Convolution in the X dimension. */ for(n = 0, j = num1; j < (cols+num1); ++j, ++n){ sum = buffer[j] * kernel[num1]; for(k = 1; k < num1; ++k){ @@ -147,13 +149,13 @@ offset = 0; for(i = 0; i < cols; ++i){ - // copy image column to local buffer + /* copy image column to local buffer */ offset = 0; for(j = 0; j < rows; ++j){ buffer[num1+j] = Image[offset+i]; offset += cols; } - // constant pad the ends of the buffer + /* constant pad the ends of the buffer */ for(j = 0; j < num1; ++j){ buffer[j] = buffer[num1]; } @@ -161,7 +163,7 @@ buffer[j] = buffer[rows-1+num1]; } - // Perform Symmetric Convolution in the Y dimension. + /* Perform Symmetric Convolution in the Y dimension. */ offset = 0; for(j = num1; j < (rows+num1); ++j){ sum = buffer[j] * kernel[num1]; @@ -173,7 +175,7 @@ } } - // threshold the image + /* threshold the image */ offset = 0; for(i = 0; i < rows; ++i){ for(j = 0; j < cols; ++j){ @@ -189,13 +191,14 @@ } -void doPreProcess(int samples, int rows, int cols, double *rawImage, double BPHigh, int apearture, int lowThreshold, int highThreshold){ +void doPreProcess(int samples, int rows, int cols, double *rawImage, double BPHigh, + int apearture, int lowThreshold, int highThreshold){ - // + /* // 2D low pass filter using bisinc and threshold // this specific example is on cardiac CT and focuses on segmenting the // aorta and blood-filled chambers. for MRI the threshold will be different - // + */ float *kernel; int HalfFilterTaps = (apearture-1)/2; @@ -221,9 +224,9 @@ bool Change; unsigned short T[12]; - // + /* // connected components labeling. pixels touch within 3x3 mask for edge connectedness. - // + */ Label = 1; offset = 0; for(i = 0; i < rows; ++i){ @@ -237,9 +240,9 @@ while(1){ Change = FALSE; - // + /* // TOP-DOWN Pass for labeling - // + */ offset = cols; for(i = 1; i < rows-1; ++i){ for(j = 1; j < cols-1; ++j){ @@ -267,9 +270,9 @@ } offset += cols; } - // + /* // BOTTOM-UP Pass for labeling - // + */ offset = (rows-1)*cols; for(i = (rows-1); i > 1; --i){ for(j = (cols-1); j > 1; --j){ @@ -298,7 +301,7 @@ offset -= cols; } if(!Change) break; - } // end while loop + } /* end while loop */ Classes[0] = 0; Label = 1; @@ -314,7 +317,7 @@ if(NewLabel){ Classes[Label++] = m; if(Label > 4000){ - return 0; // too many labeled regions. this is a pathology in the image slice + return 0; /* too many labeled regions. this is a pathology */ } } } @@ -322,9 +325,9 @@ offset += cols; } - // + /* // re-label the connected blobs in continuous label order - // + */ offset = cols; for(i = 1; i < (rows-1); ++i){ for(j = 1; j < (cols-1); ++j){ @@ -349,7 +352,8 @@ return (float)sqrt(X*X + Y*Y); } -int traceEdge(int i, int j, int rows, int cols, double cannyLow, float *magImage, float *HYSImage){ +int traceEdge(int i, int j, int rows, int cols, double cannyLow, float *magImage, + float *HYSImage){ int n, m; int ptr; @@ -357,9 +361,9 @@ ptr = i * cols; if(HYSImage[ptr+j] == (float)0.0){ - // + /* // this point is above high threshold - // + */ HYSImage[ptr+j] = (float)1.0; flag = 0; for(n = -1; n <= 1; ++n){ @@ -368,9 +372,9 @@ if(((i+n) > 0) && ((j+m) > 0) && ((i+n) < rows) && ((j+m) < cols)){ ptr = (i+n) * cols; if(magImage[ptr+j+m] > cannyLow){ - // + /* // this point is above low threshold - // + */ if(traceEdge(i+n, j+m, rows, cols, cannyLow, magImage, HYSImage)){ flag = 1; break; @@ -388,7 +392,8 @@ } -void edgeThreshold(int rows, int cols, double cannyLow, float *magImage, float *HYSImage){ +void edgeThreshold(int rows, int cols, double cannyLow, float *magImage, + float *HYSImage){ int i, j; int ptr; @@ -406,7 +411,8 @@ } -void edgeHysteresis(int rows, int cols, double cannyLow, double cannyHigh, float *magImage, float *HYSImage){ +void edgeHysteresis(int rows, int cols, double cannyLow, double cannyHigh, + float *magImage, float *HYSImage){ int i, j; int ptr; @@ -424,8 +430,9 @@ } -void nonMaxSupress(int rows, int cols, float aveXValue, float aveYValue, double *cannyLow, double *cannyHigh, - int mode, float *hDGImage, float *vDGImage, float *magImage){ +void nonMaxSupress(int rows, int cols, float aveXValue, float aveYValue, + double *cannyLow, double *cannyHigh, int mode, + float *hDGImage, float *vDGImage, float *magImage){ int i, j; int ptr, ptr_m1, ptr_p1; @@ -452,7 +459,7 @@ if((fabs(xC) < aveXValue) && (fabs(yC) < aveYValue)) continue; G = magnitude(xC, yC); if(fabs(yC) > fabs(xC)){ - // vertical gradient + /* vertical gradient */ xSlope = (float)(fabs(xC) / fabs(yC)); ySlope = (float)1.0; G2 = magnitude(hDGImage[ptr_m1+j], vDGImage[ptr_m1+j]); @@ -467,7 +474,7 @@ } } else{ - // horizontal gradient + /* horizontal gradient */ xSlope = (float)(fabs(yC) / fabs(xC)); ySlope = (float)1.0; G2 = magnitude(hDGImage[ptr+j+1], vDGImage[ptr+j+1]); @@ -481,7 +488,7 @@ G3 = magnitude(hDGImage[ptr_p1+j-1], vDGImage[ptr_p1+j-1]); } } - if( (G > (xSlope*G1 + (ySlope-xSlope)*G2)) && (G > (xSlope*G3 + (ySlope-xSlope)*G4)) ){ + if((G > (xSlope*G1+(ySlope-xSlope)*G2))&&(G > (xSlope*G3+(ySlope-xSlope)*G4))){ magImage[ptr+j] = G; } if(magImage[ptr+j] > maxValue) maxValue = magImage[ptr+j]; @@ -517,9 +524,9 @@ ++ptr; } } - // + /* // now get the max after skipping the low values - // + */ mValue = -1; mIndex = 0; for(i = 10; i < 256; ++i){ @@ -530,12 +537,12 @@ } if(mode == 1){ - // based on the mean value of edge energy + /* based on the mean value of edge energy */ *cannyLow = ((*cannyLow) * tAve); *cannyHigh = ((*cannyHigh) * tAve); } else{ - // based on the mode value of edge energy + /* based on the mode value of edge energy */ *cannyLow = ((*cannyLow) * ((float)mIndex/step)); *cannyHigh = ((*cannyHigh) * ((float)mIndex/step)); } @@ -548,9 +555,9 @@ float *aveXValue, float *aveYValue, double *rawImage, double *dgKernel, float *hDGImage, float *vDGImage){ - // + /* // implements the derivative of Gaussian filter. kernel set by CannyEdges - // + */ int i, j, k; int ptr; int mLength; @@ -564,9 +571,9 @@ mLength = MAX(rows, cols) + 64; tBuffer = calloc(mLength, sizeof(float)); - // + /* // filter X - // + */ count = 0; for(i = 0; i < rows; ++i){ ptr = i * cols; @@ -585,11 +592,11 @@ if(count){ *aveXValue /= (float)count; *aveXValue = (float)0.5 * (*aveXValue); - // this is 50% of the max, hardwirred for now, and is part of the threshold + /* this is 50% of the max, hardwirred for now, and is part of the threshold */ } - // + /* // filter Y - // + */ count = 0; for(i = 0; i < cols; ++i){ for(j = 0; j < rows; ++j){ @@ -612,7 +619,7 @@ if(count){ *aveYValue /= (float)count; *aveYValue = (float)0.5 * (*aveYValue); - // this is 50% of the max, hardwirred for now, and is part of the threshold + /* this is 50% of the max, hardwirred for now, and is part of the threshold */ } free(tBuffer); @@ -622,8 +629,10 @@ } -int NI_CannyEdges(int samples, int rows, int cols, double cannySigma, double cannyLow, double cannyHigh, int mode, - int lowThreshold, int highThreshold, double BPHigh, int apearture, double *rawImage, +int NI_CannyEdges(int samples, int rows, int cols, double cannySigma, + double cannyLow, double cannyHigh, int mode, + int lowThreshold, int highThreshold, double BPHigh, + int apearture, double *rawImage, unsigned short *edgeImage, int *groups){ int i, j; @@ -642,14 +651,12 @@ float *magImage = NULL; float *tBuffer = NULL; - // filter - printf("do preProcess\n"); + /* filter */ doPreProcess(samples, rows, cols, rawImage, BPHigh, apearture, lowThreshold, highThreshold); - printf("do Canny\n"); - // + /* // memory for magnitude, horizontal and vertical derivative of Gaussian filter - // + */ mLength = MAX(rows, cols) + 64; HYSImage = calloc(samples, sizeof(float)); hDGImage = calloc(samples, sizeof(float)); @@ -657,10 +664,10 @@ magImage = calloc(samples, sizeof(float)); tBuffer = calloc(mLength, sizeof(float)); - // + /* // build derivative of Gaussian filter kernel // kernel is anti-symmetric so convolution is k[j]*(v[i+j] - v[i-j]) - // + */ gWidth = 20; for(i = 0; i < gWidth; ++i){ t = (float)i; @@ -671,8 +678,10 @@ HYSImage[i] = (float)0.0; } - DGFilters(samples, rows, cols, cannySigma, gWidth, &aveXValue, &aveYValue, rawImage, dgKernel, hDGImage, vDGImage); - nonMaxSupress(rows, cols, aveXValue, aveYValue, &cannyLow, &cannyHigh, mode, hDGImage, vDGImage, magImage); + DGFilters(samples, rows, cols, cannySigma, gWidth, &aveXValue, &aveYValue, + rawImage, dgKernel, hDGImage, vDGImage); + nonMaxSupress(rows, cols, aveXValue, aveYValue, &cannyLow, &cannyHigh, + mode, hDGImage, vDGImage, magImage); if(doHysteresis){ edgeHysteresis(rows, cols, cannyLow, cannyHigh, magImage, HYSImage); } @@ -680,17 +689,17 @@ edgeThreshold(rows, cols, cannyLow, magImage, HYSImage); } - // + /* // edge image - // + */ for(i = 0; i < samples; ++i){ edgeImage[i] = (unsigned short)HYSImage[i]; } *groups = ConnectedEdgePoints(rows, cols, edgeImage); - // + /* // prune the isolated pixels - // + */ offset = 0; for(i = 0; i < rows; ++i){ for(j = 0; j < cols; ++j){ @@ -713,7 +722,8 @@ } -void doSobel(int samples, int rows, int cols, double sobelLow, int mode, double *rawImage, unsigned short *edgeImage){ +void doSobel(int samples, int rows, int cols, double sobelLow, int mode, + double *rawImage, unsigned short *edgeImage){ int i, j; int p, m, n; @@ -745,9 +755,9 @@ offset += cols; } - // + /* // Sobel - // + */ offset = cols; for(i = 1; i < rows-1; ++i){ offsetM1 = offset - cols; @@ -769,7 +779,7 @@ offset += cols; } - // threshold based on ave + /* threshold based on ave */ pAve /= count; scale = 1.0 / maxValue; @@ -785,9 +795,9 @@ } offset += cols; } - // + /* // now get the max after skipping the low values - // + */ maxValue = -1; maxIndex = 0; for(i = 10; i < 256; ++i){ @@ -798,11 +808,11 @@ } if(mode == 1){ - // based on the mean value of edge energy + /* based on the mean value of edge energy */ pThreshold = (int)(sobelLow * (float)pAve); } else{ - // based on the mode value of edge energy + /* based on the mode value of edge energy */ pThreshold = (sobelLow * (minValue + ((float)maxIndex/step))); } @@ -827,7 +837,8 @@ } -void estimateThreshold(float *lowThreshold, float *highThreshold, float ShenCastanLow, int rows, int cols, float *SourceImage){ +void estimateThreshold(float *lowThreshold, float *highThreshold, float ShenCastanLow, + int rows, int cols, float *SourceImage){ int i, j; int offset; @@ -862,9 +873,9 @@ offset += cols; } - // + /* // now get the edge energy mode - // + */ value = 0; mIndex = 10; for(i = 10; i < 256; ++i){ @@ -884,16 +895,17 @@ } -void thresholdEdges(float *SourceImage, unsigned short *EdgeImage, double ShenCastanLow, int rows, int cols){ +void thresholdEdges(float *SourceImage, unsigned short *EdgeImage, double ShenCastanLow, + int rows, int cols){ int i, j; int offset; float tLow, tHigh; - // + /* // SourceImage contains the adaptive gradient // get threshold from the mode of the edge energy - // + */ estimateThreshold(&tLow, &tHigh, ShenCastanLow, rows, cols, SourceImage); offset = 0; @@ -913,7 +925,8 @@ } -float adaptiveGradient(float *BLImage, float *FilterImage, int nrow, int ncol, int cols, int window){ +float adaptiveGradient(float *BLImage, float *FilterImage, int nrow, int ncol, + int cols, int window){ int i, j; int offset; @@ -957,7 +970,8 @@ } -void getZeroCrossings(float *SourceImage, float *FilterImage, float *BLImage, int rows, int cols, int window){ +void getZeroCrossings(float *SourceImage, float *FilterImage, float *BLImage, + int rows, int cols, int window){ int i, j; int offset; @@ -996,7 +1010,7 @@ } } if(validEdge){ - // adaptive gradeint is signed + /* adaptive gradeint is signed */ SourceImage[offset+j] = (float)fabs(adaptiveGradient(BLImage, FilterImage, i, j, cols, window)); } } @@ -1014,9 +1028,9 @@ int offset; float t; - // + /* // like an unsharp mask - // + */ offset = 0; for(i = 0; i < rows; ++i){ for(j = 0; j < cols; ++j){ @@ -1060,7 +1074,8 @@ } -void ISEF_Vertical(float *SourceImage, float *FilterImage, float *A, float *B, int rows, int cols, double b){ +void ISEF_Vertical(float *SourceImage, float *FilterImage, float *A, float *B, + int rows, int cols, double b){ int i, j; @@ -1070,40 +1085,40 @@ b1 = ((float)1.0 - b)/((float)1.0 + b); b2 = b * b1; - // + /* // set the boundaries - // + */ offset = (rows-1)*cols; for(i = 0; i < cols; ++i){ - // process row 0 + /* process row 0 */ A[i] = b1 * SourceImage[i]; - // process row N-1 + /* process row N-1 */ B[offset+i] = b2 * SourceImage[offset+i]; } - // + /* // causal component of IIR filter - // + */ offset = cols; for(i = 1; i < rows; ++i){ for(j = 0; j < cols; ++j){ - // + /* // IIR ISEF filter applied across rows - // + */ A[offset+j] = (b * A[offset-cols+j]) + (b1 * SourceImage[offset+j]); } offset += cols; } - // + /* // anti-causal component of IIR filter - // + */ offset = (rows-2)*cols; for(i = rows-2; i >= 0; --i){ for(j = 0; j < cols; ++j){ - // + /* // IIR ISEF filter applied across rows - // + */ B[offset+j] = (b * B[offset+cols+j]) + (b2 * SourceImage[offset+j]); } offset -= cols; @@ -1114,9 +1129,9 @@ FilterImage[offset+j] = A[offset+j]; } - // + /* // add causal and anti-causal IIR parts - // + */ offset = 0; for(i = 1; i < rows-2; ++i){ for(j = 0; j < cols-1; ++j){ @@ -1129,12 +1144,13 @@ } -void ISEF_Horizontal(float *SourceImage, float *FilterImage, float *A, float *B, int rows, int cols, double b){ +void ISEF_Horizontal(float *SourceImage, float *FilterImage, float *A, float *B, + int rows, int cols, double b){ - // + /* // source and smooth are the same in this pass of the 2D IIR - // + */ int i, j; int offset; @@ -1143,9 +1159,9 @@ b1 = ((float)1.0 - b)/((float)1.0 + b); b2 = b * b1; - // + /* // columns boundaries - // + */ offset = 0; for(i = 0; i < rows; ++i){ // col 0 @@ -1154,9 +1170,9 @@ B[offset+cols-1] = b2 * SourceImage[offset+cols-1]; } - // + /* // causal IIR part - // + */ offset = 0; for(j = 1; j < cols; ++j){ for(i = 0; i < rows; ++i){ @@ -1165,9 +1181,9 @@ offset += cols; } - // + /* // anti-causal IIR part - // + */ offset = 0; for(j = cols-2; j > 0; --j){ for(i = 0; i < rows; ++i){ @@ -1176,17 +1192,17 @@ offset += cols; } - // + /* // filtered output. this is 2-pass IIR and pass 1 is vertical - // + */ offset = 0; for(i = 0; i < rows; ++i){ FilterImage[offset+cols-1] = A[offset+cols-1]; } - // + /* // add causal and anti-causal IIR parts - // + */ for(i = 0; i < rows; ++i){ for(j = 0; j < cols-1; ++j){ FilterImage[offset+j] = A[offset+j] + B[offset+j+1]; @@ -1218,7 +1234,8 @@ } -void Shen_Castan(double b, double ShenCastanLow, int rows, int cols, int window, int lowThreshold, int highThreshold, +void Shen_Castan(double b, double ShenCastanLow, int rows, int cols, int window, + int lowThreshold, int highThreshold, double *RawImage, unsigned short *EdgeImage){ int i; @@ -1235,10 +1252,10 @@ SourceImage[i] = RawImage[i]; } computeISEF(SourceImage, FilterImage, rows, cols, b); - // optional thresholding based on low, high + /* optional thresholding based on low, high */ thresholdImage(SourceImage, FilterImage, rows, cols, lowThreshold, highThreshold); computeBandedLaplacian(FilterImage, SourceImage, BinaryLaplacianImage, rows, cols); - // the new source image is now the adaptive gradient + /* the new source image is now the adaptive gradient */ getZeroCrossings(SourceImage, FilterImage, BinaryLaplacianImage, rows, cols, window); thresholdEdges(SourceImage, EdgeImage, ShenCastanLow, rows, cols); @@ -1250,8 +1267,9 @@ } -int NI_ShenCastanEdges(int samples, int rows, int cols, double b, double ShenCastanLow, int window, int lowThreshold, - int highThreshold, double *rawImage, unsigned short *edgeImage, int *groups){ +int NI_ShenCastanEdges(int samples, int rows, int cols, double b, double ShenCastanLow, + int window, int lowThreshold, int highThreshold, + double *rawImage, unsigned short *edgeImage, int *groups){ int i, j; @@ -1281,7 +1299,8 @@ } -void buildBinaryImage(int rows, int cols, double *rawImage, unsigned short *edgeImage, int lowThreshold, int highThreshold){ +void buildBinaryImage(int rows, int cols, double *rawImage, unsigned short *edgeImage, + int lowThreshold, int highThreshold){ int i, j; int offset; @@ -1306,7 +1325,8 @@ -void morphoFilterBinaryImage(int rows, int cols, unsigned short *edgeImage, int CloseSize, int OpenSize){ +void morphoFilterBinaryImage(int rows, int cols, unsigned short *edgeImage, + int CloseSize, int OpenSize){ int i, j; @@ -1315,8 +1335,8 @@ unsigned short omask[11][11]; int olapValuesC[4]; int olapValuesO[4]; - int CloseMaskSize=1; - int OpenMaskSize=1; + int CloseMaskSize = 1; + int OpenMaskSize = 1; int LowValue1, HighValue1; int LowValue2, HighValue2; int spadSize; @@ -1348,9 +1368,9 @@ olapValuesC[3] = HighValue2; } - // + /* // Open filter - // + */ if(OpenSize){ OpenMaskSize = (OpenSize-1)/2; for(i = 0; i < 2*OpenMaskSize+1; ++i){ @@ -1391,11 +1411,11 @@ for(i = 0; i < rows; ++i){ for(j = 0; j < cols; ++j){ if(ImageE[offset2+j] == 1){ - // this will activate some original off-pixels + /* this will activate some original off-pixels */ edgeImage[offset+j] = 1; } else{ - // this will zero some original on-pixels + /* this will zero some original on-pixels */ edgeImage[offset+j] = 0; } } @@ -1410,7 +1430,8 @@ } -void doRegionGrow(int samples, int rows, int cols, double *rawImage, unsigned short *edgeImage, int lowThreshold, +void doRegionGrow(int samples, int rows, int cols, double *rawImage, + unsigned short *edgeImage, int lowThreshold, int highThreshold, int closeWindow, int openWindow){ buildBinaryImage(rows, cols, rawImage, edgeImage, lowThreshold, highThreshold); @@ -1420,14 +1441,16 @@ } -int NI_RegionGrow(int samples, int rows, int cols, int lowThreshold, int highThreshold, int closeWindow, - int openWindow, double *rawImage, unsigned short *edgeImage, int *groups){ +int NI_RegionGrow(int samples, int rows, int cols, int lowThreshold, int highThreshold, + int closeWindow, int openWindow, double *rawImage, + unsigned short *edgeImage, int *groups){ int i, j; int offset; int status; - doRegionGrow(samples, rows, cols, rawImage, edgeImage, lowThreshold, highThreshold, closeWindow, openWindow); + doRegionGrow(samples, rows, cols, rawImage, edgeImage, lowThreshold, + highThreshold, closeWindow, openWindow); *groups = ConnectedEdgePoints(rows, cols, edgeImage); // @@ -1448,7 +1471,8 @@ } -int NI_SobelEdges(int samples, int rows, int cols, double sobelLow, int mode, int lowThreshold, int highThreshold, double BPHigh, +int NI_SobelEdges(int samples, int rows, int cols, double sobelLow, int mode, + int lowThreshold, int highThreshold, double BPHigh, int apearture, double *rawImage, unsigned short *edgeImage, int *groups){ @@ -1461,9 +1485,9 @@ *groups = ConnectedEdgePoints(rows, cols, edgeImage); - // + /* // prune the isolated pixels - // + */ offset = 0; for(i = 0; i < rows; ++i){ for(j = 0; j < cols; ++j){ @@ -1611,7 +1635,7 @@ nloop = 0; while(1){ - // erode + /* erode */ Column = 0; for(n = 0; n < 8; ++n){ for(i = 0; i < 3; ++i){ @@ -1644,7 +1668,7 @@ Offset += spadSize; } - // dialate + /* dialate */ Offset = 0; for(i = 0; i < N; ++i){ for(j = 0; j < M; ++j){ @@ -1671,7 +1695,7 @@ Offset += spadSize; } - // form the HMT + /* form the HMT */ Offset = 0; for(i = 0; i < N; ++i){ for(j = 0; j < M; ++j){ @@ -1681,7 +1705,7 @@ Offset += spadSize; } - // Thin for stage n + /* Thin for stage n */ Offset = 0; for(i = 0; i < N; ++i){ @@ -1701,7 +1725,7 @@ } } - // check for the NULL set + /* check for no change */ hit = 0; Offset = 0; for(i = 0; i < N; ++i){ @@ -1730,7 +1754,8 @@ } -int NI_ThinFilter(int samples, int rows, int cols, int numberObjects, unsigned short *edgeImage, objStruct objectMetrics[]){ +int NI_ThinFilter(int samples, int rows, int cols, int numberObjects, + unsigned short *edgeImage, objStruct objectMetrics[]){ int i, j; int loop; @@ -1752,9 +1777,9 @@ unsigned char *Copy; unsigned short *thinEdgeImage; - // + /* // scratch pad (spad) memory - // + */ Input = calloc(samples, sizeof(unsigned char)); CInput = calloc(samples, sizeof(unsigned char)); ErosionStage = calloc(samples, sizeof(unsigned char)); @@ -1773,9 +1798,9 @@ roiRows = top-bottom+2*inflate; roiCols = right-left+2*inflate; - // + /* // clear the scratch pad - // + */ srcOffset = 0; for(i = 0; i < roiRows; ++i){ for(j = 0; j < roiCols; ++j){ @@ -1784,9 +1809,9 @@ srcOffset += cols; } - // + /* // copy the ROI for MAT (medial axis transformation) filter - // + */ dstOffset = inflate*rows; for(i = bottom; i < top; ++i){ srcOffset = i*cols; @@ -1797,11 +1822,12 @@ } dstOffset += cols; } - ThinningFilter(roiRows, roiCols, cols, J_mask, K_mask, Input, CInput, ErosionStage, DialationStage, HMT, Copy); + ThinningFilter(roiRows, roiCols, cols, J_mask, K_mask, Input, CInput, + ErosionStage, DialationStage, HMT, Copy); - // + /* // copy the MAT roi to the new edgeImage (clip the inflate border) - // + */ dstOffset = inflate*rows; for(i = bottom; i < top; ++i){ srcOffset = i*cols; @@ -1814,10 +1840,10 @@ } } - // + /* // copy the MAT edges and return the thinned edges // this will prune the isolated edge points from the edgeImage source - // + */ for(i = 0; i < rows*cols; ++i){ edgeImage[i] = thinEdgeImage[i]; } @@ -1839,11 +1865,11 @@ void generateMask(unsigned char *ImageH, bPOINT *boundary, int newSamples, int label, int cols){ - // + /* // get the boundary point pairs (left, right) for each line // if there is no pair, then the boundary is open // then fill the image in with the current label - // + */ int i, j, k, m; int list[2048]; @@ -1873,7 +1899,7 @@ } } } - // now get the closest boundary + /* now get the closest boundary */ if(k){ distance = maxDistance; index = -1; @@ -1899,9 +1925,9 @@ low = boundary[index].x; high = boundary[i].x; } - // + /* // do the fill - // + */ offset = y * cols; for(j = low; j <= high; ++j){ ImageH[offset+j] = label; @@ -1909,7 +1935,7 @@ } } else{ - // boundary point is isolated + /* boundary point is isolated */ boundary[i].linkIndex = i; } } @@ -1919,7 +1945,8 @@ } -void getBoundaryMetrics(bPOINT *boundary, float *length, float *minRadius, float *maxRadius, float *aveRadius, +void getBoundaryMetrics(bPOINT *boundary, float *length, float *minRadius, + float *maxRadius, float *aveRadius, float Xcenter, float Ycenter, int newSamples){ int j; @@ -1990,11 +2017,6 @@ p = 1; while(p < mcount){ offset = (CurI-inflate)*spadSize; - if(offset < 0){ - printf("offset < 0 "); - printf("CurI [%d]. p [%d]. mcount [%d]\n", CurI, p, mcount); - getchar(); - } MinD = 1024; NewI = -1; NewJ = -1; @@ -2002,7 +2024,7 @@ for(j = CurJ-inflate; j < CurJ+inflate; ++j){ m = Input[offset+j]; if(m == 1){ - // city block distance + /* city block distance */ k = abs(i-CurI) + abs(j-CurJ); if(k < MinD){ MinD = k; @@ -2031,10 +2053,10 @@ unsigned char *input, unsigned char *output, unsigned short mask[11][11]){ - // + /* // do morphological open/close image filtering. the olapValues array determines // if the filter is Open or Close. - // + */ int i, j, k, l, m, overlap, hit; int offset; int LowValue1, HighValue1; @@ -2045,8 +2067,8 @@ LowValue2 = olapValues[2]; HighValue2 = olapValues[3]; - // close - step 1 is dialate - // open - step 1 is erode + /* close - step 1 is dialate + open - step 1 is erode */ offset = maskSize*spadSize; for(i = maskSize; i < rows-maskSize; ++i){ for(j = maskSize; j < columns-maskSize; ++j){ @@ -2065,8 +2087,8 @@ offset += spadSize; } - // close - step 2 is erode - // open - step 2 is dialate + /* close - step 2 is erode + open - step 2 is dialate */ offset = maskSize*spadSize; for(i = maskSize; i < rows-maskSize; ++i){ for(j = maskSize; j < columns-maskSize; ++j){ @@ -2088,7 +2110,8 @@ return; } -void getCompactness(unsigned char *Input, RECT roi, int label, int spadSize, float *vCompactness, float length){ +void getCompactness(unsigned char *Input, RECT roi, int label, int spadSize, + float *vCompactness, float length){ int i, j; int maskOffset; @@ -2115,8 +2138,9 @@ } -void doMorphology(unsigned char *Input, unsigned char *ImageE, unsigned char *ImageC, unsigned char *ImageH, - int olapValuesC[],int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], +void doMorphology(unsigned char *Input, unsigned char *ImageE, unsigned char *ImageC, + unsigned char *ImageH, int olapValuesC[], int olapValuesO[], + unsigned short cmask[11][11], unsigned short omask[11][11], RECT roi, int label, int CloseMaskSize, int OpenMaskSize, int spadSize){ int i, j; @@ -2133,9 +2157,9 @@ ImageC[i] = 0; } - // + /* // put the ROI in the ImageE array centered in ULC - // + */ dstOffset = 0; for(i = roi.bottom; i < roi.top; ++i){ srcOffset = i*spadSize; @@ -2147,20 +2171,20 @@ dstOffset += spadSize; } - // + /* // open - // + */ maskSize = OpenMaskSize; OpenCloseFilter(olapValuesO, maskSize, rows, cols, spadSize, ImageE, ImageC, omask); - // + /* // close - // + */ maskSize = CloseMaskSize; OpenCloseFilter(olapValuesC, maskSize, rows, cols, spadSize, ImageE, ImageC, cmask); - // + /* // put the closed ROI (in ImageE) back in its roi space - // + */ srcOffset = 0; for(i = roi.bottom; i < roi.top+2*maskSize+1; ++i){ @@ -2178,8 +2202,10 @@ } -void getBoundary(unsigned short *ThinEdgeImage, unsigned char *Input, blobBoundary *pBoundary, blobBoundary *lBoundary, - boundaryIndex *pBoundaryIndex, RECT boundBox, int label, int bBox, int nextSlot, int memOffset, +void getBoundary(unsigned short *ThinEdgeImage, unsigned char *Input, + blobBoundary *pBoundary, blobBoundary *lBoundary, + boundaryIndex *pBoundaryIndex, RECT boundBox, int label, + int bBox, int nextSlot, int memOffset, int spadSize, int searchWindow){ int i, j; @@ -2202,7 +2228,7 @@ Input[i] = 0; } - //copy to spad + /* copy to spad */ count = 0; rows = boundBox.top-boundBox.bottom+2*inflate; @@ -2227,7 +2253,7 @@ if(Input[srcOffset+j]){ if(first){ first = FALSE; - // index of the seed sample + /* index of the seed sample */ value.xy.x = i; value.xy.y = j; } @@ -2243,12 +2269,10 @@ for(i = 0; i < mcount; ++i){ value.xy.x = lBoundary[i].xy.x + boundBox.left - inflate; value.xy.y = lBoundary[i].xy.y + boundBox.bottom - inflate + 1; - //printf("[%d, %d]\n", value.xy.x, value.xy.y); pBoundary[memOffset].xy.x = value.xy.x; pBoundary[memOffset].xy.y = value.xy.y; ++memOffset; } - //getchar(); return; @@ -2256,7 +2280,7 @@ void buildBoundary(objStruct objectMetrics[], int searchWindow, unsigned short *ThinEdgeImage, - int numberObjects, int srcRows, int srcCols){ + int numberObjects, int srcRows, int srcCols){ int i, j, k; int count; @@ -2267,7 +2291,7 @@ int end; int label; int distance; - // these should be setup parameters + /* these will be user-setup parameters */ int closureDistance = 12; int CloseSize = 5; int OpenSize = 5; @@ -2281,7 +2305,7 @@ float maxRadius; float aveRadius; float vCompactness; - // for morphological close of mask. max structuring element is 11x11 + /* for morphological close of mask. max structuring element is 11x11 */ unsigned short cmask[11][11]; unsigned short omask[11][11]; int olapValuesC[4]; @@ -2301,9 +2325,9 @@ unsigned char *ImageC; unsigned char *ImageH; - // + /* // Close filter - // + */ CloseMaskSize = (CloseSize-1)/2; for(i = 0; i < 2*CloseMaskSize+1; ++i){ for(j = 0; j < 2*CloseMaskSize+1; ++j){ @@ -2319,9 +2343,9 @@ olapValuesC[2] = LowValue2; olapValuesC[3] = HighValue2; - // + /* // Open filter - // + */ OpenMaskSize = (OpenSize-1)/2; for(i = 0; i < 2*OpenMaskSize+1; ++i){ for(j = 0; j < 2*OpenMaskSize+1; ++j){ @@ -2373,21 +2397,16 @@ bBox.bottom = objectMetrics[i].B; label = objectMetrics[i].Label; pBoundaryIndex[i+1].Label = label; - //printf("(%d, %d, %d, %d [%d])\n", bBox.left, bBox.right, bBox.top, bBox.bottom, label); getBoundary(ThinEdgeImage, Input, pBoundary, lBoundary, pBoundaryIndex, bBox, label, i, pBoundaryIndex[0].numberPoints, count, spadSize, searchWindow); } - // + /* // Input will now be used in the fill. Copy the labeled edge image - // + */ - // - // numBoundaries = numberObjects - // offset = 0; numBoundaries = pBoundaryIndex[0].numberPoints; - //printf("numBoundaries [%d]\n", numBoundaries); for(i = 0; i < numBoundaries; ++i){ numSamples = pBoundaryIndex[i+1].numberPoints; end = numSamples-2; @@ -2397,9 +2416,9 @@ boundary[j].y = pBoundary[offset+j+1].xy.y; } - // + /* // clip off the ends where stray boundary pixels were left over - // + */ while(1){ distance = abs(boundary[end].x-boundary[end-1].x) + abs(boundary[end].y-boundary[end-1].y); if(distance > threshold){ @@ -2410,7 +2429,6 @@ break; } } - //printf("[%d] newSamples [%d]\n", i, newSamples); distance = abs(boundary[0].x-boundary[end-2].x) + abs(boundary[0].y-boundary[end-2].y); pBoundaryIndex[i+1].curveClose = distance; @@ -2429,7 +2447,8 @@ pBoundaryIndex[i+1].centroid.y /= newSamples; } getBoundaryMetrics(boundary, &length, &minRadius, &maxRadius, &aveRadius, - (float)pBoundaryIndex[i+1].centroid.x, (float)pBoundaryIndex[i+1].centroid.y, newSamples); + (float)pBoundaryIndex[i+1].centroid.x, + (float)pBoundaryIndex[i+1].centroid.y, newSamples); pBoundaryIndex[i+1].boundaryLength = length; pBoundaryIndex[i+1].minRadius = minRadius; pBoundaryIndex[i+1].maxRadius = maxRadius; @@ -2441,35 +2460,35 @@ pBoundaryIndex[i+1].ratio = -1.0; } - // + /* // augment the ROI boundary - // + */ pBoundaryIndex[i+1].rectangle.left -= 2*CloseMaskSize; pBoundaryIndex[i+1].rectangle.right += 2*CloseMaskSize; pBoundaryIndex[i+1].rectangle.bottom -= 2*CloseMaskSize; pBoundaryIndex[i+1].rectangle.top += 2*CloseMaskSize; label = pBoundaryIndex[i+1].Label; - // + /* // mask goes in ImageH. morpho filter the mask first - // + */ generateMask(ImageH, boundary, newSamples, label, spadSize); - // + /* // open-close the mask - // + */ doMorphology(Input, ImageE, ImageC, ImageH, olapValuesC, olapValuesO, cmask, omask, pBoundaryIndex[i+1].rectangle, label, CloseMaskSize, OpenMaskSize, spadSize); - // + /* // now get the compactness metrics - // + */ getCompactness(Input, pBoundaryIndex[i+1].rectangle, label, spadSize, &vCompactness, length); pBoundaryIndex[i+1].compactness = vCompactness; - // + /* // reset the ROI boundary - // + */ pBoundaryIndex[i+1].rectangle.left += 2*CloseMaskSize; pBoundaryIndex[i+1].rectangle.right -= 2*CloseMaskSize; pBoundaryIndex[i+1].rectangle.bottom += 2*CloseMaskSize; @@ -2509,9 +2528,9 @@ } } - // + /* // fill in the Python features - // + */ for(i = 0; i < numBoundaries; ++i){ objectMetrics[i].curveClose = pBoundaryIndex[i+1].curveClose; objectMetrics[i].cXBoundary = pBoundaryIndex[i+1].centroid.x; @@ -2525,7 +2544,7 @@ } // debug only - if(1){ + if(0){ for(i = 0; i < numBoundaries; ++i){ if(pBoundaryIndex[i+1].boundaryLength != (float)0.0){ printf("boundary %d:\n", i); @@ -2556,9 +2575,9 @@ } } - // + /* // need to return input which is now mask image - // + */ offset = 0; offset2 = 0; @@ -2613,7 +2632,7 @@ lawsFilter->lawsKernel[5][i] = O7[i]; } - // DC filter is unity gain + /* L filter is unity gain */ sum = (float)0.0; for(i = 0; i < 7; ++i){ sum += lawsFilter->lawsKernel[0][i]; @@ -2633,7 +2652,7 @@ float result[7]; float sum; - // filter rows + /* filter rows */ for(i = 0; i < kernelSize; ++i){ sum = (float)0.0; offset = i * kernelSize; @@ -2643,7 +2662,7 @@ result[i] = sum; } - //filter columns + /* filter columns */ sum = (float)0.0; for(j = 0; j < kernelSize; ++j){ sum += (rowFilter[j]*result[j]); @@ -2654,8 +2673,10 @@ } -void getLawsTexture(LawsFilter7 lawsFilter, tTEM LawsFeatures[], objStruct objectMetrics[], double *sourceImage, - unsigned short *MaskImage, int numberObjects, int srcRows, int srcCols){ +void getLawsTexture(LawsFilter7 lawsFilter, tTEM LawsFeatures[], + objStruct objectMetrics[], double *sourceImage, + unsigned short *MaskImage, int numberObjects, + int srcRows, int srcCols){ int i, j; int label; @@ -2676,15 +2697,15 @@ bBox.bottom = objectMetrics[i].B; label = objectMetrics[i].Label; if(objectMetrics[i].voxelMean != (float)0.0){ - // + /* // valid size region - // + */ computeLaws(lawsFilter, LawsFeatures, bBox, label, aperature, srcRows, srcCols, ImageH, ImageT, MaskImage, lawsImage, sourceImage); for(j = 1; j < lawsFilter.numberFilterLayers; ++j){ objectMetrics[i].TEM[j-1] = LawsFeatures[j].Variance; } - /* + /* -- later will need to return a view of the texture images int index; int offset; int layerStep = srcRows*srcCols; @@ -2711,12 +2732,14 @@ } -void computeLaws(LawsFilter7 lawsFilter, tTEM LawsFeatures[], RECT roi, int label, int aperature, int srcRows, int srcCols, - unsigned char *ImageH, float *ImageT, unsigned short *MaskImage, float *lawsImage, double *sourceImage){ +void computeLaws(LawsFilter7 lawsFilter, tTEM LawsFeatures[], RECT roi, int label, + int aperature, int srcRows, int srcCols, + unsigned char *ImageH, float *ImageT, unsigned short *MaskImage, + float *lawsImage, double *sourceImage){ - // + /* // hard-wirred to Law's 7 kernels - // + */ int i, j, k; int lawsLayer; int column, row; @@ -2744,7 +2767,7 @@ char dual[24]; - // zero the laws mask memory first + /* zero the laws mask memory first */ for(i = 0; i < srcRows*srcCols; ++i){ ImageH[i] = 0; } @@ -2760,9 +2783,9 @@ dataOffset[row+aperature] = maskOffset[row+aperature]; } for(j = roi.left+aperature; j < roi.right-aperature; ++j){ - // + /* // get 7x7 segment and make sure have 100% mask coverage - // + */ count = 0; for(row = -aperature; row <= aperature; ++row){ rowNumber = (row+aperature)*kernelSize; @@ -2774,22 +2797,22 @@ } } if(count == fullMask){ - // - // full mask. 100% coverage. now do the Law's texture filters - // + /* + // 100% coverage. now do the Law's texture filters + */ ImageH[i*srcCols+j] = 1; lawsLayer = 0; for(outerKernelNumber = 0; outerKernelNumber < lawsFilter.numberKernels; ++outerKernelNumber){ - // + /* // outer loop pulls the i'th kernel. kernel 0 is the LP kernel // the outer loop is the iso-kernel - // + */ I = lawsFilter.name[outerKernelNumber]; sprintf(dual, "%c_%c", I, I); rowFilter = &lawsFilter.lawsKernel[outerKernelNumber][0]; colFilter = &lawsFilter.lawsKernel[outerKernelNumber][0]; filterResult1 = lawsConvolution(myImage, rowFilter, colFilter, kernelSize); - // lawsLayer 0 is the LP and needs to be used to scale. + /* lawsLayer 0 is the LP and needs to be used to scale. */ if(outerKernelNumber){ lawsImage[lawsLayer*layerStep + i*srcCols + j] = (float)2.0 * filterResult1 / lawsLL; } @@ -2799,17 +2822,20 @@ } strcpy(&LawsFeatures[lawsLayer].filterName[0], dual); ++lawsLayer; - // + /* // now do the inner loop and get the column filters for the other laws kernels - // - for(innerKernelNumber = outerKernelNumber+1; innerKernelNumber < lawsFilter.numberKernels; ++innerKernelNumber){ + */ + for(innerKernelNumber = outerKernelNumber+1; + innerKernelNumber < lawsFilter.numberKernels; + ++innerKernelNumber){ J = lawsFilter.name[innerKernelNumber]; sprintf(combo, "%c_%c", I, J); strcpy(&LawsFeatures[lawsLayer].filterName[0], combo); colFilter = &lawsFilter.lawsKernel[innerKernelNumber][0]; filterResult1 = lawsConvolution(myImage, rowFilter, colFilter, kernelSize); filterResult2 = lawsConvolution(myImage, colFilter, rowFilter, kernelSize); - lawsImage[lawsLayer*layerStep + i*srcCols + j] = (filterResult1 / lawsLL) + (filterResult2 / lawsLL); + lawsImage[lawsLayer*layerStep + i*srcCols + j] = + (filterResult1 / lawsLL) + (filterResult2 / lawsLL); ++lawsLayer; } } @@ -2837,6 +2863,7 @@ } if(count == 0){ + // debug statement printf("no samples for texture\n"); return; } @@ -2861,9 +2888,9 @@ LawsFeatures[k].Variance = (float)(sqrt(LawsFeatures[k].Variance)); } - // + /* // now normalize the variance feature (TEM) - // + */ maxValue = (float)0.0; for(i = 1; i < lawsFilter.numberFilterLayers; ++i){ if((LawsFeatures[i].Variance) > maxValue) maxValue = LawsFeatures[i].Variance; @@ -2878,8 +2905,9 @@ } -void getVoxelMeasures(objStruct objectMetrics[], double *sourceImage, unsigned short *MaskImage, - int numberObjects, int srcRows, int srcCols){ +void getVoxelMeasures(objStruct objectMetrics[], double *sourceImage, + unsigned short *MaskImage, int numberObjects, + int srcRows, int srcCols){ int i, j, k; int label; @@ -2935,10 +2963,10 @@ } -int NI_BuildBoundary(int samples, int rows, int cols, int numberObjects, unsigned short *edgeImage, - objStruct objectMetrics[]){ +int NI_BuildBoundary(int samples, int rows, int cols, int numberObjects, + unsigned short *edgeImage, objStruct objectMetrics[]){ - int searchWindow = 5; // 5 is good value for Sobel - (should be 13 for Canny edges) + int searchWindow = 5; // 5 is good value for Sobel int status = 1; buildBoundary(objectMetrics, searchWindow, edgeImage, numberObjects, rows, cols); @@ -2966,7 +2994,8 @@ tTEM LawsFeatures[21]; initLaws(&lawsFilter); - getLawsTexture(lawsFilter, LawsFeatures, objectMetrics, sourceImage, maskImage, numberObjects, rows, cols); + getLawsTexture(lawsFilter, LawsFeatures, objectMetrics, sourceImage, + maskImage, numberObjects, rows, cols); return status; Modified: trunk/scipy/ndimage/segment/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/segment/tests/test_segment.py 2007-11-08 03:42:40 UTC (rev 3510) +++ trunk/scipy/ndimage/segment/tests/test_segment.py 2007-11-09 20:53:50 UTC (rev 3511) @@ -9,17 +9,65 @@ filename = os.path.join(os.path.split(__file__)[0],inputname) -def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) +def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, + highThreshold=600+2048, dust=16): + """ + labeledEdges, ROIList = shen_castan(image, [default]) + + implements Shen-Castan edge finding + + Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust + - image is the numarray 2D image + - IIR filter is filter parameter for exponential filter + - shen_castan_low is edge threshold is range (0.0, 1.0] + - window is search window for edge detection + - low_ and high_ threshold are density values + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) + + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned + + """ + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, + lowThreshold, highThreshold, image) # allocated struct array for edge object measures. for now just the rect bounding box ROIList = N.zeros(numberObjects, dtype=S.objstruct) # return the bounding box for each connected edge S.get_object_stats(labeledEdges, ROIList) return labeledEdges, ROIList[ROIList['Area']>dust] -def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): +def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, + apearture=21, dust=16): + """ + labeledEdges, ROIList = sobel(image, [default]) + + implements sobel magnitude edge finding + + Inputs - image, sobel_low, tMode, low_threshold, high_threshold, + high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - sobel_low is edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) + + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned + + """ # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, + highThreshold, BPHigh, apearture, image) # allocated struct array for edge object measures. for now just the rect bounding box ROIList = N.zeros(numberObjects, dtype=S.objstruct) # return the bounding box for each connected edge @@ -28,8 +76,34 @@ S.morpho_thin_filt(labeledEdges, ROIList) return labeledEdges, ROIList[ROIList['Area']>dust] -def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, - BPHigh=10.0, apearture=21, dust=16): +def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, + highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): + """ + labeledEdges, ROIList = canny(image, [default]) + + implements canny edge finding + + Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, + high_threshold, high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter + - clow is low edge threshold is range (0.0, 1.0] + - chigh is high edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) + + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned + + """ # get canny edge points. return edges that are labeled (1..numberObjects) labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) @@ -40,6 +114,23 @@ return labeledEdges, ROIList[ROIList['Area']>dust] def get_shape_mask(labeledEdges, ROIList): + """ + get_shape_mask(labeledEdges, ROIList) + + takes labeled edge image plus ROIList (blob descriptors) and generates + boundary shape features and builds labeled blob masks. 'labeledEdges' + is over-written by 'labeledMask'. Adds features to ROIList structure + + Inputs - labeledEdges, ROIList + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. + + Output - no return. edge image input is over-written with mask image. + ROIList added to. + + """ + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList # GetShapeMask will augment the ROI list # labeledEdges is the original edge image and overwritten as mask image @@ -48,6 +139,21 @@ return def get_voxel_measures(rawImage, labeledEdges, ROIList): + """ + get_voxel_measures(rawImage, labeledEdges, ROIList) + + takes raw 2D image, labeled blob mask and ROIList. computes voxel features + (moments, histogram) for each blob. Adds features to ROIList structure. + + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. + + Output - no return. ROIList added to. + + """ # # pass raw image, labeled mask and the partially filled ROIList # VoxelMeasures will fill the voxel features in the list @@ -56,14 +162,52 @@ return def get_texture_measures(rawImage, labeledEdges, ROIList): + """ + get_texture_measures(rawImage, labeledEdges, ROIList) + + takes raw 2D image, labeled blob mask and ROIList. computes 2D + texture features using 7x7 Law's texture filters applied + to segmented blobs. TEM (texture energy metric) is computed + for each Law's filter image and stored in TEM part of ROIList. + + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. + + Output - no return. ROIList added to. + """ # # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list + # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list # S.texture_measures(rawImage, labeledEdges, ROIList) return def segment_regions(): + """ + sourceImage, labeledMask, ROIList = segment_regions() + + Inputs - No Input + + Outputs - sourceImage, labeledMask, ROIList + - sourceImage is raw 2D image (default cardiac CT slice for demo + - labeledMask is mask of segmented 'blobs', + numerically labeled by blob number + - ROIList is numerical Python structure of intensity, shape and + texture features for each blob + + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + sobel() - sobel magnitude edge finder, + returns connected edges + get_shape_mask() - gets segmented blob boundary and mask + and shape features + get_voxel_measures() - uses masks get object voxel moment + and histogram features + get_texture_measures() - uses masks get object 2D texture features + """ # get slice from the CT volume image = get_slice(filename) # need a copy of original image as filtering will occur on the extracted slice @@ -80,6 +224,18 @@ return sourceImage, labeledMask, ROIList def grow_regions(): + """ + regionMask, numberRegions = region_grow() + Inputs - No Input + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + region_grow() - "grows" connected blobs. default threshold + and morphological filter structuring element + """ # get slice from the CT volume image = get_slice(filename) regionMask, numberRegions = region_grow(image) @@ -87,12 +243,27 @@ def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): + """ + regionMask, numberRegions = region_grow(image, [defaults]) + + Inputs - image, low_threshold, high_threshold, open, close + - image is the numarray 2D image + - low_ and high_ threshold are density values + - open is open morphology structuring element + odd size. 0 to turn off. max is 11 + - close is close morphology structuring element + odd size. 0 to turn off. max is 11 + + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + """ # morphology filters need to be clipped to 11 max and be odd regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) return regionMask, numberRegions -def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): +def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512): # get a slice alrady extracted from the CT volume #image = open(imageName, 'rb') #slice = image.read(rows*columns*bytes) @@ -105,7 +276,7 @@ ImageSlice[505:512, :] = 0 return (ImageSlice).astype(float) -def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): +def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)): import mmap file = open(image_name, 'rb') mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) From scipy-svn at scipy.org Sun Nov 11 05:49:46 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 Nov 2007 04:49:46 -0600 (CST) Subject: [Scipy-svn] r3512 - in trunk/scipy/sandbox/multigrid: . tests Message-ID: <20071111104946.8C11239C030@new.scipy.org> Author: wnbell Date: 2007-11-11 04:48:59 -0600 (Sun, 11 Nov 2007) New Revision: 3512 Modified: trunk/scipy/sandbox/multigrid/multilevel.py trunk/scipy/sandbox/multigrid/sa.py trunk/scipy/sandbox/multigrid/tests/test_sa.py trunk/scipy/sandbox/multigrid/tests/test_utils.py trunk/scipy/sandbox/multigrid/utils.py Log: added support for diagonal scaling in SA solver Modified: trunk/scipy/sandbox/multigrid/multilevel.py =================================================================== --- trunk/scipy/sandbox/multigrid/multilevel.py 2007-11-09 20:53:50 UTC (rev 3511) +++ trunk/scipy/sandbox/multigrid/multilevel.py 2007-11-11 10:48:59 UTC (rev 3512) @@ -11,7 +11,7 @@ from sa import sa_interpolation from rs import rs_interpolation from relaxation import gauss_seidel,jacobi,sor -from utils import infinity_norm +from utils import symmetric_rescaling, diag_sparse def poisson_problem1D(N): @@ -43,8 +43,9 @@ References: "Multigrid" - Trottenberg, U., C. W. Oosterlee, and Anton Schuller. San Diego: Academic Press, 2001. - See Appendix A + Trottenberg, U., C. W. Oosterlee, and Anton Schuller. + San Diego: Academic Press, 2001. + Appendix A """ As = [A] @@ -59,8 +60,14 @@ Ps.append(P) return multilevel_solver(As,Ps) + -def smoothed_aggregation_solver(A,candidates=None,blocks=None,aggregation=None,max_levels=10,max_coarse=500,epsilon=0.08,omega=4.0/3.0): + +def smoothed_aggregation_solver(A, B=None, blocks=None, \ + aggregation=None, max_levels=10, \ + max_coarse=500, epsilon=0.0, \ + omega=4.0/3.0, symmetric=True, \ + rescale = True): """Create a multilevel solver using Smoothed Aggregation (SA) *Parameters*: @@ -83,15 +90,20 @@ List of csr_matrix objects that describe a user-defined multilevel aggregation of the variables. TODO ELABORATE - max_levels: {integer} : optional + max_levels: {integer} : default 10 Maximum number of levels to be used in the multilevel solver. - max_coarse: {integer} : optional + max_coarse: {integer} : default 500 Maximum number of variables permitted on the coarse grid. - epsilon: {float} : optional + epsilon: {float} : default 0.0 Strength of connection parameter used in aggregation. - omega: {float} : optional + omega: {float} : default 4.0/3.0 Damping parameter used in prolongator smoothing (0 < omega < 2) - + symmetric: {boolean} : default True + True if A is symmetric, False otherwise + rescale: {boolean} : default True + If True, symmetrically rescale A by the diagonal + i.e. A -> D * A * D, where D is diag(A)^-0.5 + *Example*: TODO @@ -101,17 +113,30 @@ http://citeseer.ist.psu.edu/vanek96algebraic.html """ + + if B is None: + B = ones((A.shape[0],1),dtype=A.dtype) # use constant vector + else: + B = asarray(B) + + pre,post = None,None #preprocess/postprocess + + if rescale: + D_sqrt,D_sqrt_inv,A = symmetric_rescaling(A) + D_sqrt,D_sqrt_inv = diag_sparse(D_sqrt),diag_sparse(D_sqrt_inv) + + B = D_sqrt * B #scale candidates + def pre(x,b): + return D_sqrt*x,D_sqrt_inv*b + def post(x): + return D_sqrt_inv*x + As = [A] Ps = [] - if candidates is None: - candidates = ones((A.shape[0],1),dtype=A.dtype) # use constant vector - else: - candiates = asarray(candidates) - if aggregation is None: while len(As) < max_levels and A.shape[0] > max_coarse: - P,candidates,blocks = sa_interpolation(A,candidates,epsilon*0.5**(len(As)-1),omega=omega,blocks=blocks) + P,B,blocks = sa_interpolation(A,B,epsilon*0.5**(len(As)-1),omega=omega,blocks=blocks) A = (P.T.tocsr() * A) * P #galerkin operator @@ -120,20 +145,22 @@ else: #use user-defined aggregation for AggOp in aggregation: - P,candidates,blocks = sa_interpolation(A,candidates,omega=omega,AggOp=AggOp) + P,B,blocks = sa_interpolation(A,B,omega=omega,AggOp=AggOp) A = (P.T.tocsr() * A) * P #galerkin operator As.append(A) Ps.append(P) - return multilevel_solver(As,Ps) + return multilevel_solver(As,Ps,preprocess=pre,postprocess=post) class multilevel_solver: - def __init__(self,As,Ps): + def __init__(self,As,Ps,preprocess=None,postprocess=None): self.As = As self.Ps = Ps + self.preprocess = preprocess + self.postprocess = postprocess def __repr__(self): output = 'multilevel_solver\n' @@ -170,6 +197,8 @@ else: x = array(x0) #copy + if self.preprocess is not None: + x,b = self.preprocess(x,b) #TODO change use of tol (relative tolerance) to agree with other iterative solvers A = self.As[0] @@ -183,6 +212,9 @@ if callback is not None: callback(x) + if self.postprocess is not None: + x = self.postprocess(x) + if return_residuals: return x,residuals else: Modified: trunk/scipy/sandbox/multigrid/sa.py =================================================================== --- trunk/scipy/sandbox/multigrid/sa.py 2007-11-09 20:53:50 UTC (rev 3511) +++ trunk/scipy/sandbox/multigrid/sa.py 2007-11-11 10:48:59 UTC (rev 3512) @@ -4,7 +4,8 @@ ascontiguousarray from scipy.sparse import csr_matrix,isspmatrix_csr,spidentity -from utils import diag_sparse,approximate_spectral_radius,expand_into_blocks +from utils import diag_sparse, approximate_spectral_radius, \ + symmetric_rescaling, expand_into_blocks import multigridtools __all__ = ['sa_filtered_matrix','sa_strong_connections','sa_constant_interpolation', @@ -103,6 +104,7 @@ def sa_fit_candidates(AggOp,candidates,tol=1e-10): #TODO handle non-floating point candidates better + candidates = candidates.astype('float64') K = candidates.shape[1] # num candidates @@ -181,9 +183,6 @@ # smooth tentative prolongator T P = T - (D_inv_A*T) - #S = (spidentity(A.shape[0]).tocsr() - D_inv_A) #TODO drop this? - #P = S *(S * ( S * T)) - return P def sa_interpolation(A,candidates,epsilon=0.0,omega=4.0/3.0,blocks=None,AggOp=None): Modified: trunk/scipy/sandbox/multigrid/tests/test_sa.py =================================================================== --- trunk/scipy/sandbox/multigrid/tests/test_sa.py 2007-11-09 20:53:50 UTC (rev 3511) +++ trunk/scipy/sandbox/multigrid/tests/test_sa.py 2007-11-11 10:48:59 UTC (rev 3512) @@ -226,7 +226,7 @@ #ml = smoothed_aggregation_solver(A,candidates,max_coarse=1,max_levels=2) - ml = smoothed_aggregation_solver(DAD,DAD_candidates,max_coarse=100,max_levels=2) + ml = smoothed_aggregation_solver(DAD,DAD_candidates,max_coarse=100,max_levels=2,rescale=False) #print (D_inv*ml.Ps[0]).todense() Modified: trunk/scipy/sandbox/multigrid/tests/test_utils.py =================================================================== --- trunk/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-09 20:53:50 UTC (rev 3511) +++ trunk/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-11 10:48:59 UTC (rev 3512) @@ -2,12 +2,13 @@ import numpy import scipy -from scipy import matrix,array,diag,zeros +from numpy import matrix,array,diag,zeros,sqrt from scipy.sparse import csr_matrix set_package_path() from scipy.sandbox.multigrid.utils import infinity_norm, diag_sparse, \ + symmetric_rescaling, \ expand_into_blocks restore_path() @@ -53,6 +54,33 @@ A = matrix([[1.3,0,0],[0,5.5,0],[0,0,-2]]) assert_equal(diag_sparse(array([1.3,5.5,-2])).todense(),csr_matrix(A).todense()) + + def check_symmetric_rescaling(self): + cases = [] + cases.append( diag_sparse(array([1,2,3,4])) ) + cases.append( diag_sparse(array([1,0,3,4])) ) + + A = array([ [ 5.5, 3.5, 4.8], + [ 2. , 9.9, 0.5], + [ 6.5, 2.6, 5.7]]) + A = csr_matrix( A ) + cases.append(A) + P = diag_sparse([1,0,1]) + cases.append( P*A*P ) + P = diag_sparse([0,1,0]) + cases.append( P*A*P ) + P = diag_sparse([1,-1,1]) + cases.append( P*A*P ) + + for A in cases: + D_sqrt,D_sqrt_inv,DAD = symmetric_rescaling(A) + + assert_almost_equal( diag_sparse(A) > 0, diag_sparse(DAD) ) + assert_almost_equal( diag_sparse(DAD), D_sqrt*D_sqrt_inv ) + + D_sqrt,D_sqrt_inv = diag_sparse(D_sqrt),diag_sparse(D_sqrt_inv) + assert_almost_equal((D_sqrt_inv*A*D_sqrt_inv).todense(), DAD.todense()) + def check_expand_into_blocks(self): cases = [] cases.append( ( matrix([[1]]), (1,2) ) ) Modified: trunk/scipy/sandbox/multigrid/utils.py =================================================================== --- trunk/scipy/sandbox/multigrid/utils.py 2007-11-09 20:53:50 UTC (rev 3511) +++ trunk/scipy/sandbox/multigrid/utils.py 2007-11-11 10:48:59 UTC (rev 3512) @@ -3,7 +3,7 @@ import numpy import scipy -from numpy import ravel,arange,concatenate,tile,asarray +from numpy import ravel,arange,concatenate,tile,asarray,sqrt,diff from scipy.linalg import norm from scipy.sparse import isspmatrix,isspmatrix_csr,isspmatrix_csc, \ csr_matrix,csc_matrix,extract_diagonal, \ @@ -26,7 +26,7 @@ if isspmatrix_csr(A) or isspmatrix_csc(A): #avoid copying index and ptr arrays - abs_A = A.__class__((abs(A.data),A.indices,A.indptr),dims=A.shape,check=False) + abs_A = A.__class__((abs(A.data),A.indices,A.indptr),dims=A.shape) return (abs_A * numpy.ones(A.shape[1],dtype=A.dtype)).max() else: return (abs(A) * numpy.ones(A.shape[1],dtype=A.dtype)).max() @@ -40,12 +40,37 @@ - return a csr_matrix with A on the diagonal """ + #TODO integrate into SciPy? if isspmatrix(A): return extract_diagonal(A) else: return csr_matrix((asarray(A),arange(len(A)),arange(len(A)+1)),(len(A),len(A))) +def symmetric_rescaling(A): + if not (isspmatrix_csr(A) or isspmatrix_csc(A)): + raise TypeError,'expected csr_matrix or csc_matrix' + + if A.shape[0] != A.shape[1]: + raise ValueError,'expected square matrix' + + D = diag_sparse(A) + mask = D <= 0 + + D[mask] = 0 + D_sqrt = sqrt(D) + D_sqrt_inv = 1.0/D_sqrt + D_sqrt_inv[mask] = 0 + + #TODO time this against simple implementation + data = A.data * D_sqrt_inv[A.indices] + data *= D_sqrt_inv[arange(A.shape[0]).repeat(diff(A.indptr))] + + DAD = A.__class__((data,A.indices,A.indptr),dims=A.shape) + + return D_sqrt,D_sqrt_inv,DAD + + def hstack_csr(A,B): if not isspmatrix(A) or not isspmatrix(B): raise TypeError,'expected sparse matrix' From scipy-svn at scipy.org Sun Nov 11 17:15:55 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 11 Nov 2007 16:15:55 -0600 (CST) Subject: [Scipy-svn] r3513 - trunk/scipy/sandbox/multigrid/multigridtools Message-ID: <20071111221555.0205239C0A5@new.scipy.org> Author: wnbell Date: 2007-11-11 16:15:52 -0600 (Sun, 11 Nov 2007) New Revision: 3513 Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx Log: regenerated multigridtools Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-11 10:48:59 UTC (rev 3512) +++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-11 22:15:52 UTC (rev 3513) @@ -53,70 +53,71 @@ F_NODE = _multigridtools.F_NODE def sa_get_aggregates(*args): - """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)""" - return _multigridtools.sa_get_aggregates(*args) + """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)""" + return _multigridtools.sa_get_aggregates(*args) def rs_strong_connections(*args): + """ + rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp, + std::vector<(int)> Sj, + std::vector<(float)> Sx) + rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(double)> Sx) """ - rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp, - std::vector<(int)> Sj, - std::vector<(float)> Sx) - rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(double)> Sx) - """ - return _multigridtools.rs_strong_connections(*args) + return _multigridtools.rs_strong_connections(*args) def rs_interpolation(*args): + """ + rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj, + float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj, + double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) """ - rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj, - float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj, - double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - """ - return _multigridtools.rs_interpolation(*args) + return _multigridtools.rs_interpolation(*args) def sa_strong_connections(*args): + """ + sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(float)> Sx) + sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(double)> Sx) """ - sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(float)> Sx) - sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(double)> Sx) - """ - return _multigridtools.sa_strong_connections(*args) + return _multigridtools.sa_strong_connections(*args) def sa_smoother(*args): + """ + sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp, + int Sj, float Sx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax, + int Sp, int Sj, double Sx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) """ - sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp, - int Sj, float Sx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax, - int Sp, int Sj, double Sx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - """ - return _multigridtools.sa_smoother(*args) + return _multigridtools.sa_smoother(*args) def gauss_seidel(*args): + """ + gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b, + int row_start, int row_stop, int row_step) + gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, + int row_start, int row_stop, int row_step) """ - gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b, - int row_start, int row_stop, int row_step) - gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, - int row_start, int row_stop, int row_step) - """ - return _multigridtools.gauss_seidel(*args) + return _multigridtools.gauss_seidel(*args) def jacobi(*args): + """ + jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, + float temp, int row_start, int row_stop, + int row_step, float omega) + jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, + double temp, int row_start, int row_stop, + int row_step, double omega) """ - jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, - float temp, int row_start, int row_stop, - int row_step, float omega) - jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, - double temp, int row_start, int row_stop, - int row_step, double omega) - """ - return _multigridtools.jacobi(*args) + return _multigridtools.jacobi(*args) + Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx 2007-11-11 10:48:59 UTC (rev 3512) +++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx 2007-11-11 22:15:52 UTC (rev 3513) @@ -12,7 +12,7 @@ #define SWIG_PYTHON_DIRECTOR_NO_VTABLE #ifdef __cplusplus -template class SwigValueWrapper { +template class SwigValueWrapper { T *tt; public: SwigValueWrapper() : tt(0) { } @@ -25,6 +25,10 @@ private: SwigValueWrapper& operator=(const SwigValueWrapper& rhs); }; + +template T SwigValueInit() { + return T(); +} #endif /* ----------------------------------------------------------------------------- @@ -124,7 +128,13 @@ # define _CRT_SECURE_NO_DEPRECATE #endif +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + /* Python.h has to appear first */ #include @@ -360,7 +370,7 @@ while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } - return (l1 - f1) - (l2 - f2); + return (int)((l1 - f1) - (l2 - f2)); } /* @@ -1107,7 +1117,7 @@ /* Unpack the argument tuple */ SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { @@ -1122,7 +1132,7 @@ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { - register int l = PyTuple_GET_SIZE(args); + register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), min, l); @@ -2579,25 +2589,60 @@ #include "complex_ops.h" -/* The following code originally appeared in enthought/kiva/agg/src/numeric.i, - * author unknown. It was translated from C++ to C by John Hunter. Bill - * Spotz has modified it slightly to fix some minor bugs, add some comments - * and some functionality. +/* The following code originally appeared in + * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was + * translated from C++ to C by John Hunter. Bill Spotz has modified + * it slightly to fix some minor bugs, upgrade to numpy (all + * versions), add some comments and some functionality. */ /* Macros to extract array attributes. */ #define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) #define array_type(a) (int)(PyArray_TYPE(a)) -#define array_dimensions(a) (((PyArrayObject *)a)->nd) +#define array_numdims(a) (((PyArrayObject *)a)->nd) +#define array_dimensions(a) (((PyArrayObject *)a)->dimensions) #define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) +#define array_data(a) (((PyArrayObject *)a)->data) #define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) +#define array_is_native(a) (PyArray_ISNOTSWAPPED(a)) +/* Support older NumPy data type names +*/ +#if NDARRAY_VERSION < 0x01000000 +#define NPY_BOOL PyArray_BOOL +#define NPY_BYTE PyArray_BYTE +#define NPY_UBYTE PyArray_UBYTE +#define NPY_SHORT PyArray_SHORT +#define NPY_USHORT PyArray_USHORT +#define NPY_INT PyArray_INT +#define NPY_UINT PyArray_UINT +#define NPY_LONG PyArray_LONG +#define NPY_ULONG PyArray_ULONG +#define NPY_LONGLONG PyArray_LONGLONG +#define NPY_ULONGLONG PyArray_ULONGLONG +#define NPY_FLOAT PyArray_FLOAT +#define NPY_DOUBLE PyArray_DOUBLE +#define NPY_LONGDOUBLE PyArray_LONGDOUBLE +#define NPY_CFLOAT PyArray_CFLOAT +#define NPY_CDOUBLE PyArray_CDOUBLE +#define NPY_CLONGDOUBLE PyArray_CLONGDOUBLE +#define NPY_OBJECT PyArray_OBJECT +#define NPY_STRING PyArray_STRING +#define NPY_UNICODE PyArray_UNICODE +#define NPY_VOID PyArray_VOID +#define NPY_NTYPES PyArray_NTYPES +#define NPY_NOTYPE PyArray_NOTYPE +#define NPY_CHAR PyArray_CHAR +#define NPY_USERDEF PyArray_USERDEF +#define npy_intp intp +#endif /* Given a PyObject, return a string describing its type. */ char* pytype_string(PyObject* py_obj) { if (py_obj == NULL ) return "C NULL value"; + if (py_obj == Py_None ) return "Python None" ; if (PyCallable_Check(py_obj)) return "callable" ; if (PyString_Check( py_obj)) return "string" ; if (PyInt_Check( py_obj)) return "int" ; @@ -2612,21 +2657,24 @@ return "unkown type"; } -/* Given a Numeric typecode, return a string describing the type. +/* Given a NumPy typecode, return a string describing the type. */ -char* type_names[20] = {"char","unsigned byte","byte","short", - "unsigned short","int","unsigned int","long", - "float","double","complex float","complex double", - "object","ntype","unkown"}; - char* typecode_string(int typecode) { - if(typecode < 0 || typecode > 19) - typecode = 19; - - return type_names[typecode]; +char* typecode_string(int typecode) { + static char* type_names[25] = {"bool", "byte", "unsigned byte", + "short", "unsigned short", "int", + "unsigned int", "long", "unsigned long", + "long long", "unsigned long long", + "float", "double", "long double", + "complex float", "complex double", + "complex long double", "object", + "string", "unicode", "void", "ntypes", + "notype", "char", "unknown"}; + return typecode < 24 ? type_names[typecode] : type_names[24]; } -/* Make sure input has correct numeric type. Allow character and byte - * to match. Also allow int and long to match. +/* Make sure input has correct numpy type. Allow character and byte + * to match. Also allow int and long to match. This is deprecated. + * You should use PyArray_EquivTypenums() instead. */ int type_match(int actual_type, int desired_type) { return PyArray_EquivTypenums(actual_type, desired_type); @@ -2634,45 +2682,44 @@ /* Given a PyObject pointer, cast it to a PyArrayObject pointer if * legal. If not, set the python error string appropriately and - * return NULL./ + * return NULL. */ PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) { PyArrayObject* ary = NULL; - if (is_array(input) && (typecode == PyArray_NOTYPE || - PyArray_EquivTypenums(array_type(input), - typecode))) { - ary = (PyArrayObject*) input; - } - else if is_array(input) { - char* desired_type = typecode_string(typecode); - char* actual_type = typecode_string(array_type(input)); - PyErr_Format(PyExc_TypeError, - "Array of type '%s' required. Array of type '%s' given", - desired_type, actual_type); - ary = NULL; - } - else { - char * desired_type = typecode_string(typecode); - char * actual_type = pytype_string(input); - PyErr_Format(PyExc_TypeError, - "Array of type '%s' required. A %s was given", - desired_type, actual_type); - ary = NULL; - } + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input), typecode))) { + ary = (PyArrayObject*) input; + } + else if is_array(input) { + char* desired_type = typecode_string(typecode); + char* actual_type = typecode_string(array_type(input)); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. Array of type '%s' given", + desired_type, actual_type); + ary = NULL; + } + else { + char * desired_type = typecode_string(typecode); + char * actual_type = pytype_string(input); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. A '%s' was given", + desired_type, actual_type); + ary = NULL; + } return ary; } -/* Convert the given PyObject to a Numeric array with the given - * typecode. On Success, return a valid PyArrayObject* with the +/* Convert the given PyObject to a NumPy array with the given + * typecode. On success, return a valid PyArrayObject* with the * correct type. On failure, the python error string will be set and * the routine returns NULL. */ PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, - int* is_new_object) -{ + int* is_new_object) { PyArrayObject* ary = NULL; PyObject* py_obj; - if (is_array(input) && (typecode == PyArray_NOTYPE || type_match(array_type(input),typecode))) { + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input),typecode))) { ary = (PyArrayObject*) input; *is_new_object = 0; } @@ -2691,8 +2738,7 @@ * flag it as a new object and return the pointer. */ PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object, - int min_dims, int max_dims) -{ + int min_dims, int max_dims) { PyArrayObject* result; if (array_is_contiguous(ary)) { result = ary; @@ -2719,8 +2765,7 @@ int is_new1 = 0; int is_new2 = 0; PyArrayObject* ary2; - PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, - &is_new1); + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, &is_new1); if (ary1) { ary2 = make_contiguous(ary1, &is_new2, 0, 0); if ( is_new1 && is_new2) { @@ -2739,22 +2784,37 @@ int require_contiguous(PyArrayObject* ary) { int contiguous = 1; if (!array_is_contiguous(ary)) { - PyErr_SetString(PyExc_TypeError, "Array must be contiguous. A discontiguous array was given"); + PyErr_SetString(PyExc_TypeError, + "Array must be contiguous. A non-contiguous array was given"); contiguous = 0; } return contiguous; } +/* Require that a numpy array is not byte-swapped. If the array is + * not byte-swapped, return 1. Otherwise, set the python error string + * and return 0. + */ +int require_native(PyArrayObject* ary) { + int native = 1; + if (!array_is_native(ary)) { + PyErr_SetString(PyExc_TypeError, + "Array must have native byteorder. A byte-swapped array was given"); + native = 0; + } + return native; +} + /* Require the given PyArrayObject to have a specified number of * dimensions. If the array has the specified number of dimensions, * return 1. Otherwise, set the python error string and return 0. */ int require_dimensions(PyArrayObject* ary, int exact_dimensions) { int success = 1; - if (array_dimensions(ary) != exact_dimensions) { + if (array_numdims(ary) != exact_dimensions) { PyErr_Format(PyExc_TypeError, - "Array must be have %d dimensions. Given array has %d dimensions", - exact_dimensions, array_dimensions(ary)); + "Array must have %d dimensions. Given array has %d dimensions", + exact_dimensions, array_numdims(ary)); success = 0; } return success; @@ -2771,7 +2831,7 @@ char dims_str[255] = ""; char s[255]; for (i = 0; i < n && !success; i++) { - if (array_dimensions(ary) == exact_dimensions[i]) { + if (array_numdims(ary) == exact_dimensions[i]) { success = 1; } } @@ -2784,7 +2844,7 @@ strcat(dims_str,s); PyErr_Format(PyExc_TypeError, "Array must be have %s dimensions. Given array has %d dimensions", - dims_str, array_dimensions(ary)); + dims_str, array_numdims(ary)); } return success; } @@ -2793,7 +2853,7 @@ * array has the specified shape, return 1. Otherwise, set the python * error string and return 0. */ -int require_size(PyArrayObject* ary, npy_intp * size, int n) { +int require_size(PyArrayObject* ary, npy_intp* size, int n) { int i; int success = 1; int len; @@ -2880,15 +2940,13 @@ #include -#ifndef LLONG_MIN -# define LLONG_MIN LONG_LONG_MIN +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif #endif -#ifndef LLONG_MAX -# define LLONG_MAX LONG_LONG_MAX -#endif -#ifndef ULLONG_MAX -# define ULLONG_MAX ULONG_LONG_MAX -#endif SWIGINTERN int @@ -3076,7 +3134,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -3084,7 +3144,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } sa_get_aggregates(arg1,(int const (*))arg2,(int const (*))arg3,arg4); @@ -3171,7 +3233,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -3179,7 +3243,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (int*) array4->data; } { @@ -3187,7 +3253,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (float*) array5->data; } rs_strong_connections(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); @@ -3294,7 +3362,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -3302,7 +3372,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (int*) array4->data; } { @@ -3310,7 +3382,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (double*) array5->data; } rs_strong_connections(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); @@ -3366,7 +3440,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -3434,7 +3508,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'rs_strong_connections'.\n Possible C/C++ prototypes are:\n rs_strong_connections<(float)>(int const,float const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n rs_strong_connections<(double)>(int const,double const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'rs_strong_connections'.\n Possible C/C++ prototypes are:\n"" rs_strong_connections<(float)>(int const,float const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" rs_strong_connections<(double)>(int const,double const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -3511,7 +3585,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -3519,7 +3595,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -3527,7 +3605,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (float*) array4->data; } { @@ -3535,7 +3615,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (int*) array5->data; } { @@ -3543,7 +3625,9 @@ -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (int*) array6->data; } { @@ -3551,7 +3635,9 @@ -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_FLOAT, &is_new_object7); - if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + arg7 = (float*) array7->data; } { @@ -3559,7 +3645,9 @@ -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); - if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + arg8 = (int*) array8->data; } { @@ -3567,7 +3655,9 @@ -1 }; array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_INT, &is_new_object9); - if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1)) SWIG_fail; + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + arg9 = (int*) array9->data; } { @@ -3575,7 +3665,9 @@ -1 }; array10 = obj_to_array_contiguous_allow_conversion(obj9, PyArray_FLOAT, &is_new_object10); - if (!array10 || !require_dimensions(array10,1) || !require_size(array10,size,1)) SWIG_fail; + if (!array10 || !require_dimensions(array10,1) || !require_size(array10,size,1) + || !require_contiguous(array10) || !require_native(array10)) SWIG_fail; + arg10 = (float*) array10->data; } rs_interpolation(arg1,(int const (*))arg2,(int const (*))arg3,(float const (*))arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,(int const (*))arg8,(int const (*))arg9,(float const (*))arg10,arg11,arg12,arg13); @@ -3733,7 +3825,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -3741,7 +3835,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -3749,7 +3845,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (double*) array4->data; } { @@ -3757,7 +3855,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (int*) array5->data; } { @@ -3765,7 +3865,9 @@ -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (int*) array6->data; } { @@ -3773,7 +3875,9 @@ -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_DOUBLE, &is_new_object7); - if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + arg7 = (double*) array7->data; } { @@ -3781,7 +3885,9 @@ -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); - if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + arg8 = (int*) array8->data; } { @@ -3789,7 +3895,9 @@ -1 }; array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_INT, &is_new_object9); - if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1)) SWIG_fail; + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + arg9 = (int*) array9->data; } { @@ -3797,7 +3905,9 @@ -1 }; array10 = obj_to_array_contiguous_allow_conversion(obj9, PyArray_DOUBLE, &is_new_object10); - if (!array10 || !require_dimensions(array10,1) || !require_size(array10,size,1)) SWIG_fail; + if (!array10 || !require_dimensions(array10,1) || !require_size(array10,size,1) + || !require_contiguous(array10) || !require_native(array10)) SWIG_fail; + arg10 = (double*) array10->data; } rs_interpolation(arg1,(int const (*))arg2,(int const (*))arg3,(double const (*))arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(double const (*))arg10,arg11,arg12,arg13); @@ -3889,7 +3999,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 10); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -4005,7 +4115,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'rs_interpolation'.\n Possible C/C++ prototypes are:\n rs_interpolation<(float)>(int const,int const [],int const [],float const [],int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n rs_interpolation<(double)>(int const,int const [],int const [],double const [],int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'rs_interpolation'.\n Possible C/C++ prototypes are:\n"" rs_interpolation<(float)>(int const,int const [],int const [],float const [],int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" rs_interpolation<(double)>(int const,int const [],int const [],double const [],int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -4067,7 +4177,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -4075,7 +4187,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (int*) array4->data; } { @@ -4083,7 +4197,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (float*) array5->data; } sa_strong_connections(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); @@ -4190,7 +4306,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -4198,7 +4316,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (int*) array4->data; } { @@ -4206,7 +4326,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (double*) array5->data; } sa_strong_connections(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); @@ -4262,7 +4384,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -4330,7 +4452,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sa_strong_connections'.\n Possible C/C++ prototypes are:\n sa_strong_connections<(float)>(int const,float const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n sa_strong_connections<(double)>(int const,double const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sa_strong_connections'.\n Possible C/C++ prototypes are:\n"" sa_strong_connections<(float)>(int const,float const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" sa_strong_connections<(double)>(int const,double const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -4404,7 +4526,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -4412,7 +4536,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (int*) array4->data; } { @@ -4420,7 +4546,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (float*) array5->data; } { @@ -4428,7 +4556,9 @@ -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (int*) array6->data; } { @@ -4436,7 +4566,9 @@ -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); - if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + arg7 = (int*) array7->data; } { @@ -4444,7 +4576,9 @@ -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); - if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + arg8 = (float*) array8->data; } sa_smoother(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); @@ -4581,7 +4715,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -4589,7 +4725,9 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (int*) array4->data; } { @@ -4597,7 +4735,9 @@ -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + arg5 = (double*) array5->data; } { @@ -4605,7 +4745,9 @@ -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (int*) array6->data; } { @@ -4613,7 +4755,9 @@ -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); - if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + arg7 = (int*) array7->data; } { @@ -4621,7 +4765,9 @@ -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); - if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + arg8 = (double*) array8->data; } sa_smoother(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); @@ -4695,7 +4841,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -4793,7 +4939,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sa_smoother'.\n Possible C/C++ prototypes are:\n sa_smoother<(float)>(int const,float const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n sa_smoother<(double)>(int const,double const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sa_smoother'.\n Possible C/C++ prototypes are:\n"" sa_smoother<(float)>(int const,float const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" sa_smoother<(double)>(int const,double const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -4847,7 +4993,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -4855,7 +5003,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -4863,20 +5013,24 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (float*) array4->data; } { temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); - if (!temp5 || !require_contiguous(temp5)) SWIG_fail; - arg5 = (float*) temp5->data; + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (float*) array_data(temp5); } { npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (float*) array6->data; } ecode7 = SWIG_AsVal_int(obj6, &val7); @@ -4975,7 +5129,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -4983,7 +5139,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -4991,20 +5149,24 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (double*) array4->data; } { temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); - if (!temp5 || !require_contiguous(temp5)) SWIG_fail; - arg5 = (double*) temp5->data; + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (double*) array_data(temp5); } { npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (double*) array6->data; } ecode7 = SWIG_AsVal_int(obj6, &val7); @@ -5060,7 +5222,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 9); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -5172,7 +5334,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'gauss_seidel'.\n Possible C/C++ prototypes are:\n gauss_seidel<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],int const,int const,int const)\n gauss_seidel<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],int const,int const,int const)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'gauss_seidel'.\n Possible C/C++ prototypes are:\n"" gauss_seidel<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],int const,int const,int const)\n"" gauss_seidel<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],int const,int const,int const)\n"); return NULL; } @@ -5233,7 +5395,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -5241,7 +5405,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -5249,26 +5415,30 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (float*) array4->data; } { temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); - if (!temp5 || !require_contiguous(temp5)) SWIG_fail; - arg5 = (float*) temp5->data; + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (float*) array_data(temp5); } { npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (float*) array6->data; } { temp7 = obj_to_array_no_conversion(obj6,PyArray_FLOAT); - if (!temp7 || !require_contiguous(temp7)) SWIG_fail; - arg7 = (float*) temp7->data; + if (!temp7 || !require_contiguous(temp7) || !require_native(temp7)) SWIG_fail; + arg7 = (float*) array_data(temp7); } ecode8 = SWIG_AsVal_int(obj7, &val8); if (!SWIG_IsOK(ecode8)) { @@ -5378,7 +5548,9 @@ -1 }; array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_INT, &is_new_object2); - if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1)) SWIG_fail; + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + arg2 = (int*) array2->data; } { @@ -5386,7 +5558,9 @@ -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + arg3 = (int*) array3->data; } { @@ -5394,26 +5568,30 @@ -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + arg4 = (double*) array4->data; } { temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); - if (!temp5 || !require_contiguous(temp5)) SWIG_fail; - arg5 = (double*) temp5->data; + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (double*) array_data(temp5); } { npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + arg6 = (double*) array6->data; } { temp7 = obj_to_array_no_conversion(obj6,PyArray_DOUBLE); - if (!temp7 || !require_contiguous(temp7)) SWIG_fail; - arg7 = (double*) temp7->data; + if (!temp7 || !require_contiguous(temp7) || !require_native(temp7)) SWIG_fail; + arg7 = (double*) array_data(temp7); } ecode8 = SWIG_AsVal_int(obj7, &val8); if (!SWIG_IsOK(ecode8)) { @@ -5473,7 +5651,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 11); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -5607,7 +5785,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'jacobi'.\n Possible C/C++ prototypes are:\n jacobi<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],float [],int const,int const,int const,float const)\n jacobi<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],double [],int const,int const,int const,double const)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'jacobi'.\n Possible C/C++ prototypes are:\n"" jacobi<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],float [],int const,int const,int const,float const)\n"" jacobi<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],double [],int const,int const,int const,double const)\n"); return NULL; } From scipy-svn at scipy.org Mon Nov 12 23:04:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 22:04:57 -0600 (CST) Subject: [Scipy-svn] r3514 - trunk/scipy/linalg/tests Message-ID: <20071113040457.35C0339C1D6@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 22:04:54 -0600 (Mon, 12 Nov 2007) New Revision: 3514 Modified: trunk/scipy/linalg/tests/test_basic.py Log: use NumpyTestCase rather than the one from unittest Modified: trunk/scipy/linalg/tests/test_basic.py =================================================================== --- trunk/scipy/linalg/tests/test_basic.py 2007-11-11 22:15:52 UTC (rev 3513) +++ trunk/scipy/linalg/tests/test_basic.py 2007-11-13 04:04:54 UTC (rev 3514) @@ -29,8 +29,6 @@ from linalg import pinv, pinv2, solve_banded restore_path() -import unittest - def random(size): return rand(*size) @@ -416,7 +414,7 @@ #XXX: check definition of res assert_array_almost_equal(x,direct_lstsq(a,b,1)) -class test_tri(unittest.TestCase): +class test_tri(NumpyTestCase): def check_basic(self): assert_equal(tri(4),array([[1,0,0,0], [1,1,0,0], @@ -452,7 +450,7 @@ [1,0,0], [1,1,0]])) -class test_tril(unittest.TestCase): +class test_tril(NumpyTestCase): def check_basic(self): a = (100*get_mat(5)).astype('l') b = a.copy() @@ -474,7 +472,7 @@ b[k,l] = 0 assert_equal(tril(a,k=-2),b) -class test_triu(unittest.TestCase): +class test_triu(NumpyTestCase): def check_basic(self): a = (100*get_mat(5)).astype('l') b = a.copy() @@ -496,14 +494,14 @@ b[l,k] = 0 assert_equal(triu(a,k=-2),b) -class test_toeplitz(unittest.TestCase): +class test_toeplitz(NumpyTestCase): def check_basic(self): y = toeplitz([1,2,3]) assert_array_equal(y,[[1,2,3],[2,1,2],[3,2,1]]) y = toeplitz([1,2,3],[1,4,5]) assert_array_equal(y,[[1,4,5],[2,1,4],[3,2,1]]) -class test_hankel(unittest.TestCase): +class test_hankel(NumpyTestCase): def check_basic(self): y = hankel([1,2,3]) assert_array_equal(y,[[1,2,3],[2,3,0],[3,0,0]]) From scipy-svn at scipy.org Mon Nov 12 23:18:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 22:18:32 -0600 (CST) Subject: [Scipy-svn] r3515 - in trunk/scipy: lib/blas/tests lib/lapack/tests linalg/tests misc/tests optimize/tests sparse/tests weave/tests Message-ID: <20071113041832.292BD39C015@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 22:18:23 -0600 (Mon, 12 Nov 2007) New Revision: 3515 Modified: trunk/scipy/lib/blas/tests/test_fblas.py trunk/scipy/lib/lapack/tests/test_lapack.py trunk/scipy/linalg/tests/test_basic.py trunk/scipy/linalg/tests/test_fblas.py trunk/scipy/misc/tests/test_pilutil.py trunk/scipy/optimize/tests/test_zeros.py trunk/scipy/sparse/tests/test_sparse.py trunk/scipy/weave/tests/test_build_tools.py trunk/scipy/weave/tests/test_c_spec.py trunk/scipy/weave/tests/test_numpy_scalar_spec.py trunk/scipy/weave/tests/test_scxx_sequence.py trunk/scipy/weave/tests/test_size_check.py Log: switching test_cases to CapWords Modified: trunk/scipy/lib/blas/tests/test_fblas.py =================================================================== --- trunk/scipy/lib/blas/tests/test_fblas.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/lib/blas/tests/test_fblas.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -40,7 +40,7 @@ ################################################## ### Test blas ?axpy -class base_axpy(NumpyTestCase): +class BaseAxpy(NumpyTestCase): def check_default_a(self): x = arange(3.,dtype=self.dtype) y = arange(3.,dtype=x.dtype) @@ -92,21 +92,21 @@ assert(0) try: - class test_saxpy(base_axpy): + class TestSaxpy(BaseAxpy): blas_func = fblas.saxpy dtype = float32 except AttributeError: - class test_saxpy: pass -class test_daxpy(base_axpy): + class TestSaxpy: pass +class TestDaxpy(BaseAxpy): blas_func = fblas.daxpy dtype = float64 try: - class test_caxpy(base_axpy): + class TestCaxpy(BaseAxpy): blas_func = fblas.caxpy dtype = complex64 except AttributeError: - class test_caxpy: pass -class test_zaxpy(base_axpy): + class TestCaxpy: pass +class TestZaxpy(BaseAxpy): blas_func = fblas.zaxpy dtype = complex128 @@ -114,7 +114,7 @@ ################################################## ### Test blas ?scal -class base_scal(NumpyTestCase): +class BaseScal(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) real_x = x*3. @@ -135,21 +135,21 @@ # should catch error and never get here assert(0) try: - class test_sscal(base_scal): + class TestSscal(BaseScal): blas_func = fblas.sscal dtype = float32 except AttributeError: - class test_sscal: pass -class test_dscal(base_scal): + class TestSscal: pass +class TestDscal(BaseScal): blas_func = fblas.dscal dtype = float64 try: - class test_cscal(base_scal): + class TestCscal(BaseScal): blas_func = fblas.cscal dtype = complex64 except AttributeError: - class test_cscal: pass -class test_zscal(base_scal): + class TestCscal: pass +class TestZscal(BaseScal): blas_func = fblas.zscal dtype = complex128 @@ -159,7 +159,7 @@ ################################################## ### Test blas ?copy -class base_copy(NumpyTestCase): +class BaseCopy(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -206,21 +206,21 @@ # assert_array_almost_equal(x,y) try: - class test_scopy(base_copy): + class TestScopy(BaseCopy): blas_func = fblas.scopy dtype = float32 except AttributeError: - class test_scopy: pass -class test_dcopy(base_copy): + class TestScopy: pass +class TestDcopy(BaseCopy): blas_func = fblas.dcopy dtype = float64 try: - class test_ccopy(base_copy): + class TestCcopy(BaseCopy): blas_func = fblas.ccopy dtype = complex64 except AttributeError: - class test_ccopy: pass -class test_zcopy(base_copy): + class TestCcopy: pass +class TestZcopy(BaseCopy): blas_func = fblas.zcopy dtype = complex128 @@ -228,7 +228,7 @@ ################################################## ### Test blas ?swap -class base_swap(NumpyTestCase): +class BaseSwap(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -282,21 +282,21 @@ assert(0) try: - class test_sswap(base_swap): + class TestSswap(BaseSwap): blas_func = fblas.sswap dtype = float32 except AttributeError: - class test_sswap: pass -class test_dswap(base_swap): + class TestSswap: pass +class TestDswap(BaseSwap): blas_func = fblas.dswap dtype = float64 try: - class test_cswap(base_swap): + class TestCswap(BaseSwap): blas_func = fblas.cswap dtype = complex64 except AttributeError: - class test_cswap: pass -class test_zswap(base_swap): + class TestCswap: pass +class TestZswap(BaseSwap): blas_func = fblas.zswap dtype = complex128 @@ -304,7 +304,7 @@ ### Test blas ?gemv ### This will be a mess to test all cases. -class base_gemv(NumpyTestCase): +class BaseGemv(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): mult = array(1, dtype = self.dtype) if self.dtype in [complex64, complex128]: @@ -386,21 +386,21 @@ pass try: - class test_sgemv(base_gemv): + class TestSgemv(BaseGemv): blas_func = fblas.sgemv dtype = float32 except AttributeError: - class test_sgemv: pass -class test_dgemv(base_gemv): + class TestSgemv: pass +class TestDgemv(BaseGemv): blas_func = fblas.dgemv dtype = float64 try: - class test_cgemv(base_gemv): + class TestCgemv(BaseGemv): blas_func = fblas.cgemv dtype = complex64 except AttributeError: - class test_cgemv: pass -class test_zgemv(base_gemv): + class TestCgemv: pass +class TestZgemv(BaseGemv): blas_func = fblas.zgemv dtype = complex128 @@ -409,7 +409,7 @@ ### Test blas ?ger ### This will be a mess to test all cases. -class base_ger(NumpyTestCase): +class BaseGer(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): from numpy.random import normal alpha = array(1., dtype = self.dtype) @@ -449,10 +449,10 @@ except: pass -class test_sger(base_ger): +class TestSger(BaseGer): blas_func = fblas.sger dtype = float32 -class test_dger(base_ger): +class TestDger(BaseGer): blas_func = fblas.dger dtype = float64 """ @@ -461,7 +461,7 @@ ### This will be a mess to test all cases. """ -class base_ger_complex(base_ger): +class BaseGerComplex(BaseGer): def get_data(self,x_stride=1,y_stride=1): from numpy.random import normal alpha = array(1+1j, dtype = self.dtype) @@ -493,24 +493,24 @@ # self.blas_func(x,y,a,incy=2) # assert_array_almost_equal(desired_a,a) -class test_cgeru(base_ger_complex): +class TestCgeru(BaseGerComplex): blas_func = fblas.cgeru dtype = complex64 def transform(self,x): return x -class test_zgeru(base_ger_complex): +class TestZgeru(BaseGerComplex): blas_func = fblas.zgeru dtype = complex128 def transform(self,x): return x -class test_cgerc(base_ger_complex): +class TestCgerc(BaseGerComplex): blas_func = fblas.cgerc dtype = complex64 def transform(self,x): return conjugate(x) -class test_zgerc(base_ger_complex): +class TestZgerc(BaseGerComplex): blas_func = fblas.zgerc dtype = complex128 def transform(self,x): Modified: trunk/scipy/lib/lapack/tests/test_lapack.py =================================================================== --- trunk/scipy/lib/lapack/tests/test_lapack.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/lib/lapack/tests/test_lapack.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -27,7 +27,7 @@ #class _test_ev: pass -class _test_lapack(NumpyTestCase, +class _TestLapack(NumpyTestCase, _test_ev, _test_gev): @@ -84,16 +84,16 @@ **************************************************************** """ else: - class test_flapack_double(_test_lapack): + class TestFlapackDouble(_TestLapack): lapack = PrefixWrapper(flapack,'d') decimal = 12 - class test_flapack_float(_test_lapack): + class TestFlapackFloat(_TestLapack): lapack = PrefixWrapper(flapack,'s') decimal = 5 - class test_flapack_complex(_test_lapack): + class TestFlapackComplex(_TestLapack): lapack = PrefixWrapper(flapack,'c') decimal = 5 - class test_flapack_double_complex(_test_lapack): + class TestFlapackDoubleComplex(_TestLapack): lapack = PrefixWrapper(flapack,'z') decimal = 12 @@ -109,16 +109,16 @@ **************************************************************** """ else: - class test_clapack_double(_test_lapack): + class TestClapackDouble(_TestLapack): lapack = PrefixWrapper(clapack,'d') decimal = 12 - class test_clapack_float(_test_lapack): + class TestClapackFloat(_TestLapack): lapack = PrefixWrapper(clapack,'s') decimal = 5 - class test_clapack_complex(_test_lapack): + class TestClapackComplex(_TestLapack): lapack = PrefixWrapper(clapack,'c') decimal = 5 - class test_clapack_double_complex(_test_lapack): + class TestClapackDoubleComplex(_TestLapack): lapack = PrefixWrapper(clapack,'z') decimal = 12 Modified: trunk/scipy/linalg/tests/test_basic.py =================================================================== --- trunk/scipy/linalg/tests/test_basic.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/linalg/tests/test_basic.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -414,7 +414,7 @@ #XXX: check definition of res assert_array_almost_equal(x,direct_lstsq(a,b,1)) -class test_tri(NumpyTestCase): +class TestTri(NumpyTestCase): def check_basic(self): assert_equal(tri(4),array([[1,0,0,0], [1,1,0,0], @@ -450,7 +450,7 @@ [1,0,0], [1,1,0]])) -class test_tril(NumpyTestCase): +class TestTril(NumpyTestCase): def check_basic(self): a = (100*get_mat(5)).astype('l') b = a.copy() @@ -472,7 +472,7 @@ b[k,l] = 0 assert_equal(tril(a,k=-2),b) -class test_triu(NumpyTestCase): +class TestTriu(NumpyTestCase): def check_basic(self): a = (100*get_mat(5)).astype('l') b = a.copy() @@ -494,14 +494,14 @@ b[l,k] = 0 assert_equal(triu(a,k=-2),b) -class test_toeplitz(NumpyTestCase): +class TestToeplitz(NumpyTestCase): def check_basic(self): y = toeplitz([1,2,3]) assert_array_equal(y,[[1,2,3],[2,1,2],[3,2,1]]) y = toeplitz([1,2,3],[1,4,5]) assert_array_equal(y,[[1,4,5],[2,1,4],[3,2,1]]) -class test_hankel(NumpyTestCase): +class TestHankel(NumpyTestCase): def check_basic(self): y = hankel([1,2,3]) assert_array_equal(y,[[1,2,3],[2,3,0],[3,0,0]]) Modified: trunk/scipy/linalg/tests/test_fblas.py =================================================================== --- trunk/scipy/linalg/tests/test_fblas.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/linalg/tests/test_fblas.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -40,7 +40,7 @@ ################################################## ### Test blas ?axpy -class base_axpy(NumpyTestCase): +class BaseAxpy(NumpyTestCase): def check_default_a(self): x = arange(3.,dtype=self.dtype) y = arange(3.,dtype=x.dtype) @@ -92,21 +92,21 @@ assert(0) try: - class test_saxpy(base_axpy): + class TestSaxpy(BaseAxpy): blas_func = fblas.saxpy dtype = float32 except AttributeError: - class test_saxpy: pass -class test_daxpy(base_axpy): + class TestSaxpy: pass +class TestDaxpy(BaseAxpy): blas_func = fblas.daxpy dtype = float64 try: - class test_caxpy(base_axpy): + class TestCaxpy(BaseAxpy): blas_func = fblas.caxpy dtype = complex64 except AttributeError: - class test_caxpy: pass -class test_zaxpy(base_axpy): + class TestCaxpy: pass +class TestZaxpy(BaseAxpy): blas_func = fblas.zaxpy dtype = complex128 @@ -114,7 +114,7 @@ ################################################## ### Test blas ?scal -class base_scal(NumpyTestCase): +class BaseScal(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) real_x = x*3. @@ -135,21 +135,21 @@ # should catch error and never get here assert(0) try: - class test_sscal(base_scal): + class TestSscal(BaseScal): blas_func = fblas.sscal dtype = float32 except AttributeError: - class test_sscal: pass -class test_dscal(base_scal): + class TestSscal: pass +class TestDscal(BaseScal): blas_func = fblas.dscal dtype = float64 try: - class test_cscal(base_scal): + class TestCscal(BaseScal): blas_func = fblas.cscal dtype = complex64 except AttributeError: - class test_cscal: pass -class test_zscal(base_scal): + class TestCscal: pass +class TestZscal(BaseScal): blas_func = fblas.zscal dtype = complex128 @@ -159,7 +159,7 @@ ################################################## ### Test blas ?copy -class base_copy(NumpyTestCase): +class BaseCopy(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -206,21 +206,21 @@ # assert_array_equal(x,y) try: - class test_scopy(base_copy): + class TestScopy(BaseCopy): blas_func = fblas.scopy dtype = float32 except AttributeError: - class test_scopy: pass -class test_dcopy(base_copy): + class TestScopy: pass +class TestDcopy(BaseCopy): blas_func = fblas.dcopy dtype = float64 try: - class test_ccopy(base_copy): + class TestCcopy(BaseCopy): blas_func = fblas.ccopy dtype = complex64 except AttributeError: - class test_ccopy: pass -class test_zcopy(base_copy): + class TestCcopy: pass +class TestZcopy(BaseCopy): blas_func = fblas.zcopy dtype = complex128 @@ -228,7 +228,7 @@ ################################################## ### Test blas ?swap -class base_swap(NumpyTestCase): +class BaseSwap(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -282,21 +282,21 @@ assert(0) try: - class test_sswap(base_swap): + class TestSswap(BaseSwap): blas_func = fblas.sswap dtype = float32 except AttributeError: - class test_sswap: pass -class test_dswap(base_swap): + class TestSswap: pass +class TestDswap(BaseSwap): blas_func = fblas.dswap dtype = float64 try: - class test_cswap(base_swap): + class TestCswap(BaseSwap): blas_func = fblas.cswap dtype = complex64 except AttributeError: - class test_cswap: pass -class test_zswap(base_swap): + class TestCswap: pass +class TestZswap(BaseSwap): blas_func = fblas.zswap dtype = complex128 @@ -304,7 +304,7 @@ ### Test blas ?gemv ### This will be a mess to test all cases. -class base_gemv(NumpyTestCase): +class BaseGemv(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): mult = array(1, dtype = self.dtype) if self.dtype in [complex64, complex128]: @@ -386,21 +386,21 @@ pass try: - class test_sgemv(base_gemv): + class TestSgemv(BaseGemv): blas_func = fblas.sgemv dtype = float32 except AttributeError: - class test_sgemv: pass -class test_dgemv(base_gemv): + class TestSgemv: pass +class TestDgemv(BaseGemv): blas_func = fblas.dgemv dtype = float64 try: - class test_cgemv(base_gemv): + class TestCgemv(BaseGemv): blas_func = fblas.cgemv dtype = complex64 except AttributeError: - class test_cgemv: pass -class test_zgemv(base_gemv): + class TestCgemv: pass +class TestZgemv(BaseGemv): blas_func = fblas.zgemv dtype = complex128 @@ -409,7 +409,7 @@ ### Test blas ?ger ### This will be a mess to test all cases. -class base_ger(NumpyTestCase): +class BaseGer(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): from numpy.random import normal alpha = array(1., dtype = self.dtype) @@ -449,10 +449,10 @@ except: pass -class test_sger(base_ger): +class TestSger(BaseGer): blas_func = fblas.sger dtype = float32 -class test_dger(base_ger): +class TestDger(BaseGer): blas_func = fblas.dger dtype = float64 """ @@ -461,7 +461,7 @@ ### This will be a mess to test all cases. """ -class base_ger_complex(base_ger): +class BaseGerComplex(BaseGer): def get_data(self,x_stride=1,y_stride=1): from numpy.random import normal alpha = array(1+1j, dtype = self.dtype) @@ -493,24 +493,24 @@ # self.blas_func(x,y,a,incy=2) # assert_array_almost_equal(desired_a,a) -class test_cgeru(base_ger_complex): +class TestCgeru(BaseGerComplex): blas_func = fblas.cgeru dtype = complex64 def transform(self,x): return x -class test_zgeru(base_ger_complex): +class TestZgeru(BaseGerComplex): blas_func = fblas.zgeru dtype = complex128 def transform(self,x): return x -class test_cgerc(base_ger_complex): +class TestCgerc(BaseGerComplex): blas_func = fblas.cgerc dtype = complex64 def transform(self,x): return conjugate(x) -class test_zgerc(base_ger_complex): +class TestZgerc(BaseGerComplex): blas_func = fblas.zgerc dtype = complex128 def transform(self,x): Modified: trunk/scipy/misc/tests/test_pilutil.py =================================================================== --- trunk/scipy/misc/tests/test_pilutil.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/misc/tests/test_pilutil.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -10,7 +10,7 @@ datapath = os.path.dirname(__file__) -class test_pilutil(ParametricTestCase): +class TestPILUtil(ParametricTestCase): def test_imresize(self): im = N.random.random((10,20)) for T in N.sctypes['float'] + [float]: Modified: trunk/scipy/optimize/tests/test_zeros.py =================================================================== --- trunk/scipy/optimize/tests/test_zeros.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/optimize/tests/test_zeros.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -51,7 +51,7 @@ functions = [f2,f3,f4,f5,f6] fstrings = ['f2','f3','f4','f5','f6'] -class test_basic(NumpyTestCase) : +class TestBasic(NumpyTestCase) : def run_test(self, method, name): a = .5 b = sqrt(3) Modified: trunk/scipy/sparse/tests/test_sparse.py =================================================================== --- trunk/scipy/sparse/tests/test_sparse.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/sparse/tests/test_sparse.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -26,7 +26,7 @@ from scipy.linsolve import splu restore_path() -class _test_cs: +class _TestCs: def setUp(self): self.dat = matrix([[1,0,0,2],[3,0,1,0],[0,2,0,0]],'d') self.datsp = self.spmatrix(self.dat) @@ -388,7 +388,7 @@ assert_array_equal(numpy.diag(A),extract_diagonal(self.spmatrix(A))) -class _test_horiz_slicing: +class _TestHorizSlicing: """Tests horizontal slicing (e.g. [:, 0]). Tests for individual sparse matrix types that implement this should derive from this class. """ @@ -422,7 +422,7 @@ assert caught == 2 -class _test_vert_slicing: +class _TestVertSlicing: """Tests vertical slicing (e.g. [:, 0]). Tests for individual sparse matrix types that implement this should derive from this class. """ @@ -648,7 +648,7 @@ -class test_csr(_test_cs, _test_horiz_slicing, _test_vert_slicing, +class TestCsr(_TestCs, _TestHorizSlicing, _TestVertSlicing, _test_slicing, _test_arith, NumpyTestCase): spmatrix = csr_matrix @@ -714,7 +714,7 @@ def check_empty(self): """Test manipulating empty matrices. Fails in SciPy SVN <= r1768 """ - # This test should be made global (in _test_cs), but first we + # This test should be made global (in _TestCs), but first we # need a uniform argument order / syntax for constructing an # empty sparse matrix. (coo_matrix is currently different). shape = (5, 5) @@ -757,7 +757,7 @@ assert b.shape == (2,2) assert_equal( ab, aa[i0,i1[0]:i1[1]] ) -class test_csc(_test_cs, _test_horiz_slicing, _test_vert_slicing, +class TestCsc(_TestCs, _TestHorizSlicing, _TestVertSlicing, _test_slicing, _test_arith, NumpyTestCase): spmatrix = csc_matrix @@ -799,7 +799,7 @@ def check_empty(self): """Test manipulating empty matrices. Fails in SciPy SVN <= r1768 """ - # This test should be made global (in _test_cs), but first we + # This test should be made global (in _TestCs), but first we # need a uniform argument order / syntax for constructing an # empty sparse matrix. (coo_matrix is currently different). shape = (5, 5) @@ -841,7 +841,7 @@ assert_equal(b.shape, (2,2)) assert_equal( ab, aa[i0,i1[0]:i1[1]] ) -class test_dok(_test_cs, NumpyTestCase): +class TestDok(_TestCs, NumpyTestCase): spmatrix = dok_matrix def check_mult(self): @@ -948,7 +948,7 @@ assert_equal(caught,5) -class test_lil(_test_cs, _test_horiz_slicing, NumpyTestCase, +class TestLil(_TestCs, _TestHorizSlicing, NumpyTestCase, ParametricTestCase): spmatrix = lil_matrix Modified: trunk/scipy/weave/tests/test_build_tools.py =================================================================== --- trunk/scipy/weave/tests/test_build_tools.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/weave/tests/test_build_tools.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -38,7 +38,7 @@ assert(d == d2) assert(is_writable(d)) -class test_configure_temp_dir(test_configure_build_dir): +class TestConfigureTempDir(TestConfigureBuildDir): def check_default(self): " default behavior returns tempdir" # this'll fail if the temp directory isn't writable. Modified: trunk/scipy/weave/tests/test_c_spec.py =================================================================== --- trunk/scipy/weave/tests/test_c_spec.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/weave/tests/test_c_spec.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -570,84 +570,84 @@ c = test(b) assert( c['hello'] == 5) -class test_msvc_int_converter(test_int_converter): +class TestMsvcIntConverter(TestIntConverter): compiler = 'msvc' -class test_unix_int_converter(test_int_converter): +class TestUnixIntConverter(TestIntConverter): compiler = '' -class test_gcc_int_converter(test_int_converter): +class TestGccIntConverter(TestIntConverter): compiler = 'gcc' -class test_msvc_float_converter(test_float_converter): +class TestMsvcFloatConverter(TestFloatConverter): compiler = 'msvc' -class test_msvc_float_converter(test_float_converter): +class TestMsvcFloatConverter(TestFloatConverter): compiler = 'msvc' -class test_unix_float_converter(test_float_converter): +class TestUnixFloatConverter(TestFloatConverter): compiler = '' -class test_gcc_float_converter(test_float_converter): +class TestGccFloatConverter(TestFloatConverter): compiler = 'gcc' -class test_msvc_complex_converter(test_complex_converter): +class TestMsvcComplexConverter(TestComplexConverter): compiler = 'msvc' -class test_unix_complex_converter(test_complex_converter): +class TestUnixComplexConverter(TestComplexConverter): compiler = '' -class test_gcc_complex_converter(test_complex_converter): +class TestGccComplexConverter(TestComplexConverter): compiler = 'gcc' -class test_msvc_file_converter(test_file_converter): +class TestMsvcFileConverter(TestFileConverter): compiler = 'msvc' -class test_unix_file_converter(test_file_converter): +class TestUnixFileConverter(TestFileConverter): compiler = '' -class test_gcc_file_converter(test_file_converter): +class TestGccFileConverter(TestFileConverter): compiler = 'gcc' -class test_msvc_callable_converter(test_callable_converter): +class TestMsvcCallableConverter(TestCallableConverter): compiler = 'msvc' -class test_unix_callable_converter(test_callable_converter): +class TestUnixCallableConverter(TestCallableConverter): compiler = '' -class test_gcc_callable_converter(test_callable_converter): +class TestGccCallableConverter(TestCallableConverter): compiler = 'gcc' -class test_msvc_sequence_converter(test_sequence_converter): +class TestMsvcSequenceConverter(TestSequenceConverter): compiler = 'msvc' -class test_unix_sequence_converter(test_sequence_converter): +class TestUnixSequenceConverter(TestSequenceConverter): compiler = '' -class test_gcc_sequence_converter(test_sequence_converter): +class TestGccSequenceConverter(TestSequenceConverter): compiler = 'gcc' -class test_msvc_string_converter(test_string_converter): +class TestMsvcStringConverter(TestStringConverter): compiler = 'msvc' -class test_unix_string_converter(test_string_converter): +class TestUnixStringConverter(TestStringConverter): compiler = '' -class test_gcc_string_converter(test_string_converter): +class TestGccStringConverter(TestStringConverter): compiler = 'gcc' -class test_msvc_list_converter(test_list_converter): +class TestMsvcListConverter(TestListConverter): compiler = 'msvc' -class test_unix_list_converter(test_list_converter): +class TestUnixListConverter(TestListConverter): compiler = '' -class test_gcc_list_converter(test_list_converter): +class TestGccListConverter(TestListConverter): compiler = 'gcc' -class test_msvc_tuple_converter(test_tuple_converter): +class TestMsvcTupleConverter(TestTupleConverter): compiler = 'msvc' -class test_unix_tuple_converter(test_tuple_converter): +class TestUnixTupleConverter(TestTupleConverter): compiler = '' -class test_gcc_tuple_converter(test_tuple_converter): +class TestGccTupleConverter(TestTupleConverter): compiler = 'gcc' -class test_msvc_dict_converter(test_dict_converter): +class TestMsvcDictConverter(TestDictConverter): compiler = 'msvc' -class test_unix_dict_converter(test_dict_converter): +class TestUnixDictConverter(TestDictConverter): compiler = '' -class test_gcc_dict_converter(test_dict_converter): +class TestGccDictConverter(TestDictConverter): compiler = 'gcc' -class test_msvc_instance_converter(test_instance_converter): +class TestMsvcInstanceConverter(TestInstanceConverter): compiler = 'msvc' -class test_unix_instance_converter(test_instance_converter): +class TestUnixInstanceConverter(TestInstanceConverter): compiler = '' -class test_gcc_instance_converter(test_instance_converter): +class TestGccInstanceConverter(TestInstanceConverter): compiler = 'gcc' def setup_test_location(): Modified: trunk/scipy/weave/tests/test_numpy_scalar_spec.py =================================================================== --- trunk/scipy/weave/tests/test_numpy_scalar_spec.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/weave/tests/test_numpy_scalar_spec.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -112,14 +112,14 @@ result = inline_tools.inline("return_val=1.0/a;",['a']) assert( result==.5-.5j) -class test_msvc_numpy_complex_scalar_converter( - test_numpy_complex_scalar_converter): +class TestMsvcNumpyComplexScalarConverter( + TestNumpyComplexScalarConverter): compiler = 'msvc' -class test_unix_numpy_complex_scalar_converter( - test_numpy_complex_scalar_converter): +class TestUnixNumpyComplexScalarConverter( + TestNumpyComplexScalarConverter): compiler = '' -class test_gcc_numpy_complex_scalar_converter( - test_numpy_complex_scalar_converter): +class TestGccNumpyComplexScalarConverter( + TestNumpyComplexScalarConverter): compiler = 'gcc' Modified: trunk/scipy/weave/tests/test_scxx_sequence.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_sequence.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/weave/tests/test_scxx_sequence.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -20,7 +20,7 @@ from UserList import UserList -class _test_sequence_base(NumpyTestCase): +class _TestSequenceBase(NumpyTestCase): seq_type = None def check_conversion(self,level=5): @@ -179,7 +179,7 @@ print 'weave:', t2 - t1 assert list(b) == list(a) -class test_tuple(_test_sequence_base): +class TestTuple(_TestSequenceBase): seq_type = tuple def check_set_item_operator_equal_fail(self,level=5): @@ -225,7 +225,7 @@ except IndexError: pass -class test_list(_test_sequence_base): +class TestList(_TestSequenceBase): seq_type = list def check_append_passed_item(self,level=5): a = [] Modified: trunk/scipy/weave/tests/test_size_check.py =================================================================== --- trunk/scipy/weave/tests/test_size_check.py 2007-11-13 04:04:54 UTC (rev 3514) +++ trunk/scipy/weave/tests/test_size_check.py 2007-11-13 04:18:23 UTC (rev 3515) @@ -98,7 +98,7 @@ x,y = (5,5),(4,5) self.generic_error_test(x,y) -class test_dummy_array(test_binary_op_size): +class TestDummyArray(TestBinaryOpSize): def generic_test(self,x,y,desired): if type(x) is type(()): x = ones(x) From scipy-svn at scipy.org Mon Nov 12 23:33:12 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 22:33:12 -0600 (CST) Subject: [Scipy-svn] r3516 - in trunk/scipy: maxentropy ndimage optimize sandbox/newoptimize sandbox/plt sandbox/xplt sparse stats weave Message-ID: <20071113043312.8025F39C293@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 22:33:01 -0600 (Mon, 12 Nov 2007) New Revision: 3516 Modified: trunk/scipy/maxentropy/maxentropy.py trunk/scipy/ndimage/_ni_support.py trunk/scipy/ndimage/filters.py trunk/scipy/ndimage/fourier.py trunk/scipy/ndimage/interpolation.py trunk/scipy/ndimage/measurements.py trunk/scipy/ndimage/morphology.py trunk/scipy/optimize/minpack.py trunk/scipy/optimize/tnc.py trunk/scipy/sandbox/newoptimize/tnc.py trunk/scipy/sandbox/plt/wxplt.py trunk/scipy/sandbox/xplt/gist.py trunk/scipy/sandbox/xplt/movie.py trunk/scipy/sandbox/xplt/pl3d.py trunk/scipy/sandbox/xplt/plwf.py trunk/scipy/sandbox/xplt/shapetest.py trunk/scipy/sandbox/xplt/slice3.py trunk/scipy/sparse/sparse.py trunk/scipy/stats/stats.py trunk/scipy/weave/accelerate_tools.py trunk/scipy/weave/bytecodecompiler.py Log: use identity tests (not equality tests) for None Modified: trunk/scipy/maxentropy/maxentropy.py =================================================================== --- trunk/scipy/maxentropy/maxentropy.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/maxentropy/maxentropy.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -639,9 +639,9 @@ def __init__(self, f=None, samplespace=None): super(model, self).__init__() - if f != None and samplespace != None: + if f is not None and samplespace is not None: self.setfeaturesandsamplespace(f, samplespace) - elif f != None and samplespace is None: + elif f is not None and samplespace is None: raise ValueError, "not supported: specify both features and" \ " sample space or neither" @@ -1550,7 +1550,7 @@ if self.verbose >= 2: print "(using Deylon acceleration. n is " + str(n) + " instead of " + str(k - self.a_0_hold) + "...)" if self.ruppertaverage: - if self.stepdecreaserate == None: + if self.stepdecreaserate is None: # Use log n / n as the default. Note: this requires a # different scaling of a_0 than a stepsize decreasing # as, e.g., n^(-1/2). Modified: trunk/scipy/ndimage/_ni_support.py =================================================================== --- trunk/scipy/ndimage/_ni_support.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/ndimage/_ni_support.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -64,12 +64,12 @@ import warnings def _get_output(output, input, output_type = None, shape = None): - if output_type != None: + if output_type is not None: msg = "'output_type' argument is deprecated." msg += " Assign type to 'output' instead." raise RuntimeError, msg warnings.warn(msg, DeprecationWarning) - if output == None: + if output is None: output = output_type elif ((type(output) is not type(types.TypeType)) or output.dtype != output_type): Modified: trunk/scipy/ndimage/filters.py =================================================================== --- trunk/scipy/ndimage/filters.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/ndimage/filters.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -516,8 +516,8 @@ if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' origins = _ni_support._normalize_sequence(origin, input.ndim) - if footprint == None: - if size == None: + if footprint is None: + if size is None: raise RuntimeError, "no footprint or filter size provided" sizes = _ni_support._normalize_sequence(size, input.ndim) footprint = numpy.ones(sizes, dtype = bool) @@ -652,8 +652,8 @@ if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' origins = _ni_support._normalize_sequence(origin, input.ndim) - if footprint == None: - if size == None: + if footprint is None: + if size is None: raise RuntimeError, "no footprint or filter size provided" sizes = _ni_support._normalize_sequence(size, input.ndim) footprint = numpy.ones(size, dtype = bool) Modified: trunk/scipy/ndimage/fourier.py =================================================================== --- trunk/scipy/ndimage/fourier.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/ndimage/fourier.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -35,7 +35,7 @@ import _nd_image def _get_output_fourier(output, input): - if output == None: + if output is None: if input.dtype.type in [numpy.complex64, numpy.complex128, numpy.float32]: output = numpy.zeros(input.shape, dtype = input.dtype) @@ -55,7 +55,7 @@ return output, return_value def _get_output_fourier_complex(output, input): - if output == None: + if output is None: if input.dtype.type in [numpy.complex64, numpy.complex128]: output = numpy.zeros(input.shape, dtype = input.dtype) else: Modified: trunk/scipy/ndimage/interpolation.py =================================================================== --- trunk/scipy/ndimage/interpolation.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/ndimage/interpolation.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -126,7 +126,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if output_shape == None: + if output_shape is None: output_shape = input.shape if input.ndim < 1 or len(output_shape) < 1: raise RuntimeError, 'input and output rank must be > 0' @@ -229,7 +229,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if output_shape == None: + if output_shape is None: output_shape = input.shape if input.ndim < 1 or len(output_shape) < 1: raise RuntimeError, 'input and output rank must be > 0' Modified: trunk/scipy/ndimage/measurements.py =================================================================== --- trunk/scipy/ndimage/measurements.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/ndimage/measurements.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -48,7 +48,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if structure == None: + if structure is None: structure = morphology.generate_binary_structure(input.ndim, 1) structure = numpy.asarray(structure, dtype = bool) if structure.ndim != input.ndim: @@ -65,7 +65,7 @@ output = numpy.int32 output, return_value = _ni_support._get_output(output, input) max_label = _nd_image.label(input, structure, output) - if return_value == None: + if return_value is None: return max_label else: return return_value, max_label @@ -136,7 +136,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -155,7 +155,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -188,7 +188,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -208,7 +208,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -241,7 +241,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -264,7 +264,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -288,7 +288,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -316,7 +316,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -338,7 +338,7 @@ input = numpy.asarray(input) if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' - if labels != None: + if labels is not None: labels = numpy.asarray(labels) labels = _broadcast(labels, input.shape) @@ -363,7 +363,7 @@ input = numpy.asarray(input) if input.dtype.type not in [numpy.uint8, numpy.uint16]: raise TypeError, 'only 8 and 16 unsigned inputs are supported' - if structure == None: + if structure is None: structure = morphology.generate_binary_structure(input.ndim, 1) structure = numpy.asarray(structure, dtype = bool) if structure.ndim != input.ndim: Modified: trunk/scipy/ndimage/morphology.py =================================================================== --- trunk/scipy/ndimage/morphology.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/ndimage/morphology.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -128,7 +128,7 @@ origin[ii] = -origin[ii] if not structure.shape[ii] & 1: origin[ii] -= 1 - if mask != None: + if mask is not None: msk = numpy.asarray(mask) msk = mask.astype(numpy.int8) if msk is mask: @@ -141,7 +141,7 @@ return return_value else: tmp_in = numpy.zeros(input.shape, bool) - if return_value == None: + if return_value is None: tmp_out = output else: tmp_out = numpy.zeros(input.shape, bool) @@ -155,7 +155,7 @@ changed = _nd_image.binary_erosion(tmp_in, structure, mask, tmp_out, border_value, origin, invert, cit, 0) ii += 1 - if return_value != None: + if return_value is not None: return tmp_out @@ -190,7 +190,7 @@ modified at each iteration. """ input = numpy.asarray(input) - if structure == None: + if structure is None: structure = generate_binary_structure(input.ndim, 1) origin = _ni_support._normalize_sequence(origin, input.ndim) structure = numpy.asarray(structure) @@ -544,7 +544,7 @@ metric = 3 else: raise RuntimeError, 'distance metric not supported' - if sampling != None: + if sampling is not None: sampling = _ni_support._normalize_sequence(sampling, tmp1.ndim) sampling = numpy.asarray(sampling, dtype = numpy.float64) if not sampling.flags.contiguous: @@ -554,7 +554,7 @@ else: ft = None if return_distances: - if distances == None: + if distances is None: if metric == 1: dt = numpy.zeros(tmp1.shape, dtype = numpy.float64) else: Modified: trunk/scipy/optimize/minpack.py =================================================================== --- trunk/scipy/optimize/minpack.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/optimize/minpack.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -9,7 +9,7 @@ def check_func(thefunc, x0, args, numinputs, output_shape=None): res = atleast_1d(thefunc(*((x0[:numinputs],)+args))) - if (output_shape != None) and (shape(res) != output_shape): + if (output_shape is not None) and (shape(res) != output_shape): if (output_shape[0] != 1): if len(output_shape) > 1: if output_shape[1] == 1: Modified: trunk/scipy/optimize/tnc.py =================================================================== --- trunk/scipy/optimize/tnc.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/optimize/tnc.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -213,8 +213,8 @@ """ low, up : the bounds (lists of floats) - if low == None, the lower bounds are removed. - if up == None, the upper bounds are removed. + if low is None, the lower bounds are removed. + if up is None, the upper bounds are removed. low and up defaults to None """ low = [0]*n @@ -232,13 +232,13 @@ else: up[i] = u - if scale == None: + if scale is None: scale = [] - if offset == None: + if offset is None: offset = [] - if maxfun == None: + if maxfun is None: maxfun = max(100, 10*len(x0)) rc, nf, x = moduleTNC.minimize(func_and_grad, x0, low, up, scale, offset, Modified: trunk/scipy/sandbox/newoptimize/tnc.py =================================================================== --- trunk/scipy/sandbox/newoptimize/tnc.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/newoptimize/tnc.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -202,8 +202,8 @@ low, up : the bounds (lists of floats) set low[i] to -HUGE_VAL to remove the lower bound set up[i] to HUGE_VAL to remove the upper bound - if low == None, the lower bounds are removed. - if up == None, the upper bounds are removed. + if low is None, the lower bounds are removed. + if up is None, the upper bounds are removed. low and up defaults to None """ low = [0]*n @@ -219,13 +219,13 @@ else: up[i] = u - if scale == None: + if scale is None: scale = [] - if offset == None: + if offset is None: offset = [] - if maxfun == None: + if maxfun is None: maxfun = max(100, 10*len(x0)) return moduleTNC.minimize(func_and_grad, x0, low, up, scale, offset, Modified: trunk/scipy/sandbox/plt/wxplt.py =================================================================== --- trunk/scipy/sandbox/plt/wxplt.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/plt/wxplt.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -585,7 +585,7 @@ def printout(self, paper=None): """Print current plot.""" - if paper != None: + if paper is not None: self.print_data.SetPaperId(paper) pdd = wx.wxPrintDialogData() pdd.SetPrintData(self.print_data) Modified: trunk/scipy/sandbox/xplt/gist.py =================================================================== --- trunk/scipy/sandbox/xplt/gist.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/xplt/gist.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -8,7 +8,7 @@ # SCIPY # 10/15/04 teo Added convert_bounding box. # 09/28/03 teo Changed eps file to accept noepsi when not available. -# 09/28/03 teo Changed all == None to is None and != None to not is None +# 09/28/03 teo Changed all is None to is None and is not None to not is None # # CHANGES: # 11/08/04 mdh plh: Change test if color is a list; also test if array. Modified: trunk/scipy/sandbox/xplt/movie.py =================================================================== --- trunk/scipy/sandbox/xplt/movie.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/xplt/movie.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -86,7 +86,7 @@ elapsed0 = array(elapsed, copy = 1) i = i + 1 more = draw_frame (i) - if lims != None: + if lims is not None: limits (lims [0], lims [1], lims [2], lims [3]) else: limits (square = 1) @@ -110,7 +110,7 @@ this_frame = zeros (3) i = i + 1 more = draw_frame (i) - if lims != None: + if lims is not None: limits (lims [0], lims [1], lims [2], lims [3]) else : limits (square = 1) Modified: trunk/scipy/sandbox/xplt/pl3d.py =================================================================== --- trunk/scipy/sandbox/xplt/pl3d.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/xplt/pl3d.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -191,9 +191,9 @@ except : _orient3_phi = - pi / 4. - if kw.has_key ("phi") and kw ["phi"] == None : + if kw.has_key ("phi") and kw ["phi"] is None : kw ["phi"] = _orient3_phi - if kw.has_key ("theta") and kw ["theta"] == None : + if kw.has_key ("theta") and kw ["theta"] is None : kw ["theta"] = _orient3_theta if not kw.has_key ("phi") and not kw.has_key ("theta") : phi = _orient3_phi @@ -257,7 +257,7 @@ global _draw3_list, _draw3_view, _light3_list, _draw3_n - if view != None : + if view is not None : view = view [0:len (view)] # Copies view else : view = _draw3_view + _light3_list @@ -318,30 +318,30 @@ if len (kw) > 0 : kwds = kw [0] old = _draw3_list [_draw3_nv:] [0:5] flags = 0 - if kwds.has_key ("ambient") and kwds ["ambient"] != None : + if kwds.has_key ("ambient") and kwds ["ambient"] is not None : ambient = kwds ["ambient"] if not is_scalar (ambient) : raise _AmbientError, "ambient light level must be scalar." flags = flags | 1 _draw3_list [_draw3_nv] = ambient - if kwds.has_key ("diffuse") and kwds ["diffuse"] != None : + if kwds.has_key ("diffuse") and kwds ["diffuse"] is not None : diffuse = kwds ["diffuse"] if not is_scalar (diffuse) : raise _DiffuseError, "diffuse light level must be scalar." flags = flags | 2 _draw3_list [_draw3_nv + 1 ] = diffuse - if kwds.has_key ("specular") and kwds ["specular"] != None : + if kwds.has_key ("specular") and kwds ["specular"] is not None : specular = kwds ["specular"] flags = flags | 4 else : specular = _draw3_list [_draw3_nv + 2] - if kwds.has_key ("spower") and kwds ["spower"] != None : + if kwds.has_key ("spower") and kwds ["spower"] is not None : spower = kwds ["spower"] flags = flags | 8 else : spower = _draw3_list [_draw3_nv + 3] - if kwds.has_key ("sdir") and kwds ["sdir"] != None : + if kwds.has_key ("sdir") and kwds ["sdir"] is not None : sdir = kwds ["sdir"] dims = shape (sdir) if dims == 0 or len (dims) == 2 and dims [1] != 3 : @@ -595,7 +595,7 @@ # do optional perspective projection zc = getzc3_ () - if zc != None : + if zc is not None : if len (shp) == 2 : z = tmpxyz [:, 2] zc = maximum (zc - z, 1.e-35) # protect behind camera, avoid zero divide @@ -742,7 +742,7 @@ window3 (current_window ()) gnomon (_default_gnomon) lims = draw3 (1) - if lims == None : + if lims is None : return else : limits (lims [0], lims [1], lims [2], lims [3]) @@ -902,7 +902,7 @@ # calls rather than the interactive setup calls set_draw3_ (1) list = _draw3_list [_draw3_n:] - no_lims = lims == None + no_lims = lims is None first = 1 # ZCM Feb. 1997: Because Gist command 'limits' seems to # misbehave and be timing dependent, I have added the kludge @@ -915,12 +915,12 @@ first = 0 else : fv = fnc (list [1]) - if fv != None and lims != None : + if fv is not None and lims is not None : lims = [min (fv [0], lims [0]), max (fv [1], lims [1]), min (fv [2], lims [2]), max (fv [3], lims [3])] - elif fv != None : + elif fv is not None : lims = fv else : fnc (list [1]) Modified: trunk/scipy/sandbox/xplt/plwf.py =================================================================== --- trunk/scipy/sandbox/xplt/plwf.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/xplt/plwf.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -110,7 +110,7 @@ jedge = tmp x = transpose (array (xyz1 [0])) y = transpose (array (xyz1 [1])) - if fill != None : + if fill is not None : fill = transpose (fill) else : x = xyz1 [0] @@ -123,12 +123,12 @@ if iedge < 0.0 : x = reverse (x, 0) y = reverse (y, 0) - if fill != None : + if fill is not None : fill = reverse (fill, 0) if jedge < 0.0 : x = reverse (x, 1) y = reverse (y, 1) - if fill != None : + if fill is not None : fill = reverse (fill, 1) xmax = maxelt_ (x) xmin = minelt_ (x) @@ -151,7 +151,7 @@ dif = (ydif - xdif) / 2. xmin = xmin - dif xmax = xmax + dif - if fill != None : + if fill is not None : if len (fill.shape) == 1: fill = bytscl (fill) else: @@ -159,29 +159,29 @@ l = fill.shape [1] fill = reshape ( bytscl (ravel (fill)), (k, l)) if cull == 0 : #transparent mesh - if ecolor != None : + if ecolor is not None : plm (y, x, color = ecolor) else : plm (y, x) - elif ecolor != None and ewidth != None and cmax != None : + elif ecolor is not None and ewidth is not None and cmax is not None : plf (fill, y, x, edges = edges, ecolor = ecolor, ewidth = ewidth, cmin = 0.0, cmax = cmax, legend = "") - elif ecolor != None and ewidth != None : + elif ecolor is not None and ewidth is not None : plf (fill, y, x, edges = edges, ewidth = ewidth, cmin = 0.0, ecolor = ecolor, legend = "") - elif ecolor != None and cmax != None : + elif ecolor is not None and cmax is not None : plf (fill, y, x, edges = edges, ecolor = ecolor, cmin = 0.0, cmax = cmax, legend = "") - elif ewidth != None and cmax != None : + elif ewidth is not None and cmax is not None : plf (fill, y, x, edges = edges, ewidth = ewidth, cmin = 0.0, cmax = cmax, legend = "") - elif ecolor != None : + elif ecolor is not None : plf (fill, y, x, edges = edges, ecolor = ecolor, cmin = 0.0, legend = "") - elif ewidth != None : + elif ewidth is not None : plf (fill, y, x, edges = edges, ewidth = ewidth, cmin = 0.0, legend = "") - elif cmax != None : + elif cmax is not None : plf (fill, y, x, edges = edges, cmin = 0.0, cmax = cmax, legend = "") else : @@ -256,8 +256,8 @@ raise _Xyz_wfError, "impossible dimensions for z array" nx = shape (z) [0] ny = shape (z) [1] - if y == None or x == None : - if x != None or y != None : + if y is None or x is None : + if x is not None or y is not None : raise _Xyz_wfError, "either give y,x both or neither" x = span (0, ny - 1, ny, nx) y = transpose (span (0, nx - 1, nx, ny)) @@ -265,7 +265,7 @@ raise _Xyz_wfError, "x, y, and z must all have same dimensions" xyscl = max (maxelt_ (x) - minelt_ (x), maxelt_ (y) - minelt_ (y)) - if scale != None: + if scale is not None: xyscl = xyscl * scale dz = maxelt_ (z) - minelt_ (z) zscl= dz + (dz == 0.0) Modified: trunk/scipy/sandbox/xplt/shapetest.py =================================================================== --- trunk/scipy/sandbox/xplt/shapetest.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/xplt/shapetest.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -17,7 +17,7 @@ # This routine should be able to tell you the size of any object: def no_of_dims (x) : - if x == None : return 0 + if x is None : return 0 if isinstance(x, ndarray) : return len (x.shape) if isinstance(x, (list, tuple)) : return 1 # I don't know if there are any other possibilities. Modified: trunk/scipy/sandbox/xplt/slice3.py =================================================================== --- trunk/scipy/sandbox/xplt/slice3.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sandbox/xplt/slice3.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -126,8 +126,8 @@ """ dims = shape (x) - if len (dims) == 1 and y != None and len (x) == len (y) \ - and z != None and len(x) == len (z) and kw.has_key ("verts") : + if len (dims) == 1 and y is not None and len (x) == len (y) \ + and z is not None and len(x) == len (z) and kw.has_key ("verts") : virtuals = [xyz3_irreg, getv3_irreg, getc3_irreg, iterator3_irreg] dims = kw ["verts"] @@ -160,11 +160,11 @@ xyz = x dims = dims [1:4] elif len (dims) == 1 and len (x) == 3 and type (x [0]) == IntType \ - and y != None and z != None and len (y) == len (z) == 3 : + and y is not None and z is not None and len (y) == len (z) == 3 : xyz = array ([y, z]) dims = (1 + x [0], 1 + x [1], 1 + x [2]) virtuals [0] = xyz3_unif - elif len (dims) == 1 and y != None and z != None and len (y.shape) == 1 \ + elif len (dims) == 1 and y is not None and z is not None and len (y.shape) == 1 \ and len (z.shape) == 1 and x.typed == y.typed == \ z.typed == Float : # regular mesh with unequally spaced points @@ -173,8 +173,8 @@ virtuals [0] = xyz3_unif else : if len (dims) != 3 or min (dims) < 2 or \ - y == None or len (shape (y)) != 3 or shape (y) != dims or \ - z == None or len (shape (z)) != 3 or shape (z) != dims: + y is None or len (shape (y)) != 3 or shape (y) != dims or \ + z is None or len (shape (z)) != 3 or shape (z) != dims: raise _Mesh3Error, "X,Y,Z are not viable 3D coordinate mesh arrays" xyz = array ( [x, y, z]) dim_cell = (dims [0] - 1, dims [1] - 1, dims [2] - 1) @@ -340,7 +340,7 @@ if need_clist : fcolor = args [0] - if fcolor == None : + if fcolor is None : need_clist = 0 else : fcolor = None @@ -374,7 +374,7 @@ results = [] chunk = iterator3 (m3) cell_offsets = [0, 0, 0, 0] - while chunk != None : + while chunk is not None : # get the values of the slicing function at the vertices of # this chunk @@ -400,7 +400,7 @@ # front, and negative if in back. else : fs = fslice (m3, chunk) - if node == 1 and fcolor != None and fcolor != FunctionType : + if node == 1 and fcolor is not None and fcolor != FunctionType : # need vertex-centered data col = getv3 (fcolor, m3, chunk) if type (col) == ListType : @@ -416,7 +416,7 @@ cell_offset = fs [2] # will need cell list if fslice did not compute xyz - got_xyz = _xyz3 != None + got_xyz = _xyz3 is not None need_clist = need_clist or not got_xyz # If the m3 mesh is totally unstructured, the chunk should be @@ -508,7 +508,7 @@ clist = None i8.append (len (results)) # Treat regular case as hex - if clist != None : + if clist is not None : # we need to save: # (1) the absolute cell indices of the cells in clist # (2) the corresponding ncells-by-2-by-2-by-2 (by-3-by-2, @@ -538,7 +538,7 @@ indices,axis=0), (no_cells, 2, 2, 2)) _xyz3 = new_xyz3 del new_xyz3 - if col != None : + if col is not None : col = reshape (take (ravel (col), indices,axis=0), (no_cells, 2, 2, 2)) # NB: col represents node colors, and is only used # if those are requested. @@ -549,12 +549,12 @@ else : clist = None nchunk = nchunk + 1 - need_vert_col = col != None + need_vert_col = col is not None results.append ( [clist, fs, _xyz3, col]) else : results.append ( [None, None, None, None]) chunk = iterator3 (m3, chunk) - # endwhile chunk != None + # endwhile chunk is not None # collect the results of the chunking loop if not ntotal and not (ntotal8 + ntotal6 + ntotal5 + ntotal4) : @@ -590,10 +590,10 @@ if need_clist : clist [l:k] = results [itot [i] [j]] [0] fs [l:k] = reshape (results [itot [i] [j]] [1], (k - l, _no_verts [i])) - if xyz != None : + if xyz is not None : xyz [l:k] = reshape (results [itot [i] [j]] [2], (k - l, 3, _no_verts [i])) - if col != None : + if col is not None : col [l:k] = reshape (results [itot [i] [j]] [3], (k - l, _no_verts [i])) if not got_xyz : @@ -633,7 +633,7 @@ take (ravel (xyz [:, 2]), upper,axis=0) * fsl), (len (lower),)) xyz = new_xyz del new_xyz - if col != None : + if col is not None : # Extract subset of the data the same way col = take (ravel (col), lower,axis=0) * fsu - \ take (ravel (col), upper,axis=0) * fsl @@ -669,7 +669,7 @@ xyz1 [:,1] = take (ravel (xyz [:,1]), order,axis=0) xyz1 [:,2] = take (ravel (xyz [:,2]), order,axis=0) xyz = xyz1 - if col != None : + if col is not None : col = take (col, order,axis=0) edges = take (edges, order,axis=0) pattern = take (pattern, order,axis=0) @@ -703,15 +703,15 @@ xyzverts = xyz # finally, deal with any fcolor function - if fcolor == None : + if fcolor is None : new_results.append ( [nverts, xyzverts, None]) continue # if some polys have been split, need to split clist as well if len (list) > len (clist) : clist = take (clist, take (cells, list, axis=0),axis=0) - if col == None : - if nointerp == None : + if col is None : + if nointerp is None : if type (fcolor) == FunctionType : col = fcolor (m3, clist + cell_offsets [i], lower, upper, fsl, fsu, pattern - 1) @@ -731,7 +731,7 @@ for i in range (len (new_results)) : nv_n = nv_n + len (new_results [i] [0]) xyzv_n = xyzv_n + shape (new_results [i] [1]) [0] - if new_results [i] [2] != None : + if new_results [i] [2] is not None : col_n = col_n + len (new_results [i] [2]) nverts = zeros (nv_n, Int) xyzverts = zeros ( (xyzv_n, 3), Float ) @@ -747,7 +747,7 @@ xyzv_n2 = shape (new_results [i] [1]) [0] nverts [nv_n1:nv_n1 + nv_n2] = new_results [i] [0] xyzverts [xyzv_n1:xyzv_n1 + xyzv_n2] = new_results [i] [1] - if new_results [i] [2] != None : + if new_results [i] [2] is not None : col_n2 = len (new_results [i] [2]) col [col_n1:col_n1 + col_n2] = new_results [i] [2] col_n1 = col_n1 + col_n2 @@ -882,7 +882,7 @@ color = kw ["color"] else : color = None - if color != None : + if color is not None : # col = array (len (nverts), Float ) if shape (color) == (ncx - 1, ncy - 1) : col = color @@ -1013,7 +1013,7 @@ global _chunk3_limit - if chunk == None : + if chunk is None : dims = m3 [1] [0] # [ni,nj,nk] cell dimensions [ni, nj, nk] = [dims [0], dims [1], dims [2]] njnk = nj * nk @@ -1039,7 +1039,7 @@ nk = chunk [3,2] njnk = nj * nk offsets = array ( [njnk, nj, 1], Int) - if clist != None : + if clist is not None : # add offset for this chunk to clist and return return sum (offsets * ( chunk [0] - 1),axis=0) + clist @@ -1136,14 +1136,14 @@ global _chunk3_limit - if clist != None: + if clist is not None: return clist dims = m3 [1] [0] # ncells by _no_verts array of subscripts # (or a list of from one to four of same) if type (dims) != ListType : - if chunk == None: # get the first chunk + if chunk is None: # get the first chunk return [ [0, min (shape (dims) [0], _chunk3_limit)], arange (0, min (shape (dims) [0], _chunk3_limit), dtype = Int)] @@ -1158,7 +1158,7 @@ dtype = Int)] else : totals = m3 [1] [3] # cumulative totals of numbers of cells - if chunk == None : + if chunk is None : return [ [0, min (totals [0], _chunk3_limit)], arange (0, min (totals [0], _chunk3_limit), dtype = Int)] @@ -1380,7 +1380,7 @@ no_cells = shape (indices) [0] indices = ravel (indices) corners = take (ravel (fi [i - 1]), indices,axis=0) - if l == None : + if l is None : return 0.125 * sum (transpose (reshape (corners, (no_cells, 8))),axis=0) else : # interpolate corner values to get edge values @@ -1467,7 +1467,7 @@ no_cells = shp [0] indices = ravel (indices) corners = take (fi [i - 1], indices,axis=0) - if l == None : + if l is None : return (1. / shp [1]) * transpose ((sum (transpose (reshape (corners, (no_cells, shp [1]))) [0:shp [1]],axis=0))) else : @@ -1615,7 +1615,7 @@ If CLEAR = 1, clear the display list first. If EDGES = 1, plot the edges. The algorithm is to apply slice2x repeatedly to the surface. - If color == None, then bytscl the palette into N + 1 colors + If color is None, then bytscl the palette into N + 1 colors and send each of the slices to pl3tree with the appropriate color. If color == "bg", will plot only the edges. If CMIN is given, use it instead of the minimum z actually @@ -1635,13 +1635,13 @@ # 1. Get contour colors if type (contours) == IntType : n = contours - if cmin != None : + if cmin is not None : vcmin = cmin minz = min (xyzverts [:, 2]) else : vcmin = min (xyzverts [:, 2]) minz = vcmin - if cmax != None : + if cmax is not None : vcmax = cmax maxz = max (xyzverts [:, 2]) else : @@ -1692,14 +1692,14 @@ imax = n # now make sure that the minimum and maximum contour levels computed # are not outside the axis limits. - if zaxis_min != None and zaxis_min > vc [imin] : + if zaxis_min is not None and zaxis_min > vc [imin] : for i in range (imin, imax) : if i + 1 < imax and zaxis_min > vc [i + 1] : imin = i + 1 else : break vc [imin] = zaxis_min - if zaxis_max != None and zaxis_max < vc [imax - 1] : + if zaxis_max is not None and zaxis_max < vc [imax - 1] : for i in range (imax - imin) : if imax - 2 >= imin and zaxis_max < vc [imax - 2] : imax = imax - 1 @@ -1709,19 +1709,19 @@ for i in range (imin, imax) : [nv, xyzv, d1, nvb, xyzvb, d2] = \ slice2x (array ( [0., 0., 1., vc [i]], Float) , nv, xyzv, None) - if i == imin and zaxis_min != None and zaxis_min == vc [i]: + if i == imin and zaxis_min is not None and zaxis_min == vc [i]: # Don't send the "back" surface if it's below zaxis_min. continue else: - if color == None : + if color is None : pl3tree (nvb, xyzvb, (ones (len (nvb)) * colors [i]).astype ('B'), split = 0, edges = edges) else : # N. B. Force edges to be on, otherwise the graph is empty. pl3tree (nvb, xyzvb, "bg", split = 0, edges = 1) - if zaxis_max == None or vc [imax - 1] < zaxis_max: + if zaxis_max is None or vc [imax - 1] < zaxis_max: # send "front" surface if it's not beyond zaxis_max - if color == None : + if color is None : pl3tree (nv, xyzv, (ones (len (nv)) * colors [i]).astype ('B'), split = 0, edges = edges) else : @@ -1750,7 +1750,7 @@ If CLEAR == 1, clear the display list first. If EDGES == 1, plot the edges. The algorithm is to apply slice2x repeatedly to the surface. - If color == None, then bytscl the palette into N + 1 colors + If color is None, then bytscl the palette into N + 1 colors and send each of the slices to pl3tree with the appropriate color. If color == "bg", will plot only the edges. If CMIN is given, use it instead of the minimum c actually @@ -1770,13 +1770,13 @@ # 1. Get contour colors if type (contours) == IntType : n = contours - if cmin != None : + if cmin is not None : vcmin = cmin minz = min (values) else : vcmin = min (values) minz = vcmin - if cmax != None : + if cmax is not None : vcmax = cmax maxz = max (values) else : @@ -1828,14 +1828,14 @@ imax = n # now make sure that the minimum and maximum contour levels computed # are not outside the axis limits. - if caxis_min != None and caxis_min > vc [imin] : + if caxis_min is not None and caxis_min > vc [imin] : for i in range (imin, imax) : if i + 1 < imax and caxis_min > vc [i + 1] : imin = i + 1 else : break vc [imin] = caxis_min - if caxis_max != None and caxis_max < vc [imax - 1] : + if caxis_max is not None and caxis_max < vc [imax - 1] : for i in range (imax - imin) : if imax - 2 >= imin and caxis_max < vc [imax - 2] : imax = imax - 1 @@ -1849,19 +1849,19 @@ break [nv, xyzv, vals, nvb, xyzvb, d2] = \ slice2x (vc [i], nv, xyzv, vals) - if i == imin and caxis_min != None and caxis_min == vc [i]: + if i == imin and caxis_min is not None and caxis_min == vc [i]: # Don't send the "back" surface if it's below caxis_min. continue else: - if color == None : + if color is None : pl3tree (nvb, xyzvb, (ones (len (nvb)) * colors [i]).astype ('B'), split = 0, edges = edges) else : # N. B. Force edges to be on, otherwise the graph is empty. pl3tree (nvb, xyzvb, "bg", split = 0, edges = 1) - if caxis_max == None or vc [imax - 1] < caxis_max: + if caxis_max is None or vc [imax - 1] < caxis_max: # send "front" surface if it's not beyond caxis_max - if color == None : + if color is None : pl3tree (nv, xyzv, (ones (len (nv)) * colors [i]).astype ('B'), split = 0, edges = edges) else : @@ -1947,7 +1947,7 @@ x = xyztmp [:, 0] y = xyztmp [:, 1] z = xyztmp [:, 2] - if values == None : + if values is None : # xyzverts [:, 0] = x # xyzverts [:, 1] = y # xyzverts [:, 2] = z @@ -1993,10 +1993,10 @@ if shape (xyzverts) [0] != sum (nverts,axis=0) or sum (less (nverts, 3),axis=0) or \ nverts.dtype != Int : raise _Pl3surfError, "illegal or inconsistent polygon list" - if values != None and len (values) != len (nverts) : + if values is not None and len (values) != len (nverts) : raise _Pl3surfError, "illegal or inconsistent polygon color values" - if values != None : + if values is not None : values = array (values, Float ) clear3 ( ) @@ -2091,9 +2091,9 @@ xyzverts = array (xyzverts, Float ) if values == "background" : values = "bg" - elif values != None and values != "bg" : + elif values is not None and values != "bg" : values = array (values, values.dtype) - if plane != None : + if plane is not None : plane = plane.astype (Float) if shape (xyzverts) [0] != sum (nverts,axis=0) or sum (less (nverts, 3),axis=0) > 0 or \ @@ -2112,7 +2112,7 @@ array_set (list, cumsum (nverts,axis=0) [0:-1], ones (len (nverts), Int)) tpc = values.dtype values = (histogram (cumsum (list,axis=0), values) / nverts).astype (tpc) - if plane != None : + if plane is not None : if (len (shape (plane)) != 1 or shape (plane) [0] != 4) : raise _Pl3treeError, "illegal plane format, try plane3 function" @@ -2595,9 +2595,9 @@ # back_tree= tree [1] is the part behind plane # inplane_leaf= tree [2] is the part in the plane itself # front_tree= tree [3] is the part in front of plane - if tree == None or tree == [] : + if tree is None or tree == [] : return None - if tree [0] == None or tree [0] == [] : + if tree [0] is None or tree [0] == [] : # only the leaf is non-nil (but not a plane) return _pl3leaf ( tree [2], 1, minmax) @@ -2616,33 +2616,33 @@ q1 = _pl3tree (tree [3], minmax) q2 = _pl3leaf (tree [2], 0, minmax) q3 = _pl3tree (tree [1], minmax) - if q1 != None : - if q2 != None and q3 == None : + if q1 is not None : + if q2 is not None and q3 is None : return [min (q2 [0], q1 [0]), max (q2 [1], q1 [1]), min (q2 [2], q1 [2]), max (q2 [3], q1 [3])] - elif q2 == None and q3 != None : + elif q2 is None and q3 is not None : return [min (q3 [0], q1 [0]), max (q3 [1], q1 [1]), min (q3 [2], q1 [2]), max (q3 [3], q1 [3])] - elif q2 != None and q3 != None : + elif q2 is not None and q3 is not None : return [min (q3 [0], q2 [0], q1 [0]), max (q3 [1], q2 [1], q1 [1]), min (q3 [2], q2 [2], q1 [2]), max (q3 [3], q2 [3], q1 [3])] else : return q1 - elif q2 != None : - if q3 == None : + elif q2 is not None : + if q3 is None : return q2 else : return [min (q2 [0], q3 [0]), max (q2 [1], q3 [1]), min (q2 [2], q3 [2]), max (q2 [3], q3 [3])] - elif q3 != None : + elif q3 is not None : return q3 else : return None @@ -2764,7 +2764,7 @@ # when one coordinate is insignificant with # respect to the others and doesn't have significant digits. # It is awfully hard to come up with a numerical criterion for this.) - if item [2] == None or not_plane or has_multiple_components (): + if item [2] is None or not_plane or has_multiple_components (): minx = minmax [0] maxx = minmax [1] miny = minmax [2] @@ -2774,7 +2774,7 @@ _xyzverts [:, 0] = (_xyzverts [:, 0] - minx) / (maxx - minx) _xyzverts [:, 1] = (_xyzverts [:, 1] - miny) / (maxy - miny) _xyzverts [:, 2] = (_xyzverts [:, 2] - minz) / (maxz - minz) - if item [2] == None : + if item [2] is None : # this is an isosurface to be shaded (no values specified) _xyzverts = get3_xy (_xyzverts, 1) # accumulate nverts and values @@ -2827,22 +2827,22 @@ return [_list, _vlist, item [6]] def _pl3tree_add (leaf, plane, tree) : - if tree != None and tree != [] and \ - not is_scalar (tree) and tree [0] != None : + if tree is not None and tree != [] and \ + not is_scalar (tree) and tree [0] is not None : # tree has slicing plane, slice new leaf or plane and descend [back, leaf1] = _pl3tree_slice (tree [0], leaf) if back : - if len (tree) >= 2 and tree [1] != None and tree [1] != [] : + if len (tree) >= 2 and tree [1] is not None and tree [1] != [] : _pl3tree_add (back, plane, tree [1]) else : tree [1] = [None, [], back, []] if (leaf1) : - if len (tree) >= 4 and tree [3] != None and tree [3] != [] : + if len (tree) >= 4 and tree [3] is not None and tree [3] != [] : _pl3tree_add (leaf1, plane, tree [3]) else : tree [3] = [None, [], leaf1, []] - elif plane != None : + elif plane is not None : # tree is just a leaf, but this leaf has slicing plane tree [0] = plane tmp = tree [2] @@ -2863,17 +2863,17 @@ for ll in leaf : # each item in the leaf list is itself a list nvf = ll [0] - if nvf != None : + if nvf is not None : nvb = array (nvf, copy = 1) else : nvb = None xyzf = ll [1] - if xyzf != None : + if xyzf is not None : xyzb = array (xyzf, copy = 1) else : xyzb = None valf = ll [2] - if valf != None : + if valf is not None : tpc = valf.dtype.char valb = array (valf, copy = 1) else : @@ -2892,17 +2892,17 @@ ll6 = 0 [nvf, xyzf, valf, nvb, xyzb, valb] = \ slice2x (plane, nvf, xyzf, valf) - if valf != None: + if valf is not None: valf = valf.astype (tpc) - if valb != None: + if valb is not None: valb = valb.astype (tpc) - if nvf != None : - if frnt != None : + if nvf is not None : + if frnt is not None : frnt = [ [nvf, xyzf, valf, ll [3], ll4, ll5, ll6]] + frnt else : frnt = [ [nvf, xyzf, valf, ll [3], ll4, ll5, ll6]] - if nvb != None : - if back != None : + if nvb is not None : + if back is not None : back = [ [nvb, xyzb, valb, ll [3], ll4, ll5, ll6]] + back else : back = [ [nvb, xyzb, valb, ll [3], ll4, ll5, ll6]] @@ -2915,7 +2915,7 @@ _draw3_n = get_draw3_n_ () if len (_draw3_list) >= _draw3_n : tree = _draw3_list [_draw3_n:] - if tree == None or tree == [] or tree [0] != pl3tree : + if tree is None or tree == [] or tree [0] != pl3tree : print "" # raise _Pl3tree_prtError, "" else : @@ -2923,16 +2923,16 @@ _pl3tree_prt (tree, 0) def pl3_other_prt(tree = None): - if tree == None: + if tree is None: pl3tree_prt () else : - if tree == None or tree == []: + if tree is None or tree == []: print "" else : _pl3tree_prt (tree, 0) def _pl3tree_prt (tree, depth) : - if tree == None or tree == [] : + if tree is None or tree == [] : return indent = (" " * (1 + 2 * depth)) [0:-1] print indent + "+DEPTH= " + `depth` @@ -2942,7 +2942,7 @@ back = tree [1] list = tree [2] frnt = tree [3] - if back == None or back == [] : + if back is None or back == [] : print indent + "back = []" else : _pl3tree_prt (back, depth + 1) @@ -2954,7 +2954,7 @@ print indent + "nverts= " + `shape (leaf [1]) [0]` + \ ", nvals= " + `len (leaf [2])` - if frnt == None or frnt == [] : + if frnt is None or frnt == [] : print indent + "frnt = []" else : _pl3tree_prt (frnt, depth + 1) Modified: trunk/scipy/sparse/sparse.py =================================================================== --- trunk/scipy/sparse/sparse.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/sparse/sparse.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -454,7 +454,7 @@ elif axis == 1: # sum over rows return self * asmatrix(ones((n, 1), dtype=self.dtype)) - elif axis == None: + elif axis is None: # sum over rows and columns return ( self * asmatrix(ones((n, 1), dtype=self.dtype)) ).sum() else: @@ -818,7 +818,7 @@ """ # The spmatrix base class already does axis=0 and axis=1 efficiently # so we only do the case axis=None here - if axis == None: + if axis is None: return self.data[:self.indptr[-1]].sum() else: return spmatrix.sum(self,axis) Modified: trunk/scipy/stats/stats.py =================================================================== --- trunk/scipy/stats/stats.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/stats/stats.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -1051,7 +1051,7 @@ Returns: (array of bin counts, bin-minimum, min-width, #-points-outside-range) """ a = np.ravel(a) # flatten any >1D arrays - if (defaultlimits != None): + if (defaultlimits is not None): lowerreallimit = defaultlimits[0] upperreallimit = defaultlimits[1] binsize = (upperreallimit-lowerreallimit) / float(numbins) Modified: trunk/scipy/weave/accelerate_tools.py =================================================================== --- trunk/scipy/weave/accelerate_tools.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/weave/accelerate_tools.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -399,7 +399,7 @@ def function_code(self): code = self.wrapped_code() for T in self.used: - if T != None and T.module_init_code: + if T is not None and T.module_init_code: self.customize.add_module_init_code(T.module_init_code) return code Modified: trunk/scipy/weave/bytecodecompiler.py =================================================================== --- trunk/scipy/weave/bytecodecompiler.py 2007-11-13 04:18:23 UTC (rev 3515) +++ trunk/scipy/weave/bytecodecompiler.py 2007-11-13 04:33:01 UTC (rev 3516) @@ -738,7 +738,7 @@ code = self.codeobject.co_code bytes = len(code) pc = 0 - while pc != None and pc < bytes: + while pc is not None and pc < bytes: pc = self.evaluate(pc,code) # ----------------------------------------------- From scipy-svn at scipy.org Mon Nov 12 23:36:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 22:36:32 -0600 (CST) Subject: [Scipy-svn] r3517 - trunk/scipy/sandbox/xplt Message-ID: <20071113043632.3306F39C29C@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 22:36:30 -0600 (Mon, 12 Nov 2007) New Revision: 3517 Modified: trunk/scipy/sandbox/xplt/gist.py Log: typo Modified: trunk/scipy/sandbox/xplt/gist.py =================================================================== --- trunk/scipy/sandbox/xplt/gist.py 2007-11-13 04:33:01 UTC (rev 3516) +++ trunk/scipy/sandbox/xplt/gist.py 2007-11-13 04:36:30 UTC (rev 3517) @@ -8,7 +8,7 @@ # SCIPY # 10/15/04 teo Added convert_bounding box. # 09/28/03 teo Changed eps file to accept noepsi when not available. -# 09/28/03 teo Changed all is None to is None and is not None to not is None +# 09/28/03 teo Changed all == None to is None and != None to not is None # # CHANGES: # 11/08/04 mdh plh: Change test if color is a list; also test if array. From scipy-svn at scipy.org Mon Nov 12 23:50:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 22:50:04 -0600 (CST) Subject: [Scipy-svn] r3518 - in trunk/scipy: sandbox/constants sandbox/xplt weave Message-ID: <20071113045004.EC94039C19B@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 22:50:00 -0600 (Mon, 12 Nov 2007) New Revision: 3518 Modified: trunk/scipy/sandbox/constants/codata.py trunk/scipy/sandbox/xplt/Mplot.py trunk/scipy/weave/build_tools.py trunk/scipy/weave/cpp_namespace_spec.py trunk/scipy/weave/platform_info.py Log: use the in operator for substring testing Modified: trunk/scipy/sandbox/constants/codata.py =================================================================== --- trunk/scipy/sandbox/constants/codata.py 2007-11-13 04:36:30 UTC (rev 3517) +++ trunk/scipy/sandbox/constants/codata.py 2007-11-13 04:50:00 UTC (rev 3518) @@ -376,7 +376,7 @@ result = [] for key in physical_constants : l_key = string.lower(key) - if string.find(l_key,l_sub) >= 0 : + if l_sub in l_key: result.append(key) result.sort() for key in result : Modified: trunk/scipy/sandbox/xplt/Mplot.py =================================================================== --- trunk/scipy/sandbox/xplt/Mplot.py 2007-11-13 04:36:30 UTC (rev 3517) +++ trunk/scipy/sandbox/xplt/Mplot.py 2007-11-13 04:50:00 UTC (rev 3518) @@ -177,7 +177,7 @@ import string value = default for k in dict.keys(): - if string.find(str,k) >= 0: + if k in str: value = dict[k] break return value Modified: trunk/scipy/weave/build_tools.py =================================================================== --- trunk/scipy/weave/build_tools.py 2007-11-13 04:36:30 UTC (rev 3517) +++ trunk/scipy/weave/build_tools.py 2007-11-13 04:50:00 UTC (rev 3518) @@ -115,7 +115,7 @@ # http://mail.python.org/pipermail/python-dev/2001-March/013510.html platform = sys.platform version = sys.version.lower() - if platform[:5] == 'sunos' and version.find('gcc') != -1: + if platform[:5] == 'sunos' and 'gcc' in version: extra_link_args = kw.get('extra_link_args',[]) kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args @@ -345,7 +345,7 @@ w.close() str_result = r.read() #print str_result - if string.find(str_result,'Reading specs') != -1: + if 'Reading specs' in str_result: result = 1 except: # This was needed because the msvc compiler messes with @@ -364,7 +364,7 @@ w.close() str_result = r.read() #print str_result - if string.find(str_result,'Microsoft') != -1: + if 'Microsoft' in str_result: result = 1 except: #assume we're ok if devstudio exists Modified: trunk/scipy/weave/cpp_namespace_spec.py =================================================================== --- trunk/scipy/weave/cpp_namespace_spec.py 2007-11-13 04:36:30 UTC (rev 3517) +++ trunk/scipy/weave/cpp_namespace_spec.py 2007-11-13 04:50:00 UTC (rev 3518) @@ -76,7 +76,7 @@ def type_match(self,value): try: cpp_ident = value.split('_')[2] - if cpp_ident.find(self.namespace) != -1: + if self.namespace in cpp.ident: return 1 except: pass Modified: trunk/scipy/weave/platform_info.py =================================================================== --- trunk/scipy/weave/platform_info.py 2007-11-13 04:36:30 UTC (rev 3517) +++ trunk/scipy/weave/platform_info.py 2007-11-13 04:50:00 UTC (rev 3518) @@ -172,7 +172,7 @@ w,r=os.popen4(cmd) w.close() str_result = r.read() - if str_result.find('Reading specs') != -1: + if 'Reading specs' in str_result: result = 1 except: # This was needed because the msvc compiler messes with @@ -190,7 +190,7 @@ w,r=os.popen4('cl') w.close() str_result = r.read() - if str_result.find('Microsoft') != -1: + if 'Microsoft' in str_result: result = 1 except: #assume we're ok if devstudio exists From scipy-svn at scipy.org Mon Nov 12 23:51:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 22:51:36 -0600 (CST) Subject: [Scipy-svn] r3519 - trunk/scipy/weave Message-ID: <20071113045136.23C0939C19B@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 22:51:34 -0600 (Mon, 12 Nov 2007) New Revision: 3519 Modified: trunk/scipy/weave/build_tools.py Log: cleaning up imports Modified: trunk/scipy/weave/build_tools.py =================================================================== --- trunk/scipy/weave/build_tools.py 2007-11-13 04:50:00 UTC (rev 3518) +++ trunk/scipy/weave/build_tools.py 2007-11-13 04:51:34 UTC (rev 3519) @@ -17,7 +17,9 @@ Note that you need write access to the pythonxx/lib directory to do this. """ -import sys,os,string,time +import sys +import os +import time import tempfile import exceptions import commands From scipy-svn at scipy.org Tue Nov 13 00:24:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 23:24:33 -0600 (CST) Subject: [Scipy-svn] r3520 - trunk/scipy/signal Message-ID: <20071113052433.A42B739C29E@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 23:24:31 -0600 (Mon, 12 Nov 2007) New Revision: 3520 Modified: trunk/scipy/signal/filter_design.py Log: replace map with list comprehension Modified: trunk/scipy/signal/filter_design.py =================================================================== --- trunk/scipy/signal/filter_design.py 2007-11-13 04:51:34 UTC (rev 3519) +++ trunk/scipy/signal/filter_design.py 2007-11-13 05:24:31 UTC (rev 3520) @@ -400,7 +400,7 @@ SEE ALSO butterord, cheb1ord, cheb2ord, ellipord """ - ftype, btype, output = map(string.lower, (ftype, btype, output)) + ftype, btype, output = [string.lower(x) for x in (ftype, btype, output)] Wn = asarray(Wn) try: btype = band_dict[btype] From scipy-svn at scipy.org Tue Nov 13 00:49:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 23:49:07 -0600 (CST) Subject: [Scipy-svn] r3521 - trunk/scipy/io Message-ID: <20071113054907.7C93A39C29E@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 23:49:05 -0600 (Mon, 12 Nov 2007) New Revision: 3521 Modified: trunk/scipy/io/dumbdbm_patched.py Log: synch with weave version of this module Modified: trunk/scipy/io/dumbdbm_patched.py =================================================================== --- trunk/scipy/io/dumbdbm_patched.py 2007-11-13 05:24:31 UTC (rev 3520) +++ trunk/scipy/io/dumbdbm_patched.py 2007-11-13 05:49:05 UTC (rev 3521) @@ -106,7 +106,7 @@ f.close() def __setitem__(self, key, val): - if not type(key) == type('') == type(val): + if not isinstance(key, str) or not isinstance(val, str): raise TypeError, "keys and values must be strings" if not self._index.has_key(key): (pos, siz) = self._addval(val) From scipy-svn at scipy.org Tue Nov 13 00:54:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 23:54:53 -0600 (CST) Subject: [Scipy-svn] r3522 - trunk/scipy/io Message-ID: <20071113055453.E21CB39C29E@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 23:54:51 -0600 (Mon, 12 Nov 2007) New Revision: 3522 Modified: trunk/scipy/io/dumb_shelve.py Log: remove unused import Modified: trunk/scipy/io/dumb_shelve.py =================================================================== --- trunk/scipy/io/dumb_shelve.py 2007-11-13 05:49:05 UTC (rev 3521) +++ trunk/scipy/io/dumb_shelve.py 2007-11-13 05:54:51 UTC (rev 3522) @@ -5,7 +5,6 @@ # Some python installations don't have zlib. pass -from cStringIO import StringIO import cPickle class DbfilenameShelf(Shelf): From scipy-svn at scipy.org Tue Nov 13 00:59:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 23:59:04 -0600 (CST) Subject: [Scipy-svn] r3523 - in trunk/scipy/weave: . tests Message-ID: <20071113055904.8762B39C29E@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 23:59:01 -0600 (Mon, 12 Nov 2007) New Revision: 3523 Modified: trunk/scipy/weave/blitz_tools.py trunk/scipy/weave/inline_tools.py trunk/scipy/weave/tests/test_numpy_scalar_spec.py Log: use builtin string methods rather than the string module Modified: trunk/scipy/weave/blitz_tools.py =================================================================== --- trunk/scipy/weave/blitz_tools.py 2007-11-13 05:54:51 UTC (rev 3522) +++ trunk/scipy/weave/blitz_tools.py 2007-11-13 05:59:01 UTC (rev 3523) @@ -1,5 +1,4 @@ import parser -import string import sys import ast_tools import slice_handler @@ -91,18 +90,18 @@ # be included in the generated code. # These could all alternatively be done to the ast in # build_slice_atom() - expr = string.replace(expr,'slice(_beg,_end)', '_all' ) - expr = string.replace(expr,'slice', 'blitz::Range' ) - expr = string.replace(expr,'[','(') - expr = string.replace(expr,']', ')' ) - expr = string.replace(expr,'_stp', '1' ) + expr = expr.replace('slice(_beg,_end)', '_all' ) + expr = expr.replace('slice', 'blitz::Range' ) + expr = expr.replace('[','(') + expr = expr.replace(']', ')' ) + expr = expr.replace)'_stp', '1' ) # Instead of blitz::fromStart and blitz::toEnd. This requires # the following in the generated code. # Range _beg = blitz::fromStart; # Range _end = blitz::toEnd; - #expr = string.replace(expr,'_beg', 'blitz::fromStart' ) - #expr = string.replace(expr,'_end', 'blitz::toEnd' ) + #expr = expr.replace('_beg', 'blitz::fromStart' ) + #expr = expr.replace('_end', 'blitz::toEnd' ) return expr + ';\n' Modified: trunk/scipy/weave/inline_tools.py =================================================================== --- trunk/scipy/weave/inline_tools.py 2007-11-13 05:54:51 UTC (rev 3522) +++ trunk/scipy/weave/inline_tools.py 2007-11-13 05:59:01 UTC (rev 3523) @@ -1,8 +1,8 @@ # should re-write compiled functions to take a local and global dict # as input. -import sys,os +import sys +import os import ext_tools -import string import catalog import common_info @@ -60,21 +60,21 @@ arg_strings = [] for arg in self.arg_specs: arg_strings.append(arg.declaration_code(inline=1)) - code = string.join(arg_strings,"") + code = arg_strings.join("") return code def arg_cleanup_code(self): arg_strings = [] for arg in self.arg_specs: arg_strings.append(arg.cleanup_code()) - code = string.join(arg_strings,"") + code = arg_strings.join("") return code def arg_local_dict_code(self): arg_strings = [] for arg in self.arg_specs: arg_strings.append(arg.local_dict_code()) - code = string.join(arg_strings,"") + code = arg_strings.join("") return code Modified: trunk/scipy/weave/tests/test_numpy_scalar_spec.py =================================================================== --- trunk/scipy/weave/tests/test_numpy_scalar_spec.py 2007-11-13 05:54:51 UTC (rev 3522) +++ trunk/scipy/weave/tests/test_numpy_scalar_spec.py 2007-11-13 05:59:01 UTC (rev 3523) @@ -1,5 +1,6 @@ import time -import os,sys +import os +import sys # Note: test_dir is global to this file. # It is made by setup_test_location() @@ -25,10 +26,9 @@ return m def remove_whitespace(in_str): - import string - out = string.replace(in_str," ","") - out = string.replace(out,"\t","") - out = string.replace(out,"\n","") + out = in_str.replace(" ","") + out = out.replace("\t","") + out = out.replace("\n","") return out def print_assert_equal(test_string,actual,desired): From scipy-svn at scipy.org Tue Nov 13 00:59:45 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Nov 2007 23:59:45 -0600 (CST) Subject: [Scipy-svn] r3524 - trunk/scipy/weave Message-ID: <20071113055945.1AE9939C29E@new.scipy.org> Author: jarrod.millman Date: 2007-11-12 23:59:43 -0600 (Mon, 12 Nov 2007) New Revision: 3524 Removed: trunk/scipy/weave/dumb_shelve.py trunk/scipy/weave/dumbdbm_patched.py Modified: trunk/scipy/weave/catalog.py Log: remove duplicate code and use version in scipy.io Modified: trunk/scipy/weave/catalog.py =================================================================== --- trunk/scipy/weave/catalog.py 2007-11-13 05:59:01 UTC (rev 3523) +++ trunk/scipy/weave/catalog.py 2007-11-13 05:59:43 UTC (rev 3524) @@ -41,11 +41,11 @@ import shelve dumb = 0 except ImportError: - import dumb_shelve as shelve + import scipy.io.dumb_shelve as shelve dumb = 1 #For testing... -#import dumb_shelve as shelve +#import scipy.io.dumb_shelve as shelve #dumb = 1 #import shelve Deleted: trunk/scipy/weave/dumb_shelve.py =================================================================== --- trunk/scipy/weave/dumb_shelve.py 2007-11-13 05:59:01 UTC (rev 3523) +++ trunk/scipy/weave/dumb_shelve.py 2007-11-13 05:59:43 UTC (rev 3524) @@ -1,35 +0,0 @@ -from shelve import Shelf -import zlib -import cPickle -import dumbdbm_patched - -class DbfilenameShelf(Shelf): - """Shelf implementation using the "anydbm" generic dbm interface. - - This is initialized with the filename for the dbm database. - See the module's __doc__ string for an overview of the interface. - """ - - def __init__(self, filename, flag='c'): - Shelf.__init__(self, dumbdbm_patched.open(filename, flag)) - - def __getitem__(self, key): - compressed = self.dict[key] - try: - r = zlib.decompress(compressed) - except zlib.error: - r = compressed - return cPickle.loads(r) - - def __setitem__(self, key, value): - s = cPickle.dumps(value,1) - self.dict[key] = zlib.compress(s) - -def open(filename, flag='c'): - """Open a persistent dictionary for reading and writing. - - Argument is the filename for the dbm database. - See the module's __doc__ string for an overview of the interface. - """ - - return DbfilenameShelf(filename, flag) Deleted: trunk/scipy/weave/dumbdbm_patched.py =================================================================== --- trunk/scipy/weave/dumbdbm_patched.py 2007-11-13 05:59:01 UTC (rev 3523) +++ trunk/scipy/weave/dumbdbm_patched.py 2007-11-13 05:59:43 UTC (rev 3524) @@ -1,146 +0,0 @@ -"""A dumb and slow but simple dbm clone. - -For database spam, spam.dir contains the index (a text file), -spam.bak *may* contain a backup of the index (also a text file), -while spam.dat contains the data (a binary file). - -XXX TO DO: - -- seems to contain a bug when updating... - -- reclaim free space (currently, space once occupied by deleted or expanded -items is never reused) - -- support concurrent access (currently, if two processes take turns making -updates, they can mess up the index) - -- support efficient access to large databases (currently, the whole index -is read when the database is opened, and some updates rewrite the whole index) - -- support opening for read-only (flag = 'm') - -""" - -_os = __import__('os') -import __builtin__ - -_open = __builtin__.open - -_BLOCKSIZE = 512 - -error = IOError # For anydbm - -class _Database(object): - - def __init__(self, file): - self._dirfile = file + '.dir' - self._datfile = file + '.dat' - self._bakfile = file + '.bak' - # Mod by Jack: create data file if needed - try: - f = _open(self._datfile, 'r') - except IOError: - f = _open(self._datfile, 'w') - f.close() - self._update() - - def _update(self): - import string - self._index = {} - try: - f = _open(self._dirfile) - except IOError: - pass - else: - while 1: - line = string.rstrip(f.readline()) - if not line: break - key, (pos, siz) = eval(line) - self._index[key] = (pos, siz) - f.close() - - def _commit(self): - try: _os.unlink(self._bakfile) - except _os.error: pass - try: _os.rename(self._dirfile, self._bakfile) - except _os.error: pass - f = _open(self._dirfile, 'w') - for key, (pos, siz) in self._index.items(): - f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`)) - f.close() - - def __getitem__(self, key): - pos, siz = self._index[key] # may raise KeyError - f = _open(self._datfile, 'rb') - f.seek(pos) - dat = f.read(siz) - f.close() - return dat - - def _addval(self, val): - f = _open(self._datfile, 'rb+') - f.seek(0, 2) - pos = f.tell() -## Does not work under MW compiler -## pos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE -## f.seek(pos) - npos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE - f.write('\0'*(npos-pos)) - pos = npos - - f.write(val) - f.close() - return (pos, len(val)) - - def _setval(self, pos, val): - f = _open(self._datfile, 'rb+') - f.seek(pos) - f.write(val) - f.close() - return (pos, len(val)) - - def _addkey(self, key, (pos, siz)): - self._index[key] = (pos, siz) - f = _open(self._dirfile, 'a') - f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`)) - f.close() - - def __setitem__(self, key, val): - if not isinstance(key, str) or not isinstance(val, str): - raise TypeError, "keys and values must be strings" - if not self._index.has_key(key): - (pos, siz) = self._addval(val) - self._addkey(key, (pos, siz)) - else: - pos, siz = self._index[key] - oldblocks = (siz + _BLOCKSIZE - 1) / _BLOCKSIZE - newblocks = (len(val) + _BLOCKSIZE - 1) / _BLOCKSIZE - if newblocks <= oldblocks: - pos, siz = self._setval(pos, val) - self._index[key] = pos, siz - else: - pos, siz = self._addval(val) - self._index[key] = pos, siz - self._addkey(key, (pos, siz)) - - def __delitem__(self, key): - del self._index[key] - self._commit() - - def keys(self): - return self._index.keys() - - def has_key(self, key): - return self._index.has_key(key) - - def __len__(self): - return len(self._index) - - def close(self): - self._index = None - self._datfile = self._dirfile = self._bakfile = None - - -def open(file, flag = None, mode = None): - # flag, mode arguments are currently ignored - return _Database(file) From scipy-svn at scipy.org Tue Nov 13 01:10:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 00:10:07 -0600 (CST) Subject: [Scipy-svn] r3525 - trunk/scipy/weave Message-ID: <20071113061007.742C6C7C015@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 00:10:03 -0600 (Tue, 13 Nov 2007) New Revision: 3525 Modified: trunk/scipy/weave/blitz_tools.py Log: typo Modified: trunk/scipy/weave/blitz_tools.py =================================================================== --- trunk/scipy/weave/blitz_tools.py 2007-11-13 05:59:43 UTC (rev 3524) +++ trunk/scipy/weave/blitz_tools.py 2007-11-13 06:10:03 UTC (rev 3525) @@ -94,7 +94,7 @@ expr = expr.replace('slice', 'blitz::Range' ) expr = expr.replace('[','(') expr = expr.replace(']', ')' ) - expr = expr.replace)'_stp', '1' ) + expr = expr.replace('_stp', '1' ) # Instead of blitz::fromStart and blitz::toEnd. This requires # the following in the generated code. From scipy-svn at scipy.org Tue Nov 13 01:51:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 00:51:08 -0600 (CST) Subject: [Scipy-svn] r3526 - in trunk/scipy: interpolate linalg signal special special/amos weave weave/tests Message-ID: <20071113065108.C2AEC39C2BD@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 00:51:00 -0600 (Tue, 13 Nov 2007) New Revision: 3526 Modified: trunk/scipy/interpolate/fitpack.py trunk/scipy/linalg/interface_gen.py trunk/scipy/signal/filter_design.py trunk/scipy/special/amos/setup.py trunk/scipy/special/gendoc.py trunk/scipy/weave/catalog.py trunk/scipy/weave/ext_tools.py trunk/scipy/weave/tests/test_c_spec.py trunk/scipy/weave/tests/test_catalog.py trunk/scipy/weave/tests/test_slice_handler.py trunk/scipy/weave/tests/test_standard_array_spec.py trunk/scipy/weave/tests/weave_test_utils.py Log: remove use of deprecated string module Modified: trunk/scipy/interpolate/fitpack.py =================================================================== --- trunk/scipy/interpolate/fitpack.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/interpolate/fitpack.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -823,10 +823,10 @@ return (tt, cc, k) if __name__ == "__main__": - import sys,string + import sys runtest=range(10) if len(sys.argv[1:])>0: - runtest=map(string.atoi,sys.argv[1:]) + runtest=map(int,sys.argv[1:]) put=sys.stdout.write def norm2(x): return dot(transpose(x),x) Modified: trunk/scipy/linalg/interface_gen.py =================================================================== --- trunk/scipy/linalg/interface_gen.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/linalg/interface_gen.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -2,7 +2,9 @@ #!/usr/bin/env python -import string,os,sys +import os +import sys + if sys.version[:3]>='2.3': import re else: @@ -19,7 +21,7 @@ subroutine_list = subroutine_exp.findall(interface) function_list = function_exp.findall(interface) subroutine_list = subroutine_list + function_list - subroutine_list = map(lambda x: string.strip(x),subroutine_list) + subroutine_list = map(lambda x: x.strip(),subroutine_list) return subroutine_list def real_convert(val_string): @@ -35,7 +37,7 @@ sub = regexp.search(interface) if sub is None: break converted = converter(sub.group(1)) - interface = string.replace(interface,sub.group(),converted) + interface = interface.replace(sub.group(),converted) return interface def generic_expand(generic_interface,skip_names=[]): @@ -80,33 +82,30 @@ continue type_chars = m.group(1) # get rid of spaces - type_chars = string.replace(type_chars,' ','') + type_chars = type_chars.replace(' ','') # get a list of the characters (or character pairs) - type_chars = string.split(type_chars,',') + type_chars = type_chars.split(',') # Now get rid of the special tag that contained the types sub = re.sub(type_exp,'',sub) m = TYPE_EXP.search(sub) if m is not None: sub = re.sub(TYPE_EXP,'',sub) - sub_generic = string.strip(sub) + sub_generic = sub.strip() for char in type_chars: type_in,type_out,converter, rtype_in = generic_types[char] sub = convert_types(sub_generic,converter) - function_def = string.replace(sub,'',char) - function_def = string.replace(function_def,'',string.upper(char)) - - function_def = string.replace(function_def,'',type_in) - function_def = string.replace(function_def,'', + function_def = sub.replace('',char) + function_def = function_def.replace('',char.upper()) + function_def = function_def.replace('',type_in) + function_def = function_def.replace('', generic_c_types[type_in]) - function_def = string.replace(function_def,'', + function_def = function_def.replace('', generic_cc_types[type_in]) - - function_def = string.replace(function_def,'',rtype_in) - function_def = string.replace(function_def,'', + function_def = function_def.replace('',rtype_in) + function_def = function_def.replace('', generic_c_types[rtype_in]) - - function_def = string.replace(function_def,'',type_out) - function_def = string.replace(function_def,'', + function_def = function_def.replace('',type_out) + function_def = function_def.replace('', generic_c_types[type_out]) m = routine_name.match(function_def) if m: @@ -136,8 +135,7 @@ include_files = include_exp.findall(interface_in) for filename in include_files: f = open(os.path.join(sdir,filename)) - interface_in = string.replace(interface_in, - ''%filename, + interface_in = interface_in.replace(''%filename, f.read()) f.close() return interface_in Modified: trunk/scipy/signal/filter_design.py =================================================================== --- trunk/scipy/signal/filter_design.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/signal/filter_design.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -1,6 +1,8 @@ """Filter design. """ +import types + import numpy from numpy import atleast_1d, poly, polyval, roots, real, asarray, allclose, \ resize, pi, absolute, logspace, r_, sqrt, tan, log10, arctan, arcsinh, \ @@ -8,7 +10,6 @@ from numpy import mintypecode from scipy import special, optimize from scipy.misc import comb -import string, types abs = absolute @@ -400,7 +401,7 @@ SEE ALSO butterord, cheb1ord, cheb2ord, ellipord """ - ftype, btype, output = [string.lower(x) for x in (ftype, btype, output)] + ftype, btype, output = [x.lower() for x in (ftype, btype, output)] Wn = asarray(Wn) try: btype = band_dict[btype] Modified: trunk/scipy/special/amos/setup.py =================================================================== --- trunk/scipy/special/amos/setup.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/special/amos/setup.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -1,7 +1,7 @@ import distutils from distutils.core import setup, Extension import distutils.dep_util -import os,string +import os def fortran_extension(module_name, c_files, fortran_files, library_dirs, libraries): @@ -18,15 +18,14 @@ def __init__(self): self.compiler_name = 'g77' def to_object(self,dirty_files): - files = string.join(dirty_files) + files = dirty_files.join() cmd = self.compiler_name + ' -c ' + files print cmd failure = os.system(cmd) if failure: raise ValueError, 'failure during compile' def object_to_library(self,library_name,object_files): - import string - objects = string.join(object_files) + objects = object_files.join() cmd = 'ar -cr lib%s.a %s' % (library_name,objects) print cmd os.system(cmd) Modified: trunk/scipy/special/gendoc.py =================================================================== --- trunk/scipy/special/gendoc.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/special/gendoc.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -2,7 +2,6 @@ """generate cephes_doc.h from included_functions.html""" -import string def parse(infile): d={} @@ -10,19 +9,19 @@ val='' prev_line = '' for line in infile.readlines(): - if not string.strip(line): + if not line.strip(): continue if line[0]=='<': if key and val: - d[key]=string.strip(val) + d[key]=val.strip() key,val=None,None if line[:4]=='
': - tok=string.split(line) - tok=string.split(tok[-1],'(') + tok=line.split() + tok=tok[-1].split('(') key=tok[0] elif line[:4]=='
' and key: prev_line = prev_line[4:] - tok = string.split(prev_line,' = ') + tok = prev_line.split(' = ') val=tok[0]+'='+line[4:] else: if val: Modified: trunk/scipy/weave/catalog.py =================================================================== --- trunk/scipy/weave/catalog.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/catalog.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -31,7 +31,8 @@ persistent catalog for future use by python sessions. """ -import os,sys,string +import os +import sys import pickle import socket import tempfile @@ -71,7 +72,7 @@ # if a non-builtin also has it. Otherwise quit and # consider the module found. (ain't perfect, but will # have to do for now). - if string.find('(built-in)',str(mod)) is -1: + if str(mod) not in '(built-in)': break except (TypeError, KeyError, ImportError): Modified: trunk/scipy/weave/ext_tools.py =================================================================== --- trunk/scipy/weave/ext_tools.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/ext_tools.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -1,5 +1,6 @@ -import os, sys -import string, re +import os +import sys +import re import catalog import build_tools @@ -39,20 +40,19 @@ This code got a lot uglier when I added local_dict... """ - join = string.join declare_return = 'py::object return_val;\n' \ 'int exception_occured = 0;\n' \ 'PyObject *py_local_dict = NULL;\n' arg_string_list = self.arg_specs.variable_as_strings() + ['"local_dict"'] - arg_strings = join(arg_string_list,',') + arg_strings = arg_string_list.join(',') if arg_strings: arg_strings += ',' declare_kwlist = 'static char *kwlist[] = {%s NULL};\n' % arg_strings - py_objects = join(self.arg_specs.py_pointers(),', ') - init_flags = join(self.arg_specs.init_flags(),', ') - init_flags_init = join(self.arg_specs.init_flags(),'= ') - py_vars = join(self.arg_specs.py_variables(),' = ') + py_objects = self.arg_specs.py_pointers().join(', ') + init_flags = self.arg_specs.init_flags().join(', ') + init_flags_init = self.arg_specs.init_flags().join('= ') + py_vars = self.arg_specs.py_variables().join(' = ') if py_objects: declare_py_objects = 'PyObject ' + py_objects +';\n' declare_py_objects += 'int '+ init_flags + ';\n' @@ -66,7 +66,7 @@ #cnt = len(arg_list) #declare_cleanup = "blitz::TinyVector clean_up(0);\n" % cnt - ref_string = join(self.arg_specs.py_references(),', ') + ref_string = self.arg_specs.py_references().join(', ') if ref_string: ref_string += ', &py_local_dict' else: @@ -85,7 +85,7 @@ for arg in self.arg_specs: arg_strings.append(arg.declaration_code()) arg_strings.append(arg.init_flag() +" = 1;\n") - code = string.join(arg_strings,"") + code = (arg_strings.join("") return code def arg_cleanup_code(self): @@ -97,14 +97,14 @@ code += indent(arg.cleanup_code(),4) code += "}\n" arg_strings.append(code) - code = string.join(arg_strings,"") + code = arg_strings.join("") return code def arg_local_dict_code(self): arg_strings = [] for arg in self.arg_specs: arg_strings.append(arg.local_dict_code()) - code = string.join(arg_strings,"") + code = arg_strings.join("") return code def function_code(self): @@ -454,7 +454,7 @@ def indent(st,spaces): indention = ' '*spaces - indented = indention + string.replace(st,'\n','\n'+indention) + indented = indention + st.replace('\n','\n'+indention) # trim off any trailing spaces indented = re.sub(r' +$',r'',indented) return indented Modified: trunk/scipy/weave/tests/test_c_spec.py =================================================================== --- trunk/scipy/weave/tests/test_c_spec.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/tests/test_c_spec.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -1,5 +1,6 @@ import time -import os,sys +import os +import sys # Note: test_dir is global to this file. # It is made by setup_test_location() @@ -22,10 +23,9 @@ return m def remove_whitespace(in_str): - import string - out = string.replace(in_str," ","") - out = string.replace(out,"\t","") - out = string.replace(out,"\n","") + out = in_str.replace(" ","") + out = out.replace("\t","") + out = out.replace("\n","") return out def print_assert_equal(test_string,actual,desired): Modified: trunk/scipy/weave/tests/test_catalog.py =================================================================== --- trunk/scipy/weave/tests/test_catalog.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/tests/test_catalog.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -1,4 +1,5 @@ -import sys, os +import sys +import os from numpy.testing import * Modified: trunk/scipy/weave/tests/test_slice_handler.py =================================================================== --- trunk/scipy/weave/tests/test_slice_handler.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/tests/test_slice_handler.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -129,10 +129,9 @@ self.generic_test(test,desired) def replace_whitespace(in_str): - import string - out = string.replace(in_str," ","") - out = string.replace(out,"\t","") - out = string.replace(out,"\n","") + out = in_str.replace(" ","") + out = out.replace("\t","") + out = out.replace("\n","") return out class TestTransformSlices(NumpyTestCase): @@ -143,7 +142,6 @@ actual = ast_to_string(ast_list) # Remove white space from expressions so that equivelant # but differently formatted string will compare equally - import string actual = replace_whitespace(actual) desired = replace_whitespace(desired) print_assert_equal(suite_string,actual,desired) Modified: trunk/scipy/weave/tests/test_standard_array_spec.py =================================================================== --- trunk/scipy/weave/tests/test_standard_array_spec.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/tests/test_standard_array_spec.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -6,10 +6,9 @@ restore_path() def remove_whitespace(in_str): - import string - out = string.replace(in_str," ","") - out = string.replace(out,"\t","") - out = string.replace(out,"\n","") + out = in_str.replace(" ","") + out = out.replace("\t","") + out = out.replace("\n","") return out def print_assert_equal(test_string,actual,desired): Modified: trunk/scipy/weave/tests/weave_test_utils.py =================================================================== --- trunk/scipy/weave/tests/weave_test_utils.py 2007-11-13 06:10:03 UTC (rev 3525) +++ trunk/scipy/weave/tests/weave_test_utils.py 2007-11-13 06:51:00 UTC (rev 3526) @@ -1,11 +1,12 @@ -import os,sys,string +import os +import sys +import string import pprint def remove_whitespace(in_str): - import string - out = string.replace(in_str," ","") - out = string.replace(out,"\t","") - out = string.replace(out,"\n","") + out = in_str.replace(" ","") + out = out.replace("\t","") + out = out.replace("\n","") return out def print_assert_equal(test_string,actual,desired): From scipy-svn at scipy.org Tue Nov 13 02:09:21 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 01:09:21 -0600 (CST) Subject: [Scipy-svn] r3527 - in trunk/scipy/weave: examples tests Message-ID: <20071113070921.8E01C39C2A7@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 01:09:10 -0600 (Tue, 13 Nov 2007) New Revision: 3527 Modified: trunk/scipy/weave/examples/object.py trunk/scipy/weave/tests/test_scxx_dict.py trunk/scipy/weave/tests/test_scxx_object.py Log: fixing class names in tests Modified: trunk/scipy/weave/examples/object.py =================================================================== --- trunk/scipy/weave/examples/object.py 2007-11-13 06:51:00 UTC (rev 3526) +++ trunk/scipy/weave/examples/object.py 2007-11-13 07:09:10 UTC (rev 3527) @@ -9,13 +9,13 @@ # get/set attribute and call methods example #---------------------------------------------------------------------------- -class foo(object): +class Foo(object): def __init__(self): self.val = 1 def inc(self,amount): self.val += amount return self.val -obj = foo() +obj = Foo() code = """ py::tuple result(3); Modified: trunk/scipy/weave/tests/test_scxx_dict.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_dict.py 2007-11-13 06:51:00 UTC (rev 3526) +++ trunk/scipy/weave/tests/test_scxx_dict.py 2007-11-13 07:09:10 UTC (rev 3527) @@ -27,9 +27,9 @@ class TestDictHasKey(NumpyTestCase): def check_obj(self,level=5): - class foo: + class Foo: pass - key = foo() + key = Foo() a = {} a[key] = 12345 code = """ @@ -176,9 +176,9 @@ key,val = 1+1j,12345 self.generic_new(key,val) def check_new_obj_int(self,level=5): - class foo: + class Foo: pass - key,val = foo(),12345 + key,val = Foo(),12345 self.generic_new(key,val) def check_overwrite_int_int(self,level=5): @@ -194,9 +194,9 @@ key,val = 1+1j,12345 self.generic_overwrite(key,val) def check_overwrite_obj_int(self,level=5): - class foo: + class Foo: pass - key,val = foo(),12345 + key,val = Foo(),12345 self.generic_overwrite(key,val) class TestDictDel(NumpyTestCase): @@ -228,9 +228,9 @@ key = 1+1j self.generic(key) def check_obj(self,level=5): - class foo: + class Foo: pass - key = foo() + key = Foo() self.generic(key) class TestDictOthers(NumpyTestCase): Modified: trunk/scipy/weave/tests/test_scxx_object.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_object.py 2007-11-13 06:51:00 UTC (rev 3526) +++ trunk/scipy/weave/tests/test_scxx_object.py 2007-11-13 07:09:10 UTC (rev 3527) @@ -1,7 +1,8 @@ """ Test refcounting and behavior of SCXX. """ import time -import os,sys +import os +import sys from numpy.testing import * set_package_path() @@ -135,7 +136,7 @@ inline_tools.inline(code) # test class used for testing python class access from C++. -class foo: +class Foo: def bar(self): return "bar results" def bar2(self,val1,val2): @@ -143,13 +144,13 @@ def bar3(self,val1,val2,val3=1): return val1, val2, val3 -class str_obj: - def __str__(self): - return "b" +#class StrObj: +# def __str__(self): +# return "b" class TestObjectHasattr(NumpyTestCase): def check_string(self,level=5): - a = foo() + a = Foo() a.b = 12345 code = """ return_val = a.hasattr("b"); @@ -157,7 +158,7 @@ res = inline_tools.inline(code,['a']) assert res def check_std_string(self,level=5): - a = foo() + a = Foo() a.b = 12345 attr_name = "b" code = """ @@ -166,7 +167,7 @@ res = inline_tools.inline(code,['a','attr_name']) assert res def check_string_fail(self,level=5): - a = foo() + a = Foo() a.b = 12345 code = """ return_val = a.hasattr("c"); @@ -176,7 +177,7 @@ def check_inline(self,level=5): """ THIS NEEDS TO MOVE TO THE INLINE TEST SUITE """ - a = foo() + a = Foo() a.b = 12345 code = """ throw_error(PyExc_AttributeError,"bummer"); @@ -195,7 +196,7 @@ pass def check_func(self,level=5): - a = foo() + a = Foo() a.b = 12345 code = """ return_val = a.hasattr("bar"); @@ -206,7 +207,7 @@ class TestObjectAttr(NumpyTestCase): def generic_attr(self,code,args=['a']): - a = foo() + a = Foo() a.b = 12345 before = sys.getrefcount(a.b) @@ -252,7 +253,7 @@ pass def check_attr_call(self,level=5): - a = foo() + a = Foo() res = inline_tools.inline('return_val = a.attr("bar").call();',['a']) first = sys.getrefcount(res) del res @@ -265,14 +266,14 @@ def generic_existing(self, code, desired): args = ['a'] - a = foo() + a = Foo() a.b = 12345 res = inline_tools.inline(code,args) assert_equal(a.b,desired) def generic_new(self, code, desired): args = ['a'] - a = foo() + a = Foo() res = inline_tools.inline(code,args) assert_equal(a.b,desired) @@ -328,7 +329,7 @@ class TestObjectDel(NumpyTestCase): def generic(self, code): args = ['a'] - a = foo() + a = Foo() a.b = 12345 res = inline_tools.inline(code,args) assert not hasattr(a,"b") @@ -354,12 +355,12 @@ res = inline_tools.inline('return_val = (a == b);',['a','b']) assert_equal(res,(a == b)) def check_equal_objects(self,level=5): - class foo: + class Foo: def __init__(self,x): self.x = x def __cmp__(self,other): return cmp(self.x,other.x) - a,b = foo(1),foo(2) + a,b = Foo(1),Foo(2) res = inline_tools.inline('return_val = (a == b);',['a','b']) assert_equal(res,(a == b)) def check_lt(self,level=5): @@ -413,12 +414,12 @@ class TestObjectRepr(NumpyTestCase): def check_repr(self,level=5): - class foo: + class Foo: def __str__(self): return "str return" def __repr__(self): return "repr return" - a = foo() + a = Foo() res = inline_tools.inline('return_val = a.repr();',['a']) first = sys.getrefcount(res) del res @@ -429,12 +430,12 @@ class TestObjectStr(NumpyTestCase): def check_str(self,level=5): - class foo: + class Foo: def __str__(self): return "str return" def __repr__(self): return "repr return" - a = foo() + a = Foo() res = inline_tools.inline('return_val = a.str();',['a']) first = sys.getrefcount(res) del res @@ -447,12 +448,12 @@ class TestObjectUnicode(NumpyTestCase): # This ain't going to win awards for test of the year... def check_unicode(self,level=5): - class foo: + class Foo: def __repr__(self): return "repr return" def __str__(self): return "unicode" - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.unicode();',['a']) first = sys.getrefcount(res) del res @@ -463,40 +464,40 @@ class TestObjectIsCallable(NumpyTestCase): def check_true(self,level=5): - class foo: + class Foo: def __call__(self): return 0 - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.is_callable();',['a']) assert res def check_false(self,level=5): - class foo: + class Foo: pass - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.is_callable();',['a']) assert not res class TestObjectCall(NumpyTestCase): def check_noargs(self,level=5): - def foo(): + def Foo(): return (1,2,3) - res = inline_tools.inline('return_val = foo.call();',['foo']) + res = inline_tools.inline('return_val = Foo.call();',['Foo']) assert_equal(res,(1,2,3)) assert_equal(sys.getrefcount(res),2) def check_args(self,level=5): - def foo(val1,val2): + def Foo(val1,val2): return (val1,val2) code = """ py::tuple args(2); args[0] = 1; args[1] = "hello"; - return_val = foo.call(args); + return_val = Foo.call(args); """ - res = inline_tools.inline(code,['foo']) + res = inline_tools.inline(code,['Foo']) assert_equal(res,(1,"hello")) assert_equal(sys.getrefcount(res),2) def check_args_kw(self,level=5): - def foo(val1,val2,val3=1): + def Foo(val1,val2,val3=1): return (val1,val2,val3) code = """ py::tuple args(2); @@ -504,37 +505,37 @@ args[1] = "hello"; py::dict kw; kw["val3"] = 3; - return_val = foo.call(args,kw); + return_val = Foo.call(args,kw); """ - res = inline_tools.inline(code,['foo']) + res = inline_tools.inline(code,['Foo']) assert_equal(res,(1,"hello",3)) assert_equal(sys.getrefcount(res),2) def check_noargs_with_args(self,level=5): # calling a function that does take args with args # should fail. - def foo(): + def Foo(): return "blah" code = """ py::tuple args(2); args[0] = 1; args[1] = "hello"; - return_val = foo.call(args); + return_val = Foo.call(args); """ try: - first = sys.getrefcount(foo) - res = inline_tools.inline(code,['foo']) + first = sys.getrefcount(Foo) + res = inline_tools.inline(code,['Foo']) except TypeError: - second = sys.getrefcount(foo) + second = sys.getrefcount(Foo) try: - res = inline_tools.inline(code,['foo']) + res = inline_tools.inline(code,['Foo']) except TypeError: - third = sys.getrefcount(foo) + third = sys.getrefcount(Foo) # first should == second, but the weird refcount error assert_equal(second,third) class TestObjectMcall(NumpyTestCase): def check_noargs(self,level=5): - a = foo() + a = Foo() res = inline_tools.inline('return_val = a.mcall("bar");',['a']) assert_equal(res,"bar results") first = sys.getrefcount(res) @@ -544,7 +545,7 @@ second = sys.getrefcount(res) assert_equal(first,second) def check_args(self,level=5): - a = foo() + a = Foo() code = """ py::tuple args(2); args[0] = 1; @@ -555,7 +556,7 @@ assert_equal(res,(1,"hello")) assert_equal(sys.getrefcount(res),2) def check_args_kw(self,level=5): - a = foo() + a = Foo() code = """ py::tuple args(2); args[0] = 1; @@ -568,7 +569,7 @@ assert_equal(res,(1,"hello",3)) assert_equal(sys.getrefcount(res),2) def check_std_noargs(self,level=5): - a = foo() + a = Foo() method = "bar" res = inline_tools.inline('return_val = a.mcall(method);',['a','method']) assert_equal(res,"bar results") @@ -579,7 +580,7 @@ second = sys.getrefcount(res) assert_equal(first,second) def check_std_args(self,level=5): - a = foo() + a = Foo() method = "bar2" code = """ py::tuple args(2); @@ -591,7 +592,7 @@ assert_equal(res,(1,"hello")) assert_equal(sys.getrefcount(res),2) def check_std_args_kw(self,level=5): - a = foo() + a = Foo() method = "bar3" code = """ py::tuple args(2); @@ -607,7 +608,7 @@ def check_noargs_with_args(self,level=5): # calling a function that does take args with args # should fail. - a = foo() + a = Foo() code = """ py::tuple args(2); args[0] = 1; @@ -628,19 +629,19 @@ class TestObjectHash(NumpyTestCase): def check_hash(self,level=5): - class foo: + class Foo: def __hash__(self): return 123 - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.hash(); ',['a']) print 'hash:', res assert_equal(res,123) class TestObjectIsTrue(NumpyTestCase): def check_true(self,level=5): - class foo: + class Foo: pass - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.is_true();',['a']) assert_equal(res,1) def check_false(self,level=5): @@ -650,9 +651,9 @@ class TestObjectIsTrue(NumpyTestCase): def check_false(self,level=5): - class foo: + class Foo: pass - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.mcall("not");',['a']) assert_equal(res,0) def check_true(self,level=5): @@ -662,32 +663,32 @@ class TestObjectType(NumpyTestCase): def check_type(self,level=5): - class foo: + class Foo: pass - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.type();',['a']) assert_equal(res,type(a)) class TestObjectSize(NumpyTestCase): def check_size(self,level=5): - class foo: + class Foo: def __len__(self): return 10 - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.size();',['a']) assert_equal(res,len(a)) def check_len(self,level=5): - class foo: + class Foo: def __len__(self): return 10 - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.len();',['a']) assert_equal(res,len(a)) def check_length(self,level=5): - class foo: + class Foo: def __len__(self): return 10 - a= foo() + a= Foo() res = inline_tools.inline('return_val = a.length();',['a']) assert_equal(res,len(a)) @@ -797,12 +798,12 @@ def check_set_class(self,level=5): a = UserDict() - class foo: + class Foo: def __init__(self,val): self.val = val def __hash__(self): return self.val - key = foo(4) + key = Foo(4) inline_tools.inline('a[key] = "bubba";',['a','key']) first = sys.getrefcount(key) inline_tools.inline('a[key] = "bubba";',['a','key']) From scipy-svn at scipy.org Tue Nov 13 02:13:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 01:13:15 -0600 (CST) Subject: [Scipy-svn] r3528 - trunk/scipy/weave Message-ID: <20071113071315.EE90939C2A7@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 01:13:14 -0600 (Tue, 13 Nov 2007) New Revision: 3528 Modified: trunk/scipy/weave/ext_tools.py Log: typo Modified: trunk/scipy/weave/ext_tools.py =================================================================== --- trunk/scipy/weave/ext_tools.py 2007-11-13 07:09:10 UTC (rev 3527) +++ trunk/scipy/weave/ext_tools.py 2007-11-13 07:13:14 UTC (rev 3528) @@ -85,7 +85,7 @@ for arg in self.arg_specs: arg_strings.append(arg.declaration_code()) arg_strings.append(arg.init_flag() +" = 1;\n") - code = (arg_strings.join("") + code = arg_strings.join("") return code def arg_cleanup_code(self): From scipy-svn at scipy.org Tue Nov 13 03:02:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 02:02:02 -0600 (CST) Subject: [Scipy-svn] r3529 - in trunk/scipy: integrate lib/blas lib/lapack linalg linsolve linsolve/umfpack misc sandbox/ga sandbox/maskedarray sandbox/netcdf sandbox/newoptimize sandbox/timeseries stats/models weave weave/tests Message-ID: <20071113080202.0BF2BC7C033@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 02:01:14 -0600 (Tue, 13 Nov 2007) New Revision: 3529 Modified: trunk/scipy/integrate/quadrature.py trunk/scipy/integrate/setup.py trunk/scipy/lib/blas/__init__.py trunk/scipy/lib/lapack/__init__.py trunk/scipy/linalg/blas.py trunk/scipy/linalg/flinalg.py trunk/scipy/linalg/lapack.py trunk/scipy/linsolve/linsolve.py trunk/scipy/linsolve/umfpack/umfpack.py trunk/scipy/misc/ppimport.py trunk/scipy/sandbox/ga/genome.py trunk/scipy/sandbox/ga/language.py trunk/scipy/sandbox/ga/tree.py trunk/scipy/sandbox/maskedarray/testutils.py trunk/scipy/sandbox/netcdf/netcdf.py trunk/scipy/sandbox/newoptimize/log.py trunk/scipy/sandbox/timeseries/parser.py trunk/scipy/sandbox/timeseries/plotlib.py trunk/scipy/stats/models/cox.py trunk/scipy/stats/models/mixed.py trunk/scipy/weave/build_tools.py trunk/scipy/weave/bytecodecompiler.py trunk/scipy/weave/catalog.py trunk/scipy/weave/tests/test_catalog.py trunk/scipy/weave/tests/test_scxx_dict.py Log: use the 'in' keyword instead of the 'has_key()' method for testing dictionary membership Modified: trunk/scipy/integrate/quadrature.py =================================================================== --- trunk/scipy/integrate/quadrature.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/integrate/quadrature.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -1,7 +1,4 @@ -## Automatically adapted for scipy Oct 21, 2005 by -# Author: Travis Oliphant - __all__ = ['fixed_quad','quadrature','romberg','trapz','simps','romb', 'cumtrapz','newton_cotes','composite'] @@ -562,7 +559,7 @@ rn = np.arange(N+1) equal = 1 - if equal and _builtincoeffs.has_key(N): + if equal and N in _builtincoeffs: na, da, vi, nb, db = _builtincoeffs[N] return na*np.array(vi,float)/da, float(nb)/db Modified: trunk/scipy/integrate/setup.py =================================================================== --- trunk/scipy/integrate/setup.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/integrate/setup.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -35,7 +35,7 @@ libs = ['odepack','linpack_lite','mach'] # Remove libraries key from blas_opt - if blas_opt.has_key('libraries'): # key doesn't exist on OS X ... + if 'libraries' in blas_opt: # key doesn't exist on OS X ... libs.extend(blas_opt['libraries']) newblas = {} for key in blas_opt.keys(): Modified: trunk/scipy/lib/blas/__init__.py =================================================================== --- trunk/scipy/lib/blas/__init__.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/lib/blas/__init__.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -26,7 +26,8 @@ ordering = [] for i in range(len(arrays)): t = arrays[i].dtype.char - if not _type_conv.has_key(t): t = 'd' + if t not in _type_conv: + t = 'd' ordering.append((t,i)) if ordering: ordering.sort() Modified: trunk/scipy/lib/lapack/__init__.py =================================================================== --- trunk/scipy/lib/lapack/__init__.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/lib/lapack/__init__.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -40,7 +40,8 @@ ordering = [] for i in range(len(arrays)): t = arrays[i].dtype.char - if not _type_conv.has_key(t): t = 'd' + if t not in _type_conv: + t = 'd' ordering.append((t,i)) if ordering: ordering.sort() @@ -83,7 +84,7 @@ _colmajor_func_template = '''\ def %(func_name)s(*args,**kws): - if not kws.has_key("rowmajor"): + if "rowmajor" not in kws: kws["rowmajor"] = 0 return clapack_func(*args,**kws) func_code = %(func_name)s.func_code Modified: trunk/scipy/linalg/blas.py =================================================================== --- trunk/scipy/linalg/blas.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/linalg/blas.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -31,7 +31,8 @@ ordering = [] for i in range(len(arrays)): t = arrays[i].dtype.char - if not _type_conv.has_key(t): t = 'd' + if t not in _type_conv: + t = 'd' ordering.append((t,i)) if ordering: ordering.sort() Modified: trunk/scipy/linalg/flinalg.py =================================================================== --- trunk/scipy/linalg/flinalg.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/linalg/flinalg.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -29,7 +29,8 @@ ordering = [] for i in range(len(arrays)): t = arrays[i].dtype.char - if not _type_conv.has_key(t): t = 'd' + if t not in _type_conv: + t = 'd' ordering.append((t,i)) if ordering: ordering.sort() Modified: trunk/scipy/linalg/lapack.py =================================================================== --- trunk/scipy/linalg/lapack.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/linalg/lapack.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -109,7 +109,7 @@ _colmajor_func_template = '''\ def %(func_name)s(*args,**kws): - if not kws.has_key("rowmajor"): + if "rowmajor" not in kws: kws["rowmajor"] = 0 return clapack_func(*args,**kws) func_code = %(func_name)s.func_code Modified: trunk/scipy/linsolve/linsolve.py =================================================================== --- trunk/scipy/linsolve/linsolve.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/linsolve/linsolve.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -28,7 +28,7 @@ sure that the matrix fulfills this, pass assumeSortedIndices=True to gain some speed. """ - if kwargs.has_key( 'useUmfpack' ): + if 'useUmfpack' in kwargs: globals()['useUmfpack'] = kwargs['useUmfpack'] if isUmfpack: Modified: trunk/scipy/linsolve/umfpack/umfpack.py =================================================================== --- trunk/scipy/linsolve/umfpack/umfpack.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/linsolve/umfpack/umfpack.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -28,7 +28,7 @@ sure that the matrix fulfills this, pass assumeSortedIndices = True to gain some speed. """ - if kwargs.has_key( 'assumeSortedIndices' ): + if 'assumeSortedIndices' in kwargs): globals()['assumeSortedIndices'] = kwargs['assumeSortedIndices'] @@ -297,7 +297,7 @@ maxLen = max( [len( name ) for name in umfControls] ) format = '%%-%ds : %%d' % maxLen aux = [format % (name, self.control[umfDefines[name]]) - for name in umfControls if umfDefines.has_key( name )] + for name in umfControls if name in umfDefines] return '\n'.join( aux ) ## @@ -306,7 +306,7 @@ maxLen = max( [len( name ) for name in umfInfo] ) format = '%%-%ds : %%d' % maxLen aux = [format % (name, self.info[umfDefines[name]]) - for name in umfInfo if umfDefines.has_key( name )] + for name in umfInfo if name in umfDefines] return '\n'.join( aux ) ## @@ -508,7 +508,7 @@ # UMFPACK uses CSC internally... if self.family in umfRealTypes: ii = 0 else: ii = 1 - if umfSys_transposeMap[ii].has_key( sys ): + if sys in umfSys_transposeMap[ii]: sys = umfSys_transposeMap[ii][sys] else: raise RuntimeError, 'autoTranspose ambiguous, switch it off' Modified: trunk/scipy/misc/ppimport.py =================================================================== --- trunk/scipy/misc/ppimport.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/misc/ppimport.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -101,7 +101,7 @@ return getattr(attr, name) def __repr__(self): - if self.__dict__.has_key('_ppimport_attr'): + if '_ppimport_attr' in self.__dict__: return repr(self._ppimport_attr) module = self.__dict__['_ppimport_attr_module'] name = self.__dict__['_ppimport_attr_name'] @@ -135,7 +135,7 @@ level = 1 parent_frame = p_frame = _get_frame(level) - while not p_frame.f_locals.has_key('__name__'): + while '__name__' not in p_frame.f_locals: level = level + 1 p_frame = _get_frame(level) @@ -143,7 +143,7 @@ if p_name=='__main__': p_dir = '' fullname = name - elif p_frame.f_locals.has_key('__path__'): + elif '__path__' in_frame.f_locals: # python package p_path = p_frame.f_locals['__path__'] p_dir = p_path[0] @@ -310,9 +310,9 @@ except KeyError: module = self._ppimport_importer() return module.__repr__() - if self.__dict__.has_key('_ppimport_module'): + if '_ppimport_module' in self.__dict__: status = 'imported' - elif self.__dict__.has_key('_ppimport_exc_info'): + elif '_ppimport_exc_info' in self.__dict__: status = 'import error' else: status = 'import postponed' @@ -356,7 +356,7 @@ if ignore_failure and not hasattr(a, b[-1]): a = '.'.join(ns+b) b = '.'.join(b) - if sys.modules.has_key(b) and sys.modules[b] is None: + if b in sys.modules and sys.modules[b] is None: del sys.modules[b] return a a = getattr(a,b[-1]) Modified: trunk/scipy/sandbox/ga/genome.py =================================================================== --- trunk/scipy/sandbox/ga/genome.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/ga/genome.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -211,7 +211,7 @@ ga_list.ga_list.__init__(self,list) def initialize(self,settings = None): genome.initialize(self,settings) - if settings and settings.has_key('p_mutate'): + if settings and 'p_mutate' in settings: for g in self: g.set_mutation(settings['p_mutate']) def clone(self): """This returns a new genome object. The new genome is a shallow copy @@ -316,7 +316,7 @@ tried_sym = [] for i in range(tries): sym,node_a = dict_choice(sis.symbol_table) - if not self.bad_cross_point(sym) and bro.symbol_table.has_key(sym): + if not self.bad_cross_point(sym) and sym in bro.symbol_table: break elif i == (tries - 1): msg = "chosen symbol not found in dad (%s tries)" % `tries` @@ -342,7 +342,7 @@ node_a.set_parent(node_b.get_parent()) node_b.set_parent(temp) sib1.evaluated = 0; sib2.evaluated = 0 - if self.cross_point.has_key(sym): + if sym in self.cross_point: self.cross_point[sym] = self.cross_point[sym] + 1 else: self.cross_point[sym] = 1 return sib1,sib2 @@ -372,7 +372,7 @@ # def touch(self): calls genome touch because of inheritance order def initialize(self,settings = None): genome.initialize(self,settings) - if settings and settings.has_key('p_mutate'): + if settings and 'p_mutate' in settings: raise NotImplementedError # XXX: what is g? #g.root.set_mutation(settings['p_mutate']) Modified: trunk/scipy/sandbox/ga/language.py =================================================================== --- trunk/scipy/sandbox/ga/language.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/ga/language.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -37,7 +37,7 @@ else: self.derive_type = cur_sym.node_type new_active_node = active_node if type(cur_sym) == types.StringType: - if self.lang.has_key(cur_sym): + if cur_sym in self.lang: rule = prng.choice(self.lang[cur_sym]) for sym in rule: new_active_node = self._gen(sym,new_active_node,depth) Modified: trunk/scipy/sandbox/ga/tree.py =================================================================== --- trunk/scipy/sandbox/ga/tree.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/ga/tree.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -87,7 +87,7 @@ """ for child in self._children: child._generate_symbol_table(symbol_table) - if symbol_table.has_key(self.derive_type): + if self.derive_type in symbol_table: symbol_table[self.derive_type].append(self) else: symbol_table[self.derive_type] = [self] @@ -206,11 +206,13 @@ # if not hasattr(self,'parent'): # self.parent = weakdict.WeakDict() # if parent: self.parent[0] = parent -# elif self.parent.has_key(0): del self.parent[0] +# elif 0 in self.parent: +# del self.parent[0] # print 'out set' # def get_parent(self): # print 'in get' -# if self.parent.has_key(0): p = self.parent[0] +# if 0 in self.parent: +# p = self.parent[0] # else: p = None # print 'out get' # return p Modified: trunk/scipy/sandbox/maskedarray/testutils.py =================================================================== --- trunk/scipy/sandbox/maskedarray/testutils.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/maskedarray/testutils.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -65,7 +65,7 @@ assert isinstance(actual, dict), repr(type(actual)) assert_equal(len(actual),len(desired),err_msg) for k,i in desired.items(): - assert actual.has_key(k), repr(k) + assert k in actual, repr(k) assert_equal(actual[k], desired[k], 'key=%r\n%s' % (k,err_msg)) return # Case #2: lists ..... @@ -95,7 +95,7 @@ assert isinstance(actual, dict), repr(type(actual)) fail_if_equal(len(actual),len(desired),err_msg) for k,i in desired.items(): - assert actual.has_key(k), repr(k) + assert k in actual, repr(k) fail_if_equal(actual[k], desired[k], 'key=%r\n%s' % (k,err_msg)) return if isinstance(desired, (list,tuple)) and isinstance(actual, (list,tuple)): Modified: trunk/scipy/sandbox/netcdf/netcdf.py =================================================================== --- trunk/scipy/sandbox/netcdf/netcdf.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/netcdf/netcdf.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -4,7 +4,7 @@ import sys -if sys.modules.has_key('pythondoc'): +if 'pythondoc' in sys.modules: # Fake code just for the docstrings! Modified: trunk/scipy/sandbox/newoptimize/log.py =================================================================== --- trunk/scipy/sandbox/newoptimize/log.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/newoptimize/log.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -35,7 +35,7 @@ finished = False if kwargs: - if kwargs.has_key( 'finished' ): + if 'finished' in kwargs: finished = kwargs['finished'] ls = len( args ), self.nArg Modified: trunk/scipy/sandbox/timeseries/parser.py =================================================================== --- trunk/scipy/sandbox/timeseries/parser.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/timeseries/parser.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -12,7 +12,8 @@ 'DateFromString', 'DateTimeFromString' ] -import types,re,string +import types +import re import datetime as dt class RangeError(Exception): pass @@ -275,7 +276,7 @@ if not zone: return 0 uzone = zone.upper() - if _zonetable.has_key(uzone): + if uzone in _zonetable: return _zonetable[uzone]*60 offset = _zoneoffsetRE.match(zone) if not offset: Modified: trunk/scipy/sandbox/timeseries/plotlib.py =================================================================== --- trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -67,7 +67,7 @@ except TypeError: key = str(key) # - if figure_instance._seen.has_key(key): + if key in figure_instance._seen: ax = figure_instance._seen[key] figure_instance.sca(ax) return ax Modified: trunk/scipy/stats/models/cox.py =================================================================== --- trunk/scipy/stats/models/cox.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/stats/models/cox.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -66,7 +66,7 @@ for i in range(len(subjects)): s = subjects[i] if s.delta: - if not self.failures.has_key(s.time): + if s.time not in self.failures: self.failures[s.time] = [i] else: self.failures[s.time].append(i) Modified: trunk/scipy/stats/models/mixed.py =================================================================== --- trunk/scipy/stats/models/mixed.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/stats/models/mixed.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -36,7 +36,7 @@ perform a check whether formula just has an intercept in it, in which case the number of rows must be computed. """ - if hasattr(self, 'n') and not extra.has_key('nrow'): + if hasattr(self, 'n') and 'nrow' not in extra: extra['nrow'] = self.n return formula(namespace=self.dict, **extra) Modified: trunk/scipy/weave/build_tools.py =================================================================== --- trunk/scipy/weave/build_tools.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/weave/build_tools.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -83,7 +83,7 @@ # this is a screwy trick to get rid of a ton of warnings on Unix distutils.sysconfig.get_config_vars() - if distutils.sysconfig._config_vars.has_key('OPT'): + if 'OPT' in distutils.sysconfig._config_vars: flags = distutils.sysconfig._config_vars['OPT'] flags = flags.replace('-Wall','') distutils.sysconfig._config_vars['OPT'] = flags @@ -103,7 +103,7 @@ # the user has also installed numerous packages in their own # location. #-------------------------------------------------------------------- - if os.environ.has_key('PYTHONINCLUDE'): + if 'PYTHONINCLUDE' in os.environ: path_string = os.environ['PYTHONINCLUDE'] if sys.platform == "win32": extra_include_dirs = path_string.split(';') @@ -216,7 +216,7 @@ # this is a screwy trick to get rid of a ton of warnings on Unix import distutils.sysconfig distutils.sysconfig.get_config_vars() - if distutils.sysconfig._config_vars.has_key('OPT'): + if 'OPT' in distutils.sysconfig._config_vars: flags = distutils.sysconfig._config_vars['OPT'] flags = flags.replace('-Wall','') distutils.sysconfig._config_vars['OPT'] = flags Modified: trunk/scipy/weave/bytecodecompiler.py =================================================================== --- trunk/scipy/weave/bytecodecompiler.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/weave/bytecodecompiler.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -703,7 +703,7 @@ ################################################################## def evaluate(self, pc,code): # See if we posted any forwards for this offset - if self.forwards.has_key(pc): + if pc in self.forwards: for f in self.forwards[pc]: f() self.forwards[pc] = [] @@ -948,7 +948,7 @@ # MEMBER POST # ################################################################## def post(self,pc,action): - if not self.forwards.has_key(pc): + if pc not in self.forwards: self.forwards[pc] = [] self.forwards[pc].append(action) return Modified: trunk/scipy/weave/catalog.py =================================================================== --- trunk/scipy/weave/catalog.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/weave/catalog.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -371,7 +371,7 @@ directories. On Windows, a ';' separated list is used. """ paths = [] - if os.environ.has_key('PYTHONCOMPILED'): + if 'PYTHONCOMPILED' in os.environ: path_string = os.environ['PYTHONCOMPILED'] if sys.platform == 'win32': #probably should also look in registry @@ -523,7 +523,7 @@ function_list = [] for path in self.build_search_order(): cat = get_catalog(path,mode) - if cat is not None and cat.has_key(code): + if cat is not None and code in cat: # set up the python path so that modules for this # function can be loaded. self.configure_path(cat,code) @@ -565,7 +565,7 @@ # close the catalog writable_cat.close() return - if writable_cat.has_key(code): + if code in writable_cat: print 'repairing catalog by removing key' del writable_cat[code] @@ -573,7 +573,7 @@ # registered was a built-in function), so we have to check if the path # exists before arbitrarily deleting it. path_key = self.path_key(code) - if writable_cat.has_key(path_key): + if path_key in writable_cat: del writable_cat[path_key] writable_cat.close() @@ -603,7 +603,7 @@ for more info on the search path. """ # Fast!! try cache first. - if self.cache.has_key(code): + if code in self.cache: return self.cache[code] # 2. Slow!! read previously compiled functions from disk. @@ -633,7 +633,7 @@ """ # 1. put it in the cache. - if self.cache.has_key(code): + if code in self.cache: if function not in self.cache[code]: self.cache[code].insert(0,function) else: Modified: trunk/scipy/weave/tests/test_catalog.py =================================================================== --- trunk/scipy/weave/tests/test_catalog.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/weave/tests/test_catalog.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -102,7 +102,7 @@ class TestCatalog(NumpyTestCase): def clear_environ(self): - if os.environ.has_key('PYTHONCOMPILED'): + if 'PYTHONCOMPILED' in os.environ: self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED'] del os.environ['PYTHONCOMPILED'] else: Modified: trunk/scipy/weave/tests/test_scxx_dict.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_dict.py 2007-11-13 07:13:14 UTC (rev 3528) +++ trunk/scipy/weave/tests/test_scxx_dict.py 2007-11-13 08:01:14 UTC (rev 3529) @@ -1,7 +1,8 @@ """ Test refcounting and behavior of SCXX. """ import time -import os,sys +import os +import sys from numpy.testing import * set_package_path() @@ -33,7 +34,7 @@ a = {} a[key] = 12345 code = """ - return_val = a.has_key(key); + return_val = key in a; """ res = inline_tools.inline(code,['a','key']) assert res @@ -41,7 +42,7 @@ a = {} a[1234] = 12345 code = """ - return_val = a.has_key(1234); + return_val = 1234 in a; """ res = inline_tools.inline(code,['a']) assert res @@ -49,7 +50,7 @@ a = {} a[1234.] = 12345 code = """ - return_val = a.has_key(1234.); + return_val = 1234. in a; """ res = inline_tools.inline(code,['a']) assert res @@ -58,7 +59,7 @@ a[1+1j] = 12345 key = 1+1j code = """ - return_val = a.has_key(key); + return_val = key in a; """ res = inline_tools.inline(code,['a','key']) assert res @@ -67,7 +68,7 @@ a = {} a["b"] = 12345 code = """ - return_val = a.has_key("b"); + return_val = "b" in a; """ res = inline_tools.inline(code,['a']) assert res @@ -76,7 +77,7 @@ a["b"] = 12345 key_name = "b" code = """ - return_val = a.has_key(key_name); + return_val = key_name in a; """ res = inline_tools.inline(code,['a','key_name']) assert res @@ -84,7 +85,7 @@ a = {} a["b"] = 12345 code = """ - return_val = a.has_key("c"); + return_val = "c" in a; """ res = inline_tools.inline(code,['a']) assert not res @@ -207,11 +208,11 @@ a = {} a[key] = 1 inline_tools.inline("a.del(key);",['a','key']) - assert not a.has_key(key) + assert key not in a a[key] = 1 before = sys.getrefcount(a), sys.getrefcount(key) inline_tools.inline("a.del(key);",['a','key']) - assert not a.has_key(key) + assert key not in a after = sys.getrefcount(a), sys.getrefcount(key) assert before[0] == after[0] assert before[1] == after[1] + 1 From scipy-svn at scipy.org Tue Nov 13 03:08:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 02:08:24 -0600 (CST) Subject: [Scipy-svn] r3530 - in trunk/scipy: linsolve/umfpack misc Message-ID: <20071113080824.7E98F39C28C@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 02:08:14 -0600 (Tue, 13 Nov 2007) New Revision: 3530 Modified: trunk/scipy/linsolve/umfpack/umfpack.py trunk/scipy/misc/ppimport.py Log: typo Modified: trunk/scipy/linsolve/umfpack/umfpack.py =================================================================== --- trunk/scipy/linsolve/umfpack/umfpack.py 2007-11-13 08:01:14 UTC (rev 3529) +++ trunk/scipy/linsolve/umfpack/umfpack.py 2007-11-13 08:08:14 UTC (rev 3530) @@ -28,7 +28,7 @@ sure that the matrix fulfills this, pass assumeSortedIndices = True to gain some speed. """ - if 'assumeSortedIndices' in kwargs): + if 'assumeSortedIndices' in kwargs: globals()['assumeSortedIndices'] = kwargs['assumeSortedIndices'] Modified: trunk/scipy/misc/ppimport.py =================================================================== --- trunk/scipy/misc/ppimport.py 2007-11-13 08:01:14 UTC (rev 3529) +++ trunk/scipy/misc/ppimport.py 2007-11-13 08:08:14 UTC (rev 3530) @@ -143,7 +143,7 @@ if p_name=='__main__': p_dir = '' fullname = name - elif '__path__' in_frame.f_locals: + elif '__path__' in _frame.f_locals: # python package p_path = p_frame.f_locals['__path__'] p_dir = p_path[0] From scipy-svn at scipy.org Tue Nov 13 04:48:25 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 03:48:25 -0600 (CST) Subject: [Scipy-svn] r3531 - trunk Message-ID: <20071113094825.5CFB739C2D8@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 03:48:17 -0600 (Tue, 13 Nov 2007) New Revision: 3531 Modified: trunk/INSTALL.txt Log: update python version preqs Modified: trunk/INSTALL.txt =================================================================== --- trunk/INSTALL.txt 2007-11-13 08:08:14 UTC (rev 3530) +++ trunk/INSTALL.txt 2007-11-13 09:48:17 UTC (rev 3531) @@ -20,7 +20,7 @@ SciPy requires the following software installed: -1) Python__ 2.3.x or 2.4.x +1) Python__ 2.3.x or newer Debian packages: python python-dev From scipy-svn at scipy.org Tue Nov 13 07:06:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 06:06:58 -0600 (CST) Subject: [Scipy-svn] r3532 - trunk/scipy/sparse/sparsetools Message-ID: <20071113120658.8540439C03E@new.scipy.org> Author: wnbell Date: 2007-11-13 06:06:51 -0600 (Tue, 13 Nov 2007) New Revision: 3532 Modified: trunk/scipy/sparse/sparsetools/sparsetools.py trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx Log: regenerated sparsetools with swig to address ticket #537 Modified: trunk/scipy/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/scipy/sparse/sparsetools/sparsetools.py 2007-11-13 09:48:17 UTC (rev 3531) +++ trunk/scipy/sparse/sparsetools/sparsetools.py 2007-11-13 12:06:51 UTC (rev 3532) @@ -51,1608 +51,1609 @@ def extract_csr_diagonal(*args): + """ + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(signed char)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(unsigned char)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(long long)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(npy_cfloat_wrapper)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(npy_cdouble_wrapper)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(signed char)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(unsigned char)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(short)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(int)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(float)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(double)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) """ - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(signed char)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(unsigned char)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(long long)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(npy_cfloat_wrapper)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(npy_cdouble_wrapper)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(signed char)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(unsigned char)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(short)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(int)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(float)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(double)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) - """ - return _sparsetools.extract_csr_diagonal(*args) + return _sparsetools.extract_csr_diagonal(*args) def extract_csc_diagonal(*args): + """ + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(signed char)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(unsigned char)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(long long)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(npy_cfloat_wrapper)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(npy_cdouble_wrapper)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(signed char)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(unsigned char)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(short)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(int)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(float)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(double)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) """ - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(signed char)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(unsigned char)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(long long)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(npy_cfloat_wrapper)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(npy_cdouble_wrapper)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(signed char)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(unsigned char)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(short)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(int)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(float)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(double)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) - """ - return _sparsetools.extract_csc_diagonal(*args) + return _sparsetools.extract_csc_diagonal(*args) def csrtocsc(*args): + """ + csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(signed char)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(unsigned char)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(short)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(int)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long long)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(float)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(double)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(signed char)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(short)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(int)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(long long)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(float)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(double)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) """ - csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(signed char)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(unsigned char)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(short)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(int)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long long)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(float)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(double)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(signed char)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(short)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(int)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(long long)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(float)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(double)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.csrtocsc(*args) + return _sparsetools.csrtocsc(*args) def csctocsr(*args): + """ + csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) """ - csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.csctocsr(*args) + return _sparsetools.csctocsr(*args) def csrtocoo(*args): + """ + csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) """ - csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.csrtocoo(*args) + return _sparsetools.csrtocoo(*args) def csctocoo(*args): + """ + csctocoo(int n_row, int n_col, int Ap, int Ai, signed char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, long long Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) """ - csctocoo(int n_row, int n_col, int Ap, int Ai, signed char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, long long Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.csctocoo(*args) + return _sparsetools.csctocoo(*args) def cootocsr(*args): + """ + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(short)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(int)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(float)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(double)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(signed char)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(unsigned char)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(short)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(int)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(long long)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(float)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(double)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cfloat_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cdouble_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) """ - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(short)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(int)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(float)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(double)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(signed char)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(unsigned char)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(short)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(int)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(long long)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(float)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(double)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cfloat_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cdouble_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.cootocsr(*args) + return _sparsetools.cootocsr(*args) def cootocsc(*args): + """ + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(signed char)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(unsigned char)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(short)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(int)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long long)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(float)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(double)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(signed char)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(unsigned char)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(short)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(int)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(long long)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(float)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(double)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cfloat_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cdouble_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) """ - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(signed char)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(unsigned char)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(short)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(int)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long long)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(float)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(double)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(signed char)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(unsigned char)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(short)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(int)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(long long)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(float)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(double)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cfloat_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cdouble_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.cootocsc(*args) + return _sparsetools.cootocsc(*args) def csrmucsr(*args): + """ + csrmucsr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(signed char)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(int)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(double)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) """ - csrmucsr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(signed char)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(int)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(double)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csrmucsr(*args) + return _sparsetools.csrmucsr(*args) def cscmucsc(*args): + """ + cscmucsc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(signed char)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(int)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(double)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) """ - cscmucsc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(signed char)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(int)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(double)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.cscmucsc(*args) + return _sparsetools.cscmucsc(*args) def csrmux(*args): + """ + csrmux(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx, std::vector<(signed char)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx, std::vector<(unsigned char)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, + std::vector<(short)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, + std::vector<(int)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx, std::vector<(long long)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, + std::vector<(float)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, + std::vector<(double)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, signed char Xx, std::vector<(signed char)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, unsigned char Xx, + std::vector<(unsigned char)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, short Xx, std::vector<(short)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, int Xx, std::vector<(int)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Xx, std::vector<(long long)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, float Xx, std::vector<(float)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, double Xx, std::vector<(double)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + std::vector<(npy_cfloat_wrapper)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + std::vector<(npy_cdouble_wrapper)> Yx) """ - csrmux(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx, std::vector<(signed char)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx, std::vector<(unsigned char)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, - std::vector<(short)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, - std::vector<(int)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx, std::vector<(long long)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, - std::vector<(float)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, - std::vector<(double)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, signed char Xx, std::vector<(signed char)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, unsigned char Xx, - std::vector<(unsigned char)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, short Xx, std::vector<(short)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, int Xx, std::vector<(int)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Xx, std::vector<(long long)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, float Xx, std::vector<(float)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, double Xx, std::vector<(double)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - std::vector<(npy_cfloat_wrapper)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - std::vector<(npy_cdouble_wrapper)> Yx) - """ - return _sparsetools.csrmux(*args) + return _sparsetools.csrmux(*args) def cscmux(*args): + """ + cscmux(int n_row, int n_col, int Ap, int Ai, signed char Ax, + signed char Xx, std::vector<(signed char)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + unsigned char Xx, std::vector<(unsigned char)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, + std::vector<(short)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, + std::vector<(int)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, long long Ax, + long long Xx, std::vector<(long long)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, + std::vector<(float)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, + std::vector<(double)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, signed char Xx, std::vector<(signed char)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, unsigned char Xx, + std::vector<(unsigned char)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, short Xx, std::vector<(short)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, int Xx, std::vector<(int)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Xx, std::vector<(long long)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, float Xx, std::vector<(float)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, double Xx, std::vector<(double)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + std::vector<(npy_cfloat_wrapper)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + std::vector<(npy_cdouble_wrapper)> Yx) """ - cscmux(int n_row, int n_col, int Ap, int Ai, signed char Ax, - signed char Xx, std::vector<(signed char)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - unsigned char Xx, std::vector<(unsigned char)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, - std::vector<(short)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, - std::vector<(int)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, long long Ax, - long long Xx, std::vector<(long long)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, - std::vector<(float)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, - std::vector<(double)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, signed char Xx, std::vector<(signed char)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, unsigned char Xx, - std::vector<(unsigned char)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, short Xx, std::vector<(short)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, int Xx, std::vector<(int)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Xx, std::vector<(long long)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, float Xx, std::vector<(float)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, double Xx, std::vector<(double)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - std::vector<(npy_cfloat_wrapper)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - std::vector<(npy_cdouble_wrapper)> Yx) - """ - return _sparsetools.cscmux(*args) + return _sparsetools.cscmux(*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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csr_elmul_csr(*args) + return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csr_eldiv_csr(*args) + return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csr_plus_csr(*args) + return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csr_minus_csr(*args) + return _sparsetools.csr_minus_csr(*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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csc_elmul_csc(*args) + return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csc_eldiv_csc(*args) + return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csc_plus_csc(*args) + return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - """ - return _sparsetools.csc_minus_csc(*args) + return _sparsetools.csc_minus_csc(*args) def spdiags(*args): + """ + spdiags(int n_row, int n_col, int n_diag, int offsets, signed char diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(signed char)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, unsigned char diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(unsigned char)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, short diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(short)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(int)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, long long diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(long long)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(float)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(double)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat_wrapper diags, + std::vector<(int)> Ap, + std::vector<(int)> Ai, std::vector<(npy_cfloat_wrapper)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble_wrapper diags, + std::vector<(int)> Ap, + std::vector<(int)> Ai, std::vector<(npy_cdouble_wrapper)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, signed char diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(signed char)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, unsigned char diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(unsigned char)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, short diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(short)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, int diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, std::vector<(int)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, long long diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(long long)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, float diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(float)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, double diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(double)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, npy_cfloat_wrapper diags, + std::vector<(long long)> Ap, std::vector<(long long)> Ai, + std::vector<(npy_cfloat_wrapper)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, npy_cdouble_wrapper diags, + std::vector<(long long)> Ap, std::vector<(long long)> Ai, + std::vector<(npy_cdouble_wrapper)> Ax) """ - spdiags(int n_row, int n_col, int n_diag, int offsets, signed char diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(signed char)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, unsigned char diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(unsigned char)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, short diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(short)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(int)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, long long diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(long long)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(float)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(double)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat_wrapper diags, - std::vector<(int)> Ap, - std::vector<(int)> Ai, std::vector<(npy_cfloat_wrapper)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble_wrapper diags, - std::vector<(int)> Ap, - std::vector<(int)> Ai, std::vector<(npy_cdouble_wrapper)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, signed char diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(signed char)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, unsigned char diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(unsigned char)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, short diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(short)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, int diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, std::vector<(int)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, long long diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(long long)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, float diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(float)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, double diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(double)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, npy_cfloat_wrapper diags, - std::vector<(long long)> Ap, std::vector<(long long)> Ai, - std::vector<(npy_cfloat_wrapper)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, npy_cdouble_wrapper diags, - std::vector<(long long)> Ap, std::vector<(long long)> Ai, - std::vector<(npy_cdouble_wrapper)> Ax) - """ - return _sparsetools.spdiags(*args) + return _sparsetools.spdiags(*args) def csrtodense(*args): + """ + csrtodense(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, short Ax, short Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, signed char Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, unsigned char Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, short Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, int Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, float Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, double Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Mx) """ - csrtodense(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, short Ax, short Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, signed char Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, unsigned char Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, short Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, int Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, float Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, double Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Mx) - """ - return _sparsetools.csrtodense(*args) + return _sparsetools.csrtodense(*args) def densetocsr(*args): + """ + densetocsr(int n_row, int n_col, signed char Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(signed char)> Ax) + densetocsr(int n_row, int n_col, unsigned char Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(unsigned char)> Ax) + densetocsr(int n_row, int n_col, short Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(short)> Ax) + densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(int)> Ax) + densetocsr(int n_row, int n_col, long long Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(long long)> Ax) + densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(float)> Ax) + densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(double)> Ax) + densetocsr(int n_row, int n_col, npy_cfloat_wrapper Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cfloat_wrapper)> Ax) + densetocsr(int n_row, int n_col, npy_cdouble_wrapper Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cdouble_wrapper)> Ax) + densetocsr(long long n_row, long long n_col, signed char Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(signed char)> Ax) + densetocsr(long long n_row, long long n_col, unsigned char Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(unsigned char)> Ax) + densetocsr(long long n_row, long long n_col, short Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(short)> Ax) + densetocsr(long long n_row, long long n_col, int Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(int)> Ax) + densetocsr(long long n_row, long long n_col, long long Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(long long)> Ax) + densetocsr(long long n_row, long long n_col, float Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(float)> Ax) + densetocsr(long long n_row, long long n_col, double Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(double)> Ax) + densetocsr(long long n_row, long long n_col, npy_cfloat_wrapper Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(npy_cfloat_wrapper)> Ax) + densetocsr(long long n_row, long long n_col, npy_cdouble_wrapper Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(npy_cdouble_wrapper)> Ax) """ - densetocsr(int n_row, int n_col, signed char Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(signed char)> Ax) - densetocsr(int n_row, int n_col, unsigned char Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(unsigned char)> Ax) - densetocsr(int n_row, int n_col, short Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(short)> Ax) - densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(int)> Ax) - densetocsr(int n_row, int n_col, long long Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(long long)> Ax) - densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(float)> Ax) - densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(double)> Ax) - densetocsr(int n_row, int n_col, npy_cfloat_wrapper Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_cfloat_wrapper)> Ax) - densetocsr(int n_row, int n_col, npy_cdouble_wrapper Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_cdouble_wrapper)> Ax) - densetocsr(long long n_row, long long n_col, signed char Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(signed char)> Ax) - densetocsr(long long n_row, long long n_col, unsigned char Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(unsigned char)> Ax) - densetocsr(long long n_row, long long n_col, short Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(short)> Ax) - densetocsr(long long n_row, long long n_col, int Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(int)> Ax) - densetocsr(long long n_row, long long n_col, long long Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(long long)> Ax) - densetocsr(long long n_row, long long n_col, float Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(float)> Ax) - densetocsr(long long n_row, long long n_col, double Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(double)> Ax) - densetocsr(long long n_row, long long n_col, npy_cfloat_wrapper Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(npy_cfloat_wrapper)> Ax) - densetocsr(long long n_row, long long n_col, npy_cdouble_wrapper Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(npy_cdouble_wrapper)> Ax) - """ - return _sparsetools.densetocsr(*args) + return _sparsetools.densetocsr(*args) def sort_csr_indices(*args): + """ + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, signed char Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, short Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, int Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, long long Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, float Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, double Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax) """ - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, signed char Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, short Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, int Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, long long Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, float Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, double Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax) - """ - return _sparsetools.sort_csr_indices(*args) + return _sparsetools.sort_csr_indices(*args) def sort_csc_indices(*args): + """ + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, signed char Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, short Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, int Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, long long Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, float Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, double Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax) """ - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, signed char Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, short Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, int Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, long long Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, float Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, double Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax) - """ - return _sparsetools.sort_csc_indices(*args) + return _sparsetools.sort_csc_indices(*args) def sum_csr_duplicates(*args): + """ + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax) """ - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax) - """ - return _sparsetools.sum_csr_duplicates(*args) + return _sparsetools.sum_csr_duplicates(*args) def sum_csc_duplicates(*args): + """ + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, signed char Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, short Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, int Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, long long Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, float Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, double Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax) """ - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, signed char Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, short Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, int Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, long long Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, float Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, double Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax) - """ - return _sparsetools.sum_csc_duplicates(*args) + return _sparsetools.sum_csc_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, 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, 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, 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, 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(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(signed char)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(unsigned char)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(short)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(int)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(long long)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(float)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(double)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long ir0, + long long ir1, long long ic0, long long ic1, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long ir0, + long long ir1, long long ic0, long long ic1, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cdouble_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, 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, 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, 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, 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(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(signed char)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(unsigned char)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(short)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(int)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(long long)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(float)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(double)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long ir0, - long long ir1, long long ic0, long long ic1, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long ir0, - long long ir1, long long ic0, long long ic1, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - """ - return _sparsetools.get_csr_submatrix(*args) + return _sparsetools.get_csr_submatrix(*args) + Modified: trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx 2007-11-13 09:48:17 UTC (rev 3531) +++ trunk/scipy/sparse/sparsetools/sparsetools_wrap.cxx 2007-11-13 12:06:51 UTC (rev 3532) @@ -12,7 +12,7 @@ #define SWIG_PYTHON_DIRECTOR_NO_VTABLE #ifdef __cplusplus -template class SwigValueWrapper { +template class SwigValueWrapper { T *tt; public: SwigValueWrapper() : tt(0) { } @@ -25,6 +25,10 @@ private: SwigValueWrapper& operator=(const SwigValueWrapper& rhs); }; + +template T SwigValueInit() { + return T(); +} #endif /* ----------------------------------------------------------------------------- @@ -124,7 +128,13 @@ # define _CRT_SECURE_NO_DEPRECATE #endif +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + /* Python.h has to appear first */ #include @@ -360,7 +370,7 @@ while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } - return (l1 - f1) - (l2 - f2); + return (int)((l1 - f1) - (l2 - f2)); } /* @@ -1107,7 +1117,7 @@ /* Unpack the argument tuple */ SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { @@ -1122,7 +1132,7 @@ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { - register int l = PyTuple_GET_SIZE(args); + register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), min, l); @@ -2926,15 +2936,13 @@ #include -#ifndef LLONG_MIN -# define LLONG_MIN LONG_LONG_MIN +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif #endif -#ifndef LLONG_MAX -# define LLONG_MAX LONG_LONG_MAX -#endif -#ifndef ULLONG_MAX -# define ULLONG_MAX ULONG_LONG_MAX -#endif SWIGINTERN int @@ -4971,7 +4979,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -5535,7 +5543,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'extract_csr_diagonal'.\n Possible C/C++ prototypes are:\n extract_csr_diagonal<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *)\n extract_csr_diagonal<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *)\n extract_csr_diagonal<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *)\n extract_csr_diagonal<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *)\n extract_csr_diagonal<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *)\n extract_csr_diagonal<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *)\n extract_csr_diagonal<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *)\n extract_csr_diagonal<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *)\n extract_csr_diagonal<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *)\n extract_csr_diagonal<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *)\n extract_csr_diagonal<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *)\n extract_csr_diagonal<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *)\n extract_csr_diagonal<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *)\n extract_csr_diagonal<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *)\n extract_csr_diagonal<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *)\n extract_csr_diagonal<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *)\n extract_csr_diagonal<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *)\n extract_csr_diagonal<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'extract_csr_diagonal'.\n Possible C/C++ prototypes are:\n"" extract_csr_diagonal<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *)\n"" extract_csr_diagonal<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *)\n"" extract_csr_diagonal<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *)\n"" extract_csr_diagonal<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *)\n"" extract_csr_diagonal<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *)\n"" extract_csr_diagonal<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *)\n"" extract_csr_diagonal<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *)\n"" extract_csr_diagonal<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *)\n"" extract_csr_diagonal<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *)\n"" extract_csr_diagonal<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *)\n"" extract_csr_diagonal<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *)\n"" extract_csr_diagonal<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *)\n"" extract_csr_diagonal<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *)\n"" extract_csr_diagonal<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *)\n"" extract_csr_diagonal<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *)\n"" extract_csr_diagonal<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *)\n"" extract_csr_diagonal<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *)\n"" extract_csr_diagonal<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *)\n"); return NULL; } @@ -7400,7 +7408,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -7964,7 +7972,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'extract_csc_diagonal'.\n Possible C/C++ prototypes are:\n extract_csc_diagonal<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *)\n extract_csc_diagonal<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *)\n extract_csc_diagonal<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *)\n extract_csc_diagonal<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *)\n extract_csc_diagonal<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *)\n extract_csc_diagonal<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *)\n extract_csc_diagonal<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *)\n extract_csc_diagonal<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *)\n extract_csc_diagonal<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *)\n extract_csc_diagonal<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *)\n extract_csc_diagonal<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *)\n extract_csc_diagonal<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *)\n extract_csc_diagonal<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *)\n extract_csc_diagonal<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *)\n extract_csc_diagonal<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *)\n extract_csc_diagonal<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *)\n extract_csc_diagonal<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *)\n extract_csc_diagonal<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'extract_csc_diagonal'.\n Possible C/C++ prototypes are:\n"" extract_csc_diagonal<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *)\n"" extract_csc_diagonal<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *)\n"" extract_csc_diagonal<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *)\n"" extract_csc_diagonal<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *)\n"" extract_csc_diagonal<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *)\n"" extract_csc_diagonal<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *)\n"" extract_csc_diagonal<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *)\n"" extract_csc_diagonal<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *)\n"" extract_csc_diagonal<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *)\n"" extract_csc_diagonal<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *)\n"" extract_csc_diagonal<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *)\n"" extract_csc_diagonal<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *)\n"" extract_csc_diagonal<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *)\n"" extract_csc_diagonal<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *)\n"" extract_csc_diagonal<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *)\n"" extract_csc_diagonal<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *)\n"" extract_csc_diagonal<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *)\n"" extract_csc_diagonal<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *)\n"); return NULL; } @@ -10297,7 +10305,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -10861,7 +10869,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n csrtocsc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n"" csrtocsc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrtocsc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -13194,7 +13202,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -13758,7 +13766,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n csctocsr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n"" csctocsr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csctocsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -16091,7 +16099,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -16655,7 +16663,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n csrtocoo<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n"" csrtocoo<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrtocoo<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -18988,7 +18996,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -19552,7 +19560,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n csctocoo<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n"" csctocoo<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,short)>(int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,long long)>(int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csctocoo<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -22047,7 +22055,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -22719,7 +22727,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n cootocsr<(int,signed char)>(int const,int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,unsigned char)>(int const,int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,short)>(int const,int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,int)>(int const,int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,long long)>(int const,int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,npy_cfloat_wrapper)>(int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,npy_cdouble_wrapper)>(int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,signed char)>(long long const,long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,unsigned char)>(long long const,long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,short)>(long long const,long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,int)>(long long const,long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,long long)>(long long const,long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,float)>(long long const,long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,double)>(long long const,long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n"" cootocsr<(int,signed char)>(int const,int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,unsigned char)>(int const,int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,short)>(int const,int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,int)>(int const,int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,long long)>(int const,int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,npy_cfloat_wrapper)>(int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(int,npy_cdouble_wrapper)>(int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,signed char)>(long long const,long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,unsigned char)>(long long const,long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,short)>(long long const,long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,int)>(long long const,long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,long long)>(long long const,long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,float)>(long long const,long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,double)>(long long const,long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cootocsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -25214,7 +25222,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -25886,7 +25894,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n cootocsc<(int,signed char)>(int const,int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,unsigned char)>(int const,int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,short)>(int const,int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,int)>(int const,int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,long long)>(int const,int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,npy_cfloat_wrapper)>(int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,npy_cdouble_wrapper)>(int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,signed char)>(long long const,long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,unsigned char)>(long long const,long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,short)>(long long const,long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,int)>(long long const,long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,long long)>(long long const,long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,float)>(long long const,long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,double)>(long long const,long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n"" cootocsc<(int,signed char)>(int const,int const,int const,int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,unsigned char)>(int const,int const,int const,int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,short)>(int const,int const,int const,int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,int)>(int const,int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,long long)>(int const,int const,int const,int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,npy_cfloat_wrapper)>(int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(int,npy_cdouble_wrapper)>(int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,signed char)>(long long const,long long const,long long const,long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,unsigned char)>(long long const,long long const,long long const,long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,short)>(long long const,long long const,long long const,long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,int)>(long long const,long long const,long long const,long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,long long)>(long long const,long long const,long long const,long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,float)>(long long const,long long const,long long const,long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,double)>(long long const,long long const,long long const,long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cootocsc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -29299,7 +29307,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -30133,7 +30141,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n csrmucsr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n"" csrmucsr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csrmucsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -33546,7 +33554,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -34380,7 +34388,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n cscmucsc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n"" cscmucsc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" cscmucsc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -36605,7 +36613,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -37259,7 +37267,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n csrmux<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],signed char const [],std::vector *)\n csrmux<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],std::vector *)\n csrmux<(int,short)>(int const,int const,int const [],int const [],short const [],short const [],std::vector *)\n csrmux<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],std::vector *)\n csrmux<(int,long long)>(int const,int const,int const [],int const [],long long const [],long long const [],std::vector *)\n csrmux<(int,float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n csrmux<(int,double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n csrmux<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n csrmux<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n csrmux<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],signed char const [],std::vector *)\n csrmux<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],unsigned char const [],std::vector *)\n csrmux<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],short const [],std::vector *)\n csrmux<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],int const [],std::vector *)\n csrmux<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],std::vector *)\n csrmux<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],float const [],std::vector *)\n csrmux<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],double const [],std::vector *)\n csrmux<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n csrmux<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n"" csrmux<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],signed char const [],std::vector *)\n"" csrmux<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],std::vector *)\n"" csrmux<(int,short)>(int const,int const,int const [],int const [],short const [],short const [],std::vector *)\n"" csrmux<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],std::vector *)\n"" csrmux<(int,long long)>(int const,int const,int const [],int const [],long long const [],long long const [],std::vector *)\n"" csrmux<(int,float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n"" csrmux<(int,double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n"" csrmux<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n"" csrmux<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n"" csrmux<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],signed char const [],std::vector *)\n"" csrmux<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],unsigned char const [],std::vector *)\n"" csrmux<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],short const [],std::vector *)\n"" csrmux<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],int const [],std::vector *)\n"" csrmux<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],std::vector *)\n"" csrmux<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],float const [],std::vector *)\n"" csrmux<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],double const [],std::vector *)\n"" csrmux<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n"" csrmux<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n"); return NULL; } @@ -39484,7 +39492,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -40138,7 +40146,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n cscmux<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],signed char const [],std::vector *)\n cscmux<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],std::vector *)\n cscmux<(int,short)>(int const,int const,int const [],int const [],short const [],short const [],std::vector *)\n cscmux<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],std::vector *)\n cscmux<(int,long long)>(int const,int const,int const [],int const [],long long const [],long long const [],std::vector *)\n cscmux<(int,float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n cscmux<(int,double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n cscmux<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n cscmux<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n cscmux<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],signed char const [],std::vector *)\n cscmux<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],unsigned char const [],std::vector *)\n cscmux<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],short const [],std::vector *)\n cscmux<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],int const [],std::vector *)\n cscmux<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],std::vector *)\n cscmux<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],float const [],std::vector *)\n cscmux<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],double const [],std::vector *)\n cscmux<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n cscmux<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n"" cscmux<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],signed char const [],std::vector *)\n"" cscmux<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],std::vector *)\n"" cscmux<(int,short)>(int const,int const,int const [],int const [],short const [],short const [],std::vector *)\n"" cscmux<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],std::vector *)\n"" cscmux<(int,long long)>(int const,int const,int const [],int const [],long long const [],long long const [],std::vector *)\n"" cscmux<(int,float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n"" cscmux<(int,double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n"" cscmux<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n"" cscmux<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n"" cscmux<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],signed char const [],std::vector *)\n"" cscmux<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],unsigned char const [],std::vector *)\n"" cscmux<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],short const [],std::vector *)\n"" cscmux<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],int const [],std::vector *)\n"" cscmux<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],std::vector *)\n"" cscmux<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],float const [],std::vector *)\n"" cscmux<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],double const [],std::vector *)\n"" cscmux<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],std::vector *)\n"" cscmux<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],std::vector *)\n"); return NULL; } @@ -43551,7 +43559,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -44385,7 +44393,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_elmul_csr'.\n Possible C/C++ prototypes are:\n csr_elmul_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_elmul_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_elmul_csr'.\n Possible C/C++ prototypes are:\n"" csr_elmul_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_elmul_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -47798,7 +47806,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -48632,7 +48640,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_eldiv_csr'.\n Possible C/C++ prototypes are:\n csr_eldiv_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_eldiv_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_eldiv_csr'.\n Possible C/C++ prototypes are:\n"" csr_eldiv_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_eldiv_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -52045,7 +52053,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -52879,7 +52887,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_plus_csr'.\n Possible C/C++ prototypes are:\n csr_plus_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_plus_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_plus_csr'.\n Possible C/C++ prototypes are:\n"" csr_plus_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_plus_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -56292,7 +56300,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -57126,7 +57134,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_minus_csr'.\n Possible C/C++ prototypes are:\n csr_minus_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csr_minus_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_minus_csr'.\n Possible C/C++ prototypes are:\n"" csr_minus_csr<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csr_minus_csr<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -60539,7 +60547,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -61373,7 +61381,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_elmul_csc'.\n Possible C/C++ prototypes are:\n csc_elmul_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_elmul_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_elmul_csc'.\n Possible C/C++ prototypes are:\n"" csc_elmul_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_elmul_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -64786,7 +64794,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -65620,7 +65628,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_eldiv_csc'.\n Possible C/C++ prototypes are:\n csc_eldiv_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_eldiv_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_eldiv_csc'.\n Possible C/C++ prototypes are:\n"" csc_eldiv_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_eldiv_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -69033,7 +69041,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -69867,7 +69875,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_plus_csc'.\n Possible C/C++ prototypes are:\n csc_plus_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_plus_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_plus_csc'.\n Possible C/C++ prototypes are:\n"" csc_plus_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_plus_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -73280,7 +73288,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 8); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -74114,7 +74122,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_minus_csc'.\n Possible C/C++ prototypes are:\n csc_minus_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n csc_minus_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_minus_csc'.\n Possible C/C++ prototypes are:\n"" csc_minus_csc<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,short)>(int const,int const,int const [],int const [],short const [],int const [],int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const [],int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const [],int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const [],int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const [],long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const [],long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const [],long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const [],long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const [],long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const [],long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const [],long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const [],long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" csc_minus_csc<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const [],long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -76231,7 +76239,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -76813,7 +76821,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n spdiags<(int,signed char)>(int const,int const,int const,int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,unsigned char)>(int const,int const,int const,int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,short)>(int const,int const,int const,int const [],short const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,int)>(int const,int const,int const,int const [],int const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,long long)>(int const,int const,int const,int const [],long long const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,npy_cfloat_wrapper)>(int const,int const,int const,int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,npy_cdouble_wrapper)>(int const,int const,int const,int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,signed char)>(long long const,long long const,long long const,long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,unsigned char)>(long long const,long long const,long long const,long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,short)>(long long const,long long const,long long const,long long const [],short const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,int)>(long long const,long long const,long long const,long long const [],int const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,long long)>(long long const,long long const,long long const,long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,float)>(long long const,long long const,long long const,long long const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,double)>(long long const,long long const,long long const,long long const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const,long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const,long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n"" spdiags<(int,signed char)>(int const,int const,int const,int const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,unsigned char)>(int const,int const,int const,int const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,short)>(int const,int const,int const,int const [],short const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,int)>(int const,int const,int const,int const [],int const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,long long)>(int const,int const,int const,int const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,npy_cfloat_wrapper)>(int const,int const,int const,int const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(int,npy_cdouble_wrapper)>(int const,int const,int const,int const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,signed char)>(long long const,long long const,long long const,long long const [],signed char const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,unsigned char)>(long long const,long long const,long long const,long long const [],unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,short)>(long long const,long long const,long long const,long long const [],short const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,int)>(long long const,long long const,long long const,long long const [],int const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,long long)>(long long const,long long const,long long const,long long const [],long long const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,float)>(long long const,long long const,long long const,long long const [],float const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,double)>(long long const,long long const,long long const,long long const [],double const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const,long long const [],npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" spdiags<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const,long long const [],npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -78588,7 +78596,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -79242,7 +79250,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n csrtodense<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],signed char [])\n csrtodense<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],unsigned char [])\n csrtodense<(int,short)>(int const,int const,int const [],int const [],short const [],short [])\n csrtodense<(int,int)>(int const,int const,int const [],int const [],int const [],int [])\n csrtodense<(int,long long)>(int const,int const,int const [],int const [],long long const [],long long [])\n csrtodense<(int,float)>(int const,int const,int const [],int const [],float const [],float [])\n csrtodense<(int,double)>(int const,int const,int const [],int const [],double const [],double [])\n csrtodense<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n csrtodense<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n csrtodense<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],signed char [])\n csrtodense<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],unsigned char [])\n csrtodense<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],short [])\n csrtodense<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],int [])\n csrtodense<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long [])\n csrtodense<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],float [])\n csrtodense<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],double [])\n csrtodense<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n csrtodense<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n"" csrtodense<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],signed char [])\n"" csrtodense<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],unsigned char [])\n"" csrtodense<(int,short)>(int const,int const,int const [],int const [],short const [],short [])\n"" csrtodense<(int,int)>(int const,int const,int const [],int const [],int const [],int [])\n"" csrtodense<(int,long long)>(int const,int const,int const [],int const [],long long const [],long long [])\n"" csrtodense<(int,float)>(int const,int const,int const [],int const [],float const [],float [])\n"" csrtodense<(int,double)>(int const,int const,int const [],int const [],double const [],double [])\n"" csrtodense<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n"" csrtodense<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n"" csrtodense<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],signed char [])\n"" csrtodense<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],unsigned char [])\n"" csrtodense<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],short [])\n"" csrtodense<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],int [])\n"" csrtodense<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long [])\n"" csrtodense<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],float [])\n"" csrtodense<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],double [])\n"" csrtodense<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n"" csrtodense<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n"); return NULL; } @@ -80837,7 +80845,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 3); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -81221,7 +81229,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n densetocsr<(int,signed char)>(int const,int const,signed char const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,unsigned char)>(int const,int const,unsigned char const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,short)>(int const,int const,short const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,int)>(int const,int const,int const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,long long)>(int const,int const,long long const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,npy_cfloat_wrapper)>(int const,int const,npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,npy_cdouble_wrapper)>(int const,int const,npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,signed char)>(long long const,long long const,signed char const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,unsigned char)>(long long const,long long const,unsigned char const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,short)>(long long const,long long const,short const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,int)>(long long const,long long const,int const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,long long)>(long long const,long long const,long long const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,float)>(long long const,long long const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,double)>(long long const,long long const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n"" densetocsr<(int,signed char)>(int const,int const,signed char const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,unsigned char)>(int const,int const,unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,short)>(int const,int const,short const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,int)>(int const,int const,int const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,long long)>(int const,int const,long long const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,npy_cfloat_wrapper)>(int const,int const,npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(int,npy_cdouble_wrapper)>(int const,int const,npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,signed char)>(long long const,long long const,signed char const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,unsigned char)>(long long const,long long const,unsigned char const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,short)>(long long const,long long const,short const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,int)>(long long const,long long const,int const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,long long)>(long long const,long long const,long long const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,float)>(long long const,long long const,float const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,double)>(long long const,long long const,double const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,npy_cfloat_wrapper)>(long long const,long long const,npy_cfloat_wrapper const [],std::vector *,std::vector *,std::vector *)\n"" densetocsr<(long long,npy_cdouble_wrapper)>(long long const,long long const,npy_cdouble_wrapper const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -82420,7 +82428,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -82984,7 +82992,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sort_csr_indices'.\n Possible C/C++ prototypes are:\n sort_csr_indices<(int,signed char)>(int const,int const,int const [],int [],signed char [])\n sort_csr_indices<(int,unsigned char)>(int const,int const,int const [],int [],unsigned char [])\n sort_csr_indices<(int,short)>(int const,int const,int const [],int [],short [])\n sort_csr_indices<(int,int)>(int const,int const,int const [],int [],int [])\n sort_csr_indices<(int,long long)>(int const,int const,int const [],int [],long long [])\n sort_csr_indices<(int,float)>(int const,int const,int const [],int [],float [])\n sort_csr_indices<(int,double)>(int const,int const,int const [],int [],double [])\n sort_csr_indices<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int [],npy_cfloat_wrapper [])\n sort_csr_indices<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int [],npy_cdouble_wrapper [])\n sort_csr_indices<(long long,signed char)>(long long const,long long const,long long const [],long long [],signed char [])\n sort_csr_indices<(long long,unsigned char)>(long long const,long long const,long long const [],long long [],unsigned char [])\n sort_csr_indices<(long long,short)>(long long const,long long const,long long const [],long long [],short [])\n sort_csr_indices<(long long,int)>(long long const,long long const,long long const [],long long [],int [])\n sort_csr_indices<(long long,long long)>(long long const,long long const,long long const [],long long [],long long [])\n sort_csr_indices<(long long,float)>(long long const,long long const,long long const [],long long [],float [])\n sort_csr_indices<(long long,double)>(long long const,long long const,long long const [],long long [],double [])\n sort_csr_indices<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long [],npy_cfloat_wrapper [])\n sort_csr_indices<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long [],npy_cdouble_wrapper [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sort_csr_indices'.\n Possible C/C++ prototypes are:\n"" sort_csr_indices<(int,signed char)>(int const,int const,int const [],int [],signed char [])\n"" sort_csr_indices<(int,unsigned char)>(int const,int const,int const [],int [],unsigned char [])\n"" sort_csr_indices<(int,short)>(int const,int const,int const [],int [],short [])\n"" sort_csr_indices<(int,int)>(int const,int const,int const [],int [],int [])\n"" sort_csr_indices<(int,long long)>(int const,int const,int const [],int [],long long [])\n"" sort_csr_indices<(int,float)>(int const,int const,int const [],int [],float [])\n"" sort_csr_indices<(int,double)>(int const,int const,int const [],int [],double [])\n"" sort_csr_indices<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int [],npy_cfloat_wrapper [])\n"" sort_csr_indices<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int [],npy_cdouble_wrapper [])\n"" sort_csr_indices<(long long,signed char)>(long long const,long long const,long long const [],long long [],signed char [])\n"" sort_csr_indices<(long long,unsigned char)>(long long const,long long const,long long const [],long long [],unsigned char [])\n"" sort_csr_indices<(long long,short)>(long long const,long long const,long long const [],long long [],short [])\n"" sort_csr_indices<(long long,int)>(long long const,long long const,long long const [],long long [],int [])\n"" sort_csr_indices<(long long,long long)>(long long const,long long const,long long const [],long long [],long long [])\n"" sort_csr_indices<(long long,float)>(long long const,long long const,long long const [],long long [],float [])\n"" sort_csr_indices<(long long,double)>(long long const,long long const,long long const [],long long [],double [])\n"" sort_csr_indices<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long [],npy_cfloat_wrapper [])\n"" sort_csr_indices<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long [],npy_cdouble_wrapper [])\n"); return NULL; } @@ -84201,7 +84209,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -84765,7 +84773,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sort_csc_indices'.\n Possible C/C++ prototypes are:\n sort_csc_indices<(int,signed char)>(int const,int const,int const [],int [],signed char [])\n sort_csc_indices<(int,unsigned char)>(int const,int const,int const [],int [],unsigned char [])\n sort_csc_indices<(int,short)>(int const,int const,int const [],int [],short [])\n sort_csc_indices<(int,int)>(int const,int const,int const [],int [],int [])\n sort_csc_indices<(int,long long)>(int const,int const,int const [],int [],long long [])\n sort_csc_indices<(int,float)>(int const,int const,int const [],int [],float [])\n sort_csc_indices<(int,double)>(int const,int const,int const [],int [],double [])\n sort_csc_indices<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int [],npy_cfloat_wrapper [])\n sort_csc_indices<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int [],npy_cdouble_wrapper [])\n sort_csc_indices<(long long,signed char)>(long long const,long long const,long long const [],long long [],signed char [])\n sort_csc_indices<(long long,unsigned char)>(long long const,long long const,long long const [],long long [],unsigned char [])\n sort_csc_indices<(long long,short)>(long long const,long long const,long long const [],long long [],short [])\n sort_csc_indices<(long long,int)>(long long const,long long const,long long const [],long long [],int [])\n sort_csc_indices<(long long,long long)>(long long const,long long const,long long const [],long long [],long long [])\n sort_csc_indices<(long long,float)>(long long const,long long const,long long const [],long long [],float [])\n sort_csc_indices<(long long,double)>(long long const,long long const,long long const [],long long [],double [])\n sort_csc_indices<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long [],npy_cfloat_wrapper [])\n sort_csc_indices<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long [],npy_cdouble_wrapper [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sort_csc_indices'.\n Possible C/C++ prototypes are:\n"" sort_csc_indices<(int,signed char)>(int const,int const,int const [],int [],signed char [])\n"" sort_csc_indices<(int,unsigned char)>(int const,int const,int const [],int [],unsigned char [])\n"" sort_csc_indices<(int,short)>(int const,int const,int const [],int [],short [])\n"" sort_csc_indices<(int,int)>(int const,int const,int const [],int [],int [])\n"" sort_csc_indices<(int,long long)>(int const,int const,int const [],int [],long long [])\n"" sort_csc_indices<(int,float)>(int const,int const,int const [],int [],float [])\n"" sort_csc_indices<(int,double)>(int const,int const,int const [],int [],double [])\n"" sort_csc_indices<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int [],npy_cfloat_wrapper [])\n"" sort_csc_indices<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int [],npy_cdouble_wrapper [])\n"" sort_csc_indices<(long long,signed char)>(long long const,long long const,long long const [],long long [],signed char [])\n"" sort_csc_indices<(long long,unsigned char)>(long long const,long long const,long long const [],long long [],unsigned char [])\n"" sort_csc_indices<(long long,short)>(long long const,long long const,long long const [],long long [],short [])\n"" sort_csc_indices<(long long,int)>(long long const,long long const,long long const [],long long [],int [])\n"" sort_csc_indices<(long long,long long)>(long long const,long long const,long long const [],long long [],long long [])\n"" sort_csc_indices<(long long,float)>(long long const,long long const,long long const [],long long [],float [])\n"" sort_csc_indices<(long long,double)>(long long const,long long const,long long const [],long long [],double [])\n"" sort_csc_indices<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long [],npy_cfloat_wrapper [])\n"" sort_csc_indices<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long [],npy_cdouble_wrapper [])\n"); return NULL; } @@ -85748,7 +85756,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -86312,7 +86320,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sum_csr_duplicates'.\n Possible C/C++ prototypes are:\n sum_csr_duplicates<(int,signed char)>(int const,int const,int [],int [],signed char [])\n sum_csr_duplicates<(int,unsigned char)>(int const,int const,int [],int [],unsigned char [])\n sum_csr_duplicates<(int,short)>(int const,int const,int [],int [],short [])\n sum_csr_duplicates<(int,int)>(int const,int const,int [],int [],int [])\n sum_csr_duplicates<(int,long long)>(int const,int const,int [],int [],long long [])\n sum_csr_duplicates<(int,float)>(int const,int const,int [],int [],float [])\n sum_csr_duplicates<(int,double)>(int const,int const,int [],int [],double [])\n sum_csr_duplicates<(int,npy_cfloat_wrapper)>(int const,int const,int [],int [],npy_cfloat_wrapper [])\n sum_csr_duplicates<(int,npy_cdouble_wrapper)>(int const,int const,int [],int [],npy_cdouble_wrapper [])\n sum_csr_duplicates<(long long,signed char)>(long long const,long long const,long long [],long long [],signed char [])\n sum_csr_duplicates<(long long,unsigned char)>(long long const,long long const,long long [],long long [],unsigned char [])\n sum_csr_duplicates<(long long,short)>(long long const,long long const,long long [],long long [],short [])\n sum_csr_duplicates<(long long,int)>(long long const,long long const,long long [],long long [],int [])\n sum_csr_duplicates<(long long,long long)>(long long const,long long const,long long [],long long [],long long [])\n sum_csr_duplicates<(long long,float)>(long long const,long long const,long long [],long long [],float [])\n sum_csr_duplicates<(long long,double)>(long long const,long long const,long long [],long long [],double [])\n sum_csr_duplicates<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long [],long long [],npy_cfloat_wrapper [])\n sum_csr_duplicates<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long [],long long [],npy_cdouble_wrapper [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sum_csr_duplicates'.\n Possible C/C++ prototypes are:\n"" sum_csr_duplicates<(int,signed char)>(int const,int const,int [],int [],signed char [])\n"" sum_csr_duplicates<(int,unsigned char)>(int const,int const,int [],int [],unsigned char [])\n"" sum_csr_duplicates<(int,short)>(int const,int const,int [],int [],short [])\n"" sum_csr_duplicates<(int,int)>(int const,int const,int [],int [],int [])\n"" sum_csr_duplicates<(int,long long)>(int const,int const,int [],int [],long long [])\n"" sum_csr_duplicates<(int,float)>(int const,int const,int [],int [],float [])\n"" sum_csr_duplicates<(int,double)>(int const,int const,int [],int [],double [])\n"" sum_csr_duplicates<(int,npy_cfloat_wrapper)>(int const,int const,int [],int [],npy_cfloat_wrapper [])\n"" sum_csr_duplicates<(int,npy_cdouble_wrapper)>(int const,int const,int [],int [],npy_cdouble_wrapper [])\n"" sum_csr_duplicates<(long long,signed char)>(long long const,long long const,long long [],long long [],signed char [])\n"" sum_csr_duplicates<(long long,unsigned char)>(long long const,long long const,long long [],long long [],unsigned char [])\n"" sum_csr_duplicates<(long long,short)>(long long const,long long const,long long [],long long [],short [])\n"" sum_csr_duplicates<(long long,int)>(long long const,long long const,long long [],long long [],int [])\n"" sum_csr_duplicates<(long long,long long)>(long long const,long long const,long long [],long long [],long long [])\n"" sum_csr_duplicates<(long long,float)>(long long const,long long const,long long [],long long [],float [])\n"" sum_csr_duplicates<(long long,double)>(long long const,long long const,long long [],long long [],double [])\n"" sum_csr_duplicates<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long [],long long [],npy_cfloat_wrapper [])\n"" sum_csr_duplicates<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long [],long long [],npy_cdouble_wrapper [])\n"); return NULL; } @@ -87313,7 +87321,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -87877,7 +87885,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sum_csc_duplicates'.\n Possible C/C++ prototypes are:\n sum_csc_duplicates<(int,signed char)>(int const,int const,int [],int [],signed char [])\n sum_csc_duplicates<(int,unsigned char)>(int const,int const,int [],int [],unsigned char [])\n sum_csc_duplicates<(int,short)>(int const,int const,int [],int [],short [])\n sum_csc_duplicates<(int,int)>(int const,int const,int [],int [],int [])\n sum_csc_duplicates<(int,long long)>(int const,int const,int [],int [],long long [])\n sum_csc_duplicates<(int,float)>(int const,int const,int [],int [],float [])\n sum_csc_duplicates<(int,double)>(int const,int const,int [],int [],double [])\n sum_csc_duplicates<(int,npy_cfloat_wrapper)>(int const,int const,int [],int [],npy_cfloat_wrapper [])\n sum_csc_duplicates<(int,npy_cdouble_wrapper)>(int const,int const,int [],int [],npy_cdouble_wrapper [])\n sum_csc_duplicates<(long long,signed char)>(long long const,long long const,long long [],long long [],signed char [])\n sum_csc_duplicates<(long long,unsigned char)>(long long const,long long const,long long [],long long [],unsigned char [])\n sum_csc_duplicates<(long long,short)>(long long const,long long const,long long [],long long [],short [])\n sum_csc_duplicates<(long long,int)>(long long const,long long const,long long [],long long [],int [])\n sum_csc_duplicates<(long long,long long)>(long long const,long long const,long long [],long long [],long long [])\n sum_csc_duplicates<(long long,float)>(long long const,long long const,long long [],long long [],float [])\n sum_csc_duplicates<(long long,double)>(long long const,long long const,long long [],long long [],double [])\n sum_csc_duplicates<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long [],long long [],npy_cfloat_wrapper [])\n sum_csc_duplicates<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long [],long long [],npy_cdouble_wrapper [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'sum_csc_duplicates'.\n Possible C/C++ prototypes are:\n"" sum_csc_duplicates<(int,signed char)>(int const,int const,int [],int [],signed char [])\n"" sum_csc_duplicates<(int,unsigned char)>(int const,int const,int [],int [],unsigned char [])\n"" sum_csc_duplicates<(int,short)>(int const,int const,int [],int [],short [])\n"" sum_csc_duplicates<(int,int)>(int const,int const,int [],int [],int [])\n"" sum_csc_duplicates<(int,long long)>(int const,int const,int [],int [],long long [])\n"" sum_csc_duplicates<(int,float)>(int const,int const,int [],int [],float [])\n"" sum_csc_duplicates<(int,double)>(int const,int const,int [],int [],double [])\n"" sum_csc_duplicates<(int,npy_cfloat_wrapper)>(int const,int const,int [],int [],npy_cfloat_wrapper [])\n"" sum_csc_duplicates<(int,npy_cdouble_wrapper)>(int const,int const,int [],int [],npy_cdouble_wrapper [])\n"" sum_csc_duplicates<(long long,signed char)>(long long const,long long const,long long [],long long [],signed char [])\n"" sum_csc_duplicates<(long long,unsigned char)>(long long const,long long const,long long [],long long [],unsigned char [])\n"" sum_csc_duplicates<(long long,short)>(long long const,long long const,long long [],long long [],short [])\n"" sum_csc_duplicates<(long long,int)>(long long const,long long const,long long [],long long [],int [])\n"" sum_csc_duplicates<(long long,long long)>(long long const,long long const,long long [],long long [],long long [])\n"" sum_csc_duplicates<(long long,float)>(long long const,long long const,long long [],long long [],float [])\n"" sum_csc_duplicates<(long long,double)>(long long const,long long const,long long [],long long [],double [])\n"" sum_csc_duplicates<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long [],long long [],npy_cfloat_wrapper [])\n"" sum_csc_duplicates<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long [],long long [],npy_cdouble_wrapper [])\n"); return NULL; } @@ -90858,7 +90866,7 @@ int ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = PyObject_Length(args); + argc = (int)PyObject_Length(args); for (ii = 0; (ii < argc) && (ii < 9); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -91854,7 +91862,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'get_csr_submatrix'.\n Possible C/C++ prototypes are:\n get_csr_submatrix<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,short)>(int const,int const,int const [],int const [],short const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,int)>(int const,int const,int const [],int const [],int const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,float)>(int const,int const,int const [],int const [],float const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,double)>(int const,int const,int const [],int const [],double const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n get_csr_submatrix<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'get_csr_submatrix'.\n Possible C/C++ prototypes are:\n"" get_csr_submatrix<(int,signed char)>(int const,int const,int const [],int const [],signed char const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,unsigned char)>(int const,int const,int const [],int const [],unsigned char const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,short)>(int const,int const,int const [],int const [],short const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,int)>(int const,int const,int const [],int const [],int const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,long long)>(int const,int const,int const [],int const [],long long const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,float)>(int const,int const,int const [],int const [],float const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,double)>(int const,int const,int const [],int const [],double const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,npy_cfloat_wrapper)>(int const,int const,int const [],int const [],npy_cfloat_wrapper const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(int,npy_cdouble_wrapper)>(int const,int const,int const [],int const [],npy_cdouble_wrapper const [],int const,int const,int const,int const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,signed char)>(long long const,long long const,long long const [],long long const [],signed char const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,unsigned char)>(long long const,long long const,long long const [],long long const [],unsigned char const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,short)>(long long const,long long const,long long const [],long long const [],short const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,int)>(long long const,long long const,long long const [],long long const [],int const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,long long)>(long long const,long long const,long long const [],long long const [],long long const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,float)>(long long const,long long const,long long const [],long long const [],float const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,double)>(long long const,long long const,long long const [],long long const [],double const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,npy_cfloat_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cfloat_wrapper const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"" get_csr_submatrix<(long long,npy_cdouble_wrapper)>(long long const,long long const,long long const [],long long const [],npy_cdouble_wrapper const [],long long const,long long const,long long const,long long const,std::vector *,std::vector *,std::vector *)\n"); return NULL; } From scipy-svn at scipy.org Tue Nov 13 10:24:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 09:24:26 -0600 (CST) Subject: [Scipy-svn] r3533 - branches Message-ID: <20071113152426.3829C39C07E@new.scipy.org> Author: cdavid Date: 2007-11-13 09:24:19 -0600 (Tue, 13 Nov 2007) New Revision: 3533 Added: branches/scipy.scons/ Log: Create scipy.scons, a branch to build scipy using numpy.distutils.scons Copied: branches/scipy.scons (from rev 3532, trunk) From scipy-svn at scipy.org Tue Nov 13 10:30:51 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 09:30:51 -0600 (CST) Subject: [Scipy-svn] r3534 - trunk Message-ID: <20071113153051.4B68939C2BF@new.scipy.org> Author: cdavid Date: 2007-11-13 09:30:47 -0600 (Tue, 13 Nov 2007) New Revision: 3534 Modified: trunk/ Log: Initializing scipy.scons Property changes on: trunk ___________________________________________________________________ Name: svnmerge-integrated + /branches/scipy.scons:1-3533 From scipy-svn at scipy.org Tue Nov 13 10:32:48 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 09:32:48 -0600 (CST) Subject: [Scipy-svn] r3535 - branches/scipy.scons Message-ID: <20071113153248.0177939C23E@new.scipy.org> Author: cdavid Date: 2007-11-13 09:32:45 -0600 (Tue, 13 Nov 2007) New Revision: 3535 Modified: branches/scipy.scons/ Log: Initializing from trunk (?) Property changes on: branches/scipy.scons ___________________________________________________________________ Name: svnmerge-integrated + /trunk:1-3534 From scipy-svn at scipy.org Tue Nov 13 10:34:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 09:34:54 -0600 (CST) Subject: [Scipy-svn] r3536 - in branches/scipy.scons: . scipy Message-ID: <20071113153454.D13DA39C302@new.scipy.org> Author: cdavid Date: 2007-11-13 09:34:47 -0600 (Tue, 13 Nov 2007) New Revision: 3536 Added: branches/scipy.scons/scipy/setupscons.py branches/scipy.scons/setupscons.py Log: Put setupscons.py in place for optional scons build of scipy Added: branches/scipy.scons/scipy/setupscons.py =================================================================== --- branches/scipy.scons/scipy/setupscons.py 2007-11-13 15:32:45 UTC (rev 3535) +++ branches/scipy.scons/scipy/setupscons.py 2007-11-13 15:34:47 UTC (rev 3536) @@ -0,0 +1,31 @@ + +def configuration(parent_package='',top_path=None, setup_name = 'setupscons.py'): + from numpy.distutils.misc_util import Configuration + config = Configuration('scipy',parent_package,top_path) + config.add_subpackage('cluster') + config.add_subpackage('fftpack') + config.add_subpackage('integrate') + config.add_subpackage('interpolate') + config.add_subpackage('io') + config.add_subpackage('lib') + config.add_subpackage('linalg') + config.add_subpackage('linsolve') + config.add_subpackage('maxentropy') + config.add_subpackage('misc') + config.add_subpackage('odr') + config.add_subpackage('optimize') + config.add_subpackage('sandbox') + config.add_subpackage('signal') + config.add_subpackage('sparse') + config.add_subpackage('special') + config.add_subpackage('stats') + config.add_subpackage('ndimage') + config.add_subpackage('stsci') + config.add_subpackage('weave') + config.make_svn_version_py() # installs __svn_version__.py + config.make_config_py() + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) Added: branches/scipy.scons/setupscons.py =================================================================== --- branches/scipy.scons/setupscons.py 2007-11-13 15:32:45 UTC (rev 3535) +++ branches/scipy.scons/setupscons.py 2007-11-13 15:34:47 UTC (rev 3536) @@ -0,0 +1,92 @@ +#!/usr/bin/env python +"""SciPy: Scientific Library for Python + +SciPy (pronounced "Sigh Pie") is open-source software for mathematics, +science, and engineering. The SciPy library +depends on NumPy, which provides convenient and fast N-dimensional +array manipulation. The SciPy library is built to work with NumPy +arrays, and provides many user-friendly and efficient numerical +routines such as routines for numerical integration and optimization. +Together, they run on all popular operating systems, are quick to +install, and are free of charge. NumPy and SciPy are easy to use, +but powerful enough to be depended upon by some of the world's +leading scientists and engineers. If you need to manipulate +numbers on a computer and display or publish the results, +give SciPy a try! + +""" + +DOCLINES = __doc__.split("\n") + +import os +import sys + +CLASSIFIERS = """\ +Development Status :: 4 - Beta +Intended Audience :: Science/Research +Intended Audience :: Developers +License :: OSI Approved +Programming Language :: C +Programming Language :: Python +Topic :: Software Development +Topic :: Scientific/Engineering +Operating System :: Microsoft :: Windows +Operating System :: POSIX +Operating System :: Unix +Operating System :: MacOS + +""" + +# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly +# update it when the contents of directories change. +if os.path.exists('MANIFEST'): os.remove('MANIFEST') + +os.environ['NO_SCIPY_IMPORT']='SciPy/setup.py' + +def configuration(parent_package='',top_path=None, setup_name = 'setupscons.py'): + from numpy.distutils.misc_util import Configuration + config = Configuration(None, parent_package, top_path) + config.set_options(ignore_setup_xxx_py=True, + assume_default_configuration=True, + delegate_options_to_subpackages=True, + quiet=True) + + config.add_subpackage('scipy') + config.add_data_files(('scipy','*.txt')) + + config.get_version('scipy/version.py') # sets config.version + + return config + +def setup_package(): + + from numpy.distutils.core import setup + from numpy.distutils.misc_util import Configuration + + old_path = os.getcwd() + local_path = os.path.dirname(os.path.abspath(sys.argv[0])) + os.chdir(local_path) + sys.path.insert(0,local_path) + sys.path.insert(0,os.path.join(local_path,'scipy')) # to retrive version + + try: + setup( + name = 'scipy', + maintainer = "SciPy Developers", + maintainer_email = "scipy-dev at scipy.org", + description = DOCLINES[0], + long_description = "\n".join(DOCLINES[2:]), + url = "http://www.scipy.org", + download_url = "http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531", + license = 'BSD', + classifiers=filter(None, CLASSIFIERS.split('\n')), + platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"], + configuration=configuration ) + finally: + del sys.path[0] + os.chdir(old_path) + + return + +if __name__ == '__main__': + setup_package() Property changes on: branches/scipy.scons/setupscons.py ___________________________________________________________________ Name: svn:executable + * From scipy-svn at scipy.org Tue Nov 13 10:43:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 09:43:05 -0600 (CST) Subject: [Scipy-svn] r3537 - branches/scipy.scons/scipy/cluster Message-ID: <20071113154305.4FE8139C2A4@new.scipy.org> Author: cdavid Date: 2007-11-13 09:42:58 -0600 (Tue, 13 Nov 2007) New Revision: 3537 Added: branches/scipy.scons/scipy/cluster/SConstruct branches/scipy.scons/scipy/cluster/setupscons.py Log: cluster now builds with scons Added: branches/scipy.scons/scipy/cluster/SConstruct =================================================================== --- branches/scipy.scons/scipy/cluster/SConstruct 2007-11-13 15:34:47 UTC (rev 3536) +++ branches/scipy.scons/scipy/cluster/SConstruct 2007-11-13 15:42:58 UTC (rev 3537) @@ -0,0 +1,12 @@ +# Last Change: Thu Oct 18 09:00 PM 2007 J +# vim:syntax=python +from os.path import join + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.NumpyPythonExtension('_vq', source = [join('src', 'vq_module.c'), + join('src', 'vq.c')]) Added: branches/scipy.scons/scipy/cluster/setupscons.py =================================================================== --- branches/scipy.scons/scipy/cluster/setupscons.py 2007-11-13 15:34:47 UTC (rev 3536) +++ branches/scipy.scons/scipy/cluster/setupscons.py 2007-11-13 15:42:58 UTC (rev 3537) @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +from os.path import join + +def configuration(parent_package = '', top_path = None): + from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs + config = Configuration('cluster', parent_package, top_path) + + config.add_data_dir('tests') + + #config.add_extension('_vq', + # sources=[join('src', 'vq_module.c'), join('src', 'vq.c')], + # include_dirs = [get_numpy_include_dirs()]) + config.add_sconscript('SConstruct') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(maintainer = "SciPy Developers", + author = "Eric Jones", + maintainer_email = "scipy-dev at scipy.org", + description = "Clustering Algorithms (Information Theory)", + url = "http://www.scipy.org", + license = "SciPy License (BSD Style)", + **configuration(top_path='').todict() + ) Property changes on: branches/scipy.scons/scipy/cluster/setupscons.py ___________________________________________________________________ Name: svn:executable + * From scipy-svn at scipy.org Tue Nov 13 23:14:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 22:14:28 -0600 (CST) Subject: [Scipy-svn] r3538 - in trunk/scipy: special/amos weave Message-ID: <20071114041428.8DD0539C08B@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 22:14:24 -0600 (Tue, 13 Nov 2007) New Revision: 3538 Modified: trunk/scipy/special/amos/setup.py trunk/scipy/weave/ext_tools.py Log: braino Modified: trunk/scipy/special/amos/setup.py =================================================================== --- trunk/scipy/special/amos/setup.py 2007-11-13 15:42:58 UTC (rev 3537) +++ trunk/scipy/special/amos/setup.py 2007-11-14 04:14:24 UTC (rev 3538) @@ -18,14 +18,14 @@ def __init__(self): self.compiler_name = 'g77' def to_object(self,dirty_files): - files = dirty_files.join() + files = " ".join(dirty_files) cmd = self.compiler_name + ' -c ' + files print cmd failure = os.system(cmd) if failure: raise ValueError, 'failure during compile' def object_to_library(self,library_name,object_files): - objects = object_files.join() + objects = " ".join(object_files) cmd = 'ar -cr lib%s.a %s' % (library_name,objects) print cmd os.system(cmd) Modified: trunk/scipy/weave/ext_tools.py =================================================================== --- trunk/scipy/weave/ext_tools.py 2007-11-13 15:42:58 UTC (rev 3537) +++ trunk/scipy/weave/ext_tools.py 2007-11-14 04:14:24 UTC (rev 3538) @@ -45,14 +45,14 @@ 'int exception_occured = 0;\n' \ 'PyObject *py_local_dict = NULL;\n' arg_string_list = self.arg_specs.variable_as_strings() + ['"local_dict"'] - arg_strings = arg_string_list.join(',') + arg_strings = ','.join(arg_string_list) if arg_strings: arg_strings += ',' declare_kwlist = 'static char *kwlist[] = {%s NULL};\n' % arg_strings - py_objects = self.arg_specs.py_pointers().join(', ') - init_flags = self.arg_specs.init_flags().join(', ') - init_flags_init = self.arg_specs.init_flags().join('= ') - py_vars = self.arg_specs.py_variables().join(' = ') + py_objects = ', '.join(self.arg_specs.py_pointers()) + init_flags = ', '.join(self.arg_specs.init_flags()) + init_flags_init = '= '.join(self.arg_specs.init_flags()) + py_vars = ' = '.join(self.arg_specs.py_variables()) if py_objects: declare_py_objects = 'PyObject ' + py_objects +';\n' declare_py_objects += 'int '+ init_flags + ';\n' @@ -66,7 +66,7 @@ #cnt = len(arg_list) #declare_cleanup = "blitz::TinyVector clean_up(0);\n" % cnt - ref_string = self.arg_specs.py_references().join(', ') + ref_string = ', '.join(self.arg_specs.py_references()) if ref_string: ref_string += ', &py_local_dict' else: @@ -85,7 +85,7 @@ for arg in self.arg_specs: arg_strings.append(arg.declaration_code()) arg_strings.append(arg.init_flag() +" = 1;\n") - code = arg_strings.join("") + code = "".join(arg_strings) return code def arg_cleanup_code(self): @@ -97,14 +97,14 @@ code += indent(arg.cleanup_code(),4) code += "}\n" arg_strings.append(code) - code = arg_strings.join("") + code = "".join(arg_strings) return code def arg_local_dict_code(self): arg_strings = [] for arg in self.arg_specs: arg_strings.append(arg.local_dict_code()) - code = arg_strings.join("") + code = "".join(arg_strings) return code def function_code(self): From scipy-svn at scipy.org Tue Nov 13 23:21:18 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 13 Nov 2007 22:21:18 -0600 (CST) Subject: [Scipy-svn] r3539 - trunk/scipy/weave Message-ID: <20071114042118.72F9039C08B@new.scipy.org> Author: jarrod.millman Date: 2007-11-13 22:21:13 -0600 (Tue, 13 Nov 2007) New Revision: 3539 Modified: trunk/scipy/weave/inline_tools.py Log: applying patch from Fernando P., which corrects my braino and more Modified: trunk/scipy/weave/inline_tools.py =================================================================== --- trunk/scipy/weave/inline_tools.py 2007-11-14 04:14:24 UTC (rev 3538) +++ trunk/scipy/weave/inline_tools.py 2007-11-14 04:21:13 UTC (rev 3539) @@ -57,27 +57,21 @@ init_values + parse_tuple def arg_declaration_code(self): - arg_strings = [] - for arg in self.arg_specs: - arg_strings.append(arg.declaration_code(inline=1)) - code = arg_strings.join("") - return code + """Return the declaration code as a string.""" + arg_strings = [arg.declaration_code(inline=1) + for arg in self.arg_specs] + return "".join(arg_strings) def arg_cleanup_code(self): - arg_strings = [] - for arg in self.arg_specs: - arg_strings.append(arg.cleanup_code()) - code = arg_strings.join("") - return code + """Return the cleanup code as a string.""" + arg_strings = [arg.cleanup_code() for arg in self.arg_specs] + return "".join(arg_strings) def arg_local_dict_code(self): - arg_strings = [] - for arg in self.arg_specs: - arg_strings.append(arg.local_dict_code()) - code = arg_strings.join("") - return code + """Return the code to create the local dict as a string.""" + arg_strings = [arg.local_dict_code() for arg in self.arg_specs] + return "".join(arg_strings) - def function_code(self): from ext_tools import indent decl_code = indent(self.arg_declaration_code(),4) From scipy-svn at scipy.org Thu Nov 15 01:48:37 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 Nov 2007 00:48:37 -0600 (CST) Subject: [Scipy-svn] r3540 - in branches/scipy.scons: . scipy/special/amos scipy/weave Message-ID: <20071115064837.02EF739C1C9@new.scipy.org> Author: cdavid Date: 2007-11-15 00:48:24 -0600 (Thu, 15 Nov 2007) New Revision: 3540 Modified: branches/scipy.scons/ branches/scipy.scons/scipy/special/amos/setup.py branches/scipy.scons/scipy/weave/ext_tools.py branches/scipy.scons/scipy/weave/inline_tools.py Log: Merged revisions 3535-3539 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r3538 | jarrod.millman | 2007-11-14 13:14:24 +0900 (Wed, 14 Nov 2007) | 2 lines braino ........ r3539 | jarrod.millman | 2007-11-14 13:21:13 +0900 (Wed, 14 Nov 2007) | 2 lines applying patch from Fernando P., which corrects my braino and more ........ Property changes on: branches/scipy.scons ___________________________________________________________________ Name: svnmerge-integrated - /trunk:1-3534 + /trunk:1-3539 Modified: branches/scipy.scons/scipy/special/amos/setup.py =================================================================== --- branches/scipy.scons/scipy/special/amos/setup.py 2007-11-14 04:21:13 UTC (rev 3539) +++ branches/scipy.scons/scipy/special/amos/setup.py 2007-11-15 06:48:24 UTC (rev 3540) @@ -18,14 +18,14 @@ def __init__(self): self.compiler_name = 'g77' def to_object(self,dirty_files): - files = dirty_files.join() + files = " ".join(dirty_files) cmd = self.compiler_name + ' -c ' + files print cmd failure = os.system(cmd) if failure: raise ValueError, 'failure during compile' def object_to_library(self,library_name,object_files): - objects = object_files.join() + objects = " ".join(object_files) cmd = 'ar -cr lib%s.a %s' % (library_name,objects) print cmd os.system(cmd) Modified: branches/scipy.scons/scipy/weave/ext_tools.py =================================================================== --- branches/scipy.scons/scipy/weave/ext_tools.py 2007-11-14 04:21:13 UTC (rev 3539) +++ branches/scipy.scons/scipy/weave/ext_tools.py 2007-11-15 06:48:24 UTC (rev 3540) @@ -45,14 +45,14 @@ 'int exception_occured = 0;\n' \ 'PyObject *py_local_dict = NULL;\n' arg_string_list = self.arg_specs.variable_as_strings() + ['"local_dict"'] - arg_strings = arg_string_list.join(',') + arg_strings = ','.join(arg_string_list) if arg_strings: arg_strings += ',' declare_kwlist = 'static char *kwlist[] = {%s NULL};\n' % arg_strings - py_objects = self.arg_specs.py_pointers().join(', ') - init_flags = self.arg_specs.init_flags().join(', ') - init_flags_init = self.arg_specs.init_flags().join('= ') - py_vars = self.arg_specs.py_variables().join(' = ') + py_objects = ', '.join(self.arg_specs.py_pointers()) + init_flags = ', '.join(self.arg_specs.init_flags()) + init_flags_init = '= '.join(self.arg_specs.init_flags()) + py_vars = ' = '.join(self.arg_specs.py_variables()) if py_objects: declare_py_objects = 'PyObject ' + py_objects +';\n' declare_py_objects += 'int '+ init_flags + ';\n' @@ -66,7 +66,7 @@ #cnt = len(arg_list) #declare_cleanup = "blitz::TinyVector clean_up(0);\n" % cnt - ref_string = self.arg_specs.py_references().join(', ') + ref_string = ', '.join(self.arg_specs.py_references()) if ref_string: ref_string += ', &py_local_dict' else: @@ -85,7 +85,7 @@ for arg in self.arg_specs: arg_strings.append(arg.declaration_code()) arg_strings.append(arg.init_flag() +" = 1;\n") - code = arg_strings.join("") + code = "".join(arg_strings) return code def arg_cleanup_code(self): @@ -97,14 +97,14 @@ code += indent(arg.cleanup_code(),4) code += "}\n" arg_strings.append(code) - code = arg_strings.join("") + code = "".join(arg_strings) return code def arg_local_dict_code(self): arg_strings = [] for arg in self.arg_specs: arg_strings.append(arg.local_dict_code()) - code = arg_strings.join("") + code = "".join(arg_strings) return code def function_code(self): Modified: branches/scipy.scons/scipy/weave/inline_tools.py =================================================================== --- branches/scipy.scons/scipy/weave/inline_tools.py 2007-11-14 04:21:13 UTC (rev 3539) +++ branches/scipy.scons/scipy/weave/inline_tools.py 2007-11-15 06:48:24 UTC (rev 3540) @@ -57,27 +57,21 @@ init_values + parse_tuple def arg_declaration_code(self): - arg_strings = [] - for arg in self.arg_specs: - arg_strings.append(arg.declaration_code(inline=1)) - code = arg_strings.join("") - return code + """Return the declaration code as a string.""" + arg_strings = [arg.declaration_code(inline=1) + for arg in self.arg_specs] + return "".join(arg_strings) def arg_cleanup_code(self): - arg_strings = [] - for arg in self.arg_specs: - arg_strings.append(arg.cleanup_code()) - code = arg_strings.join("") - return code + """Return the cleanup code as a string.""" + arg_strings = [arg.cleanup_code() for arg in self.arg_specs] + return "".join(arg_strings) def arg_local_dict_code(self): - arg_strings = [] - for arg in self.arg_specs: - arg_strings.append(arg.local_dict_code()) - code = arg_strings.join("") - return code + """Return the code to create the local dict as a string.""" + arg_strings = [arg.local_dict_code() for arg in self.arg_specs] + return "".join(arg_strings) - def function_code(self): from ext_tools import indent decl_code = indent(self.arg_declaration_code(),4) From scipy-svn at scipy.org Thu Nov 15 16:57:14 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 Nov 2007 15:57:14 -0600 (CST) Subject: [Scipy-svn] r3541 - trunk/scipy/ndimage Message-ID: <20071115215714.6FC6639C113@new.scipy.org> Author: tom.waite Date: 2007-11-15 15:56:38 -0600 (Thu, 15 Nov 2007) New Revision: 3541 Added: trunk/scipy/ndimage/segmenter.py Log: Python segment execution Added: trunk/scipy/ndimage/segmenter.py =================================================================== --- trunk/scipy/ndimage/segmenter.py 2007-11-15 06:48:24 UTC (rev 3540) +++ trunk/scipy/ndimage/segmenter.py 2007-11-15 21:56:38 UTC (rev 3541) @@ -0,0 +1,293 @@ + +import numpy as N +import scipy.ndimage.segment as S + +# make sure this is local to use as default +inputname = 'slice112.raw' + +import os +filename = os.path.join(os.path.split(__file__)[0],inputname) + + +def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, + highThreshold=600+2048, dust=16): + """ + labeledEdges, ROIList = shen_castan(image, [default]) + + implements Shen-Castan edge finding + + Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust + - image is the numarray 2D image + - IIR filter is filter parameter for exponential filter + - shen_castan_low is edge threshold is range (0.0, 1.0] + - window is search window for edge detection + - low_ and high_ threshold are density values + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) + + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned + + """ + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, + lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, + apearture=21, dust=16): + """ + labeledEdges, ROIList = sobel(image, [default]) + + implements sobel magnitude edge finding + + Inputs - image, sobel_low, tMode, low_threshold, high_threshold, + high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - sobel_low is edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) + + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned + + """ + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, + highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, + highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): + """ + labeledEdges, ROIList = canny(image, [default]) + + implements canny edge finding + + Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, + high_threshold, high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter + - clow is low edge threshold is range (0.0, 1.0] + - chigh is high edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) + + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned + + """ + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] + +def get_shape_mask(labeledEdges, ROIList): + """ + get_shape_mask(labeledEdges, ROIList) + + takes labeled edge image plus ROIList (blob descriptors) and generates + boundary shape features and builds labeled blob masks. 'labeledEdges' + is over-written by 'labeledMask'. Adds features to ROIList structure + + Inputs - labeledEdges, ROIList + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. + + Output - no return. edge image input is over-written with mask image. + ROIList added to. + + """ + + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return + +def get_voxel_measures(rawImage, labeledEdges, ROIList): + """ + get_voxel_measures(rawImage, labeledEdges, ROIList) + + takes raw 2D image, labeled blob mask and ROIList. computes voxel features + (moments, histogram) for each blob. Adds features to ROIList structure. + + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. + + Output - no return. ROIList added to. + + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return + +def get_texture_measures(rawImage, labeledEdges, ROIList): + """ + get_texture_measures(rawImage, labeledEdges, ROIList) + + takes raw 2D image, labeled blob mask and ROIList. computes 2D + texture features using 7x7 Law's texture filters applied + to segmented blobs. TEM (texture energy metric) is computed + for each Law's filter image and stored in TEM part of ROIList. + + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. + + Output - no return. ROIList added to. + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return + +def segment_regions(): + """ + sourceImage, labeledMask, ROIList = segment_regions() + + Inputs - No Input + + Outputs - sourceImage, labeledMask, ROIList + - sourceImage is raw 2D image (default cardiac CT slice for demo + - labeledMask is mask of segmented 'blobs', + numerically labeled by blob number + - ROIList is numerical Python structure of intensity, shape and + texture features for each blob + + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + sobel() - sobel magnitude edge finder, + returns connected edges + get_shape_mask() - gets segmented blob boundary and mask + and shape features + get_voxel_measures() - uses masks get object voxel moment + and histogram features + get_texture_measures() - uses masks get object 2D texture features + """ + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList + +def grow_regions(): + """ + regionMask, numberRegions = region_grow() + Inputs - No Input + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + region_grow() - "grows" connected blobs. default threshold + and morphological filter structuring element + """ + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions + + +def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): + """ + regionMask, numberRegions = region_grow(image, [defaults]) + + Inputs - image, low_threshold, high_threshold, open, close + - image is the numarray 2D image + - low_ and high_ threshold are density values + - open is open morphology structuring element + odd size. 0 to turn off. max is 11 + - close is close morphology structuring element + odd size. 0 to turn off. max is 11 + + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + """ + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + + +def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512): + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) + +def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)): + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice + +def save_slice(mySlice, filename='junk.raw', bytes=4): + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) + + From scipy-svn at scipy.org Thu Nov 15 19:28:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 Nov 2007 18:28:28 -0600 (CST) Subject: [Scipy-svn] r3542 - trunk/scipy/ndimage/segment Message-ID: <20071116002828.E51C139C0F3@new.scipy.org> Author: tom.waite Date: 2007-11-15 18:28:25 -0600 (Thu, 15 Nov 2007) New Revision: 3542 Modified: trunk/scipy/ndimage/segment/Segmenter_IMPL.c Log: changed morphological mask function passing method Modified: trunk/scipy/ndimage/segment/Segmenter_IMPL.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-15 21:56:38 UTC (rev 3541) +++ trunk/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-16 00:28:25 UTC (rev 3542) @@ -1331,8 +1331,8 @@ int i, j; int offset, offset2; - unsigned short cmask[11][11]; - unsigned short omask[11][11]; + unsigned short *cmask; + unsigned short *omask; int olapValuesC[4]; int olapValuesO[4]; int CloseMaskSize = 1; @@ -1340,6 +1340,7 @@ int LowValue1, HighValue1; int LowValue2, HighValue2; int spadSize; + int maskSize = 11; unsigned char *ImageE; unsigned char *ImageC; @@ -1348,6 +1349,9 @@ ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + cmask = calloc(11*11, sizeof(unsigned short)); + omask = calloc(11*11, sizeof(unsigned short)); + // // Close filter // @@ -1355,7 +1359,7 @@ CloseMaskSize = (CloseSize-1)/2; for(i = 0; i < 2*CloseMaskSize+1; ++i){ for(j = 0; j < 2*CloseMaskSize+1; ++j){ - cmask[i][j] = 1; + cmask[i*maskSize+j] = 1; } } LowValue1 = 0; @@ -1375,7 +1379,7 @@ OpenMaskSize = (OpenSize-1)/2; for(i = 0; i < 2*OpenMaskSize+1; ++i){ for(j = 0; j < 2*OpenMaskSize+1; ++j){ - omask[i][j] = 1; + omask[i*maskSize+j] = 1; } } LowValue1 = 1; @@ -1426,6 +1430,9 @@ free(ImageE); free(ImageC); + free(cmask); + free(omask); + return; } @@ -1442,8 +1449,8 @@ } int NI_RegionGrow(int samples, int rows, int cols, int lowThreshold, int highThreshold, - int closeWindow, int openWindow, double *rawImage, - unsigned short *edgeImage, int *groups){ + int closeWindow, int openWindow, double *rawImage, + unsigned short *edgeImage, int *groups){ int i, j; int offset; @@ -1503,107 +1510,108 @@ } -void initThinFilter(int J_mask[3][30], int K_mask[3][30]){ +void initThinFilter(int *J_mask, int *K_mask){ int i, j; int Column; + int maskCols = 3; for(i = 0; i < 3; ++i){ for(j = 0; j < 30; ++j){ - J_mask[i][j] = 0; - K_mask[i][j] = 0; + J_mask[i+j*maskCols] = 0; + K_mask[i+j*maskCols] = 0; } } Column = 0; - J_mask[0][Column+0] = 1; - J_mask[0][Column+1] = 1; - J_mask[0][Column+2] = 1; - J_mask[1][Column+1] = 1; + J_mask[0+maskCols*(Column+0)] = 1; + J_mask[0+maskCols*(Column+1)] = 1; + J_mask[0+maskCols*(Column+2)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; Column += 3; - J_mask[0][Column+1] = 1; - J_mask[1][Column+1] = 1; - J_mask[1][Column+2] = 1; + J_mask[0+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+2)] = 1; Column += 3; - J_mask[0][Column+0] = 1; - J_mask[1][Column+0] = 1; - J_mask[2][Column+0] = 1; - J_mask[1][Column+1] = 1; + J_mask[0+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+0)] = 1; + J_mask[2+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; Column += 3; - J_mask[0][Column+1] = 1; - J_mask[1][Column+0] = 1; - J_mask[1][Column+1] = 1; + J_mask[0+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; Column += 3; - J_mask[0][Column+2] = 1; - J_mask[1][Column+1] = 1; - J_mask[1][Column+2] = 1; - J_mask[2][Column+2] = 1; + J_mask[0+maskCols*(Column+2)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+2)] = 1; + J_mask[2+maskCols*(Column+2)] = 1; Column += 3; - J_mask[1][Column+0] = 1; - J_mask[1][Column+1] = 1; - J_mask[2][Column+1] = 1; + J_mask[1+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[2+maskCols*(Column+1)] = 1; Column += 3; - J_mask[1][Column+1] = 1; - J_mask[2][Column+0] = 1; - J_mask[2][Column+1] = 1; - J_mask[2][Column+2] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[2+maskCols*(Column+0)] = 1; + J_mask[2+maskCols*(Column+1)] = 1; + J_mask[2+maskCols*(Column+2)] = 1; Column += 3; - J_mask[1][Column+1] = 1; - J_mask[1][Column+2] = 1; - J_mask[2][Column+1] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+2)] = 1; + J_mask[2+maskCols*(Column+1)] = 1; Column = 0; - K_mask[2][Column+0] = 1; - K_mask[2][Column+1] = 1; - K_mask[2][Column+2] = 1; + K_mask[2+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+1)] = 1; + K_mask[2+maskCols*(Column+2)] = 1; Column += 3; - K_mask[1][Column+0] = 1; - K_mask[2][Column+0] = 1; - K_mask[2][Column+1] = 1; + K_mask[1+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+1)] = 1; Column += 3; - K_mask[0][Column+2] = 1; - K_mask[1][Column+2] = 1; - K_mask[2][Column+2] = 1; + K_mask[0+maskCols*(Column+2)] = 1; + K_mask[1+maskCols*(Column+2)] = 1; + K_mask[2+maskCols*(Column+2)] = 1; Column += 3; - K_mask[1][Column+2] = 1; - K_mask[2][Column+1] = 1; - K_mask[2][Column+2] = 1; + K_mask[1+maskCols*(Column+2)] = 1; + K_mask[2+maskCols*(Column+1)] = 1; + K_mask[2+maskCols*(Column+2)] = 1; Column += 3; - K_mask[0][Column+0] = 1; - K_mask[1][Column+0] = 1; - K_mask[2][Column+0] = 1; + K_mask[0+maskCols*(Column+0)] = 1; + K_mask[1+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+0)] = 1; Column += 3; - K_mask[0][Column+1] = 1; - K_mask[0][Column+2] = 1; - K_mask[1][Column+2] = 1; + K_mask[0+maskCols*(Column+1)] = 1; + K_mask[0+maskCols*(Column+2)] = 1; + K_mask[1+maskCols*(Column+2)] = 1; Column += 3; - K_mask[0][Column+0] = 1; - K_mask[0][Column+1] = 1; - K_mask[0][Column+2] = 1; + K_mask[0+maskCols*(Column+0)] = 1; + K_mask[0+maskCols*(Column+1)] = 1; + K_mask[0+maskCols*(Column+2)] = 1; Column += 3; - K_mask[0][Column+0] = 1; - K_mask[0][Column+1] = 1; - K_mask[1][Column+0] = 1; + K_mask[0+maskCols*(Column+0)] = 1; + K_mask[0+maskCols*(Column+1)] = 1; + K_mask[1+maskCols*(Column+0)] = 1; return; } -void ThinningFilter(int regRows, int regColumns, int spadSize, int J_mask[3][30], int K_mask[3][30], +void ThinningFilter(int regRows, int regColumns, int spadSize, int *J_mask, int *K_mask, unsigned char *Input, unsigned char *CInput, unsigned char *ErosionStage, unsigned char *DialationStage, unsigned char *HMT, unsigned char *Copy){ @@ -1613,6 +1621,7 @@ int Column, T, nloop; int Offset; int N, M; + int maskCols = 3; int j_mask[3][3]; int k_mask[3][3]; @@ -1640,12 +1649,12 @@ for(n = 0; n < 8; ++n){ for(i = 0; i < 3; ++i){ for(j = 0; j < 3; ++j){ - j_mask[i][j] = J_mask[i][Column+j]; + j_mask[i][j] = J_mask[i+maskCols*(Column+j)]; } } for(i = 0; i < 3; ++i){ for(j = 0; j < 3; ++j){ - k_mask[i][j] = K_mask[i][Column+j]; + k_mask[i][j] = K_mask[i+maskCols*(Column+j)]; } } Column += 3; @@ -1745,6 +1754,7 @@ } Offset += spadSize; } + /* nloop is data dependent. */ ++nloop; } @@ -1766,8 +1776,8 @@ int dstOffset; int status; int inflate = 1; - int J_mask[3][30]; - int K_mask[3][30]; + int *J_mask; + int *K_mask; unsigned char *Input; unsigned char *CInput; @@ -1787,6 +1797,8 @@ HMT = calloc(samples, sizeof(unsigned char)); Copy = calloc(samples, sizeof(unsigned char)); thinEdgeImage = calloc(samples, sizeof(unsigned short)); + J_mask = calloc(3*30, sizeof(int)); + K_mask = calloc(3*30, sizeof(int)); initThinFilter(J_mask, K_mask); for(loop = 0; loop < numberObjects; ++loop){ @@ -1855,6 +1867,8 @@ free(HMT); free(Copy); free(thinEdgeImage); + free(J_mask); + free(K_mask); status = 1; @@ -2050,7 +2064,7 @@ void OpenCloseFilter(int olapValues[], int maskSize, int rows, int columns, int spadSize, - unsigned char *input, unsigned char *output, unsigned short mask[11][11]){ + unsigned char *input, unsigned char *output, unsigned short *mask){ /* @@ -2061,6 +2075,7 @@ int offset; int LowValue1, HighValue1; int LowValue2, HighValue2; + int morphoMaskSize = 11; LowValue1 = olapValues[0]; HighValue1 = olapValues[1]; @@ -2076,7 +2091,7 @@ for(k = -maskSize; k < maskSize; ++k){ m = k*spadSize; for(l = -maskSize; l < maskSize; ++l){ - overlap = mask[k+maskSize][l+maskSize]*input[offset+m+j+l]; + overlap = mask[morphoMaskSize*(k+maskSize)+(l+maskSize)]*input[offset+m+j+l]; if(overlap == HighValue1){ hit = HighValue1; } @@ -2096,7 +2111,7 @@ for(k = -maskSize; k < maskSize; ++k){ m = k*spadSize; for(l = -maskSize; l < maskSize; ++l){ - overlap = mask[k+maskSize][l+maskSize]*output[offset+m+j+l]; + overlap = mask[morphoMaskSize*(k+maskSize)+(l+maskSize)]*output[offset+m+j+l]; if(overlap == HighValue2){ hit = HighValue2; } @@ -2140,7 +2155,7 @@ void doMorphology(unsigned char *Input, unsigned char *ImageE, unsigned char *ImageC, unsigned char *ImageH, int olapValuesC[], int olapValuesO[], - unsigned short cmask[11][11], unsigned short omask[11][11], + unsigned short *cmask, unsigned short *omask, RECT roi, int label, int CloseMaskSize, int OpenMaskSize, int spadSize){ int i, j; @@ -2306,8 +2321,9 @@ float aveRadius; float vCompactness; /* for morphological close of mask. max structuring element is 11x11 */ - unsigned short cmask[11][11]; - unsigned short omask[11][11]; + unsigned short *cmask; + unsigned short *omask; + int maskSize = 11; int olapValuesC[4]; int olapValuesO[4]; int CloseMaskSize; @@ -2325,13 +2341,25 @@ unsigned char *ImageC; unsigned char *ImageH; + spadSize = srcCols; + pBoundaryIndex = calloc(srcRows+srcCols, sizeof(boundaryIndex)); + Input = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageH = calloc(spadSize*spadSize, sizeof(unsigned char)); + pBoundary = calloc(srcRows*srcCols, sizeof(blobBoundary)); + lBoundary = calloc(32767, sizeof(blobBoundary)); + boundary = calloc(32767, sizeof(POINT)); + cmask = calloc(11*11, sizeof(unsigned short)); + omask = calloc(11*11, sizeof(unsigned short)); + /* // Close filter */ CloseMaskSize = (CloseSize-1)/2; for(i = 0; i < 2*CloseMaskSize+1; ++i){ for(j = 0; j < 2*CloseMaskSize+1; ++j){ - cmask[i][j] = 1; + cmask[i*maskSize+j] = 1; } } LowValue1 = 0; @@ -2349,7 +2377,7 @@ OpenMaskSize = (OpenSize-1)/2; for(i = 0; i < 2*OpenMaskSize+1; ++i){ for(j = 0; j < 2*OpenMaskSize+1; ++j){ - omask[i][j] = 1; + omask[i*maskSize+j] = 1; } } LowValue1 = 1; @@ -2361,19 +2389,6 @@ olapValuesO[2] = LowValue2; olapValuesO[3] = HighValue2; - - //spadSize = MAX(srcRows, srcCols); - spadSize = srcCols; - - pBoundaryIndex = calloc(srcRows+srcCols, sizeof(boundaryIndex)); - Input = calloc(spadSize*spadSize, sizeof(unsigned char)); - ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); - ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); - ImageH = calloc(spadSize*spadSize, sizeof(unsigned char)); - pBoundary = calloc(srcRows*srcCols, sizeof(blobBoundary)); - lBoundary = calloc(32767, sizeof(blobBoundary)); - boundary = calloc(32767, sizeof(POINT)); - for(i = 0; i < (srcRows+srcCols); ++i){ pBoundaryIndex[i].numberPoints = 0; pBoundaryIndex[i].curveClose = 0; @@ -2384,7 +2399,6 @@ for(i = 0; i < numberObjects; ++i){ - //for(i = 0; i < 1; ++i){ ++pBoundaryIndex[0].numberPoints; count = 0; j = 1; @@ -2597,6 +2611,8 @@ free(pBoundary); free(lBoundary); free(boundary); + free(cmask); + free(omask); return; @@ -2949,14 +2965,13 @@ if(count){ std /= (float)count; std = sqrt(std); - objectMetrics[i].voxelMean = mean - 2048.0; // the 2048 is only for the cardiac CT volume + objectMetrics[i].voxelMean = mean; objectMetrics[i].voxelVar = std; } else{ objectMetrics[i].voxelMean = 0.0; objectMetrics[i].voxelVar = 0.0; } - if(0) printf("(%d) mean %f, std %f\n", label, objectMetrics[i].voxelMean, objectMetrics[i].voxelVar); } return; From scipy-svn at scipy.org Thu Nov 15 19:29:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 Nov 2007 18:29:20 -0600 (CST) Subject: [Scipy-svn] r3543 - trunk/scipy/ndimage/segment Message-ID: <20071116002920.2464939C0F3@new.scipy.org> Author: tom.waite Date: 2007-11-15 18:29:18 -0600 (Thu, 15 Nov 2007) New Revision: 3543 Modified: trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h Log: changed function prototypes Modified: trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h =================================================================== --- trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h 2007-11-16 00:28:25 UTC (rev 3542) +++ trunk/scipy/ndimage/segment/ndImage_Segmenter_structs.h 2007-11-16 00:29:18 UTC (rev 3543) @@ -117,17 +117,17 @@ void getBoundary(unsigned short *, unsigned char *, blobBoundary *, blobBoundary *, boundaryIndex *, RECT, int, int, int, int, int, int); void doMorphology(unsigned char *, unsigned char *, unsigned char *, unsigned char *, int olapValuesC[], - int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], + int olapValuesO[], unsigned short *, unsigned short *, RECT, int, int, int, int); void getCompactness(unsigned char *, RECT, int, int, float *, float); void OpenCloseFilter(int olapValues[], int, int, int, int, unsigned char *, - unsigned char *, unsigned short mask[11][11]); + unsigned char *, unsigned short *); void trackBoundary(unsigned char *, blobBoundary lBoundary[], int, int, blobBoundary, int); void getBoundaryMetrics(bPOINT *, float *, float *, float *, float *, float, float, int); void generateMask(unsigned char *, bPOINT *, int, int, int); -void ThinningFilter(int, int, int, int J_mask[3][30], int K_mask[3][30], unsigned char *, +void ThinningFilter(int, int, int, int *, int *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *); -void initThinFilter(int J_mask[3][30], int K_mask[3][30]); +void initThinFilter(int *, int *); void Shen_Castan(double, double, int, int, int, int, int, double *, unsigned short *); void computeISEF(float *, float *, int, int, double); void ISEF_Horizontal(float *, float *, float *, float *, int, int, double); From scipy-svn at scipy.org Thu Nov 15 19:31:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 15 Nov 2007 18:31:13 -0600 (CST) Subject: [Scipy-svn] r3544 - trunk/scipy/ndimage/segment Message-ID: <20071116003113.D227D39C0F3@new.scipy.org> Author: tom.waite Date: 2007-11-15 18:31:11 -0600 (Thu, 15 Nov 2007) New Revision: 3544 Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c Log: changed PyArray type creation for edge and mask output arrays. Modified: trunk/scipy/ndimage/segment/Segmenter_EXT.c =================================================================== --- trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-16 00:29:18 UTC (rev 3543) +++ trunk/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-16 00:31:11 UTC (rev 3544) @@ -36,7 +36,8 @@ type = PyArray_TYPE(iArray); num = PyArray_SIZE(iArray); - itype = 4; + //itype = 4; + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -88,7 +89,8 @@ num = PyArray_SIZE(iArray); // this is int type and hard-wirred. pass this in from Python code - itype = 4; // unsigned short + //itype = 4; // unsigned short + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -139,7 +141,8 @@ num = PyArray_SIZE(iArray); // this is int type and hard-wirred. pass this in from Python code - itype = 4; // unsigned short + //itype = 4; // unsigned short + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -325,7 +328,8 @@ // replace the edgeImage with maskImage // - if(!NI_VoxelMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + if(!NI_VoxelMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, + fP2, ROIList)) goto exit; exit: @@ -373,7 +377,8 @@ // replace the edgeImage with maskImage // - if(!NI_TextureMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + if(!NI_TextureMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, + fP2, ROIList)) goto exit; exit: @@ -402,7 +407,8 @@ // // pass in 2D LPF coefficients - if(!PyArg_ParseTuple(args, "iiiiO", &lowThreshold, &highThreshold, &closeWindow, &openWindow, &iArray)) + if(!PyArg_ParseTuple(args, "iiiiO", &lowThreshold, &highThreshold, &closeWindow, + &openWindow, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -412,7 +418,8 @@ num = PyArray_SIZE(iArray); // this is int type and hard-wirred. pass this in from Python code - itype = 4; // unsigned short + //itype = 4; // unsigned short + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -420,8 +427,9 @@ goto exit; - if(!NI_RegionGrow(num, (int)dims[0], (int)dims[1], lowThreshold, highThreshold, closeWindow, openWindow, - fP1, fP2, &groups)) + if(!NI_RegionGrow(num, (int)dims[0], (int)dims[1], lowThreshold, highThreshold, + closeWindow, openWindow, fP1, fP2, &groups)) + goto exit; exit: From scipy-svn at scipy.org Fri Nov 16 03:42:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 Nov 2007 02:42:02 -0600 (CST) Subject: [Scipy-svn] r3545 - trunk/scipy/sandbox/multigrid/multigridtools Message-ID: <20071116084202.2910839C324@new.scipy.org> Author: wnbell Date: 2007-11-16 02:41:00 -0600 (Fri, 16 Nov 2007) New Revision: 3545 Added: trunk/scipy/sandbox/multigrid/multigridtools/README.txt Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.i trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx Log: support for 64bit indices in multigridtools Added: trunk/scipy/sandbox/multigrid/multigridtools/README.txt =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/README.txt 2007-11-16 00:31:11 UTC (rev 3544) +++ trunk/scipy/sandbox/multigrid/multigridtools/README.txt 2007-11-16 08:41:00 UTC (rev 3545) @@ -0,0 +1,7 @@ +Before regenerating multigridtools_wrap.cxx with SWIG, ensure that you +are using SWIG Version 1.3.32 or newer (check with: 'swig -version') + +The wrappers are generated with: + swig -c++ -python multigridtools.i + + Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.i =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.i 2007-11-16 00:31:11 UTC (rev 3544) +++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.i 2007-11-16 08:41:00 UTC (rev 3545) @@ -62,6 +62,7 @@ I_IN_ARRAY1( int ) +I_IN_ARRAY1( long long ) T_IN_ARRAY1( float ) T_IN_ARRAY1( double ) @@ -103,6 +104,7 @@ %enddef I_ARRAY_ARGOUT( int ) +I_ARRAY_ARGOUT( long long ) T_ARRAY_ARGOUT( float ) T_ARRAY_ARGOUT( double ) @@ -125,6 +127,7 @@ %enddef I_INPLACE_ARRAY1( int ) +I_INPLACE_ARRAY1( long long ) T_INPLACE_ARRAY1( float ) T_INPLACE_ARRAY1( double ) @@ -140,12 +143,14 @@ %define INSTANTIATE_BOTH( f_name ) %template(f_name) f_name; %template(f_name) f_name; +%template(f_name) f_name; +%template(f_name) f_name; /* 64-bit indices would go here */ %enddef %define INSTANTIATE_INDEX( f_name ) %template(f_name) f_name; -/* 64-bit indices would go here */ +%template(f_name) f_name; %enddef %define INSTANTIATE_DATA( f_name ) Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-16 00:31:11 UTC (rev 3544) +++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-16 08:41:00 UTC (rev 3545) @@ -107,6 +107,12 @@ int row_start, int row_stop, int row_step) gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, int row_start, int row_stop, int row_step) + gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax, + float x, float b, long long row_start, long long row_stop, + long long row_step) + gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax, + double x, double b, long long row_start, + long long row_stop, long long row_step) """ return _multigridtools.gauss_seidel(*args) @@ -118,6 +124,14 @@ jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, double temp, int row_start, int row_stop, int row_step, double omega) + jacobi(long long n_row, long long Ap, long long Aj, float Ax, + float x, float b, float temp, long long row_start, + long long row_stop, long long row_step, + float omega) + jacobi(long long n_row, long long Ap, long long Aj, double Ax, + double x, double b, double temp, long long row_start, + long long row_stop, long long row_step, + double omega) """ return _multigridtools.jacobi(*args) Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx 2007-11-16 00:31:11 UTC (rev 3544) +++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx 2007-11-16 08:41:00 UTC (rev 3545) @@ -3099,6 +3099,43 @@ return res; } + +SWIGINTERN int +SWIG_AsVal_long_SS_long (PyObject *obj, long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + long long v = PyLong_AsLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } else { + long v; + res = SWIG_AsVal_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} + #ifdef __cplusplus extern "C" { #endif @@ -5216,6 +5253,278 @@ } +SWIGINTERN PyObject *_wrap_gauss_seidel__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + float *arg4 ; + float *arg5 ; + float *arg6 ; + long long arg7 ; + long long arg8 ; + long long arg9 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + long long val7 ; + int ecode7 = 0 ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:gauss_seidel",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gauss_seidel" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (float*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (float*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (float*) array6->data; + } + ecode7 = SWIG_AsVal_long_SS_long(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gauss_seidel" "', argument " "7"" of type '" "long long""'"); + } + arg7 = static_cast< long long >(val7); + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "gauss_seidel" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "gauss_seidel" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + gauss_seidel(arg1,(long long const (*))arg2,(long long const (*))arg3,(float const (*))arg4,arg5,(float const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_gauss_seidel__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + double *arg4 ; + double *arg5 ; + double *arg6 ; + long long arg7 ; + long long arg8 ; + long long arg9 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + long long val7 ; + int ecode7 = 0 ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:gauss_seidel",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gauss_seidel" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (double*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (double*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (double*) array6->data; + } + ecode7 = SWIG_AsVal_long_SS_long(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gauss_seidel" "', argument " "7"" of type '" "long long""'"); + } + arg7 = static_cast< long long >(val7); + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "gauss_seidel" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "gauss_seidel" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + gauss_seidel(arg1,(long long const (*))arg2,(long long const (*))arg3,(double const (*))arg4,arg5,(double const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + SWIGINTERN PyObject *_wrap_gauss_seidel(PyObject *self, PyObject *args) { int argc; PyObject *argv[10]; @@ -5332,9 +5641,115 @@ } } } + if (argc == 9) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_gauss_seidel__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + } + if (argc == 9) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_gauss_seidel__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'gauss_seidel'.\n Possible C/C++ prototypes are:\n"" gauss_seidel<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],int const,int const,int const)\n"" gauss_seidel<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],int const,int const,int const)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'gauss_seidel'.\n Possible C/C++ prototypes are:\n"" gauss_seidel<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],int const,int const,int const)\n"" gauss_seidel<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],int const,int const,int const)\n"" gauss_seidel<(long long,float)>(long long const,long long const [],long long const [],float const [],float [],float const [],long long const,long long const,long long const)\n"" gauss_seidel<(long long,double)>(long long const,long long const [],long long const [],double const [],double [],double const [],long long const,long long const,long long const)\n"); return NULL; } @@ -5645,6 +6060,312 @@ } +SWIGINTERN PyObject *_wrap_jacobi__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + float *arg4 ; + float *arg5 ; + float *arg6 ; + float *arg7 ; + long long arg8 ; + long long arg9 ; + long long arg10 ; + float arg11 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *temp7 = NULL ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + long long val10 ; + int ecode10 = 0 ; + float val11 ; + int ecode11 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOO:jacobi",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "jacobi" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (float*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (float*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (float*) array6->data; + } + { + temp7 = obj_to_array_no_conversion(obj6,PyArray_FLOAT); + if (!temp7 || !require_contiguous(temp7) || !require_native(temp7)) SWIG_fail; + arg7 = (float*) array_data(temp7); + } + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "jacobi" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "jacobi" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + ecode10 = SWIG_AsVal_long_SS_long(obj9, &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "jacobi" "', argument " "10"" of type '" "long long""'"); + } + arg10 = static_cast< long long >(val10); + ecode11 = SWIG_AsVal_float(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "jacobi" "', argument " "11"" of type '" "float""'"); + } + arg11 = static_cast< float >(val11); + jacobi(arg1,(long long const (*))arg2,(long long const (*))arg3,(float const (*))arg4,arg5,(float const (*))arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_jacobi__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + double *arg4 ; + double *arg5 ; + double *arg6 ; + double *arg7 ; + long long arg8 ; + long long arg9 ; + long long arg10 ; + double arg11 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *temp7 = NULL ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + long long val10 ; + int ecode10 = 0 ; + double val11 ; + int ecode11 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOO:jacobi",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "jacobi" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (double*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (double*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (double*) array6->data; + } + { + temp7 = obj_to_array_no_conversion(obj6,PyArray_DOUBLE); + if (!temp7 || !require_contiguous(temp7) || !require_native(temp7)) SWIG_fail; + arg7 = (double*) array_data(temp7); + } + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "jacobi" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "jacobi" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + ecode10 = SWIG_AsVal_long_SS_long(obj9, &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "jacobi" "', argument " "10"" of type '" "long long""'"); + } + arg10 = static_cast< long long >(val10); + ecode11 = SWIG_AsVal_double(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "jacobi" "', argument " "11"" of type '" "double""'"); + } + arg11 = static_cast< double >(val11); + jacobi(arg1,(long long const (*))arg2,(long long const (*))arg3,(double const (*))arg4,arg5,(double const (*))arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + SWIGINTERN PyObject *_wrap_jacobi(PyObject *self, PyObject *args) { int argc; PyObject *argv[12]; @@ -5783,9 +6504,137 @@ } } } + if (argc == 11) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[9], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_float(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_jacobi__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + } + } + } + if (argc == 11) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[9], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_jacobi__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + } + } + } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'jacobi'.\n Possible C/C++ prototypes are:\n"" jacobi<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],float [],int const,int const,int const,float const)\n"" jacobi<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],double [],int const,int const,int const,double const)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'jacobi'.\n Possible C/C++ prototypes are:\n"" jacobi<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],float [],int const,int const,int const,float const)\n"" jacobi<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],double [],int const,int const,int const,double const)\n"" jacobi<(long long,float)>(long long const,long long const [],long long const [],float const [],float [],float const [],float [],long long const,long long const,long long const,float const)\n"" jacobi<(long long,double)>(long long const,long long const [],long long const [],double const [],double [],double const [],double [],long long const,long long const,long long const,double const)\n"); return NULL; } @@ -5829,6 +6678,12 @@ " int row_start, int row_stop, int row_step)\n" "gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, \n" " int row_start, int row_stop, int row_step)\n" + "gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax, \n" + " float x, float b, long long row_start, long long row_stop, \n" + " long long row_step)\n" + "gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax, \n" + " double x, double b, long long row_start, \n" + " long long row_stop, long long row_step)\n" ""}, { (char *)"jacobi", _wrap_jacobi, METH_VARARGS, (char *)"\n" "jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, \n" @@ -5837,6 +6692,14 @@ "jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, \n" " double temp, int row_start, int row_stop, \n" " int row_step, double omega)\n" + "jacobi(long long n_row, long long Ap, long long Aj, float Ax, \n" + " float x, float b, float temp, long long row_start, \n" + " long long row_stop, long long row_step, \n" + " float omega)\n" + "jacobi(long long n_row, long long Ap, long long Aj, double Ax, \n" + " double x, double b, double temp, long long row_start, \n" + " long long row_stop, long long row_step, \n" + " double omega)\n" ""}, { NULL, NULL, 0, NULL } }; From scipy-svn at scipy.org Fri Nov 16 07:50:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 Nov 2007 06:50:41 -0600 (CST) Subject: [Scipy-svn] r3546 - branches/scipy.scons/scipy/linalg Message-ID: <20071116125041.ABC4B39C1F0@new.scipy.org> Author: cdavid Date: 2007-11-16 06:50:30 -0600 (Fri, 16 Nov 2007) New Revision: 3546 Added: branches/scipy.scons/scipy/linalg/SConstruct branches/scipy.scons/scipy/linalg/setupscons.py Modified: branches/scipy.scons/scipy/linalg/setup.py Log: Starting working on scons build of linalg. Added: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-16 08:41:00 UTC (rev 3545) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-16 12:50:30 UTC (rev 3546) @@ -0,0 +1,177 @@ +# Last Change: Fri Nov 16 09:00 PM 2007 J +# vim:syntax=python + +#import os +#import sys +#from os.path import join as pjoin, basename as pbasename, dirname as pdirname +#from copy import deepcopy + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir +from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ + CheckCLAPACK +#from numpy.distutils.scons.configuration import write_info + +#from scons_support import CheckBrokenMathlib, define_no_smp, \ +# generate_config_header, generate_config_header_emitter + +#------------------- +# To skip wrapping single precision atlas/lapack/blas routines, set +# the following flag to True: +skip_single_routines = 0 + +# Some OS distributions (e.g. Redhat, Suse) provide a blas library that +# is built using incomplete blas sources that come with lapack tar-ball. +# In order to use such a library in scipy.linalg, the following flag +# must be set to True: +using_lapack_blas = 0 + +env = GetNumpyEnvironment(ARGUMENTS) +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 +# # simple code using only typedef and so on, so we need it for configuration +# # checks +# env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) + +#======================= +# Starting Configuration +#======================= +# XXX: separate env for configuration +config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS, + 'CheckBLAS' : CheckF77BLAS, + 'CheckCLAPACK' : CheckCLAPACK, + 'CheckLAPACK' : CheckF77LAPACK}) + +#-------------- +# Checking Blas +#-------------- +st = config.CheckBLAS() +if not st: + raise RuntimeError("no blas found, necessary for linalg module") + +st = config.CheckLAPACK() +if not st: + raise RuntimeError("no lapack found, necessary for linalg module") + +if config.CheckCBLAS(): + has_cblas = 1 +else: + has_cblas = 0 + +if config.CheckCLAPACK(): + has_clapack = 1 +else: + has_clapack = 0 + +config.Finish() +#write_info(env) + +#========== +# Build +#========== +#atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \ +# if k=='ATLAS_INFO']+[None])[0] +#if atlas_version: +# print 'ATLAS version',atlas_version + +target_dir = '' +skip_names = {'clapack':[],'flapack':[],'cblas':[],'fblas':[]} +if skip_single_routines: + target_dir = 'dbl' + skip_names['clapack'].extend(\ + 'sgesv cgesv sgetrf cgetrf sgetrs cgetrs sgetri cgetri'\ + ' sposv cposv spotrf cpotrf spotrs cpotrs spotri cpotri'\ + ' slauum clauum strtri ctrtri'.split()) + skip_names['flapack'].extend(skip_names['clapack']) + skip_names['flapack'].extend(\ + 'sgesdd cgesdd sgelss cgelss sgeqrf cgeqrf sgeev cgeev'\ + ' sgegv cgegv ssyev cheev slaswp claswp sgees cgees' + ' sggev cggev'.split()) + skip_names['cblas'].extend('saxpy caxpy'.split()) + skip_names['fblas'].extend(skip_names['cblas']) + skip_names['fblas'].extend(\ + 'srotg crotg srotmg srot csrot srotm sswap cswap sscal cscal'\ + ' csscal scopy ccopy sdot cdotu cdotc snrm2 scnrm2 sasum scasum'\ + ' isamax icamax sgemv cgemv chemv ssymv strmv ctrmv'\ + ' sgemm cgemm'.split()) + +if using_lapack_blas: + target_dir = join(target_dir,'blas') + skip_names['fblas'].extend(\ + 'drotmg srotmg drotm srotm'.split()) + +#if atlas_version=='3.2.1_pre3.3.6': +# target_dir = join(target_dir,'atlas321') +# skip_names['clapack'].extend(\ +# 'sgetri dgetri cgetri zgetri spotri dpotri cpotri zpotri'\ +# ' slauum dlauum clauum zlauum strtri dtrtri ctrtri ztrtri'.split()) +#elif atlas_version>'3.4.0' and atlas_version<='3.5.12': +# skip_names['clapack'].extend('cpotrf zpotrf'.split()) + +def generate_pyf(target, source, env): + target = join(build_dir,target_dir,name+'.pyf') + if name[0]=='c' and atlas_version is None and newer(__file__,target): + print "============ %s =============" % target + f = open(target,'w') + f.write('python module '+name+'\n') + f.write('usercode void empty_module(void) {}\n') + f.write('interface\n') + f.write('subroutine empty_module()\n') + f.write('intent(c) empty_module\n') + f.write('end subroutine empty_module\n') + f.write('end interface\nend python module'+name+'\n') + f.close() + return target + if newer_group(extension.depends,target): + print name, extension.depend[0], target + raise "YATA:" + generate_interface(name, + extension.depends[0], + target, + skip_names[name]) + return target + +#------------- +# Build fblas: +#------------- +# XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) +import os +from os.path import join + +from interface_gen import generate_interface + +src_files = ['generic_fblas.pyf', + 'generic_fblas1.pyf', + 'generic_fblas2.pyf', + 'generic_fblas3.pyf', + 'interface_gen.py', + join('src','fblaswrap_veclib_c.c'), + join('src','fblaswrap.f')] + +# fblas: + +def do_generate_interface(target, source, env): + """Generate a .pyf file from another pyf file (!).""" + # XXX: do this correctly + target_name = str(target[0]) + source_name = str(source[0]) + + # XXX handle skip names + name = os.path.splitext(os.path.basename(target_name))[0] + generate_interface(name, source_name, target_name) + return 0 + +def generate_interface_emitter(target, source, env): + base = str(target[0]) + return (['%s.pyf' % base], source) + +env['BUILDERS']['haha'] = Builder(action = do_generate_interface, + emitter = generate_interface_emitter) +env.haha('build/scons/fblas', 'generic_fblas.pyf') +env.NumpyPythonExtension('fblas', source = 'fblas.pyf') + +#if has_cblas: +# env.haha('cblas', 'generic_cblas.pyf') +# env.NumpyPythonExtension('cblas', source = 'cblas.pyf') Modified: branches/scipy.scons/scipy/linalg/setup.py =================================================================== --- branches/scipy.scons/scipy/linalg/setup.py 2007-11-16 08:41:00 UTC (rev 3545) +++ branches/scipy.scons/scipy/linalg/setup.py 2007-11-16 12:50:30 UTC (rev 3546) @@ -108,6 +108,8 @@ f.close() return target if newer_group(extension.depends,target): + print "name %s, depends %s, target %s" % (name, extension.depends[0], target) + print "skipping %s" % skip_names[name] generate_interface(name, extension.depends[0], target, Copied: branches/scipy.scons/scipy/linalg/setupscons.py (from rev 3539, branches/scipy.scons/scipy/linalg/setup.py) =================================================================== --- branches/scipy.scons/scipy/linalg/setup.py 2007-11-14 04:21:13 UTC (rev 3539) +++ branches/scipy.scons/scipy/linalg/setupscons.py 2007-11-16 12:50:30 UTC (rev 3546) @@ -0,0 +1,65 @@ +## Automatically adapted for scipy Oct 18, 2005 by + +#!/usr/bin/env python + +from __future__ import nested_scopes +import os +import sys +import re +from distutils.dep_util import newer_group, newer +from glob import glob +from os.path import join + +#------------------- +# To skip wrapping single precision atlas/lapack/blas routines, set +# the following flag to True: +skip_single_routines = 0 + +# Some OS distributions (e.g. Redhat, Suse) provide a blas library that +# is built using incomplete blas sources that come with lapack tar-ball. +# In order to use such a library in scipy.linalg, the following flag +# must be set to True: +using_lapack_blas = 0 + +#-------------------- + +def needs_cblas_wrapper(info): + """Returns true if needs c wrapper around cblas for calling from + fortran.""" + import re + r_accel = re.compile("Accelerate") + r_vec = re.compile("vecLib") + res = False + try: + tmpstr = info['extra_link_args'] + for i in tmpstr: + if r_accel.search(i) or r_vec.search(i): + res = True + except KeyError: + pass + + return res + +def configuration(parent_package='',top_path=None): + from numpy.distutils.system_info import get_info, NotFoundError + + from numpy.distutils.misc_util import Configuration + + from interface_gen import generate_interface + + config = Configuration('linalg',parent_package,top_path) + + # list of source files to register to distutils + source_files = [] + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + from linalg_version import linalg_version + + setup(version=linalg_version, + **configuration(top_path='').todict()) From scipy-svn at scipy.org Fri Nov 16 20:15:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 Nov 2007 19:15:10 -0600 (CST) Subject: [Scipy-svn] r3547 - trunk/scipy/ndimage Message-ID: <20071117011510.DD38439C0A6@new.scipy.org> Author: tom.waite Date: 2007-11-16 19:15:06 -0600 (Fri, 16 Nov 2007) New Revision: 3547 Modified: trunk/scipy/ndimage/segmenter.py Log: Move C code to Python. Start with setup functions. Modified: trunk/scipy/ndimage/segmenter.py =================================================================== --- trunk/scipy/ndimage/segmenter.py 2007-11-16 12:50:30 UTC (rev 3546) +++ trunk/scipy/ndimage/segmenter.py 2007-11-17 01:15:06 UTC (rev 3547) @@ -1,4 +1,4 @@ - +import math import numpy as N import scipy.ndimage.segment as S @@ -282,6 +282,7 @@ mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) slice = slice.astype(float) + # this is for the test CT as spine runs off back of image slice[505:512,:] = 0 return slice @@ -290,4 +291,203 @@ slice = mySlice.astype('u%d' % bytes) slice.tofile(filename) +def build_d_gauss_kernel(gWidth=21, sigma=1.0): + """ + build the derivative of Gaussian kernel for Canny edge filter + DGFilter = build_d_gauss_kernel(gWidth, sigma) + Inputs: + gWdith is width of derivative of Gaussian kernel + sigma is sigma term of derivative of Gaussian kernel + Output: + DGFilter (a struct). Use in Canny filter call + + """ + kernel = N.zeros((1+2*(gWidth-1)), dtype=float) + indices = range(1, gWidth) + + i = 0 + kernel[gWidth-1] = math.exp(((-i*i)/(2.0 * sigma * sigma))) + kernel[gWidth-1] *= -(i / (sigma * sigma)) + for i in indices: + kernel[gWidth-1+i] = math.exp(((-i*i)/(2.0 * sigma * sigma))) + kernel[gWidth-1+i] *= -(i / (sigma * sigma)) + kernel[gWidth-1-i] = -kernel[gWidth-1+i] + + DGFilter= {'kernelSize' : gWidth, 'coefficients': kernel} + + return DGFilter + +def build_2d_kernel(aperature=21, hiFilterCutoff=10.0): + + """ + build flat FIR filter with sinc kernel + this is bandpass, but low cutoff is 0.0 + Use in Sobel and Canny filter edge find as image pre-process + + FIRFilter = build_2d_kernel(aperature, hiFilterCutoff) + Inputs: + aperature is number of FIR taps in sinc kernel + hiFilterCutoff is digital frequency cutoff in range (0.0, 180.0) + Output: + FIRFilter (a struct) + + """ + + rad = math.pi / 180.0 + HalfFilterTaps = (aperature-1) / 2 + kernel = N.zeros((aperature), dtype=N.float32) + LC = 0.0 + HC = hiFilterCutoff * rad + t2 = 2.0 * math.pi + t1 = 2.0 * HalfFilterTaps + 1.0 + indices = range(-HalfFilterTaps, HalfFilterTaps+1, 1) + j = 0 + for i in indices: + if i == 0: + tLOW = LC + tHIGH = HC + else: + tLOW = math.sin(i*LC)/i + tHIGH = math.sin(i*HC)/i + # Hamming window + t3 = 0.54 + 0.46*(math.cos(i*t2/t1)) + t4 = t3*(tHIGH-tLOW) + kernel[j] = t4 + j += 1 + + # normalize the kernel + sum = kernel.sum() + kernel /= sum + + FIRFilter= {'kernelSize' : aperature, 'coefficients': kernel} + + return FIRFilter + + +def build_laws_kernel(): + + """ + build 6 length-7 Law's texture filter masks + mask names are: 'L', 'S', 'E', 'W', 'R', 'O' + + LAWSFilter = build_laws_kernel() + + Inputs: + None + + Output: + LAWSFilter (a struct) + + """ + aperature = (6, 7) + coefficients = N.zeros((aperature), dtype=N.float32) + names = ('L', 'E', 'S', 'W', 'R', 'O' ) + + coefficients[0, :] = ( 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0 ) + coefficients[1, :] = (-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0 ) + coefficients[2, :] = (-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0 ) + coefficients[3, :] = (-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0 ) + coefficients[4, :] = ( 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0 ) + coefficients[5, :] = (-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0 ) + + LAWSFilter= {'numKernels' : 6, 'kernelSize' : 7, 'coefficients': coefficients, 'names': names} + + return LAWSFilter + +def build_morpho_thin_masks(): + + """ + build 2 sets (J and K) of 8 3x3 morphology masks (structuring elements) + to implement thinning (medial axis transformation - MAT) + + MATFilter = build_morpho_thin_masks() + + Inputs: + None + + Output: + MATFilter (a struct) + + """ + + # (layers, rows, cols) + shape = (8, 3, 3) + J_mask = N.zeros((shape), dtype=N.ushort) + K_mask = N.zeros((shape), dtype=N.ushort) + + # load the 8 J masks for medial axis transformation + J_mask[0][0][0] = 1; + J_mask[0][0][1] = 1; + J_mask[0][0][2] = 1; + J_mask[0][1][1] = 1; + + J_mask[1][0][1] = 1; + J_mask[1][1][1] = 1; + J_mask[1][1][2] = 1; + + J_mask[2][0][0] = 1; + J_mask[2][1][0] = 1; + J_mask[2][2][0] = 1; + J_mask[2][1][1] = 1; + + J_mask[3][0][1] = 1; + J_mask[3][1][0] = 1; + J_mask[3][1][1] = 1; + + J_mask[4][0][2] = 1; + J_mask[4][1][1] = 1; + J_mask[4][1][2] = 1; + J_mask[4][2][2] = 1; + + J_mask[5][1][0] = 1; + J_mask[5][1][1] = 1; + J_mask[5][2][1] = 1; + + J_mask[6][1][1] = 1; + J_mask[6][2][0] = 1; + J_mask[6][2][1] = 1; + J_mask[6][2][2] = 1; + + J_mask[7][1][1] = 1; + J_mask[7][1][2] = 1; + J_mask[7][2][1] = 1; + + + # load the 8 K masks for medial axis transformation + K_mask[0][2][0] = 1; + K_mask[0][2][1] = 1; + K_mask[0][2][2] = 1; + + K_mask[1][1][0] = 1; + K_mask[1][2][0] = 1; + K_mask[1][2][1] = 1; + + K_mask[2][0][2] = 1; + K_mask[2][1][2] = 1; + K_mask[2][2][2] = 1; + + K_mask[3][1][2] = 1; + K_mask[3][2][1] = 1; + K_mask[3][2][2] = 1; + + K_mask[4][0][0] = 1; + K_mask[4][1][0] = 1; + K_mask[4][2][0] = 1; + + K_mask[5][0][1] = 1; + K_mask[5][0][2] = 1; + K_mask[5][1][2] = 1; + + K_mask[6][0][0] = 1; + K_mask[6][0][1] = 1; + K_mask[6][0][2] = 1; + + K_mask[7][0][0] = 1; + K_mask[7][0][1] = 1; + K_mask[7][1][0] = 1; + + MATFilter = {'number3x3Masks' : 8, 'jmask' : J_mask, 'kmask' : K_mask} + + return MATFilter + From scipy-svn at scipy.org Sun Nov 18 23:13:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 18 Nov 2007 22:13:58 -0600 (CST) Subject: [Scipy-svn] r3548 - in trunk: . scipy/io/tests scipy/ndimage scipy/ndimage/segment/tests scipy/ndimage/tests scipy/sandbox/montecarlo/examples scipy/sandbox/multigrid scipy/sandbox/multigrid/multigridtools scipy/sandbox/multigrid/tests scipy/sparse scipy/sparse/sparsetools scipy/stats/models/robust Message-ID: <20071119041358.6F59E39C073@new.scipy.org> Author: jarrod.millman Date: 2007-11-18 22:13:22 -0600 (Sun, 18 Nov 2007) New Revision: 3548 Modified: trunk/scipy/io/tests/test_datasource.py trunk/scipy/ndimage/segment/tests/test_segment.py trunk/scipy/ndimage/segmenter.py trunk/scipy/ndimage/tests/test_segment.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py trunk/scipy/sandbox/multigrid/adaptive.py trunk/scipy/sandbox/multigrid/dec_test.py trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py trunk/scipy/sandbox/multigrid/multilevel.py trunk/scipy/sandbox/multigrid/tests/test_utils.py trunk/scipy/sandbox/multigrid/utils.py trunk/scipy/sparse/sparse.py trunk/scipy/sparse/sparsetools/sparsetools.py trunk/scipy/stats/models/robust/scale.py trunk/setup.py Log: ran reindent.py to cleanup whitespaces Modified: trunk/scipy/io/tests/test_datasource.py =================================================================== --- trunk/scipy/io/tests/test_datasource.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/io/tests/test_datasource.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -85,7 +85,7 @@ def test_ValidHTTP(self): assert self.ds.open(valid_httpurl()) - + def test_InvalidHTTP(self): self.assertRaises(IOError, self.ds.open, invalid_httpurl()) @@ -131,7 +131,7 @@ def test_ValidHTTP(self): assert self.ds.exists(valid_httpurl()) - + def test_InvalidHTTP(self): self.assertEqual(self.ds.exists(invalid_httpurl()), False) @@ -240,7 +240,7 @@ class TestOpenFunc(NumpyTestCase): def setUp(self): self.tmpdir = mkdtemp() - + def tearDown(self): rmtree(self.tmpdir) @@ -254,4 +254,3 @@ if __name__ == "__main__": NumpyTest().run() - Modified: trunk/scipy/ndimage/segment/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/segment/tests/test_segment.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/ndimage/segment/tests/test_segment.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -11,302 +11,302 @@ def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - """ - labeledEdges, ROIList = shen_castan(image, [default]) + """ + labeledEdges, ROIList = shen_castan(image, [default]) - implements Shen-Castan edge finding + implements Shen-Castan edge finding - Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust - - image is the numarray 2D image - - IIR filter is filter parameter for exponential filter - - shen_castan_low is edge threshold is range (0.0, 1.0] - - window is search window for edge detection - - low_ and high_ threshold are density values - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust + - image is the numarray 2D image + - IIR filter is filter parameter for exponential filter + - shen_castan_low is edge threshold is range (0.0, 1.0] + - window is search window for edge detection + - low_ and high_ threshold are density values + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, - lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, + lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - """ - labeledEdges, ROIList = sobel(image, [default]) + """ + labeledEdges, ROIList = sobel(image, [default]) - implements sobel magnitude edge finding + implements sobel magnitude edge finding - Inputs - image, sobel_low, tMode, low_threshold, high_threshold, - high_filter_cutoff, filter_aperature, dust - - image is the numarray 2D image - - sobel_low is edge threshold is range (0.0, 1.0] - - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) - - low_ and high_ threshold are density values - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - aperature is odd filter kernel length - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, sobel_low, tMode, low_threshold, high_threshold, + high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - sobel_low is edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, - highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, + highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - """ - labeledEdges, ROIList = canny(image, [default]) + """ + labeledEdges, ROIList = canny(image, [default]) - implements canny edge finding + implements canny edge finding - Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, - high_threshold, high_filter_cutoff, filter_aperature, dust - - image is the numarray 2D image - - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter - - clow is low edge threshold is range (0.0, 1.0] - - chigh is high edge threshold is range (0.0, 1.0] - - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) - - low_ and high_ threshold are density values - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - aperature is odd filter kernel length - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, + high_threshold, high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter + - clow is low edge threshold is range (0.0, 1.0] + - chigh is high edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def get_shape_mask(labeledEdges, ROIList): - """ - get_shape_mask(labeledEdges, ROIList) + """ + get_shape_mask(labeledEdges, ROIList) - takes labeled edge image plus ROIList (blob descriptors) and generates - boundary shape features and builds labeled blob masks. 'labeledEdges' - is over-written by 'labeledMask'. Adds features to ROIList structure + takes labeled edge image plus ROIList (blob descriptors) and generates + boundary shape features and builds labeled blob masks. 'labeledEdges' + is over-written by 'labeledMask'. Adds features to ROIList structure - Inputs - labeledEdges, ROIList - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - labeledEdges, ROIList + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. edge image input is over-written with mask image. - ROIList added to. + Output - no return. edge image input is over-written with mask image. + ROIList added to. - """ + """ - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return def get_voxel_measures(rawImage, labeledEdges, ROIList): - """ - get_voxel_measures(rawImage, labeledEdges, ROIList) + """ + get_voxel_measures(rawImage, labeledEdges, ROIList) - takes raw 2D image, labeled blob mask and ROIList. computes voxel features - (moments, histogram) for each blob. Adds features to ROIList structure. + takes raw 2D image, labeled blob mask and ROIList. computes voxel features + (moments, histogram) for each blob. Adds features to ROIList structure. - Inputs - rawImage, labeledEdges, ROIList - - rawImage is the original source 2D image - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. ROIList added to. + Output - no return. ROIList added to. - """ - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return def get_texture_measures(rawImage, labeledEdges, ROIList): - """ - get_texture_measures(rawImage, labeledEdges, ROIList) + """ + get_texture_measures(rawImage, labeledEdges, ROIList) - takes raw 2D image, labeled blob mask and ROIList. computes 2D - texture features using 7x7 Law's texture filters applied - to segmented blobs. TEM (texture energy metric) is computed - for each Law's filter image and stored in TEM part of ROIList. + takes raw 2D image, labeled blob mask and ROIList. computes 2D + texture features using 7x7 Law's texture filters applied + to segmented blobs. TEM (texture energy metric) is computed + for each Law's filter image and stored in TEM part of ROIList. - Inputs - rawImage, labeledEdges, ROIList - - rawImage is the original source 2D image - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. ROIList added to. - """ - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return + Output - no return. ROIList added to. + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return def segment_regions(): - """ - sourceImage, labeledMask, ROIList = segment_regions() + """ + sourceImage, labeledMask, ROIList = segment_regions() - Inputs - No Input + Inputs - No Input - Outputs - sourceImage, labeledMask, ROIList - - sourceImage is raw 2D image (default cardiac CT slice for demo - - labeledMask is mask of segmented 'blobs', - numerically labeled by blob number - - ROIList is numerical Python structure of intensity, shape and - texture features for each blob + Outputs - sourceImage, labeledMask, ROIList + - sourceImage is raw 2D image (default cardiac CT slice for demo + - labeledMask is mask of segmented 'blobs', + numerically labeled by blob number + - ROIList is numerical Python structure of intensity, shape and + texture features for each blob - High level script calls Python functions: - get_slice() - a cardiac CT slice demo file - sobel() - sobel magnitude edge finder, - returns connected edges - get_shape_mask() - gets segmented blob boundary and mask - and shape features - get_voxel_measures() - uses masks get object voxel moment - and histogram features - get_texture_measures() - uses masks get object 2D texture features - """ - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + sobel() - sobel magnitude edge finder, + returns connected edges + get_shape_mask() - gets segmented blob boundary and mask + and shape features + get_voxel_measures() - uses masks get object voxel moment + and histogram features + get_texture_measures() - uses masks get object 2D texture features + """ + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList def grow_regions(): - """ - regionMask, numberRegions = region_grow() - Inputs - No Input - Outputs - regionMask, numberRegions - - regionMask is the labeled segment masks from 2D image - - numberRegions is the number of segmented blobs + """ + regionMask, numberRegions = region_grow() + Inputs - No Input + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs - High level script calls Python functions: - get_slice() - a cardiac CT slice demo file - region_grow() - "grows" connected blobs. default threshold - and morphological filter structuring element - """ - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + region_grow() - "grows" connected blobs. default threshold + and morphological filter structuring element + """ + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - """ - regionMask, numberRegions = region_grow(image, [defaults]) + """ + regionMask, numberRegions = region_grow(image, [defaults]) - Inputs - image, low_threshold, high_threshold, open, close - - image is the numarray 2D image - - low_ and high_ threshold are density values - - open is open morphology structuring element - odd size. 0 to turn off. max is 11 - - close is close morphology structuring element - odd size. 0 to turn off. max is 11 + Inputs - image, low_threshold, high_threshold, open, close + - image is the numarray 2D image + - low_ and high_ threshold are density values + - open is open morphology structuring element + odd size. 0 to turn off. max is 11 + - close is close morphology structuring element + odd size. 0 to turn off. max is 11 - Outputs - regionMask, numberRegions - - regionMask is the labeled segment masks from 2D image - - numberRegions is the number of segmented blobs - """ - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + """ + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - slice[505:512,:] = 0 - return slice + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) class TestSegment(NumpyTestCase): def test1(self): - image = get_slice(filename) - sourceImage = image.copy() - edges, objects = sobel(image) - get_shape_mask(edges, objects) - get_voxel_measures(sourceImage, edges, objects) - get_texture_measures(sourceImage, edges, objects) + image = get_slice(filename) + sourceImage = image.copy() + edges, objects = sobel(image) + get_shape_mask(edges, objects) + get_voxel_measures(sourceImage, edges, objects) + get_texture_measures(sourceImage, edges, objects) def test2(self): - sourceImage, labeledMask, ROIList = segment_regions() + sourceImage, labeledMask, ROIList = segment_regions() def test3(self): - regionMask, numberRegions = grow_regions() - regionMask.max() - #save_slice(regionMask, 'regionMask.raw') + regionMask, numberRegions = grow_regions() + regionMask.max() + #save_slice(regionMask, 'regionMask.raw') if __name__ == "__main__": Modified: trunk/scipy/ndimage/segmenter.py =================================================================== --- trunk/scipy/ndimage/segmenter.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/ndimage/segmenter.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -11,483 +11,483 @@ def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - """ - labeledEdges, ROIList = shen_castan(image, [default]) + """ + labeledEdges, ROIList = shen_castan(image, [default]) - implements Shen-Castan edge finding + implements Shen-Castan edge finding - Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust - - image is the numarray 2D image - - IIR filter is filter parameter for exponential filter - - shen_castan_low is edge threshold is range (0.0, 1.0] - - window is search window for edge detection - - low_ and high_ threshold are density values - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust + - image is the numarray 2D image + - IIR filter is filter parameter for exponential filter + - shen_castan_low is edge threshold is range (0.0, 1.0] + - window is search window for edge detection + - low_ and high_ threshold are density values + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, - lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, + lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - """ - labeledEdges, ROIList = sobel(image, [default]) + """ + labeledEdges, ROIList = sobel(image, [default]) - implements sobel magnitude edge finding + implements sobel magnitude edge finding - Inputs - image, sobel_low, tMode, low_threshold, high_threshold, - high_filter_cutoff, filter_aperature, dust - - image is the numarray 2D image - - sobel_low is edge threshold is range (0.0, 1.0] - - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) - - low_ and high_ threshold are density values - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - aperature is odd filter kernel length - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, sobel_low, tMode, low_threshold, high_threshold, + high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - sobel_low is edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, - highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, + highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - """ - labeledEdges, ROIList = canny(image, [default]) + """ + labeledEdges, ROIList = canny(image, [default]) - implements canny edge finding + implements canny edge finding - Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, - high_threshold, high_filter_cutoff, filter_aperature, dust - - image is the numarray 2D image - - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter - - clow is low edge threshold is range (0.0, 1.0] - - chigh is high edge threshold is range (0.0, 1.0] - - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) - - low_ and high_ threshold are density values - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - aperature is odd filter kernel length - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, + high_threshold, high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter + - clow is low edge threshold is range (0.0, 1.0] + - chigh is high edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def get_shape_mask(labeledEdges, ROIList): - """ - get_shape_mask(labeledEdges, ROIList) + """ + get_shape_mask(labeledEdges, ROIList) - takes labeled edge image plus ROIList (blob descriptors) and generates - boundary shape features and builds labeled blob masks. 'labeledEdges' - is over-written by 'labeledMask'. Adds features to ROIList structure + takes labeled edge image plus ROIList (blob descriptors) and generates + boundary shape features and builds labeled blob masks. 'labeledEdges' + is over-written by 'labeledMask'. Adds features to ROIList structure - Inputs - labeledEdges, ROIList - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - labeledEdges, ROIList + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. edge image input is over-written with mask image. - ROIList added to. + Output - no return. edge image input is over-written with mask image. + ROIList added to. - """ + """ - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return def get_voxel_measures(rawImage, labeledEdges, ROIList): - """ - get_voxel_measures(rawImage, labeledEdges, ROIList) + """ + get_voxel_measures(rawImage, labeledEdges, ROIList) - takes raw 2D image, labeled blob mask and ROIList. computes voxel features - (moments, histogram) for each blob. Adds features to ROIList structure. + takes raw 2D image, labeled blob mask and ROIList. computes voxel features + (moments, histogram) for each blob. Adds features to ROIList structure. - Inputs - rawImage, labeledEdges, ROIList - - rawImage is the original source 2D image - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. ROIList added to. + Output - no return. ROIList added to. - """ - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return def get_texture_measures(rawImage, labeledEdges, ROIList): - """ - get_texture_measures(rawImage, labeledEdges, ROIList) + """ + get_texture_measures(rawImage, labeledEdges, ROIList) - takes raw 2D image, labeled blob mask and ROIList. computes 2D - texture features using 7x7 Law's texture filters applied - to segmented blobs. TEM (texture energy metric) is computed - for each Law's filter image and stored in TEM part of ROIList. + takes raw 2D image, labeled blob mask and ROIList. computes 2D + texture features using 7x7 Law's texture filters applied + to segmented blobs. TEM (texture energy metric) is computed + for each Law's filter image and stored in TEM part of ROIList. - Inputs - rawImage, labeledEdges, ROIList - - rawImage is the original source 2D image - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. ROIList added to. - """ - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return + Output - no return. ROIList added to. + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return def segment_regions(): - """ - sourceImage, labeledMask, ROIList = segment_regions() + """ + sourceImage, labeledMask, ROIList = segment_regions() - Inputs - No Input + Inputs - No Input - Outputs - sourceImage, labeledMask, ROIList - - sourceImage is raw 2D image (default cardiac CT slice for demo - - labeledMask is mask of segmented 'blobs', - numerically labeled by blob number - - ROIList is numerical Python structure of intensity, shape and - texture features for each blob + Outputs - sourceImage, labeledMask, ROIList + - sourceImage is raw 2D image (default cardiac CT slice for demo + - labeledMask is mask of segmented 'blobs', + numerically labeled by blob number + - ROIList is numerical Python structure of intensity, shape and + texture features for each blob - High level script calls Python functions: - get_slice() - a cardiac CT slice demo file - sobel() - sobel magnitude edge finder, - returns connected edges - get_shape_mask() - gets segmented blob boundary and mask - and shape features - get_voxel_measures() - uses masks get object voxel moment - and histogram features - get_texture_measures() - uses masks get object 2D texture features - """ - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + sobel() - sobel magnitude edge finder, + returns connected edges + get_shape_mask() - gets segmented blob boundary and mask + and shape features + get_voxel_measures() - uses masks get object voxel moment + and histogram features + get_texture_measures() - uses masks get object 2D texture features + """ + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList def grow_regions(): - """ - regionMask, numberRegions = region_grow() - Inputs - No Input - Outputs - regionMask, numberRegions - - regionMask is the labeled segment masks from 2D image - - numberRegions is the number of segmented blobs + """ + regionMask, numberRegions = region_grow() + Inputs - No Input + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs - High level script calls Python functions: - get_slice() - a cardiac CT slice demo file - region_grow() - "grows" connected blobs. default threshold - and morphological filter structuring element - """ - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + region_grow() - "grows" connected blobs. default threshold + and morphological filter structuring element + """ + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - """ - regionMask, numberRegions = region_grow(image, [defaults]) + """ + regionMask, numberRegions = region_grow(image, [defaults]) - Inputs - image, low_threshold, high_threshold, open, close - - image is the numarray 2D image - - low_ and high_ threshold are density values - - open is open morphology structuring element - odd size. 0 to turn off. max is 11 - - close is close morphology structuring element - odd size. 0 to turn off. max is 11 + Inputs - image, low_threshold, high_threshold, open, close + - image is the numarray 2D image + - low_ and high_ threshold are density values + - open is open morphology structuring element + odd size. 0 to turn off. max is 11 + - close is close morphology structuring element + odd size. 0 to turn off. max is 11 - Outputs - regionMask, numberRegions - - regionMask is the labeled segment masks from 2D image - - numberRegions is the number of segmented blobs - """ - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + """ + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - # this is for the test CT as spine runs off back of image - slice[505:512,:] = 0 - return slice + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + # this is for the test CT as spine runs off back of image + slice[505:512,:] = 0 + return slice def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) def build_d_gauss_kernel(gWidth=21, sigma=1.0): - """ - build the derivative of Gaussian kernel for Canny edge filter - DGFilter = build_d_gauss_kernel(gWidth, sigma) - Inputs: - gWdith is width of derivative of Gaussian kernel - sigma is sigma term of derivative of Gaussian kernel - Output: - DGFilter (a struct). Use in Canny filter call + """ + build the derivative of Gaussian kernel for Canny edge filter + DGFilter = build_d_gauss_kernel(gWidth, sigma) + Inputs: + gWdith is width of derivative of Gaussian kernel + sigma is sigma term of derivative of Gaussian kernel + Output: + DGFilter (a struct). Use in Canny filter call - """ - kernel = N.zeros((1+2*(gWidth-1)), dtype=float) - indices = range(1, gWidth) + """ + kernel = N.zeros((1+2*(gWidth-1)), dtype=float) + indices = range(1, gWidth) - i = 0 - kernel[gWidth-1] = math.exp(((-i*i)/(2.0 * sigma * sigma))) - kernel[gWidth-1] *= -(i / (sigma * sigma)) - for i in indices: - kernel[gWidth-1+i] = math.exp(((-i*i)/(2.0 * sigma * sigma))) - kernel[gWidth-1+i] *= -(i / (sigma * sigma)) - kernel[gWidth-1-i] = -kernel[gWidth-1+i] + i = 0 + kernel[gWidth-1] = math.exp(((-i*i)/(2.0 * sigma * sigma))) + kernel[gWidth-1] *= -(i / (sigma * sigma)) + for i in indices: + kernel[gWidth-1+i] = math.exp(((-i*i)/(2.0 * sigma * sigma))) + kernel[gWidth-1+i] *= -(i / (sigma * sigma)) + kernel[gWidth-1-i] = -kernel[gWidth-1+i] - DGFilter= {'kernelSize' : gWidth, 'coefficients': kernel} + DGFilter= {'kernelSize' : gWidth, 'coefficients': kernel} - return DGFilter + return DGFilter def build_2d_kernel(aperature=21, hiFilterCutoff=10.0): - """ - build flat FIR filter with sinc kernel - this is bandpass, but low cutoff is 0.0 - Use in Sobel and Canny filter edge find as image pre-process + """ + build flat FIR filter with sinc kernel + this is bandpass, but low cutoff is 0.0 + Use in Sobel and Canny filter edge find as image pre-process - FIRFilter = build_2d_kernel(aperature, hiFilterCutoff) - Inputs: - aperature is number of FIR taps in sinc kernel - hiFilterCutoff is digital frequency cutoff in range (0.0, 180.0) - Output: - FIRFilter (a struct) + FIRFilter = build_2d_kernel(aperature, hiFilterCutoff) + Inputs: + aperature is number of FIR taps in sinc kernel + hiFilterCutoff is digital frequency cutoff in range (0.0, 180.0) + Output: + FIRFilter (a struct) - """ + """ - rad = math.pi / 180.0 - HalfFilterTaps = (aperature-1) / 2 - kernel = N.zeros((aperature), dtype=N.float32) - LC = 0.0 - HC = hiFilterCutoff * rad - t2 = 2.0 * math.pi - t1 = 2.0 * HalfFilterTaps + 1.0 - indices = range(-HalfFilterTaps, HalfFilterTaps+1, 1) - j = 0 - for i in indices: - if i == 0: - tLOW = LC - tHIGH = HC - else: - tLOW = math.sin(i*LC)/i - tHIGH = math.sin(i*HC)/i - # Hamming window - t3 = 0.54 + 0.46*(math.cos(i*t2/t1)) - t4 = t3*(tHIGH-tLOW) - kernel[j] = t4 - j += 1 + rad = math.pi / 180.0 + HalfFilterTaps = (aperature-1) / 2 + kernel = N.zeros((aperature), dtype=N.float32) + LC = 0.0 + HC = hiFilterCutoff * rad + t2 = 2.0 * math.pi + t1 = 2.0 * HalfFilterTaps + 1.0 + indices = range(-HalfFilterTaps, HalfFilterTaps+1, 1) + j = 0 + for i in indices: + if i == 0: + tLOW = LC + tHIGH = HC + else: + tLOW = math.sin(i*LC)/i + tHIGH = math.sin(i*HC)/i + # Hamming window + t3 = 0.54 + 0.46*(math.cos(i*t2/t1)) + t4 = t3*(tHIGH-tLOW) + kernel[j] = t4 + j += 1 - # normalize the kernel - sum = kernel.sum() - kernel /= sum + # normalize the kernel + sum = kernel.sum() + kernel /= sum - FIRFilter= {'kernelSize' : aperature, 'coefficients': kernel} + FIRFilter= {'kernelSize' : aperature, 'coefficients': kernel} - return FIRFilter + return FIRFilter def build_laws_kernel(): - """ - build 6 length-7 Law's texture filter masks - mask names are: 'L', 'S', 'E', 'W', 'R', 'O' + """ + build 6 length-7 Law's texture filter masks + mask names are: 'L', 'S', 'E', 'W', 'R', 'O' - LAWSFilter = build_laws_kernel() + LAWSFilter = build_laws_kernel() - Inputs: - None + Inputs: + None - Output: - LAWSFilter (a struct) + Output: + LAWSFilter (a struct) - """ - aperature = (6, 7) - coefficients = N.zeros((aperature), dtype=N.float32) - names = ('L', 'E', 'S', 'W', 'R', 'O' ) + """ + aperature = (6, 7) + coefficients = N.zeros((aperature), dtype=N.float32) + names = ('L', 'E', 'S', 'W', 'R', 'O' ) - coefficients[0, :] = ( 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0 ) - coefficients[1, :] = (-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0 ) - coefficients[2, :] = (-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0 ) - coefficients[3, :] = (-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0 ) - coefficients[4, :] = ( 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0 ) - coefficients[5, :] = (-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0 ) + coefficients[0, :] = ( 1.0, 6.0, 15.0, 20.0, 15.0, 6.0, 1.0 ) + coefficients[1, :] = (-1.0, -4.0, -5.0, 0.0, 5.0, 4.0, 1.0 ) + coefficients[2, :] = (-1.0, -2.0, 1.0, 4.0, 1.0, -2.0, -1.0 ) + coefficients[3, :] = (-1.0, 0.0, 3.0, 0.0, -3.0, 0.0, 1.0 ) + coefficients[4, :] = ( 1.0, -2.0, -1.0, 4.0, -1.0, -2.0, 1.0 ) + coefficients[5, :] = (-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0 ) - LAWSFilter= {'numKernels' : 6, 'kernelSize' : 7, 'coefficients': coefficients, 'names': names} + LAWSFilter= {'numKernels' : 6, 'kernelSize' : 7, 'coefficients': coefficients, 'names': names} - return LAWSFilter + return LAWSFilter def build_morpho_thin_masks(): - """ - build 2 sets (J and K) of 8 3x3 morphology masks (structuring elements) - to implement thinning (medial axis transformation - MAT) + """ + build 2 sets (J and K) of 8 3x3 morphology masks (structuring elements) + to implement thinning (medial axis transformation - MAT) - MATFilter = build_morpho_thin_masks() + MATFilter = build_morpho_thin_masks() - Inputs: - None + Inputs: + None - Output: - MATFilter (a struct) + Output: + MATFilter (a struct) - """ + """ - # (layers, rows, cols) - shape = (8, 3, 3) - J_mask = N.zeros((shape), dtype=N.ushort) - K_mask = N.zeros((shape), dtype=N.ushort) + # (layers, rows, cols) + shape = (8, 3, 3) + J_mask = N.zeros((shape), dtype=N.ushort) + K_mask = N.zeros((shape), dtype=N.ushort) - # load the 8 J masks for medial axis transformation - J_mask[0][0][0] = 1; - J_mask[0][0][1] = 1; - J_mask[0][0][2] = 1; - J_mask[0][1][1] = 1; + # load the 8 J masks for medial axis transformation + J_mask[0][0][0] = 1; + J_mask[0][0][1] = 1; + J_mask[0][0][2] = 1; + J_mask[0][1][1] = 1; - J_mask[1][0][1] = 1; - J_mask[1][1][1] = 1; - J_mask[1][1][2] = 1; + J_mask[1][0][1] = 1; + J_mask[1][1][1] = 1; + J_mask[1][1][2] = 1; - J_mask[2][0][0] = 1; - J_mask[2][1][0] = 1; - J_mask[2][2][0] = 1; - J_mask[2][1][1] = 1; + J_mask[2][0][0] = 1; + J_mask[2][1][0] = 1; + J_mask[2][2][0] = 1; + J_mask[2][1][1] = 1; - J_mask[3][0][1] = 1; - J_mask[3][1][0] = 1; - J_mask[3][1][1] = 1; + J_mask[3][0][1] = 1; + J_mask[3][1][0] = 1; + J_mask[3][1][1] = 1; - J_mask[4][0][2] = 1; - J_mask[4][1][1] = 1; - J_mask[4][1][2] = 1; - J_mask[4][2][2] = 1; + J_mask[4][0][2] = 1; + J_mask[4][1][1] = 1; + J_mask[4][1][2] = 1; + J_mask[4][2][2] = 1; - J_mask[5][1][0] = 1; - J_mask[5][1][1] = 1; - J_mask[5][2][1] = 1; + J_mask[5][1][0] = 1; + J_mask[5][1][1] = 1; + J_mask[5][2][1] = 1; - J_mask[6][1][1] = 1; - J_mask[6][2][0] = 1; - J_mask[6][2][1] = 1; - J_mask[6][2][2] = 1; + J_mask[6][1][1] = 1; + J_mask[6][2][0] = 1; + J_mask[6][2][1] = 1; + J_mask[6][2][2] = 1; - J_mask[7][1][1] = 1; - J_mask[7][1][2] = 1; - J_mask[7][2][1] = 1; + J_mask[7][1][1] = 1; + J_mask[7][1][2] = 1; + J_mask[7][2][1] = 1; - # load the 8 K masks for medial axis transformation - K_mask[0][2][0] = 1; - K_mask[0][2][1] = 1; - K_mask[0][2][2] = 1; + # load the 8 K masks for medial axis transformation + K_mask[0][2][0] = 1; + K_mask[0][2][1] = 1; + K_mask[0][2][2] = 1; - K_mask[1][1][0] = 1; - K_mask[1][2][0] = 1; - K_mask[1][2][1] = 1; + K_mask[1][1][0] = 1; + K_mask[1][2][0] = 1; + K_mask[1][2][1] = 1; - K_mask[2][0][2] = 1; - K_mask[2][1][2] = 1; - K_mask[2][2][2] = 1; + K_mask[2][0][2] = 1; + K_mask[2][1][2] = 1; + K_mask[2][2][2] = 1; - K_mask[3][1][2] = 1; - K_mask[3][2][1] = 1; - K_mask[3][2][2] = 1; + K_mask[3][1][2] = 1; + K_mask[3][2][1] = 1; + K_mask[3][2][2] = 1; - K_mask[4][0][0] = 1; - K_mask[4][1][0] = 1; - K_mask[4][2][0] = 1; + K_mask[4][0][0] = 1; + K_mask[4][1][0] = 1; + K_mask[4][2][0] = 1; - K_mask[5][0][1] = 1; - K_mask[5][0][2] = 1; - K_mask[5][1][2] = 1; + K_mask[5][0][1] = 1; + K_mask[5][0][2] = 1; + K_mask[5][1][2] = 1; - K_mask[6][0][0] = 1; - K_mask[6][0][1] = 1; - K_mask[6][0][2] = 1; + K_mask[6][0][0] = 1; + K_mask[6][0][1] = 1; + K_mask[6][0][2] = 1; - K_mask[7][0][0] = 1; - K_mask[7][0][1] = 1; - K_mask[7][1][0] = 1; + K_mask[7][0][0] = 1; + K_mask[7][0][1] = 1; + K_mask[7][1][0] = 1; - MATFilter = {'number3x3Masks' : 8, 'jmask' : J_mask, 'kmask' : K_mask} + MATFilter = {'number3x3Masks' : 8, 'jmask' : J_mask, 'kmask' : K_mask} - return MATFilter + return MATFilter Modified: trunk/scipy/ndimage/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/tests/test_segment.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/ndimage/tests/test_segment.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -10,132 +10,132 @@ def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def get_shape_mask(labeledEdges, ROIList): - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return def get_voxel_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return def get_texture_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return def segment_regions(): - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList def grow_regions(): - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - slice[505:512,:] = 0 - return slice + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) class TestSegment(NumpyTestCase): def test1(self): - image = get_slice(filename) - sourceImage = image.copy() - edges, objects = sobel(image) - get_shape_mask(edges, objects) - get_voxel_measures(sourceImage, edges, objects) - get_texture_measures(sourceImage, edges, objects) + image = get_slice(filename) + sourceImage = image.copy() + edges, objects = sobel(image) + get_shape_mask(edges, objects) + get_voxel_measures(sourceImage, edges, objects) + get_texture_measures(sourceImage, edges, objects) def test2(self): - sourceImage, labeledMask, ROIList = segment_regions() + sourceImage, labeledMask, ROIList = segment_regions() def test3(self): - regionMask, numberRegions = grow_regions() - print regionMask.max() - #save_slice(regionMask, 'regionMask.raw') + regionMask, numberRegions = grow_regions() + print regionMask.max() + #save_slice(regionMask, 'regionMask.raw') if __name__ == "__main__": Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -17,4 +17,3 @@ s = montecarlo.dictsampler(d) for i in range(10): temp = s.sample(10**7) - Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -8,4 +8,3 @@ s = montecarlo.dictsampler(d) for i in range(10): temp = s.sample(10**7) - Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -6,4 +6,3 @@ s = montecarlo.intsampler(v) for i in range(10): temp = s.sample(10**7) - Modified: trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py =================================================================== --- trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -6,4 +6,3 @@ s = montecarlo.intsampler(v) for i in range(10): temp = s.sample(10**7) - Modified: trunk/scipy/sandbox/multigrid/adaptive.py =================================================================== --- trunk/scipy/sandbox/multigrid/adaptive.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/multigrid/adaptive.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -139,8 +139,8 @@ max_levels = max_levels, \ max_coarse = max_coarse, \ mu = mu, epsilon = epsilon, \ - aggregation = aggregation ) - + aggregation = aggregation ) + #create SA using x here As,Ps,Ts,Bs = sa_hierarchy(A,x,AggOps) @@ -160,7 +160,7 @@ for i in range(max_candidates): B = B[:,1:] As,Ps,Ts,Bs = sa_hierarchy(A,B,AggOps) - x = self.__develop_new_candidate(As,Ps,Ts,Bs,AggOps,mu=mu) + x = self.__develop_new_candidate(As,Ps,Ts,Bs,AggOps,mu=mu) B = hstack((B,x)) As,Ps,Ts,Bs = sa_hierarchy(A,B,AggOps) @@ -174,7 +174,7 @@ max_coarse = 0 max_levels = len(aggregation) + 1 - # aSA parameters + # aSA parameters # mu - number of test relaxation iterations # epsilon - minimum acceptable relaxation convergence factor @@ -307,7 +307,7 @@ aggregation = None #A = poisson_problem2D(200,1e-2) - #aggregation = [ sa_constant_interpolation(A*A*A,epsilon=0.0) ] + #aggregation = [ sa_constant_interpolation(A*A*A,epsilon=0.0) ] #A = io.mmread("tests/sample_data/laplacian_41_3dcube.mtx").tocsr() #A = io.mmread("laplacian_40_3dcube.mtx").tocsr() @@ -373,7 +373,7 @@ pcolor(x.reshape(sqrt(len(x)),sqrt(len(x)))) show() - + for c in asa.Bs[0].T: #plot2d(c) plot2d_arrows(c) Modified: trunk/scipy/sandbox/multigrid/dec_test.py =================================================================== --- trunk/scipy/sandbox/multigrid/dec_test.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/multigrid/dec_test.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -30,10 +30,10 @@ def curl_curl_prolongator(D_nodal,vertices): if not isspmatrix_csr(D_nodal): raise TypeError('expected csr_matrix') - + A = D_nodal.T.tocsr() * D_nodal aggs = multigridtools.sa_get_aggregates(A.shape[0],A.indptr,A.indices) - + num_edges = D_nodal.shape[0] num_basis = vertices.shape[1] num_aggs = aggs.max() + 1 @@ -52,9 +52,9 @@ return coo_matrix((data,(row,col)),dims=(num_edges,num_basis*num_aggs)).tocsr() - + def whitney_innerproduct_cache(cmplx,k): h = hash(cmplx.vertices.tostring()) ^ hash(cmplx.simplices.tostring()) ^ hash(k) @@ -102,33 +102,33 @@ Mi = whitney_innerproduct_cache(cmplx,i+1) else: Mi = regular_cube_innerproduct(cmplx,i+1) - - + + dimension = mesh['vertices'].shape[1] if True: - + d0 = cmplx[0].d d1 = cmplx[1].d - + #A = (d1.T.tocsr() * d1 + d0 * d0.T.tocsr()).astype('d') A = (d1.T.tocsr() * d1).astype('d') - + P = curl_curl_prolongator(d0,mesh['vertices']) - + num_blocks = P.shape[1]/dimension blocks = arange(num_blocks).repeat(dimension) - + P = sa_smoothed_prolongator(A,P,epsilon=0,omega=4.0/3.0) - + PAP = P.T.tocsr() * A * P - + candidates = None candidates = zeros((num_blocks,dimension,dimension)) for n in range(dimension): candidates[:,n,n] = 1.0 candidates = candidates.reshape(-1,dimension) - + ml = smoothed_aggregation_solver(PAP,epsilon=0.0,candidates=candidates,blocks=blocks) #A = PAP ml = multilevel_solver([A] + ml.As, [P] + ml.Ps) @@ -138,16 +138,16 @@ while len(bh) < 3: bh.coarsen() print repr(bh) - + N = len(cochain_complex) - 1 - + B = bh[0][N - i].B - + A = (B.T.tocsr() * B).astype('d') #A = B.T.tocsr() * Mi * B - + constant_prolongators = [lvl[N - i].I for lvl in bh[:-1]] - + method = 'aSA' if method == 'RS': @@ -157,28 +157,28 @@ Ps.append( sa_smoothed_prolongator(As[-1],T,epsilon=0.0,omega=4.0/3.0) ) As.append(Ps[-1].T.tocsr() * As[-1] * Ps[-1]) ml = multilevel_solver(As,Ps) - + else: if method == 'BSA': - if i == 0: + if i == 0: candidates = None else: candidates = cmplx[0].d * mesh['vertices'] K = candidates.shape[1] - + constant_prolongators = [constant_prolongators[0]] + \ [expand_into_blocks(T,K,1).tocsr() for T in constant_prolongators[1:] ] ml = smoothed_aggregation_solver(A,candidates,aggregation=constant_prolongators) elif method == 'aSA': - asa = adaptive_sa_solver(A,aggregation=constant_prolongators,max_candidates=dimension,epsilon=0.0) + asa = adaptive_sa_solver(A,aggregation=constant_prolongators,max_candidates=dimension,epsilon=0.0) ml = asa.solver else: raise ValuerError,'unknown method' - + #ml = smoothed_aggregation_solver(A,candidates) - #x = d0 * mesh['vertices'][:,0] + #x = d0 * mesh['vertices'][:,0] x = rand(A.shape[0]) b = zeros_like(x) #b = A*rand(A.shape[0]) Modified: trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py =================================================================== --- trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -53,85 +53,84 @@ F_NODE = _multigridtools.F_NODE def sa_get_aggregates(*args): - """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)""" - return _multigridtools.sa_get_aggregates(*args) + """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)""" + return _multigridtools.sa_get_aggregates(*args) def rs_strong_connections(*args): - """ - rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp, - std::vector<(int)> Sj, - std::vector<(float)> Sx) - rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(double)> Sx) """ - return _multigridtools.rs_strong_connections(*args) + rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp, + std::vector<(int)> Sj, + std::vector<(float)> Sx) + rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(double)> Sx) + """ + return _multigridtools.rs_strong_connections(*args) def rs_interpolation(*args): - """ - rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj, - float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj, - double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) """ - return _multigridtools.rs_interpolation(*args) + rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj, + float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj, + double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + """ + return _multigridtools.rs_interpolation(*args) def sa_strong_connections(*args): - """ - sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(float)> Sx) - sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(double)> Sx) """ - return _multigridtools.sa_strong_connections(*args) + sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(float)> Sx) + sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(double)> Sx) + """ + return _multigridtools.sa_strong_connections(*args) def sa_smoother(*args): - """ - sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp, - int Sj, float Sx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax, - int Sp, int Sj, double Sx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) """ - return _multigridtools.sa_smoother(*args) + sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp, + int Sj, float Sx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax, + int Sp, int Sj, double Sx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + """ + return _multigridtools.sa_smoother(*args) def gauss_seidel(*args): - """ - gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b, - int row_start, int row_stop, int row_step) - gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, - int row_start, int row_stop, int row_step) - gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax, - float x, float b, long long row_start, long long row_stop, - long long row_step) - gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax, - double x, double b, long long row_start, - long long row_stop, long long row_step) """ - return _multigridtools.gauss_seidel(*args) + gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b, + int row_start, int row_stop, int row_step) + gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, + int row_start, int row_stop, int row_step) + gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax, + float x, float b, long long row_start, long long row_stop, + long long row_step) + gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax, + double x, double b, long long row_start, + long long row_stop, long long row_step) + """ + return _multigridtools.gauss_seidel(*args) def jacobi(*args): - """ - jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, - float temp, int row_start, int row_stop, - int row_step, float omega) - jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, - double temp, int row_start, int row_stop, - int row_step, double omega) - jacobi(long long n_row, long long Ap, long long Aj, float Ax, - float x, float b, float temp, long long row_start, - long long row_stop, long long row_step, - float omega) - jacobi(long long n_row, long long Ap, long long Aj, double Ax, - double x, double b, double temp, long long row_start, - long long row_stop, long long row_step, - double omega) """ - return _multigridtools.jacobi(*args) - + jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, + float temp, int row_start, int row_stop, + int row_step, float omega) + jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, + double temp, int row_start, int row_stop, + int row_step, double omega) + jacobi(long long n_row, long long Ap, long long Aj, float Ax, + float x, float b, float temp, long long row_start, + long long row_stop, long long row_step, + float omega) + jacobi(long long n_row, long long Ap, long long Aj, double Ax, + double x, double b, double temp, long long row_start, + long long row_stop, long long row_step, + double omega) + """ + return _multigridtools.jacobi(*args) Modified: trunk/scipy/sandbox/multigrid/multilevel.py =================================================================== --- trunk/scipy/sandbox/multigrid/multilevel.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/multigrid/multilevel.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -43,7 +43,7 @@ References: "Multigrid" - Trottenberg, U., C. W. Oosterlee, and Anton Schuller. + Trottenberg, U., C. W. Oosterlee, and Anton Schuller. San Diego: Academic Press, 2001. Appendix A @@ -60,9 +60,9 @@ Ps.append(P) return multilevel_solver(As,Ps) - + def smoothed_aggregation_solver(A, B=None, blocks=None, \ aggregation=None, max_levels=10, \ max_coarse=500, epsilon=0.0, \ @@ -98,12 +98,12 @@ Strength of connection parameter used in aggregation. omega: {float} : default 4.0/3.0 Damping parameter used in prolongator smoothing (0 < omega < 2) - symmetric: {boolean} : default True + symmetric: {boolean} : default True True if A is symmetric, False otherwise rescale: {boolean} : default True If True, symmetrically rescale A by the diagonal i.e. A -> D * A * D, where D is diag(A)^-0.5 - + *Example*: TODO @@ -120,17 +120,17 @@ B = asarray(B) pre,post = None,None #preprocess/postprocess - + if rescale: D_sqrt,D_sqrt_inv,A = symmetric_rescaling(A) D_sqrt,D_sqrt_inv = diag_sparse(D_sqrt),diag_sparse(D_sqrt_inv) - + B = D_sqrt * B #scale candidates def pre(x,b): return D_sqrt*x,D_sqrt_inv*b def post(x): return D_sqrt_inv*x - + As = [A] Ps = [] Modified: trunk/scipy/sandbox/multigrid/tests/test_utils.py =================================================================== --- trunk/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -59,7 +59,7 @@ cases = [] cases.append( diag_sparse(array([1,2,3,4])) ) cases.append( diag_sparse(array([1,0,3,4])) ) - + A = array([ [ 5.5, 3.5, 4.8], [ 2. , 9.9, 0.5], [ 6.5, 2.6, 5.7]]) Modified: trunk/scipy/sandbox/multigrid/utils.py =================================================================== --- trunk/scipy/sandbox/multigrid/utils.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sandbox/multigrid/utils.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -61,11 +61,11 @@ D_sqrt = sqrt(D) D_sqrt_inv = 1.0/D_sqrt D_sqrt_inv[mask] = 0 - + #TODO time this against simple implementation data = A.data * D_sqrt_inv[A.indices] data *= D_sqrt_inv[arange(A.shape[0]).repeat(diff(A.indptr))] - + DAD = A.__class__((data,A.indices,A.indptr),dims=A.shape) return D_sqrt,D_sqrt_inv,DAD Modified: trunk/scipy/sparse/sparse.py =================================================================== --- trunk/scipy/sparse/sparse.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sparse/sparse.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -92,7 +92,7 @@ def set_shape(self,shape): shape = tuple(shape) - + if len(shape) != 2: raise ValueError("Only two-dimensional sparse arrays " "are supported.") @@ -103,7 +103,7 @@ if not (shape[0] >= 1 and shape[1] >= 1): raise TypeError,'invalid shape' - + if (self._shape != shape) and (self._shape is not None): try: self = self.reshape(shape) @@ -518,17 +518,17 @@ def _set_self(self, other, copy=False): """take the member variables of other and assign them to self""" - + if copy: other = other.copy() - + self.data = other.data self.indices = other.indices self.indptr = other.indptr self.shape = other.shape self.dtype = other.data.dtype - + def _check_format(self, orientation, full_check): # some functions pass floats self.shape = tuple([int(x) for x in self.shape]) @@ -988,14 +988,14 @@ self._set_self( other ) else: - raise ValueError, "unrecognized form for csc_matrix constructor" + raise ValueError, "unrecognized form for csc_matrix constructor" # Read matrix dimensions given, if any if dims is not None: self.shape = dims # spmatrix will check for errors else: - if self.shape is None: + if self.shape is None: # shape not already set, try to infer dimensions try: M = self.indices.max() + 1 @@ -1238,7 +1238,7 @@ if copy: arg1 = arg1.copy() self._set_self( self._tothis(arg1) ) - + elif isinstance(arg1, tuple): if isshape(arg1): # It's a tuple of matrix dimensions (M, N) @@ -1270,7 +1270,7 @@ other = coo_matrix((data, ij), dims=dims ) other = self._tothis(other) self._set_self( other ) - + else: raise ValueError, "unrecognized form for csr_matrix constructor" @@ -1278,7 +1278,7 @@ if dims is not None: self.shape = dims # spmatrix will check for errors else: - if self.shape is None: + if self.shape is None: # shape not already set, try to infer dimensions try: M = len(self.indptr) - 1 Modified: trunk/scipy/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/scipy/sparse/sparsetools/sparsetools.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/sparse/sparsetools/sparsetools.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -51,1609 +51,1608 @@ def extract_csr_diagonal(*args): - """ - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(signed char)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(unsigned char)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(long long)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(npy_cfloat_wrapper)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(npy_cdouble_wrapper)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(signed char)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(unsigned char)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(short)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(int)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(float)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(double)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.extract_csr_diagonal(*args) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(signed char)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(unsigned char)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(long long)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(npy_cfloat_wrapper)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(npy_cdouble_wrapper)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(signed char)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(unsigned char)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(short)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(int)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(float)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(double)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.extract_csr_diagonal(*args) def extract_csc_diagonal(*args): - """ - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(signed char)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(unsigned char)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(long long)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(npy_cfloat_wrapper)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(npy_cdouble_wrapper)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(signed char)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(unsigned char)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(short)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(int)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(float)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(double)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.extract_csc_diagonal(*args) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(signed char)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(unsigned char)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(long long)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(npy_cfloat_wrapper)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(npy_cdouble_wrapper)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(signed char)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(unsigned char)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(short)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(int)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(float)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(double)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.extract_csc_diagonal(*args) def csrtocsc(*args): - """ - csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(signed char)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(unsigned char)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(short)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(int)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long long)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(float)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(double)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(signed char)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(short)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(int)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(long long)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(float)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(double)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csrtocsc(*args) + csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(signed char)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(unsigned char)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(short)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(int)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long long)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(float)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(double)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(signed char)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(short)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(int)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(long long)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(float)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(double)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csrtocsc(*args) def csctocsr(*args): - """ - csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csctocsr(*args) + csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csctocsr(*args) def csrtocoo(*args): - """ - csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csrtocoo(*args) + csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csrtocoo(*args) def csctocoo(*args): - """ - csctocoo(int n_row, int n_col, int Ap, int Ai, signed char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, long long Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csctocoo(*args) + csctocoo(int n_row, int n_col, int Ap, int Ai, signed char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, long long Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csctocoo(*args) def cootocsr(*args): - """ - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(short)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(int)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(float)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(double)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(signed char)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(unsigned char)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(short)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(int)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(long long)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(float)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(double)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cfloat_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cdouble_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.cootocsr(*args) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(short)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(int)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(float)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(double)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(signed char)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(unsigned char)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(short)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(int)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(long long)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(float)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(double)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cfloat_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cdouble_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.cootocsr(*args) def cootocsc(*args): - """ - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(signed char)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(unsigned char)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(short)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(int)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long long)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(float)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(double)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(signed char)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(unsigned char)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(short)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(int)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(long long)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(float)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(double)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cfloat_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cdouble_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.cootocsc(*args) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(signed char)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(unsigned char)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(short)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(int)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long long)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(float)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(double)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(signed char)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(unsigned char)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(short)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(int)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(long long)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(float)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(double)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cfloat_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cdouble_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.cootocsc(*args) def csrmucsr(*args): - """ - csrmucsr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(signed char)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(int)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(double)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.csrmucsr(*args) + csrmucsr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(signed char)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(int)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(double)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.csrmucsr(*args) def cscmucsc(*args): - """ - cscmucsc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(signed char)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(int)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(double)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.cscmucsc(*args) + cscmucsc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(signed char)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(int)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(double)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.cscmucsc(*args) def csrmux(*args): - """ - csrmux(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx, std::vector<(signed char)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx, std::vector<(unsigned char)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, - std::vector<(short)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, - std::vector<(int)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx, std::vector<(long long)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, - std::vector<(float)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, - std::vector<(double)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, signed char Xx, std::vector<(signed char)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, unsigned char Xx, - std::vector<(unsigned char)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, short Xx, std::vector<(short)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, int Xx, std::vector<(int)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Xx, std::vector<(long long)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, float Xx, std::vector<(float)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, double Xx, std::vector<(double)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - std::vector<(npy_cfloat_wrapper)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.csrmux(*args) + csrmux(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx, std::vector<(signed char)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx, std::vector<(unsigned char)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, + std::vector<(short)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, + std::vector<(int)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx, std::vector<(long long)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, + std::vector<(float)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, + std::vector<(double)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, signed char Xx, std::vector<(signed char)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, unsigned char Xx, + std::vector<(unsigned char)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, short Xx, std::vector<(short)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, int Xx, std::vector<(int)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Xx, std::vector<(long long)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, float Xx, std::vector<(float)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, double Xx, std::vector<(double)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + std::vector<(npy_cfloat_wrapper)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.csrmux(*args) def cscmux(*args): - """ - cscmux(int n_row, int n_col, int Ap, int Ai, signed char Ax, - signed char Xx, std::vector<(signed char)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - unsigned char Xx, std::vector<(unsigned char)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, - std::vector<(short)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, - std::vector<(int)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, long long Ax, - long long Xx, std::vector<(long long)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, - std::vector<(float)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, - std::vector<(double)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, signed char Xx, std::vector<(signed char)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, unsigned char Xx, - std::vector<(unsigned char)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, short Xx, std::vector<(short)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, int Xx, std::vector<(int)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Xx, std::vector<(long long)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, float Xx, std::vector<(float)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, double Xx, std::vector<(double)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - std::vector<(npy_cfloat_wrapper)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.cscmux(*args) + cscmux(int n_row, int n_col, int Ap, int Ai, signed char Ax, + signed char Xx, std::vector<(signed char)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + unsigned char Xx, std::vector<(unsigned char)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, + std::vector<(short)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, + std::vector<(int)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, long long Ax, + long long Xx, std::vector<(long long)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, + std::vector<(float)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, + std::vector<(double)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, signed char Xx, std::vector<(signed char)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, unsigned char Xx, + std::vector<(unsigned char)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, short Xx, std::vector<(short)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, int Xx, std::vector<(int)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Xx, std::vector<(long long)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, float Xx, std::vector<(float)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, double Xx, std::vector<(double)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + std::vector<(npy_cfloat_wrapper)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.cscmux(*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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.csr_minus_csr(*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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.csc_minus_csc(*args) def spdiags(*args): - """ - spdiags(int n_row, int n_col, int n_diag, int offsets, signed char diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(signed char)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, unsigned char diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(unsigned char)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, short diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(short)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(int)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, long long diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(long long)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(float)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(double)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat_wrapper diags, - std::vector<(int)> Ap, - std::vector<(int)> Ai, std::vector<(npy_cfloat_wrapper)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble_wrapper diags, - std::vector<(int)> Ap, - std::vector<(int)> Ai, std::vector<(npy_cdouble_wrapper)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, signed char diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(signed char)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, unsigned char diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(unsigned char)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, short diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(short)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, int diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, std::vector<(int)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, long long diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(long long)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, float diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(float)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, double diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(double)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, npy_cfloat_wrapper diags, - std::vector<(long long)> Ap, std::vector<(long long)> Ai, - std::vector<(npy_cfloat_wrapper)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, npy_cdouble_wrapper diags, - std::vector<(long long)> Ap, std::vector<(long long)> Ai, - std::vector<(npy_cdouble_wrapper)> Ax) """ - return _sparsetools.spdiags(*args) + spdiags(int n_row, int n_col, int n_diag, int offsets, signed char diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(signed char)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, unsigned char diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(unsigned char)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, short diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(short)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(int)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, long long diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(long long)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(float)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(double)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat_wrapper diags, + std::vector<(int)> Ap, + std::vector<(int)> Ai, std::vector<(npy_cfloat_wrapper)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble_wrapper diags, + std::vector<(int)> Ap, + std::vector<(int)> Ai, std::vector<(npy_cdouble_wrapper)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, signed char diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(signed char)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, unsigned char diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(unsigned char)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, short diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(short)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, int diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, std::vector<(int)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, long long diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(long long)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, float diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(float)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, double diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(double)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, npy_cfloat_wrapper diags, + std::vector<(long long)> Ap, std::vector<(long long)> Ai, + std::vector<(npy_cfloat_wrapper)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, npy_cdouble_wrapper diags, + std::vector<(long long)> Ap, std::vector<(long long)> Ai, + std::vector<(npy_cdouble_wrapper)> Ax) + """ + return _sparsetools.spdiags(*args) def csrtodense(*args): - """ - csrtodense(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, short Ax, short Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, signed char Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, unsigned char Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, short Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, int Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, float Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, double Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Mx) """ - return _sparsetools.csrtodense(*args) + csrtodense(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, short Ax, short Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, signed char Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, unsigned char Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, short Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, int Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, float Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, double Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Mx) + """ + return _sparsetools.csrtodense(*args) def densetocsr(*args): - """ - densetocsr(int n_row, int n_col, signed char Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(signed char)> Ax) - densetocsr(int n_row, int n_col, unsigned char Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(unsigned char)> Ax) - densetocsr(int n_row, int n_col, short Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(short)> Ax) - densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(int)> Ax) - densetocsr(int n_row, int n_col, long long Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(long long)> Ax) - densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(float)> Ax) - densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(double)> Ax) - densetocsr(int n_row, int n_col, npy_cfloat_wrapper Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_cfloat_wrapper)> Ax) - densetocsr(int n_row, int n_col, npy_cdouble_wrapper Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_cdouble_wrapper)> Ax) - densetocsr(long long n_row, long long n_col, signed char Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(signed char)> Ax) - densetocsr(long long n_row, long long n_col, unsigned char Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(unsigned char)> Ax) - densetocsr(long long n_row, long long n_col, short Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(short)> Ax) - densetocsr(long long n_row, long long n_col, int Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(int)> Ax) - densetocsr(long long n_row, long long n_col, long long Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(long long)> Ax) - densetocsr(long long n_row, long long n_col, float Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(float)> Ax) - densetocsr(long long n_row, long long n_col, double Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(double)> Ax) - densetocsr(long long n_row, long long n_col, npy_cfloat_wrapper Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(npy_cfloat_wrapper)> Ax) - densetocsr(long long n_row, long long n_col, npy_cdouble_wrapper Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(npy_cdouble_wrapper)> Ax) """ - return _sparsetools.densetocsr(*args) + densetocsr(int n_row, int n_col, signed char Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(signed char)> Ax) + densetocsr(int n_row, int n_col, unsigned char Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(unsigned char)> Ax) + densetocsr(int n_row, int n_col, short Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(short)> Ax) + densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(int)> Ax) + densetocsr(int n_row, int n_col, long long Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(long long)> Ax) + densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(float)> Ax) + densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(double)> Ax) + densetocsr(int n_row, int n_col, npy_cfloat_wrapper Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cfloat_wrapper)> Ax) + densetocsr(int n_row, int n_col, npy_cdouble_wrapper Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cdouble_wrapper)> Ax) + densetocsr(long long n_row, long long n_col, signed char Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(signed char)> Ax) + densetocsr(long long n_row, long long n_col, unsigned char Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(unsigned char)> Ax) + densetocsr(long long n_row, long long n_col, short Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(short)> Ax) + densetocsr(long long n_row, long long n_col, int Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(int)> Ax) + densetocsr(long long n_row, long long n_col, long long Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(long long)> Ax) + densetocsr(long long n_row, long long n_col, float Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(float)> Ax) + densetocsr(long long n_row, long long n_col, double Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(double)> Ax) + densetocsr(long long n_row, long long n_col, npy_cfloat_wrapper Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(npy_cfloat_wrapper)> Ax) + densetocsr(long long n_row, long long n_col, npy_cdouble_wrapper Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(npy_cdouble_wrapper)> Ax) + """ + return _sparsetools.densetocsr(*args) def sort_csr_indices(*args): - """ - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, signed char Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, short Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, int Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, long long Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, float Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, double Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sort_csr_indices(*args) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, signed char Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, short Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, int Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, long long Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, float Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, double Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sort_csr_indices(*args) def sort_csc_indices(*args): - """ - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, signed char Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, short Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, int Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, long long Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, float Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, double Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sort_csc_indices(*args) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, signed char Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, short Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, int Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, long long Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, float Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, double Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sort_csc_indices(*args) def sum_csr_duplicates(*args): - """ - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sum_csr_duplicates(*args) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sum_csr_duplicates(*args) def sum_csc_duplicates(*args): - """ - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, signed char Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, short Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, int Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, long long Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, float Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, double Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sum_csc_duplicates(*args) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, signed char Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, short Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, int Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, long long Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, float Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, double Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sum_csc_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, 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, 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, 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, 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(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(signed char)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(unsigned char)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(short)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(int)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(long long)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(float)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(double)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long ir0, - long long ir1, long long ic0, long long ic1, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long ir0, - long long ir1, long long ic0, long long ic1, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.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, 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, 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, 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, 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(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(signed char)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(unsigned char)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(short)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(int)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(long long)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(float)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(double)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long ir0, + long long ir1, long long ic0, long long ic1, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long ir0, + long long ir1, long long ic0, long long ic1, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.get_csr_submatrix(*args) Modified: trunk/scipy/stats/models/robust/scale.py =================================================================== --- trunk/scipy/stats/models/robust/scale.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/scipy/stats/models/robust/scale.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -49,7 +49,7 @@ tmp = 2 * norm.cdf(c) - 1 gamma = tmp + c**2 * (1 - tmp) - 2 * c * norm.pdf(c) - del tmp + del tmp niter = 30 Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2007-11-17 01:15:06 UTC (rev 3547) +++ trunk/setup.py 2007-11-19 04:13:22 UTC (rev 3548) @@ -44,19 +44,19 @@ os.environ['NO_SCIPY_IMPORT']='SciPy/setup.py' def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration(None, parent_package, top_path) - config.set_options(ignore_setup_xxx_py=True, - assume_default_configuration=True, - delegate_options_to_subpackages=True, - quiet=True) + from numpy.distutils.misc_util import Configuration + config = Configuration(None, parent_package, top_path) + config.set_options(ignore_setup_xxx_py=True, + assume_default_configuration=True, + delegate_options_to_subpackages=True, + quiet=True) - config.add_subpackage('scipy') - config.add_data_files(('scipy','*.txt')) + config.add_subpackage('scipy') + config.add_data_files(('scipy','*.txt')) - config.get_version('scipy/version.py') # sets config.version + config.get_version('scipy/version.py') # sets config.version - return config + return config def setup_package(): From scipy-svn at scipy.org Mon Nov 19 03:23:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 19 Nov 2007 02:23:16 -0600 (CST) Subject: [Scipy-svn] r3549 - branches/scipy.scons Message-ID: <20071119082316.9C4C839C0D1@new.scipy.org> Author: cdavid Date: 2007-11-19 02:23:06 -0600 (Mon, 19 Nov 2007) New Revision: 3549 Modified: branches/scipy.scons/setupscons.py Log: Properly call setupscons instead of setup for scons build Modified: branches/scipy.scons/setupscons.py =================================================================== --- branches/scipy.scons/setupscons.py 2007-11-19 04:13:22 UTC (rev 3548) +++ branches/scipy.scons/setupscons.py 2007-11-19 08:23:06 UTC (rev 3549) @@ -43,9 +43,9 @@ os.environ['NO_SCIPY_IMPORT']='SciPy/setup.py' -def configuration(parent_package='',top_path=None, setup_name = 'setupscons.py'): +def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration(None, parent_package, top_path) + config = Configuration(None, parent_package, top_path, setup_name = 'setupscons.py') config.set_options(ignore_setup_xxx_py=True, assume_default_configuration=True, delegate_options_to_subpackages=True, From scipy-svn at scipy.org Mon Nov 19 05:21:37 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 19 Nov 2007 04:21:37 -0600 (CST) Subject: [Scipy-svn] r3550 - branches/scipy.scons/scipy/linalg Message-ID: <20071119102137.8C85D39C02E@new.scipy.org> Author: cdavid Date: 2007-11-19 04:21:31 -0600 (Mon, 19 Nov 2007) New Revision: 3550 Modified: branches/scipy.scons/scipy/linalg/SConstruct branches/scipy.scons/scipy/linalg/setup.py Log: fblas/cblas now build correctly with scons (but not flapack) Modified: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-19 08:23:06 UTC (rev 3549) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-19 10:21:31 UTC (rev 3550) @@ -1,4 +1,4 @@ -# Last Change: Fri Nov 16 09:00 PM 2007 J +# Last Change: Mon Nov 19 07:00 PM 2007 J # vim:syntax=python #import os @@ -71,87 +71,15 @@ #========== # Build #========== -#atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \ -# if k=='ATLAS_INFO']+[None])[0] -#if atlas_version: -# print 'ATLAS version',atlas_version -target_dir = '' -skip_names = {'clapack':[],'flapack':[],'cblas':[],'fblas':[]} -if skip_single_routines: - target_dir = 'dbl' - skip_names['clapack'].extend(\ - 'sgesv cgesv sgetrf cgetrf sgetrs cgetrs sgetri cgetri'\ - ' sposv cposv spotrf cpotrf spotrs cpotrs spotri cpotri'\ - ' slauum clauum strtri ctrtri'.split()) - skip_names['flapack'].extend(skip_names['clapack']) - skip_names['flapack'].extend(\ - 'sgesdd cgesdd sgelss cgelss sgeqrf cgeqrf sgeev cgeev'\ - ' sgegv cgegv ssyev cheev slaswp claswp sgees cgees' - ' sggev cggev'.split()) - skip_names['cblas'].extend('saxpy caxpy'.split()) - skip_names['fblas'].extend(skip_names['cblas']) - skip_names['fblas'].extend(\ - 'srotg crotg srotmg srot csrot srotm sswap cswap sscal cscal'\ - ' csscal scopy ccopy sdot cdotu cdotc snrm2 scnrm2 sasum scasum'\ - ' isamax icamax sgemv cgemv chemv ssymv strmv ctrmv'\ - ' sgemm cgemm'.split()) - -if using_lapack_blas: - target_dir = join(target_dir,'blas') - skip_names['fblas'].extend(\ - 'drotmg srotmg drotm srotm'.split()) - -#if atlas_version=='3.2.1_pre3.3.6': -# target_dir = join(target_dir,'atlas321') -# skip_names['clapack'].extend(\ -# 'sgetri dgetri cgetri zgetri spotri dpotri cpotri zpotri'\ -# ' slauum dlauum clauum zlauum strtri dtrtri ctrtri ztrtri'.split()) -#elif atlas_version>'3.4.0' and atlas_version<='3.5.12': -# skip_names['clapack'].extend('cpotrf zpotrf'.split()) - -def generate_pyf(target, source, env): - target = join(build_dir,target_dir,name+'.pyf') - if name[0]=='c' and atlas_version is None and newer(__file__,target): - print "============ %s =============" % target - f = open(target,'w') - f.write('python module '+name+'\n') - f.write('usercode void empty_module(void) {}\n') - f.write('interface\n') - f.write('subroutine empty_module()\n') - f.write('intent(c) empty_module\n') - f.write('end subroutine empty_module\n') - f.write('end interface\nend python module'+name+'\n') - f.close() - return target - if newer_group(extension.depends,target): - print name, extension.depend[0], target - raise "YATA:" - generate_interface(name, - extension.depends[0], - target, - skip_names[name]) - return target - -#------------- -# Build fblas: -#------------- # XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) import os -from os.path import join +from os.path import join as pjoin from interface_gen import generate_interface -src_files = ['generic_fblas.pyf', - 'generic_fblas1.pyf', - 'generic_fblas2.pyf', - 'generic_fblas3.pyf', - 'interface_gen.py', - join('src','fblaswrap_veclib_c.c'), - join('src','fblaswrap.f')] +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -# fblas: - def do_generate_interface(target, source, env): """Generate a .pyf file from another pyf file (!).""" # XXX: do this correctly @@ -164,14 +92,62 @@ return 0 def generate_interface_emitter(target, source, env): + source = [pjoin(env['build_dir'], str(i)) for i in source] + target = [pjoin(env['build_dir'], str(i)) for i in target] base = str(target[0]) return (['%s.pyf' % base], source) +def do_generate_fake_interface(target, source, env): + """Generate a (fake) .pyf file from another pyf file (!).""" + # XXX: do this correctly + target_name = str(target[0]) + source_name = str(source[0]) + + # XXX handle skip names + name = os.path.splitext(os.path.basename(target_name))[0] + generate_interface(name, source_name, target_name) + + f = open(target_name, 'w') + f.write('python module '+name+'\n') + f.write('usercode void empty_module(void) {}\n') + f.write('interface\n') + f.write('subroutine empty_module()\n') + f.write('intent(c) empty_module\n') + f.write('end subroutine empty_module\n') + f.write('end interface\nend python module'+name+'\n') + f.close() + + return 0 + env['BUILDERS']['haha'] = Builder(action = do_generate_interface, emitter = generate_interface_emitter) -env.haha('build/scons/fblas', 'generic_fblas.pyf') -env.NumpyPythonExtension('fblas', source = 'fblas.pyf') -#if has_cblas: -# env.haha('cblas', 'generic_cblas.pyf') -# env.NumpyPythonExtension('cblas', source = 'cblas.pyf') +env['BUILDERS']['hihi'] = Builder(action = do_generate_fake_interface, + emitter = generate_interface_emitter) + +# fblas: +# XXX: handle Accelerate problem +env.haha('fblas', 'generic_fblas.pyf') +env.NumpyPythonExtension('fblas', source = ['fblas.pyf', pjoin('src', 'fblaswrap.f')]) + +# cblas: +if has_cblas: + env.haha('cblas', 'generic_cblas.pyf') +else: + env.hihi('cblas', 'generic_cblas.pyf') +env.NumpyPythonExtension('cblas', source = 'cblas.pyf') + +# flapack +env.haha('flapack', 'generic_flapack.pyf') +env.NumpyPythonExtension('flapack', source = 'flapack.pyf') + +# # clapack +# if has_clapack: +# env.haha('build/scons/clapack', 'generic_clapack.pyf') +# else: +# env.hihi('build/scons/clapack', 'generic_clapack.pyf') +# env.NumpyPythonExtension('clapack', source = 'clapack.pyf') +# +# # _flinalg +# env.NumpyPythonExtension('_flinalg', source = [join('src', 'det.f'), +# join('src', 'lu.f')]) Modified: branches/scipy.scons/scipy/linalg/setup.py =================================================================== --- branches/scipy.scons/scipy/linalg/setup.py 2007-11-19 08:23:06 UTC (rev 3549) +++ branches/scipy.scons/scipy/linalg/setup.py 2007-11-19 10:21:31 UTC (rev 3550) @@ -125,30 +125,30 @@ join('src','fblaswrap.f'), ] - # fblas: - if needs_cblas_wrapper(lapack_opt): - config.add_extension('fblas', - sources = [generate_pyf, - join('src','fblaswrap_veclib_c.c')], - depends = depends, - extra_info = lapack_opt - ) - else: - config.add_extension('fblas', - sources = [generate_pyf, - join('src','fblaswrap.f')], - depends = depends, - extra_info = lapack_opt - ) + # # fblas: + # if needs_cblas_wrapper(lapack_opt): + # config.add_extension('fblas', + # sources = [generate_pyf, + # join('src','fblaswrap_veclib_c.c')], + # depends = depends, + # extra_info = lapack_opt + # ) + # else: + # config.add_extension('fblas', + # sources = [generate_pyf, + # join('src','fblaswrap.f')], + # depends = depends, + # extra_info = lapack_opt + # ) - # cblas: - config.add_extension('cblas', - sources = [generate_pyf], - depends = ['generic_cblas.pyf', - 'generic_cblas1.pyf', - 'interface_gen.py'], - extra_info = lapack_opt - ) + # # cblas: + # config.add_extension('cblas', + # sources = [generate_pyf], + # depends = ['generic_cblas.pyf', + # 'generic_cblas1.pyf', + # 'interface_gen.py'], + # extra_info = lapack_opt + # ) # flapack: config.add_extension('flapack', @@ -159,50 +159,50 @@ extra_info = lapack_opt ) - # clapack: - config.add_extension('clapack', - sources = [generate_pyf], - depends = ['generic_clapack.pyf', - 'interface_gen.py'], - extra_info = lapack_opt - ) + # # clapack: + # config.add_extension('clapack', + # sources = [generate_pyf], + # depends = ['generic_clapack.pyf', + # 'interface_gen.py'], + # extra_info = lapack_opt + # ) - # _flinalg: - config.add_extension('_flinalg', - sources = [join('src','det.f'),join('src','lu.f')], - extra_info = lapack_opt - ) + # # _flinalg: + # config.add_extension('_flinalg', + # sources = [join('src','det.f'),join('src','lu.f')], + # extra_info = lapack_opt + # ) - # calc_lwork: - config.add_extension('calc_lwork', - [join('src','calc_lwork.f')], - extra_info = lapack_opt - ) + # # calc_lwork: + # config.add_extension('calc_lwork', + # [join('src','calc_lwork.f')], + # extra_info = lapack_opt + # ) - # atlas_version: + # # atlas_version: - config.add_extension('atlas_version', - ['atlas_version.c'], - extra_info = lapack_opt - ) + # config.add_extension('atlas_version', + # ['atlas_version.c'], + # extra_info = lapack_opt + # ) - # iterative methods - methods = ['BiCGREVCOM.f.src', - 'BiCGSTABREVCOM.f.src', - 'CGREVCOM.f.src', - 'CGSREVCOM.f.src', -# 'ChebyREVCOM.f.src', - 'GMRESREVCOM.f.src', -# 'JacobiREVCOM.f.src', - 'QMRREVCOM.f.src', -# 'SORREVCOM.f.src' - ] - Util = ['STOPTEST2.f.src','getbreak.f.src'] - sources = Util + methods + ['_iterative.pyf.src'] - config.add_extension('_iterative', - sources = [join('iterative',x) for x in sources], - extra_info = lapack_opt - ) + # # iterative methods + # methods = ['BiCGREVCOM.f.src', + # 'BiCGSTABREVCOM.f.src', + # 'CGREVCOM.f.src', + # 'CGSREVCOM.f.src', +# # 'ChebyREVCOM.f.src', + # 'GMRESREVCOM.f.src', +# # 'JacobiREVCOM.f.src', + # 'QMRREVCOM.f.src', +# # 'SORREVCOM.f.src' + # ] + # Util = ['STOPTEST2.f.src','getbreak.f.src'] + # sources = Util + methods + ['_iterative.pyf.src'] + # config.add_extension('_iterative', + # sources = [join('iterative',x) for x in sources], + # extra_info = lapack_opt + # ) config.add_data_dir('tests') From scipy-svn at scipy.org Tue Nov 20 06:53:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Nov 2007 05:53:20 -0600 (CST) Subject: [Scipy-svn] r3551 - branches/scipy.scons/scipy/linalg Message-ID: <20071120115320.E284C39C1E2@new.scipy.org> Author: cdavid Date: 2007-11-20 05:53:08 -0600 (Tue, 20 Nov 2007) New Revision: 3551 Added: branches/scipy.scons/scipy/linalg/scons_support.py Modified: branches/scipy.scons/scipy/linalg/SConstruct branches/scipy.scons/scipy/linalg/setup.py Log: linalg now builds with scons, all tests at max level pass on Gnu + Atlas Modified: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-19 10:21:31 UTC (rev 3550) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-20 11:53:08 UTC (rev 3551) @@ -1,16 +1,17 @@ -# Last Change: Mon Nov 19 07:00 PM 2007 J +# Last Change: Tue Nov 20 08:00 PM 2007 J # vim:syntax=python -#import os -#import sys -#from os.path import join as pjoin, basename as pbasename, dirname as pdirname -#from copy import deepcopy - +import os +from os.path import join as pjoin, splitext + from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir from numpy.distutils.scons import GetNumpyEnvironment from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ CheckCLAPACK + +from scons_support import do_generate_interface, do_generate_fake_interface, \ + generate_interface_emitter #from numpy.distutils.scons.configuration import write_info #from scons_support import CheckBrokenMathlib, define_no_smp, \ @@ -73,81 +74,94 @@ #========== # XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) -import os -from os.path import join as pjoin - -from interface_gen import generate_interface - env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +env.AppendUnique(F2PYOPTIONS = '--quiet') -def do_generate_interface(target, source, env): - """Generate a .pyf file from another pyf file (!).""" - # XXX: do this correctly - target_name = str(target[0]) - source_name = str(source[0]) - - # XXX handle skip names - name = os.path.splitext(os.path.basename(target_name))[0] - generate_interface(name, source_name, target_name) - return 0 - -def generate_interface_emitter(target, source, env): - source = [pjoin(env['build_dir'], str(i)) for i in source] - target = [pjoin(env['build_dir'], str(i)) for i in target] - base = str(target[0]) - return (['%s.pyf' % base], source) - -def do_generate_fake_interface(target, source, env): - """Generate a (fake) .pyf file from another pyf file (!).""" - # XXX: do this correctly - target_name = str(target[0]) - source_name = str(source[0]) - - # XXX handle skip names - name = os.path.splitext(os.path.basename(target_name))[0] - generate_interface(name, source_name, target_name) - - f = open(target_name, 'w') - f.write('python module '+name+'\n') - f.write('usercode void empty_module(void) {}\n') - f.write('interface\n') - f.write('subroutine empty_module()\n') - f.write('intent(c) empty_module\n') - f.write('end subroutine empty_module\n') - f.write('end interface\nend python module'+name+'\n') - f.close() - - return 0 - env['BUILDERS']['haha'] = Builder(action = do_generate_interface, emitter = generate_interface_emitter) env['BUILDERS']['hihi'] = Builder(action = do_generate_fake_interface, emitter = generate_interface_emitter) -# fblas: +#------------ +# fblas +#------------ # XXX: handle Accelerate problem env.haha('fblas', 'generic_fblas.pyf') env.NumpyPythonExtension('fblas', source = ['fblas.pyf', pjoin('src', 'fblaswrap.f')]) -# cblas: +#------------ +# cblas +#------------ if has_cblas: env.haha('cblas', 'generic_cblas.pyf') else: env.hihi('cblas', 'generic_cblas.pyf') env.NumpyPythonExtension('cblas', source = 'cblas.pyf') -# flapack -env.haha('flapack', 'generic_flapack.pyf') -env.NumpyPythonExtension('flapack', source = 'flapack.pyf') +#------------ +# flapack +#------------ +yop = env.haha('flapack', 'generic_flapack.pyf') +# XXX: automatically scan dependency on flapack_user_routines.pyf ? +env.Depends(yop, pjoin(env['build_dir'], 'flapack_user_routines.pyf')) +env.NumpyPythonExtension('flapack', source = ['flapack.pyf']) -# # clapack -# if has_clapack: -# env.haha('build/scons/clapack', 'generic_clapack.pyf') -# else: -# env.hihi('build/scons/clapack', 'generic_clapack.pyf') -# env.NumpyPythonExtension('clapack', source = 'clapack.pyf') -# -# # _flinalg -# env.NumpyPythonExtension('_flinalg', source = [join('src', 'det.f'), -# join('src', 'lu.f')]) +#------------ +# clapack +#------------ +if has_clapack: + env.haha('clapack', 'generic_clapack.pyf') +else: + env.hihi('clapack', 'generic_clapack.pyf') +env.NumpyPythonExtension('clapack', source = 'clapack.pyf') + +#---------------- +# _flinalg +#---------------- +_flinalg_fsrc = ['det.f', 'lu.f'] +_flinalg_src = env.F2PY( + pjoin(env['build_dir'], 'src', '_flinalgmodule.c'), + source = [pjoin(env['build_dir'], 'src', i) for i in _flinalg_fsrc]) + +env.NumpyPythonExtension( + '_flinalg', source = _flinalg_src + [pjoin('src', i) for i in _flinalg_fsrc]) + +#---------------- +# calc_lwork: +#---------------- +calc_src = env.F2PY(pjoin(env['build_dir'], 'src', 'calc_lworkmodule.c'), + source = pjoin(env['build_dir'], 'src', 'calc_lwork.f')) +env.NumpyPythonExtension('calc_lwork', + source = calc_src + [pjoin('src', 'calc_lwork.f')]) + +#-------------------- +# iterative methods +#-------------------- +methods = ['BiCGREVCOM.f.src', + 'BiCGSTABREVCOM.f.src', + 'CGREVCOM.f.src', + 'CGSREVCOM.f.src', +# 'ChebyREVCOM.f.src', + 'GMRESREVCOM.f.src', +# 'JacobiREVCOM.f.src', + 'QMRREVCOM.f.src', +# 'SORREVCOM.f.src' + ] +Util = ['STOPTEST2.f.src','getbreak.f.src'] +raw_sources = methods + Util + ['_iterative.pyf.src'] + +sources = [] +for method in raw_sources: + target = splitext(method)[0] + res = env.NumpyFromFTemplate(target, pjoin('iterative', method)) + sources.append(res[0]) + +env.NumpyPythonExtension('_iterative', source = sources) + +#-------------- +# Atlas version +#-------------- +atlas_env = env.Copy() +atlas_env.AppendUnique(CPPDEFINES = "NO_ATLAS_INFO") +atlas_env.NumpyPythonExtension('atlas_version', 'atlas_version.c') Added: branches/scipy.scons/scipy/linalg/scons_support.py =================================================================== --- branches/scipy.scons/scipy/linalg/scons_support.py 2007-11-19 10:21:31 UTC (rev 3550) +++ branches/scipy.scons/scipy/linalg/scons_support.py 2007-11-20 11:53:08 UTC (rev 3551) @@ -0,0 +1,43 @@ +from os.path import join as pjoin, splitext, basename as pbasename + +from interface_gen import generate_interface + +def do_generate_interface(target, source, env): + """Generate a .pyf file from another pyf file (!).""" + # XXX: do this correctly + target_name = str(target[0]) + source_name = str(source[0]) + + # XXX handle skip names + name = splitext(pbasename(target_name))[0] + generate_interface(name, source_name, target_name) + return 0 + +def generate_interface_emitter(target, source, env): + source = [pjoin(env['build_dir'], str(i)) for i in source] + target = [pjoin(env['build_dir'], str(i)) for i in target] + base = str(target[0]) + return (['%s.pyf' % base], source) + +def do_generate_fake_interface(target, source, env): + """Generate a (fake) .pyf file from another pyf file (!).""" + # XXX: do this correctly + target_name = str(target[0]) + source_name = str(source[0]) + + # XXX handle skip names + name = splitext(pbasename(target_name))[0] + generate_interface(name, source_name, target_name) + + f = open(target_name, 'w') + f.write('python module '+name+'\n') + f.write('usercode void empty_module(void) {}\n') + f.write('interface\n') + f.write('subroutine empty_module()\n') + f.write('intent(c) empty_module\n') + f.write('end subroutine empty_module\n') + f.write('end interface\nend python module'+name+'\n') + f.close() + + return 0 + Modified: branches/scipy.scons/scipy/linalg/setup.py =================================================================== --- branches/scipy.scons/scipy/linalg/setup.py 2007-11-19 10:21:31 UTC (rev 3550) +++ branches/scipy.scons/scipy/linalg/setup.py 2007-11-20 11:53:08 UTC (rev 3551) @@ -150,14 +150,14 @@ # extra_info = lapack_opt # ) - # flapack: - config.add_extension('flapack', - sources = [generate_pyf], - depends = ['generic_flapack.pyf', - 'flapack_user_routines.pyf', - 'interface_gen.py'], - extra_info = lapack_opt - ) + # # flapack: + # config.add_extension('flapack', + # sources = [generate_pyf], + # depends = ['generic_flapack.pyf', + # 'flapack_user_routines.pyf', + # 'interface_gen.py'], + # extra_info = lapack_opt + # ) # # clapack: # config.add_extension('clapack', @@ -173,11 +173,11 @@ # extra_info = lapack_opt # ) - # # calc_lwork: - # config.add_extension('calc_lwork', - # [join('src','calc_lwork.f')], - # extra_info = lapack_opt - # ) + # calc_lwork: + config.add_extension('calc_lwork', + [join('src','calc_lwork.f')], + extra_info = lapack_opt + ) # # atlas_version: @@ -186,23 +186,23 @@ # extra_info = lapack_opt # ) - # # iterative methods - # methods = ['BiCGREVCOM.f.src', - # 'BiCGSTABREVCOM.f.src', - # 'CGREVCOM.f.src', - # 'CGSREVCOM.f.src', -# # 'ChebyREVCOM.f.src', - # 'GMRESREVCOM.f.src', -# # 'JacobiREVCOM.f.src', - # 'QMRREVCOM.f.src', -# # 'SORREVCOM.f.src' - # ] - # Util = ['STOPTEST2.f.src','getbreak.f.src'] - # sources = Util + methods + ['_iterative.pyf.src'] - # config.add_extension('_iterative', - # sources = [join('iterative',x) for x in sources], - # extra_info = lapack_opt - # ) +# # iterative methods +# methods = ['BiCGREVCOM.f.src', +# 'BiCGSTABREVCOM.f.src', +# 'CGREVCOM.f.src', +# 'CGSREVCOM.f.src', +# # 'ChebyREVCOM.f.src', +# 'GMRESREVCOM.f.src', +# # 'JacobiREVCOM.f.src', +# 'QMRREVCOM.f.src', +# # 'SORREVCOM.f.src' +# ] +# Util = ['STOPTEST2.f.src','getbreak.f.src'] +# sources = Util + methods + ['_iterative.pyf.src'] +# config.add_extension('_iterative', +# sources = [join('iterative',x) for x in sources], +# extra_info = lapack_opt +# ) config.add_data_dir('tests') From scipy-svn at scipy.org Tue Nov 20 07:04:25 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Nov 2007 06:04:25 -0600 (CST) Subject: [Scipy-svn] r3552 - branches/scipy.scons/scipy/linalg Message-ID: <20071120120425.D315439C1E2@new.scipy.org> Author: cdavid Date: 2007-11-20 06:04:20 -0600 (Tue, 20 Nov 2007) New Revision: 3552 Modified: branches/scipy.scons/scipy/linalg/setup.py Log: Revert setup.py, whose diff were commited by accident Modified: branches/scipy.scons/scipy/linalg/setup.py =================================================================== --- branches/scipy.scons/scipy/linalg/setup.py 2007-11-20 11:53:08 UTC (rev 3551) +++ branches/scipy.scons/scipy/linalg/setup.py 2007-11-20 12:04:20 UTC (rev 3552) @@ -125,53 +125,53 @@ join('src','fblaswrap.f'), ] - # # fblas: - # if needs_cblas_wrapper(lapack_opt): - # config.add_extension('fblas', - # sources = [generate_pyf, - # join('src','fblaswrap_veclib_c.c')], - # depends = depends, - # extra_info = lapack_opt - # ) - # else: - # config.add_extension('fblas', - # sources = [generate_pyf, - # join('src','fblaswrap.f')], - # depends = depends, - # extra_info = lapack_opt - # ) + # fblas: + if needs_cblas_wrapper(lapack_opt): + config.add_extension('fblas', + sources = [generate_pyf, + join('src','fblaswrap_veclib_c.c')], + depends = depends, + extra_info = lapack_opt + ) + else: + config.add_extension('fblas', + sources = [generate_pyf, + join('src','fblaswrap.f')], + depends = depends, + extra_info = lapack_opt + ) - # # cblas: - # config.add_extension('cblas', - # sources = [generate_pyf], - # depends = ['generic_cblas.pyf', - # 'generic_cblas1.pyf', - # 'interface_gen.py'], - # extra_info = lapack_opt - # ) + # cblas: + config.add_extension('cblas', + sources = [generate_pyf], + depends = ['generic_cblas.pyf', + 'generic_cblas1.pyf', + 'interface_gen.py'], + extra_info = lapack_opt + ) - # # flapack: - # config.add_extension('flapack', - # sources = [generate_pyf], - # depends = ['generic_flapack.pyf', - # 'flapack_user_routines.pyf', - # 'interface_gen.py'], - # extra_info = lapack_opt - # ) + # flapack: + config.add_extension('flapack', + sources = [generate_pyf], + depends = ['generic_flapack.pyf', + 'flapack_user_routines.pyf', + 'interface_gen.py'], + extra_info = lapack_opt + ) - # # clapack: - # config.add_extension('clapack', - # sources = [generate_pyf], - # depends = ['generic_clapack.pyf', - # 'interface_gen.py'], - # extra_info = lapack_opt - # ) + # clapack: + config.add_extension('clapack', + sources = [generate_pyf], + depends = ['generic_clapack.pyf', + 'interface_gen.py'], + extra_info = lapack_opt + ) - # # _flinalg: - # config.add_extension('_flinalg', - # sources = [join('src','det.f'),join('src','lu.f')], - # extra_info = lapack_opt - # ) + # _flinalg: + config.add_extension('_flinalg', + sources = [join('src','det.f'),join('src','lu.f')], + extra_info = lapack_opt + ) # calc_lwork: config.add_extension('calc_lwork', @@ -179,30 +179,30 @@ extra_info = lapack_opt ) - # # atlas_version: + # atlas_version: - # config.add_extension('atlas_version', - # ['atlas_version.c'], - # extra_info = lapack_opt - # ) + config.add_extension('atlas_version', + ['atlas_version.c'], + extra_info = lapack_opt + ) -# # iterative methods -# methods = ['BiCGREVCOM.f.src', -# 'BiCGSTABREVCOM.f.src', -# 'CGREVCOM.f.src', -# 'CGSREVCOM.f.src', -# # 'ChebyREVCOM.f.src', -# 'GMRESREVCOM.f.src', -# # 'JacobiREVCOM.f.src', -# 'QMRREVCOM.f.src', -# # 'SORREVCOM.f.src' -# ] -# Util = ['STOPTEST2.f.src','getbreak.f.src'] -# sources = Util + methods + ['_iterative.pyf.src'] -# config.add_extension('_iterative', -# sources = [join('iterative',x) for x in sources], -# extra_info = lapack_opt -# ) + # iterative methods + methods = ['BiCGREVCOM.f.src', + 'BiCGSTABREVCOM.f.src', + 'CGREVCOM.f.src', + 'CGSREVCOM.f.src', +# 'ChebyREVCOM.f.src', + 'GMRESREVCOM.f.src', +# 'JacobiREVCOM.f.src', + 'QMRREVCOM.f.src', +# 'SORREVCOM.f.src' + ] + Util = ['STOPTEST2.f.src','getbreak.f.src'] + sources = Util + methods + ['_iterative.pyf.src'] + config.add_extension('_iterative', + sources = [join('iterative',x) for x in sources], + extra_info = lapack_opt + ) config.add_data_dir('tests') From scipy-svn at scipy.org Tue Nov 20 09:28:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Nov 2007 08:28:34 -0600 (CST) Subject: [Scipy-svn] r3553 - trunk/scipy/linsolve/umfpack Message-ID: <20071120142834.B820C39C0CC@new.scipy.org> Author: rc Date: 2007-11-20 08:28:31 -0600 (Tue, 20 Nov 2007) New Revision: 3553 Modified: trunk/scipy/linsolve/umfpack/info.py Log: Edited module docstring. Modified: trunk/scipy/linsolve/umfpack/info.py =================================================================== --- trunk/scipy/linsolve/umfpack/info.py 2007-11-20 12:04:20 UTC (rev 3552) +++ trunk/scipy/linsolve/umfpack/info.py 2007-11-20 14:28:31 UTC (rev 3553) @@ -2,6 +2,10 @@ Interface to the UMFPACK library. ================================= +:Contains: UmfpackContext class + +:Description: +------------- Routines for symbolic and numeric LU factorization of sparse matrices and for solving systems of linear equations with sparse matrices. @@ -9,13 +13,12 @@ Copyright (c) 2005 by Timothy A. Davis. All Rights Reserved. UMFPACK homepage: http://www.cise.ufl.edu/research/sparse/umfpack -Contains: UmfpackContext class - Use 'print UmfpackContext().funs' to see all UMFPACK library functions the module exposes, if you need something not covered by the examples below. -Installation: -============= +:Installation: +-------------- + Example site.cfg entry: UMFPACK v4.4 in : @@ -43,8 +46,8 @@ umfpack_libs = umfpack -Examples: -========= +:Examples: +---------- Assuming this module imported as um (import scipy.linsolve.umfpack as um) @@ -115,8 +118,8 @@ LU = PRAQ when do_recip is true LU = P(R^-1)AQ when do_recip is false -Description of arguments of UmfpackContext solution methods: -============================================= +:Arguments of UmfpackContext solution methods: +---------------------------------------------- This holds for: umfpack(), umfpack.linsolve(), umfpack.solve() sys - one of UMFPACK system description constants, like @@ -128,8 +131,9 @@ transposed type, if 'mtx' is in CSR, since UMFPACK assumes CSC internally -Setting control parameters: -=========================== +:Setting control parameters: +---------------------------- + Assuming this module imported as um: List of control parameter names is accessible as 'um.umfControls' - their @@ -143,9 +147,9 @@ umfpack.control[um.UMFPACK_PRL] = 4 # Let's be more verbose. -- -Author: Robert Cimrman +:Author: Robert Cimrman -Other contributors: Nathan Bell (lu() method wrappers) +:Other contributors: Nathan Bell (lu() method wrappers) """ postpone_import = 1 From scipy-svn at scipy.org Wed Nov 21 06:34:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 05:34:07 -0600 (CST) Subject: [Scipy-svn] r3554 - branches/scipy.scons/scipy/fftpack Message-ID: <20071121113407.B864539C228@new.scipy.org> Author: cdavid Date: 2007-11-21 05:34:00 -0600 (Wed, 21 Nov 2007) New Revision: 3554 Added: branches/scipy.scons/scipy/fftpack/SConstruct branches/scipy.scons/scipy/fftpack/setupscons.py Log: fftpack knows build and all tests pass Added: branches/scipy.scons/scipy/fftpack/SConstruct =================================================================== --- branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-20 14:28:31 UTC (rev 3553) +++ branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-21 11:34:00 UTC (rev 3554) @@ -0,0 +1,29 @@ +# Last Change: Wed Nov 21 08:00 PM 2007 J +# vim:syntax=python +from os.path import join as pjoin +import glob + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) + +# Build dfftpack +src = glob.glob(pjoin('dfftpack', '*.f')) +dfftpack = env.NumpyStaticExtLibrary('dfftpack', source = src) +env.AppendUnique(LIBS = ['dfftpack']) +env.AppendUnique(LIBPATH = env['build_dir']) + +# Build _fftpack +src = ['src/zfft.c','src/drfft.c','src/zrfft.c', 'src/zfftnd.c'] +wsrc = env.F2PY(pjoin(env['build_dir'], '_fftpackmodule.c'), + pjoin(env['build_dir'], 'fftpack.pyf')) +env.NumpyPythonExtension('_fftpack', source = src + wsrc) + +# Build convolve +src = ['src/convolve.c'] +wsrc = env.F2PY(pjoin(env['build_dir'], 'convolve.pyf')) +env.NumpyPythonExtension('convolve', source = src + wsrc) Copied: branches/scipy.scons/scipy/fftpack/setupscons.py (from rev 3551, branches/scipy.scons/scipy/fftpack/setup.py) =================================================================== --- branches/scipy.scons/scipy/fftpack/setup.py 2007-11-20 11:53:08 UTC (rev 3551) +++ branches/scipy.scons/scipy/fftpack/setupscons.py 2007-11-21 11:34:00 UTC (rev 3554) @@ -0,0 +1,60 @@ +#!/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 + from numpy.distutils.system_info import get_info + config = Configuration('fftpack',parent_package, top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') +# +# +# 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 +# else: +# fft_opt_info = get_info('fftw3') or get_info('fftw2') \ +# or get_info('dfftw') +# djbfft_info = get_info('djbfft') +# +# config.add_library('dfftpack', +# sources=[join('dfftpack','*.f')]) +# +# sources = ['fftpack.pyf','src/zfft.c','src/drfft.c','src/zrfft.c', +# 'src/zfftnd.c'] +# +# config.add_extension('_fftpack', +# sources=sources, +# 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/drfft_fftw3.c', 'src/drfft_fftw.c', +# 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', +# 'src/zfftnd_fftw3.c', 'src/zfftnd_mkl.c', +# ], +# ) +# +# config.add_extension('convolve', +# sources=['convolve.pyf','src/convolve.c'], +# libraries=['dfftpack'], +# extra_info=[fft_opt_info, djbfft_info], +# ) + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + from fftpack_version import fftpack_version + setup(version=fftpack_version, + description='fftpack - Discrete Fourier Transform package', + author='Pearu Peterson', + author_email = 'pearu at cens.ioc.ee', + maintainer_email = 'scipy-dev at scipy.org', + license = 'SciPy License (BSD Style)', + **configuration(top_path='').todict()) From scipy-svn at scipy.org Wed Nov 21 06:36:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 05:36:36 -0600 (CST) Subject: [Scipy-svn] r3555 - branches/scipy.scons/scipy/fftpack Message-ID: <20071121113636.D670939C228@new.scipy.org> Author: cdavid Date: 2007-11-21 05:36:30 -0600 (Wed, 21 Nov 2007) New Revision: 3555 Modified: branches/scipy.scons/scipy/fftpack/SConstruct branches/scipy.scons/scipy/fftpack/setupscons.py Log: Remove junk in setupscons.py Modified: branches/scipy.scons/scipy/fftpack/SConstruct =================================================================== --- branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-21 11:34:00 UTC (rev 3554) +++ branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-21 11:36:30 UTC (rev 3555) @@ -11,6 +11,8 @@ env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +# XXX: implement fft checkers ... + # Build dfftpack src = glob.glob(pjoin('dfftpack', '*.f')) dfftpack = env.NumpyStaticExtLibrary('dfftpack', source = src) Modified: branches/scipy.scons/scipy/fftpack/setupscons.py =================================================================== --- branches/scipy.scons/scipy/fftpack/setupscons.py 2007-11-21 11:34:00 UTC (rev 3554) +++ branches/scipy.scons/scipy/fftpack/setupscons.py 2007-11-21 11:36:30 UTC (rev 3555) @@ -10,42 +10,7 @@ config.add_sconscript('SConstruct') config.add_data_dir('tests') -# -# -# 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 -# else: -# fft_opt_info = get_info('fftw3') or get_info('fftw2') \ -# or get_info('dfftw') -# djbfft_info = get_info('djbfft') -# -# config.add_library('dfftpack', -# sources=[join('dfftpack','*.f')]) -# -# sources = ['fftpack.pyf','src/zfft.c','src/drfft.c','src/zrfft.c', -# 'src/zfftnd.c'] -# -# config.add_extension('_fftpack', -# sources=sources, -# 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/drfft_fftw3.c', 'src/drfft_fftw.c', -# 'src/zfftnd_fftpack.c', 'src/zfftnd_fftw.c', -# 'src/zfftnd_fftw3.c', 'src/zfftnd_mkl.c', -# ], -# ) -# -# config.add_extension('convolve', -# sources=['convolve.pyf','src/convolve.c'], -# libraries=['dfftpack'], -# extra_info=[fft_opt_info, djbfft_info], -# ) + return config if __name__ == '__main__': From scipy-svn at scipy.org Wed Nov 21 07:21:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 06:21:07 -0600 (CST) Subject: [Scipy-svn] r3556 - branches/scipy.scons/scipy Message-ID: <20071121122107.51B2739C0D7@new.scipy.org> Author: cdavid Date: 2007-11-21 06:21:03 -0600 (Wed, 21 Nov 2007) New Revision: 3556 Modified: branches/scipy.scons/scipy/setupscons.py Log: make top setupscons.py call setupscons instead of setup Modified: branches/scipy.scons/scipy/setupscons.py =================================================================== --- branches/scipy.scons/scipy/setupscons.py 2007-11-21 11:36:30 UTC (rev 3555) +++ branches/scipy.scons/scipy/setupscons.py 2007-11-21 12:21:03 UTC (rev 3556) @@ -1,7 +1,7 @@ def configuration(parent_package='',top_path=None, setup_name = 'setupscons.py'): from numpy.distutils.misc_util import Configuration - config = Configuration('scipy',parent_package,top_path) + config = Configuration('scipy',parent_package,top_path, setup_name = 'setupscons.py') config.add_subpackage('cluster') config.add_subpackage('fftpack') config.add_subpackage('integrate') From scipy-svn at scipy.org Wed Nov 21 07:33:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 06:33:03 -0600 (CST) Subject: [Scipy-svn] r3557 - in branches/scipy.scons: . scipy/io/tests scipy/linsolve/umfpack scipy/ndimage scipy/ndimage/segment scipy/ndimage/segment/tests scipy/ndimage/tests scipy/sandbox/montecarlo/examples scipy/sandbox/multigrid scipy/sandbox/multigrid/multigridtools scipy/sandbox/multigrid/tests scipy/sparse scipy/sparse/sparsetools scipy/stats/models/robust Message-ID: <20071121123303.7D35D39C139@new.scipy.org> Author: cdavid Date: 2007-11-21 06:32:02 -0600 (Wed, 21 Nov 2007) New Revision: 3557 Added: branches/scipy.scons/scipy/ndimage/segmenter.py branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/README.txt Modified: branches/scipy.scons/ branches/scipy.scons/scipy/io/tests/test_datasource.py branches/scipy.scons/scipy/linsolve/umfpack/info.py branches/scipy.scons/scipy/ndimage/segment/Segmenter_EXT.c branches/scipy.scons/scipy/ndimage/segment/Segmenter_IMPL.c branches/scipy.scons/scipy/ndimage/segment/ndImage_Segmenter_structs.h branches/scipy.scons/scipy/ndimage/segment/tests/test_segment.py branches/scipy.scons/scipy/ndimage/tests/test_segment.py branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py branches/scipy.scons/scipy/sandbox/multigrid/adaptive.py branches/scipy.scons/scipy/sandbox/multigrid/dec_test.py branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.i branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.py branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx branches/scipy.scons/scipy/sandbox/multigrid/multilevel.py branches/scipy.scons/scipy/sandbox/multigrid/tests/test_utils.py branches/scipy.scons/scipy/sandbox/multigrid/utils.py branches/scipy.scons/scipy/sparse/sparse.py branches/scipy.scons/scipy/sparse/sparsetools/sparsetools.py branches/scipy.scons/scipy/stats/models/robust/scale.py branches/scipy.scons/setup.py Log: Merged revisions 3540-3556 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r3541 | tom.waite | 2007-11-16 06:56:38 +0900 (Fri, 16 Nov 2007) | 1 line Python segment execution ........ r3542 | tom.waite | 2007-11-16 09:28:25 +0900 (Fri, 16 Nov 2007) | 1 line changed morphological mask function passing method ........ r3543 | tom.waite | 2007-11-16 09:29:18 +0900 (Fri, 16 Nov 2007) | 1 line changed function prototypes ........ r3544 | tom.waite | 2007-11-16 09:31:11 +0900 (Fri, 16 Nov 2007) | 1 line changed PyArray type creation for edge and mask output arrays. ........ r3545 | wnbell | 2007-11-16 17:41:00 +0900 (Fri, 16 Nov 2007) | 2 lines support for 64bit indices in multigridtools ........ r3547 | tom.waite | 2007-11-17 10:15:06 +0900 (Sat, 17 Nov 2007) | 1 line Move C code to Python. Start with setup functions. ........ r3548 | jarrod.millman | 2007-11-19 13:13:22 +0900 (Mon, 19 Nov 2007) | 2 lines ran reindent.py to cleanup whitespaces ........ r3553 | rc | 2007-11-20 23:28:31 +0900 (Tue, 20 Nov 2007) | 2 lines Edited module docstring. ........ Property changes on: branches/scipy.scons ___________________________________________________________________ Name: svnmerge-integrated - /trunk:1-3539 + /trunk:1-3556 Modified: branches/scipy.scons/scipy/io/tests/test_datasource.py =================================================================== --- branches/scipy.scons/scipy/io/tests/test_datasource.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/io/tests/test_datasource.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -85,7 +85,7 @@ def test_ValidHTTP(self): assert self.ds.open(valid_httpurl()) - + def test_InvalidHTTP(self): self.assertRaises(IOError, self.ds.open, invalid_httpurl()) @@ -131,7 +131,7 @@ def test_ValidHTTP(self): assert self.ds.exists(valid_httpurl()) - + def test_InvalidHTTP(self): self.assertEqual(self.ds.exists(invalid_httpurl()), False) @@ -240,7 +240,7 @@ class TestOpenFunc(NumpyTestCase): def setUp(self): self.tmpdir = mkdtemp() - + def tearDown(self): rmtree(self.tmpdir) @@ -254,4 +254,3 @@ if __name__ == "__main__": NumpyTest().run() - Modified: branches/scipy.scons/scipy/linsolve/umfpack/info.py =================================================================== --- branches/scipy.scons/scipy/linsolve/umfpack/info.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/linsolve/umfpack/info.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -2,6 +2,10 @@ Interface to the UMFPACK library. ================================= +:Contains: UmfpackContext class + +:Description: +------------- Routines for symbolic and numeric LU factorization of sparse matrices and for solving systems of linear equations with sparse matrices. @@ -9,13 +13,12 @@ Copyright (c) 2005 by Timothy A. Davis. All Rights Reserved. UMFPACK homepage: http://www.cise.ufl.edu/research/sparse/umfpack -Contains: UmfpackContext class - Use 'print UmfpackContext().funs' to see all UMFPACK library functions the module exposes, if you need something not covered by the examples below. -Installation: -============= +:Installation: +-------------- + Example site.cfg entry: UMFPACK v4.4 in : @@ -43,8 +46,8 @@ umfpack_libs = umfpack -Examples: -========= +:Examples: +---------- Assuming this module imported as um (import scipy.linsolve.umfpack as um) @@ -115,8 +118,8 @@ LU = PRAQ when do_recip is true LU = P(R^-1)AQ when do_recip is false -Description of arguments of UmfpackContext solution methods: -============================================= +:Arguments of UmfpackContext solution methods: +---------------------------------------------- This holds for: umfpack(), umfpack.linsolve(), umfpack.solve() sys - one of UMFPACK system description constants, like @@ -128,8 +131,9 @@ transposed type, if 'mtx' is in CSR, since UMFPACK assumes CSC internally -Setting control parameters: -=========================== +:Setting control parameters: +---------------------------- + Assuming this module imported as um: List of control parameter names is accessible as 'um.umfControls' - their @@ -143,9 +147,9 @@ umfpack.control[um.UMFPACK_PRL] = 4 # Let's be more verbose. -- -Author: Robert Cimrman +:Author: Robert Cimrman -Other contributors: Nathan Bell (lu() method wrappers) +:Other contributors: Nathan Bell (lu() method wrappers) """ postpone_import = 1 Modified: branches/scipy.scons/scipy/ndimage/segment/Segmenter_EXT.c =================================================================== --- branches/scipy.scons/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/ndimage/segment/Segmenter_EXT.c 2007-11-21 12:32:02 UTC (rev 3557) @@ -36,7 +36,8 @@ type = PyArray_TYPE(iArray); num = PyArray_SIZE(iArray); - itype = 4; + //itype = 4; + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -88,7 +89,8 @@ num = PyArray_SIZE(iArray); // this is int type and hard-wirred. pass this in from Python code - itype = 4; // unsigned short + //itype = 4; // unsigned short + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -139,7 +141,8 @@ num = PyArray_SIZE(iArray); // this is int type and hard-wirred. pass this in from Python code - itype = 4; // unsigned short + //itype = 4; // unsigned short + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -325,7 +328,8 @@ // replace the edgeImage with maskImage // - if(!NI_VoxelMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + if(!NI_VoxelMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, + fP2, ROIList)) goto exit; exit: @@ -373,7 +377,8 @@ // replace the edgeImage with maskImage // - if(!NI_TextureMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, fP2, ROIList)) + if(!NI_TextureMeasures(num, (int)dims[0], (int)dims[1], (int)objNumber[0], fP1, + fP2, ROIList)) goto exit; exit: @@ -402,7 +407,8 @@ // // pass in 2D LPF coefficients - if(!PyArg_ParseTuple(args, "iiiiO", &lowThreshold, &highThreshold, &closeWindow, &openWindow, &iArray)) + if(!PyArg_ParseTuple(args, "iiiiO", &lowThreshold, &highThreshold, &closeWindow, + &openWindow, &iArray)) goto exit; fP1 = (double *)PyArray_DATA(iArray); @@ -412,7 +418,8 @@ num = PyArray_SIZE(iArray); // this is int type and hard-wirred. pass this in from Python code - itype = 4; // unsigned short + //itype = 4; // unsigned short + itype = NPY_USHORT; eArray = (PyObject*)PyArray_SimpleNew(nd, dims, itype); fP2 = (unsigned short *)PyArray_DATA(eArray); @@ -420,8 +427,9 @@ goto exit; - if(!NI_RegionGrow(num, (int)dims[0], (int)dims[1], lowThreshold, highThreshold, closeWindow, openWindow, - fP1, fP2, &groups)) + if(!NI_RegionGrow(num, (int)dims[0], (int)dims[1], lowThreshold, highThreshold, + closeWindow, openWindow, fP1, fP2, &groups)) + goto exit; exit: Modified: branches/scipy.scons/scipy/ndimage/segment/Segmenter_IMPL.c =================================================================== --- branches/scipy.scons/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/ndimage/segment/Segmenter_IMPL.c 2007-11-21 12:32:02 UTC (rev 3557) @@ -1331,8 +1331,8 @@ int i, j; int offset, offset2; - unsigned short cmask[11][11]; - unsigned short omask[11][11]; + unsigned short *cmask; + unsigned short *omask; int olapValuesC[4]; int olapValuesO[4]; int CloseMaskSize = 1; @@ -1340,6 +1340,7 @@ int LowValue1, HighValue1; int LowValue2, HighValue2; int spadSize; + int maskSize = 11; unsigned char *ImageE; unsigned char *ImageC; @@ -1348,6 +1349,9 @@ ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + cmask = calloc(11*11, sizeof(unsigned short)); + omask = calloc(11*11, sizeof(unsigned short)); + // // Close filter // @@ -1355,7 +1359,7 @@ CloseMaskSize = (CloseSize-1)/2; for(i = 0; i < 2*CloseMaskSize+1; ++i){ for(j = 0; j < 2*CloseMaskSize+1; ++j){ - cmask[i][j] = 1; + cmask[i*maskSize+j] = 1; } } LowValue1 = 0; @@ -1375,7 +1379,7 @@ OpenMaskSize = (OpenSize-1)/2; for(i = 0; i < 2*OpenMaskSize+1; ++i){ for(j = 0; j < 2*OpenMaskSize+1; ++j){ - omask[i][j] = 1; + omask[i*maskSize+j] = 1; } } LowValue1 = 1; @@ -1426,6 +1430,9 @@ free(ImageE); free(ImageC); + free(cmask); + free(omask); + return; } @@ -1442,8 +1449,8 @@ } int NI_RegionGrow(int samples, int rows, int cols, int lowThreshold, int highThreshold, - int closeWindow, int openWindow, double *rawImage, - unsigned short *edgeImage, int *groups){ + int closeWindow, int openWindow, double *rawImage, + unsigned short *edgeImage, int *groups){ int i, j; int offset; @@ -1503,107 +1510,108 @@ } -void initThinFilter(int J_mask[3][30], int K_mask[3][30]){ +void initThinFilter(int *J_mask, int *K_mask){ int i, j; int Column; + int maskCols = 3; for(i = 0; i < 3; ++i){ for(j = 0; j < 30; ++j){ - J_mask[i][j] = 0; - K_mask[i][j] = 0; + J_mask[i+j*maskCols] = 0; + K_mask[i+j*maskCols] = 0; } } Column = 0; - J_mask[0][Column+0] = 1; - J_mask[0][Column+1] = 1; - J_mask[0][Column+2] = 1; - J_mask[1][Column+1] = 1; + J_mask[0+maskCols*(Column+0)] = 1; + J_mask[0+maskCols*(Column+1)] = 1; + J_mask[0+maskCols*(Column+2)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; Column += 3; - J_mask[0][Column+1] = 1; - J_mask[1][Column+1] = 1; - J_mask[1][Column+2] = 1; + J_mask[0+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+2)] = 1; Column += 3; - J_mask[0][Column+0] = 1; - J_mask[1][Column+0] = 1; - J_mask[2][Column+0] = 1; - J_mask[1][Column+1] = 1; + J_mask[0+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+0)] = 1; + J_mask[2+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; Column += 3; - J_mask[0][Column+1] = 1; - J_mask[1][Column+0] = 1; - J_mask[1][Column+1] = 1; + J_mask[0+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; Column += 3; - J_mask[0][Column+2] = 1; - J_mask[1][Column+1] = 1; - J_mask[1][Column+2] = 1; - J_mask[2][Column+2] = 1; + J_mask[0+maskCols*(Column+2)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+2)] = 1; + J_mask[2+maskCols*(Column+2)] = 1; Column += 3; - J_mask[1][Column+0] = 1; - J_mask[1][Column+1] = 1; - J_mask[2][Column+1] = 1; + J_mask[1+maskCols*(Column+0)] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[2+maskCols*(Column+1)] = 1; Column += 3; - J_mask[1][Column+1] = 1; - J_mask[2][Column+0] = 1; - J_mask[2][Column+1] = 1; - J_mask[2][Column+2] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[2+maskCols*(Column+0)] = 1; + J_mask[2+maskCols*(Column+1)] = 1; + J_mask[2+maskCols*(Column+2)] = 1; Column += 3; - J_mask[1][Column+1] = 1; - J_mask[1][Column+2] = 1; - J_mask[2][Column+1] = 1; + J_mask[1+maskCols*(Column+1)] = 1; + J_mask[1+maskCols*(Column+2)] = 1; + J_mask[2+maskCols*(Column+1)] = 1; Column = 0; - K_mask[2][Column+0] = 1; - K_mask[2][Column+1] = 1; - K_mask[2][Column+2] = 1; + K_mask[2+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+1)] = 1; + K_mask[2+maskCols*(Column+2)] = 1; Column += 3; - K_mask[1][Column+0] = 1; - K_mask[2][Column+0] = 1; - K_mask[2][Column+1] = 1; + K_mask[1+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+1)] = 1; Column += 3; - K_mask[0][Column+2] = 1; - K_mask[1][Column+2] = 1; - K_mask[2][Column+2] = 1; + K_mask[0+maskCols*(Column+2)] = 1; + K_mask[1+maskCols*(Column+2)] = 1; + K_mask[2+maskCols*(Column+2)] = 1; Column += 3; - K_mask[1][Column+2] = 1; - K_mask[2][Column+1] = 1; - K_mask[2][Column+2] = 1; + K_mask[1+maskCols*(Column+2)] = 1; + K_mask[2+maskCols*(Column+1)] = 1; + K_mask[2+maskCols*(Column+2)] = 1; Column += 3; - K_mask[0][Column+0] = 1; - K_mask[1][Column+0] = 1; - K_mask[2][Column+0] = 1; + K_mask[0+maskCols*(Column+0)] = 1; + K_mask[1+maskCols*(Column+0)] = 1; + K_mask[2+maskCols*(Column+0)] = 1; Column += 3; - K_mask[0][Column+1] = 1; - K_mask[0][Column+2] = 1; - K_mask[1][Column+2] = 1; + K_mask[0+maskCols*(Column+1)] = 1; + K_mask[0+maskCols*(Column+2)] = 1; + K_mask[1+maskCols*(Column+2)] = 1; Column += 3; - K_mask[0][Column+0] = 1; - K_mask[0][Column+1] = 1; - K_mask[0][Column+2] = 1; + K_mask[0+maskCols*(Column+0)] = 1; + K_mask[0+maskCols*(Column+1)] = 1; + K_mask[0+maskCols*(Column+2)] = 1; Column += 3; - K_mask[0][Column+0] = 1; - K_mask[0][Column+1] = 1; - K_mask[1][Column+0] = 1; + K_mask[0+maskCols*(Column+0)] = 1; + K_mask[0+maskCols*(Column+1)] = 1; + K_mask[1+maskCols*(Column+0)] = 1; return; } -void ThinningFilter(int regRows, int regColumns, int spadSize, int J_mask[3][30], int K_mask[3][30], +void ThinningFilter(int regRows, int regColumns, int spadSize, int *J_mask, int *K_mask, unsigned char *Input, unsigned char *CInput, unsigned char *ErosionStage, unsigned char *DialationStage, unsigned char *HMT, unsigned char *Copy){ @@ -1613,6 +1621,7 @@ int Column, T, nloop; int Offset; int N, M; + int maskCols = 3; int j_mask[3][3]; int k_mask[3][3]; @@ -1640,12 +1649,12 @@ for(n = 0; n < 8; ++n){ for(i = 0; i < 3; ++i){ for(j = 0; j < 3; ++j){ - j_mask[i][j] = J_mask[i][Column+j]; + j_mask[i][j] = J_mask[i+maskCols*(Column+j)]; } } for(i = 0; i < 3; ++i){ for(j = 0; j < 3; ++j){ - k_mask[i][j] = K_mask[i][Column+j]; + k_mask[i][j] = K_mask[i+maskCols*(Column+j)]; } } Column += 3; @@ -1745,6 +1754,7 @@ } Offset += spadSize; } + /* nloop is data dependent. */ ++nloop; } @@ -1766,8 +1776,8 @@ int dstOffset; int status; int inflate = 1; - int J_mask[3][30]; - int K_mask[3][30]; + int *J_mask; + int *K_mask; unsigned char *Input; unsigned char *CInput; @@ -1787,6 +1797,8 @@ HMT = calloc(samples, sizeof(unsigned char)); Copy = calloc(samples, sizeof(unsigned char)); thinEdgeImage = calloc(samples, sizeof(unsigned short)); + J_mask = calloc(3*30, sizeof(int)); + K_mask = calloc(3*30, sizeof(int)); initThinFilter(J_mask, K_mask); for(loop = 0; loop < numberObjects; ++loop){ @@ -1855,6 +1867,8 @@ free(HMT); free(Copy); free(thinEdgeImage); + free(J_mask); + free(K_mask); status = 1; @@ -2050,7 +2064,7 @@ void OpenCloseFilter(int olapValues[], int maskSize, int rows, int columns, int spadSize, - unsigned char *input, unsigned char *output, unsigned short mask[11][11]){ + unsigned char *input, unsigned char *output, unsigned short *mask){ /* @@ -2061,6 +2075,7 @@ int offset; int LowValue1, HighValue1; int LowValue2, HighValue2; + int morphoMaskSize = 11; LowValue1 = olapValues[0]; HighValue1 = olapValues[1]; @@ -2076,7 +2091,7 @@ for(k = -maskSize; k < maskSize; ++k){ m = k*spadSize; for(l = -maskSize; l < maskSize; ++l){ - overlap = mask[k+maskSize][l+maskSize]*input[offset+m+j+l]; + overlap = mask[morphoMaskSize*(k+maskSize)+(l+maskSize)]*input[offset+m+j+l]; if(overlap == HighValue1){ hit = HighValue1; } @@ -2096,7 +2111,7 @@ for(k = -maskSize; k < maskSize; ++k){ m = k*spadSize; for(l = -maskSize; l < maskSize; ++l){ - overlap = mask[k+maskSize][l+maskSize]*output[offset+m+j+l]; + overlap = mask[morphoMaskSize*(k+maskSize)+(l+maskSize)]*output[offset+m+j+l]; if(overlap == HighValue2){ hit = HighValue2; } @@ -2140,7 +2155,7 @@ void doMorphology(unsigned char *Input, unsigned char *ImageE, unsigned char *ImageC, unsigned char *ImageH, int olapValuesC[], int olapValuesO[], - unsigned short cmask[11][11], unsigned short omask[11][11], + unsigned short *cmask, unsigned short *omask, RECT roi, int label, int CloseMaskSize, int OpenMaskSize, int spadSize){ int i, j; @@ -2306,8 +2321,9 @@ float aveRadius; float vCompactness; /* for morphological close of mask. max structuring element is 11x11 */ - unsigned short cmask[11][11]; - unsigned short omask[11][11]; + unsigned short *cmask; + unsigned short *omask; + int maskSize = 11; int olapValuesC[4]; int olapValuesO[4]; int CloseMaskSize; @@ -2325,13 +2341,25 @@ unsigned char *ImageC; unsigned char *ImageH; + spadSize = srcCols; + pBoundaryIndex = calloc(srcRows+srcCols, sizeof(boundaryIndex)); + Input = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); + ImageH = calloc(spadSize*spadSize, sizeof(unsigned char)); + pBoundary = calloc(srcRows*srcCols, sizeof(blobBoundary)); + lBoundary = calloc(32767, sizeof(blobBoundary)); + boundary = calloc(32767, sizeof(POINT)); + cmask = calloc(11*11, sizeof(unsigned short)); + omask = calloc(11*11, sizeof(unsigned short)); + /* // Close filter */ CloseMaskSize = (CloseSize-1)/2; for(i = 0; i < 2*CloseMaskSize+1; ++i){ for(j = 0; j < 2*CloseMaskSize+1; ++j){ - cmask[i][j] = 1; + cmask[i*maskSize+j] = 1; } } LowValue1 = 0; @@ -2349,7 +2377,7 @@ OpenMaskSize = (OpenSize-1)/2; for(i = 0; i < 2*OpenMaskSize+1; ++i){ for(j = 0; j < 2*OpenMaskSize+1; ++j){ - omask[i][j] = 1; + omask[i*maskSize+j] = 1; } } LowValue1 = 1; @@ -2361,19 +2389,6 @@ olapValuesO[2] = LowValue2; olapValuesO[3] = HighValue2; - - //spadSize = MAX(srcRows, srcCols); - spadSize = srcCols; - - pBoundaryIndex = calloc(srcRows+srcCols, sizeof(boundaryIndex)); - Input = calloc(spadSize*spadSize, sizeof(unsigned char)); - ImageE = calloc(spadSize*spadSize, sizeof(unsigned char)); - ImageC = calloc(spadSize*spadSize, sizeof(unsigned char)); - ImageH = calloc(spadSize*spadSize, sizeof(unsigned char)); - pBoundary = calloc(srcRows*srcCols, sizeof(blobBoundary)); - lBoundary = calloc(32767, sizeof(blobBoundary)); - boundary = calloc(32767, sizeof(POINT)); - for(i = 0; i < (srcRows+srcCols); ++i){ pBoundaryIndex[i].numberPoints = 0; pBoundaryIndex[i].curveClose = 0; @@ -2384,7 +2399,6 @@ for(i = 0; i < numberObjects; ++i){ - //for(i = 0; i < 1; ++i){ ++pBoundaryIndex[0].numberPoints; count = 0; j = 1; @@ -2597,6 +2611,8 @@ free(pBoundary); free(lBoundary); free(boundary); + free(cmask); + free(omask); return; @@ -2949,14 +2965,13 @@ if(count){ std /= (float)count; std = sqrt(std); - objectMetrics[i].voxelMean = mean - 2048.0; // the 2048 is only for the cardiac CT volume + objectMetrics[i].voxelMean = mean; objectMetrics[i].voxelVar = std; } else{ objectMetrics[i].voxelMean = 0.0; objectMetrics[i].voxelVar = 0.0; } - if(0) printf("(%d) mean %f, std %f\n", label, objectMetrics[i].voxelMean, objectMetrics[i].voxelVar); } return; Modified: branches/scipy.scons/scipy/ndimage/segment/ndImage_Segmenter_structs.h =================================================================== --- branches/scipy.scons/scipy/ndimage/segment/ndImage_Segmenter_structs.h 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/ndimage/segment/ndImage_Segmenter_structs.h 2007-11-21 12:32:02 UTC (rev 3557) @@ -117,17 +117,17 @@ void getBoundary(unsigned short *, unsigned char *, blobBoundary *, blobBoundary *, boundaryIndex *, RECT, int, int, int, int, int, int); void doMorphology(unsigned char *, unsigned char *, unsigned char *, unsigned char *, int olapValuesC[], - int olapValuesO[], unsigned short cmask[11][11], unsigned short omask[11][11], + int olapValuesO[], unsigned short *, unsigned short *, RECT, int, int, int, int); void getCompactness(unsigned char *, RECT, int, int, float *, float); void OpenCloseFilter(int olapValues[], int, int, int, int, unsigned char *, - unsigned char *, unsigned short mask[11][11]); + unsigned char *, unsigned short *); void trackBoundary(unsigned char *, blobBoundary lBoundary[], int, int, blobBoundary, int); void getBoundaryMetrics(bPOINT *, float *, float *, float *, float *, float, float, int); void generateMask(unsigned char *, bPOINT *, int, int, int); -void ThinningFilter(int, int, int, int J_mask[3][30], int K_mask[3][30], unsigned char *, +void ThinningFilter(int, int, int, int *, int *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned char *); -void initThinFilter(int J_mask[3][30], int K_mask[3][30]); +void initThinFilter(int *, int *); void Shen_Castan(double, double, int, int, int, int, int, double *, unsigned short *); void computeISEF(float *, float *, int, int, double); void ISEF_Horizontal(float *, float *, float *, float *, int, int, double); Modified: branches/scipy.scons/scipy/ndimage/segment/tests/test_segment.py =================================================================== --- branches/scipy.scons/scipy/ndimage/segment/tests/test_segment.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/ndimage/segment/tests/test_segment.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -11,302 +11,302 @@ def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - """ - labeledEdges, ROIList = shen_castan(image, [default]) + """ + labeledEdges, ROIList = shen_castan(image, [default]) - implements Shen-Castan edge finding + implements Shen-Castan edge finding - Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust - - image is the numarray 2D image - - IIR filter is filter parameter for exponential filter - - shen_castan_low is edge threshold is range (0.0, 1.0] - - window is search window for edge detection - - low_ and high_ threshold are density values - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, IIR filter, shen_castan_low, window, low_threshold, high_threshold, dust + - image is the numarray 2D image + - IIR filter is filter parameter for exponential filter + - shen_castan_low is edge threshold is range (0.0, 1.0] + - window is search window for edge detection + - low_ and high_ threshold are density values + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, - lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, + lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - """ - labeledEdges, ROIList = sobel(image, [default]) + """ + labeledEdges, ROIList = sobel(image, [default]) - implements sobel magnitude edge finding + implements sobel magnitude edge finding - Inputs - image, sobel_low, tMode, low_threshold, high_threshold, - high_filter_cutoff, filter_aperature, dust - - image is the numarray 2D image - - sobel_low is edge threshold is range (0.0, 1.0] - - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) - - low_ and high_ threshold are density values - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - aperature is odd filter kernel length - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, sobel_low, tMode, low_threshold, high_threshold, + high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - sobel_low is edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, - highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, + highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - """ - labeledEdges, ROIList = canny(image, [default]) + """ + labeledEdges, ROIList = canny(image, [default]) - implements canny edge finding + implements canny edge finding - Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, - high_threshold, high_filter_cutoff, filter_aperature, dust - - image is the numarray 2D image - - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter - - clow is low edge threshold is range (0.0, 1.0] - - chigh is high edge threshold is range (0.0, 1.0] - - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) - - low_ and high_ threshold are density values - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] - - aperature is odd filter kernel length - - dust is blob filter. blob area (length x width of bounding box) under this - size threshold are filtered (referred to as dust and blown away) + Inputs - image, DG_sigma, canny_low, canny_high, tMode, low_threshold, + high_threshold, high_filter_cutoff, filter_aperature, dust + - image is the numarray 2D image + - DG_sigma is Gaussain sigma for the derivative-of-gaussian filter + - clow is low edge threshold is range (0.0, 1.0] + - chigh is high edge threshold is range (0.0, 1.0] + - tMode is threshold mode: 1 for ave, 2 for mode (histogram peak) + - low_ and high_ threshold are density values + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - high_filter_cutoff is digital high frequency cutoff in range (0.0, 180.0] + - aperature is odd filter kernel length + - dust is blob filter. blob area (length x width of bounding box) under this + size threshold are filtered (referred to as dust and blown away) - Outputs - labeledEdges, ROIList[>dust] - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList[>dust] is a blob feature list. Only values - with bounding box area greater than dust threshold are returned + Outputs - labeledEdges, ROIList[>dust] + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList[>dust] is a blob feature list. Only values + with bounding box area greater than dust threshold are returned - """ - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + """ + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def get_shape_mask(labeledEdges, ROIList): - """ - get_shape_mask(labeledEdges, ROIList) + """ + get_shape_mask(labeledEdges, ROIList) - takes labeled edge image plus ROIList (blob descriptors) and generates - boundary shape features and builds labeled blob masks. 'labeledEdges' - is over-written by 'labeledMask'. Adds features to ROIList structure + takes labeled edge image plus ROIList (blob descriptors) and generates + boundary shape features and builds labeled blob masks. 'labeledEdges' + is over-written by 'labeledMask'. Adds features to ROIList structure - Inputs - labeledEdges, ROIList - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - labeledEdges, ROIList + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. edge image input is over-written with mask image. - ROIList added to. + Output - no return. edge image input is over-written with mask image. + ROIList added to. - """ + """ - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return def get_voxel_measures(rawImage, labeledEdges, ROIList): - """ - get_voxel_measures(rawImage, labeledEdges, ROIList) + """ + get_voxel_measures(rawImage, labeledEdges, ROIList) - takes raw 2D image, labeled blob mask and ROIList. computes voxel features - (moments, histogram) for each blob. Adds features to ROIList structure. + takes raw 2D image, labeled blob mask and ROIList. computes voxel features + (moments, histogram) for each blob. Adds features to ROIList structure. - Inputs - rawImage, labeledEdges, ROIList - - rawImage is the original source 2D image - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. ROIList added to. + Output - no return. ROIList added to. - """ - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return def get_texture_measures(rawImage, labeledEdges, ROIList): - """ - get_texture_measures(rawImage, labeledEdges, ROIList) + """ + get_texture_measures(rawImage, labeledEdges, ROIList) - takes raw 2D image, labeled blob mask and ROIList. computes 2D - texture features using 7x7 Law's texture filters applied - to segmented blobs. TEM (texture energy metric) is computed - for each Law's filter image and stored in TEM part of ROIList. + takes raw 2D image, labeled blob mask and ROIList. computes 2D + texture features using 7x7 Law's texture filters applied + to segmented blobs. TEM (texture energy metric) is computed + for each Law's filter image and stored in TEM part of ROIList. - Inputs - rawImage, labeledEdges, ROIList - - rawImage is the original source 2D image - - labeledEdges is boundary (edges) of segmented 'blobs', - numerically labeled by blob number - - ROIList is a blob feature list. + Inputs - rawImage, labeledEdges, ROIList + - rawImage is the original source 2D image + - labeledEdges is boundary (edges) of segmented 'blobs', + numerically labeled by blob number + - ROIList is a blob feature list. - Output - no return. ROIList added to. - """ - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return + Output - no return. ROIList added to. + """ + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, sub-edges, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return def segment_regions(): - """ - sourceImage, labeledMask, ROIList = segment_regions() + """ + sourceImage, labeledMask, ROIList = segment_regions() - Inputs - No Input + Inputs - No Input - Outputs - sourceImage, labeledMask, ROIList - - sourceImage is raw 2D image (default cardiac CT slice for demo - - labeledMask is mask of segmented 'blobs', - numerically labeled by blob number - - ROIList is numerical Python structure of intensity, shape and - texture features for each blob + Outputs - sourceImage, labeledMask, ROIList + - sourceImage is raw 2D image (default cardiac CT slice for demo + - labeledMask is mask of segmented 'blobs', + numerically labeled by blob number + - ROIList is numerical Python structure of intensity, shape and + texture features for each blob - High level script calls Python functions: - get_slice() - a cardiac CT slice demo file - sobel() - sobel magnitude edge finder, - returns connected edges - get_shape_mask() - gets segmented blob boundary and mask - and shape features - get_voxel_measures() - uses masks get object voxel moment - and histogram features - get_texture_measures() - uses masks get object 2D texture features - """ - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + sobel() - sobel magnitude edge finder, + returns connected edges + get_shape_mask() - gets segmented blob boundary and mask + and shape features + get_voxel_measures() - uses masks get object voxel moment + and histogram features + get_texture_measures() - uses masks get object 2D texture features + """ + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList def grow_regions(): - """ - regionMask, numberRegions = region_grow() - Inputs - No Input - Outputs - regionMask, numberRegions - - regionMask is the labeled segment masks from 2D image - - numberRegions is the number of segmented blobs + """ + regionMask, numberRegions = region_grow() + Inputs - No Input + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs - High level script calls Python functions: - get_slice() - a cardiac CT slice demo file - region_grow() - "grows" connected blobs. default threshold - and morphological filter structuring element - """ - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions + High level script calls Python functions: + get_slice() - a cardiac CT slice demo file + region_grow() - "grows" connected blobs. default threshold + and morphological filter structuring element + """ + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - """ - regionMask, numberRegions = region_grow(image, [defaults]) + """ + regionMask, numberRegions = region_grow(image, [defaults]) - Inputs - image, low_threshold, high_threshold, open, close - - image is the numarray 2D image - - low_ and high_ threshold are density values - - open is open morphology structuring element - odd size. 0 to turn off. max is 11 - - close is close morphology structuring element - odd size. 0 to turn off. max is 11 + Inputs - image, low_threshold, high_threshold, open, close + - image is the numarray 2D image + - low_ and high_ threshold are density values + - open is open morphology structuring element + odd size. 0 to turn off. max is 11 + - close is close morphology structuring element + odd size. 0 to turn off. max is 11 - Outputs - regionMask, numberRegions - - regionMask is the labeled segment masks from 2D image - - numberRegions is the number of segmented blobs - """ - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - + Outputs - regionMask, numberRegions + - regionMask is the labeled segment masks from 2D image + - numberRegions is the number of segmented blobs + """ + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + def get_slice(imageName='slice112.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) def get_slice2(image_name='slice112.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - slice[505:512,:] = 0 - return slice + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) class TestSegment(NumpyTestCase): def test1(self): - image = get_slice(filename) - sourceImage = image.copy() - edges, objects = sobel(image) - get_shape_mask(edges, objects) - get_voxel_measures(sourceImage, edges, objects) - get_texture_measures(sourceImage, edges, objects) + image = get_slice(filename) + sourceImage = image.copy() + edges, objects = sobel(image) + get_shape_mask(edges, objects) + get_voxel_measures(sourceImage, edges, objects) + get_texture_measures(sourceImage, edges, objects) def test2(self): - sourceImage, labeledMask, ROIList = segment_regions() + sourceImage, labeledMask, ROIList = segment_regions() def test3(self): - regionMask, numberRegions = grow_regions() - regionMask.max() - #save_slice(regionMask, 'regionMask.raw') + regionMask, numberRegions = grow_regions() + regionMask.max() + #save_slice(regionMask, 'regionMask.raw') if __name__ == "__main__": Copied: branches/scipy.scons/scipy/ndimage/segmenter.py (from rev 3553, trunk/scipy/ndimage/segmenter.py) Modified: branches/scipy.scons/scipy/ndimage/tests/test_segment.py =================================================================== --- branches/scipy.scons/scipy/ndimage/tests/test_segment.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/ndimage/tests/test_segment.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -10,132 +10,132 @@ def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048, highThreshold=600+2048, dust=16): - labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, lowThreshold, highThreshold, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def sobel(image, sLow=0.3, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - # get sobel edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' - S.morpho_thin_filt(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + # get sobel edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, highThreshold, BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge' + S.morpho_thin_filt(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def canny(image, cSigma=1.0, cLow=0.5, cHigh=0.8, tMode=1, lowThreshold=220+2048, highThreshold=600+2048, BPHigh=10.0, apearture=21, dust=16): - # get canny edge points. return edges that are labeled (1..numberObjects) - labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, - BPHigh, apearture, image) - # allocated struct array for edge object measures. for now just the rect bounding box - ROIList = N.zeros(numberObjects, dtype=S.objstruct) - # return the bounding box for each connected edge - S.get_object_stats(labeledEdges, ROIList) - return labeledEdges, ROIList[ROIList['Area']>dust] + # get canny edge points. return edges that are labeled (1..numberObjects) + labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, + BPHigh, apearture, image) + # allocated struct array for edge object measures. for now just the rect bounding box + ROIList = N.zeros(numberObjects, dtype=S.objstruct) + # return the bounding box for each connected edge + S.get_object_stats(labeledEdges, ROIList) + return labeledEdges, ROIList[ROIList['Area']>dust] def get_shape_mask(labeledEdges, ROIList): - # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList - # GetShapeMask will augment the ROI list - # labeledEdges is the original edge image and overwritten as mask image - # maskImage is the mask that is used for blob texture / pixel features - S.build_boundary(labeledEdges, ROIList) - return + # pass in Sobel morph-thinned labeled edge image (LEI) and ROIList + # GetShapeMask will augment the ROI list + # labeledEdges is the original edge image and overwritten as mask image + # maskImage is the mask that is used for blob texture / pixel features + S.build_boundary(labeledEdges, ROIList) + return def get_voxel_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the voxel features in the list - # - S.voxel_measures(rawImage, labeledEdges, ROIList) - return + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the voxel features in the list + # + S.voxel_measures(rawImage, labeledEdges, ROIList) + return def get_texture_measures(rawImage, labeledEdges, ROIList): - # - # pass raw image, labeled mask and the partially filled ROIList - # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list - # - S.texture_measures(rawImage, labeledEdges, ROIList) - return + # + # pass raw image, labeled mask and the partially filled ROIList + # VoxelMeasures will fill the texture (Law's, co-occurence, Gabor) features in the list + # + S.texture_measures(rawImage, labeledEdges, ROIList) + return def segment_regions(): - # get slice from the CT volume - image = get_slice(filename) - # need a copy of original image as filtering will occur on the extracted slice - sourceImage = image.copy() - # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) - # followed by connected component analysis. What is returned is labeled edges and the object list - labeledMask, ROIList = sobel(image) - # From the labeled edges and the object list get the labeled mask for each blob object - get_shape_mask(labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get voxel features - get_voxel_measures(sourceImage, labeledMask, ROIList) - # Use the labeled mask and source image (raw) to get texture features - get_texture_measures(sourceImage, labeledMask, ROIList) - return sourceImage, labeledMask, ROIList + # get slice from the CT volume + image = get_slice(filename) + # need a copy of original image as filtering will occur on the extracted slice + sourceImage = image.copy() + # Sobel is the first level segmenter. Sobel magnitude and MAT (medial axis transform) + # followed by connected component analysis. What is returned is labeled edges and the object list + labeledMask, ROIList = sobel(image) + # From the labeled edges and the object list get the labeled mask for each blob object + get_shape_mask(labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get voxel features + get_voxel_measures(sourceImage, labeledMask, ROIList) + # Use the labeled mask and source image (raw) to get texture features + get_texture_measures(sourceImage, labeledMask, ROIList) + return sourceImage, labeledMask, ROIList def grow_regions(): - # get slice from the CT volume - image = get_slice(filename) - regionMask, numberRegions = region_grow(image) - return regionMask, numberRegions + # get slice from the CT volume + image = get_slice(filename) + regionMask, numberRegions = region_grow(image) + return regionMask, numberRegions def region_grow(image, lowThreshold=220+2048, highThreshold=600+2048, open=7, close=7): - # morphology filters need to be clipped to 11 max and be odd - regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) - return regionMask, numberRegions - + # morphology filters need to be clipped to 11 max and be odd + regionMask, numberRegions = S.region_grow(lowThreshold, highThreshold, close, open, image) + return regionMask, numberRegions + def get_slice(imageName='junk.raw', bytes=2, rows=512, columns=512): - # get a slice alrady extracted from the CT volume - #image = open(imageName, 'rb') - #slice = image.read(rows*columns*bytes) - #values = struct.unpack('h'*rows*columns, slice) - #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) + # get a slice alrady extracted from the CT volume + #image = open(imageName, 'rb') + #slice = image.read(rows*columns*bytes) + #values = struct.unpack('h'*rows*columns, slice) + #ImageSlice = N.array(values, dtype=float).reshape(rows, columns) - ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); + ImageSlice = N.fromfile(imageName, dtype=N.uint16).reshape(rows, columns); - # clip the ends for this test CT image file as the spine runs off the end of the image - ImageSlice[505:512, :] = 0 - return (ImageSlice).astype(float) + # clip the ends for this test CT image file as the spine runs off the end of the image + ImageSlice[505:512, :] = 0 + return (ImageSlice).astype(float) def get_slice2(image_name='junk.raw', bytes=2, shape=(512,512)): - import mmap - file = open(image_name, 'rb') - mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) - slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) - slice = slice.astype(float) - slice[505:512,:] = 0 - return slice + import mmap + file = open(image_name, 'rb') + mm = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) + slice = N.frombuffer(mm, dtype='u%d' % bytes).reshape(shape) + slice = slice.astype(float) + slice[505:512,:] = 0 + return slice def save_slice(mySlice, filename='junk.raw', bytes=4): - # just save the slice to a fixed file - slice = mySlice.astype('u%d' % bytes) - slice.tofile(filename) + # just save the slice to a fixed file + slice = mySlice.astype('u%d' % bytes) + slice.tofile(filename) class TestSegment(NumpyTestCase): def test1(self): - image = get_slice(filename) - sourceImage = image.copy() - edges, objects = sobel(image) - get_shape_mask(edges, objects) - get_voxel_measures(sourceImage, edges, objects) - get_texture_measures(sourceImage, edges, objects) + image = get_slice(filename) + sourceImage = image.copy() + edges, objects = sobel(image) + get_shape_mask(edges, objects) + get_voxel_measures(sourceImage, edges, objects) + get_texture_measures(sourceImage, edges, objects) def test2(self): - sourceImage, labeledMask, ROIList = segment_regions() + sourceImage, labeledMask, ROIList = segment_regions() def test3(self): - regionMask, numberRegions = grow_regions() - print regionMask.max() - #save_slice(regionMask, 'regionMask.raw') + regionMask, numberRegions = grow_regions() + print regionMask.max() + #save_slice(regionMask, 'regionMask.raw') if __name__ == "__main__": Modified: branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py =================================================================== --- branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -17,4 +17,3 @@ s = montecarlo.dictsampler(d) for i in range(10): temp = s.sample(10**7) - Modified: branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py =================================================================== --- branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_2.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -8,4 +8,3 @@ s = montecarlo.dictsampler(d) for i in range(10): temp = s.sample(10**7) - Modified: branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py =================================================================== --- branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_3.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -6,4 +6,3 @@ s = montecarlo.intsampler(v) for i in range(10): temp = s.sample(10**7) - Modified: branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py =================================================================== --- branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/montecarlo/examples/test_montecarlo_speed_4.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -6,4 +6,3 @@ s = montecarlo.intsampler(v) for i in range(10): temp = s.sample(10**7) - Modified: branches/scipy.scons/scipy/sandbox/multigrid/adaptive.py =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/adaptive.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/adaptive.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -139,8 +139,8 @@ max_levels = max_levels, \ max_coarse = max_coarse, \ mu = mu, epsilon = epsilon, \ - aggregation = aggregation ) - + aggregation = aggregation ) + #create SA using x here As,Ps,Ts,Bs = sa_hierarchy(A,x,AggOps) @@ -160,7 +160,7 @@ for i in range(max_candidates): B = B[:,1:] As,Ps,Ts,Bs = sa_hierarchy(A,B,AggOps) - x = self.__develop_new_candidate(As,Ps,Ts,Bs,AggOps,mu=mu) + x = self.__develop_new_candidate(As,Ps,Ts,Bs,AggOps,mu=mu) B = hstack((B,x)) As,Ps,Ts,Bs = sa_hierarchy(A,B,AggOps) @@ -174,7 +174,7 @@ max_coarse = 0 max_levels = len(aggregation) + 1 - # aSA parameters + # aSA parameters # mu - number of test relaxation iterations # epsilon - minimum acceptable relaxation convergence factor @@ -307,7 +307,7 @@ aggregation = None #A = poisson_problem2D(200,1e-2) - #aggregation = [ sa_constant_interpolation(A*A*A,epsilon=0.0) ] + #aggregation = [ sa_constant_interpolation(A*A*A,epsilon=0.0) ] #A = io.mmread("tests/sample_data/laplacian_41_3dcube.mtx").tocsr() #A = io.mmread("laplacian_40_3dcube.mtx").tocsr() @@ -373,7 +373,7 @@ pcolor(x.reshape(sqrt(len(x)),sqrt(len(x)))) show() - + for c in asa.Bs[0].T: #plot2d(c) plot2d_arrows(c) Modified: branches/scipy.scons/scipy/sandbox/multigrid/dec_test.py =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/dec_test.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/dec_test.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -30,10 +30,10 @@ def curl_curl_prolongator(D_nodal,vertices): if not isspmatrix_csr(D_nodal): raise TypeError('expected csr_matrix') - + A = D_nodal.T.tocsr() * D_nodal aggs = multigridtools.sa_get_aggregates(A.shape[0],A.indptr,A.indices) - + num_edges = D_nodal.shape[0] num_basis = vertices.shape[1] num_aggs = aggs.max() + 1 @@ -52,9 +52,9 @@ return coo_matrix((data,(row,col)),dims=(num_edges,num_basis*num_aggs)).tocsr() - + def whitney_innerproduct_cache(cmplx,k): h = hash(cmplx.vertices.tostring()) ^ hash(cmplx.simplices.tostring()) ^ hash(k) @@ -102,33 +102,33 @@ Mi = whitney_innerproduct_cache(cmplx,i+1) else: Mi = regular_cube_innerproduct(cmplx,i+1) - - + + dimension = mesh['vertices'].shape[1] if True: - + d0 = cmplx[0].d d1 = cmplx[1].d - + #A = (d1.T.tocsr() * d1 + d0 * d0.T.tocsr()).astype('d') A = (d1.T.tocsr() * d1).astype('d') - + P = curl_curl_prolongator(d0,mesh['vertices']) - + num_blocks = P.shape[1]/dimension blocks = arange(num_blocks).repeat(dimension) - + P = sa_smoothed_prolongator(A,P,epsilon=0,omega=4.0/3.0) - + PAP = P.T.tocsr() * A * P - + candidates = None candidates = zeros((num_blocks,dimension,dimension)) for n in range(dimension): candidates[:,n,n] = 1.0 candidates = candidates.reshape(-1,dimension) - + ml = smoothed_aggregation_solver(PAP,epsilon=0.0,candidates=candidates,blocks=blocks) #A = PAP ml = multilevel_solver([A] + ml.As, [P] + ml.Ps) @@ -138,16 +138,16 @@ while len(bh) < 3: bh.coarsen() print repr(bh) - + N = len(cochain_complex) - 1 - + B = bh[0][N - i].B - + A = (B.T.tocsr() * B).astype('d') #A = B.T.tocsr() * Mi * B - + constant_prolongators = [lvl[N - i].I for lvl in bh[:-1]] - + method = 'aSA' if method == 'RS': @@ -157,28 +157,28 @@ Ps.append( sa_smoothed_prolongator(As[-1],T,epsilon=0.0,omega=4.0/3.0) ) As.append(Ps[-1].T.tocsr() * As[-1] * Ps[-1]) ml = multilevel_solver(As,Ps) - + else: if method == 'BSA': - if i == 0: + if i == 0: candidates = None else: candidates = cmplx[0].d * mesh['vertices'] K = candidates.shape[1] - + constant_prolongators = [constant_prolongators[0]] + \ [expand_into_blocks(T,K,1).tocsr() for T in constant_prolongators[1:] ] ml = smoothed_aggregation_solver(A,candidates,aggregation=constant_prolongators) elif method == 'aSA': - asa = adaptive_sa_solver(A,aggregation=constant_prolongators,max_candidates=dimension,epsilon=0.0) + asa = adaptive_sa_solver(A,aggregation=constant_prolongators,max_candidates=dimension,epsilon=0.0) ml = asa.solver else: raise ValuerError,'unknown method' - + #ml = smoothed_aggregation_solver(A,candidates) - #x = d0 * mesh['vertices'][:,0] + #x = d0 * mesh['vertices'][:,0] x = rand(A.shape[0]) b = zeros_like(x) #b = A*rand(A.shape[0]) Copied: branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/README.txt (from rev 3553, trunk/scipy/sandbox/multigrid/multigridtools/README.txt) Modified: branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.i =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.i 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.i 2007-11-21 12:32:02 UTC (rev 3557) @@ -62,6 +62,7 @@ I_IN_ARRAY1( int ) +I_IN_ARRAY1( long long ) T_IN_ARRAY1( float ) T_IN_ARRAY1( double ) @@ -103,6 +104,7 @@ %enddef I_ARRAY_ARGOUT( int ) +I_ARRAY_ARGOUT( long long ) T_ARRAY_ARGOUT( float ) T_ARRAY_ARGOUT( double ) @@ -125,6 +127,7 @@ %enddef I_INPLACE_ARRAY1( int ) +I_INPLACE_ARRAY1( long long ) T_INPLACE_ARRAY1( float ) T_INPLACE_ARRAY1( double ) @@ -140,12 +143,14 @@ %define INSTANTIATE_BOTH( f_name ) %template(f_name) f_name; %template(f_name) f_name; +%template(f_name) f_name; +%template(f_name) f_name; /* 64-bit indices would go here */ %enddef %define INSTANTIATE_INDEX( f_name ) %template(f_name) f_name; -/* 64-bit indices would go here */ +%template(f_name) f_name; %enddef %define INSTANTIATE_DATA( f_name ) Modified: branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.py =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -53,71 +53,84 @@ F_NODE = _multigridtools.F_NODE def sa_get_aggregates(*args): - """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)""" - return _multigridtools.sa_get_aggregates(*args) + """sa_get_aggregates(int n_row, int Ap, int Aj, std::vector<(int)> Bj)""" + return _multigridtools.sa_get_aggregates(*args) def rs_strong_connections(*args): - """ - rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp, - std::vector<(int)> Sj, - std::vector<(float)> Sx) - rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(double)> Sx) """ - return _multigridtools.rs_strong_connections(*args) + rs_strong_connections(int n_row, float theta, int Ap, int Aj, float Ax, std::vector<(int)> Sp, + std::vector<(int)> Sj, + std::vector<(float)> Sx) + rs_strong_connections(int n_row, double theta, int Ap, int Aj, double Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(double)> Sx) + """ + return _multigridtools.rs_strong_connections(*args) def rs_interpolation(*args): - """ - rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj, - float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj, - double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) """ - return _multigridtools.rs_interpolation(*args) + rs_interpolation(int n_nodes, int Ap, int Aj, float Ax, int Sp, int Sj, + float Sx, int Tp, int Tj, float Tx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + rs_interpolation(int n_nodes, int Ap, int Aj, double Ax, int Sp, int Sj, + double Sx, int Tp, int Tj, double Tx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + """ + return _multigridtools.rs_interpolation(*args) def sa_strong_connections(*args): - """ - sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(float)> Sx) - sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax, - std::vector<(int)> Sp, std::vector<(int)> Sj, - std::vector<(double)> Sx) """ - return _multigridtools.sa_strong_connections(*args) + sa_strong_connections(int n_row, float epsilon, int Ap, int Aj, float Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(float)> Sx) + sa_strong_connections(int n_row, double epsilon, int Ap, int Aj, double Ax, + std::vector<(int)> Sp, std::vector<(int)> Sj, + std::vector<(double)> Sx) + """ + return _multigridtools.sa_strong_connections(*args) def sa_smoother(*args): - """ - sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp, - int Sj, float Sx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax, - int Sp, int Sj, double Sx, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) """ - return _multigridtools.sa_smoother(*args) + sa_smoother(int n_row, float omega, int Ap, int Aj, float Ax, int Sp, + int Sj, float Sx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + sa_smoother(int n_row, double omega, int Ap, int Aj, double Ax, + int Sp, int Sj, double Sx, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + """ + return _multigridtools.sa_smoother(*args) def gauss_seidel(*args): - """ - gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b, - int row_start, int row_stop, int row_step) - gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, - int row_start, int row_stop, int row_step) """ - return _multigridtools.gauss_seidel(*args) + gauss_seidel(int n_row, int Ap, int Aj, float Ax, float x, float b, + int row_start, int row_stop, int row_step) + gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, + int row_start, int row_stop, int row_step) + gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax, + float x, float b, long long row_start, long long row_stop, + long long row_step) + gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax, + double x, double b, long long row_start, + long long row_stop, long long row_step) + """ + return _multigridtools.gauss_seidel(*args) def jacobi(*args): - """ - jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, - float temp, int row_start, int row_stop, - int row_step, float omega) - jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, - double temp, int row_start, int row_stop, - int row_step, double omega) """ - return _multigridtools.jacobi(*args) - + jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, + float temp, int row_start, int row_stop, + int row_step, float omega) + jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, + double temp, int row_start, int row_stop, + int row_step, double omega) + jacobi(long long n_row, long long Ap, long long Aj, float Ax, + float x, float b, float temp, long long row_start, + long long row_stop, long long row_step, + float omega) + jacobi(long long n_row, long long Ap, long long Aj, double Ax, + double x, double b, double temp, long long row_start, + long long row_stop, long long row_step, + double omega) + """ + return _multigridtools.jacobi(*args) Modified: branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/multigridtools/multigridtools_wrap.cxx 2007-11-21 12:32:02 UTC (rev 3557) @@ -3099,6 +3099,43 @@ return res; } + +SWIGINTERN int +SWIG_AsVal_long_SS_long (PyObject *obj, long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + long long v = PyLong_AsLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } else { + long v; + res = SWIG_AsVal_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} + #ifdef __cplusplus extern "C" { #endif @@ -5216,6 +5253,278 @@ } +SWIGINTERN PyObject *_wrap_gauss_seidel__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + float *arg4 ; + float *arg5 ; + float *arg6 ; + long long arg7 ; + long long arg8 ; + long long arg9 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + long long val7 ; + int ecode7 = 0 ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:gauss_seidel",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gauss_seidel" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (float*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (float*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (float*) array6->data; + } + ecode7 = SWIG_AsVal_long_SS_long(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gauss_seidel" "', argument " "7"" of type '" "long long""'"); + } + arg7 = static_cast< long long >(val7); + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "gauss_seidel" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "gauss_seidel" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + gauss_seidel(arg1,(long long const (*))arg2,(long long const (*))arg3,(float const (*))arg4,arg5,(float const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_gauss_seidel__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + double *arg4 ; + double *arg5 ; + double *arg6 ; + long long arg7 ; + long long arg8 ; + long long arg9 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + long long val7 ; + int ecode7 = 0 ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:gauss_seidel",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gauss_seidel" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (double*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (double*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (double*) array6->data; + } + ecode7 = SWIG_AsVal_long_SS_long(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gauss_seidel" "', argument " "7"" of type '" "long long""'"); + } + arg7 = static_cast< long long >(val7); + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "gauss_seidel" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "gauss_seidel" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + gauss_seidel(arg1,(long long const (*))arg2,(long long const (*))arg3,(double const (*))arg4,arg5,(double const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + SWIGINTERN PyObject *_wrap_gauss_seidel(PyObject *self, PyObject *args) { int argc; PyObject *argv[10]; @@ -5332,9 +5641,115 @@ } } } + if (argc == 9) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_gauss_seidel__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + } + if (argc == 9) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_gauss_seidel__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'gauss_seidel'.\n Possible C/C++ prototypes are:\n"" gauss_seidel<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],int const,int const,int const)\n"" gauss_seidel<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],int const,int const,int const)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'gauss_seidel'.\n Possible C/C++ prototypes are:\n"" gauss_seidel<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],int const,int const,int const)\n"" gauss_seidel<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],int const,int const,int const)\n"" gauss_seidel<(long long,float)>(long long const,long long const [],long long const [],float const [],float [],float const [],long long const,long long const,long long const)\n"" gauss_seidel<(long long,double)>(long long const,long long const [],long long const [],double const [],double [],double const [],long long const,long long const,long long const)\n"); return NULL; } @@ -5645,6 +6060,312 @@ } +SWIGINTERN PyObject *_wrap_jacobi__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + float *arg4 ; + float *arg5 ; + float *arg6 ; + float *arg7 ; + long long arg8 ; + long long arg9 ; + long long arg10 ; + float arg11 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *temp7 = NULL ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + long long val10 ; + int ecode10 = 0 ; + float val11 ; + int ecode11 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOO:jacobi",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "jacobi" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_FLOAT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (float*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (float*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (float*) array6->data; + } + { + temp7 = obj_to_array_no_conversion(obj6,PyArray_FLOAT); + if (!temp7 || !require_contiguous(temp7) || !require_native(temp7)) SWIG_fail; + arg7 = (float*) array_data(temp7); + } + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "jacobi" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "jacobi" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + ecode10 = SWIG_AsVal_long_SS_long(obj9, &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "jacobi" "', argument " "10"" of type '" "long long""'"); + } + arg10 = static_cast< long long >(val10); + ecode11 = SWIG_AsVal_float(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "jacobi" "', argument " "11"" of type '" "float""'"); + } + arg11 = static_cast< float >(val11); + jacobi(arg1,(long long const (*))arg2,(long long const (*))arg3,(float const (*))arg4,arg5,(float const (*))arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_jacobi__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long long arg1 ; + long long *arg2 ; + long long *arg3 ; + double *arg4 ; + double *arg5 ; + double *arg6 ; + double *arg7 ; + long long arg8 ; + long long arg9 ; + long long arg10 ; + double arg11 ; + long long val1 ; + int ecode1 = 0 ; + PyArrayObject *array2 = NULL ; + int is_new_object2 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *temp5 = NULL ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *temp7 = NULL ; + long long val8 ; + int ecode8 = 0 ; + long long val9 ; + int ecode9 = 0 ; + long long val10 ; + int ecode10 = 0 ; + double val11 ; + int ecode11 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOO:jacobi",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10)) SWIG_fail; + ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "jacobi" "', argument " "1"" of type '" "long long""'"); + } + arg1 = static_cast< long long >(val1); + { + npy_intp size[1] = { + -1 + }; + array2 = obj_to_array_contiguous_allow_conversion(obj1, PyArray_LONGLONG, &is_new_object2); + if (!array2 || !require_dimensions(array2,1) || !require_size(array2,size,1) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (long long*) array2->data; + } + { + npy_intp size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGLONG, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (long long*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_DOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (double*) array4->data; + } + { + temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); + if (!temp5 || !require_contiguous(temp5) || !require_native(temp5)) SWIG_fail; + arg5 = (double*) array_data(temp5); + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (double*) array6->data; + } + { + temp7 = obj_to_array_no_conversion(obj6,PyArray_DOUBLE); + if (!temp7 || !require_contiguous(temp7) || !require_native(temp7)) SWIG_fail; + arg7 = (double*) array_data(temp7); + } + ecode8 = SWIG_AsVal_long_SS_long(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "jacobi" "', argument " "8"" of type '" "long long""'"); + } + arg8 = static_cast< long long >(val8); + ecode9 = SWIG_AsVal_long_SS_long(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "jacobi" "', argument " "9"" of type '" "long long""'"); + } + arg9 = static_cast< long long >(val9); + ecode10 = SWIG_AsVal_long_SS_long(obj9, &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "jacobi" "', argument " "10"" of type '" "long long""'"); + } + arg10 = static_cast< long long >(val10); + ecode11 = SWIG_AsVal_double(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "jacobi" "', argument " "11"" of type '" "double""'"); + } + arg11 = static_cast< double >(val11); + jacobi(arg1,(long long const (*))arg2,(long long const (*))arg3,(double const (*))arg4,arg5,(double const (*))arg6,arg7,arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object2 && array2) Py_DECREF(array2); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + SWIGINTERN PyObject *_wrap_jacobi(PyObject *self, PyObject *args) { int argc; PyObject *argv[12]; @@ -5783,9 +6504,137 @@ } } } + if (argc == 11) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[9], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_float(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_jacobi__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + } + } + } + if (argc == 11) { + int _v; + { + int res = SWIG_AsVal_long_SS_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[8], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long_SS_long(argv[9], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_jacobi__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + } + } + } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'jacobi'.\n Possible C/C++ prototypes are:\n"" jacobi<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],float [],int const,int const,int const,float const)\n"" jacobi<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],double [],int const,int const,int const,double const)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'jacobi'.\n Possible C/C++ prototypes are:\n"" jacobi<(int,float)>(int const,int const [],int const [],float const [],float [],float const [],float [],int const,int const,int const,float const)\n"" jacobi<(int,double)>(int const,int const [],int const [],double const [],double [],double const [],double [],int const,int const,int const,double const)\n"" jacobi<(long long,float)>(long long const,long long const [],long long const [],float const [],float [],float const [],float [],long long const,long long const,long long const,float const)\n"" jacobi<(long long,double)>(long long const,long long const [],long long const [],double const [],double [],double const [],double [],long long const,long long const,long long const,double const)\n"); return NULL; } @@ -5829,6 +6678,12 @@ " int row_start, int row_stop, int row_step)\n" "gauss_seidel(int n_row, int Ap, int Aj, double Ax, double x, double b, \n" " int row_start, int row_stop, int row_step)\n" + "gauss_seidel(long long n_row, long long Ap, long long Aj, float Ax, \n" + " float x, float b, long long row_start, long long row_stop, \n" + " long long row_step)\n" + "gauss_seidel(long long n_row, long long Ap, long long Aj, double Ax, \n" + " double x, double b, long long row_start, \n" + " long long row_stop, long long row_step)\n" ""}, { (char *)"jacobi", _wrap_jacobi, METH_VARARGS, (char *)"\n" "jacobi(int n_row, int Ap, int Aj, float Ax, float x, float b, \n" @@ -5837,6 +6692,14 @@ "jacobi(int n_row, int Ap, int Aj, double Ax, double x, double b, \n" " double temp, int row_start, int row_stop, \n" " int row_step, double omega)\n" + "jacobi(long long n_row, long long Ap, long long Aj, float Ax, \n" + " float x, float b, float temp, long long row_start, \n" + " long long row_stop, long long row_step, \n" + " float omega)\n" + "jacobi(long long n_row, long long Ap, long long Aj, double Ax, \n" + " double x, double b, double temp, long long row_start, \n" + " long long row_stop, long long row_step, \n" + " double omega)\n" ""}, { NULL, NULL, 0, NULL } }; Modified: branches/scipy.scons/scipy/sandbox/multigrid/multilevel.py =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/multilevel.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/multilevel.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -43,7 +43,7 @@ References: "Multigrid" - Trottenberg, U., C. W. Oosterlee, and Anton Schuller. + Trottenberg, U., C. W. Oosterlee, and Anton Schuller. San Diego: Academic Press, 2001. Appendix A @@ -60,9 +60,9 @@ Ps.append(P) return multilevel_solver(As,Ps) - + def smoothed_aggregation_solver(A, B=None, blocks=None, \ aggregation=None, max_levels=10, \ max_coarse=500, epsilon=0.0, \ @@ -98,12 +98,12 @@ Strength of connection parameter used in aggregation. omega: {float} : default 4.0/3.0 Damping parameter used in prolongator smoothing (0 < omega < 2) - symmetric: {boolean} : default True + symmetric: {boolean} : default True True if A is symmetric, False otherwise rescale: {boolean} : default True If True, symmetrically rescale A by the diagonal i.e. A -> D * A * D, where D is diag(A)^-0.5 - + *Example*: TODO @@ -120,17 +120,17 @@ B = asarray(B) pre,post = None,None #preprocess/postprocess - + if rescale: D_sqrt,D_sqrt_inv,A = symmetric_rescaling(A) D_sqrt,D_sqrt_inv = diag_sparse(D_sqrt),diag_sparse(D_sqrt_inv) - + B = D_sqrt * B #scale candidates def pre(x,b): return D_sqrt*x,D_sqrt_inv*b def post(x): return D_sqrt_inv*x - + As = [A] Ps = [] Modified: branches/scipy.scons/scipy/sandbox/multigrid/tests/test_utils.py =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/tests/test_utils.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -59,7 +59,7 @@ cases = [] cases.append( diag_sparse(array([1,2,3,4])) ) cases.append( diag_sparse(array([1,0,3,4])) ) - + A = array([ [ 5.5, 3.5, 4.8], [ 2. , 9.9, 0.5], [ 6.5, 2.6, 5.7]]) Modified: branches/scipy.scons/scipy/sandbox/multigrid/utils.py =================================================================== --- branches/scipy.scons/scipy/sandbox/multigrid/utils.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sandbox/multigrid/utils.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -61,11 +61,11 @@ D_sqrt = sqrt(D) D_sqrt_inv = 1.0/D_sqrt D_sqrt_inv[mask] = 0 - + #TODO time this against simple implementation data = A.data * D_sqrt_inv[A.indices] data *= D_sqrt_inv[arange(A.shape[0]).repeat(diff(A.indptr))] - + DAD = A.__class__((data,A.indices,A.indptr),dims=A.shape) return D_sqrt,D_sqrt_inv,DAD Modified: branches/scipy.scons/scipy/sparse/sparse.py =================================================================== --- branches/scipy.scons/scipy/sparse/sparse.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sparse/sparse.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -92,7 +92,7 @@ def set_shape(self,shape): shape = tuple(shape) - + if len(shape) != 2: raise ValueError("Only two-dimensional sparse arrays " "are supported.") @@ -103,7 +103,7 @@ if not (shape[0] >= 1 and shape[1] >= 1): raise TypeError,'invalid shape' - + if (self._shape != shape) and (self._shape is not None): try: self = self.reshape(shape) @@ -518,17 +518,17 @@ def _set_self(self, other, copy=False): """take the member variables of other and assign them to self""" - + if copy: other = other.copy() - + self.data = other.data self.indices = other.indices self.indptr = other.indptr self.shape = other.shape self.dtype = other.data.dtype - + def _check_format(self, orientation, full_check): # some functions pass floats self.shape = tuple([int(x) for x in self.shape]) @@ -988,14 +988,14 @@ self._set_self( other ) else: - raise ValueError, "unrecognized form for csc_matrix constructor" + raise ValueError, "unrecognized form for csc_matrix constructor" # Read matrix dimensions given, if any if dims is not None: self.shape = dims # spmatrix will check for errors else: - if self.shape is None: + if self.shape is None: # shape not already set, try to infer dimensions try: M = self.indices.max() + 1 @@ -1238,7 +1238,7 @@ if copy: arg1 = arg1.copy() self._set_self( self._tothis(arg1) ) - + elif isinstance(arg1, tuple): if isshape(arg1): # It's a tuple of matrix dimensions (M, N) @@ -1270,7 +1270,7 @@ other = coo_matrix((data, ij), dims=dims ) other = self._tothis(other) self._set_self( other ) - + else: raise ValueError, "unrecognized form for csr_matrix constructor" @@ -1278,7 +1278,7 @@ if dims is not None: self.shape = dims # spmatrix will check for errors else: - if self.shape is None: + if self.shape is None: # shape not already set, try to infer dimensions try: M = len(self.indptr) - 1 Modified: branches/scipy.scons/scipy/sparse/sparsetools/sparsetools.py =================================================================== --- branches/scipy.scons/scipy/sparse/sparsetools/sparsetools.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/sparse/sparsetools/sparsetools.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -51,1609 +51,1608 @@ def extract_csr_diagonal(*args): - """ - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(signed char)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(unsigned char)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(long long)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(npy_cfloat_wrapper)> Yx) - extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(npy_cdouble_wrapper)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(signed char)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(unsigned char)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(short)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(int)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(float)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(double)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) - extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.extract_csr_diagonal(*args) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(signed char)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(unsigned char)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(long long)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(npy_cfloat_wrapper)> Yx) + extract_csr_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(npy_cdouble_wrapper)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(signed char)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(unsigned char)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(short)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(int)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(float)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(double)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) + extract_csr_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.extract_csr_diagonal(*args) def extract_csc_diagonal(*args): - """ - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(signed char)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(unsigned char)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(long long)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(npy_cfloat_wrapper)> Yx) - extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(npy_cdouble_wrapper)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(signed char)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(unsigned char)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(short)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(int)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(float)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(double)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) - extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.extract_csc_diagonal(*args) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(signed char)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(unsigned char)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(short)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(long long)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(float)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(double)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(npy_cfloat_wrapper)> Yx) + extract_csc_diagonal(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(npy_cdouble_wrapper)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(signed char)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(unsigned char)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(short)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(int)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(float)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(double)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(npy_cfloat_wrapper)> Yx) + extract_csc_diagonal(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.extract_csc_diagonal(*args) def csrtocsc(*args): - """ - csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(signed char)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(unsigned char)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(short)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(int)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long long)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(float)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, - std::vector<(int)> Bi, std::vector<(double)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(signed char)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(short)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(int)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(long long)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(float)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, std::vector<(double)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csrtocsc(*args) + csrtocsc(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(signed char)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(unsigned char)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(short)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(int)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long long)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(float)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(double)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(signed char)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(unsigned char)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(short)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(int)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(long long)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(float)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, std::vector<(double)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocsc(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csrtocsc(*args) def csctocsr(*args): - """ - csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csctocsr(*args) + csctocsr(int n_row, int n_col, int Ap, int Ai, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocsr(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csctocsr(*args) def csrtocoo(*args): - """ - csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csrtocoo(*args) + csrtocoo(int n_row, int n_col, int Ap, int Aj, signed char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, short Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, long long Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csrtocoo(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csrtocoo(*args) def csctocoo(*args): - """ - csctocoo(int n_row, int n_col, int Ap, int Ai, signed char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(short)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(int)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, long long Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(signed char)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(short)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(int)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(long long)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(float)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, std::vector<(double)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, - std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.csctocoo(*args) + csctocoo(int n_row, int n_col, int Ap, int Ai, signed char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, short Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(short)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, long long Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(signed char)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(unsigned char)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(short)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(int)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(long long)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(float)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, std::vector<(double)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + csctocoo(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, std::vector<(long long)> Bi, + std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.csctocoo(*args) def cootocsr(*args): - """ - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(signed char)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(unsigned char)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(short)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(int)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long long)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(float)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(double)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(signed char)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(unsigned char)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(short)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(int)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(long long)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(float)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(double)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cfloat_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cdouble_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.cootocsr(*args) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(signed char)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(unsigned char)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(short)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(int)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long long)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(float)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(double)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(signed char)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(unsigned char)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(short)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(int)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(long long)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(float)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(double)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cfloat_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsr(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cdouble_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.cootocsr(*args) def cootocsc(*args): - """ - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(signed char)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(unsigned char)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(short)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(int)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long long)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(float)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(double)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, signed char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(signed char)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, unsigned char Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(unsigned char)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, short Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(short)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, int Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(int)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, long long Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(long long)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, float Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(float)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, double Ax, std::vector<(long long)> Bp, - std::vector<(long long)> Bi, - std::vector<(double)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cfloat_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bi, - std::vector<(npy_cfloat_wrapper)> Bx) - cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, - long long Aj, npy_cdouble_wrapper Ax, - std::vector<(long long)> Bp, std::vector<(long long)> Bi, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.cootocsc(*args) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, signed char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(signed char)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, unsigned char Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(unsigned char)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, short Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(short)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(int)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long long)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(float)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(double)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble_wrapper Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, signed char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(signed char)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, unsigned char Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(unsigned char)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, short Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(short)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, int Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(int)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, long long Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(long long)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, float Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(float)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, double Ax, std::vector<(long long)> Bp, + std::vector<(long long)> Bi, + std::vector<(double)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cfloat_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bi, + std::vector<(npy_cfloat_wrapper)> Bx) + cootocsc(long long n_row, long long n_col, long long NNZ, long long Ai, + long long Aj, npy_cdouble_wrapper Ax, + std::vector<(long long)> Bp, std::vector<(long long)> Bi, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.cootocsc(*args) def csrmucsr(*args): - """ - csrmucsr(int n_row, int n_col, int Ap, int Aj, signed char Ax, - int Bp, int Bj, signed char Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(signed char)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - int Bp, int Bj, unsigned char Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(int)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, long long Ax, - int Bp, int Bj, long long Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(double)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - int Bp, int Bj, npy_cfloat_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - int Bp, int Bj, npy_cdouble_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.csrmucsr(*args) + csrmucsr(int n_row, int n_col, int Ap, int Aj, signed char Ax, + int Bp, int Bj, signed char Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(signed char)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + int Bp, int Bj, unsigned char Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(int)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, long long Ax, + int Bp, int Bj, long long Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(double)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + int Bp, int Bj, npy_cfloat_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + int Bp, int Bj, npy_cdouble_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csrmucsr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.csrmucsr(*args) def cscmucsc(*args): - """ - cscmucsc(int n_row, int n_col, int Ap, int Ai, signed char Ax, - int Bp, int Bi, signed char Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(signed char)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - int Bp, int Bi, unsigned char Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(int)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, long long Ax, - int Bp, int Bi, long long Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(double)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - int Bp, int Bi, npy_cfloat_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - int Bp, int Bi, npy_cdouble_wrapper Bx, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.cscmucsc(*args) + cscmucsc(int n_row, int n_col, int Ap, int Ai, signed char Ax, + int Bp, int Bi, signed char Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(signed char)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + int Bp, int Bi, unsigned char Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(int)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, long long Ax, + int Bp, int Bi, long long Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(double)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + int Bp, int Bi, npy_cfloat_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + int Bp, int Bi, npy_cdouble_wrapper Bx, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + cscmucsc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.cscmucsc(*args) def csrmux(*args): - """ - csrmux(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Xx, std::vector<(signed char)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Xx, std::vector<(unsigned char)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, - std::vector<(short)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, - std::vector<(int)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Xx, std::vector<(long long)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, - std::vector<(float)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, - std::vector<(double)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, signed char Xx, std::vector<(signed char)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, unsigned char Xx, - std::vector<(unsigned char)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, short Xx, std::vector<(short)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, int Xx, std::vector<(int)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Xx, std::vector<(long long)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, float Xx, std::vector<(float)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, double Xx, std::vector<(double)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - std::vector<(npy_cfloat_wrapper)> Yx) - csrmux(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.csrmux(*args) + csrmux(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Xx, std::vector<(signed char)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Xx, std::vector<(unsigned char)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, short Ax, short Xx, + std::vector<(short)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, + std::vector<(int)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Xx, std::vector<(long long)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, + std::vector<(float)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, + std::vector<(double)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, signed char Xx, std::vector<(signed char)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, unsigned char Xx, + std::vector<(unsigned char)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, short Xx, std::vector<(short)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, int Xx, std::vector<(int)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Xx, std::vector<(long long)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, float Xx, std::vector<(float)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, double Xx, std::vector<(double)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + std::vector<(npy_cfloat_wrapper)> Yx) + csrmux(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.csrmux(*args) def cscmux(*args): - """ - cscmux(int n_row, int n_col, int Ap, int Ai, signed char Ax, - signed char Xx, std::vector<(signed char)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, - unsigned char Xx, std::vector<(unsigned char)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, - std::vector<(short)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, - std::vector<(int)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, long long Ax, - long long Xx, std::vector<(long long)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, - std::vector<(float)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, - std::vector<(double)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, signed char Xx, std::vector<(signed char)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, unsigned char Xx, - std::vector<(unsigned char)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, short Xx, std::vector<(short)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, int Xx, std::vector<(int)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Xx, std::vector<(long long)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, float Xx, std::vector<(float)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, double Xx, std::vector<(double)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, - std::vector<(npy_cfloat_wrapper)> Yx) - cscmux(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, - std::vector<(npy_cdouble_wrapper)> Yx) """ - return _sparsetools.cscmux(*args) + cscmux(int n_row, int n_col, int Ap, int Ai, signed char Ax, + signed char Xx, std::vector<(signed char)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, unsigned char Ax, + unsigned char Xx, std::vector<(unsigned char)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, short Ax, short Xx, + std::vector<(short)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, + std::vector<(int)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, long long Ax, + long long Xx, std::vector<(long long)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, + std::vector<(float)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, + std::vector<(double)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, std::vector<(npy_cfloat_wrapper)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, std::vector<(npy_cdouble_wrapper)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, signed char Xx, std::vector<(signed char)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, unsigned char Xx, + std::vector<(unsigned char)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, short Xx, std::vector<(short)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, int Xx, std::vector<(int)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Xx, std::vector<(long long)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, float Xx, std::vector<(float)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, double Xx, std::vector<(double)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + std::vector<(npy_cfloat_wrapper)> Yx) + cscmux(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + std::vector<(npy_cdouble_wrapper)> Yx) + """ + return _sparsetools.cscmux(*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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_elmul_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_eldiv_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_eldiv_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_plus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_plus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, - int Bj, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(short)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, - int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long long)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, - int Bj, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(float)> Cx) - csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, - int Bj, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long Bp, long long Bj, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(signed char)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long Bp, long long Bj, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long Bp, long long Bj, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(short)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long Bp, long long Bj, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(int)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Bp, long long Bj, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(long long)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long Bp, long long Bj, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, - std::vector<(float)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long Bp, long long Bj, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, std::vector<(double)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long Bp, - long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cfloat_wrapper)> Cx) - csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long Bp, - long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Cj, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(unsigned char)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, short Ax, int Bp, + int Bj, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(short)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long long)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csr_minus_csr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long Bp, long long Bj, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(signed char)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long Bp, long long Bj, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(unsigned char)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long Bp, long long Bj, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(short)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long Bp, long long Bj, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(int)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Bp, long long Bj, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(long long)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long Bp, long long Bj, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Cj, + std::vector<(float)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long Bp, long long Bj, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, std::vector<(double)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long Bp, + long long Bj, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cfloat_wrapper)> Cx) + csr_minus_csr(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long Bp, + long long Bj, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Cj, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.csr_minus_csr(*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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_elmul_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_eldiv_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_eldiv_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_plus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_plus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, - int Bi, short Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(short)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, - int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long long)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, - int Bi, float Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(float)> Cx) - csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, - int Bi, double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(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, - std::vector<(int)> Cp, std::vector<(int)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax, long long Bp, long long Bi, - signed char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(signed char)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax, long long Bp, long long Bi, - unsigned char Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax, long long Bp, long long Bi, - short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(short)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax, long long Bp, long long Bi, - int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(int)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax, long long Bp, long long Bi, - long long Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(long long)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax, long long Bp, long long Bi, - float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, - std::vector<(float)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax, long long Bp, long long Bi, - double Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, std::vector<(double)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax, long long Bp, - long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cfloat_wrapper)> Cx) - csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax, long long Bp, - long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, - std::vector<(long long)> Ci, - std::vector<(npy_cdouble_wrapper)> Cx) """ - return _sparsetools.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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(unsigned char)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, short Ax, int Bp, + int Bi, short Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(short)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long long)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + csc_minus_csc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(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, + std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax, long long Bp, long long Bi, + signed char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(signed char)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax, long long Bp, long long Bi, + unsigned char Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(unsigned char)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax, long long Bp, long long Bi, + short Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(short)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax, long long Bp, long long Bi, + int Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(int)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax, long long Bp, long long Bi, + long long Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(long long)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax, long long Bp, long long Bi, + float Bx, std::vector<(long long)> Cp, std::vector<(long long)> Ci, + std::vector<(float)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax, long long Bp, long long Bi, + double Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, std::vector<(double)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax, long long Bp, + long long Bi, npy_cfloat_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cfloat_wrapper)> Cx) + csc_minus_csc(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax, long long Bp, + long long Bi, npy_cdouble_wrapper Bx, std::vector<(long long)> Cp, + std::vector<(long long)> Ci, + std::vector<(npy_cdouble_wrapper)> Cx) + """ + return _sparsetools.csc_minus_csc(*args) def spdiags(*args): - """ - spdiags(int n_row, int n_col, int n_diag, int offsets, signed char diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(signed char)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, unsigned char diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(unsigned char)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, short diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(short)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(int)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, long long diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(long long)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(float)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(double)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat_wrapper diags, - std::vector<(int)> Ap, - std::vector<(int)> Ai, std::vector<(npy_cfloat_wrapper)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble_wrapper diags, - std::vector<(int)> Ap, - std::vector<(int)> Ai, std::vector<(npy_cdouble_wrapper)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, signed char diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(signed char)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, unsigned char diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(unsigned char)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, short diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(short)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, int diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, std::vector<(int)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, long long diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(long long)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, float diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(float)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, double diags, std::vector<(long long)> Ap, - std::vector<(long long)> Ai, - std::vector<(double)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, npy_cfloat_wrapper diags, - std::vector<(long long)> Ap, std::vector<(long long)> Ai, - std::vector<(npy_cfloat_wrapper)> Ax) - spdiags(long long n_row, long long n_col, long long n_diag, - long long offsets, npy_cdouble_wrapper diags, - std::vector<(long long)> Ap, std::vector<(long long)> Ai, - std::vector<(npy_cdouble_wrapper)> Ax) """ - return _sparsetools.spdiags(*args) + spdiags(int n_row, int n_col, int n_diag, int offsets, signed char diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(signed char)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, unsigned char diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(unsigned char)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, short diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(short)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(int)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, long long diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(long long)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(float)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(double)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat_wrapper diags, + std::vector<(int)> Ap, + std::vector<(int)> Ai, std::vector<(npy_cfloat_wrapper)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble_wrapper diags, + std::vector<(int)> Ap, + std::vector<(int)> Ai, std::vector<(npy_cdouble_wrapper)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, signed char diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(signed char)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, unsigned char diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(unsigned char)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, short diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(short)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, int diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, std::vector<(int)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, long long diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(long long)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, float diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(float)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, double diags, std::vector<(long long)> Ap, + std::vector<(long long)> Ai, + std::vector<(double)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, npy_cfloat_wrapper diags, + std::vector<(long long)> Ap, std::vector<(long long)> Ai, + std::vector<(npy_cfloat_wrapper)> Ax) + spdiags(long long n_row, long long n_col, long long n_diag, + long long offsets, npy_cdouble_wrapper diags, + std::vector<(long long)> Ap, std::vector<(long long)> Ai, + std::vector<(npy_cdouble_wrapper)> Ax) + """ + return _sparsetools.spdiags(*args) def csrtodense(*args): - """ - csrtodense(int n_row, int n_col, int Ap, int Aj, signed char Ax, - signed char Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, - unsigned char Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, short Ax, short Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, long long Ax, - long long Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, - npy_cfloat_wrapper Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, - npy_cdouble_wrapper Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, signed char Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, unsigned char Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, short Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, int Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, float Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, double Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, npy_cfloat_wrapper Mx) - csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, npy_cdouble_wrapper Mx) """ - return _sparsetools.csrtodense(*args) + csrtodense(int n_row, int n_col, int Ap, int Aj, signed char Ax, + signed char Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, unsigned char Ax, + unsigned char Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, short Ax, short Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, long long Ax, + long long Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, signed char Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, unsigned char Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, short Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, int Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, float Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, double Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, npy_cfloat_wrapper Mx) + csrtodense(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, npy_cdouble_wrapper Mx) + """ + return _sparsetools.csrtodense(*args) def densetocsr(*args): - """ - densetocsr(int n_row, int n_col, signed char Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(signed char)> Ax) - densetocsr(int n_row, int n_col, unsigned char Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(unsigned char)> Ax) - densetocsr(int n_row, int n_col, short Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(short)> Ax) - densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(int)> Ax) - densetocsr(int n_row, int n_col, long long Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(long long)> Ax) - densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(float)> Ax) - densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(double)> Ax) - densetocsr(int n_row, int n_col, npy_cfloat_wrapper Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_cfloat_wrapper)> Ax) - densetocsr(int n_row, int n_col, npy_cdouble_wrapper Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_cdouble_wrapper)> Ax) - densetocsr(long long n_row, long long n_col, signed char Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(signed char)> Ax) - densetocsr(long long n_row, long long n_col, unsigned char Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(unsigned char)> Ax) - densetocsr(long long n_row, long long n_col, short Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(short)> Ax) - densetocsr(long long n_row, long long n_col, int Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(int)> Ax) - densetocsr(long long n_row, long long n_col, long long Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(long long)> Ax) - densetocsr(long long n_row, long long n_col, float Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(float)> Ax) - densetocsr(long long n_row, long long n_col, double Mx, std::vector<(long long)> Ap, - std::vector<(long long)> Aj, - std::vector<(double)> Ax) - densetocsr(long long n_row, long long n_col, npy_cfloat_wrapper Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(npy_cfloat_wrapper)> Ax) - densetocsr(long long n_row, long long n_col, npy_cdouble_wrapper Mx, - std::vector<(long long)> Ap, std::vector<(long long)> Aj, - std::vector<(npy_cdouble_wrapper)> Ax) """ - return _sparsetools.densetocsr(*args) + densetocsr(int n_row, int n_col, signed char Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(signed char)> Ax) + densetocsr(int n_row, int n_col, unsigned char Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(unsigned char)> Ax) + densetocsr(int n_row, int n_col, short Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(short)> Ax) + densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(int)> Ax) + densetocsr(int n_row, int n_col, long long Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(long long)> Ax) + densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(float)> Ax) + densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(double)> Ax) + densetocsr(int n_row, int n_col, npy_cfloat_wrapper Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cfloat_wrapper)> Ax) + densetocsr(int n_row, int n_col, npy_cdouble_wrapper Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cdouble_wrapper)> Ax) + densetocsr(long long n_row, long long n_col, signed char Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(signed char)> Ax) + densetocsr(long long n_row, long long n_col, unsigned char Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(unsigned char)> Ax) + densetocsr(long long n_row, long long n_col, short Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(short)> Ax) + densetocsr(long long n_row, long long n_col, int Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(int)> Ax) + densetocsr(long long n_row, long long n_col, long long Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(long long)> Ax) + densetocsr(long long n_row, long long n_col, float Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(float)> Ax) + densetocsr(long long n_row, long long n_col, double Mx, std::vector<(long long)> Ap, + std::vector<(long long)> Aj, + std::vector<(double)> Ax) + densetocsr(long long n_row, long long n_col, npy_cfloat_wrapper Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(npy_cfloat_wrapper)> Ax) + densetocsr(long long n_row, long long n_col, npy_cdouble_wrapper Mx, + std::vector<(long long)> Ap, std::vector<(long long)> Aj, + std::vector<(npy_cdouble_wrapper)> Ax) + """ + return _sparsetools.densetocsr(*args) def sort_csr_indices(*args): - """ - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, signed char Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, short Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, int Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, long long Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, float Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, double Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax) - sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sort_csr_indices(*args) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, signed char Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, short Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, int Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, long long Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, float Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, double Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + sort_csr_indices(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax) + sort_csr_indices(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sort_csr_indices(*args) def sort_csc_indices(*args): - """ - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, signed char Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, short Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, int Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, long long Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, float Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, double Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) - sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax) - sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sort_csc_indices(*args) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, signed char Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, short Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, int Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, long long Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, float Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, double Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) + sort_csc_indices(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax) + sort_csc_indices(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sort_csc_indices(*args) def sum_csr_duplicates(*args): - """ - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) - sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax) - sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sum_csr_duplicates(*args) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, signed char Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, unsigned char Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, short Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, int Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, long long Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, float Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, double Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cfloat_wrapper Ax) + sum_csr_duplicates(int n_row, int n_col, int Ap, int Aj, npy_cdouble_wrapper Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax) + sum_csr_duplicates(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sum_csr_duplicates(*args) def sum_csc_duplicates(*args): - """ - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, signed char Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, short Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, int Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, long long Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, float Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, double Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) - sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - signed char Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - unsigned char Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - short Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - int Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - long long Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - float Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - double Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cfloat_wrapper Ax) - sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, - npy_cdouble_wrapper Ax) """ - return _sparsetools.sum_csc_duplicates(*args) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, signed char Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, unsigned char Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, short Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, int Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, long long Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, float Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, double Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cfloat_wrapper Ax) + sum_csc_duplicates(int n_row, int n_col, int Ap, int Ai, npy_cdouble_wrapper Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + signed char Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + unsigned char Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + short Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + int Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + long long Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + float Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + double Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cfloat_wrapper Ax) + sum_csc_duplicates(long long n_row, long long n_col, long long Ap, long long Ai, + npy_cdouble_wrapper Ax) + """ + return _sparsetools.sum_csc_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, 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, 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, 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, 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(long long n_row, long long n_col, long long Ap, long long Aj, - signed char Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(signed char)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - unsigned char Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(unsigned char)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - short Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(short)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - int Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(int)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - long long Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(long long)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - float Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(float)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - double Ax, long long ir0, long long ir1, - long long ic0, long long ic1, std::vector<(long long)> Bp, - std::vector<(long long)> Bj, - std::vector<(double)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cfloat_wrapper Ax, long long ir0, - long long ir1, long long ic0, long long ic1, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cfloat_wrapper)> Bx) - get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, - npy_cdouble_wrapper Ax, long long ir0, - long long ir1, long long ic0, long long ic1, - std::vector<(long long)> Bp, std::vector<(long long)> Bj, - std::vector<(npy_cdouble_wrapper)> Bx) """ - return _sparsetools.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, 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, 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, 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, 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(long long n_row, long long n_col, long long Ap, long long Aj, + signed char Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(signed char)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + unsigned char Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(unsigned char)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + short Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(short)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + int Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(int)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + long long Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(long long)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + float Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(float)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + double Ax, long long ir0, long long ir1, + long long ic0, long long ic1, std::vector<(long long)> Bp, + std::vector<(long long)> Bj, + std::vector<(double)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cfloat_wrapper Ax, long long ir0, + long long ir1, long long ic0, long long ic1, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cfloat_wrapper)> Bx) + get_csr_submatrix(long long n_row, long long n_col, long long Ap, long long Aj, + npy_cdouble_wrapper Ax, long long ir0, + long long ir1, long long ic0, long long ic1, + std::vector<(long long)> Bp, std::vector<(long long)> Bj, + std::vector<(npy_cdouble_wrapper)> Bx) + """ + return _sparsetools.get_csr_submatrix(*args) Modified: branches/scipy.scons/scipy/stats/models/robust/scale.py =================================================================== --- branches/scipy.scons/scipy/stats/models/robust/scale.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/scipy/stats/models/robust/scale.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -49,7 +49,7 @@ tmp = 2 * norm.cdf(c) - 1 gamma = tmp + c**2 * (1 - tmp) - 2 * c * norm.pdf(c) - del tmp + del tmp niter = 30 Modified: branches/scipy.scons/setup.py =================================================================== --- branches/scipy.scons/setup.py 2007-11-21 12:21:03 UTC (rev 3556) +++ branches/scipy.scons/setup.py 2007-11-21 12:32:02 UTC (rev 3557) @@ -44,19 +44,19 @@ os.environ['NO_SCIPY_IMPORT']='SciPy/setup.py' def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration(None, parent_package, top_path) - config.set_options(ignore_setup_xxx_py=True, - assume_default_configuration=True, - delegate_options_to_subpackages=True, - quiet=True) + from numpy.distutils.misc_util import Configuration + config = Configuration(None, parent_package, top_path) + config.set_options(ignore_setup_xxx_py=True, + assume_default_configuration=True, + delegate_options_to_subpackages=True, + quiet=True) - config.add_subpackage('scipy') - config.add_data_files(('scipy','*.txt')) + config.add_subpackage('scipy') + config.add_data_files(('scipy','*.txt')) - config.get_version('scipy/version.py') # sets config.version + config.get_version('scipy/version.py') # sets config.version - return config + return config def setup_package(): From scipy-svn at scipy.org Wed Nov 21 10:28:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 09:28:24 -0600 (CST) Subject: [Scipy-svn] r3558 - branches/scipy.scons/scipy/integrate Message-ID: <20071121152824.2F7EB39C1ED@new.scipy.org> Author: cdavid Date: 2007-11-21 09:27:57 -0600 (Wed, 21 Nov 2007) New Revision: 3558 Added: branches/scipy.scons/scipy/integrate/SConstruct branches/scipy.scons/scipy/integrate/setupscons.py Log: integrate scons build done Added: branches/scipy.scons/scipy/integrate/SConstruct =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-21 12:32:02 UTC (rev 3557) +++ branches/scipy.scons/scipy/integrate/SConstruct 2007-11-21 15:27:57 UTC (rev 3558) @@ -0,0 +1,42 @@ +# Last Change: Wed Nov 21 08:00 PM 2007 J +# vim:syntax=python +from os.path import join as pjoin +import glob + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) + +# XXX: blas/lapack integration + +# Build linpack_lite +src = glob.glob(pjoin('linpack_lite', '*.f')) +linpack_lite = env.NumpyStaticExtLibrary('linpack_lite', source = src) + +# Build mach +src = glob.glob(pjoin('mach', '*.f')) +mach = env.NumpyStaticExtLibrary('mach', source = src) + +# Build quadpack +src = glob.glob(pjoin('quadpack', '*.f')) +quadpack = env.NumpyStaticExtLibrary('quadpack', source = src) + +# Build odepack +src = glob.glob(pjoin('odepack', '*.f')) +odepack = env.NumpyStaticExtLibrary('odepack', source = src) + +env.AppendUnique(LIBS = ['linpack_lite', 'quadpack', 'odepack']) +env.AppendUnique(LIBPATH = env['build_dir']) + +# Build _quadpack +env.NumpyPythonExtension('_quadpack', source = '_quadpackmodule.c') + +# Build _odepack +env.NumpyPythonExtension('_odepack', source = '_odepackmodule.c') + +# Build vode +env.NumpyPythonExtension('vode', source = 'vode.pyf') Copied: branches/scipy.scons/scipy/integrate/setupscons.py (from rev 3557, branches/scipy.scons/scipy/integrate/setup.py) =================================================================== --- branches/scipy.scons/scipy/integrate/setup.py 2007-11-21 12:32:02 UTC (rev 3557) +++ branches/scipy.scons/scipy/integrate/setupscons.py 2007-11-21 15:27:57 UTC (rev 3558) @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +from __future__ import nested_scopes +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('integrate', parent_package, top_path) + + config.add_sconscript('SConstruct') +# blas_opt = get_info('blas_opt',notfound_action=2) +# +# config.add_library('linpack_lite', +# sources=[join('linpack_lite','*.f')]) +# config.add_library('mach', +# sources=[join('mach','*.f')], +# config_fc={'noopt':(__file__,1)}) +# config.add_library('quadpack', +# sources=[join('quadpack','*.f')]) +# config.add_library('odepack', +# sources=[join('odepack','*.f')]) +# # should we try to weed through files and replace with calls to +# # LAPACK routines? +# # Yes, someday... +# +# +# +# # Extensions +# # quadpack: +# +# config.add_extension('_quadpack', +# sources=['_quadpackmodule.c'], +# libraries=['quadpack', 'linpack_lite', 'mach']) +# # odepack +# libs = ['odepack','linpack_lite','mach'] +# +# # Remove libraries key from blas_opt +# if 'libraries' in blas_opt: # key doesn't exist on OS X ... +# libs.extend(blas_opt['libraries']) +# newblas = {} +# for key in blas_opt.keys(): +# if key == 'libraries': +# continue +# newblas[key] = blas_opt[key] +# config.add_extension('_odepack', +# sources=['_odepackmodule.c'], +# libraries=libs, +# **newblas) +# +# # vode +# config.add_extension('vode', +# sources=['vode.pyf'], +# libraries=libs, +# **newblas) + + config.add_data_dir('tests') + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Wed Nov 21 10:49:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 09:49:03 -0600 (CST) Subject: [Scipy-svn] r3559 - branches/scipy.scons/scipy/interpolate Message-ID: <20071121154903.D773339C14D@new.scipy.org> Author: cdavid Date: 2007-11-21 09:48:36 -0600 (Wed, 21 Nov 2007) New Revision: 3559 Added: branches/scipy.scons/scipy/interpolate/SConstruct branches/scipy.scons/scipy/interpolate/setupscons.py Log: scons build done for interpolate Added: branches/scipy.scons/scipy/interpolate/SConstruct =================================================================== --- branches/scipy.scons/scipy/interpolate/SConstruct 2007-11-21 15:27:57 UTC (rev 3558) +++ branches/scipy.scons/scipy/interpolate/SConstruct 2007-11-21 15:48:36 UTC (rev 3559) @@ -0,0 +1,33 @@ +# Last Change: Wed Nov 21 08:00 PM 2007 J +# vim:syntax=python +from os.path import join as pjoin +import glob + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment, CheckF77Clib + +env = GetNumpyEnvironment(ARGUMENTS) + +config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib}) +if not config.CheckF77Clib(): + raise Exception("Could not check F77 runtime, needed for interpolate") +config.Finish() + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +env.AppendUnique(LINKFLAGS = env['F77_LDFLAGS']) + +# Build fitpack +src = glob.glob(pjoin('fitpack', '*.f')) +fitpack = env.NumpyStaticExtLibrary('fitpack', source = src) + +env.AppendUnique(LIBS = ['fitpack']) +env.AppendUnique(LIBPATH = env['build_dir']) + +# Build _fitpack +env.NumpyPythonExtension('_fitpack', source = '_fitpackmodule.c') + +# Build dfitpack +dfitpack_wrap = env.F2PY(pjoin(env['build_dir'], 'dfitpack'), + pjoin(env['build_dir'], 'fitpack.pyf')) +env.NumpyPythonExtension('dfitpack', source = dfitpack_wrap) Copied: branches/scipy.scons/scipy/interpolate/setupscons.py (from rev 3557, branches/scipy.scons/scipy/interpolate/setup.py) =================================================================== --- branches/scipy.scons/scipy/interpolate/setup.py 2007-11-21 12:32:02 UTC (rev 3557) +++ branches/scipy.scons/scipy/interpolate/setupscons.py 2007-11-21 15:48:36 UTC (rev 3559) @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +from os.path import join + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('interpolate', parent_package, top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Wed Nov 21 11:01:59 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 10:01:59 -0600 (CST) Subject: [Scipy-svn] r3560 - branches/scipy.scons/scipy/io Message-ID: <20071121160159.6BA5739C224@new.scipy.org> Author: cdavid Date: 2007-11-21 10:01:50 -0600 (Wed, 21 Nov 2007) New Revision: 3560 Added: branches/scipy.scons/scipy/io/SConstruct branches/scipy.scons/scipy/io/setupscons.py Log: io module build with scons Added: branches/scipy.scons/scipy/io/SConstruct =================================================================== --- branches/scipy.scons/scipy/io/SConstruct 2007-11-21 15:48:36 UTC (rev 3559) +++ branches/scipy.scons/scipy/io/SConstruct 2007-11-21 16:01:50 UTC (rev 3560) @@ -0,0 +1,11 @@ +# Last Change: Thu Oct 18 09:00 PM 2007 J +# vim:syntax=python +from os.path import join + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.NumpyPythonExtension('numpyio', source = 'numpyiomodule.c') Copied: branches/scipy.scons/scipy/io/setupscons.py (from rev 3559, branches/scipy.scons/scipy/io/setup.py) =================================================================== --- branches/scipy.scons/scipy/io/setup.py 2007-11-21 15:48:36 UTC (rev 3559) +++ branches/scipy.scons/scipy/io/setupscons.py 2007-11-21 16:01:50 UTC (rev 3560) @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('io', parent_package, top_path) + + config.add_sconscript('SConstruct') + + config.add_data_dir('tests') + config.add_data_dir('examples') + config.add_data_dir('docs') + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Wed Nov 21 11:03:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 10:03:27 -0600 (CST) Subject: [Scipy-svn] r3561 - branches/scipy.scons/scipy/maxentropy Message-ID: <20071121160327.5D15C39C224@new.scipy.org> Author: cdavid Date: 2007-11-21 10:03:21 -0600 (Wed, 21 Nov 2007) New Revision: 3561 Added: branches/scipy.scons/scipy/maxentropy/setupscons.py Log: maxentropy build with scons Copied: branches/scipy.scons/scipy/maxentropy/setupscons.py (from rev 3559, branches/scipy.scons/scipy/maxentropy/setup.py) From scipy-svn at scipy.org Wed Nov 21 11:04:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 10:04:10 -0600 (CST) Subject: [Scipy-svn] r3562 - branches/scipy.scons/scipy/weave Message-ID: <20071121160410.7289639C273@new.scipy.org> Author: cdavid Date: 2007-11-21 10:04:03 -0600 (Wed, 21 Nov 2007) New Revision: 3562 Added: branches/scipy.scons/scipy/weave/setupscons.py Log: weave now builds with scons Copied: branches/scipy.scons/scipy/weave/setupscons.py (from rev 3559, branches/scipy.scons/scipy/weave/setup.py) From scipy-svn at scipy.org Wed Nov 21 11:09:40 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 10:09:40 -0600 (CST) Subject: [Scipy-svn] r3563 - branches/scipy.scons/scipy/misc Message-ID: <20071121160940.9A65E39C1F1@new.scipy.org> Author: cdavid Date: 2007-11-21 10:09:31 -0600 (Wed, 21 Nov 2007) New Revision: 3563 Added: branches/scipy.scons/scipy/misc/setupscons.py Log: misc now builds with scons Copied: branches/scipy.scons/scipy/misc/setupscons.py (from rev 3562, branches/scipy.scons/scipy/misc/setup.py) From scipy-svn at scipy.org Wed Nov 21 21:45:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 20:45:34 -0600 (CST) Subject: [Scipy-svn] r3564 - in branches/scipy.scons/scipy/ndimage: . segment segment/tests src tests Message-ID: <20071122024534.08C1939C134@new.scipy.org> Author: cdavid Date: 2007-11-21 20:45:18 -0600 (Wed, 21 Nov 2007) New Revision: 3564 Added: branches/scipy.scons/scipy/ndimage/SConstruct branches/scipy.scons/scipy/ndimage/segment/SConstruct branches/scipy.scons/scipy/ndimage/segment/setupscons.py branches/scipy.scons/scipy/ndimage/setupscons.py Modified: branches/scipy.scons/scipy/ndimage/ branches/scipy.scons/scipy/ndimage/segment/ branches/scipy.scons/scipy/ndimage/segment/tests/ branches/scipy.scons/scipy/ndimage/src/ branches/scipy.scons/scipy/ndimage/tests/ Log: ndimage now builds with scons Property changes on: branches/scipy.scons/scipy/ndimage ___________________________________________________________________ Name: svn:ignore - *.pyc *.swp *.pyd *.so + *.pyc *.swp *.pyd *.so Added: branches/scipy.scons/scipy/ndimage/SConstruct =================================================================== --- branches/scipy.scons/scipy/ndimage/SConstruct 2007-11-21 16:09:31 UTC (rev 3563) +++ branches/scipy.scons/scipy/ndimage/SConstruct 2007-11-22 02:45:18 UTC (rev 3564) @@ -0,0 +1,16 @@ +# Last Change: Thu Oct 18 09:00 PM 2007 J +# vim:syntax=python +from os.path import join + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = 'src') + +src = ["nd_image.c", "ni_filters.c", "ni_fourier.c", "ni_interpolation.c", + "ni_measure.c", "ni_morphology.c", "ni_support.c"] + +env.NumpyPythonExtension('_nd_image', source = [join('src', i) for i in src]) Property changes on: branches/scipy.scons/scipy/ndimage/segment ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Added: branches/scipy.scons/scipy/ndimage/segment/SConstruct =================================================================== --- branches/scipy.scons/scipy/ndimage/segment/SConstruct 2007-11-21 16:09:31 UTC (rev 3563) +++ branches/scipy.scons/scipy/ndimage/segment/SConstruct 2007-11-22 02:45:18 UTC (rev 3564) @@ -0,0 +1,14 @@ +# Last Change: Thu Oct 18 09:00 PM 2007 J +# vim:syntax=python +from os.path import join + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = 'src') + +src = ["Segmenter_EXT.c", "Segmenter_IMPL.c"] +env.NumpyPythonExtension('_segmenter', source = src) Copied: branches/scipy.scons/scipy/ndimage/segment/setupscons.py (from rev 3562, branches/scipy.scons/scipy/ndimage/segment/setup.py) =================================================================== --- branches/scipy.scons/scipy/ndimage/segment/setup.py 2007-11-21 16:04:03 UTC (rev 3562) +++ branches/scipy.scons/scipy/ndimage/segment/setupscons.py 2007-11-22 02:45:18 UTC (rev 3564) @@ -0,0 +1,19 @@ + +#!/usr/bin/env python + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('segment', parent_package, top_path) + + config.add_sconscript('SConstruct') + + config.add_data_dir('tests') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) + + Property changes on: branches/scipy.scons/scipy/ndimage/segment/tests ___________________________________________________________________ Name: svn:ignore + *.pyc *.swp *.pyd *.so Copied: branches/scipy.scons/scipy/ndimage/setupscons.py (from rev 3562, branches/scipy.scons/scipy/ndimage/setup.py) =================================================================== --- branches/scipy.scons/scipy/ndimage/setup.py 2007-11-21 16:04:03 UTC (rev 3562) +++ branches/scipy.scons/scipy/ndimage/setupscons.py 2007-11-22 02:45:18 UTC (rev 3564) @@ -0,0 +1,17 @@ +from numpy.distutils.core import setup +from numpy.distutils.misc_util import Configuration +from numpy import get_include + +def configuration(parent_package='', top_path=None): + + config = Configuration('ndimage', parent_package, top_path, + setup_name = 'setupscons.py') + + config.add_sconscript('SConstruct') + config.add_subpackage('segment') + config.add_data_dir('tests') + + return config + +if __name__ == '__main__': + setup(**configuration(top_path='').todict()) Property changes on: branches/scipy.scons/scipy/ndimage/src ___________________________________________________________________ Name: svn:ignore - *.pyc *.swp *.pyd *.so + *.pyc *.swp *.pyd *.so Property changes on: branches/scipy.scons/scipy/ndimage/tests ___________________________________________________________________ Name: svn:ignore - *.pyc *.swp *.pyd *.so + *.pyc *.swp *.pyd *.so From scipy-svn at scipy.org Wed Nov 21 22:20:30 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Nov 2007 21:20:30 -0600 (CST) Subject: [Scipy-svn] r3565 - in branches/scipy.scons/scipy: fftpack integrate interpolate lib lib/blas lib/lapack linalg Message-ID: <20071122032030.50CEC39C27E@new.scipy.org> Author: cdavid Date: 2007-11-21 21:20:10 -0600 (Wed, 21 Nov 2007) New Revision: 3565 Added: branches/scipy.scons/scipy/lib/blas/setupscons.py branches/scipy.scons/scipy/lib/lapack/setupscons.py branches/scipy.scons/scipy/lib/setupscons.py Modified: branches/scipy.scons/scipy/fftpack/SConstruct branches/scipy.scons/scipy/integrate/SConstruct branches/scipy.scons/scipy/interpolate/SConstruct branches/scipy.scons/scipy/linalg/SConstruct Log: Change F2PY calls to F2py for sconscripts Modified: branches/scipy.scons/scipy/fftpack/SConstruct =================================================================== --- branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-22 02:45:18 UTC (rev 3564) +++ branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-22 03:20:10 UTC (rev 3565) @@ -1,4 +1,4 @@ -# Last Change: Wed Nov 21 08:00 PM 2007 J +# Last Change: Thu Nov 22 12:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin import glob @@ -21,11 +21,11 @@ # Build _fftpack src = ['src/zfft.c','src/drfft.c','src/zrfft.c', 'src/zfftnd.c'] -wsrc = env.F2PY(pjoin(env['build_dir'], '_fftpackmodule.c'), +wsrc = env.F2py(pjoin(env['build_dir'], '_fftpackmodule.c'), pjoin(env['build_dir'], 'fftpack.pyf')) env.NumpyPythonExtension('_fftpack', source = src + wsrc) # Build convolve src = ['src/convolve.c'] -wsrc = env.F2PY(pjoin(env['build_dir'], 'convolve.pyf')) +wsrc = env.F2py(pjoin(env['build_dir'], 'convolve.pyf')) env.NumpyPythonExtension('convolve', source = src + wsrc) Modified: branches/scipy.scons/scipy/integrate/SConstruct =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-22 02:45:18 UTC (rev 3564) +++ branches/scipy.scons/scipy/integrate/SConstruct 2007-11-22 03:20:10 UTC (rev 3565) @@ -1,4 +1,4 @@ -# Last Change: Wed Nov 21 08:00 PM 2007 J +# Last Change: Thu Nov 22 12:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin import glob Modified: branches/scipy.scons/scipy/interpolate/SConstruct =================================================================== --- branches/scipy.scons/scipy/interpolate/SConstruct 2007-11-22 02:45:18 UTC (rev 3564) +++ branches/scipy.scons/scipy/interpolate/SConstruct 2007-11-22 03:20:10 UTC (rev 3565) @@ -1,4 +1,4 @@ -# Last Change: Wed Nov 21 08:00 PM 2007 J +# Last Change: Thu Nov 22 12:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin import glob @@ -28,6 +28,6 @@ env.NumpyPythonExtension('_fitpack', source = '_fitpackmodule.c') # Build dfitpack -dfitpack_wrap = env.F2PY(pjoin(env['build_dir'], 'dfitpack'), +dfitpack_wrap = env.F2py(pjoin(env['build_dir'], 'dfitpack'), pjoin(env['build_dir'], 'fitpack.pyf')) env.NumpyPythonExtension('dfitpack', source = dfitpack_wrap) Copied: branches/scipy.scons/scipy/lib/blas/setupscons.py (from rev 3564, branches/scipy.scons/scipy/lib/blas/setup.py) Copied: branches/scipy.scons/scipy/lib/lapack/setupscons.py (from rev 3564, branches/scipy.scons/scipy/lib/lapack/setup.py) Copied: branches/scipy.scons/scipy/lib/setupscons.py (from rev 3564, branches/scipy.scons/scipy/lib/setup.py) =================================================================== --- branches/scipy.scons/scipy/lib/setup.py 2007-11-22 02:45:18 UTC (rev 3564) +++ branches/scipy.scons/scipy/lib/setupscons.py 2007-11-22 03:20:10 UTC (rev 3565) @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('lib',parent_package,top_path, setup_name = 'setupscons.py') + config.add_subpackage('blas') + config.add_subpackage('lapack') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + + setup(**configuration(top_path='').todict()) Modified: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-22 02:45:18 UTC (rev 3564) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-22 03:20:10 UTC (rev 3565) @@ -1,4 +1,4 @@ -# Last Change: Tue Nov 20 08:00 PM 2007 J +# Last Change: Thu Nov 22 12:00 PM 2007 J # vim:syntax=python import os @@ -120,7 +120,7 @@ # _flinalg #---------------- _flinalg_fsrc = ['det.f', 'lu.f'] -_flinalg_src = env.F2PY( +_flinalg_src = env.F2py( pjoin(env['build_dir'], 'src', '_flinalgmodule.c'), source = [pjoin(env['build_dir'], 'src', i) for i in _flinalg_fsrc]) @@ -130,7 +130,7 @@ #---------------- # calc_lwork: #---------------- -calc_src = env.F2PY(pjoin(env['build_dir'], 'src', 'calc_lworkmodule.c'), +calc_src = env.F2py(pjoin(env['build_dir'], 'src', 'calc_lworkmodule.c'), source = pjoin(env['build_dir'], 'src', 'calc_lwork.f')) env.NumpyPythonExtension('calc_lwork', source = calc_src + [pjoin('src', 'calc_lwork.f')]) From scipy-svn at scipy.org Thu Nov 22 05:55:55 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 22 Nov 2007 04:55:55 -0600 (CST) Subject: [Scipy-svn] r3566 - trunk/scipy/signal Message-ID: <20071122105555.3BDA139C01B@new.scipy.org> Author: jarrod.millman Date: 2007-11-22 04:55:50 -0600 (Thu, 22 Nov 2007) New Revision: 3566 Modified: trunk/scipy/signal/signaltools.py Log: fixed missing import as per ticket #542 Modified: trunk/scipy/signal/signaltools.py =================================================================== --- trunk/scipy/signal/signaltools.py 2007-11-22 03:20:10 UTC (rev 3565) +++ trunk/scipy/signal/signaltools.py 2007-11-22 10:55:50 UTC (rev 3566) @@ -12,7 +12,7 @@ ravel, size, less_equal, sum, r_, iscomplexobj, take, \ argsort, allclose, expand_dims, unique, prod, sort, reshape, c_, \ transpose, dot, any, minimum, maximum, mean, cosh, arccosh, \ - arccos + arccos, concatenate import numpy from scipy.fftpack import fftn, ifftn, fft from scipy.misc import factorial From scipy-svn at scipy.org Thu Nov 22 07:38:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 22 Nov 2007 06:38:15 -0600 (CST) Subject: [Scipy-svn] r3567 - branches/scipy.scons/scipy/linalg Message-ID: <20071122123815.E40B139C30C@new.scipy.org> Author: cdavid Date: 2007-11-22 06:38:12 -0600 (Thu, 22 Nov 2007) New Revision: 3567 Modified: branches/scipy.scons/scipy/linalg/SConstruct Log: Use special wrapper for Mac OS X fblas when built with scons Modified: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-22 10:55:50 UTC (rev 3566) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-22 12:38:12 UTC (rev 3567) @@ -1,4 +1,4 @@ -# Last Change: Thu Nov 22 12:00 PM 2007 J +# Last Change: Thu Nov 22 05:00 PM 2007 J # vim:syntax=python import os @@ -8,26 +8,15 @@ from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir from numpy.distutils.scons import GetNumpyEnvironment from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ - CheckCLAPACK + CheckCLAPACK, IsVeclib, IsAccelerate, IsATLAS from scons_support import do_generate_interface, do_generate_fake_interface, \ generate_interface_emitter -#from numpy.distutils.scons.configuration import write_info +from numpy.distutils.scons.configuration import write_info #from scons_support import CheckBrokenMathlib, define_no_smp, \ # generate_config_header, generate_config_header_emitter -#------------------- -# To skip wrapping single precision atlas/lapack/blas routines, set -# the following flag to True: -skip_single_routines = 0 - -# Some OS distributions (e.g. Redhat, Suse) provide a blas library that -# is built using incomplete blas sources that come with lapack tar-ball. -# In order to use such a library in scipy.linalg, the following flag -# must be set to True: -using_lapack_blas = 0 - env = GetNumpyEnvironment(ARGUMENTS) env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) #if os.name == 'nt': @@ -39,7 +28,6 @@ #======================= # Starting Configuration #======================= -# XXX: separate env for configuration config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS, 'CheckBLAS' : CheckF77BLAS, 'CheckCLAPACK' : CheckCLAPACK, @@ -67,7 +55,7 @@ has_clapack = 0 config.Finish() -#write_info(env) +write_info(env) #========== # Build @@ -86,9 +74,13 @@ #------------ # fblas #------------ -# XXX: handle Accelerate problem env.haha('fblas', 'generic_fblas.pyf') -env.NumpyPythonExtension('fblas', source = ['fblas.pyf', pjoin('src', 'fblaswrap.f')]) +source = ['fblas.pyf'] +if IsVeclib(env, 'blas') or IsAccelerate(env, 'blas'): + source.append(pjoin('src', 'fblaswrap_veclib_c.c')) +else: + source.append(pjoin('src', 'fblaswrap.f')) +env.NumpyPythonExtension('fblas', source) #------------ # cblas @@ -163,5 +155,6 @@ # Atlas version #-------------- atlas_env = env.Copy() -atlas_env.AppendUnique(CPPDEFINES = "NO_ATLAS_INFO") +if not IsATLAS(env, 'blas'): + atlas_env.AppendUnique(CPPDEFINES = "NO_ATLAS_INFO") atlas_env.NumpyPythonExtension('atlas_version', 'atlas_version.c') From scipy-svn at scipy.org Fri Nov 23 02:20:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 01:20:10 -0600 (CST) Subject: [Scipy-svn] r3568 - in trunk/scipy/sandbox/numexpr: . tests Message-ID: <20071123072010.66E9539C069@new.scipy.org> Author: cookedm Date: 2007-11-23 01:20:02 -0600 (Fri, 23 Nov 2007) New Revision: 3568 Added: trunk/scipy/sandbox/numexpr/boolean_timing.py Modified: trunk/scipy/sandbox/numexpr/__init__.py trunk/scipy/sandbox/numexpr/compiler.py trunk/scipy/sandbox/numexpr/complex_functions.inc trunk/scipy/sandbox/numexpr/expressions.py trunk/scipy/sandbox/numexpr/info.py trunk/scipy/sandbox/numexpr/interp_body.c trunk/scipy/sandbox/numexpr/interpreter.c trunk/scipy/sandbox/numexpr/tests/test_numexpr.py trunk/scipy/sandbox/numexpr/timing.py Log: [numexpr] Merge improvements from PyTables into numexpr (#529), thanks to Francesc Altet. This includes: - support for long long int datatype - support for string datatype - optimization of the unidimensional strided array case - optimization of the unidimensional unaligned array case Modified: trunk/scipy/sandbox/numexpr/__init__.py =================================================================== --- trunk/scipy/sandbox/numexpr/__init__.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/__init__.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -1,6 +1,6 @@ -from info import __doc__ -from expressions import E -from compiler import numexpr, disassemble, evaluate +from numexpr.info import __doc__ +from numexpr.expressions import E +from numexpr.compiler import numexpr, disassemble, evaluate def test(level=1, verbosity=1): from numpy.testing import NumpyTest Added: trunk/scipy/sandbox/numexpr/boolean_timing.py =================================================================== --- trunk/scipy/sandbox/numexpr/boolean_timing.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/boolean_timing.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -0,0 +1,139 @@ +import sys +import timeit +import numpy + +array_size = 1000*1000 +iterations = 10 + +numpy_ttime = 0 +numpy_sttime = 0 +numpy_nttime = 0 +numexpr_ttime = 0 +numexpr_sttime = 0 +numexpr_nttime = 0 + +def compare_times(expr, nexpr): + global numpy_ttime + global numpy_sttime + global numpy_nttime + global numexpr_ttime + global numexpr_sttime + global numexpr_nttime + + print "******************* Expression:", expr + + setup_contiguous = setupNP_contiguous + setup_strided = setupNP_strided + setup_unaligned = setupNP_unaligned + + numpy_timer = timeit.Timer(expr, setup_contiguous) + numpy_time = round(numpy_timer.timeit(number=iterations), 4) + numpy_ttime += numpy_time + print 'numpy:', numpy_time / iterations + + numpy_timer = timeit.Timer(expr, setup_strided) + numpy_stime = round(numpy_timer.timeit(number=iterations), 4) + numpy_sttime += numpy_stime + print 'numpy strided:', numpy_stime / iterations + + numpy_timer = timeit.Timer(expr, setup_unaligned) + numpy_ntime = round(numpy_timer.timeit(number=iterations), 4) + numpy_nttime += numpy_ntime + print 'numpy unaligned:', numpy_ntime / iterations + + evalexpr = 'evaluate("%s", optimization="aggressive")' % expr + numexpr_timer = timeit.Timer(evalexpr, setup_contiguous) + numexpr_time = round(numexpr_timer.timeit(number=iterations), 4) + numexpr_ttime += numexpr_time + print "numexpr:", numexpr_time/iterations, + print "Speed-up of numexpr over numpy:", round(numpy_time/numexpr_time, 4) + + evalexpr = 'evaluate("%s", optimization="aggressive")' % expr + numexpr_timer = timeit.Timer(evalexpr, setup_strided) + numexpr_stime = round(numexpr_timer.timeit(number=iterations), 4) + numexpr_sttime += numexpr_stime + print "numexpr strided:", numexpr_stime/iterations, + print "Speed-up of numexpr strided over numpy:", \ + round(numpy_stime/numexpr_stime, 4) + + evalexpr = 'evaluate("%s", optimization="aggressive")' % expr + numexpr_timer = timeit.Timer(evalexpr, setup_unaligned) + numexpr_ntime = round(numexpr_timer.timeit(number=iterations), 4) + numexpr_nttime += numexpr_ntime + print "numexpr unaligned:", numexpr_ntime/iterations, + print "Speed-up of numexpr unaligned over numpy:", \ + round(numpy_ntime/numexpr_ntime, 4) + + + +setupNP = """\ +from numpy import arange, where, arctan2, sqrt +from numpy import rec as records +from numexpr import evaluate + +# Initialize a recarray of 16 MB in size +r=records.array(None, formats='a%s,i4,f8', shape=%s) +c1 = r.field('f0')%s +i2 = r.field('f1')%s +f3 = r.field('f2')%s +c1[:] = "a" +i2[:] = arange(%s)/1000 +f3[:] = i2/2. +""" + +setupNP_contiguous = setupNP % (4, array_size, + ".copy()", ".copy()", ".copy()", + array_size) +setupNP_strided = setupNP % (4, array_size, "", "", "", array_size) +setupNP_unaligned = setupNP % (1, array_size, "", "", "", array_size) + + +expressions = [] +expressions.append('i2 > 0') +expressions.append('i2 < 0') +expressions.append('i2 < f3') +expressions.append('i2-10 < f3') +expressions.append('i2*f3+f3*f3 > i2') +expressions.append('0.1*i2 > arctan2(i2, f3)') +expressions.append('i2%2 > 3') +expressions.append('i2%10 < 4') +expressions.append('i2**2 + (f3+1)**-2.5 < 3') +expressions.append('(f3+1)**50 > i2') +expressions.append('sqrt(i2**2 + f3**2) > 1') +expressions.append('(i2>2) | ((f3**2>3) & ~(i2*f3<2))') + +def compare(expression=False): + if expression: + compare_times(expression, 1) + sys.exit(0) + nexpr = 0 + for expr in expressions: + nexpr += 1 + compare_times(expr, nexpr) + print + +if __name__ == '__main__': + + print 'Python version: %s' % sys.version + print "NumPy version: %s" % numpy.__version__ + + if len(sys.argv) > 1: + expression = sys.argv[1] + print "expression-->", expression + compare(expression) + else: + compare() + + print "*************** TOTALS **************************" + print "numpy total:", numpy_ttime/iterations + print "numpy strided total:", numpy_sttime/iterations + print "numpy unaligned total:", numpy_nttime/iterations + print "numexpr total:", numexpr_ttime/iterations + print "Speed-up of numexpr over numpy:", \ + round(numpy_ttime/numexpr_ttime, 3) + print "numexpr strided total:", numexpr_sttime/iterations + print "Speed-up of numexpr strided over numpy:", \ + round(numpy_sttime/numexpr_sttime, 3) + print "numexpr unaligned total:", numexpr_nttime/iterations + print "Speed-up of numexpr unaligned over numpy:", \ + round(numpy_nttime/numexpr_nttime, 3) Modified: trunk/scipy/sandbox/numexpr/compiler.py =================================================================== --- trunk/scipy/sandbox/numexpr/compiler.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/compiler.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -1,12 +1,12 @@ import sys import numpy -import interpreter, expressions +from numexpr import interpreter, expressions -typecode_to_kind = {'b': 'bool', 'i': 'int', 'f': 'float', - 'c': 'complex', 'n' : 'none'} -kind_to_typecode = {'bool': 'b', 'int': 'i', 'float': 'f', - 'complex': 'c', 'none' : 'n'} +typecode_to_kind = {'b': 'bool', 'i': 'int', 'l': 'long', 'f': 'float', + 'c': 'complex', 's': 'str', 'n' : 'none'} +kind_to_typecode = {'bool': 'b', 'int': 'i', 'long': 'l', 'float': 'f', + 'complex': 'c', 'str': 's', 'none' : 'n'} type_to_kind = expressions.type_to_kind kind_to_type = expressions.kind_to_type @@ -91,7 +91,7 @@ """Generate all possible signatures derived by upcasting the given signature. """ - codes = 'bifc' + codes = 'bilfc' if not s: yield '' elif s[0] in codes: @@ -99,6 +99,9 @@ for x in codes[start:]: for y in sigPerms(s[1:]): yield x + y + elif s[0] == 's': # numbers shall not be cast to strings + for y in sigPerms(s[1:]): + yield 's' + y else: yield s @@ -198,6 +201,10 @@ for name in c.co_names: if name == "None": names[name] = None + elif name == "True": + names[name] = True + elif name == "False": + names[name] = False else: t = types.get(name, float) names[name] = expressions.VariableNode(name, type_to_kind[t]) @@ -206,6 +213,8 @@ ex = eval(c, names) if expressions.isConstant(ex): ex = expressions.ConstantNode(ex, expressions.getKind(ex)) + elif not isinstance(ex, expressions.ExpressionNode): + raise TypeError("unsupported expression type: %s" % type(ex)) finally: expressions._context.ctx = old_ctx return ex @@ -308,8 +317,8 @@ for c in n.children: if c.reg.temporary: users_of[c.reg].add(n) - unused = {'bool' : set(), 'int' : set(), - 'float' : set(), 'complex' : set()} + unused = {'bool' : set(), 'int' : set(), 'long': set(), + 'float' : set(), 'complex' : set(), 'str': set()} for n in nodes: for reg, users in users_of.iteritems(): if n in users: @@ -435,7 +444,7 @@ ast = expressionToAST(ex) - # Add a copy for strided or unaligned arrays + # Add a copy for strided or unaligned unidimensional arrays for a in ast.postorderWalk(): if a.astType == "variable" and a.value in copy_args: newVar = ASTNode(*a.key()) @@ -536,15 +545,19 @@ def getType(a): - t = a.dtype.type - if issubclass(t, numpy.bool_): + kind = a.dtype.kind + if kind == 'b': return bool - if issubclass(t, numpy.integer): + if kind in 'iu': + if a.dtype.itemsize > 4: + return long # ``long`` is for integers of more than 32 bits return int - if issubclass(t, numpy.floating): + if kind == 'f': return float - if issubclass(t, numpy.complexfloating): + if kind == 'c': return complex + if kind == 'S': + return str raise ValueError("unkown type %s" % a.dtype.name) @@ -589,12 +602,29 @@ a = local_dict[name] except KeyError: a = global_dict[name] - # byteswapped arrays are taken care of in the extension. - arguments.append(numpy.asarray(a)) # don't make a data copy, if possible - if (hasattr(a, "flags") and # numpy object - (not a.flags.contiguous or - not a.flags.aligned)): - copy_args.append(name) # do a copy to temporary + b = numpy.asarray(a) + # Byteswapped arrays are dealt with in the extension + # All the opcodes can deal with strided arrays directly as + # long as they are undimensional (strides in other + # dimensions are dealt within the extension), so we don't + # need a copy for the strided case. + if not b.flags.aligned: + # For the unaligned case, we have two cases: + if b.ndim == 1: + # For unidimensional arrays we can use the copy opcode + # because it can deal with unaligned arrays as long + # as they are unidimensionals with a possible stride + # (very common case for recarrays). This can be up to + # 2x faster than doing a copy using NumPy. + copy_args.append(name) + else: + # For multimensional unaligned arrays do a plain copy. + # We could refine more this and do a plain copy only + # in the case that strides doesn't exist in dimensions + # other than the last one (whose case is supported by + # the copy opcode). + b = b.copy() + arguments.append(b) # Create a signature signature = [(name, getType(arg)) for (name, arg) in zip(names, arguments)] Modified: trunk/scipy/sandbox/numexpr/complex_functions.inc =================================================================== --- trunk/scipy/sandbox/numexpr/complex_functions.inc 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/complex_functions.inc 2007-11-23 07:20:02 UTC (rev 3568) @@ -365,3 +365,34 @@ r->imag = (is*rc-rs*ic)/d; return; } + + +/* The next nowarn1() and nowarn2() are defined in order to avoid + compiler warnings about unused functions. Just add to nowarn1() a + call to each function the compiler complains about to make it look + like it gets used somewhere. + + Of course, you shouldn't directly invoke neither of these two + functions, since they cause a stack overflow. */ + +void nowarn2(cdouble *x, cdouble *r, cdouble *b); + +void +nowarn1(cdouble *x, cdouble *r, cdouble *b) +{ + nc_floor_quot(x, b, r); + nc_log1p(x, r); + nc_expm1(x, r); + nc_log10(x, r); + nc_asinh(x, r); + nc_acosh(x, r); + nc_atanh(x, r); + /* Append more calls here. */ + nowarn2(x, r, b); +} + +void +nowarn2(cdouble *x, cdouble *r, cdouble *b) +{ + nowarn1(x, r, b); +} Modified: trunk/scipy/sandbox/numexpr/expressions.py =================================================================== --- trunk/scipy/sandbox/numexpr/expressions.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/expressions.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -6,7 +6,7 @@ import numpy -import interpreter +from numexpr import interpreter class Expression(object): def __init__(self): @@ -55,25 +55,53 @@ def isConstant(ex): "Returns True if ex is a constant scalar of an allowed type." - return isinstance(ex, (bool, int, float, complex)) + return isinstance(ex, (bool, int, long, float, complex, str)) -type_to_kind = {bool: 'bool', int: 'int', float: 'float', complex: 'complex'} -kind_to_type = {'bool': bool, 'int': int, 'float': float, 'complex': complex} -kind_rank = ['bool', 'int', 'float', 'complex', 'none'] +type_to_kind = {bool: 'bool', int: 'int', long: 'long', float: 'float', complex: 'complex', str: 'str'} +kind_to_type = {'bool': bool, 'int': int, 'long': long, 'float': float, 'complex': complex, 'str': str} +kind_rank = ['bool', 'int', 'long', 'float', 'complex', 'none'] def commonKind(nodes): + node_kinds = [node.astKind for node in nodes] + str_count = node_kinds.count('str') + if 0 < str_count < len(node_kinds): # some args are strings, but not all + raise TypeError("strings can only be operated with strings") + if str_count > 0: # if there are some, all of them must be + return 'str' n = -1 for x in nodes: n = max(n, kind_rank.index(x.astKind)) return kind_rank[n] +max_int32 = 2147483647 +min_int32 = -max_int32 - 1 def bestConstantType(x): - for converter in bool, int, float, complex: + if isinstance(x, str): # ``numpy.string_`` is a subclass of ``str`` + return str + # ``long`` objects are kept as is to allow the user to force + # promotion of results by using long constants, e.g. by operating + # a 32-bit array with a long (64-bit) constant. + if isinstance(x, (long, numpy.int64)): + return long + # Numeric conversion to boolean values is not tried because + # ``bool(1) == True`` (same for 0 and False), so 0 and 1 would be + # interpreted as booleans when ``False`` and ``True`` are already + # supported. + if isinstance(x, (bool, numpy.bool_)): + return bool + # ``long`` is not explicitly needed since ``int`` automatically + # returns longs when needed (since Python 2.3). + for converter in int, float, complex: try: y = converter(x) except StandardError, err: continue if x == y: + # Constants needing more than 32 bits are always + # considered ``long``, *regardless of the platform*, so we + # can clearly tell 32- and 64-bit constants apart. + if converter is int and not (min_int32 <= x <= max_int32): + return long return converter def getKind(x): @@ -94,7 +122,7 @@ return OpNode(opname, (self, other), kind=kind) return operation -def func(func, minkind=None): +def func(func, minkind=None, maxkind=None): @ophelper def function(*args): if allConstantNodes(args): @@ -102,6 +130,8 @@ kind = commonKind(args) if minkind and kind_rank.index(minkind) > kind_rank.index(kind): kind = minkind + if maxkind and kind_rank.index(maxkind) < kind_rank.index(kind): + kind = maxkind return FuncNode(func.__name__, args, kind) return function @@ -129,23 +159,17 @@ axis = encode_axis(axis) if isinstance(a, ConstantNode): return a - if isinstance(a, (bool, int, float, complex)): + if isinstance(a, (bool, int, long, float, complex)): a = ConstantNode(a) - kind = a.astKind - if kind == 'bool': - kind = 'int' - return FuncNode('sum', [a, axis], kind=kind) + return FuncNode('sum', [a, axis], kind=a.astKind) def prod_func(a, axis=-1): axis = encode_axis(axis) - if isinstance(a, (bool, int, float, complex)): + if isinstance(a, (bool, int, long, float, complex)): a = ConstantNode(a) if isinstance(a, ConstantNode): return a - kind = a.astKind - if kind == 'bool': - kind = 'int' - return FuncNode('prod', [a, axis], kind=kind) + return FuncNode('prod', [a, axis], kind=a.astKind) @ophelper def div_op(a, b): @@ -182,7 +206,7 @@ p = OpNode('mul', [p,p]) if ishalfpower: kind = commonKind([a]) - if kind == 'int': kind = 'float' + if kind in ('int', 'long'): kind = 'float' r = multiply(r, OpNode('sqrt', [a], kind)) if r is None: r = OpNode('ones_like', [a]) @@ -196,7 +220,7 @@ return FuncNode('ones_like', [a]) if x == 0.5: kind = a.astKind - if kind == 'int': kind = 'float' + if kind in ('int', 'long'): kind = 'float' return FuncNode('sqrt', [a], kind=kind) if x == 1: return a @@ -224,6 +248,8 @@ 'where' : where_func, + 'real': func(numpy.real, 'float', 'float'), + 'imag': func(numpy.imag, 'float', 'float'), 'complex' : func(complex, 'complex'), 'sum' : sum_func, @@ -306,7 +332,7 @@ class VariableNode(LeafNode): astType = 'variable' def __init__(self, value=None, kind=None, children=None): - ExpressionNode.__init__(self, value=value, kind=kind) + LeafNode.__init__(self, value=value, kind=kind) class RawNode(object): """Used to pass raw integers to interpreter. Modified: trunk/scipy/sandbox/numexpr/info.py =================================================================== --- trunk/scipy/sandbox/numexpr/info.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/info.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -2,25 +2,55 @@ Usage: -Build an expression up by using E. for the variables: +The easiest way is to use the ``evaluate`` function: ->>> ex = 2.0 * E.a + 3 * E.b * E.c +>>> a = numpy.array([1., 2, 3]) +>>> b = numpy.array([4, 5, 6]) +>>> c = numpy.array([7., 8, 9]) +>>> numexpr.evaluate("2.0 * a + 3 * b * c") +array([ 86., 124., 168.]) -then compile it to a function: +This works for every datatype defined in NumPy and the next operators +are supported: ->>> func = numexpr(ex, input_names=('a', 'b', 'c')) + Logical operators: &, |, ~ + Comparison operators: <, <=, ==, !=, >=, > + Unary arithmetic operators: - + Binary arithmetic operators: +, -, *, /, **, % -(if input_names is not given to compile, the variables are sort lexically.) +Note: Types do not support all operators. Boolean values only support + logical and strict (in)equality comparison operators, while + strings only support comparisons, numbers do not work with logical + operators, and complex comparisons can only check for strict + (in)equality. Unsupported operations (including invalid castings) + raise NotImplementedError exceptions. -Then, you can use that function for elementwise operations: +The next functions are also supported: ->>> func(array([1., 2, 3]), array([4., 5, 6]), array([7., 8, 9])) -array([ 86., 124., 168.]) + where(bool, number1, number2): number - number1 if the bool + condition is true, number2 otherwise. -Currently, this is only implemented for arrays of float64, and only -for the simple operations +, -, *, and /. + {sin,cos,tan}(float|complex): float|complex - trigonometric sinus, + cosinus or tangent. -Copyright 2006 David M. Cooke + {arcsin,arccos,arctan}(float|complex): float|complex - + trigonometric inverse sinus, cosinus or tangent. + + arctan2(float1, float2): float - trigonometric inverse tangent of + float1/float2. + + {sinh,cosh,tanh}(float|complex): float|complex - hyperbolic sinus, + cosinus or tangent. + + sqrt(float|complex): float|complex - square root. + + {real,imag}(complex): float - real or imaginary part of complex. + + complex(float, float): complex - complex from real and imaginary + parts. + + +Copyright 2006,2007 David M. Cooke Licenced under a BSD-style license. See LICENSE.txt in the scipy source directory. """ Modified: trunk/scipy/sandbox/numexpr/interp_body.c =================================================================== --- trunk/scipy/sandbox/numexpr/interp_body.c 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/interp_body.c 2007-11-23 07:20:02 UTC (rev 3568) @@ -8,9 +8,13 @@ { \ char *dest = params.mem[store_in]; \ char *x1 = params.mem[arg1]; \ + intp ss1 = params.memsizes[arg1]; \ intp sb1 = params.memsteps[arg1]; \ - intp si1 = sb1 / sizeof(long); \ - intp sf1 = sb1 / sizeof(double); \ + /* nowarns is defined and used so as to \ + avoid compiler warnings about unused \ + variables */ \ + intp nowarns = ss1+sb1+*x1; \ + nowarns += 1; \ VEC_LOOP(expr); \ } break #define VEC_ARG2(expr) \ @@ -20,14 +24,16 @@ { \ char *dest = params.mem[store_in]; \ char *x1 = params.mem[arg1]; \ + intp ss1 = params.memsizes[arg1]; \ intp sb1 = params.memsteps[arg1]; \ - intp si1 = sb1 / sizeof(long); \ - intp sf1 = sb1 / sizeof(double); \ + /* nowarns is defined and used so as to \ + avoid compiler warnings about unused \ + variables */ \ + intp nowarns = ss1+sb1+*x1; \ char *x2 = params.mem[arg2]; \ + intp ss2 = params.memsizes[arg2]; \ intp sb2 = params.memsteps[arg2]; \ - intp si2 = sb2 / sizeof(long); \ - intp sf2 = sb2 / sizeof(double); \ - intp s2 = params.memsteps[arg2]; \ + nowarns += ss2+sb2+*x2; \ VEC_LOOP(expr); \ } break @@ -39,19 +45,20 @@ { \ char *dest = params.mem[store_in]; \ char *x1 = params.mem[arg1]; \ + intp ss1 = params.memsizes[arg1]; \ intp sb1 = params.memsteps[arg1]; \ - intp si1 = sb1 / sizeof(long); \ - intp sf1 = sb1 / sizeof(double); \ + /* nowarns is defined and used so as to \ + avoid compiler warnings about unused \ + variables */ \ + intp nowarns = ss1+sb1+*x1; \ char *x2 = params.mem[arg2]; \ - intp s2 = params.memsteps[arg2]; \ + intp ss2 = params.memsizes[arg2]; \ intp sb2 = params.memsteps[arg2]; \ - intp si2 = sb2 / sizeof(long); \ - intp sf2 = sb2 / sizeof(double); \ char *x3 = params.mem[arg3]; \ - intp s3 = params.memsteps[arg3]; \ + intp ss3 = params.memsizes[arg3]; \ intp sb3 = params.memsteps[arg3]; \ - intp si3 = sb3 / sizeof(long); \ - intp sf3 = sb3 / sizeof(double); \ + nowarns += ss2+sb2+*x2; \ + nowarns += ss3+sb3+*x3; \ VEC_LOOP(expr); \ } break @@ -82,6 +89,11 @@ params.mem[1+r] = params.inputs[r] + index * params.memsteps[1+r]; } } + + /* WARNING: From now on, only do references to params.mem[arg[123]] + & params.memsteps[arg[123]] inside the VEC_ARG[123] macros, + or you will risk accessing invalid addresses. */ + for (pc = 0; pc < params.prog_len; pc += 4) { unsigned char op = params.program[pc]; unsigned int store_in = params.program[pc+1]; @@ -89,37 +101,41 @@ unsigned int arg2 = params.program[pc+3]; #define arg3 params.program[pc+5] #define store_index params.index_data[store_in] - - /* WARNING: From now on, only do references to params.mem[arg[123]] - & params.memsteps[arg[123]] inside the VEC_ARG[123] macros, - or you will risk accessing invalid addresses. */ - #define reduce_ptr (dest + flat_index(&store_index, j)) - #define i_reduce *(long *)reduce_ptr + #define i_reduce *(int *)reduce_ptr + #define l_reduce *(long long *)reduce_ptr #define f_reduce *(double *)reduce_ptr #define cr_reduce *(double *)ptr #define ci_reduce *((double *)ptr+1) #define b_dest ((char *)dest)[j] - #define i_dest ((long *)dest)[j] + #define i_dest ((int *)dest)[j] + #define l_dest ((long long *)dest)[j] #define f_dest ((double *)dest)[j] #define cr_dest ((double *)dest)[2*j] #define ci_dest ((double *)dest)[2*j+1] - #define b1 ((char *)x1)[j*sb1] - #define i1 ((long *)x1)[j*si1] - #define f1 ((double *)x1)[j*sf1] - #define c1r ((double *)x1)[j*sf1] - #define c1i ((double *)x1)[j*sf1+1] - #define b2 ((char *)x2)[j*sb2] - #define i2 ((long *)x2)[j*si2] - #define f2 ((double *)x2)[j*sf2] - #define c2r ((double *)x2)[j*sf2] - #define c2i ((double *)x2)[j*sf2+1] - #define b3 ((char *)x3)[j*sb3] - #define i3 ((long *)x3)[j*si3] - #define f3 ((double *)x3)[j*sf3] - #define c3r ((double *)x3)[j*sf3] - #define c3i ((double *)x3)[j*sf3+1] - + #define s_dest ((char *)dest + j*params.memsteps[store_in]) + #define b1 ((char *)(x1+j*sb1))[0] + #define i1 ((int *)(x1+j*sb1))[0] + #define l1 ((long long *)(x1+j*sb1))[0] + #define f1 ((double *)(x1+j*sb1))[0] + #define c1r ((double *)(x1+j*sb1))[0] + #define c1i ((double *)(x1+j*sb1))[1] + #define s1 ((char *)x1+j*sb1) + #define b2 ((char *)(x2+j*sb2))[0] + #define i2 ((int *)(x2+j*sb2))[0] + #define l2 ((long long *)(x2+j*sb2))[0] + #define f2 ((double *)(x2+j*sb2))[0] + #define c2r ((double *)(x2+j*sb2))[0] + #define c2i ((double *)(x2+j*sb2))[1] + #define s2 ((char *)x2+j*sb2) + #define b3 ((char *)(x3+j*sb3))[0] + #define i3 ((int *)(x3+j*sb3))[0] + #define l3 ((long long *)(x3+j*sb3))[0] + #define f3 ((double *)(x3+j*sb3))[0] + #define c3r ((double *)(x3+j*sb3))[0] + #define c3i ((double *)(x3+j*sb3))[1] + #define s3 ((char *)x3+j*sb3) + /* Some temporaries */ double fa, fb; cdouble ca, cb; char *ptr; @@ -129,27 +145,42 @@ case OP_NOOP: break; case OP_COPY_BB: VEC_ARG1(b_dest = b1); - case OP_COPY_II: VEC_ARG1(i_dest = i1); - case OP_COPY_FF: VEC_ARG1(f_dest = f1); - case OP_COPY_CC: VEC_ARG1(cr_dest = c1r; - ci_dest = c1i); + case OP_COPY_SS: VEC_ARG1(memcpy(s_dest, s1, ss1)); + /* The next versions of copy opcodes can cope with unaligned + data even on platforms that crash while accessing it + (like the Sparc architecture under Solaris). */ + case OP_COPY_II: VEC_ARG1(memcpy(&i_dest, s1, sizeof(int))); + case OP_COPY_LL: VEC_ARG1(memcpy(&f_dest, s1, sizeof(long long))); + case OP_COPY_FF: VEC_ARG1(memcpy(&f_dest, s1, sizeof(double))); + case OP_COPY_CC: VEC_ARG1(memcpy(&cr_dest, s1, sizeof(double)*2)); case OP_INVERT_BB: VEC_ARG1(b_dest = !b1); + case OP_AND_BBB: VEC_ARG2(b_dest = (b1 && b2)); + case OP_OR_BBB: VEC_ARG2(b_dest = (b1 || b2)); - case OP_AND_BBB: VEC_ARG2(b_dest = b1 && b2); - case OP_OR_BBB: VEC_ARG2(b_dest = b1 || b2); + case OP_EQ_BBB: VEC_ARG2(b_dest = (b1 == b2)); + case OP_NE_BBB: VEC_ARG2(b_dest = (b1 != b2)); - case OP_GT_BII: VEC_ARG2(b_dest = (i1 > i2) ? 1 : 0); - case OP_GE_BII: VEC_ARG2(b_dest = (i1 >= i2) ? 1 : 0); - case OP_EQ_BII: VEC_ARG2(b_dest = (i1 == i2) ? 1 : 0); - case OP_NE_BII: VEC_ARG2(b_dest = (i1 != i2) ? 1 : 0); + case OP_GT_BII: VEC_ARG2(b_dest = (i1 > i2)); + case OP_GE_BII: VEC_ARG2(b_dest = (i1 >= i2)); + case OP_EQ_BII: VEC_ARG2(b_dest = (i1 == i2)); + case OP_NE_BII: VEC_ARG2(b_dest = (i1 != i2)); - case OP_GT_BFF: VEC_ARG2(b_dest = (f1 > f2) ? 1 : 0); - case OP_GE_BFF: VEC_ARG2(b_dest = (f1 >= f2) ? 1 : 0); - case OP_EQ_BFF: VEC_ARG2(b_dest = (f1 == f2) ? 1 : 0); - case OP_NE_BFF: VEC_ARG2(b_dest = (f1 != f2) ? 1 : 0); + case OP_GT_BLL: VEC_ARG2(b_dest = (l1 > l2)); + case OP_GE_BLL: VEC_ARG2(b_dest = (l1 >= l2)); + case OP_EQ_BLL: VEC_ARG2(b_dest = (l1 == l2)); + case OP_NE_BLL: VEC_ARG2(b_dest = (l1 != l2)); - case OP_CAST_IB: VEC_ARG1(i_dest = (long)b1); + case OP_GT_BFF: VEC_ARG2(b_dest = (f1 > f2)); + case OP_GE_BFF: VEC_ARG2(b_dest = (f1 >= f2)); + case OP_EQ_BFF: VEC_ARG2(b_dest = (f1 == f2)); + case OP_NE_BFF: VEC_ARG2(b_dest = (f1 != f2)); + + case OP_GT_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) > 0)); + case OP_GE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) >= 0)); + case OP_EQ_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) == 0)); + case OP_NE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) != 0)); + case OP_ONES_LIKE_II: VEC_ARG1(i_dest = 1); case OP_NEG_II: VEC_ARG1(i_dest = -i1); @@ -157,13 +188,26 @@ case OP_SUB_III: VEC_ARG2(i_dest = i1 - i2); case OP_MUL_III: VEC_ARG2(i_dest = i1 * i2); case OP_DIV_III: VEC_ARG2(i_dest = i1 / i2); - case OP_POW_III: VEC_ARG2(i_dest = (i2 < 0) ? (1 / i1) : (long)pow(i1, i2)); + case OP_POW_III: VEC_ARG2(i_dest = (i2 < 0) ? (1 / i1) : (int)pow(i1, i2)); case OP_MOD_III: VEC_ARG2(i_dest = i1 % i2); - case OP_WHERE_IFII: VEC_ARG3(i_dest = f1 ? i2 : i3); + case OP_WHERE_IBII: VEC_ARG3(i_dest = b1 ? i2 : i3); - case OP_CAST_FB: VEC_ARG1(f_dest = (long)b1); + case OP_CAST_LI: VEC_ARG1(l_dest = (long long)(i1)); + case OP_ONES_LIKE_LL: VEC_ARG1(l_dest = 1); + case OP_NEG_LL: VEC_ARG1(l_dest = -i1); + + case OP_ADD_LLL: VEC_ARG2(l_dest = l1 + l2); + case OP_SUB_LLL: VEC_ARG2(l_dest = l1 - l2); + case OP_MUL_LLL: VEC_ARG2(l_dest = l1 * l2); + case OP_DIV_LLL: VEC_ARG2(l_dest = l1 / l2); + case OP_POW_LLL: VEC_ARG2(l_dest = (l2 < 0) ? (1 / l1) : (long long)pow(l1, l2)); + case OP_MOD_LLL: VEC_ARG2(l_dest = l1 % l2); + + case OP_WHERE_LBLL: VEC_ARG3(l_dest = b1 ? l2 : l3); + case OP_CAST_FI: VEC_ARG1(f_dest = (double)(i1)); + case OP_CAST_FL: VEC_ARG1(f_dest = (double)(l1)); case OP_ONES_LIKE_FF: VEC_ARG1(f_dest = 1.0); case OP_NEG_FF: VEC_ARG1(f_dest = -f1); @@ -180,15 +224,15 @@ case OP_SQRT_FF: VEC_ARG1(f_dest = sqrt(f1)); case OP_ARCTAN2_FFF: VEC_ARG2(f_dest = atan2(f1, f2)); - case OP_WHERE_FFFF: VEC_ARG3(f_dest = f1 ? f2 : f3); + case OP_WHERE_FBFF: VEC_ARG3(f_dest = b1 ? f2 : f3); case OP_FUNC_FF: VEC_ARG1(f_dest = functions_f[arg2](f1)); case OP_FUNC_FFF: VEC_ARG2(f_dest = functions_ff[arg3](f1, f2)); - case OP_CAST_CB: VEC_ARG1(cr_dest = (double)b1; - ci_dest = 0); case OP_CAST_CI: VEC_ARG1(cr_dest = (double)(i1); ci_dest = 0); + case OP_CAST_CL: VEC_ARG1(cr_dest = (double)(l1); + ci_dest = 0); case OP_CAST_CF: VEC_ARG1(cr_dest = f1; ci_dest = 0); case OP_ONES_LIKE_CC: VEC_ARG1(cr_dest = 1; @@ -208,11 +252,11 @@ ci_dest = (c1i*c2r - c1r*c2i) / fa; cr_dest = fb); - case OP_EQ_BCC: VEC_ARG2(b_dest = (c1r == c2r && c1i == c2i) ? 1 : 0); - case OP_NE_BCC: VEC_ARG2(b_dest = (c1r != c2r || c1i != c2i) ? 1 : 0); + case OP_EQ_BCC: VEC_ARG2(b_dest = (c1r == c2r && c1i == c2i)); + case OP_NE_BCC: VEC_ARG2(b_dest = (c1r != c2r || c1i != c2i)); - case OP_WHERE_CFCC: VEC_ARG3(cr_dest = f1 ? c2r : c3r; - ci_dest = f1 ? c2i : c3i); + case OP_WHERE_CBCC: VEC_ARG3(cr_dest = b1 ? c2r : c3r; + ci_dest = b1 ? c2i : c3i); case OP_FUNC_CC: VEC_ARG1(ca.real = c1r; ca.imag = c1i; functions_cc[arg2](&ca, &ca); @@ -232,12 +276,14 @@ ci_dest = f2); case OP_SUM_IIN: VEC_ARG1(i_reduce += i1); + case OP_SUM_LLN: VEC_ARG1(l_reduce += l1); case OP_SUM_FFN: VEC_ARG1(f_reduce += f1); case OP_SUM_CCN: VEC_ARG1(ptr = reduce_ptr; cr_reduce += c1r; ci_reduce += c1i); case OP_PROD_IIN: VEC_ARG1(i_reduce *= i1); + case OP_PROD_LLN: VEC_ARG1(l_reduce *= l1); case OP_PROD_FFN: VEC_ARG1(f_reduce *= f1); case OP_PROD_CCN: VEC_ARG1(ptr = reduce_ptr; fa = cr_reduce*c1r - ci_reduce*c1i; @@ -258,22 +304,30 @@ #undef b_dest #undef i_dest +#undef l_dest #undef f_dest #undef cr_dest #undef ci_dest +#undef s_dest #undef b1 #undef i1 +#undef l1 #undef f1 #undef c1r #undef c1i +#undef s1 #undef b2 #undef i2 +#undef l2 #undef f2 #undef c2r #undef c2i +#undef s2 #undef b3 #undef i3 +#undef l3 #undef f3 #undef c3r #undef c3i +#undef s3 } Modified: trunk/scipy/sandbox/numexpr/interpreter.c =================================================================== --- trunk/scipy/sandbox/numexpr/interpreter.c 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/interpreter.c 2007-11-23 07:20:02 UTC (rev 3568) @@ -2,6 +2,8 @@ #include "structmember.h" #include "numpy/noprefix.h" #include "math.h" +#include "string.h" +#include "assert.h" #include "complex_functions.inc" @@ -25,17 +27,29 @@ OP_AND_BBB, OP_OR_BBB, + OP_EQ_BBB, + OP_NE_BBB, + OP_GT_BII, OP_GE_BII, OP_EQ_BII, OP_NE_BII, + OP_GT_BLL, + OP_GE_BLL, + OP_EQ_BLL, + OP_NE_BLL, + OP_GT_BFF, OP_GE_BFF, OP_EQ_BFF, OP_NE_BFF, - OP_CAST_IB, + OP_GT_BSS, + OP_GE_BSS, + OP_EQ_BSS, + OP_NE_BSS, + OP_COPY_II, OP_ONES_LIKE_II, OP_NEG_II, @@ -45,10 +59,22 @@ OP_DIV_III, OP_POW_III, OP_MOD_III, - OP_WHERE_IFII, + OP_WHERE_IBII, - OP_CAST_FB, + OP_CAST_LI, + OP_COPY_LL, + OP_ONES_LIKE_LL, + OP_NEG_LL, + OP_ADD_LLL, + OP_SUB_LLL, + OP_MUL_LLL, + OP_DIV_LLL, + OP_POW_LLL, + OP_MOD_LLL, + OP_WHERE_LBLL, + OP_CAST_FI, + OP_CAST_FL, OP_COPY_FF, OP_ONES_LIKE_FF, OP_NEG_FF, @@ -63,15 +89,15 @@ OP_TAN_FF, OP_SQRT_FF, OP_ARCTAN2_FFF, - OP_WHERE_FFFF, + OP_WHERE_FBFF, OP_FUNC_FF, OP_FUNC_FFF, OP_EQ_BCC, OP_NE_BCC, - OP_CAST_CB, OP_CAST_CI, + OP_CAST_CL, OP_CAST_CF, OP_ONES_LIKE_CC, OP_COPY_CC, @@ -80,7 +106,7 @@ OP_SUB_CCC, OP_MUL_CCC, OP_DIV_CCC, - OP_WHERE_CFCC, + OP_WHERE_CBCC, OP_FUNC_CC, OP_FUNC_CCC, @@ -88,15 +114,19 @@ OP_IMAG_FC, OP_COMPLEX_CFF, + OP_COPY_SS, + OP_REDUCTION, OP_SUM, OP_SUM_IIN, + OP_SUM_LLN, OP_SUM_FFN, OP_SUM_CCN, OP_PROD, OP_PROD_IIN, + OP_PROD_LLN, OP_PROD_FFN, OP_PROD_CCN @@ -116,6 +146,8 @@ break; case OP_AND_BBB: case OP_OR_BBB: + case OP_EQ_BBB: + case OP_NE_BBB: if (n == 0 || n == 1 || n == 2) return 'b'; break; case OP_GT_BII: @@ -125,6 +157,13 @@ if (n == 0) return 'b'; if (n == 1 || n == 2) return 'i'; break; + case OP_GT_BLL: + case OP_GE_BLL: + case OP_EQ_BLL: + case OP_NE_BLL: + if (n == 0) return 'b'; + if (n == 1 || n == 2) return 'l'; + break; case OP_GT_BFF: case OP_GE_BFF: case OP_EQ_BFF: @@ -132,9 +171,12 @@ if (n == 0) return 'b'; if (n == 1 || n == 2) return 'f'; break; - case OP_CAST_IB: - if (n == 0) return 'i'; - if (n == 1) return 'b'; + case OP_GT_BSS: + case OP_GE_BSS: + case OP_EQ_BSS: + case OP_NE_BSS: + if (n == 0) return 'b'; + if (n == 1 || n == 2) return 's'; break; case OP_COPY_II: case OP_ONES_LIKE_II: @@ -149,18 +191,39 @@ case OP_POW_III: if (n == 0 || n == 1 || n == 2) return 'i'; break; - case OP_WHERE_IFII: + case OP_WHERE_IBII: if (n == 0 || n == 2 || n == 3) return 'i'; - if (n == 1) return 'f'; + if (n == 1) return 'b'; break; - case OP_CAST_FB: - if (n == 0) return 'f'; + case OP_CAST_LI: + if (n == 0) return 'l'; + if (n == 1) return 'i'; + break; + case OP_COPY_LL: + case OP_ONES_LIKE_LL: + case OP_NEG_LL: + if (n == 0 || n == 1) return 'l'; + break; + case OP_ADD_LLL: + case OP_SUB_LLL: + case OP_MUL_LLL: + case OP_DIV_LLL: + case OP_MOD_LLL: + case OP_POW_LLL: + if (n == 0 || n == 1 || n == 2) return 'l'; + break; + case OP_WHERE_LBLL: + if (n == 0 || n == 2 || n == 3) return 'l'; if (n == 1) return 'b'; break; case OP_CAST_FI: if (n == 0) return 'f'; if (n == 1) return 'i'; break; + case OP_CAST_FL: + if (n == 0) return 'f'; + if (n == 1) return 'l'; + break; case OP_COPY_FF: case OP_ONES_LIKE_FF: case OP_NEG_FF: @@ -179,8 +242,9 @@ case OP_ARCTAN2_FFF: if (n == 0 || n == 1 || n == 2) return 'f'; break; - case OP_WHERE_FFFF: - if (n == 0 || n == 1 || n == 2 || n == 3) return 'f'; + case OP_WHERE_FBFF: + if (n == 0 || n == 2 || n == 3) return 'f'; + if (n == 1) return 'b'; break; case OP_FUNC_FF: if (n == 0 || n == 1) return 'f'; @@ -195,14 +259,14 @@ if (n == 0) return 'b'; if (n == 1 || n == 2) return 'c'; break; - case OP_CAST_CB: - if (n == 0) return 'c'; - if (n == 1) return 'b'; - break; case OP_CAST_CI: if (n == 0) return 'c'; if (n == 1) return 'i'; break; + case OP_CAST_CL: + if (n == 0) return 'c'; + if (n == 1) return 'l'; + break; case OP_CAST_CF: if (n == 0) return 'c'; if (n == 1) return 'f'; @@ -218,9 +282,9 @@ case OP_DIV_CCC: if (n == 0 || n == 1 || n == 2) return 'c'; break; - case OP_WHERE_CFCC: + case OP_WHERE_CBCC: if (n == 0 || n == 2 || n == 3) return 'c'; - if (n == 1) return 'f'; + if (n == 1) return 'b'; break; case OP_FUNC_CC: if (n == 0 || n == 1) return 'c'; @@ -239,11 +303,19 @@ if (n == 0) return 'c'; if (n == 1 || n == 2) return 'f'; break; + case OP_COPY_SS: + if (n == 0 || n == 1) return 's'; + break; case OP_PROD_IIN: case OP_SUM_IIN: if (n == 0 || n == 1) return 'i'; if (n == 2) return 'n'; break; + case OP_PROD_LLN: + case OP_SUM_LLN: + if (n == 0 || n == 1) return 'l'; + if (n == 2) return 'n'; + break; case OP_PROD_FFN: case OP_SUM_FFN: if (n == 0 || n == 1) return 'f'; @@ -383,6 +455,7 @@ char **mem; /* pointers to registers */ char *rawmem; /* a chunks of raw memory for storing registers */ intp *memsteps; + intp *memsizes; int rawmemsize; } NumExprObject; @@ -399,6 +472,7 @@ PyMem_Del(self->mem); PyMem_Del(self->rawmem); PyMem_Del(self->memsteps); + PyMem_Del(self->memsizes); self->ob_type->tp_free((PyObject*)self); } @@ -425,6 +499,7 @@ self->mem = NULL; self->rawmem = NULL; self->memsteps = NULL; + self->memsizes = NULL; self->rawmemsize = 0; #undef INIT_WITH } @@ -454,11 +529,13 @@ { switch (c) { case 'b': return sizeof(char); - case 'i': return sizeof(long); + case 'i': return sizeof(int); + case 'l': return sizeof(long long); case 'f': return sizeof(double); case 'c': return 2*sizeof(double); + case 's': return 0; /* strings are ok but size must be computed */ default: - PyErr_SetString(PyExc_TypeError, "signature value not in 'bifc'"); + PyErr_SetString(PyExc_TypeError, "signature value not in 'bilfcs'"); return -1; } } @@ -482,11 +559,13 @@ { switch (c) { case 'b': return PyArray_BOOL; - case 'i': return PyArray_LONG; + case 'i': return PyArray_INT; + case 'l': return PyArray_LONGLONG; case 'f': return PyArray_DOUBLE; case 'c': return PyArray_CDOUBLE; + case 's': return PyArray_STRING; default: - PyErr_SetString(PyExc_TypeError, "signature value not in 'ifc'"); + PyErr_SetString(PyExc_TypeError, "signature value not in 'bilfcs'"); return -1; } } @@ -502,7 +581,6 @@ static int get_reduction_axis(PyObject* program) { - char last_opcode, sig; int end = PyString_Size(program); int axis = ((unsigned char *)PyString_AS_STRING(program))[end-1]; if (axis != 255 && axis >= MAX_DIMS) @@ -579,7 +657,7 @@ } arg = program[argloc]; - if (sig != 'n' && (arg >= n_buffers) || (arg < 0)) { + if (sig != 'n' && ((arg >= n_buffers) || (arg < 0))) { PyErr_Format(PyExc_RuntimeError, "invalid program: buffer out of range (%i) at %i", arg, argloc); return -1; } @@ -630,8 +708,10 @@ PyObject *signature = NULL, *tempsig = NULL, *constsig = NULL; PyObject *fullsig = NULL, *program = NULL, *constants = NULL; PyObject *input_names = NULL, *o_constants = NULL; + int *itemsizes = NULL; char **mem = NULL, *rawmem = NULL; intp *memsteps; + intp *memsizes; int rawmemsize; static char *kwlist[] = {"signature", "tempsig", "program", "constants", @@ -660,33 +740,53 @@ Py_DECREF(constants); return -1; } + if (!(itemsizes = PyMem_New(int, n_constants))) { + Py_DECREF(constants); + return -1; + } for (i = 0; i < n_constants; i++) { PyObject *o; if (!(o = PySequence_GetItem(o_constants, i))) { /* new reference */ Py_DECREF(constants); Py_DECREF(constsig); + PyMem_Del(itemsizes); return -1; } PyTuple_SET_ITEM(constants, i, o); /* steals reference */ if (PyBool_Check(o)) { PyString_AS_STRING(constsig)[i] = 'b'; + itemsizes[i] = size_from_char('b'); continue; } if (PyInt_Check(o)) { PyString_AS_STRING(constsig)[i] = 'i'; + itemsizes[i] = size_from_char('i'); continue; } + if (PyLong_Check(o)) { + PyString_AS_STRING(constsig)[i] = 'l'; + itemsizes[i] = size_from_char('l'); + continue; + } if (PyFloat_Check(o)) { PyString_AS_STRING(constsig)[i] = 'f'; + itemsizes[i] = size_from_char('f'); continue; } if (PyComplex_Check(o)) { PyString_AS_STRING(constsig)[i] = 'c'; + itemsizes[i] = size_from_char('c'); continue; } - PyErr_SetString(PyExc_TypeError, "constants must be of type int/float/complex"); + if (PyString_Check(o)) { + PyString_AS_STRING(constsig)[i] = 's'; + itemsizes[i] = PyString_GET_SIZE(o); + continue; + } + PyErr_SetString(PyExc_TypeError, "constants must be of type bool/int/long/float/complex/str"); Py_DECREF(constsig); Py_DECREF(constants); + PyMem_Del(itemsizes); return -1; } } else { @@ -705,23 +805,34 @@ if (!fullsig) { Py_DECREF(constants); Py_DECREF(constsig); + PyMem_Del(itemsizes); + return -1; } if (!input_names) { input_names = Py_None; } - rawmemsize = BLOCK_SIZE1 * (size_from_sig(constsig) + size_from_sig(tempsig)); + /* Compute the size of registers. */ + rawmemsize = 0; + for (i = 0; i < n_constants; i++) + rawmemsize += itemsizes[i]; + rawmemsize += size_from_sig(tempsig); /* no string temporaries */ + rawmemsize *= BLOCK_SIZE1; + mem = PyMem_New(char *, 1 + n_inputs + n_constants + n_temps); rawmem = PyMem_New(char, rawmemsize); - memsteps = PyMem_New(int, 1 + n_inputs + n_constants + n_temps); - if (!mem || !rawmem || !memsteps) { + memsteps = PyMem_New(intp, 1 + n_inputs + n_constants + n_temps); + memsizes = PyMem_New(intp, 1 + n_inputs + n_constants + n_temps); + if (!mem || !rawmem || !memsteps || !memsizes) { Py_DECREF(constants); Py_DECREF(constsig); Py_DECREF(fullsig); + PyMem_Del(itemsizes); PyMem_Del(mem); PyMem_Del(rawmem); PyMem_Del(memsteps); + PyMem_Del(memsizes); return -1; } /* @@ -734,10 +845,10 @@ mem_offset = 0; for (i = 0; i < n_constants; i++) { char c = PyString_AS_STRING(constsig)[i]; - int size = size_from_char(c); + int size = itemsizes[i]; mem[i+n_inputs+1] = rawmem + mem_offset; mem_offset += BLOCK_SIZE1 * size; - memsteps[i+n_inputs+1] = size; + memsteps[i+n_inputs+1] = memsizes[i+n_inputs+1] = size; /* fill in the constants */ if (c == 'b') { char *bmem = (char*)mem[i+n_inputs+1]; @@ -746,11 +857,17 @@ bmem[j] = value; } } else if (c == 'i') { - long *imem = (long*)mem[i+n_inputs+1]; - long value = PyInt_AS_LONG(PyTuple_GET_ITEM(constants, i)); + int *imem = (int*)mem[i+n_inputs+1]; + int value = (int)PyInt_AS_LONG(PyTuple_GET_ITEM(constants, i)); for (j = 0; j < BLOCK_SIZE1; j++) { imem[j] = value; } + } else if (c == 'l') { + long long *lmem = (long long*)mem[i+n_inputs+1]; + long long value = PyLong_AsLongLong(PyTuple_GET_ITEM(constants, i)); + for (j = 0; j < BLOCK_SIZE1; j++) { + lmem[j] = value; + } } else if (c == 'f') { double *dmem = (double*)mem[i+n_inputs+1]; double value = PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(constants, i)); @@ -764,14 +881,32 @@ cmem[j] = value.real; cmem[j+1] = value.imag; } + } else if (c == 's') { + char *smem = (char*)mem[i+n_inputs+1]; + char *value = PyString_AS_STRING(PyTuple_GET_ITEM(constants, i)); + for (j = 0; j < size*BLOCK_SIZE1; j+=size) { + memcpy(smem + j, value, size); + } } } + /* This is no longer needed since no unusual item sizes appear + in temporaries (there are no string temporaries). */ + PyMem_Del(itemsizes); + /* Fill in 'mem' for temps */ for (i = 0; i < n_temps; i++) { - int size = size_from_char(PyString_AS_STRING(tempsig)[i]); + char c = PyString_AS_STRING(tempsig)[i]; + int size = size_from_char(c); + /* XXX: This check is quite useless, since using a string temporary + still causes a crash when freeing rawmem. Why? */ + if (c == 's') { + PyErr_SetString(PyExc_NotImplementedError, + "string temporaries are not supported"); + break; + } mem[i+n_inputs+n_constants+1] = rawmem + mem_offset; mem_offset += BLOCK_SIZE1 * size; - memsteps[i+n_inputs+n_constants+1] = size; + memsteps[i+n_inputs+n_constants+1] = memsizes[i+n_inputs+n_constants+1] = size; } /* See if any errors occured (e.g., in size_from_char) or if mem_offset is wrong */ if (PyErr_Occurred() || mem_offset != rawmemsize) { @@ -784,6 +919,7 @@ PyMem_Del(mem); PyMem_Del(rawmem); PyMem_Del(memsteps); + PyMem_Del(memsizes); return -1; } @@ -805,6 +941,7 @@ REPLACE_MEM(mem); REPLACE_MEM(rawmem); REPLACE_MEM(memsteps); + REPLACE_MEM(memsizes); self->rawmemsize = rawmemsize; #undef REPLACE_OBJ @@ -832,8 +969,8 @@ int count; int size; int findex; - int *shape; - int *strides; + intp *shape; + intp *strides; int *index; char *buffer; }; @@ -847,6 +984,7 @@ char **inputs; char **mem; intp *memsteps; + intp *memsizes; struct index_data *index_data; }; @@ -886,6 +1024,26 @@ #define BOUNDS_CHECK(arg) #endif +int +stringcmp(const char *s1, const char *s2, intp maxlen1, intp maxlen2) +{ + intp maxlen, nextpos; + /* Point to this when the end of a string is found, + to simulate infinte trailing NUL characters. */ + const char null = 0; + + maxlen = (maxlen1 > maxlen2) ? maxlen1 : maxlen2; + for (nextpos = 1; nextpos <= maxlen; nextpos++) { + if (*s1 < *s2) + return -1; + if (*s1 > *s2) + return +1; + s1 = (nextpos >= maxlen1) ? &null : s1+1; + s2 = (nextpos >= maxlen2) ? &null : s2+1; + } + return 0; +} + static inline int vm_engine_1(int start, int blen, struct vm_params params, int *pc_error) { @@ -943,6 +1101,7 @@ params.index_data = index_data; params.mem = self->mem; params.memsteps = self->memsteps; + params.memsizes = self->memsizes; params.r_end = PyString_Size(self->fullsig); blen1 = len - len % BLOCK_SIZE1; r = vm_engine_1(0, blen1, params, pc_error); @@ -966,7 +1125,7 @@ PyObject *output = NULL, *a_inputs = NULL; struct index_data *inddata = NULL; unsigned int n_inputs, n_dimensions = 0; - int shape[MAX_DIMS]; + intp shape[MAX_DIMS]; int i, j, size, r, pc_error; char **inputs = NULL; intp strides[MAX_DIMS]; /* clean up XXX */ @@ -1004,7 +1163,12 @@ int typecode = typecode_from_char(c); if (typecode == -1) goto cleanup_and_exit; /* Convert it just in case of a non-swapped array */ - a = PyArray_FROM_OTF(o, typecode, NOTSWAPPED); + if (!PyArray_Check(o) || PyArray_TYPE(o) != PyArray_STRING) { + a = PyArray_FROM_OTF(o, typecode, NOTSWAPPED); + } else { + Py_INCREF(PyArray_DESCR(o)); /* typecode is not enough */ + a = PyArray_FromAny(o, PyArray_DESCR(o), 0, 0, NOTSWAPPED, NULL); + } if (!a) goto cleanup_and_exit; PyTuple_SET_ITEM(a_inputs, i, a); /* steals reference */ if (PyArray_NDIM(a) > n_dimensions) @@ -1042,7 +1206,7 @@ for (i = 0; i < n_inputs; i++) { PyObject *a = PyTuple_GET_ITEM(a_inputs, i); PyObject *b; - int strides[MAX_DIMS]; + intp strides[MAX_DIMS]; int delta = n_dimensions - PyArray_NDIM(a); if (PyArray_NDIM(a)) { for (j = 0; j < n_dimensions; j++) @@ -1071,15 +1235,25 @@ if (PyArray_NDIM(a) == 0) { /* Broadcast scalars */ intp dims[1] = {BLOCK_SIZE1}; - b = PyArray_SimpleNew(1, dims, typecode); + Py_INCREF(PyArray_DESCR(a)); + b = PyArray_SimpleNewFromDescr(1, dims, PyArray_DESCR(a)); if (!b) goto cleanup_and_exit; self->memsteps[i+1] = 0; + self->memsizes[i+1] = PyArray_ITEMSIZE(a); PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, b); /* steals reference */ inputs[i] = PyArray_DATA(b); - if (typecode == PyArray_LONG) { - long value = ((long*)PyArray_DATA(a))[0]; + if (typecode == PyArray_BOOL) { + char value = ((char*)PyArray_DATA(a))[0]; for (j = 0; j < BLOCK_SIZE1; j++) - ((long*)PyArray_DATA(b))[j] = value; + ((char*)PyArray_DATA(b))[j] = value; + } else if (typecode == PyArray_INT) { + int value = ((int*)PyArray_DATA(a))[0]; + for (j = 0; j < BLOCK_SIZE1; j++) + ((int*)PyArray_DATA(b))[j] = value; + } else if (typecode == PyArray_LONGLONG) { + long long value = ((long long*)PyArray_DATA(a))[0]; + for (j = 0; j < BLOCK_SIZE1; j++) + ((long long*)PyArray_DATA(b))[j] = value; } else if (typecode == PyArray_DOUBLE) { double value = ((double*)PyArray_DATA(a))[0]; for (j = 0; j < BLOCK_SIZE1; j++) @@ -1091,17 +1265,25 @@ ((double*)PyArray_DATA(b))[j] = rvalue; ((double*)PyArray_DATA(b))[j+1] = ivalue; } + } else if (typecode == PyArray_STRING) { + int itemsize = PyArray_ITEMSIZE(a); + char *value = (char*)(PyArray_DATA(a)); + for (j = 0; j < itemsize*BLOCK_SIZE1; j+=itemsize) + memcpy((char*)(PyArray_DATA(b)) + j, value, itemsize); } else { PyErr_SetString(PyExc_RuntimeError, "illegal typecode value"); goto cleanup_and_exit; } } else { - PyObject *origA = a; - int inner_size = -1; - /* Check array is contiguous */ - for (j = PyArray_NDIM(a)-1; j >= 0; j--) { - if ((inner_size == -1 && PyArray_STRIDE(a, j) % PyArray_ITEMSIZE(a)) || - (inner_size != -1 && PyArray_STRIDE(a, j) != inner_size)) { + /* Check that discontiguous strides appear only on the last + dimension. If not, the arrays should be copied. + Furthermore, such arrays can appear when doing + broadcasting above, so this check really needs to be + here, and not in Python space. */ + intp inner_size; + for (j = PyArray_NDIM(a)-2; j >= 0; j--) { + inner_size = PyArray_STRIDE(a, j) * PyArray_DIM(a, j); + if (PyArray_STRIDE(a, j+1) != inner_size) { intp dims[1] = {BLOCK_SIZE1}; inddata[i+1].count = PyArray_NDIM(a); inddata[i+1].findex = -1; @@ -1112,20 +1294,24 @@ inddata[i+1].index = PyMem_New(int, inddata[i+1].count); for (j = 0; j < inddata[i+1].count; j++) inddata[i+1].index[j] = 0; - a = PyArray_SimpleNew(1, dims, typecode); - PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, a); /* steals reference */ + Py_INCREF(PyArray_DESCR(a)); + a = PyArray_SimpleNewFromDescr(1, dims, PyArray_DESCR(a)); + /* steals reference below */ + PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, a); break; } - inner_size = PyArray_STRIDE(a, j) * PyArray_DIM(a, j); } self->memsteps[i+1] = PyArray_STRIDE(a, PyArray_NDIM(a)-1); + self->memsizes[i+1] = PyArray_ITEMSIZE(a); inputs[i] = PyArray_DATA(a); } } if (last_opcode(self->program) > OP_REDUCTION) { + /* A reduction can not result in a string, + so we don't need to worry about item sizes here. */ char retsig = get_return_sig(self->program); int axis = get_reduction_axis(self->program); self->memsteps[0] = 0; /*size_from_char(retsig);*/ @@ -1188,10 +1374,26 @@ } else { char retsig = get_return_sig(self->program); - self->memsteps[0] = size_from_char(retsig); - output = PyArray_SimpleNew(n_dimensions, - shape, - typecode_from_char(retsig)); + if (retsig != 's') { + self->memsteps[0] = self->memsizes[0] = size_from_char(retsig); + output = PyArray_SimpleNew( + n_dimensions, shape, typecode_from_char(retsig)); + } else { + /* Since the *only* supported operation returning a string + * is a copy, the size of returned strings + * can be directly gotten from the first (and only) + * input/constant/temporary. */ + PyArray_Descr *descr; + if (n_inputs > 0) { /* input, like in 'a' where a -> 'foo' */ + descr = PyArray_DESCR(PyTuple_GET_ITEM(a_inputs, 1)); + Py_INCREF(descr); + } else { /* constant, like in '"foo"' */ + descr = PyArray_DescrFromType(PyArray_STRING); + descr->elsize = self->memsizes[1]; + } /* no string temporaries, so no third case */ + self->memsteps[0] = self->memsizes[0] = self->memsizes[1]; + output = PyArray_SimpleNewFromDescr(n_dimensions, shape, descr); + } if (!output) goto cleanup_and_exit; } @@ -1311,17 +1513,30 @@ add_op("invert_bb", OP_INVERT_BB); add_op("and_bbb", OP_AND_BBB); add_op("or_bbb", OP_OR_BBB); + + add_op("eq_bbb", OP_EQ_BBB); + add_op("ne_bbb", OP_NE_BBB); + add_op("gt_bii", OP_GT_BII); add_op("ge_bii", OP_GE_BII); add_op("eq_bii", OP_EQ_BII); add_op("ne_bii", OP_NE_BII); + add_op("gt_bll", OP_GT_BLL); + add_op("ge_bll", OP_GE_BLL); + add_op("eq_bll", OP_EQ_BLL); + add_op("ne_bll", OP_NE_BLL); + add_op("gt_bff", OP_GT_BFF); add_op("ge_bff", OP_GE_BFF); add_op("eq_bff", OP_EQ_BFF); add_op("ne_bff", OP_NE_BFF); - add_op("cast_ib", OP_CAST_IB); + add_op("gt_bss", OP_GT_BSS); + add_op("ge_bss", OP_GE_BSS); + add_op("eq_bss", OP_EQ_BSS); + add_op("ne_bss", OP_NE_BSS); + add_op("ones_like_ii", OP_ONES_LIKE_II); add_op("copy_ii", OP_COPY_II); add_op("neg_ii", OP_NEG_II); @@ -1331,10 +1546,22 @@ add_op("div_iii", OP_DIV_III); add_op("pow_iii", OP_POW_III); add_op("mod_iii", OP_MOD_III); - add_op("where_ifii", OP_WHERE_IFII); + add_op("where_ibii", OP_WHERE_IBII); - add_op("cast_fb", OP_CAST_FB); + add_op("cast_li", OP_CAST_LI); + add_op("ones_like_ll", OP_ONES_LIKE_LL); + add_op("copy_ll", OP_COPY_LL); + add_op("neg_ll", OP_NEG_LL); + add_op("add_lll", OP_ADD_LLL); + add_op("sub_lll", OP_SUB_LLL); + add_op("mul_lll", OP_MUL_LLL); + add_op("div_lll", OP_DIV_LLL); + add_op("pow_lll", OP_POW_LLL); + add_op("mod_lll", OP_MOD_LLL); + add_op("where_lbll", OP_WHERE_LBLL); + add_op("cast_fi", OP_CAST_FI); + add_op("cast_fl", OP_CAST_FL); add_op("copy_ff", OP_COPY_FF); add_op("ones_like_ff", OP_ONES_LIKE_FF); add_op("neg_cc", OP_NEG_CC); @@ -1350,15 +1577,15 @@ add_op("tan_ff", OP_TAN_FF); add_op("sqrt_ff", OP_SQRT_FF); add_op("arctan2_fff", OP_ARCTAN2_FFF); - add_op("where_ffff", OP_WHERE_FFFF); + add_op("where_fbff", OP_WHERE_FBFF); add_op("func_ff", OP_FUNC_FF); add_op("func_fff", OP_FUNC_FFF); add_op("eq_bcc", OP_EQ_BCC); add_op("ne_bcc", OP_NE_BCC); - add_op("cast_cb", OP_CAST_CB); add_op("cast_ci", OP_CAST_CI); + add_op("cast_cl", OP_CAST_CL); add_op("cast_cf", OP_CAST_CF); add_op("copy_cc", OP_COPY_CC); add_op("ones_like_cc", OP_ONES_LIKE_CC); @@ -1367,7 +1594,7 @@ add_op("sub_ccc", OP_SUB_CCC); add_op("mul_ccc", OP_MUL_CCC); add_op("div_ccc", OP_DIV_CCC); - add_op("where_cfcc", OP_WHERE_CFCC); + add_op("where_cbcc", OP_WHERE_CBCC); add_op("func_cc", OP_FUNC_CC); add_op("func_ccc", OP_FUNC_CCC); @@ -1375,11 +1602,15 @@ add_op("imag_fc", OP_IMAG_FC); add_op("complex_cff", OP_COMPLEX_CFF); + add_op("copy_ss", OP_COPY_SS); + add_op("sum_iin", OP_SUM_IIN); + add_op("sum_lln", OP_SUM_LLN); add_op("sum_ffn", OP_SUM_FFN); add_op("sum_ccn", OP_SUM_CCN); add_op("prod_iin", OP_PROD_IIN); + add_op("prod_lln", OP_PROD_LLN); add_op("prod_ffn", OP_PROD_FFN); add_op("prod_ccn", OP_PROD_CCN); Modified: trunk/scipy/sandbox/numexpr/tests/test_numexpr.py =================================================================== --- trunk/scipy/sandbox/numexpr/tests/test_numexpr.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/tests/test_numexpr.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -6,7 +6,7 @@ from numexpr import E, numexpr, evaluate, disassemble restore_path() -class TestNumExpr(NumpyTestCase): +class test_numexpr(NumpyTestCase): def check_simple(self): ex = 2.0 * E.a + 3.0 * E.b * E.c func = numexpr(ex, signature=[('a', float), ('b', float), ('c', float)]) @@ -63,14 +63,14 @@ x = x.astype(int) assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0)) assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0)) + # Check longs + x = x.astype(long) + assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0)) + assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0)) # Check complex x = x + 5j assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0)) assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0)) - # Check boolean (should cast to integer) - x = (arange(10) % 2).astype(bool) - assert_equal(evaluate("prod(x,axis=0)"), prod(x,axis=0)) - assert_equal(evaluate("sum(x,axis=0)"), sum(x,axis=0)) def check_axis(self): y = arange(9.0).reshape(3,3) @@ -95,7 +95,7 @@ [('mul_fff', 'r0', 'r1[x]', 'r1[x]'), ('add_fff', 'r0', 'r0', 'c2[2.0]')]) -class TestEvaluate(NumpyTestCase): +class test_evaluate(NumpyTestCase): def check_simple(self): a = array([1., 2., 3.]) b = array([4., 5., 6.]) @@ -187,8 +187,8 @@ '2*a + (cos(3)+5)*sinh(cos(b))', '2*a + arctan2(a, b)', 'arcsin(0.5)', - 'where(a, 2, b)', - 'where((a-10).real, a, 2)', + 'where(a != 0.0, 2, b)', + 'where((a-10).real != 0.0, a, 2)', 'cos(1+1)', '1+1', '1', @@ -239,7 +239,7 @@ class Skip(Exception): pass -class TestExpressions(NumpyTestCase): +class test_expressions(NumpyTestCase): pass def generate_check_expressions(): @@ -274,7 +274,7 @@ new.instancemethod(method, None, test_expressions)) x = None for test_scalar in [0,1,2]: - for dtype in [int, float, complex]: + for dtype in [int, long, float, complex]: array_size = 100 a = arange(2*array_size, dtype=dtype)[::2] a2 = zeros([array_size, array_size], dtype=dtype) @@ -298,7 +298,7 @@ '<' in expr or '>' in expr or '%' in expr or "arctan2" in expr or "fmod" in expr): continue # skip complex comparisons - if dtype == int and test_scalar and expr == '(a+1) ** -1': + if dtype in (int, long) and test_scalar and expr == '(a+1) ** -1': continue make_check_method(a, a2, b, c, d, e, x, expr, test_scalar, dtype, @@ -306,5 +306,145 @@ generate_check_expressions() +class test_int32_int64(NumpyTestCase): + def check_small_long(self): + # Small longs should not be downgraded to ints. + res = evaluate('42L') + assert_array_equal(res, 42) + self.assertEqual(res.dtype.name, 'int64') + + def check_big_int(self): + # Big ints should be promoted to longs. + # This test may only fail under 64-bit platforms. + res = evaluate('2**40') + assert_array_equal(res, 2**40) + self.assertEqual(res.dtype.name, 'int64') + + def check_long_constant_promotion(self): + int32array = arange(100, dtype='int32') + res = int32array * 2 + res32 = evaluate('int32array * 2') + res64 = evaluate('int32array * 2L') + assert_array_equal(res, res32) + assert_array_equal(res, res64) + self.assertEqual(res32.dtype.name, 'int32') + self.assertEqual(res64.dtype.name, 'int64') + + def check_int64_array_promotion(self): + int32array = arange(100, dtype='int32') + int64array = arange(100, dtype='int64') + respy = int32array * int64array + resnx = evaluate('int32array * int64array') + assert_array_equal(respy, resnx) + self.assertEqual(resnx.dtype.name, 'int64') + +class test_strings(NumpyTestCase): + BLOCK_SIZE1 = 128 + BLOCK_SIZE2 = 8 + str_list1 = ['foo', 'bar', '', ' '] + str_list2 = ['foo', '', 'x', ' '] + str_nloops = len(str_list1) * (BLOCK_SIZE1 + BLOCK_SIZE2 + 1) + str_array1 = array(str_list1 * str_nloops) + str_array2 = array(str_list2 * str_nloops) + str_constant = 'doodoo' + + def check_null_chars(self): + str_list = [ + '\0\0\0', '\0\0foo\0', '\0\0foo\0b', '\0\0foo\0b\0', + 'foo\0', 'foo\0b', 'foo\0b\0', 'foo\0bar\0baz\0\0' ] + for s in str_list: + r = evaluate('s') + self.assertEqual(s, r.tostring()) # check *all* stored data + + def check_compare_copy(self): + sarr = self.str_array1 + expr = 'sarr' + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_compare_array(self): + sarr1 = self.str_array1 + sarr2 = self.str_array2 + expr = 'sarr1 >= sarr2' + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_compare_variable(self): + sarr = self.str_array1 + svar = self.str_constant + expr = 'sarr >= svar' + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_compare_constant(self): + sarr = self.str_array1 + expr = 'sarr >= %r' % self.str_constant + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_add_string_array(self): + sarr1 = self.str_array1 + sarr2 = self.str_array2 + expr = 'sarr1 + sarr2' + self.assert_missing_op('add_sss', expr, locals()) + + def check_add_numeric_array(self): + sarr = self.str_array1 + narr = arange(len(sarr), dtype='int32') + expr = 'sarr >= narr' + self.assert_missing_op('ge_bsi', expr, locals()) + + def assert_missing_op(self, op, expr, local_dict): + msg = "expected NotImplementedError regarding '%s'" % op + try: + evaluate(expr, local_dict) + except NotImplementedError, nie: + if "'%s'" % op not in nie.args[0]: + self.fail(msg) + else: + self.fail(msg) + + def check_compare_prefix(self): + # Check comparing two strings where one is a prefix of the + # other. + for s1, s2 in [ ('foo', 'foobar'), ('foo', 'foo\0bar'), + ('foo\0a', 'foo\0bar') ]: + self.assert_(evaluate('s1 < s2')) + self.assert_(evaluate('s1 <= s2')) + self.assert_(evaluate('~(s1 == s2)')) + self.assert_(evaluate('~(s1 >= s2)')) + self.assert_(evaluate('~(s1 > s2)')) + + # Check for NumPy array-style semantics in string equality. + s1, s2 = 'foo', 'foo\0\0' + self.assert_(evaluate('s1 == s2')) + +# Case for testing selections in fields which are aligned but whose +# data length is not an exact multiple of the length of the record. +# The following test exposes the problem only in 32-bit machines, +# because in 64-bit machines 'c2' is unaligned. However, this should +# check most platforms where, while not unaligned, 'len(datatype) > +# boundary_alignment' is fullfilled. +class test_irregular_stride(NumpyTestCase): + def check_select(self): + f0 = arange(10, dtype=int32) + f1 = arange(10, dtype=float64) + + irregular = rec.fromarrays([f0, f1]) + + f0 = irregular['f0'] + f1 = irregular['f1'] + + i0 = evaluate('f0 < 5') + i1 = evaluate('f1 < 5') + + assert_array_equal(f0[i0], arange(5, dtype=int32)) + assert_array_equal(f1[i1], arange(5, dtype=float64)) + + if __name__ == '__main__': NumpyTest().run() Modified: trunk/scipy/sandbox/numexpr/timing.py =================================================================== --- trunk/scipy/sandbox/numexpr/timing.py 2007-11-22 12:38:12 UTC (rev 3567) +++ trunk/scipy/sandbox/numexpr/timing.py 2007-11-23 07:20:02 UTC (rev 3568) @@ -88,13 +88,13 @@ """ % ((array_size,)*3) expr5 = 'where(0.1*a > arctan2(a, b), 2*a, arctan2(a,b))' -expr6 = 'where(a, 2, b)' +expr6 = 'where(a != 0.0, 2, b)' -expr7 = 'where(a-10, a, 2)' +expr7 = 'where(a-10 != 0.0, a, 2)' -expr8 = 'where(a%2, b+5, 2)' +expr8 = 'where(a%2 != 0.0, b+5, 2)' -expr9 = 'where(a%2, 2, b+5)' +expr9 = 'where(a%2 != 0.0, 2, b+5)' expr10 = 'a**2 + (b+1)**-2.5' @@ -131,6 +131,6 @@ if __name__ == '__main__': averages = [] - for i in range(10): + for i in range(iterations): averages.append(compare()) print "Averages:", ', '.join("%.2f" % x for x in averages) From scipy-svn at scipy.org Fri Nov 23 02:21:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 01:21:58 -0600 (CST) Subject: [Scipy-svn] r3569 - in trunk/scipy/sandbox/numexpr: . bench Message-ID: <20071123072158.20A4339C069@new.scipy.org> Author: cookedm Date: 2007-11-23 01:21:55 -0600 (Fri, 23 Nov 2007) New Revision: 3569 Added: trunk/scipy/sandbox/numexpr/bench/ trunk/scipy/sandbox/numexpr/bench/boolean_timing.py trunk/scipy/sandbox/numexpr/bench/timing.py Removed: trunk/scipy/sandbox/numexpr/boolean_timing.py trunk/scipy/sandbox/numexpr/timing.py Log: [numexpr] Move timing files to a bench/ subdirectory Copied: trunk/scipy/sandbox/numexpr/bench/boolean_timing.py (from rev 3568, trunk/scipy/sandbox/numexpr/boolean_timing.py) Copied: trunk/scipy/sandbox/numexpr/bench/timing.py (from rev 3568, trunk/scipy/sandbox/numexpr/timing.py) Deleted: trunk/scipy/sandbox/numexpr/boolean_timing.py =================================================================== --- trunk/scipy/sandbox/numexpr/boolean_timing.py 2007-11-23 07:20:02 UTC (rev 3568) +++ trunk/scipy/sandbox/numexpr/boolean_timing.py 2007-11-23 07:21:55 UTC (rev 3569) @@ -1,139 +0,0 @@ -import sys -import timeit -import numpy - -array_size = 1000*1000 -iterations = 10 - -numpy_ttime = 0 -numpy_sttime = 0 -numpy_nttime = 0 -numexpr_ttime = 0 -numexpr_sttime = 0 -numexpr_nttime = 0 - -def compare_times(expr, nexpr): - global numpy_ttime - global numpy_sttime - global numpy_nttime - global numexpr_ttime - global numexpr_sttime - global numexpr_nttime - - print "******************* Expression:", expr - - setup_contiguous = setupNP_contiguous - setup_strided = setupNP_strided - setup_unaligned = setupNP_unaligned - - numpy_timer = timeit.Timer(expr, setup_contiguous) - numpy_time = round(numpy_timer.timeit(number=iterations), 4) - numpy_ttime += numpy_time - print 'numpy:', numpy_time / iterations - - numpy_timer = timeit.Timer(expr, setup_strided) - numpy_stime = round(numpy_timer.timeit(number=iterations), 4) - numpy_sttime += numpy_stime - print 'numpy strided:', numpy_stime / iterations - - numpy_timer = timeit.Timer(expr, setup_unaligned) - numpy_ntime = round(numpy_timer.timeit(number=iterations), 4) - numpy_nttime += numpy_ntime - print 'numpy unaligned:', numpy_ntime / iterations - - evalexpr = 'evaluate("%s", optimization="aggressive")' % expr - numexpr_timer = timeit.Timer(evalexpr, setup_contiguous) - numexpr_time = round(numexpr_timer.timeit(number=iterations), 4) - numexpr_ttime += numexpr_time - print "numexpr:", numexpr_time/iterations, - print "Speed-up of numexpr over numpy:", round(numpy_time/numexpr_time, 4) - - evalexpr = 'evaluate("%s", optimization="aggressive")' % expr - numexpr_timer = timeit.Timer(evalexpr, setup_strided) - numexpr_stime = round(numexpr_timer.timeit(number=iterations), 4) - numexpr_sttime += numexpr_stime - print "numexpr strided:", numexpr_stime/iterations, - print "Speed-up of numexpr strided over numpy:", \ - round(numpy_stime/numexpr_stime, 4) - - evalexpr = 'evaluate("%s", optimization="aggressive")' % expr - numexpr_timer = timeit.Timer(evalexpr, setup_unaligned) - numexpr_ntime = round(numexpr_timer.timeit(number=iterations), 4) - numexpr_nttime += numexpr_ntime - print "numexpr unaligned:", numexpr_ntime/iterations, - print "Speed-up of numexpr unaligned over numpy:", \ - round(numpy_ntime/numexpr_ntime, 4) - - - -setupNP = """\ -from numpy import arange, where, arctan2, sqrt -from numpy import rec as records -from numexpr import evaluate - -# Initialize a recarray of 16 MB in size -r=records.array(None, formats='a%s,i4,f8', shape=%s) -c1 = r.field('f0')%s -i2 = r.field('f1')%s -f3 = r.field('f2')%s -c1[:] = "a" -i2[:] = arange(%s)/1000 -f3[:] = i2/2. -""" - -setupNP_contiguous = setupNP % (4, array_size, - ".copy()", ".copy()", ".copy()", - array_size) -setupNP_strided = setupNP % (4, array_size, "", "", "", array_size) -setupNP_unaligned = setupNP % (1, array_size, "", "", "", array_size) - - -expressions = [] -expressions.append('i2 > 0') -expressions.append('i2 < 0') -expressions.append('i2 < f3') -expressions.append('i2-10 < f3') -expressions.append('i2*f3+f3*f3 > i2') -expressions.append('0.1*i2 > arctan2(i2, f3)') -expressions.append('i2%2 > 3') -expressions.append('i2%10 < 4') -expressions.append('i2**2 + (f3+1)**-2.5 < 3') -expressions.append('(f3+1)**50 > i2') -expressions.append('sqrt(i2**2 + f3**2) > 1') -expressions.append('(i2>2) | ((f3**2>3) & ~(i2*f3<2))') - -def compare(expression=False): - if expression: - compare_times(expression, 1) - sys.exit(0) - nexpr = 0 - for expr in expressions: - nexpr += 1 - compare_times(expr, nexpr) - print - -if __name__ == '__main__': - - print 'Python version: %s' % sys.version - print "NumPy version: %s" % numpy.__version__ - - if len(sys.argv) > 1: - expression = sys.argv[1] - print "expression-->", expression - compare(expression) - else: - compare() - - print "*************** TOTALS **************************" - print "numpy total:", numpy_ttime/iterations - print "numpy strided total:", numpy_sttime/iterations - print "numpy unaligned total:", numpy_nttime/iterations - print "numexpr total:", numexpr_ttime/iterations - print "Speed-up of numexpr over numpy:", \ - round(numpy_ttime/numexpr_ttime, 3) - print "numexpr strided total:", numexpr_sttime/iterations - print "Speed-up of numexpr strided over numpy:", \ - round(numpy_sttime/numexpr_sttime, 3) - print "numexpr unaligned total:", numexpr_nttime/iterations - print "Speed-up of numexpr unaligned over numpy:", \ - round(numpy_nttime/numexpr_nttime, 3) Deleted: trunk/scipy/sandbox/numexpr/timing.py =================================================================== --- trunk/scipy/sandbox/numexpr/timing.py 2007-11-23 07:20:02 UTC (rev 3568) +++ trunk/scipy/sandbox/numexpr/timing.py 2007-11-23 07:21:55 UTC (rev 3569) @@ -1,136 +0,0 @@ -import timeit, numpy - -array_size = 1e6 -iterations = 10 - -def compare_times(setup, expr): - print "Expression:", expr - namespace = {} - exec setup in namespace - - numpy_timer = timeit.Timer(expr, setup) - numpy_time = numpy_timer.timeit(number=iterations) - print 'numpy:', numpy_time / iterations - - try: - weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) - weave_time = weave_timer.timeit(number=iterations) - print "Weave:", weave_time/iterations - - print "Speed-up of weave over numpy:", numpy_time/weave_time - except: - print "Skipping weave timing" - - numexpr_timer = timeit.Timer('evaluate("%s", optimization="aggressive")' % expr, setup) - numexpr_time = numexpr_timer.timeit(number=iterations) - print "numexpr:", numexpr_time/iterations - - print "Speed-up of numexpr over numpy:", numpy_time/numexpr_time - return numpy_time/numexpr_time - -setup1 = """\ -from numpy import arange -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -result = arange(%f) -b = arange(%f) -c = arange(%f) -d = arange(%f) -e = arange(%f) -""" % ((array_size,)*5) -expr1 = 'b*c+d*e' - -setup2 = """\ -from numpy import arange -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(%f) -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr2 = '2*a+3*b' - - -setup3 = """\ -from numpy import arange, sin, cos, sinh -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f)[::2] -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr3 = '2*a + (cos(3)+5)*sinh(cos(b))' - - -setup4 = """\ -from numpy import arange, sin, cos, sinh, arctan2 -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f)[::2] -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr4 = '2*a + arctan2(a, b)' - - -setup5 = """\ -from numpy import arange, sin, cos, sinh, arctan2, sqrt, where -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f, dtype=float)[::2] -b = arange(%f, dtype=float) -result = arange(%f, dtype=float) -""" % ((array_size,)*3) -expr5 = 'where(0.1*a > arctan2(a, b), 2*a, arctan2(a,b))' - -expr6 = 'where(a != 0.0, 2, b)' - -expr7 = 'where(a-10 != 0.0, a, 2)' - -expr8 = 'where(a%2 != 0.0, b+5, 2)' - -expr9 = 'where(a%2 != 0.0, 2, b+5)' - -expr10 = 'a**2 + (b+1)**-2.5' - -expr11 = '(a+1)**50' - -expr12 = 'sqrt(a**2 + b**2)' - -def compare(check_only=False): - total = 0 - total += compare_times(setup1, expr1) - print - total += compare_times(setup2, expr2) - print - total += compare_times(setup3, expr3) - print - total += compare_times(setup4, expr4) - print - total += compare_times(setup5, expr6) - print - total += compare_times(setup5, expr7) - print - total += compare_times(setup5, expr8) - print - total += compare_times(setup5, expr9) - print - total += compare_times(setup5, expr10) - print - total += compare_times(setup5, expr11) - print - total += compare_times(setup5, expr12) - print - print "Average =", total / 11.0 - return total - -if __name__ == '__main__': - averages = [] - for i in range(iterations): - averages.append(compare()) - print "Averages:", ', '.join("%.2f" % x for x in averages) From scipy-svn at scipy.org Fri Nov 23 16:42:35 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 15:42:35 -0600 (CST) Subject: [Scipy-svn] r3570 - in trunk/scipy/sandbox/timeseries: . include lib src tests Message-ID: <20071123214235.8E939C7C043@new.scipy.org> Author: mattknox_ca Date: 2007-11-23 15:42:20 -0600 (Fri, 23 Nov 2007) New Revision: 3570 Modified: trunk/scipy/sandbox/timeseries/dates.py trunk/scipy/sandbox/timeseries/include/c_dates.h trunk/scipy/sandbox/timeseries/lib/moving_funcs.py trunk/scipy/sandbox/timeseries/plotlib.py trunk/scipy/sandbox/timeseries/report.py trunk/scipy/sandbox/timeseries/src/c_dates.c trunk/scipy/sandbox/timeseries/src/cseries.c trunk/scipy/sandbox/timeseries/tests/test_dates.py trunk/scipy/sandbox/timeseries/tseries.py Log: - renamed 'thisday' to 'now' (left 'thisday' and 'today' as deprecated aliases) - added tolist method to DateArray which returns a list of datetime objects - added additional documentation - renamed 'day_of_week' to 'weekday' (left 'day_of_week' as deprecated alias for now) Modified: trunk/scipy/sandbox/timeseries/dates.py =================================================================== --- trunk/scipy/sandbox/timeseries/dates.py 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/dates.py 2007-11-23 21:42:20 UTC (rev 3570) @@ -12,6 +12,7 @@ import datetime as dt +import operator import itertools import warnings import types @@ -36,17 +37,21 @@ cseries.set_callback_DateFromString(DateFromString) cseries.set_callback_DateTimeFromString(DateTimeFromString) -from cseries import Date, thisday, check_freq, check_freq_str, get_freq_group,\ +from cseries import Date, now, check_freq, check_freq_str, get_freq_group,\ DateCalc_Error, DateCalc_RangeError -today = thisday +# aliases for `now` function. These are deprecated +today = now +thisday = now + __all__ = [ 'Date', 'DateArray','isDate','isDateArray', 'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', 'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', -'day_of_week','day_of_year','day','month','quarter','year','hour','minute', -'second','thisday','today','prevbusday','period_break', 'check_freq', -'check_freq_str','get_freq_group', 'DateCalc_Error', 'DateCalc_RangeError' +'day_of_week','weekday','day_of_year','day','month','quarter','year','hour', +'minute','second','now','thisday','today','prevbusday','period_break', +'check_freq','check_freq_str','get_freq_group', 'DateCalc_Error', +'DateCalc_RangeError' ] @@ -93,22 +98,23 @@ def prevbusday(day_end_hour=18, day_end_min=0): """Returns the previous business day (Monday-Friday) at business frequency. -:Parameters: - - day_end_hour : (int, *[18]* ) - - day_end_min : (int, *[0]*) +*Parameters*: + day_end_hour : {18, int} (optional) + day_end_min : {0, int} (optional) -:Return values: +*Return values*: If it is currently Saturday or Sunday, then the preceding Friday will be returned. If it is later than the specified day_end_hour and day_end_min, - thisday('b') will be returned. Otherwise, thisday('b')-1 will be returned. + now('Business') will be returned. Otherwise, now('Business')-1 will be + returned. """ tempDate = dt.datetime.now() dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 if dateNum < checkNum: - return thisday(_c.FR_BUS) - 1 + return now(_c.FR_BUS) - 1 else: - return thisday(_c.FR_BUS) + return now(_c.FR_BUS) def isDate(data): @@ -283,9 +289,11 @@ "Returns the day of month." return self.__getdateinfo__('D') @property - def day_of_week(self): + def weekday(self): "Returns the day of week." return self.__getdateinfo__('W') + # deprecated alias for weekday + day_of_week = weekday @property def day_of_year(self): "Returns the day of year." @@ -329,7 +337,7 @@ return self.__getdateinfo__('I') days = day - weekdays = day_of_week + weekdays = weekday yeardays = day_of_year months = month quarters = quarter @@ -355,7 +363,6 @@ "Converts the dates from values to ordinals." # Note: we better try to cache the result if self._cachedinfo['toord'] is None: -# diter = (Date(self.freq, value=d).toordinal() for d in self) if self.freq == _c.FR_UND: diter = (d.value for d in self) else: @@ -364,6 +371,13 @@ self._cachedinfo['toord'] = toord return self._cachedinfo['toord'] # + def tolist(self): + """Returns a hierarchical python list of standard datetime objects.""" + _result = numpy.empty(self.shape, dtype=numpy.object_) + for idx, val in numpy.ndenumerate(self): + operator.setitem(_result, idx, Date(freq=self.freq, value=val).datetime) + return _result.tolist() + # def tostring(self): "Converts the dates to strings." # Note: we better cache the result @@ -674,7 +688,9 @@ except SystemError: return getattr(numpy,self._methodname).__call__(caller, *args, **params) #............................ -day_of_week = _frommethod('day_of_week') +weekday = _frommethod('day_of_week') +# deprecated alias for weekday +day_of_week = weekday day_of_year = _frommethod('day_of_year') year = _frommethod('year') quarter = _frommethod('quarter') Modified: trunk/scipy/sandbox/timeseries/include/c_dates.h =================================================================== --- trunk/scipy/sandbox/timeseries/include/c_dates.h 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/include/c_dates.h 2007-11-23 21:42:20 UTC (rev 3570) @@ -110,7 +110,7 @@ PyObject *DateArray_getDateInfo(PyObject *, PyObject *); -PyObject *c_dates_thisday(PyObject *, PyObject *); +PyObject *c_dates_now(PyObject *, PyObject *); PyObject *c_dates_check_freq(PyObject *, PyObject *); PyObject *c_dates_check_freq_str(PyObject *, PyObject *); PyObject *c_dates_get_freq_group(PyObject *, PyObject *); Modified: trunk/scipy/sandbox/timeseries/lib/moving_funcs.py =================================================================== --- trunk/scipy/sandbox/timeseries/lib/moving_funcs.py 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/lib/moving_funcs.py 2007-11-23 21:42:20 UTC (rev 3570) @@ -366,10 +366,10 @@ ############################################################################### if __name__ == '__main__': - from timeseries import time_series, today + from timeseries import time_series, now from maskedarray.testutils import assert_equal, assert_almost_equal # - series = time_series(N.arange(10),start_date=today('D')) + series = time_series(N.arange(10),start_date=now('D')) # filtered = mov_sum(series,3) assert_equal(filtered, [0,1,3,6,9,12,15,18,21,24]) Modified: trunk/scipy/sandbox/timeseries/plotlib.py =================================================================== --- trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-23 21:42:20 UTC (rev 3570) @@ -574,7 +574,7 @@ if self.isminor: fmt = self.formatdict.pop(x, '') if fmt is not '': - retval = Date(self.freq, value=int(x)).strfmt(fmt) + retval = Date(self.freq, value=int(x)).strftime(fmt) else: retval = '' else: Modified: trunk/scipy/sandbox/timeseries/report.py =================================================================== --- trunk/scipy/sandbox/timeseries/report.py 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/report.py 2007-11-23 21:42:20 UTC (rev 3570) @@ -328,7 +328,7 @@ if datefmt is None: def datefmt_func(date): return str(date) else: - def datefmt_func(date): return date.strfmt(datefmt) + def datefmt_func(date): return date.strftime(datefmt) if dates is None: tseries = ts.align_series(*tseries) Modified: trunk/scipy/sandbox/timeseries/src/c_dates.c =================================================================== --- trunk/scipy/sandbox/timeseries/src/c_dates.c 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/src/c_dates.c 2007-11-23 21:42:20 UTC (rev 3570) @@ -1649,9 +1649,12 @@ } static char DateObject_strfmt_doc[] = +"Deprecated alias for strftime method"; + +static char DateObject_strftime_doc[] = "Returns string representation of Date object according to format specified.\n\n" -":Parameters:\n" -" - fmt : string\n" +"*Parameters*:\n" +" fmt : {str}\n" " Formatting string. Uses the same directives as in the time.strftime\n" " function in the standard Python time module. In addition, a few other\n" " directives are supported:\n" @@ -1665,7 +1668,7 @@ " the current quarter. This is the same as %Y unless the\n" " Date is one of the 'qtr-s' frequencies\n"; static PyObject * -DateObject_strfmt(DateObject *self, PyObject *args) +DateObject_strftime(DateObject *self, PyObject *args) { char *orig_fmt_str, *fmt_str; @@ -1689,7 +1692,7 @@ long (*toDaily)(long, char, asfreq_info*) = NULL; asfreq_info af_info; - if (!PyArg_ParseTuple(args, "s:strfmt(fmt)", &orig_fmt_str)) return NULL; + if (!PyArg_ParseTuple(args, "s:strftime(fmt)", &orig_fmt_str)) return NULL; toDaily = get_asfreq_func(self->freq, FR_DAY, 0); get_asfreq_info(self->freq, FR_DAY, &af_info); @@ -1821,7 +1824,7 @@ if (string_arg == NULL) { return NULL; } - retval = DateObject_strfmt(self, string_arg); + retval = DateObject_strftime(self, string_arg); Py_DECREF(string_arg); return retval; @@ -2098,7 +2101,7 @@ } static PyObject * -DateObject_day_of_week(DateObject *self, void *closure) { +DateObject_weekday(DateObject *self, void *closure) { struct date_info dinfo; if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; return PyInt_FromLong(dinfo.day_of_week); @@ -2173,8 +2176,11 @@ "Returns the week.", NULL}, {"day", (getter)DateObject_day, (setter)DateObject_ReadOnlyErr, "Returns the day of month.", NULL}, - {"day_of_week", (getter)DateObject_day_of_week, (setter)DateObject_ReadOnlyErr, + {"weekday", (getter)DateObject_weekday, (setter)DateObject_ReadOnlyErr, "Returns the day of week.", NULL}, + // deprecated alias for weekday property + {"day_of_week", (getter)DateObject_weekday, (setter)DateObject_ReadOnlyErr, + "Returns the day of week.", NULL}, {"day_of_year", (getter)DateObject_day_of_year, (setter)DateObject_ReadOnlyErr, "Returns the day of year.", NULL}, {"second", (getter)DateObject_second, (setter)DateObject_ReadOnlyErr, @@ -2223,7 +2229,10 @@ static PyMethodDef DateObject_methods[] = { {"toordinal", (PyCFunction)DateObject_toordinal, METH_NOARGS, DateObject_toordinal_doc}, - {"strfmt", (PyCFunction)DateObject_strfmt, METH_VARARGS, + {"strftime", (PyCFunction)DateObject_strftime, METH_VARARGS, + DateObject_strftime_doc}, + // deprecated alias for strftime + {"strfmt", (PyCFunction)DateObject_strftime, METH_VARARGS, DateObject_strfmt_doc}, {"asfreq", (PyCFunction)DateObject_asfreq, METH_VARARGS | METH_KEYWORDS, DateObject_asfreq_doc}, @@ -2331,7 +2340,7 @@ } PyObject * -c_dates_thisday(PyObject *self, PyObject *args) { +c_dates_now(PyObject *self, PyObject *args) { PyObject *freq, *init_args, *init_kwargs; time_t rawtime; @@ -2340,7 +2349,7 @@ DateObject *secondly_date; - if (!PyArg_ParseTuple(args, "O:thisday(freq)", &freq)) return NULL; + if (!PyArg_ParseTuple(args, "O:now(freq)", &freq)) return NULL; if ((freq_val = check_freq(freq)) == INT_ERR_CODE) return NULL; @@ -2635,7 +2644,7 @@ skip_periods = __skip_periods_day(freq); break; case 'W': //day of week - getDateInfo = &DateObject_day_of_week; + getDateInfo = &DateObject_weekday; skip_periods = __skip_periods_day(freq); break; case 'I': //week of year Modified: trunk/scipy/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/scipy/sandbox/timeseries/src/cseries.c 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/src/cseries.c 2007-11-23 21:42:20 UTC (rev 3570) @@ -26,11 +26,11 @@ METH_VARARGS, ""}, - {"thisday", (PyCFunction)c_dates_thisday, + {"now", (PyCFunction)c_dates_now, METH_VARARGS, - "Returns today's date, at the given frequency\n\n" - ":Parameters:\n" - " - freq : string/int\n" + "Returns the current date/time, at the given frequency\n\n" + "*Parameters*:\n" + " freq : {freq_spec}\n" " Frequency to convert the Date to. Accepts any valid frequency\n" " specification (string or integer)\n"}, Modified: trunk/scipy/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-23 21:42:20 UTC (rev 3570) @@ -29,7 +29,7 @@ from timeseries import const as C from timeseries.parser import DateFromString, DateTimeFromString from timeseries import Date, DateArray,\ - thisday, today, date_array, date_array_fromlist + now, date_array, date_array_fromlist from timeseries.cseries import freq_dict @@ -122,8 +122,8 @@ freqs = [x[0] for x in freq_dict.values() if x[0] != 'U'] for f in freqs: - today = thisday(f) - assert_equal(Date(freq=f, value=today.value), today) + _now = now(f) + assert_equal(Date(freq=f, value=_now.value), _now) print "finished test_consistent_value" def test_shortcuts(self): @@ -134,14 +134,14 @@ assert_equal(Date('D','2007-01'), Date('D', value=732677)) assert_equal(Date('D',732677), Date('D', value=732677)) # DateArray shortcuts - n = today('M') + n = now('M') d = date_array(start_date=n, length=3) assert_equal(date_array(n,length=3), d) assert_equal(date_array(n, n+2), d) print "finished test_shortcuts" class TestDateProperties(NumpyTestCase): - "Test properties such as year, month, day_of_week, etc...." + "Test properties such as year, month, weekday, etc...." def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) @@ -201,21 +201,21 @@ assert_equal(b_date.quarter, 1) assert_equal(b_date.month, 1) assert_equal(b_date.day, 1) - assert_equal(b_date.day_of_week, 0) + assert_equal(b_date.weekday, 0) assert_equal(b_date.day_of_year, 1) assert_equal(d_date.year, 2007) assert_equal(d_date.quarter, 1) assert_equal(d_date.month, 1) assert_equal(d_date.day, 1) - assert_equal(d_date.day_of_week, 0) + assert_equal(d_date.weekday, 0) assert_equal(d_date.day_of_year, 1) assert_equal(h_date.year, 2007) assert_equal(h_date.quarter, 1) assert_equal(h_date.month, 1) assert_equal(h_date.day, 1) - assert_equal(h_date.day_of_week, 0) + assert_equal(h_date.weekday, 0) assert_equal(h_date.day_of_year, 1) assert_equal(h_date.hour, 0) @@ -223,7 +223,7 @@ assert_equal(t_date.quarter, 1) assert_equal(t_date.month, 1) assert_equal(t_date.day, 1) - assert_equal(t_date.day_of_week, 0) + assert_equal(t_date.weekday, 0) assert_equal(t_date.day_of_year, 1) assert_equal(t_date.hour, 0) assert_equal(t_date.minute, 0) @@ -232,7 +232,7 @@ assert_equal(s_date.quarter, 1) assert_equal(s_date.month, 1) assert_equal(s_date.day, 1) - assert_equal(s_date.day_of_week, 0) + assert_equal(s_date.weekday, 0) assert_equal(s_date.day_of_year, 1) assert_equal(s_date.hour, 0) assert_equal(s_date.minute, 0) @@ -483,17 +483,17 @@ date_W_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) date_W_to_M = dWrap(Date(freq='M', year=2007, month=1)) - if Date(freq='D', year=2007, month=12, day=31).day_of_week == 6: + if Date(freq='D', year=2007, month=12, day=31).weekday == 6: date_W_to_A_end_of_year = dWrap(Date(freq='A', year=2007)) else: date_W_to_A_end_of_year = dWrap(Date(freq='A', year=2008)) - if Date(freq='D', year=2007, month=3, day=31).day_of_week == 6: + if Date(freq='D', year=2007, month=3, day=31).weekday == 6: date_W_to_Q_end_of_quarter = dWrap(Date(freq='Q', year=2007, quarter=1)) else: date_W_to_Q_end_of_quarter = dWrap(Date(freq='Q', year=2007, quarter=2)) - if Date(freq='D', year=2007, month=1, day=31).day_of_week == 6: + if Date(freq='D', year=2007, month=1, day=31).weekday == 6: date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=1)) else: date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=2)) @@ -877,7 +877,7 @@ assert_equal(empty_darray.get_steps(), None) def test_cachedinfo(self): - D = date_array(start_date=thisday('D'), length=5) + D = date_array(start_date=now('D'), length=5) Dstr = D.tostring() assert_equal(D.tostring(), Dstr) DL = D[[0,-1]] Modified: trunk/scipy/sandbox/timeseries/tseries.py =================================================================== --- trunk/scipy/sandbox/timeseries/tseries.py 2007-11-23 07:21:55 UTC (rev 3569) +++ trunk/scipy/sandbox/timeseries/tseries.py 2007-11-23 21:42:20 UTC (rev 3570) @@ -35,7 +35,7 @@ import dates from dates import DateError, InsufficientDateError from dates import Date, isDate, DateArray, isDateArray, \ - date_array, date_array_fromlist, date_array_fromrange, thisday, today, \ + date_array, date_array_fromlist, date_array_fromrange, now, \ check_freq, check_freq_str import cseries @@ -56,6 +56,7 @@ 'quarter', 'second','split', 'stack', 'tofile','tshift', +'week', 'year', ] @@ -595,9 +596,11 @@ """Returns the day of month for each date in self._dates.""" return self._dates.day @property - def day_of_week(self): + def weekday(self): """Returns the day of week for each date in self._dates.""" - return self._dates.day_of_week + return self._dates.weekday + # deprecated alias for weekday + day_of_week = weekday @property def day_of_year(self): """Returns the day of year for each date in self._dates.""" @@ -632,7 +635,7 @@ return self._dates.week days = day - weekdays = day_of_week + weekdays = weekday yeardays = day_of_year months = month quarters = quarter @@ -873,8 +876,11 @@ except SystemError: return getattr(numpy,self._methodname).__call__(caller, *args, **params) #............................ -day_of_week = _frommethod('day_of_week') +weekday = _frommethod('weekday') +# deprecated alias for weekday +day_of_week = weekday day_of_year = _frommethod('day_of_year') +week = _frommethod('week') year = _frommethod('year') quarter = _frommethod('quarter') month = _frommethod('month') @@ -1544,8 +1550,8 @@ saved. Otherwise, only the first occurence of the date is conserved. Example ->>> a = time_series([1,2,3], start_date=today('D')) ->>> b = time_series([10,20,30], start_date=today('D')+1) +>>> a = time_series([1,2,3], start_date=now('D')) +>>> b = time_series([10,20,30], start_date=now('D')+1) >>> c = concatenate((a,b)) >>> c._series masked_array(data = [ 1 2 3 30], From scipy-svn at scipy.org Fri Nov 23 18:26:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 17:26:07 -0600 (CST) Subject: [Scipy-svn] r3571 - trunk/scipy/sandbox/timeseries Message-ID: <20071123232607.4CA7939C053@new.scipy.org> Author: pierregm Date: 2007-11-23 17:26:02 -0600 (Fri, 23 Nov 2007) New Revision: 3571 Modified: trunk/scipy/sandbox/timeseries/dates.py trunk/scipy/sandbox/timeseries/plotlib.py Log: plotlib : ensured that TimeSeriesPlot.tsplot returns the plotted elements : prevented the minor ticks on the date axis to overwrite the major ticks : improved the finder functions dates : prevented the use of the combination toordinal()/fromordinal() in date_array Modified: trunk/scipy/sandbox/timeseries/dates.py =================================================================== --- trunk/scipy/sandbox/timeseries/dates.py 2007-11-23 21:42:20 UTC (rev 3570) +++ trunk/scipy/sandbox/timeseries/dates.py 2007-11-23 23:26:02 UTC (rev 3571) @@ -12,7 +12,6 @@ import datetime as dt -import operator import itertools import warnings import types @@ -585,10 +584,10 @@ dates = [Date(freq, datetime=m) for m in dlist] #...as datetime objects elif hasattr(template, 'toordinal'): - ords = numpy.fromiter((d.toordinal() for d in dlist), float_) if freq == _c.FR_UND: + ords = numpy.fromiter((d.toordinal() for d in dlist), float_) freq = guess_freq(ords) - dates = [Date(freq, datetime=dt.datetime.fromordinal(a)) for a in ords] + dates = [Date(freq, datetime=d) for d in dlist] # result = DateArray(dates, freq) result._unsorted = idx @@ -721,10 +720,20 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal - if 1: + if 0: dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] mdates = date_array_fromlist(dlist, 'M') - - if 2: + # + if 0: dlist = ['2007-01','2007-03','2007-04','2007-02'] mdates = date_array_fromlist(dlist, 'M') + # + if 1: + import datetime + dlist = [dt.datetime(2001,1,1,0), + dt.datetime(2001,1,2,1), + dt.datetime(2001,1,3,2)] + _dates = date_array(dlist,freq='H') + # + assert_equal(_dates.hour, [0,1,2]) + assert_equal(_dates.day, [1,2,3]) Modified: trunk/scipy/sandbox/timeseries/plotlib.py =================================================================== --- trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-23 21:42:20 UTC (rev 3570) +++ trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-23 23:26:02 UTC (rev 3571) @@ -30,6 +30,7 @@ #from matplotlib.transforms import nonsingular import numpy +from numpy import int_, bool_ import maskedarray as MA import timeseries @@ -47,16 +48,18 @@ The specific Subplot object class to add is given through the keywords `SubplotClass` or `class`. -:Parameters: - `figure_instance` : Figure object +*:Parameters*: + figure_instance : {Figure object} Figure to which the generic subplot should be attached. - `args` : Misc + args : {var} Miscellaneous arguments to the subplot. - `kwargs` : Dictionary + kwargs : {Dictionary} Keywords. Same keywords as `Subplot`, with the addition of - - `SubplotClass` : Type of subplot - - `subclass` : Shortcut to `SubplotClass`. - - any keyword required by the `SubplotClass` subclass. + * SubplotClass* : {string} + Type of subplot + *subclass* : {string} + Shortcut to SubplotClass. + * any keyword required by the `SubplotClass` subclass. """ key = figure_instance._make_key(*args, **kwargs) @@ -67,7 +70,7 @@ except TypeError: key = str(key) # - if key in figure_instance._seen: + if figure_instance._seen.has_key(key): ax = figure_instance._seen[key] figure_instance.sca(ax) return ax @@ -171,7 +174,7 @@ else: return True -def _daily_finder(vmin, vmax, freq, aslocator): +def _daily_finder(vmin, vmax, freq, asformatter): if freq == _c.FR_BUS: periodsperyear = 261 @@ -187,13 +190,13 @@ (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 - dates = date_array(start_date=Date(freq,vmin), - end_date=Date(freq, vmax)) - default = numpy.arange(vmin, vmax+1) + dates_ = date_array(start_date=Date(freq,vmin), + end_date=Date(freq, vmax)) # Initialize the output - if not aslocator: - format = numpy.empty(default.shape, dtype="|S10") - format.flat = '' + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S10')]) + info['val'] = numpy.arange(vmin, vmax+1) + info['fmt'] = '' def first_label(label_flags): if label_flags[0] == 0: return label_flags[1] @@ -201,115 +204,103 @@ # Case 1. Less than a month if span <= periodspermonth: - month_start = period_break(dates,'month') - if aslocator: - major = default[month_start] - minor = default - else: - year_start = period_break(dates,'year') - format[:] = '%d' - format[month_start] = '%d\n%b' - format[year_start] = '%d\n%b\n%Y' + month_start = period_break(dates_,'month') + info['maj'][month_start] = True + info['min'] = True + if asformatter: + year_start = period_break(dates_,'year') + info['fmt'][:] = '%d' + info['fmt'][month_start] = '%d\n%b' + info['fmt'][year_start] = '%d\n%b\n%Y' if not has_level_label(year_start): if not has_level_label(month_start): - if dates.size > 1: + if dates_.size > 1: idx = 1 else: idx = 0 - format[idx] = '%d\n%b\n%Y' + info['fmt'][idx] = '%d\n%b\n%Y' else: - format[first_label(month_start)] = '%d\n%b\n%Y' + info['fmt'][first_label(month_start)] = '%d\n%b\n%Y' # Case 2. Less than three months elif span <= periodsperyear//4: month_start = period_break(dates,'month') - if aslocator: - major = default[month_start] - minor = default - else: - week_start = period_break(dates,'week') - year_start = period_break(dates,'year') + info['maj'][month_start] = True + info['min'] = True + if asformatter: + week_start = period_break(dates_,'week') + year_start = period_break(dates_,'year') - format[week_start] = '%d' - format[month_start] = '\n\n%b' - format[year_start] = '\n\n%b\n%Y' + info['fmt'][week_start] = '%d' + info['fmt'][month_start] = '\n\n%b' + info['fmt'][year_start] = '\n\n%b\n%Y' if not has_level_label(year_start): if not has_level_label(month_start): - format[first_label(week_start)] = '\n\n%b\n%Y' + info['fmt'][first_label(week_start)] = '\n\n%b\n%Y' else: - format[first_label(month_start)] = '\n\n%b\n%Y' + info['fmt'][first_label(month_start)] = '\n\n%b\n%Y' # Case 3. Less than 14 months ............... elif span <= 1.15 * periodsperyear: + d_minus_1 = dates_-1 - if aslocator: - d_minus_1 = dates-1 + month_diff = numpy.abs(dates_.month - d_minus_1.month) + week_diff = numpy.abs(dates_.week - d_minus_1.week) + minor_idx = (month_diff + week_diff).nonzero()[0] - month_diff = numpy.abs(dates.month - d_minus_1.month) - week_diff = numpy.abs(dates.week - d_minus_1.week) - minor_idx = (month_diff + week_diff).nonzero()[0] + info['maj'][month_diff != 0] = True + info['min'][minor_idx] = True + if asformatter: + year_start = period_break(dates_,'year') + month_start = period_break(dates_,'month') - major = default[month_diff != 0] - minor = default[minor_idx] - else: - year_start = period_break(dates,'year') - month_start = period_break(dates,'month') - - format[month_start] = '%b' - format[year_start] = '%b\n%Y' + info['fmt'][month_start] = '%b' + info['fmt'][year_start] = '%b\n%Y' if not has_level_label(year_start): - format[first_label(month_start)] = '%b\n%Y' + info['fmt'][first_label(month_start)] = '%b\n%Y' # Case 4. Less than 2.5 years ............... elif span <= 2.5 * periodsperyear: - year_start = period_break(dates,'year') - if aslocator: - month_start = period_break(dates, 'quarter') - major = default[year_start] - minor = default[month_start] - else: - quarter_start = period_break(dates, 'quarter') - format[quarter_start] = '%b' - format[year_start] = '%b\n%Y' + year_start = period_break(dates_,'year') + month_start = period_break(dates_, 'quarter') + info['maj'][year_start] = True + info['min'][month_start] = True + if asformatter: + quarter_start = period_break(dates_, 'quarter') + info['fmt'][quarter_start] = '%b' + info['fmt'][year_start] = '%b\n%Y' # Case 4. Less than 4 years ................. elif span <= 4 * periodsperyear: - year_start = period_break(dates,'year') - month_start = period_break(dates, 'month') - if aslocator: - major = default[year_start] - minor = default[month_start] - else: - month_break = dates[month_start].month + year_start = period_break(dates_,'year') + month_start = period_break(dates_, 'month') + info['maj'][year_start] = True + info['min'][month_start] = True + if asformatter: + month_break = dates_[month_start].month jan_or_jul = month_start[(month_break == 1) | (month_break == 7)] - format[jan_or_jul] = '%b' - format[year_start] = '%b\n%Y' + info['fmt'][jan_or_jul] = '%b' + info['fmt'][year_start] = '%b\n%Y' # Case 5. Less than 11 years ................ elif span <= 11 * periodsperyear: - year_start = period_break(dates,'year') - if aslocator: - quarter_start = period_break(dates, 'quarter') - major = default[year_start] - minor = default[quarter_start] - else: - format[year_start] = '%Y' + year_start = period_break(dates_,'year') + quarter_start = period_break(dates_, 'quarter') + info['maj'][year_start] = True + info['min'][quarter_start] = True + if asformatter: + info['fmt'][year_start] = '%Y' # Case 6. More than 12 years ................ else: year_start = period_break(dates,'year') - year_break = dates[year_start].years + year_break = dates_[year_start].years nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) major_idx = year_start[(year_break % maj_anndef == 0)] - if aslocator: - major = default[major_idx] - minor_idx = year_start[(year_break % min_anndef == 0)] - minor = default[minor_idx] - else: - format[major_idx] = '%Y' + info['maj'][major_idx] = True + minor_idx = year_start[(year_break % min_anndef == 0)] + info['min'][minor_idx] = True + if asformatter: + info['fmt'][major_idx] = '%Y' #............................................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(default[formatted],format[formatted])]) + return info #............................................................................... -def _monthly_finder(vmin, vmax, freq, aslocator): +def _monthly_finder(vmin, vmax, freq, asformatter): if freq != _c.FR_MTH: raise ValueError("Unexpected frequency") periodsperyear = 12 @@ -317,143 +308,128 @@ (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 #............................................ - dates = numpy.arange(vmin, vmax+1) - format = numpy.empty(span, dtype="|S8") - format.flat = '' - year_start = (dates % 12 == 1).nonzero()[0] + # Initialize the output + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S8')]) + info['val'] = numpy.arange(vmin, vmax+1) + dates_ = info['val'] + info['fmt'] = '' + year_start = (dates_ % 12 == 1).nonzero()[0] #............................................ if span <= 1.15 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: + info['maj'][year_start] = True + info['min'] = True + if asformatter: + info['fmt'][:] = '%b' + info['fmt'][year_start] = '%b\n%Y' - format[:] = '%b' - format[year_start] = '%b\n%Y' - if not has_level_label(year_start): - if dates.size > 1: + if dates_.size > 1: idx = 1 else: idx = 0 - format[idx] = '%b\n%Y' + info['fmt'][idx] = '%b\n%Y' #........................ elif span <= 2.5 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - quarter_start = (dates % 3 == 1).nonzero() - format[quarter_start] = '%b' - format[year_start] = '%b\n%Y' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + quarter_start = (dates_ % 3 == 1).nonzero() + info['fmt'][quarter_start] = '%b' + info['fmt'][year_start] = '%b\n%Y' #....................... elif span <= 4 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - jan_or_jul = (dates % 12 == 1) | (dates % 12 == 7) - format[jan_or_jul] = '%b' - format[year_start] = '%b\n%Y' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + jan_or_jul = (dates_ % 12 == 1) | (dates_ % 12 == 7) + info['fmt'][jan_or_jul] = '%b' + info['fmt'][year_start] = '%b\n%Y' #........................ elif span <= 11 * periodsperyear: - if aslocator: - quarter_start = (dates % 3 == 1).nonzero() - major = dates[year_start] - minor = dates[quarter_start] - else: - format[year_start] = '%Y' + quarter_start = (dates_ % 3 == 1).nonzero() + info['maj'][year_start] = True + info['min'][quarter_start] = True + if asformatter: + info['fmt'][year_start] = '%Y' #......................... else: nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) - years = dates[year_start]//12 + 1 + years = dates_[year_start]//12 + 1 major_idx = year_start[(years % maj_anndef == 0)] - if aslocator: - major = dates[major_idx] - minor = dates[year_start[(years % min_anndef == 0)]] - else: - format[major_idx] = '%Y' + info['maj'][major_idx] = True + info['min'][year_start[(years % min_anndef == 0)]] = True + if asformatter: + info['fmt'][major_idx] = '%Y' #........................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) + return info #............................................................................... -def _quarterly_finder(vmin, vmax, freq, aslocator): +def _quarterly_finder(vmin, vmax, freq, asformatter): if get_freq_group(freq) != _c.FR_QTR: raise ValueError("Unexpected frequency") periodsperyear = 4 (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 #............................................ - dates = numpy.arange(vmin, vmax+1) - format = numpy.empty(span, dtype="|S8") - format.flat = '' - year_start = (dates % 4 == 1).nonzero()[0] + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S8')]) + info['val'] = numpy.arange(vmin, vmax+1) + info['fmt'] = '' + dates_ = info['val'] + year_start = (dates_ % 4 == 1).nonzero()[0] #............................................ if span <= 3.5 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - format[:] = 'Q%q' - format[year_start] = 'Q%q\n%F' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + info['fmt'][:] = 'Q%q' + info['fmt'][year_start] = 'Q%q\n%F' if not has_level_label(year_start): - if dates.size > 1: + if dates_.size > 1: idx = 1 else: idx = 0 - format[idx] = 'Q%q\n%F' + info['fmt'][idx] = 'Q%q\n%F' #............................................ elif span <= 11 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - format[year_start] = '%F' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + info['fmt'][year_start] = '%F' #............................................ else: - years = dates[year_start]//4 + 1 + years = dates_[year_start]//4 + 1 nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) major_idx = year_start[(years % maj_anndef == 0)] - if aslocator: - major = dates[major_idx] - minor = dates[year_start[(years % min_anndef == 0)]] - else: - format[major_idx] = '%F' + info['maj'][major_idx] = True + info['min'][year_start[(years % min_anndef == 0)]] = True + if asformatter: + info['fmt'][major_idx] = '%F' #............................................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) + return info #............................................................................... -def _annual_finder(vmin, vmax, freq, aslocator): +def _annual_finder(vmin, vmax, freq, asformatter): if get_freq_group(freq) != _c.FR_ANN: raise ValueError("Unexpected frequency") (vmin, vmax) = (int(vmin), int(vmax+1)) span = vmax - vmin + 1 #............................................ - dates = numpy.arange(vmin, vmax+1) - format = numpy.empty(span, dtype="|S8") - format.flat = '' + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S8')]) + info['val'] = numpy.arange(vmin, vmax+1) + info['fmt'] = '' + dates_ = info['val'] #............................................ (min_anndef, maj_anndef) = _get_default_annual_spacing(span) - major_idx = dates % maj_anndef == 0 - if aslocator: - major = dates[major_idx] - minor = dates[(dates % min_anndef == 0)] - else: - format[major_idx] = '%Y' + major_idx = dates_ % maj_anndef == 0 + info['maj'][major_idx] = True + info['min'][(dates_ % min_anndef == 0)] = True + if asformatter: + info['fmt'][major_idx] = '%Y' #............................................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) + return info #............................................................................... class TimeSeries_DateLocator(Locator): @@ -490,10 +466,10 @@ def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." - (minor, major) = self.finder(vmin, vmax, self.freq, True) + locator = self.finder(vmin, vmax, self.freq, False) if self.isminor: - return minor - return major + return numpy.compress(locator['min'], locator['val']) + return numpy.compress(locator['maj'], locator['val']) def __call__(self): 'Return the locations of the ticks.' @@ -560,7 +536,13 @@ def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." - self.formatdict = self.finder(vmin, vmax, self.freq, False) + info = self.finder(vmin, vmax, self.freq, True) + if self.isminor: + format = numpy.compress(info['min'] & numpy.logical_not(info['maj']), + info) + else: + format = numpy.compress(info['maj'], info) + self.formatdict = dict([(x,f) for (x,_,_,f) in format]) return self.formatdict def set_locs(self, locs): @@ -571,15 +553,8 @@ self._set_default_format(locs[0], locs[-1]) # def __call__(self, x, pos=0): - if self.isminor: - fmt = self.formatdict.pop(x, '') - if fmt is not '': - retval = Date(self.freq, value=int(x)).strftime(fmt) - else: - retval = '' - else: - retval = '' - return retval + fmt = self.formatdict.pop(x, '') + return Date(self.freq, value=int(x)).strfmt(fmt) @@ -593,12 +568,10 @@ """ Accepts the same keywords as a standard subplot, plus a specific `series` keyword. -:Parameters: - `fig` : Figure +*Parameters*: + fig : {Figure} Base figure. - -:Keywords: - `series` : TimeSeries + series : {TimeSeries}, optional Data to plot """ @@ -719,26 +692,18 @@ #...................................................... def tsplot(self,*parms,**kwargs): """Plots the data parsed in argument. -This command accepts the same keywords as `matplotlib.plot`.""" +This command accepts the same keywords as matplotlib.plot.""" # parms = tuple(list(parms) + kwargs.pop('series',None)) # print "Parameters: %s - %i" % (parms, len(parms)) # print "OPtions: %s - %i" % (kwargs, len(kwargs)) parms = self._check_plot_params(*parms) self.legendlabels.append(kwargs.get('label',None)) - Subplot.plot(self, *parms,**kwargs) + plotted = Subplot.plot(self, *parms,**kwargs) self.format_dateaxis() + return plotted #...................................................... - def format_dateaxis(self,maj_spacing=None, min_spacing=None, - strformat="%Y", rotate=True): + def format_dateaxis(self): """Pretty-formats the date axis (x-axis). - -:Parameters: - `major` : Integer *[5]* - Major tick locator, in years (major tick every `major` years). - `minor` : Integer *[12]* - Minor tick locator, in months (minor ticks every `minor` months). - `strformat` : String *['%Y']* - String format for major ticks ("%Y"). """ # Get the locator class ................. majlocator = TimeSeries_DateLocator(self.freq, dynamic_mode=True, @@ -754,6 +719,7 @@ minor_locator=True) self.xaxis.set_major_formatter(majformatter) self.xaxis.set_minor_formatter(minformatter) + pylab.draw_if_interactive() #........................................ # if rcParams['backend'] == 'PS': # rotate = False @@ -766,10 +732,10 @@ """Sets the date limits of the plot to start_date and end_date. The dates can be given as timeseries.Date objects, strings or integers. -:Inputs: - start_date : var *[None]* +*Parameters*: + start_date : {var} Starting date of the plot. If None, the current left limit is used. - end_date : var *[None]* + end_date : {var} Ending date of the plot. If None, the current right limit is used. """ freq = self.freq @@ -806,23 +772,23 @@ **kwargs): """Adds a second y-axis to a plot. -:Parameters: - `fsp` : Subplot *[None]* - Subplot to which the secondary y-axis is added. If *None*, the current - subplot is selected - `position` : String in `('left','right')` *['right']* - Position of the new axis. - `yscale` : String, in `('log', 'linear')` *[None]* - Scale of the new axis. If None, uses the same scale as the first y -axis - `basey` : Integer *[10]* +*Parameters*: + fsp : {Subplot} + Subplot to which the secondary y-axis is added. + If None, the current subplot is selected + position : {string} + Position of the new axis, as either 'left' or 'right'. + yscale : {string} + Scale of the new axis, as either 'log', 'linear' or None. + If None, uses the same scale as the first y axis + basey : {integer} Base of the logarithm for the new axis (if needed). - `subsy` : sequence *[None]* + subsy : {sequence} Sequence of the location of the minor ticks; None defaults to autosubs, which depend on the number of decades in -the plot. + the plot. Eg for base 10, subsy=(1,2,5) will put minor ticks on 1,2,5,11,12,15, -21, .... + 21, .... To turn off minor ticking, set subsy=[] """ @@ -888,10 +854,10 @@ def tsfigure(series=None, **figargs): """Creates a new `TimeSeriesFigure` object. -:Parameters: - `series` : TimeSeries object +*Parameters*: + series : {TimeSeries object} Input data. - `figargs` : Dictionary + figargs : {dictionary} Figure options [`figsize`, `dpi`, `facecolor`, `edgecolor`, `frameon`]. """ figargs.update(FigureClass=TSFigure) From scipy-svn at scipy.org Fri Nov 23 19:01:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 18:01:36 -0600 (CST) Subject: [Scipy-svn] r3572 - trunk/scipy/sandbox/timeseries Message-ID: <20071124000136.9A84139C0EB@new.scipy.org> Author: mattknox_ca Date: 2007-11-23 18:01:30 -0600 (Fri, 23 Nov 2007) New Revision: 3572 Modified: trunk/scipy/sandbox/timeseries/plotlib.py Log: putting some modifications back in that were overwritten in previous commit Modified: trunk/scipy/sandbox/timeseries/plotlib.py =================================================================== --- trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-23 23:26:02 UTC (rev 3571) +++ trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-24 00:01:30 UTC (rev 3572) @@ -70,7 +70,7 @@ except TypeError: key = str(key) # - if figure_instance._seen.has_key(key): + if key in figure_instance._seen: ax = figure_instance._seen[key] figure_instance.sca(ax) return ax @@ -554,7 +554,7 @@ # def __call__(self, x, pos=0): fmt = self.formatdict.pop(x, '') - return Date(self.freq, value=int(x)).strfmt(fmt) + return Date(self.freq, value=int(x)).strftime(fmt) From scipy-svn at scipy.org Fri Nov 23 19:15:40 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 18:15:40 -0600 (CST) Subject: [Scipy-svn] r3573 - trunk/scipy/sandbox/timeseries Message-ID: <20071124001540.CD43539C084@new.scipy.org> Author: pierregm Date: 2007-11-23 18:15:38 -0600 (Fri, 23 Nov 2007) New Revision: 3573 Modified: trunk/scipy/sandbox/timeseries/dates.py Log: dates : improved .tolist() plotlib : fixed a wrong format Modified: trunk/scipy/sandbox/timeseries/dates.py =================================================================== --- trunk/scipy/sandbox/timeseries/dates.py 2007-11-24 00:01:30 UTC (rev 3572) +++ trunk/scipy/sandbox/timeseries/dates.py 2007-11-24 00:15:38 UTC (rev 3573) @@ -373,8 +373,9 @@ def tolist(self): """Returns a hierarchical python list of standard datetime objects.""" _result = numpy.empty(self.shape, dtype=numpy.object_) - for idx, val in numpy.ndenumerate(self): - operator.setitem(_result, idx, Date(freq=self.freq, value=val).datetime) + _result.flat = [d.datetime for d in self.ravel()] +# for idx, val in numpy.ndenumerate(self): +# operator.setitem(_result, idx, Date(freq=self.freq, value=val).datetime) return _result.tolist() # def tostring(self): From scipy-svn at scipy.org Fri Nov 23 22:59:09 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Nov 2007 21:59:09 -0600 (CST) Subject: [Scipy-svn] r3574 - branches/scipy.scons/scipy/linalg Message-ID: <20071124035909.ECC5F39C037@new.scipy.org> Author: cdavid Date: 2007-11-23 21:59:04 -0600 (Fri, 23 Nov 2007) New Revision: 3574 Modified: branches/scipy.scons/scipy/linalg/SConstruct Log: Handle atlas_version module when compiled with ATLAS Modified: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-24 00:15:38 UTC (rev 3573) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-24 03:59:04 UTC (rev 3574) @@ -1,4 +1,4 @@ -# Last Change: Thu Nov 22 05:00 PM 2007 J +# Last Change: Sat Nov 24 12:00 PM 2007 J # vim:syntax=python import os @@ -8,7 +8,8 @@ from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir from numpy.distutils.scons import GetNumpyEnvironment from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ - CheckCLAPACK, IsVeclib, IsAccelerate, IsATLAS + CheckCLAPACK, IsVeclib, IsAccelerate, \ + IsATLAS, GetATLASVersion from scons_support import do_generate_interface, do_generate_fake_interface, \ generate_interface_emitter @@ -36,9 +37,14 @@ #-------------- # Checking Blas #-------------- -st = config.CheckBLAS() +st = config.CheckBLAS(check_version = 1) if not st: raise RuntimeError("no blas found, necessary for linalg module") +if IsATLAS(env, 'blas'): + version = GetATLASVersion(env, 'blas') + env.Append(CPPDEFINES = [('ATLAS_INFO', '"\\"%s"\\"' % version)]) +else: + env.Append(CPPDEFINES = [('NO_ATLAS_INFO', 1)]) st = config.CheckLAPACK() if not st: From scipy-svn at scipy.org Sat Nov 24 02:52:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 01:52:42 -0600 (CST) Subject: [Scipy-svn] r3575 - branches/scipy.scons/scipy/lib/blas Message-ID: <20071124075242.70E2739C02D@new.scipy.org> Author: cdavid Date: 2007-11-24 01:49:23 -0600 (Sat, 24 Nov 2007) New Revision: 3575 Added: branches/scipy.scons/scipy/lib/blas/SConstruct Modified: branches/scipy.scons/scipy/lib/blas/setupscons.py Log: lib/blas now build with scons Copied: branches/scipy.scons/scipy/lib/blas/SConstruct (from rev 3574, branches/scipy.scons/scipy/linalg/SConstruct) =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-24 03:59:04 UTC (rev 3574) +++ branches/scipy.scons/scipy/lib/blas/SConstruct 2007-11-24 07:49:23 UTC (rev 3575) @@ -0,0 +1,81 @@ +# Last Change: Sat Nov 24 04:00 PM 2007 J +# vim:syntax=python + +import os +from os.path import join as pjoin, splitext + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir +from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS,\ + IsVeclib, IsAccelerate, \ + IsATLAS, GetATLASVersion + +from numpy.distutils.scons.configuration import write_info + +env = GetNumpyEnvironment(ARGUMENTS) +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 +# # simple code using only typedef and so on, so we need it for configuration +# # checks +# env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) + +#======================= +# Starting Configuration +#======================= +config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS, + 'CheckBLAS' : CheckF77BLAS}) + +#-------------- +# Checking Blas +#-------------- +st = config.CheckBLAS(check_version = 1) +if not st: + raise RuntimeError("no blas found, necessary for linalg module") +if IsATLAS(env, 'blas'): + version = GetATLASVersion(env, 'blas') + env.Append(CPPDEFINES = [('ATLAS_INFO', '"\\"%s"\\"' % version)]) +else: + env.Append(CPPDEFINES = [('NO_ATLAS_INFO', 1)]) + +if config.CheckCBLAS(): + has_cblas = 1 +else: + has_cblas = 0 + +config.Finish() +write_info(env) + +#========== +# Build +#========== + +# XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +env.AppendUnique(F2PYOPTIONS = '--quiet') + +#------------ +# fblas +#------------ +env.NumpyFromFTemplate('fblas.pyf', 'fblas.pyf.src') +source = ['fblas.pyf'] +if IsVeclib(env, 'blas') or IsAccelerate(env, 'blas'): + env.NumpyFromCTemplate('fblaswrap_veclib_c.c', 'fblaswrap_veclib_c.c.src') + source.append('fblaswrap_veclib_c.c') +else: + env.NumpyFromFTemplate('fblaswrap.f', 'fblaswrap.f.src') + source.append('fblaswrap.f') +env.NumpyPythonExtension('fblas', source) + +#------------ +# cblas +#------------ +source = ['cblas.pyf'] +if has_cblas: + env.NumpyFromFTemplate('cblas.pyf', 'cblas.pyf.src') +env.NumpyPythonExtension('cblas', source) +# env.haha('cblas', 'generic_cblas.pyf') +# else: +# env.hihi('cblas', 'generic_cblas.pyf') +# env.NumpyPythonExtension('cblas', source = 'cblas.pyf') Modified: branches/scipy.scons/scipy/lib/blas/setupscons.py =================================================================== --- branches/scipy.scons/scipy/lib/blas/setupscons.py 2007-11-24 03:59:04 UTC (rev 3574) +++ branches/scipy.scons/scipy/lib/blas/setupscons.py 2007-11-24 07:49:23 UTC (rev 3575) @@ -1,119 +1,12 @@ #!/usr/bin/env python -from __future__ import nested_scopes -import os -import sys -import re -from distutils.dep_util import newer_group, newer -from glob import glob -from os.path import join - -#------------------- -# To skip wrapping single precision atlas/lapack/blas routines, set -# the following flag to True: -skip_single_routines = 0 - -# Some OS distributions (e.g. Redhat, Suse) provide a blas library that -# is built using incomplete blas sources that come with lapack tar-ball. -# In order to use such a library in scipy.linalg, the following flag -# must be set to True: -using_lapack_blas = 0 - -#-------------------- - -def needs_cblas_wrapper(info): - """Returns true if needs c wrapper around cblas for calling from - fortran.""" - r_accel = re.compile("Accelerate") - r_vec = re.compile("vecLib") - res = False - try: - tmpstr = info['extra_link_args'] - for i in tmpstr: - if r_accel.search(i) or r_vec.search(i): - res = True - except KeyError: - pass - - return res - -tmpl_empty_cblas_pyf = ''' -python module cblas - usercode void empty_module(void) {} - interface - subroutine empty_module() - intent(c) empty_module - end subroutine empty_module - end interface -end python module cblas -''' - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info config = Configuration('blas',parent_package,top_path) - blas_opt = get_info('blas_opt',notfound_action=2) - - atlas_version = ([v[3:-3] for k,v in blas_opt.get('define_macros',[]) \ - if k=='ATLAS_INFO']+[None])[0] - if atlas_version: - print 'ATLAS version',atlas_version - - target_dir = '' - skip_names = {'cblas':[],'fblas':[]} - if skip_single_routines: - target_dir = 'dbl' - skip_names['cblas'].extend('saxpy caxpy'.split()) - skip_names['fblas'].extend(skip_names['cblas']) - skip_names['fblas'].extend(\ - 'srotg crotg srotmg srot csrot srotm sswap cswap sscal cscal'\ - ' csscal scopy ccopy sdot cdotu cdotc snrm2 scnrm2 sasum scasum'\ - ' isamax icamax sgemv cgemv chemv ssymv strmv ctrmv'\ - ' sgemm cgemm'.split()) - - if using_lapack_blas: - target_dir = join(target_dir,'blas') - skip_names['fblas'].extend(\ - 'drotmg srotmg drotm srotm'.split()) - - depends = [__file__, 'fblas_l?.pyf.src', 'fblas.pyf.src','fblaswrap.f.src', - 'fblaswrap_veclib_c.c.src'] - # fblas: - if needs_cblas_wrapper(blas_opt): - sources = ['fblas.pyf.src', 'fblaswrap_veclib_c.c.src'], - else: - sources = ['fblas.pyf.src','fblaswrap.f.src'] - config.add_extension('fblas', - sources = sources, - depends = depends, - f2py_options = ['skip:']+skip_names['fblas']+[':'], - extra_info = blas_opt - ) - # cblas: - def get_cblas_source(ext, build_dir): - name = ext.name.split('.')[-1] - assert name=='cblas',`name` - if atlas_version is None: - target = join(build_dir,target_dir,'cblas.pyf') - from distutils.dep_util import newer - if newer(__file__,target): - f = open(target,'w') - f.write(tmpl_empty_cblas_pyf) - f.close() - else: - target = ext.depends[0] - assert os.path.basename(target)=='cblas.pyf.src' - return target - - config.add_extension('cblas', - sources = [get_cblas_source], - depends = ['cblas.pyf.src','cblas_l?.pyf.src'], - f2py_options = ['skip:']+skip_names['cblas']+[':'], - extra_info = blas_opt - ) - + config.add_sconscript('SConstruct') config.add_data_dir('tests') return config From scipy-svn at scipy.org Sat Nov 24 03:08:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 02:08:19 -0600 (CST) Subject: [Scipy-svn] r3576 - branches/scipy.scons/scipy/lib/blas Message-ID: <20071124080819.45DE439C058@new.scipy.org> Author: cdavid Date: 2007-11-24 02:05:42 -0600 (Sat, 24 Nov 2007) New Revision: 3576 Added: branches/scipy.scons/scipy/lib/blas/scons_support.py Modified: branches/scipy.scons/scipy/lib/blas/SConstruct Log: Handle missing cblas in scipy/lib/blas scons build Modified: branches/scipy.scons/scipy/lib/blas/SConstruct =================================================================== --- branches/scipy.scons/scipy/lib/blas/SConstruct 2007-11-24 07:49:23 UTC (rev 3575) +++ branches/scipy.scons/scipy/lib/blas/SConstruct 2007-11-24 08:05:42 UTC (rev 3576) @@ -13,6 +13,8 @@ from numpy.distutils.scons.configuration import write_info +from scons_support import do_generate_fake_interface, generate_interface_emitter + env = GetNumpyEnvironment(ARGUMENTS) env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) #if os.name == 'nt': @@ -21,6 +23,9 @@ # # checks # env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) +env['BUILDERS']['GenerateFakePyf'] = Builder(action = do_generate_fake_interface, + emitter = generate_interface_emitter) + #======================= # Starting Configuration #======================= @@ -74,8 +79,6 @@ source = ['cblas.pyf'] if has_cblas: env.NumpyFromFTemplate('cblas.pyf', 'cblas.pyf.src') +else: + print env.GenerateFakePyf('cblas', 'cblas.pyf.src') env.NumpyPythonExtension('cblas', source) -# env.haha('cblas', 'generic_cblas.pyf') -# else: -# env.hihi('cblas', 'generic_cblas.pyf') -# env.NumpyPythonExtension('cblas', source = 'cblas.pyf') Copied: branches/scipy.scons/scipy/lib/blas/scons_support.py (from rev 3567, branches/scipy.scons/scipy/linalg/scons_support.py) =================================================================== --- branches/scipy.scons/scipy/linalg/scons_support.py 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/lib/blas/scons_support.py 2007-11-24 08:05:42 UTC (rev 3576) @@ -0,0 +1,30 @@ +from os.path import join as pjoin, splitext, basename as pbasename + +def generate_interface_emitter(target, source, env): + source = [pjoin(env['build_dir'], str(i)) for i in source] + target = [pjoin(env['build_dir'], str(i)) for i in target] + base = str(target[0]) + return (['%s.pyf' % base], source) + +def do_generate_fake_interface(target, source, env): + """Generate a (fake) .pyf file from another pyf file (!).""" + # XXX: do this correctly + target_name = str(target[0]) + source_name = str(source[0]) + + # XXX handle skip names + name = splitext(pbasename(target_name))[0] + #generate_interface(name, source_name, target_name) + + f = open(target_name, 'w') + f.write('python module '+name+'\n') + f.write('usercode void empty_module(void) {}\n') + f.write('interface\n') + f.write('subroutine empty_module()\n') + f.write('intent(c) empty_module\n') + f.write('end subroutine empty_module\n') + f.write('end interface\nend python module'+name+'\n') + f.close() + + return 0 + From scipy-svn at scipy.org Sat Nov 24 03:21:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 02:21:24 -0600 (CST) Subject: [Scipy-svn] r3577 - branches/scipy.scons/scipy/lib/lapack Message-ID: <20071124082124.2CDE739C07F@new.scipy.org> Author: cdavid Date: 2007-11-24 02:18:52 -0600 (Sat, 24 Nov 2007) New Revision: 3577 Added: branches/scipy.scons/scipy/lib/lapack/SConstruct branches/scipy.scons/scipy/lib/lapack/scons_support.py Modified: branches/scipy.scons/scipy/lib/lapack/setupscons.py Log: scipy/lib/lapack now builds with scons Copied: branches/scipy.scons/scipy/lib/lapack/SConstruct (from rev 3574, branches/scipy.scons/scipy/linalg/SConstruct) =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-24 03:59:04 UTC (rev 3574) +++ branches/scipy.scons/scipy/lib/lapack/SConstruct 2007-11-24 08:18:52 UTC (rev 3577) @@ -0,0 +1,89 @@ +# Last Change: Sat Nov 24 05:00 PM 2007 J +# vim:syntax=python + +import os +from os.path import join as pjoin, splitext + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import get_python_inc +from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckF77LAPACK,\ + CheckCLAPACK, \ + IsATLAS, GetATLASVersion + +from scons_support import do_generate_fake_interface, \ + generate_interface_emitter +from numpy.distutils.scons.configuration import write_info + +env = GetNumpyEnvironment(ARGUMENTS) +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 +# # simple code using only typedef and so on, so we need it for configuration +# # checks +# env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) + +#======================= +# Starting Configuration +#======================= +config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS, + 'CheckBLAS' : CheckF77BLAS, + 'CheckCLAPACK' : CheckCLAPACK, + 'CheckLAPACK' : CheckF77LAPACK}) + +#-------------- +# Checking Blas +#-------------- +st = config.CheckLAPACK(check_version = 1) +if not st: + raise RuntimeError("no lapack found, necessary for lapack module") + +if IsATLAS(env, 'lapack'): + version = GetATLASVersion(env, 'lapack') + env.Append(CPPDEFINES = [('ATLAS_INFO', '"\\"%s"\\"' % version)]) +else: + env.Append(CPPDEFINES = [('NO_ATLAS_INFO', 1)]) + +if config.CheckCLAPACK(): + has_clapack = 1 +else: + has_clapack = 0 + +config.Finish() +write_info(env) + +#========== +# Build +#========== +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +env.AppendUnique(F2PYOPTIONS = '--quiet') + +env['BUILDERS']['GenerateFakePyf'] = Builder(action = do_generate_fake_interface, + emitter = generate_interface_emitter) + +#------------ +# flapack +#------------ +yop = env.NumpyFromFTemplate('flapack.pyf', 'flapack.pyf.src') +env.NumpyPythonExtension('flapack', source = ['flapack.pyf']) + +#------------ +# clapack +#------------ +if has_clapack: + env.NumpyFromFTemplate('clapack.pyf', 'clapack.pyf.src') +else: + env.GenerateFakePyf('clapack', 'clapack.pyf.src') +env.NumpyPythonExtension('clapack', source = 'clapack.pyf') + +#---------------- +# calc_lwork: +#---------------- +calc_src = env.F2py(pjoin(env['build_dir'], 'calc_lworkmodule.c'), + source = pjoin(env['build_dir'], 'calc_lwork.f')) +env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f']) + +#-------------- +# Atlas version +#-------------- +env.NumpyPythonExtension('atlas_version', 'atlas_version.c') Copied: branches/scipy.scons/scipy/lib/lapack/scons_support.py (from rev 3576, branches/scipy.scons/scipy/lib/blas/scons_support.py) Modified: branches/scipy.scons/scipy/lib/lapack/setupscons.py =================================================================== --- branches/scipy.scons/scipy/lib/lapack/setupscons.py 2007-11-24 08:05:42 UTC (rev 3576) +++ branches/scipy.scons/scipy/lib/lapack/setupscons.py 2007-11-24 08:18:52 UTC (rev 3577) @@ -1,106 +1,14 @@ #!/usr/bin/env python import os -from glob import glob -#------------------- -# To skip wrapping single precision atlas/lapack routines, set -# the following flag to True: - -skip_single_routines = 0 - -#-------------------- - -tmpl_empty_clapack_pyf = ''' -python module clapack - usercode void empty_module(void) {} - interface - subroutine empty_module() - intent(c) empty_module - end subroutine empty_module - end interface -end python module clapack -''' - - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info config = Configuration('lapack',parent_package,top_path) - lapack_opt = get_info('lapack_opt',notfound_action=2) - - atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \ - if k=='ATLAS_INFO']+[None])[0] - if atlas_version: - print 'ATLAS version',atlas_version - - target_dir = '' - skip_names = {'clapack':[],'flapack':[]} - if skip_single_routines: - target_dir = 'dbl' - skip_names['clapack'].extend(\ - 'sgesv cgesv sgetrf cgetrf sgetrs cgetrs sgetri cgetri'\ - ' sposv cposv spotrf cpotrf spotrs cpotrs spotri cpotri'\ - ' slauum clauum strtri ctrtri'.split()) - skip_names['flapack'].extend(skip_names['clapack']) - skip_names['flapack'].extend(\ - 'sgesdd cgesdd sgelss cgelss sgeqrf cgeqrf sgeev cgeev'\ - ' sgegv cgegv ssyev cheev slaswp claswp sgees cgees' - ' sggev cggev'.split()) - - if atlas_version=='3.2.1_pre3.3.6': - target_dir = os.path.join(target_dir,'atlas321') - skip_names['clapack'].extend(\ - 'sgetri dgetri cgetri zgetri spotri dpotri cpotri zpotri'\ - ' slauum dlauum clauum zlauum strtri dtrtri ctrtri ztrtri'.split()) - elif atlas_version>'3.4.0' and atlas_version<='3.5.12': - skip_names['clapack'].extend('cpotrf zpotrf'.split()) - - # flapack: - config.add_extension('flapack', - sources = ['flapack.pyf.src'], - depends = [__file__,'flapack_*.pyf.src'], - f2py_options = ['skip:']+skip_names['flapack']+[':'], - extra_info = lapack_opt - ) - - # clapack: - def get_clapack_source(ext, build_dir): - name = ext.name.split('.')[-1] - assert name=='clapack',`name` - if atlas_version is None: - target = os.path.join(build_dir,target_dir,'clapack.pyf') - from distutils.dep_util import newer - if newer(__file__,target): - f = open(target,'w') - f.write(tmpl_empty_clapack_pyf) - f.close() - else: - target = ext.depends[0] - assert os.path.basename(target)=='clapack.pyf.src' - return target - - config.add_extension('clapack', - sources = [get_clapack_source], - depends = ['clapack.pyf.src'], - f2py_options = ['skip:']+skip_names['clapack']+[':'], - extra_info = lapack_opt - ) - - # calc_lwork: - config.add_extension('calc_lwork', - sources = ['calc_lwork.f'], - extra_info = lapack_opt - ) - - # atlas_version: - config.add_extension('atlas_version', - sources = ['atlas_version.c'], - extra_info = lapack_opt - ) - + config.add_sconscript('SConstruct') config.add_data_dir('tests') return config From scipy-svn at scipy.org Sat Nov 24 04:00:51 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 03:00:51 -0600 (CST) Subject: [Scipy-svn] r3578 - in branches/scipy.scons/scipy/linsolve: . umfpack Message-ID: <20071124090051.1B08539C097@new.scipy.org> Author: cdavid Date: 2007-11-24 02:57:38 -0600 (Sat, 24 Nov 2007) New Revision: 3578 Added: branches/scipy.scons/scipy/linsolve/SConstruct branches/scipy.scons/scipy/linsolve/setupscons.py branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py Log: linsolve now builds with scons (umfpack wrapper not done yet) Copied: branches/scipy.scons/scipy/linsolve/SConstruct (from rev 3567, branches/scipy.scons/scipy/integrate/SConstruct) =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/linsolve/SConstruct 2007-11-24 08:57:38 UTC (rev 3578) @@ -0,0 +1,48 @@ +# Last Change: Sat Nov 24 05:00 PM 2007 J +# vim:syntax=python +from os.path import join as pjoin +import glob +import sys +from distutils.sysconfig import get_python_inc + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +from numpy.distutils.scons import CheckF77LAPACK + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) + +if sys.platform=='win32': + superlu_defs = [('NO_TIMER',1)] +else: + superlu_defs = [] + +# Build superlu +src = glob.glob(pjoin('SuperLU', 'SRC', '*.c')) +superlu = env.NumpyStaticExtLibrary('superlu_src', source = src, + CPPDEFINES = superlu_defs) + +env.AppendUnique(LIBS = ['superlu_src']) +env.AppendUnique(LIBPATH = env['build_dir']) + +# Build common objects files +com_env = env.Copy() +com_env.AppendUnique(CPPPATH = get_python_inc()) +com_src = [pjoin(env['build_dir'], i) for i in ['_superlu_utils.c', \ + '_superluobject.c']] +com_objs = com_env.SharedObject(source = com_src) + +# Build _zsuperlu +env.NumpyPythonExtension('_zsuperlu', source = ['_zsuperlumodule.c'] + com_objs) + +# Build _csuperlu +env.NumpyPythonExtension('_csuperlu', source = ['_csuperlumodule.c'] + com_objs) + +# Build _dsuperlu +env.NumpyPythonExtension('_dsuperlu', source = ['_dsuperlumodule.c'] + com_objs) + +# Build _ssuperlu +env.NumpyPythonExtension('_ssuperlu', source = ['_ssuperlumodule.c'] + com_objs) Copied: branches/scipy.scons/scipy/linsolve/setupscons.py (from rev 3567, branches/scipy.scons/scipy/linsolve/setup.py) =================================================================== --- branches/scipy.scons/scipy/linsolve/setup.py 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/linsolve/setupscons.py 2007-11-24 08:57:38 UTC (rev 3578) @@ -0,0 +1,18 @@ +#!/usr/bin/env python +from os.path import join +import sys + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + from numpy.distutils.system_info import get_info + + config = Configuration('linsolve',parent_package,top_path, + setup_name = 'setupscons.py') + config.add_sconscript('SConstruct') + config.add_subpackage('umfpack') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) Copied: branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py (from rev 3567, branches/scipy.scons/scipy/linsolve/umfpack/setup.py) =================================================================== --- branches/scipy.scons/scipy/linsolve/umfpack/setup.py 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py 2007-11-24 08:57:38 UTC (rev 3578) @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# 05.12.2005, c +# last change: 27.03.2006 +def configuration(parent_package='',top_path=None): + import numpy + from numpy.distutils.misc_util import Configuration + from numpy.distutils.system_info import get_info, dict_append + + config = Configuration( 'umfpack', parent_package, top_path ) + config.add_data_dir('tests') + +# umf_info = get_info( 'umfpack', notfound_action = 1 ) +# +# umfpack_i_file = config.paths('umfpack.i')[0] +# def umfpack_i(ext, build_dir): +# if umf_info: +# return umfpack_i_file +# +# blas_info = get_info('blas_opt') +# build_info = {} +# dict_append(build_info, **umf_info) +# dict_append(build_info, **blas_info) +# +# config.add_extension( '__umfpack', +# sources = [umfpack_i], +# depends = ['umfpack.i'], +# **build_info) + + return config + +if __name__ == "__main__": + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 04:46:17 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 03:46:17 -0600 (CST) Subject: [Scipy-svn] r3579 - branches/scipy.scons/scipy/odr Message-ID: <20071124094617.E8A3C39C2BD@new.scipy.org> Author: cdavid Date: 2007-11-24 03:45:36 -0600 (Sat, 24 Nov 2007) New Revision: 3579 Added: branches/scipy.scons/scipy/odr/SConstruct branches/scipy.scons/scipy/odr/setupscons.py Log: odr now builds with scons Copied: branches/scipy.scons/scipy/odr/SConstruct (from rev 3576, branches/scipy.scons/scipy/lib/blas/SConstruct) =================================================================== --- branches/scipy.scons/scipy/lib/blas/SConstruct 2007-11-24 08:05:42 UTC (rev 3576) +++ branches/scipy.scons/scipy/odr/SConstruct 2007-11-24 09:45:36 UTC (rev 3579) @@ -0,0 +1,55 @@ +# Last Change: Sat Nov 24 06:00 PM 2007 J +# vim:syntax=python + +import os +from os.path import join as pjoin, splitext + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir +from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckF77BLAS + +from numpy.distutils.scons.configuration import write_info + +env = GetNumpyEnvironment(ARGUMENTS) +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 +# # simple code using only typedef and so on, so we need it for configuration +# # checks +# env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) + +#======================= +# Starting Configuration +#======================= +config = env.NumpyConfigure(custom_tests = {'CheckBLAS' : CheckF77BLAS}) + +#-------------- +# Checking Blas +#-------------- +st = config.CheckBLAS() +if not st: + has_blas = 0 +else: + has_blas = 1 + +config.Finish() +write_info(env) + +#========== +# Build +#========== + +# odr lib +libodr_src = [pjoin('odrpack', i) for i in ['d_odr.f', 'd_mprec.f', 'dlunoc.f']] +if has_blas: + libodr_src.append(pjoin('odrpack', 'd_lpk.f')) +else: + libodr_src.append(pjoin('odrpack', 'd_lpkbls.f')) + +env.NumpyStaticExtLibrary('odr', source = libodr_src) +env.AppendUnique(LIBS = 'odr') +env.AppendUnique(LIBPATH = env['build_dir']) + +# odr pyextension +env.NumpyPythonExtension('__odrpack', '__odrpack.c') Copied: branches/scipy.scons/scipy/odr/setupscons.py (from rev 3567, branches/scipy.scons/scipy/odr/setup.py) =================================================================== --- branches/scipy.scons/scipy/odr/setup.py 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/odr/setupscons.py 2007-11-24 09:45:36 UTC (rev 3579) @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +from os.path import join + +def configuration(parent_package='', top_path=None): + import warnings + from numpy.distutils.misc_util import Configuration + from numpy.distutils.system_info import get_info, BlasNotFoundError + config = Configuration('odr', parent_package, top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 05:37:51 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 04:37:51 -0600 (CST) Subject: [Scipy-svn] r3580 - branches/scipy.scons/scipy/optimize Message-ID: <20071124103751.8E21C39C09B@new.scipy.org> Author: cdavid Date: 2007-11-24 04:37:35 -0600 (Sat, 24 Nov 2007) New Revision: 3580 Added: branches/scipy.scons/scipy/optimize/SConstruct branches/scipy.scons/scipy/optimize/setupscons.py Log: optimize now builds with scons Copied: branches/scipy.scons/scipy/optimize/SConstruct (from rev 3579, branches/scipy.scons/scipy/odr/SConstruct) =================================================================== --- branches/scipy.scons/scipy/odr/SConstruct 2007-11-24 09:45:36 UTC (rev 3579) +++ branches/scipy.scons/scipy/optimize/SConstruct 2007-11-24 10:37:35 UTC (rev 3580) @@ -0,0 +1,83 @@ +# Last Change: Sat Nov 24 07:00 PM 2007 J +# vim:syntax=python + +import os +from os.path import join as pjoin, splitext +import glob + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir +from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckF77LAPACK + +from numpy.distutils.scons.configuration import write_info + +env = GetNumpyEnvironment(ARGUMENTS) +env.Append(CPPPATH = get_numpy_include_dirs()) +env.Append(CPPPATH = env['F2PYINCLUDEDIR']) +#if os.name == 'nt': +# # NT needs the pythonlib to run any code importing Python.h, including +# # simple code using only typedef and so on, so we need it for configuration +# # checks +# env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) + +#======================= +# Starting Configuration +#======================= +config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) + +#----------------- +# Checking Lapack +#----------------- +st = config.CheckLAPACK() +if not st: + has_lapack = 0 +else: + has_lapack = 1 + +config.Finish() +write_info(env) + +#========== +# Build +#========== + +# minpack lib +minpack_src = glob.glob(pjoin('minpack', '*.f')) +env.NumpyStaticExtLibrary('minpack', source = minpack_src) + +# rootfind lib +rootfind_src = glob.glob(pjoin('Zeros', '*.c')) +env.NumpyStaticExtLibrary('rootfind', source = rootfind_src) + +env.AppendUnique(LIBS = ['minpack', 'rootfind']) +env.AppendUnique(LIBPATH = env['build_dir']) + +# _minpack pyextension +env.NumpyPythonExtension('_minpack', '_minpackmodule.c') + +# _zeros pyextension +env.NumpyPythonExtension('_zeros', 'zeros.c') + +# _lbfgsb pyextension +src = pjoin('lbfgsb', 'routines.f') +lbfgsb_src = env.F2py(pjoin(env['build_dir'], '_lbfgsbmodule.c'), + pjoin(env['build_dir'], 'lbfgsb', 'lbfgsb.pyf')) +env.NumpyPythonExtension('_lbfgsb', source = [src] + lbfgsb_src) + +# _cobyla pyextension +src = [pjoin('cobyla', i) for i in ['cobyla2.f', 'trstlp.f']] +wrap_src = env.F2py(pjoin(env['build_dir'], 'cobyla', '_cobylamodule.c'), + pjoin(env['build_dir'], 'cobyla', 'cobyla.pyf')) +env.NumpyPythonExtension('_cobyla', source = src + wrap_src) + +# _minpack2 pyextension +src = [pjoin('minpack2', i) for i in ['dcsrch.f', 'dcstep.f']] +wrap_src = env.F2py(pjoin(env['build_dir'], 'minpack2', 'minpack2module.c'), + pjoin(env['build_dir'], 'minpack2', 'minpack2.pyf')) +env.NumpyPythonExtension('minpack2', source = src + wrap_src) + +# moduleTNC pyextension +env.NumpyPythonExtension('moduleTNC', + source = [pjoin('tnc', i) for i in \ + ['moduleTNC.c', 'tnc.c']]) Copied: branches/scipy.scons/scipy/optimize/setupscons.py (from rev 3567, branches/scipy.scons/scipy/optimize/setup.py) =================================================================== --- branches/scipy.scons/scipy/optimize/setup.py 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/optimize/setupscons.py 2007-11-24 10:37:35 UTC (rev 3580) @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +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('optimize',parent_package, top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 05:46:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 04:46:38 -0600 (CST) Subject: [Scipy-svn] r3581 - branches/scipy.scons/scipy/signal Message-ID: <20071124104638.C9A3A39C05D@new.scipy.org> Author: cdavid Date: 2007-11-24 04:46:29 -0600 (Sat, 24 Nov 2007) New Revision: 3581 Added: branches/scipy.scons/scipy/signal/SConstruct branches/scipy.scons/scipy/signal/setupscons.py Log: signal now builds with scons Copied: branches/scipy.scons/scipy/signal/SConstruct (from rev 3567, branches/scipy.scons/scipy/cluster/SConstruct) =================================================================== --- branches/scipy.scons/scipy/cluster/SConstruct 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/signal/SConstruct 2007-11-24 10:46:29 UTC (rev 3581) @@ -0,0 +1,19 @@ +# Last Change: Sat Nov 24 07:00 PM 2007 J +# vim:syntax=python +from os.path import join + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.NumpyPythonExtension('sigtools', + source = ['sigtoolsmodule.c',\ + 'firfilter.c', \ + 'medianfilter.c']) + +env.NumpyPythonExtension('spline', + source = ['splinemodule.c', 'S_bspline_util.c', + 'D_bspline_util.c', 'C_bspline_util.c', + 'Z_bspline_util.c','bspline_util.c']) Copied: branches/scipy.scons/scipy/signal/setupscons.py (from rev 3567, branches/scipy.scons/scipy/signal/setup.py) =================================================================== --- branches/scipy.scons/scipy/signal/setup.py 2007-11-22 12:38:12 UTC (rev 3567) +++ branches/scipy.scons/scipy/signal/setupscons.py 2007-11-24 10:46:29 UTC (rev 3581) @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('signal', parent_package, top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + + config.add_extension('sigtools', + sources=['sigtoolsmodule.c', + 'firfilter.c','medianfilter.c'], + depends = ['sigtools.h'] + ) + + config.add_extension('spline', + sources = ['splinemodule.c','S_bspline_util.c','D_bspline_util.c', + 'C_bspline_util.c','Z_bspline_util.c','bspline_util.c'], + ) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 05:49:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 04:49:58 -0600 (CST) Subject: [Scipy-svn] r3582 - branches/scipy.scons/scipy Message-ID: <20071124104958.B4A1F39C05D@new.scipy.org> Author: cdavid Date: 2007-11-24 04:49:51 -0600 (Sat, 24 Nov 2007) New Revision: 3582 Modified: branches/scipy.scons/scipy/setupscons.py Log: Update setupscons.py with newly sconsified packages Modified: branches/scipy.scons/scipy/setupscons.py =================================================================== --- branches/scipy.scons/scipy/setupscons.py 2007-11-24 10:46:29 UTC (rev 3581) +++ branches/scipy.scons/scipy/setupscons.py 2007-11-24 10:49:51 UTC (rev 3582) @@ -14,13 +14,13 @@ config.add_subpackage('misc') config.add_subpackage('odr') config.add_subpackage('optimize') - config.add_subpackage('sandbox') + #config.add_subpackage('sandbox') config.add_subpackage('signal') - config.add_subpackage('sparse') - config.add_subpackage('special') - config.add_subpackage('stats') + #config.add_subpackage('sparse') + #config.add_subpackage('special') + #config.add_subpackage('stats') config.add_subpackage('ndimage') - config.add_subpackage('stsci') + #config.add_subpackage('stsci') config.add_subpackage('weave') config.make_svn_version_py() # installs __svn_version__.py config.make_config_py() From scipy-svn at scipy.org Sat Nov 24 05:54:47 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 04:54:47 -0600 (CST) Subject: [Scipy-svn] r3583 - in branches/scipy.scons: . scipy/sandbox/numexpr scipy/sandbox/numexpr/bench scipy/sandbox/numexpr/tests scipy/sandbox/timeseries scipy/sandbox/timeseries/include scipy/sandbox/timeseries/lib scipy/sandbox/timeseries/src scipy/sandbox/timeseries/tests scipy/signal Message-ID: <20071124105447.D822939C05D@new.scipy.org> Author: cdavid Date: 2007-11-24 04:53:58 -0600 (Sat, 24 Nov 2007) New Revision: 3583 Added: branches/scipy.scons/scipy/sandbox/numexpr/bench/ branches/scipy.scons/scipy/sandbox/numexpr/bench/boolean_timing.py branches/scipy.scons/scipy/sandbox/numexpr/bench/timing.py Removed: branches/scipy.scons/scipy/sandbox/numexpr/bench/boolean_timing.py branches/scipy.scons/scipy/sandbox/numexpr/bench/timing.py branches/scipy.scons/scipy/sandbox/numexpr/timing.py Modified: branches/scipy.scons/ branches/scipy.scons/scipy/sandbox/numexpr/__init__.py branches/scipy.scons/scipy/sandbox/numexpr/compiler.py branches/scipy.scons/scipy/sandbox/numexpr/complex_functions.inc branches/scipy.scons/scipy/sandbox/numexpr/expressions.py branches/scipy.scons/scipy/sandbox/numexpr/info.py branches/scipy.scons/scipy/sandbox/numexpr/interp_body.c branches/scipy.scons/scipy/sandbox/numexpr/interpreter.c branches/scipy.scons/scipy/sandbox/numexpr/tests/test_numexpr.py branches/scipy.scons/scipy/sandbox/timeseries/dates.py branches/scipy.scons/scipy/sandbox/timeseries/include/c_dates.h branches/scipy.scons/scipy/sandbox/timeseries/lib/moving_funcs.py branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py branches/scipy.scons/scipy/sandbox/timeseries/report.py branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c branches/scipy.scons/scipy/sandbox/timeseries/src/cseries.c branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py branches/scipy.scons/scipy/sandbox/timeseries/tseries.py branches/scipy.scons/scipy/signal/signaltools.py Log: Merged revisions 3557-3582 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r3566 | jarrod.millman | 2007-11-22 19:55:50 +0900 (Thu, 22 Nov 2007) | 2 lines fixed missing import as per ticket #542 ........ r3568 | cookedm | 2007-11-23 16:20:02 +0900 (Fri, 23 Nov 2007) | 7 lines [numexpr] Merge improvements from PyTables into numexpr (#529), thanks to Francesc Altet. This includes: - support for long long int datatype - support for string datatype - optimization of the unidimensional strided array case - optimization of the unidimensional unaligned array case ........ r3569 | cookedm | 2007-11-23 16:21:55 +0900 (Fri, 23 Nov 2007) | 2 lines [numexpr] Move timing files to a bench/ subdirectory ........ r3570 | mattknox_ca | 2007-11-24 06:42:20 +0900 (Sat, 24 Nov 2007) | 4 lines - renamed 'thisday' to 'now' (left 'thisday' and 'today' as deprecated aliases) - added tolist method to DateArray which returns a list of datetime objects - added additional documentation - renamed 'day_of_week' to 'weekday' (left 'day_of_week' as deprecated alias for now) ........ r3571 | pierregm | 2007-11-24 08:26:02 +0900 (Sat, 24 Nov 2007) | 4 lines plotlib : ensured that TimeSeriesPlot.tsplot returns the plotted elements : prevented the minor ticks on the date axis to overwrite the major ticks : improved the finder functions dates : prevented the use of the combination toordinal()/fromordinal() in date_array ........ r3572 | mattknox_ca | 2007-11-24 09:01:30 +0900 (Sat, 24 Nov 2007) | 1 line putting some modifications back in that were overwritten in previous commit ........ r3573 | pierregm | 2007-11-24 09:15:38 +0900 (Sat, 24 Nov 2007) | 2 lines dates : improved .tolist() plotlib : fixed a wrong format ........ Property changes on: branches/scipy.scons ___________________________________________________________________ Name: svnmerge-integrated - /trunk:1-3556 + /trunk:1-3582 Modified: branches/scipy.scons/scipy/sandbox/numexpr/__init__.py =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/__init__.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/__init__.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -1,6 +1,6 @@ -from info import __doc__ -from expressions import E -from compiler import numexpr, disassemble, evaluate +from numexpr.info import __doc__ +from numexpr.expressions import E +from numexpr.compiler import numexpr, disassemble, evaluate def test(level=1, verbosity=1): from numpy.testing import NumpyTest Copied: branches/scipy.scons/scipy/sandbox/numexpr/bench (from rev 3573, trunk/scipy/sandbox/numexpr/bench) Deleted: branches/scipy.scons/scipy/sandbox/numexpr/bench/boolean_timing.py =================================================================== --- trunk/scipy/sandbox/numexpr/bench/boolean_timing.py 2007-11-24 00:15:38 UTC (rev 3573) +++ branches/scipy.scons/scipy/sandbox/numexpr/bench/boolean_timing.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -1,139 +0,0 @@ -import sys -import timeit -import numpy - -array_size = 1000*1000 -iterations = 10 - -numpy_ttime = 0 -numpy_sttime = 0 -numpy_nttime = 0 -numexpr_ttime = 0 -numexpr_sttime = 0 -numexpr_nttime = 0 - -def compare_times(expr, nexpr): - global numpy_ttime - global numpy_sttime - global numpy_nttime - global numexpr_ttime - global numexpr_sttime - global numexpr_nttime - - print "******************* Expression:", expr - - setup_contiguous = setupNP_contiguous - setup_strided = setupNP_strided - setup_unaligned = setupNP_unaligned - - numpy_timer = timeit.Timer(expr, setup_contiguous) - numpy_time = round(numpy_timer.timeit(number=iterations), 4) - numpy_ttime += numpy_time - print 'numpy:', numpy_time / iterations - - numpy_timer = timeit.Timer(expr, setup_strided) - numpy_stime = round(numpy_timer.timeit(number=iterations), 4) - numpy_sttime += numpy_stime - print 'numpy strided:', numpy_stime / iterations - - numpy_timer = timeit.Timer(expr, setup_unaligned) - numpy_ntime = round(numpy_timer.timeit(number=iterations), 4) - numpy_nttime += numpy_ntime - print 'numpy unaligned:', numpy_ntime / iterations - - evalexpr = 'evaluate("%s", optimization="aggressive")' % expr - numexpr_timer = timeit.Timer(evalexpr, setup_contiguous) - numexpr_time = round(numexpr_timer.timeit(number=iterations), 4) - numexpr_ttime += numexpr_time - print "numexpr:", numexpr_time/iterations, - print "Speed-up of numexpr over numpy:", round(numpy_time/numexpr_time, 4) - - evalexpr = 'evaluate("%s", optimization="aggressive")' % expr - numexpr_timer = timeit.Timer(evalexpr, setup_strided) - numexpr_stime = round(numexpr_timer.timeit(number=iterations), 4) - numexpr_sttime += numexpr_stime - print "numexpr strided:", numexpr_stime/iterations, - print "Speed-up of numexpr strided over numpy:", \ - round(numpy_stime/numexpr_stime, 4) - - evalexpr = 'evaluate("%s", optimization="aggressive")' % expr - numexpr_timer = timeit.Timer(evalexpr, setup_unaligned) - numexpr_ntime = round(numexpr_timer.timeit(number=iterations), 4) - numexpr_nttime += numexpr_ntime - print "numexpr unaligned:", numexpr_ntime/iterations, - print "Speed-up of numexpr unaligned over numpy:", \ - round(numpy_ntime/numexpr_ntime, 4) - - - -setupNP = """\ -from numpy import arange, where, arctan2, sqrt -from numpy import rec as records -from numexpr import evaluate - -# Initialize a recarray of 16 MB in size -r=records.array(None, formats='a%s,i4,f8', shape=%s) -c1 = r.field('f0')%s -i2 = r.field('f1')%s -f3 = r.field('f2')%s -c1[:] = "a" -i2[:] = arange(%s)/1000 -f3[:] = i2/2. -""" - -setupNP_contiguous = setupNP % (4, array_size, - ".copy()", ".copy()", ".copy()", - array_size) -setupNP_strided = setupNP % (4, array_size, "", "", "", array_size) -setupNP_unaligned = setupNP % (1, array_size, "", "", "", array_size) - - -expressions = [] -expressions.append('i2 > 0') -expressions.append('i2 < 0') -expressions.append('i2 < f3') -expressions.append('i2-10 < f3') -expressions.append('i2*f3+f3*f3 > i2') -expressions.append('0.1*i2 > arctan2(i2, f3)') -expressions.append('i2%2 > 3') -expressions.append('i2%10 < 4') -expressions.append('i2**2 + (f3+1)**-2.5 < 3') -expressions.append('(f3+1)**50 > i2') -expressions.append('sqrt(i2**2 + f3**2) > 1') -expressions.append('(i2>2) | ((f3**2>3) & ~(i2*f3<2))') - -def compare(expression=False): - if expression: - compare_times(expression, 1) - sys.exit(0) - nexpr = 0 - for expr in expressions: - nexpr += 1 - compare_times(expr, nexpr) - print - -if __name__ == '__main__': - - print 'Python version: %s' % sys.version - print "NumPy version: %s" % numpy.__version__ - - if len(sys.argv) > 1: - expression = sys.argv[1] - print "expression-->", expression - compare(expression) - else: - compare() - - print "*************** TOTALS **************************" - print "numpy total:", numpy_ttime/iterations - print "numpy strided total:", numpy_sttime/iterations - print "numpy unaligned total:", numpy_nttime/iterations - print "numexpr total:", numexpr_ttime/iterations - print "Speed-up of numexpr over numpy:", \ - round(numpy_ttime/numexpr_ttime, 3) - print "numexpr strided total:", numexpr_sttime/iterations - print "Speed-up of numexpr strided over numpy:", \ - round(numpy_sttime/numexpr_sttime, 3) - print "numexpr unaligned total:", numexpr_nttime/iterations - print "Speed-up of numexpr unaligned over numpy:", \ - round(numpy_nttime/numexpr_nttime, 3) Copied: branches/scipy.scons/scipy/sandbox/numexpr/bench/boolean_timing.py (from rev 3573, trunk/scipy/sandbox/numexpr/bench/boolean_timing.py) Deleted: branches/scipy.scons/scipy/sandbox/numexpr/bench/timing.py =================================================================== --- trunk/scipy/sandbox/numexpr/bench/timing.py 2007-11-24 00:15:38 UTC (rev 3573) +++ branches/scipy.scons/scipy/sandbox/numexpr/bench/timing.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -1,136 +0,0 @@ -import timeit, numpy - -array_size = 1e6 -iterations = 10 - -def compare_times(setup, expr): - print "Expression:", expr - namespace = {} - exec setup in namespace - - numpy_timer = timeit.Timer(expr, setup) - numpy_time = numpy_timer.timeit(number=iterations) - print 'numpy:', numpy_time / iterations - - try: - weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) - weave_time = weave_timer.timeit(number=iterations) - print "Weave:", weave_time/iterations - - print "Speed-up of weave over numpy:", numpy_time/weave_time - except: - print "Skipping weave timing" - - numexpr_timer = timeit.Timer('evaluate("%s", optimization="aggressive")' % expr, setup) - numexpr_time = numexpr_timer.timeit(number=iterations) - print "numexpr:", numexpr_time/iterations - - print "Speed-up of numexpr over numpy:", numpy_time/numexpr_time - return numpy_time/numexpr_time - -setup1 = """\ -from numpy import arange -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -result = arange(%f) -b = arange(%f) -c = arange(%f) -d = arange(%f) -e = arange(%f) -""" % ((array_size,)*5) -expr1 = 'b*c+d*e' - -setup2 = """\ -from numpy import arange -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(%f) -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr2 = '2*a+3*b' - - -setup3 = """\ -from numpy import arange, sin, cos, sinh -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f)[::2] -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr3 = '2*a + (cos(3)+5)*sinh(cos(b))' - - -setup4 = """\ -from numpy import arange, sin, cos, sinh, arctan2 -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f)[::2] -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr4 = '2*a + arctan2(a, b)' - - -setup5 = """\ -from numpy import arange, sin, cos, sinh, arctan2, sqrt, where -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f, dtype=float)[::2] -b = arange(%f, dtype=float) -result = arange(%f, dtype=float) -""" % ((array_size,)*3) -expr5 = 'where(0.1*a > arctan2(a, b), 2*a, arctan2(a,b))' - -expr6 = 'where(a != 0.0, 2, b)' - -expr7 = 'where(a-10 != 0.0, a, 2)' - -expr8 = 'where(a%2 != 0.0, b+5, 2)' - -expr9 = 'where(a%2 != 0.0, 2, b+5)' - -expr10 = 'a**2 + (b+1)**-2.5' - -expr11 = '(a+1)**50' - -expr12 = 'sqrt(a**2 + b**2)' - -def compare(check_only=False): - total = 0 - total += compare_times(setup1, expr1) - print - total += compare_times(setup2, expr2) - print - total += compare_times(setup3, expr3) - print - total += compare_times(setup4, expr4) - print - total += compare_times(setup5, expr6) - print - total += compare_times(setup5, expr7) - print - total += compare_times(setup5, expr8) - print - total += compare_times(setup5, expr9) - print - total += compare_times(setup5, expr10) - print - total += compare_times(setup5, expr11) - print - total += compare_times(setup5, expr12) - print - print "Average =", total / 11.0 - return total - -if __name__ == '__main__': - averages = [] - for i in range(iterations): - averages.append(compare()) - print "Averages:", ', '.join("%.2f" % x for x in averages) Copied: branches/scipy.scons/scipy/sandbox/numexpr/bench/timing.py (from rev 3573, trunk/scipy/sandbox/numexpr/bench/timing.py) Modified: branches/scipy.scons/scipy/sandbox/numexpr/compiler.py =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/compiler.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/compiler.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -1,12 +1,12 @@ import sys import numpy -import interpreter, expressions +from numexpr import interpreter, expressions -typecode_to_kind = {'b': 'bool', 'i': 'int', 'f': 'float', - 'c': 'complex', 'n' : 'none'} -kind_to_typecode = {'bool': 'b', 'int': 'i', 'float': 'f', - 'complex': 'c', 'none' : 'n'} +typecode_to_kind = {'b': 'bool', 'i': 'int', 'l': 'long', 'f': 'float', + 'c': 'complex', 's': 'str', 'n' : 'none'} +kind_to_typecode = {'bool': 'b', 'int': 'i', 'long': 'l', 'float': 'f', + 'complex': 'c', 'str': 's', 'none' : 'n'} type_to_kind = expressions.type_to_kind kind_to_type = expressions.kind_to_type @@ -91,7 +91,7 @@ """Generate all possible signatures derived by upcasting the given signature. """ - codes = 'bifc' + codes = 'bilfc' if not s: yield '' elif s[0] in codes: @@ -99,6 +99,9 @@ for x in codes[start:]: for y in sigPerms(s[1:]): yield x + y + elif s[0] == 's': # numbers shall not be cast to strings + for y in sigPerms(s[1:]): + yield 's' + y else: yield s @@ -198,6 +201,10 @@ for name in c.co_names: if name == "None": names[name] = None + elif name == "True": + names[name] = True + elif name == "False": + names[name] = False else: t = types.get(name, float) names[name] = expressions.VariableNode(name, type_to_kind[t]) @@ -206,6 +213,8 @@ ex = eval(c, names) if expressions.isConstant(ex): ex = expressions.ConstantNode(ex, expressions.getKind(ex)) + elif not isinstance(ex, expressions.ExpressionNode): + raise TypeError("unsupported expression type: %s" % type(ex)) finally: expressions._context.ctx = old_ctx return ex @@ -308,8 +317,8 @@ for c in n.children: if c.reg.temporary: users_of[c.reg].add(n) - unused = {'bool' : set(), 'int' : set(), - 'float' : set(), 'complex' : set()} + unused = {'bool' : set(), 'int' : set(), 'long': set(), + 'float' : set(), 'complex' : set(), 'str': set()} for n in nodes: for reg, users in users_of.iteritems(): if n in users: @@ -435,7 +444,7 @@ ast = expressionToAST(ex) - # Add a copy for strided or unaligned arrays + # Add a copy for strided or unaligned unidimensional arrays for a in ast.postorderWalk(): if a.astType == "variable" and a.value in copy_args: newVar = ASTNode(*a.key()) @@ -536,15 +545,19 @@ def getType(a): - t = a.dtype.type - if issubclass(t, numpy.bool_): + kind = a.dtype.kind + if kind == 'b': return bool - if issubclass(t, numpy.integer): + if kind in 'iu': + if a.dtype.itemsize > 4: + return long # ``long`` is for integers of more than 32 bits return int - if issubclass(t, numpy.floating): + if kind == 'f': return float - if issubclass(t, numpy.complexfloating): + if kind == 'c': return complex + if kind == 'S': + return str raise ValueError("unkown type %s" % a.dtype.name) @@ -589,12 +602,29 @@ a = local_dict[name] except KeyError: a = global_dict[name] - # byteswapped arrays are taken care of in the extension. - arguments.append(numpy.asarray(a)) # don't make a data copy, if possible - if (hasattr(a, "flags") and # numpy object - (not a.flags.contiguous or - not a.flags.aligned)): - copy_args.append(name) # do a copy to temporary + b = numpy.asarray(a) + # Byteswapped arrays are dealt with in the extension + # All the opcodes can deal with strided arrays directly as + # long as they are undimensional (strides in other + # dimensions are dealt within the extension), so we don't + # need a copy for the strided case. + if not b.flags.aligned: + # For the unaligned case, we have two cases: + if b.ndim == 1: + # For unidimensional arrays we can use the copy opcode + # because it can deal with unaligned arrays as long + # as they are unidimensionals with a possible stride + # (very common case for recarrays). This can be up to + # 2x faster than doing a copy using NumPy. + copy_args.append(name) + else: + # For multimensional unaligned arrays do a plain copy. + # We could refine more this and do a plain copy only + # in the case that strides doesn't exist in dimensions + # other than the last one (whose case is supported by + # the copy opcode). + b = b.copy() + arguments.append(b) # Create a signature signature = [(name, getType(arg)) for (name, arg) in zip(names, arguments)] Modified: branches/scipy.scons/scipy/sandbox/numexpr/complex_functions.inc =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/complex_functions.inc 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/complex_functions.inc 2007-11-24 10:53:58 UTC (rev 3583) @@ -365,3 +365,34 @@ r->imag = (is*rc-rs*ic)/d; return; } + + +/* The next nowarn1() and nowarn2() are defined in order to avoid + compiler warnings about unused functions. Just add to nowarn1() a + call to each function the compiler complains about to make it look + like it gets used somewhere. + + Of course, you shouldn't directly invoke neither of these two + functions, since they cause a stack overflow. */ + +void nowarn2(cdouble *x, cdouble *r, cdouble *b); + +void +nowarn1(cdouble *x, cdouble *r, cdouble *b) +{ + nc_floor_quot(x, b, r); + nc_log1p(x, r); + nc_expm1(x, r); + nc_log10(x, r); + nc_asinh(x, r); + nc_acosh(x, r); + nc_atanh(x, r); + /* Append more calls here. */ + nowarn2(x, r, b); +} + +void +nowarn2(cdouble *x, cdouble *r, cdouble *b) +{ + nowarn1(x, r, b); +} Modified: branches/scipy.scons/scipy/sandbox/numexpr/expressions.py =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/expressions.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/expressions.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -6,7 +6,7 @@ import numpy -import interpreter +from numexpr import interpreter class Expression(object): def __init__(self): @@ -55,25 +55,53 @@ def isConstant(ex): "Returns True if ex is a constant scalar of an allowed type." - return isinstance(ex, (bool, int, float, complex)) + return isinstance(ex, (bool, int, long, float, complex, str)) -type_to_kind = {bool: 'bool', int: 'int', float: 'float', complex: 'complex'} -kind_to_type = {'bool': bool, 'int': int, 'float': float, 'complex': complex} -kind_rank = ['bool', 'int', 'float', 'complex', 'none'] +type_to_kind = {bool: 'bool', int: 'int', long: 'long', float: 'float', complex: 'complex', str: 'str'} +kind_to_type = {'bool': bool, 'int': int, 'long': long, 'float': float, 'complex': complex, 'str': str} +kind_rank = ['bool', 'int', 'long', 'float', 'complex', 'none'] def commonKind(nodes): + node_kinds = [node.astKind for node in nodes] + str_count = node_kinds.count('str') + if 0 < str_count < len(node_kinds): # some args are strings, but not all + raise TypeError("strings can only be operated with strings") + if str_count > 0: # if there are some, all of them must be + return 'str' n = -1 for x in nodes: n = max(n, kind_rank.index(x.astKind)) return kind_rank[n] +max_int32 = 2147483647 +min_int32 = -max_int32 - 1 def bestConstantType(x): - for converter in bool, int, float, complex: + if isinstance(x, str): # ``numpy.string_`` is a subclass of ``str`` + return str + # ``long`` objects are kept as is to allow the user to force + # promotion of results by using long constants, e.g. by operating + # a 32-bit array with a long (64-bit) constant. + if isinstance(x, (long, numpy.int64)): + return long + # Numeric conversion to boolean values is not tried because + # ``bool(1) == True`` (same for 0 and False), so 0 and 1 would be + # interpreted as booleans when ``False`` and ``True`` are already + # supported. + if isinstance(x, (bool, numpy.bool_)): + return bool + # ``long`` is not explicitly needed since ``int`` automatically + # returns longs when needed (since Python 2.3). + for converter in int, float, complex: try: y = converter(x) except StandardError, err: continue if x == y: + # Constants needing more than 32 bits are always + # considered ``long``, *regardless of the platform*, so we + # can clearly tell 32- and 64-bit constants apart. + if converter is int and not (min_int32 <= x <= max_int32): + return long return converter def getKind(x): @@ -94,7 +122,7 @@ return OpNode(opname, (self, other), kind=kind) return operation -def func(func, minkind=None): +def func(func, minkind=None, maxkind=None): @ophelper def function(*args): if allConstantNodes(args): @@ -102,6 +130,8 @@ kind = commonKind(args) if minkind and kind_rank.index(minkind) > kind_rank.index(kind): kind = minkind + if maxkind and kind_rank.index(maxkind) < kind_rank.index(kind): + kind = maxkind return FuncNode(func.__name__, args, kind) return function @@ -129,23 +159,17 @@ axis = encode_axis(axis) if isinstance(a, ConstantNode): return a - if isinstance(a, (bool, int, float, complex)): + if isinstance(a, (bool, int, long, float, complex)): a = ConstantNode(a) - kind = a.astKind - if kind == 'bool': - kind = 'int' - return FuncNode('sum', [a, axis], kind=kind) + return FuncNode('sum', [a, axis], kind=a.astKind) def prod_func(a, axis=-1): axis = encode_axis(axis) - if isinstance(a, (bool, int, float, complex)): + if isinstance(a, (bool, int, long, float, complex)): a = ConstantNode(a) if isinstance(a, ConstantNode): return a - kind = a.astKind - if kind == 'bool': - kind = 'int' - return FuncNode('prod', [a, axis], kind=kind) + return FuncNode('prod', [a, axis], kind=a.astKind) @ophelper def div_op(a, b): @@ -182,7 +206,7 @@ p = OpNode('mul', [p,p]) if ishalfpower: kind = commonKind([a]) - if kind == 'int': kind = 'float' + if kind in ('int', 'long'): kind = 'float' r = multiply(r, OpNode('sqrt', [a], kind)) if r is None: r = OpNode('ones_like', [a]) @@ -196,7 +220,7 @@ return FuncNode('ones_like', [a]) if x == 0.5: kind = a.astKind - if kind == 'int': kind = 'float' + if kind in ('int', 'long'): kind = 'float' return FuncNode('sqrt', [a], kind=kind) if x == 1: return a @@ -224,6 +248,8 @@ 'where' : where_func, + 'real': func(numpy.real, 'float', 'float'), + 'imag': func(numpy.imag, 'float', 'float'), 'complex' : func(complex, 'complex'), 'sum' : sum_func, @@ -306,7 +332,7 @@ class VariableNode(LeafNode): astType = 'variable' def __init__(self, value=None, kind=None, children=None): - ExpressionNode.__init__(self, value=value, kind=kind) + LeafNode.__init__(self, value=value, kind=kind) class RawNode(object): """Used to pass raw integers to interpreter. Modified: branches/scipy.scons/scipy/sandbox/numexpr/info.py =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/info.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/info.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -2,25 +2,55 @@ Usage: -Build an expression up by using E. for the variables: +The easiest way is to use the ``evaluate`` function: ->>> ex = 2.0 * E.a + 3 * E.b * E.c +>>> a = numpy.array([1., 2, 3]) +>>> b = numpy.array([4, 5, 6]) +>>> c = numpy.array([7., 8, 9]) +>>> numexpr.evaluate("2.0 * a + 3 * b * c") +array([ 86., 124., 168.]) -then compile it to a function: +This works for every datatype defined in NumPy and the next operators +are supported: ->>> func = numexpr(ex, input_names=('a', 'b', 'c')) + Logical operators: &, |, ~ + Comparison operators: <, <=, ==, !=, >=, > + Unary arithmetic operators: - + Binary arithmetic operators: +, -, *, /, **, % -(if input_names is not given to compile, the variables are sort lexically.) +Note: Types do not support all operators. Boolean values only support + logical and strict (in)equality comparison operators, while + strings only support comparisons, numbers do not work with logical + operators, and complex comparisons can only check for strict + (in)equality. Unsupported operations (including invalid castings) + raise NotImplementedError exceptions. -Then, you can use that function for elementwise operations: +The next functions are also supported: ->>> func(array([1., 2, 3]), array([4., 5, 6]), array([7., 8, 9])) -array([ 86., 124., 168.]) + where(bool, number1, number2): number - number1 if the bool + condition is true, number2 otherwise. -Currently, this is only implemented for arrays of float64, and only -for the simple operations +, -, *, and /. + {sin,cos,tan}(float|complex): float|complex - trigonometric sinus, + cosinus or tangent. -Copyright 2006 David M. Cooke + {arcsin,arccos,arctan}(float|complex): float|complex - + trigonometric inverse sinus, cosinus or tangent. + + arctan2(float1, float2): float - trigonometric inverse tangent of + float1/float2. + + {sinh,cosh,tanh}(float|complex): float|complex - hyperbolic sinus, + cosinus or tangent. + + sqrt(float|complex): float|complex - square root. + + {real,imag}(complex): float - real or imaginary part of complex. + + complex(float, float): complex - complex from real and imaginary + parts. + + +Copyright 2006,2007 David M. Cooke Licenced under a BSD-style license. See LICENSE.txt in the scipy source directory. """ Modified: branches/scipy.scons/scipy/sandbox/numexpr/interp_body.c =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/interp_body.c 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/interp_body.c 2007-11-24 10:53:58 UTC (rev 3583) @@ -8,9 +8,13 @@ { \ char *dest = params.mem[store_in]; \ char *x1 = params.mem[arg1]; \ + intp ss1 = params.memsizes[arg1]; \ intp sb1 = params.memsteps[arg1]; \ - intp si1 = sb1 / sizeof(long); \ - intp sf1 = sb1 / sizeof(double); \ + /* nowarns is defined and used so as to \ + avoid compiler warnings about unused \ + variables */ \ + intp nowarns = ss1+sb1+*x1; \ + nowarns += 1; \ VEC_LOOP(expr); \ } break #define VEC_ARG2(expr) \ @@ -20,14 +24,16 @@ { \ char *dest = params.mem[store_in]; \ char *x1 = params.mem[arg1]; \ + intp ss1 = params.memsizes[arg1]; \ intp sb1 = params.memsteps[arg1]; \ - intp si1 = sb1 / sizeof(long); \ - intp sf1 = sb1 / sizeof(double); \ + /* nowarns is defined and used so as to \ + avoid compiler warnings about unused \ + variables */ \ + intp nowarns = ss1+sb1+*x1; \ char *x2 = params.mem[arg2]; \ + intp ss2 = params.memsizes[arg2]; \ intp sb2 = params.memsteps[arg2]; \ - intp si2 = sb2 / sizeof(long); \ - intp sf2 = sb2 / sizeof(double); \ - intp s2 = params.memsteps[arg2]; \ + nowarns += ss2+sb2+*x2; \ VEC_LOOP(expr); \ } break @@ -39,19 +45,20 @@ { \ char *dest = params.mem[store_in]; \ char *x1 = params.mem[arg1]; \ + intp ss1 = params.memsizes[arg1]; \ intp sb1 = params.memsteps[arg1]; \ - intp si1 = sb1 / sizeof(long); \ - intp sf1 = sb1 / sizeof(double); \ + /* nowarns is defined and used so as to \ + avoid compiler warnings about unused \ + variables */ \ + intp nowarns = ss1+sb1+*x1; \ char *x2 = params.mem[arg2]; \ - intp s2 = params.memsteps[arg2]; \ + intp ss2 = params.memsizes[arg2]; \ intp sb2 = params.memsteps[arg2]; \ - intp si2 = sb2 / sizeof(long); \ - intp sf2 = sb2 / sizeof(double); \ char *x3 = params.mem[arg3]; \ - intp s3 = params.memsteps[arg3]; \ + intp ss3 = params.memsizes[arg3]; \ intp sb3 = params.memsteps[arg3]; \ - intp si3 = sb3 / sizeof(long); \ - intp sf3 = sb3 / sizeof(double); \ + nowarns += ss2+sb2+*x2; \ + nowarns += ss3+sb3+*x3; \ VEC_LOOP(expr); \ } break @@ -82,6 +89,11 @@ params.mem[1+r] = params.inputs[r] + index * params.memsteps[1+r]; } } + + /* WARNING: From now on, only do references to params.mem[arg[123]] + & params.memsteps[arg[123]] inside the VEC_ARG[123] macros, + or you will risk accessing invalid addresses. */ + for (pc = 0; pc < params.prog_len; pc += 4) { unsigned char op = params.program[pc]; unsigned int store_in = params.program[pc+1]; @@ -89,37 +101,41 @@ unsigned int arg2 = params.program[pc+3]; #define arg3 params.program[pc+5] #define store_index params.index_data[store_in] - - /* WARNING: From now on, only do references to params.mem[arg[123]] - & params.memsteps[arg[123]] inside the VEC_ARG[123] macros, - or you will risk accessing invalid addresses. */ - #define reduce_ptr (dest + flat_index(&store_index, j)) - #define i_reduce *(long *)reduce_ptr + #define i_reduce *(int *)reduce_ptr + #define l_reduce *(long long *)reduce_ptr #define f_reduce *(double *)reduce_ptr #define cr_reduce *(double *)ptr #define ci_reduce *((double *)ptr+1) #define b_dest ((char *)dest)[j] - #define i_dest ((long *)dest)[j] + #define i_dest ((int *)dest)[j] + #define l_dest ((long long *)dest)[j] #define f_dest ((double *)dest)[j] #define cr_dest ((double *)dest)[2*j] #define ci_dest ((double *)dest)[2*j+1] - #define b1 ((char *)x1)[j*sb1] - #define i1 ((long *)x1)[j*si1] - #define f1 ((double *)x1)[j*sf1] - #define c1r ((double *)x1)[j*sf1] - #define c1i ((double *)x1)[j*sf1+1] - #define b2 ((char *)x2)[j*sb2] - #define i2 ((long *)x2)[j*si2] - #define f2 ((double *)x2)[j*sf2] - #define c2r ((double *)x2)[j*sf2] - #define c2i ((double *)x2)[j*sf2+1] - #define b3 ((char *)x3)[j*sb3] - #define i3 ((long *)x3)[j*si3] - #define f3 ((double *)x3)[j*sf3] - #define c3r ((double *)x3)[j*sf3] - #define c3i ((double *)x3)[j*sf3+1] - + #define s_dest ((char *)dest + j*params.memsteps[store_in]) + #define b1 ((char *)(x1+j*sb1))[0] + #define i1 ((int *)(x1+j*sb1))[0] + #define l1 ((long long *)(x1+j*sb1))[0] + #define f1 ((double *)(x1+j*sb1))[0] + #define c1r ((double *)(x1+j*sb1))[0] + #define c1i ((double *)(x1+j*sb1))[1] + #define s1 ((char *)x1+j*sb1) + #define b2 ((char *)(x2+j*sb2))[0] + #define i2 ((int *)(x2+j*sb2))[0] + #define l2 ((long long *)(x2+j*sb2))[0] + #define f2 ((double *)(x2+j*sb2))[0] + #define c2r ((double *)(x2+j*sb2))[0] + #define c2i ((double *)(x2+j*sb2))[1] + #define s2 ((char *)x2+j*sb2) + #define b3 ((char *)(x3+j*sb3))[0] + #define i3 ((int *)(x3+j*sb3))[0] + #define l3 ((long long *)(x3+j*sb3))[0] + #define f3 ((double *)(x3+j*sb3))[0] + #define c3r ((double *)(x3+j*sb3))[0] + #define c3i ((double *)(x3+j*sb3))[1] + #define s3 ((char *)x3+j*sb3) + /* Some temporaries */ double fa, fb; cdouble ca, cb; char *ptr; @@ -129,27 +145,42 @@ case OP_NOOP: break; case OP_COPY_BB: VEC_ARG1(b_dest = b1); - case OP_COPY_II: VEC_ARG1(i_dest = i1); - case OP_COPY_FF: VEC_ARG1(f_dest = f1); - case OP_COPY_CC: VEC_ARG1(cr_dest = c1r; - ci_dest = c1i); + case OP_COPY_SS: VEC_ARG1(memcpy(s_dest, s1, ss1)); + /* The next versions of copy opcodes can cope with unaligned + data even on platforms that crash while accessing it + (like the Sparc architecture under Solaris). */ + case OP_COPY_II: VEC_ARG1(memcpy(&i_dest, s1, sizeof(int))); + case OP_COPY_LL: VEC_ARG1(memcpy(&f_dest, s1, sizeof(long long))); + case OP_COPY_FF: VEC_ARG1(memcpy(&f_dest, s1, sizeof(double))); + case OP_COPY_CC: VEC_ARG1(memcpy(&cr_dest, s1, sizeof(double)*2)); case OP_INVERT_BB: VEC_ARG1(b_dest = !b1); + case OP_AND_BBB: VEC_ARG2(b_dest = (b1 && b2)); + case OP_OR_BBB: VEC_ARG2(b_dest = (b1 || b2)); - case OP_AND_BBB: VEC_ARG2(b_dest = b1 && b2); - case OP_OR_BBB: VEC_ARG2(b_dest = b1 || b2); + case OP_EQ_BBB: VEC_ARG2(b_dest = (b1 == b2)); + case OP_NE_BBB: VEC_ARG2(b_dest = (b1 != b2)); - case OP_GT_BII: VEC_ARG2(b_dest = (i1 > i2) ? 1 : 0); - case OP_GE_BII: VEC_ARG2(b_dest = (i1 >= i2) ? 1 : 0); - case OP_EQ_BII: VEC_ARG2(b_dest = (i1 == i2) ? 1 : 0); - case OP_NE_BII: VEC_ARG2(b_dest = (i1 != i2) ? 1 : 0); + case OP_GT_BII: VEC_ARG2(b_dest = (i1 > i2)); + case OP_GE_BII: VEC_ARG2(b_dest = (i1 >= i2)); + case OP_EQ_BII: VEC_ARG2(b_dest = (i1 == i2)); + case OP_NE_BII: VEC_ARG2(b_dest = (i1 != i2)); - case OP_GT_BFF: VEC_ARG2(b_dest = (f1 > f2) ? 1 : 0); - case OP_GE_BFF: VEC_ARG2(b_dest = (f1 >= f2) ? 1 : 0); - case OP_EQ_BFF: VEC_ARG2(b_dest = (f1 == f2) ? 1 : 0); - case OP_NE_BFF: VEC_ARG2(b_dest = (f1 != f2) ? 1 : 0); + case OP_GT_BLL: VEC_ARG2(b_dest = (l1 > l2)); + case OP_GE_BLL: VEC_ARG2(b_dest = (l1 >= l2)); + case OP_EQ_BLL: VEC_ARG2(b_dest = (l1 == l2)); + case OP_NE_BLL: VEC_ARG2(b_dest = (l1 != l2)); - case OP_CAST_IB: VEC_ARG1(i_dest = (long)b1); + case OP_GT_BFF: VEC_ARG2(b_dest = (f1 > f2)); + case OP_GE_BFF: VEC_ARG2(b_dest = (f1 >= f2)); + case OP_EQ_BFF: VEC_ARG2(b_dest = (f1 == f2)); + case OP_NE_BFF: VEC_ARG2(b_dest = (f1 != f2)); + + case OP_GT_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) > 0)); + case OP_GE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) >= 0)); + case OP_EQ_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) == 0)); + case OP_NE_BSS: VEC_ARG2(b_dest = (stringcmp(s1, s2, ss1, ss2) != 0)); + case OP_ONES_LIKE_II: VEC_ARG1(i_dest = 1); case OP_NEG_II: VEC_ARG1(i_dest = -i1); @@ -157,13 +188,26 @@ case OP_SUB_III: VEC_ARG2(i_dest = i1 - i2); case OP_MUL_III: VEC_ARG2(i_dest = i1 * i2); case OP_DIV_III: VEC_ARG2(i_dest = i1 / i2); - case OP_POW_III: VEC_ARG2(i_dest = (i2 < 0) ? (1 / i1) : (long)pow(i1, i2)); + case OP_POW_III: VEC_ARG2(i_dest = (i2 < 0) ? (1 / i1) : (int)pow(i1, i2)); case OP_MOD_III: VEC_ARG2(i_dest = i1 % i2); - case OP_WHERE_IFII: VEC_ARG3(i_dest = f1 ? i2 : i3); + case OP_WHERE_IBII: VEC_ARG3(i_dest = b1 ? i2 : i3); - case OP_CAST_FB: VEC_ARG1(f_dest = (long)b1); + case OP_CAST_LI: VEC_ARG1(l_dest = (long long)(i1)); + case OP_ONES_LIKE_LL: VEC_ARG1(l_dest = 1); + case OP_NEG_LL: VEC_ARG1(l_dest = -i1); + + case OP_ADD_LLL: VEC_ARG2(l_dest = l1 + l2); + case OP_SUB_LLL: VEC_ARG2(l_dest = l1 - l2); + case OP_MUL_LLL: VEC_ARG2(l_dest = l1 * l2); + case OP_DIV_LLL: VEC_ARG2(l_dest = l1 / l2); + case OP_POW_LLL: VEC_ARG2(l_dest = (l2 < 0) ? (1 / l1) : (long long)pow(l1, l2)); + case OP_MOD_LLL: VEC_ARG2(l_dest = l1 % l2); + + case OP_WHERE_LBLL: VEC_ARG3(l_dest = b1 ? l2 : l3); + case OP_CAST_FI: VEC_ARG1(f_dest = (double)(i1)); + case OP_CAST_FL: VEC_ARG1(f_dest = (double)(l1)); case OP_ONES_LIKE_FF: VEC_ARG1(f_dest = 1.0); case OP_NEG_FF: VEC_ARG1(f_dest = -f1); @@ -180,15 +224,15 @@ case OP_SQRT_FF: VEC_ARG1(f_dest = sqrt(f1)); case OP_ARCTAN2_FFF: VEC_ARG2(f_dest = atan2(f1, f2)); - case OP_WHERE_FFFF: VEC_ARG3(f_dest = f1 ? f2 : f3); + case OP_WHERE_FBFF: VEC_ARG3(f_dest = b1 ? f2 : f3); case OP_FUNC_FF: VEC_ARG1(f_dest = functions_f[arg2](f1)); case OP_FUNC_FFF: VEC_ARG2(f_dest = functions_ff[arg3](f1, f2)); - case OP_CAST_CB: VEC_ARG1(cr_dest = (double)b1; - ci_dest = 0); case OP_CAST_CI: VEC_ARG1(cr_dest = (double)(i1); ci_dest = 0); + case OP_CAST_CL: VEC_ARG1(cr_dest = (double)(l1); + ci_dest = 0); case OP_CAST_CF: VEC_ARG1(cr_dest = f1; ci_dest = 0); case OP_ONES_LIKE_CC: VEC_ARG1(cr_dest = 1; @@ -208,11 +252,11 @@ ci_dest = (c1i*c2r - c1r*c2i) / fa; cr_dest = fb); - case OP_EQ_BCC: VEC_ARG2(b_dest = (c1r == c2r && c1i == c2i) ? 1 : 0); - case OP_NE_BCC: VEC_ARG2(b_dest = (c1r != c2r || c1i != c2i) ? 1 : 0); + case OP_EQ_BCC: VEC_ARG2(b_dest = (c1r == c2r && c1i == c2i)); + case OP_NE_BCC: VEC_ARG2(b_dest = (c1r != c2r || c1i != c2i)); - case OP_WHERE_CFCC: VEC_ARG3(cr_dest = f1 ? c2r : c3r; - ci_dest = f1 ? c2i : c3i); + case OP_WHERE_CBCC: VEC_ARG3(cr_dest = b1 ? c2r : c3r; + ci_dest = b1 ? c2i : c3i); case OP_FUNC_CC: VEC_ARG1(ca.real = c1r; ca.imag = c1i; functions_cc[arg2](&ca, &ca); @@ -232,12 +276,14 @@ ci_dest = f2); case OP_SUM_IIN: VEC_ARG1(i_reduce += i1); + case OP_SUM_LLN: VEC_ARG1(l_reduce += l1); case OP_SUM_FFN: VEC_ARG1(f_reduce += f1); case OP_SUM_CCN: VEC_ARG1(ptr = reduce_ptr; cr_reduce += c1r; ci_reduce += c1i); case OP_PROD_IIN: VEC_ARG1(i_reduce *= i1); + case OP_PROD_LLN: VEC_ARG1(l_reduce *= l1); case OP_PROD_FFN: VEC_ARG1(f_reduce *= f1); case OP_PROD_CCN: VEC_ARG1(ptr = reduce_ptr; fa = cr_reduce*c1r - ci_reduce*c1i; @@ -258,22 +304,30 @@ #undef b_dest #undef i_dest +#undef l_dest #undef f_dest #undef cr_dest #undef ci_dest +#undef s_dest #undef b1 #undef i1 +#undef l1 #undef f1 #undef c1r #undef c1i +#undef s1 #undef b2 #undef i2 +#undef l2 #undef f2 #undef c2r #undef c2i +#undef s2 #undef b3 #undef i3 +#undef l3 #undef f3 #undef c3r #undef c3i +#undef s3 } Modified: branches/scipy.scons/scipy/sandbox/numexpr/interpreter.c =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/interpreter.c 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/interpreter.c 2007-11-24 10:53:58 UTC (rev 3583) @@ -2,6 +2,8 @@ #include "structmember.h" #include "numpy/noprefix.h" #include "math.h" +#include "string.h" +#include "assert.h" #include "complex_functions.inc" @@ -25,17 +27,29 @@ OP_AND_BBB, OP_OR_BBB, + OP_EQ_BBB, + OP_NE_BBB, + OP_GT_BII, OP_GE_BII, OP_EQ_BII, OP_NE_BII, + OP_GT_BLL, + OP_GE_BLL, + OP_EQ_BLL, + OP_NE_BLL, + OP_GT_BFF, OP_GE_BFF, OP_EQ_BFF, OP_NE_BFF, - OP_CAST_IB, + OP_GT_BSS, + OP_GE_BSS, + OP_EQ_BSS, + OP_NE_BSS, + OP_COPY_II, OP_ONES_LIKE_II, OP_NEG_II, @@ -45,10 +59,22 @@ OP_DIV_III, OP_POW_III, OP_MOD_III, - OP_WHERE_IFII, + OP_WHERE_IBII, - OP_CAST_FB, + OP_CAST_LI, + OP_COPY_LL, + OP_ONES_LIKE_LL, + OP_NEG_LL, + OP_ADD_LLL, + OP_SUB_LLL, + OP_MUL_LLL, + OP_DIV_LLL, + OP_POW_LLL, + OP_MOD_LLL, + OP_WHERE_LBLL, + OP_CAST_FI, + OP_CAST_FL, OP_COPY_FF, OP_ONES_LIKE_FF, OP_NEG_FF, @@ -63,15 +89,15 @@ OP_TAN_FF, OP_SQRT_FF, OP_ARCTAN2_FFF, - OP_WHERE_FFFF, + OP_WHERE_FBFF, OP_FUNC_FF, OP_FUNC_FFF, OP_EQ_BCC, OP_NE_BCC, - OP_CAST_CB, OP_CAST_CI, + OP_CAST_CL, OP_CAST_CF, OP_ONES_LIKE_CC, OP_COPY_CC, @@ -80,7 +106,7 @@ OP_SUB_CCC, OP_MUL_CCC, OP_DIV_CCC, - OP_WHERE_CFCC, + OP_WHERE_CBCC, OP_FUNC_CC, OP_FUNC_CCC, @@ -88,15 +114,19 @@ OP_IMAG_FC, OP_COMPLEX_CFF, + OP_COPY_SS, + OP_REDUCTION, OP_SUM, OP_SUM_IIN, + OP_SUM_LLN, OP_SUM_FFN, OP_SUM_CCN, OP_PROD, OP_PROD_IIN, + OP_PROD_LLN, OP_PROD_FFN, OP_PROD_CCN @@ -116,6 +146,8 @@ break; case OP_AND_BBB: case OP_OR_BBB: + case OP_EQ_BBB: + case OP_NE_BBB: if (n == 0 || n == 1 || n == 2) return 'b'; break; case OP_GT_BII: @@ -125,6 +157,13 @@ if (n == 0) return 'b'; if (n == 1 || n == 2) return 'i'; break; + case OP_GT_BLL: + case OP_GE_BLL: + case OP_EQ_BLL: + case OP_NE_BLL: + if (n == 0) return 'b'; + if (n == 1 || n == 2) return 'l'; + break; case OP_GT_BFF: case OP_GE_BFF: case OP_EQ_BFF: @@ -132,9 +171,12 @@ if (n == 0) return 'b'; if (n == 1 || n == 2) return 'f'; break; - case OP_CAST_IB: - if (n == 0) return 'i'; - if (n == 1) return 'b'; + case OP_GT_BSS: + case OP_GE_BSS: + case OP_EQ_BSS: + case OP_NE_BSS: + if (n == 0) return 'b'; + if (n == 1 || n == 2) return 's'; break; case OP_COPY_II: case OP_ONES_LIKE_II: @@ -149,18 +191,39 @@ case OP_POW_III: if (n == 0 || n == 1 || n == 2) return 'i'; break; - case OP_WHERE_IFII: + case OP_WHERE_IBII: if (n == 0 || n == 2 || n == 3) return 'i'; - if (n == 1) return 'f'; + if (n == 1) return 'b'; break; - case OP_CAST_FB: - if (n == 0) return 'f'; + case OP_CAST_LI: + if (n == 0) return 'l'; + if (n == 1) return 'i'; + break; + case OP_COPY_LL: + case OP_ONES_LIKE_LL: + case OP_NEG_LL: + if (n == 0 || n == 1) return 'l'; + break; + case OP_ADD_LLL: + case OP_SUB_LLL: + case OP_MUL_LLL: + case OP_DIV_LLL: + case OP_MOD_LLL: + case OP_POW_LLL: + if (n == 0 || n == 1 || n == 2) return 'l'; + break; + case OP_WHERE_LBLL: + if (n == 0 || n == 2 || n == 3) return 'l'; if (n == 1) return 'b'; break; case OP_CAST_FI: if (n == 0) return 'f'; if (n == 1) return 'i'; break; + case OP_CAST_FL: + if (n == 0) return 'f'; + if (n == 1) return 'l'; + break; case OP_COPY_FF: case OP_ONES_LIKE_FF: case OP_NEG_FF: @@ -179,8 +242,9 @@ case OP_ARCTAN2_FFF: if (n == 0 || n == 1 || n == 2) return 'f'; break; - case OP_WHERE_FFFF: - if (n == 0 || n == 1 || n == 2 || n == 3) return 'f'; + case OP_WHERE_FBFF: + if (n == 0 || n == 2 || n == 3) return 'f'; + if (n == 1) return 'b'; break; case OP_FUNC_FF: if (n == 0 || n == 1) return 'f'; @@ -195,14 +259,14 @@ if (n == 0) return 'b'; if (n == 1 || n == 2) return 'c'; break; - case OP_CAST_CB: - if (n == 0) return 'c'; - if (n == 1) return 'b'; - break; case OP_CAST_CI: if (n == 0) return 'c'; if (n == 1) return 'i'; break; + case OP_CAST_CL: + if (n == 0) return 'c'; + if (n == 1) return 'l'; + break; case OP_CAST_CF: if (n == 0) return 'c'; if (n == 1) return 'f'; @@ -218,9 +282,9 @@ case OP_DIV_CCC: if (n == 0 || n == 1 || n == 2) return 'c'; break; - case OP_WHERE_CFCC: + case OP_WHERE_CBCC: if (n == 0 || n == 2 || n == 3) return 'c'; - if (n == 1) return 'f'; + if (n == 1) return 'b'; break; case OP_FUNC_CC: if (n == 0 || n == 1) return 'c'; @@ -239,11 +303,19 @@ if (n == 0) return 'c'; if (n == 1 || n == 2) return 'f'; break; + case OP_COPY_SS: + if (n == 0 || n == 1) return 's'; + break; case OP_PROD_IIN: case OP_SUM_IIN: if (n == 0 || n == 1) return 'i'; if (n == 2) return 'n'; break; + case OP_PROD_LLN: + case OP_SUM_LLN: + if (n == 0 || n == 1) return 'l'; + if (n == 2) return 'n'; + break; case OP_PROD_FFN: case OP_SUM_FFN: if (n == 0 || n == 1) return 'f'; @@ -383,6 +455,7 @@ char **mem; /* pointers to registers */ char *rawmem; /* a chunks of raw memory for storing registers */ intp *memsteps; + intp *memsizes; int rawmemsize; } NumExprObject; @@ -399,6 +472,7 @@ PyMem_Del(self->mem); PyMem_Del(self->rawmem); PyMem_Del(self->memsteps); + PyMem_Del(self->memsizes); self->ob_type->tp_free((PyObject*)self); } @@ -425,6 +499,7 @@ self->mem = NULL; self->rawmem = NULL; self->memsteps = NULL; + self->memsizes = NULL; self->rawmemsize = 0; #undef INIT_WITH } @@ -454,11 +529,13 @@ { switch (c) { case 'b': return sizeof(char); - case 'i': return sizeof(long); + case 'i': return sizeof(int); + case 'l': return sizeof(long long); case 'f': return sizeof(double); case 'c': return 2*sizeof(double); + case 's': return 0; /* strings are ok but size must be computed */ default: - PyErr_SetString(PyExc_TypeError, "signature value not in 'bifc'"); + PyErr_SetString(PyExc_TypeError, "signature value not in 'bilfcs'"); return -1; } } @@ -482,11 +559,13 @@ { switch (c) { case 'b': return PyArray_BOOL; - case 'i': return PyArray_LONG; + case 'i': return PyArray_INT; + case 'l': return PyArray_LONGLONG; case 'f': return PyArray_DOUBLE; case 'c': return PyArray_CDOUBLE; + case 's': return PyArray_STRING; default: - PyErr_SetString(PyExc_TypeError, "signature value not in 'ifc'"); + PyErr_SetString(PyExc_TypeError, "signature value not in 'bilfcs'"); return -1; } } @@ -502,7 +581,6 @@ static int get_reduction_axis(PyObject* program) { - char last_opcode, sig; int end = PyString_Size(program); int axis = ((unsigned char *)PyString_AS_STRING(program))[end-1]; if (axis != 255 && axis >= MAX_DIMS) @@ -579,7 +657,7 @@ } arg = program[argloc]; - if (sig != 'n' && (arg >= n_buffers) || (arg < 0)) { + if (sig != 'n' && ((arg >= n_buffers) || (arg < 0))) { PyErr_Format(PyExc_RuntimeError, "invalid program: buffer out of range (%i) at %i", arg, argloc); return -1; } @@ -630,8 +708,10 @@ PyObject *signature = NULL, *tempsig = NULL, *constsig = NULL; PyObject *fullsig = NULL, *program = NULL, *constants = NULL; PyObject *input_names = NULL, *o_constants = NULL; + int *itemsizes = NULL; char **mem = NULL, *rawmem = NULL; intp *memsteps; + intp *memsizes; int rawmemsize; static char *kwlist[] = {"signature", "tempsig", "program", "constants", @@ -660,33 +740,53 @@ Py_DECREF(constants); return -1; } + if (!(itemsizes = PyMem_New(int, n_constants))) { + Py_DECREF(constants); + return -1; + } for (i = 0; i < n_constants; i++) { PyObject *o; if (!(o = PySequence_GetItem(o_constants, i))) { /* new reference */ Py_DECREF(constants); Py_DECREF(constsig); + PyMem_Del(itemsizes); return -1; } PyTuple_SET_ITEM(constants, i, o); /* steals reference */ if (PyBool_Check(o)) { PyString_AS_STRING(constsig)[i] = 'b'; + itemsizes[i] = size_from_char('b'); continue; } if (PyInt_Check(o)) { PyString_AS_STRING(constsig)[i] = 'i'; + itemsizes[i] = size_from_char('i'); continue; } + if (PyLong_Check(o)) { + PyString_AS_STRING(constsig)[i] = 'l'; + itemsizes[i] = size_from_char('l'); + continue; + } if (PyFloat_Check(o)) { PyString_AS_STRING(constsig)[i] = 'f'; + itemsizes[i] = size_from_char('f'); continue; } if (PyComplex_Check(o)) { PyString_AS_STRING(constsig)[i] = 'c'; + itemsizes[i] = size_from_char('c'); continue; } - PyErr_SetString(PyExc_TypeError, "constants must be of type int/float/complex"); + if (PyString_Check(o)) { + PyString_AS_STRING(constsig)[i] = 's'; + itemsizes[i] = PyString_GET_SIZE(o); + continue; + } + PyErr_SetString(PyExc_TypeError, "constants must be of type bool/int/long/float/complex/str"); Py_DECREF(constsig); Py_DECREF(constants); + PyMem_Del(itemsizes); return -1; } } else { @@ -705,23 +805,34 @@ if (!fullsig) { Py_DECREF(constants); Py_DECREF(constsig); + PyMem_Del(itemsizes); + return -1; } if (!input_names) { input_names = Py_None; } - rawmemsize = BLOCK_SIZE1 * (size_from_sig(constsig) + size_from_sig(tempsig)); + /* Compute the size of registers. */ + rawmemsize = 0; + for (i = 0; i < n_constants; i++) + rawmemsize += itemsizes[i]; + rawmemsize += size_from_sig(tempsig); /* no string temporaries */ + rawmemsize *= BLOCK_SIZE1; + mem = PyMem_New(char *, 1 + n_inputs + n_constants + n_temps); rawmem = PyMem_New(char, rawmemsize); - memsteps = PyMem_New(int, 1 + n_inputs + n_constants + n_temps); - if (!mem || !rawmem || !memsteps) { + memsteps = PyMem_New(intp, 1 + n_inputs + n_constants + n_temps); + memsizes = PyMem_New(intp, 1 + n_inputs + n_constants + n_temps); + if (!mem || !rawmem || !memsteps || !memsizes) { Py_DECREF(constants); Py_DECREF(constsig); Py_DECREF(fullsig); + PyMem_Del(itemsizes); PyMem_Del(mem); PyMem_Del(rawmem); PyMem_Del(memsteps); + PyMem_Del(memsizes); return -1; } /* @@ -734,10 +845,10 @@ mem_offset = 0; for (i = 0; i < n_constants; i++) { char c = PyString_AS_STRING(constsig)[i]; - int size = size_from_char(c); + int size = itemsizes[i]; mem[i+n_inputs+1] = rawmem + mem_offset; mem_offset += BLOCK_SIZE1 * size; - memsteps[i+n_inputs+1] = size; + memsteps[i+n_inputs+1] = memsizes[i+n_inputs+1] = size; /* fill in the constants */ if (c == 'b') { char *bmem = (char*)mem[i+n_inputs+1]; @@ -746,11 +857,17 @@ bmem[j] = value; } } else if (c == 'i') { - long *imem = (long*)mem[i+n_inputs+1]; - long value = PyInt_AS_LONG(PyTuple_GET_ITEM(constants, i)); + int *imem = (int*)mem[i+n_inputs+1]; + int value = (int)PyInt_AS_LONG(PyTuple_GET_ITEM(constants, i)); for (j = 0; j < BLOCK_SIZE1; j++) { imem[j] = value; } + } else if (c == 'l') { + long long *lmem = (long long*)mem[i+n_inputs+1]; + long long value = PyLong_AsLongLong(PyTuple_GET_ITEM(constants, i)); + for (j = 0; j < BLOCK_SIZE1; j++) { + lmem[j] = value; + } } else if (c == 'f') { double *dmem = (double*)mem[i+n_inputs+1]; double value = PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(constants, i)); @@ -764,14 +881,32 @@ cmem[j] = value.real; cmem[j+1] = value.imag; } + } else if (c == 's') { + char *smem = (char*)mem[i+n_inputs+1]; + char *value = PyString_AS_STRING(PyTuple_GET_ITEM(constants, i)); + for (j = 0; j < size*BLOCK_SIZE1; j+=size) { + memcpy(smem + j, value, size); + } } } + /* This is no longer needed since no unusual item sizes appear + in temporaries (there are no string temporaries). */ + PyMem_Del(itemsizes); + /* Fill in 'mem' for temps */ for (i = 0; i < n_temps; i++) { - int size = size_from_char(PyString_AS_STRING(tempsig)[i]); + char c = PyString_AS_STRING(tempsig)[i]; + int size = size_from_char(c); + /* XXX: This check is quite useless, since using a string temporary + still causes a crash when freeing rawmem. Why? */ + if (c == 's') { + PyErr_SetString(PyExc_NotImplementedError, + "string temporaries are not supported"); + break; + } mem[i+n_inputs+n_constants+1] = rawmem + mem_offset; mem_offset += BLOCK_SIZE1 * size; - memsteps[i+n_inputs+n_constants+1] = size; + memsteps[i+n_inputs+n_constants+1] = memsizes[i+n_inputs+n_constants+1] = size; } /* See if any errors occured (e.g., in size_from_char) or if mem_offset is wrong */ if (PyErr_Occurred() || mem_offset != rawmemsize) { @@ -784,6 +919,7 @@ PyMem_Del(mem); PyMem_Del(rawmem); PyMem_Del(memsteps); + PyMem_Del(memsizes); return -1; } @@ -805,6 +941,7 @@ REPLACE_MEM(mem); REPLACE_MEM(rawmem); REPLACE_MEM(memsteps); + REPLACE_MEM(memsizes); self->rawmemsize = rawmemsize; #undef REPLACE_OBJ @@ -832,8 +969,8 @@ int count; int size; int findex; - int *shape; - int *strides; + intp *shape; + intp *strides; int *index; char *buffer; }; @@ -847,6 +984,7 @@ char **inputs; char **mem; intp *memsteps; + intp *memsizes; struct index_data *index_data; }; @@ -886,6 +1024,26 @@ #define BOUNDS_CHECK(arg) #endif +int +stringcmp(const char *s1, const char *s2, intp maxlen1, intp maxlen2) +{ + intp maxlen, nextpos; + /* Point to this when the end of a string is found, + to simulate infinte trailing NUL characters. */ + const char null = 0; + + maxlen = (maxlen1 > maxlen2) ? maxlen1 : maxlen2; + for (nextpos = 1; nextpos <= maxlen; nextpos++) { + if (*s1 < *s2) + return -1; + if (*s1 > *s2) + return +1; + s1 = (nextpos >= maxlen1) ? &null : s1+1; + s2 = (nextpos >= maxlen2) ? &null : s2+1; + } + return 0; +} + static inline int vm_engine_1(int start, int blen, struct vm_params params, int *pc_error) { @@ -943,6 +1101,7 @@ params.index_data = index_data; params.mem = self->mem; params.memsteps = self->memsteps; + params.memsizes = self->memsizes; params.r_end = PyString_Size(self->fullsig); blen1 = len - len % BLOCK_SIZE1; r = vm_engine_1(0, blen1, params, pc_error); @@ -966,7 +1125,7 @@ PyObject *output = NULL, *a_inputs = NULL; struct index_data *inddata = NULL; unsigned int n_inputs, n_dimensions = 0; - int shape[MAX_DIMS]; + intp shape[MAX_DIMS]; int i, j, size, r, pc_error; char **inputs = NULL; intp strides[MAX_DIMS]; /* clean up XXX */ @@ -1004,7 +1163,12 @@ int typecode = typecode_from_char(c); if (typecode == -1) goto cleanup_and_exit; /* Convert it just in case of a non-swapped array */ - a = PyArray_FROM_OTF(o, typecode, NOTSWAPPED); + if (!PyArray_Check(o) || PyArray_TYPE(o) != PyArray_STRING) { + a = PyArray_FROM_OTF(o, typecode, NOTSWAPPED); + } else { + Py_INCREF(PyArray_DESCR(o)); /* typecode is not enough */ + a = PyArray_FromAny(o, PyArray_DESCR(o), 0, 0, NOTSWAPPED, NULL); + } if (!a) goto cleanup_and_exit; PyTuple_SET_ITEM(a_inputs, i, a); /* steals reference */ if (PyArray_NDIM(a) > n_dimensions) @@ -1042,7 +1206,7 @@ for (i = 0; i < n_inputs; i++) { PyObject *a = PyTuple_GET_ITEM(a_inputs, i); PyObject *b; - int strides[MAX_DIMS]; + intp strides[MAX_DIMS]; int delta = n_dimensions - PyArray_NDIM(a); if (PyArray_NDIM(a)) { for (j = 0; j < n_dimensions; j++) @@ -1071,15 +1235,25 @@ if (PyArray_NDIM(a) == 0) { /* Broadcast scalars */ intp dims[1] = {BLOCK_SIZE1}; - b = PyArray_SimpleNew(1, dims, typecode); + Py_INCREF(PyArray_DESCR(a)); + b = PyArray_SimpleNewFromDescr(1, dims, PyArray_DESCR(a)); if (!b) goto cleanup_and_exit; self->memsteps[i+1] = 0; + self->memsizes[i+1] = PyArray_ITEMSIZE(a); PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, b); /* steals reference */ inputs[i] = PyArray_DATA(b); - if (typecode == PyArray_LONG) { - long value = ((long*)PyArray_DATA(a))[0]; + if (typecode == PyArray_BOOL) { + char value = ((char*)PyArray_DATA(a))[0]; for (j = 0; j < BLOCK_SIZE1; j++) - ((long*)PyArray_DATA(b))[j] = value; + ((char*)PyArray_DATA(b))[j] = value; + } else if (typecode == PyArray_INT) { + int value = ((int*)PyArray_DATA(a))[0]; + for (j = 0; j < BLOCK_SIZE1; j++) + ((int*)PyArray_DATA(b))[j] = value; + } else if (typecode == PyArray_LONGLONG) { + long long value = ((long long*)PyArray_DATA(a))[0]; + for (j = 0; j < BLOCK_SIZE1; j++) + ((long long*)PyArray_DATA(b))[j] = value; } else if (typecode == PyArray_DOUBLE) { double value = ((double*)PyArray_DATA(a))[0]; for (j = 0; j < BLOCK_SIZE1; j++) @@ -1091,17 +1265,25 @@ ((double*)PyArray_DATA(b))[j] = rvalue; ((double*)PyArray_DATA(b))[j+1] = ivalue; } + } else if (typecode == PyArray_STRING) { + int itemsize = PyArray_ITEMSIZE(a); + char *value = (char*)(PyArray_DATA(a)); + for (j = 0; j < itemsize*BLOCK_SIZE1; j+=itemsize) + memcpy((char*)(PyArray_DATA(b)) + j, value, itemsize); } else { PyErr_SetString(PyExc_RuntimeError, "illegal typecode value"); goto cleanup_and_exit; } } else { - PyObject *origA = a; - int inner_size = -1; - /* Check array is contiguous */ - for (j = PyArray_NDIM(a)-1; j >= 0; j--) { - if ((inner_size == -1 && PyArray_STRIDE(a, j) % PyArray_ITEMSIZE(a)) || - (inner_size != -1 && PyArray_STRIDE(a, j) != inner_size)) { + /* Check that discontiguous strides appear only on the last + dimension. If not, the arrays should be copied. + Furthermore, such arrays can appear when doing + broadcasting above, so this check really needs to be + here, and not in Python space. */ + intp inner_size; + for (j = PyArray_NDIM(a)-2; j >= 0; j--) { + inner_size = PyArray_STRIDE(a, j) * PyArray_DIM(a, j); + if (PyArray_STRIDE(a, j+1) != inner_size) { intp dims[1] = {BLOCK_SIZE1}; inddata[i+1].count = PyArray_NDIM(a); inddata[i+1].findex = -1; @@ -1112,20 +1294,24 @@ inddata[i+1].index = PyMem_New(int, inddata[i+1].count); for (j = 0; j < inddata[i+1].count; j++) inddata[i+1].index[j] = 0; - a = PyArray_SimpleNew(1, dims, typecode); - PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, a); /* steals reference */ + Py_INCREF(PyArray_DESCR(a)); + a = PyArray_SimpleNewFromDescr(1, dims, PyArray_DESCR(a)); + /* steals reference below */ + PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, a); break; } - inner_size = PyArray_STRIDE(a, j) * PyArray_DIM(a, j); } self->memsteps[i+1] = PyArray_STRIDE(a, PyArray_NDIM(a)-1); + self->memsizes[i+1] = PyArray_ITEMSIZE(a); inputs[i] = PyArray_DATA(a); } } if (last_opcode(self->program) > OP_REDUCTION) { + /* A reduction can not result in a string, + so we don't need to worry about item sizes here. */ char retsig = get_return_sig(self->program); int axis = get_reduction_axis(self->program); self->memsteps[0] = 0; /*size_from_char(retsig);*/ @@ -1188,10 +1374,26 @@ } else { char retsig = get_return_sig(self->program); - self->memsteps[0] = size_from_char(retsig); - output = PyArray_SimpleNew(n_dimensions, - shape, - typecode_from_char(retsig)); + if (retsig != 's') { + self->memsteps[0] = self->memsizes[0] = size_from_char(retsig); + output = PyArray_SimpleNew( + n_dimensions, shape, typecode_from_char(retsig)); + } else { + /* Since the *only* supported operation returning a string + * is a copy, the size of returned strings + * can be directly gotten from the first (and only) + * input/constant/temporary. */ + PyArray_Descr *descr; + if (n_inputs > 0) { /* input, like in 'a' where a -> 'foo' */ + descr = PyArray_DESCR(PyTuple_GET_ITEM(a_inputs, 1)); + Py_INCREF(descr); + } else { /* constant, like in '"foo"' */ + descr = PyArray_DescrFromType(PyArray_STRING); + descr->elsize = self->memsizes[1]; + } /* no string temporaries, so no third case */ + self->memsteps[0] = self->memsizes[0] = self->memsizes[1]; + output = PyArray_SimpleNewFromDescr(n_dimensions, shape, descr); + } if (!output) goto cleanup_and_exit; } @@ -1311,17 +1513,30 @@ add_op("invert_bb", OP_INVERT_BB); add_op("and_bbb", OP_AND_BBB); add_op("or_bbb", OP_OR_BBB); + + add_op("eq_bbb", OP_EQ_BBB); + add_op("ne_bbb", OP_NE_BBB); + add_op("gt_bii", OP_GT_BII); add_op("ge_bii", OP_GE_BII); add_op("eq_bii", OP_EQ_BII); add_op("ne_bii", OP_NE_BII); + add_op("gt_bll", OP_GT_BLL); + add_op("ge_bll", OP_GE_BLL); + add_op("eq_bll", OP_EQ_BLL); + add_op("ne_bll", OP_NE_BLL); + add_op("gt_bff", OP_GT_BFF); add_op("ge_bff", OP_GE_BFF); add_op("eq_bff", OP_EQ_BFF); add_op("ne_bff", OP_NE_BFF); - add_op("cast_ib", OP_CAST_IB); + add_op("gt_bss", OP_GT_BSS); + add_op("ge_bss", OP_GE_BSS); + add_op("eq_bss", OP_EQ_BSS); + add_op("ne_bss", OP_NE_BSS); + add_op("ones_like_ii", OP_ONES_LIKE_II); add_op("copy_ii", OP_COPY_II); add_op("neg_ii", OP_NEG_II); @@ -1331,10 +1546,22 @@ add_op("div_iii", OP_DIV_III); add_op("pow_iii", OP_POW_III); add_op("mod_iii", OP_MOD_III); - add_op("where_ifii", OP_WHERE_IFII); + add_op("where_ibii", OP_WHERE_IBII); - add_op("cast_fb", OP_CAST_FB); + add_op("cast_li", OP_CAST_LI); + add_op("ones_like_ll", OP_ONES_LIKE_LL); + add_op("copy_ll", OP_COPY_LL); + add_op("neg_ll", OP_NEG_LL); + add_op("add_lll", OP_ADD_LLL); + add_op("sub_lll", OP_SUB_LLL); + add_op("mul_lll", OP_MUL_LLL); + add_op("div_lll", OP_DIV_LLL); + add_op("pow_lll", OP_POW_LLL); + add_op("mod_lll", OP_MOD_LLL); + add_op("where_lbll", OP_WHERE_LBLL); + add_op("cast_fi", OP_CAST_FI); + add_op("cast_fl", OP_CAST_FL); add_op("copy_ff", OP_COPY_FF); add_op("ones_like_ff", OP_ONES_LIKE_FF); add_op("neg_cc", OP_NEG_CC); @@ -1350,15 +1577,15 @@ add_op("tan_ff", OP_TAN_FF); add_op("sqrt_ff", OP_SQRT_FF); add_op("arctan2_fff", OP_ARCTAN2_FFF); - add_op("where_ffff", OP_WHERE_FFFF); + add_op("where_fbff", OP_WHERE_FBFF); add_op("func_ff", OP_FUNC_FF); add_op("func_fff", OP_FUNC_FFF); add_op("eq_bcc", OP_EQ_BCC); add_op("ne_bcc", OP_NE_BCC); - add_op("cast_cb", OP_CAST_CB); add_op("cast_ci", OP_CAST_CI); + add_op("cast_cl", OP_CAST_CL); add_op("cast_cf", OP_CAST_CF); add_op("copy_cc", OP_COPY_CC); add_op("ones_like_cc", OP_ONES_LIKE_CC); @@ -1367,7 +1594,7 @@ add_op("sub_ccc", OP_SUB_CCC); add_op("mul_ccc", OP_MUL_CCC); add_op("div_ccc", OP_DIV_CCC); - add_op("where_cfcc", OP_WHERE_CFCC); + add_op("where_cbcc", OP_WHERE_CBCC); add_op("func_cc", OP_FUNC_CC); add_op("func_ccc", OP_FUNC_CCC); @@ -1375,11 +1602,15 @@ add_op("imag_fc", OP_IMAG_FC); add_op("complex_cff", OP_COMPLEX_CFF); + add_op("copy_ss", OP_COPY_SS); + add_op("sum_iin", OP_SUM_IIN); + add_op("sum_lln", OP_SUM_LLN); add_op("sum_ffn", OP_SUM_FFN); add_op("sum_ccn", OP_SUM_CCN); add_op("prod_iin", OP_PROD_IIN); + add_op("prod_lln", OP_PROD_LLN); add_op("prod_ffn", OP_PROD_FFN); add_op("prod_ccn", OP_PROD_CCN); Modified: branches/scipy.scons/scipy/sandbox/numexpr/tests/test_numexpr.py =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/tests/test_numexpr.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/tests/test_numexpr.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -6,7 +6,7 @@ from numexpr import E, numexpr, evaluate, disassemble restore_path() -class TestNumExpr(NumpyTestCase): +class test_numexpr(NumpyTestCase): def check_simple(self): ex = 2.0 * E.a + 3.0 * E.b * E.c func = numexpr(ex, signature=[('a', float), ('b', float), ('c', float)]) @@ -63,14 +63,14 @@ x = x.astype(int) assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0)) assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0)) + # Check longs + x = x.astype(long) + assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0)) + assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0)) # Check complex x = x + 5j assert_equal(evaluate("sum(x**2+2,axis=0)"), sum(x**2+2,axis=0)) assert_equal(evaluate("prod(x**2+2,axis=0)"), prod(x**2+2,axis=0)) - # Check boolean (should cast to integer) - x = (arange(10) % 2).astype(bool) - assert_equal(evaluate("prod(x,axis=0)"), prod(x,axis=0)) - assert_equal(evaluate("sum(x,axis=0)"), sum(x,axis=0)) def check_axis(self): y = arange(9.0).reshape(3,3) @@ -95,7 +95,7 @@ [('mul_fff', 'r0', 'r1[x]', 'r1[x]'), ('add_fff', 'r0', 'r0', 'c2[2.0]')]) -class TestEvaluate(NumpyTestCase): +class test_evaluate(NumpyTestCase): def check_simple(self): a = array([1., 2., 3.]) b = array([4., 5., 6.]) @@ -187,8 +187,8 @@ '2*a + (cos(3)+5)*sinh(cos(b))', '2*a + arctan2(a, b)', 'arcsin(0.5)', - 'where(a, 2, b)', - 'where((a-10).real, a, 2)', + 'where(a != 0.0, 2, b)', + 'where((a-10).real != 0.0, a, 2)', 'cos(1+1)', '1+1', '1', @@ -239,7 +239,7 @@ class Skip(Exception): pass -class TestExpressions(NumpyTestCase): +class test_expressions(NumpyTestCase): pass def generate_check_expressions(): @@ -274,7 +274,7 @@ new.instancemethod(method, None, test_expressions)) x = None for test_scalar in [0,1,2]: - for dtype in [int, float, complex]: + for dtype in [int, long, float, complex]: array_size = 100 a = arange(2*array_size, dtype=dtype)[::2] a2 = zeros([array_size, array_size], dtype=dtype) @@ -298,7 +298,7 @@ '<' in expr or '>' in expr or '%' in expr or "arctan2" in expr or "fmod" in expr): continue # skip complex comparisons - if dtype == int and test_scalar and expr == '(a+1) ** -1': + if dtype in (int, long) and test_scalar and expr == '(a+1) ** -1': continue make_check_method(a, a2, b, c, d, e, x, expr, test_scalar, dtype, @@ -306,5 +306,145 @@ generate_check_expressions() +class test_int32_int64(NumpyTestCase): + def check_small_long(self): + # Small longs should not be downgraded to ints. + res = evaluate('42L') + assert_array_equal(res, 42) + self.assertEqual(res.dtype.name, 'int64') + + def check_big_int(self): + # Big ints should be promoted to longs. + # This test may only fail under 64-bit platforms. + res = evaluate('2**40') + assert_array_equal(res, 2**40) + self.assertEqual(res.dtype.name, 'int64') + + def check_long_constant_promotion(self): + int32array = arange(100, dtype='int32') + res = int32array * 2 + res32 = evaluate('int32array * 2') + res64 = evaluate('int32array * 2L') + assert_array_equal(res, res32) + assert_array_equal(res, res64) + self.assertEqual(res32.dtype.name, 'int32') + self.assertEqual(res64.dtype.name, 'int64') + + def check_int64_array_promotion(self): + int32array = arange(100, dtype='int32') + int64array = arange(100, dtype='int64') + respy = int32array * int64array + resnx = evaluate('int32array * int64array') + assert_array_equal(respy, resnx) + self.assertEqual(resnx.dtype.name, 'int64') + +class test_strings(NumpyTestCase): + BLOCK_SIZE1 = 128 + BLOCK_SIZE2 = 8 + str_list1 = ['foo', 'bar', '', ' '] + str_list2 = ['foo', '', 'x', ' '] + str_nloops = len(str_list1) * (BLOCK_SIZE1 + BLOCK_SIZE2 + 1) + str_array1 = array(str_list1 * str_nloops) + str_array2 = array(str_list2 * str_nloops) + str_constant = 'doodoo' + + def check_null_chars(self): + str_list = [ + '\0\0\0', '\0\0foo\0', '\0\0foo\0b', '\0\0foo\0b\0', + 'foo\0', 'foo\0b', 'foo\0b\0', 'foo\0bar\0baz\0\0' ] + for s in str_list: + r = evaluate('s') + self.assertEqual(s, r.tostring()) # check *all* stored data + + def check_compare_copy(self): + sarr = self.str_array1 + expr = 'sarr' + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_compare_array(self): + sarr1 = self.str_array1 + sarr2 = self.str_array2 + expr = 'sarr1 >= sarr2' + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_compare_variable(self): + sarr = self.str_array1 + svar = self.str_constant + expr = 'sarr >= svar' + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_compare_constant(self): + sarr = self.str_array1 + expr = 'sarr >= %r' % self.str_constant + res1 = eval(expr) + res2 = evaluate(expr) + assert_array_equal(res1, res2) + + def check_add_string_array(self): + sarr1 = self.str_array1 + sarr2 = self.str_array2 + expr = 'sarr1 + sarr2' + self.assert_missing_op('add_sss', expr, locals()) + + def check_add_numeric_array(self): + sarr = self.str_array1 + narr = arange(len(sarr), dtype='int32') + expr = 'sarr >= narr' + self.assert_missing_op('ge_bsi', expr, locals()) + + def assert_missing_op(self, op, expr, local_dict): + msg = "expected NotImplementedError regarding '%s'" % op + try: + evaluate(expr, local_dict) + except NotImplementedError, nie: + if "'%s'" % op not in nie.args[0]: + self.fail(msg) + else: + self.fail(msg) + + def check_compare_prefix(self): + # Check comparing two strings where one is a prefix of the + # other. + for s1, s2 in [ ('foo', 'foobar'), ('foo', 'foo\0bar'), + ('foo\0a', 'foo\0bar') ]: + self.assert_(evaluate('s1 < s2')) + self.assert_(evaluate('s1 <= s2')) + self.assert_(evaluate('~(s1 == s2)')) + self.assert_(evaluate('~(s1 >= s2)')) + self.assert_(evaluate('~(s1 > s2)')) + + # Check for NumPy array-style semantics in string equality. + s1, s2 = 'foo', 'foo\0\0' + self.assert_(evaluate('s1 == s2')) + +# Case for testing selections in fields which are aligned but whose +# data length is not an exact multiple of the length of the record. +# The following test exposes the problem only in 32-bit machines, +# because in 64-bit machines 'c2' is unaligned. However, this should +# check most platforms where, while not unaligned, 'len(datatype) > +# boundary_alignment' is fullfilled. +class test_irregular_stride(NumpyTestCase): + def check_select(self): + f0 = arange(10, dtype=int32) + f1 = arange(10, dtype=float64) + + irregular = rec.fromarrays([f0, f1]) + + f0 = irregular['f0'] + f1 = irregular['f1'] + + i0 = evaluate('f0 < 5') + i1 = evaluate('f1 < 5') + + assert_array_equal(f0[i0], arange(5, dtype=int32)) + assert_array_equal(f1[i1], arange(5, dtype=float64)) + + if __name__ == '__main__': NumpyTest().run() Deleted: branches/scipy.scons/scipy/sandbox/numexpr/timing.py =================================================================== --- branches/scipy.scons/scipy/sandbox/numexpr/timing.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/numexpr/timing.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -1,136 +0,0 @@ -import timeit, numpy - -array_size = 1e6 -iterations = 10 - -def compare_times(setup, expr): - print "Expression:", expr - namespace = {} - exec setup in namespace - - numpy_timer = timeit.Timer(expr, setup) - numpy_time = numpy_timer.timeit(number=iterations) - print 'numpy:', numpy_time / iterations - - try: - weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) - weave_time = weave_timer.timeit(number=iterations) - print "Weave:", weave_time/iterations - - print "Speed-up of weave over numpy:", numpy_time/weave_time - except: - print "Skipping weave timing" - - numexpr_timer = timeit.Timer('evaluate("%s", optimization="aggressive")' % expr, setup) - numexpr_time = numexpr_timer.timeit(number=iterations) - print "numexpr:", numexpr_time/iterations - - print "Speed-up of numexpr over numpy:", numpy_time/numexpr_time - return numpy_time/numexpr_time - -setup1 = """\ -from numpy import arange -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -result = arange(%f) -b = arange(%f) -c = arange(%f) -d = arange(%f) -e = arange(%f) -""" % ((array_size,)*5) -expr1 = 'b*c+d*e' - -setup2 = """\ -from numpy import arange -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(%f) -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr2 = '2*a+3*b' - - -setup3 = """\ -from numpy import arange, sin, cos, sinh -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f)[::2] -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr3 = '2*a + (cos(3)+5)*sinh(cos(b))' - - -setup4 = """\ -from numpy import arange, sin, cos, sinh, arctan2 -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f)[::2] -b = arange(%f) -result = arange(%f) -""" % ((array_size,)*3) -expr4 = '2*a + arctan2(a, b)' - - -setup5 = """\ -from numpy import arange, sin, cos, sinh, arctan2, sqrt, where -try: from scipy.weave import blitz -except: pass -from numexpr import evaluate -a = arange(2*%f, dtype=float)[::2] -b = arange(%f, dtype=float) -result = arange(%f, dtype=float) -""" % ((array_size,)*3) -expr5 = 'where(0.1*a > arctan2(a, b), 2*a, arctan2(a,b))' - -expr6 = 'where(a, 2, b)' - -expr7 = 'where(a-10, a, 2)' - -expr8 = 'where(a%2, b+5, 2)' - -expr9 = 'where(a%2, 2, b+5)' - -expr10 = 'a**2 + (b+1)**-2.5' - -expr11 = '(a+1)**50' - -expr12 = 'sqrt(a**2 + b**2)' - -def compare(check_only=False): - total = 0 - total += compare_times(setup1, expr1) - print - total += compare_times(setup2, expr2) - print - total += compare_times(setup3, expr3) - print - total += compare_times(setup4, expr4) - print - total += compare_times(setup5, expr6) - print - total += compare_times(setup5, expr7) - print - total += compare_times(setup5, expr8) - print - total += compare_times(setup5, expr9) - print - total += compare_times(setup5, expr10) - print - total += compare_times(setup5, expr11) - print - total += compare_times(setup5, expr12) - print - print "Average =", total / 11.0 - return total - -if __name__ == '__main__': - averages = [] - for i in range(10): - averages.append(compare()) - print "Averages:", ', '.join("%.2f" % x for x in averages) Modified: branches/scipy.scons/scipy/sandbox/timeseries/dates.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/dates.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/dates.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -36,17 +36,21 @@ cseries.set_callback_DateFromString(DateFromString) cseries.set_callback_DateTimeFromString(DateTimeFromString) -from cseries import Date, thisday, check_freq, check_freq_str, get_freq_group,\ +from cseries import Date, now, check_freq, check_freq_str, get_freq_group,\ DateCalc_Error, DateCalc_RangeError -today = thisday +# aliases for `now` function. These are deprecated +today = now +thisday = now + __all__ = [ 'Date', 'DateArray','isDate','isDateArray', 'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', 'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', -'day_of_week','day_of_year','day','month','quarter','year','hour','minute', -'second','thisday','today','prevbusday','period_break', 'check_freq', -'check_freq_str','get_freq_group', 'DateCalc_Error', 'DateCalc_RangeError' +'day_of_week','weekday','day_of_year','day','month','quarter','year','hour', +'minute','second','now','thisday','today','prevbusday','period_break', +'check_freq','check_freq_str','get_freq_group', 'DateCalc_Error', +'DateCalc_RangeError' ] @@ -93,22 +97,23 @@ def prevbusday(day_end_hour=18, day_end_min=0): """Returns the previous business day (Monday-Friday) at business frequency. -:Parameters: - - day_end_hour : (int, *[18]* ) - - day_end_min : (int, *[0]*) +*Parameters*: + day_end_hour : {18, int} (optional) + day_end_min : {0, int} (optional) -:Return values: +*Return values*: If it is currently Saturday or Sunday, then the preceding Friday will be returned. If it is later than the specified day_end_hour and day_end_min, - thisday('b') will be returned. Otherwise, thisday('b')-1 will be returned. + now('Business') will be returned. Otherwise, now('Business')-1 will be + returned. """ tempDate = dt.datetime.now() dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 if dateNum < checkNum: - return thisday(_c.FR_BUS) - 1 + return now(_c.FR_BUS) - 1 else: - return thisday(_c.FR_BUS) + return now(_c.FR_BUS) def isDate(data): @@ -283,9 +288,11 @@ "Returns the day of month." return self.__getdateinfo__('D') @property - def day_of_week(self): + def weekday(self): "Returns the day of week." return self.__getdateinfo__('W') + # deprecated alias for weekday + day_of_week = weekday @property def day_of_year(self): "Returns the day of year." @@ -329,7 +336,7 @@ return self.__getdateinfo__('I') days = day - weekdays = day_of_week + weekdays = weekday yeardays = day_of_year months = month quarters = quarter @@ -355,7 +362,6 @@ "Converts the dates from values to ordinals." # Note: we better try to cache the result if self._cachedinfo['toord'] is None: -# diter = (Date(self.freq, value=d).toordinal() for d in self) if self.freq == _c.FR_UND: diter = (d.value for d in self) else: @@ -364,6 +370,14 @@ self._cachedinfo['toord'] = toord return self._cachedinfo['toord'] # + def tolist(self): + """Returns a hierarchical python list of standard datetime objects.""" + _result = numpy.empty(self.shape, dtype=numpy.object_) + _result.flat = [d.datetime for d in self.ravel()] +# for idx, val in numpy.ndenumerate(self): +# operator.setitem(_result, idx, Date(freq=self.freq, value=val).datetime) + return _result.tolist() + # def tostring(self): "Converts the dates to strings." # Note: we better cache the result @@ -571,10 +585,10 @@ dates = [Date(freq, datetime=m) for m in dlist] #...as datetime objects elif hasattr(template, 'toordinal'): - ords = numpy.fromiter((d.toordinal() for d in dlist), float_) if freq == _c.FR_UND: + ords = numpy.fromiter((d.toordinal() for d in dlist), float_) freq = guess_freq(ords) - dates = [Date(freq, datetime=dt.datetime.fromordinal(a)) for a in ords] + dates = [Date(freq, datetime=d) for d in dlist] # result = DateArray(dates, freq) result._unsorted = idx @@ -674,7 +688,9 @@ except SystemError: return getattr(numpy,self._methodname).__call__(caller, *args, **params) #............................ -day_of_week = _frommethod('day_of_week') +weekday = _frommethod('day_of_week') +# deprecated alias for weekday +day_of_week = weekday day_of_year = _frommethod('day_of_year') year = _frommethod('year') quarter = _frommethod('quarter') @@ -705,10 +721,20 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal - if 1: + if 0: dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] mdates = date_array_fromlist(dlist, 'M') - - if 2: + # + if 0: dlist = ['2007-01','2007-03','2007-04','2007-02'] mdates = date_array_fromlist(dlist, 'M') + # + if 1: + import datetime + dlist = [dt.datetime(2001,1,1,0), + dt.datetime(2001,1,2,1), + dt.datetime(2001,1,3,2)] + _dates = date_array(dlist,freq='H') + # + assert_equal(_dates.hour, [0,1,2]) + assert_equal(_dates.day, [1,2,3]) Modified: branches/scipy.scons/scipy/sandbox/timeseries/include/c_dates.h =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/include/c_dates.h 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/include/c_dates.h 2007-11-24 10:53:58 UTC (rev 3583) @@ -110,7 +110,7 @@ PyObject *DateArray_getDateInfo(PyObject *, PyObject *); -PyObject *c_dates_thisday(PyObject *, PyObject *); +PyObject *c_dates_now(PyObject *, PyObject *); PyObject *c_dates_check_freq(PyObject *, PyObject *); PyObject *c_dates_check_freq_str(PyObject *, PyObject *); PyObject *c_dates_get_freq_group(PyObject *, PyObject *); Modified: branches/scipy.scons/scipy/sandbox/timeseries/lib/moving_funcs.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/lib/moving_funcs.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/lib/moving_funcs.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -366,10 +366,10 @@ ############################################################################### if __name__ == '__main__': - from timeseries import time_series, today + from timeseries import time_series, now from maskedarray.testutils import assert_equal, assert_almost_equal # - series = time_series(N.arange(10),start_date=today('D')) + series = time_series(N.arange(10),start_date=now('D')) # filtered = mov_sum(series,3) assert_equal(filtered, [0,1,3,6,9,12,15,18,21,24]) Modified: branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -30,6 +30,7 @@ #from matplotlib.transforms import nonsingular import numpy +from numpy import int_, bool_ import maskedarray as MA import timeseries @@ -47,16 +48,18 @@ The specific Subplot object class to add is given through the keywords `SubplotClass` or `class`. -:Parameters: - `figure_instance` : Figure object +*:Parameters*: + figure_instance : {Figure object} Figure to which the generic subplot should be attached. - `args` : Misc + args : {var} Miscellaneous arguments to the subplot. - `kwargs` : Dictionary + kwargs : {Dictionary} Keywords. Same keywords as `Subplot`, with the addition of - - `SubplotClass` : Type of subplot - - `subclass` : Shortcut to `SubplotClass`. - - any keyword required by the `SubplotClass` subclass. + * SubplotClass* : {string} + Type of subplot + *subclass* : {string} + Shortcut to SubplotClass. + * any keyword required by the `SubplotClass` subclass. """ key = figure_instance._make_key(*args, **kwargs) @@ -171,7 +174,7 @@ else: return True -def _daily_finder(vmin, vmax, freq, aslocator): +def _daily_finder(vmin, vmax, freq, asformatter): if freq == _c.FR_BUS: periodsperyear = 261 @@ -187,13 +190,13 @@ (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 - dates = date_array(start_date=Date(freq,vmin), - end_date=Date(freq, vmax)) - default = numpy.arange(vmin, vmax+1) + dates_ = date_array(start_date=Date(freq,vmin), + end_date=Date(freq, vmax)) # Initialize the output - if not aslocator: - format = numpy.empty(default.shape, dtype="|S10") - format.flat = '' + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S10')]) + info['val'] = numpy.arange(vmin, vmax+1) + info['fmt'] = '' def first_label(label_flags): if label_flags[0] == 0: return label_flags[1] @@ -201,115 +204,103 @@ # Case 1. Less than a month if span <= periodspermonth: - month_start = period_break(dates,'month') - if aslocator: - major = default[month_start] - minor = default - else: - year_start = period_break(dates,'year') - format[:] = '%d' - format[month_start] = '%d\n%b' - format[year_start] = '%d\n%b\n%Y' + month_start = period_break(dates_,'month') + info['maj'][month_start] = True + info['min'] = True + if asformatter: + year_start = period_break(dates_,'year') + info['fmt'][:] = '%d' + info['fmt'][month_start] = '%d\n%b' + info['fmt'][year_start] = '%d\n%b\n%Y' if not has_level_label(year_start): if not has_level_label(month_start): - if dates.size > 1: + if dates_.size > 1: idx = 1 else: idx = 0 - format[idx] = '%d\n%b\n%Y' + info['fmt'][idx] = '%d\n%b\n%Y' else: - format[first_label(month_start)] = '%d\n%b\n%Y' + info['fmt'][first_label(month_start)] = '%d\n%b\n%Y' # Case 2. Less than three months elif span <= periodsperyear//4: month_start = period_break(dates,'month') - if aslocator: - major = default[month_start] - minor = default - else: - week_start = period_break(dates,'week') - year_start = period_break(dates,'year') + info['maj'][month_start] = True + info['min'] = True + if asformatter: + week_start = period_break(dates_,'week') + year_start = period_break(dates_,'year') - format[week_start] = '%d' - format[month_start] = '\n\n%b' - format[year_start] = '\n\n%b\n%Y' + info['fmt'][week_start] = '%d' + info['fmt'][month_start] = '\n\n%b' + info['fmt'][year_start] = '\n\n%b\n%Y' if not has_level_label(year_start): if not has_level_label(month_start): - format[first_label(week_start)] = '\n\n%b\n%Y' + info['fmt'][first_label(week_start)] = '\n\n%b\n%Y' else: - format[first_label(month_start)] = '\n\n%b\n%Y' + info['fmt'][first_label(month_start)] = '\n\n%b\n%Y' # Case 3. Less than 14 months ............... elif span <= 1.15 * periodsperyear: + d_minus_1 = dates_-1 - if aslocator: - d_minus_1 = dates-1 + month_diff = numpy.abs(dates_.month - d_minus_1.month) + week_diff = numpy.abs(dates_.week - d_minus_1.week) + minor_idx = (month_diff + week_diff).nonzero()[0] - month_diff = numpy.abs(dates.month - d_minus_1.month) - week_diff = numpy.abs(dates.week - d_minus_1.week) - minor_idx = (month_diff + week_diff).nonzero()[0] + info['maj'][month_diff != 0] = True + info['min'][minor_idx] = True + if asformatter: + year_start = period_break(dates_,'year') + month_start = period_break(dates_,'month') - major = default[month_diff != 0] - minor = default[minor_idx] - else: - year_start = period_break(dates,'year') - month_start = period_break(dates,'month') - - format[month_start] = '%b' - format[year_start] = '%b\n%Y' + info['fmt'][month_start] = '%b' + info['fmt'][year_start] = '%b\n%Y' if not has_level_label(year_start): - format[first_label(month_start)] = '%b\n%Y' + info['fmt'][first_label(month_start)] = '%b\n%Y' # Case 4. Less than 2.5 years ............... elif span <= 2.5 * periodsperyear: - year_start = period_break(dates,'year') - if aslocator: - month_start = period_break(dates, 'quarter') - major = default[year_start] - minor = default[month_start] - else: - quarter_start = period_break(dates, 'quarter') - format[quarter_start] = '%b' - format[year_start] = '%b\n%Y' + year_start = period_break(dates_,'year') + month_start = period_break(dates_, 'quarter') + info['maj'][year_start] = True + info['min'][month_start] = True + if asformatter: + quarter_start = period_break(dates_, 'quarter') + info['fmt'][quarter_start] = '%b' + info['fmt'][year_start] = '%b\n%Y' # Case 4. Less than 4 years ................. elif span <= 4 * periodsperyear: - year_start = period_break(dates,'year') - month_start = period_break(dates, 'month') - if aslocator: - major = default[year_start] - minor = default[month_start] - else: - month_break = dates[month_start].month + year_start = period_break(dates_,'year') + month_start = period_break(dates_, 'month') + info['maj'][year_start] = True + info['min'][month_start] = True + if asformatter: + month_break = dates_[month_start].month jan_or_jul = month_start[(month_break == 1) | (month_break == 7)] - format[jan_or_jul] = '%b' - format[year_start] = '%b\n%Y' + info['fmt'][jan_or_jul] = '%b' + info['fmt'][year_start] = '%b\n%Y' # Case 5. Less than 11 years ................ elif span <= 11 * periodsperyear: - year_start = period_break(dates,'year') - if aslocator: - quarter_start = period_break(dates, 'quarter') - major = default[year_start] - minor = default[quarter_start] - else: - format[year_start] = '%Y' + year_start = period_break(dates_,'year') + quarter_start = period_break(dates_, 'quarter') + info['maj'][year_start] = True + info['min'][quarter_start] = True + if asformatter: + info['fmt'][year_start] = '%Y' # Case 6. More than 12 years ................ else: year_start = period_break(dates,'year') - year_break = dates[year_start].years + year_break = dates_[year_start].years nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) major_idx = year_start[(year_break % maj_anndef == 0)] - if aslocator: - major = default[major_idx] - minor_idx = year_start[(year_break % min_anndef == 0)] - minor = default[minor_idx] - else: - format[major_idx] = '%Y' + info['maj'][major_idx] = True + minor_idx = year_start[(year_break % min_anndef == 0)] + info['min'][minor_idx] = True + if asformatter: + info['fmt'][major_idx] = '%Y' #............................................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(default[formatted],format[formatted])]) + return info #............................................................................... -def _monthly_finder(vmin, vmax, freq, aslocator): +def _monthly_finder(vmin, vmax, freq, asformatter): if freq != _c.FR_MTH: raise ValueError("Unexpected frequency") periodsperyear = 12 @@ -317,143 +308,128 @@ (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 #............................................ - dates = numpy.arange(vmin, vmax+1) - format = numpy.empty(span, dtype="|S8") - format.flat = '' - year_start = (dates % 12 == 1).nonzero()[0] + # Initialize the output + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S8')]) + info['val'] = numpy.arange(vmin, vmax+1) + dates_ = info['val'] + info['fmt'] = '' + year_start = (dates_ % 12 == 1).nonzero()[0] #............................................ if span <= 1.15 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: + info['maj'][year_start] = True + info['min'] = True + if asformatter: + info['fmt'][:] = '%b' + info['fmt'][year_start] = '%b\n%Y' - format[:] = '%b' - format[year_start] = '%b\n%Y' - if not has_level_label(year_start): - if dates.size > 1: + if dates_.size > 1: idx = 1 else: idx = 0 - format[idx] = '%b\n%Y' + info['fmt'][idx] = '%b\n%Y' #........................ elif span <= 2.5 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - quarter_start = (dates % 3 == 1).nonzero() - format[quarter_start] = '%b' - format[year_start] = '%b\n%Y' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + quarter_start = (dates_ % 3 == 1).nonzero() + info['fmt'][quarter_start] = '%b' + info['fmt'][year_start] = '%b\n%Y' #....................... elif span <= 4 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - jan_or_jul = (dates % 12 == 1) | (dates % 12 == 7) - format[jan_or_jul] = '%b' - format[year_start] = '%b\n%Y' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + jan_or_jul = (dates_ % 12 == 1) | (dates_ % 12 == 7) + info['fmt'][jan_or_jul] = '%b' + info['fmt'][year_start] = '%b\n%Y' #........................ elif span <= 11 * periodsperyear: - if aslocator: - quarter_start = (dates % 3 == 1).nonzero() - major = dates[year_start] - minor = dates[quarter_start] - else: - format[year_start] = '%Y' + quarter_start = (dates_ % 3 == 1).nonzero() + info['maj'][year_start] = True + info['min'][quarter_start] = True + if asformatter: + info['fmt'][year_start] = '%Y' #......................... else: nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) - years = dates[year_start]//12 + 1 + years = dates_[year_start]//12 + 1 major_idx = year_start[(years % maj_anndef == 0)] - if aslocator: - major = dates[major_idx] - minor = dates[year_start[(years % min_anndef == 0)]] - else: - format[major_idx] = '%Y' + info['maj'][major_idx] = True + info['min'][year_start[(years % min_anndef == 0)]] = True + if asformatter: + info['fmt'][major_idx] = '%Y' #........................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) + return info #............................................................................... -def _quarterly_finder(vmin, vmax, freq, aslocator): +def _quarterly_finder(vmin, vmax, freq, asformatter): if get_freq_group(freq) != _c.FR_QTR: raise ValueError("Unexpected frequency") periodsperyear = 4 (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 #............................................ - dates = numpy.arange(vmin, vmax+1) - format = numpy.empty(span, dtype="|S8") - format.flat = '' - year_start = (dates % 4 == 1).nonzero()[0] + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S8')]) + info['val'] = numpy.arange(vmin, vmax+1) + info['fmt'] = '' + dates_ = info['val'] + year_start = (dates_ % 4 == 1).nonzero()[0] #............................................ if span <= 3.5 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - format[:] = 'Q%q' - format[year_start] = 'Q%q\n%F' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + info['fmt'][:] = 'Q%q' + info['fmt'][year_start] = 'Q%q\n%F' if not has_level_label(year_start): - if dates.size > 1: + if dates_.size > 1: idx = 1 else: idx = 0 - format[idx] = 'Q%q\n%F' + info['fmt'][idx] = 'Q%q\n%F' #............................................ elif span <= 11 * periodsperyear: - if aslocator: - major = dates[year_start] - minor = dates - else: - format[year_start] = '%F' + info['maj'][year_start] = True + info['min'] = True + if asformatter: + info['fmt'][year_start] = '%F' #............................................ else: - years = dates[year_start]//4 + 1 + years = dates_[year_start]//4 + 1 nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) major_idx = year_start[(years % maj_anndef == 0)] - if aslocator: - major = dates[major_idx] - minor = dates[year_start[(years % min_anndef == 0)]] - else: - format[major_idx] = '%F' + info['maj'][major_idx] = True + info['min'][year_start[(years % min_anndef == 0)]] = True + if asformatter: + info['fmt'][major_idx] = '%F' #............................................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) + return info #............................................................................... -def _annual_finder(vmin, vmax, freq, aslocator): +def _annual_finder(vmin, vmax, freq, asformatter): if get_freq_group(freq) != _c.FR_ANN: raise ValueError("Unexpected frequency") (vmin, vmax) = (int(vmin), int(vmax+1)) span = vmax - vmin + 1 #............................................ - dates = numpy.arange(vmin, vmax+1) - format = numpy.empty(span, dtype="|S8") - format.flat = '' + info = numpy.zeros(span, + dtype=[('val',int_),('maj',bool_),('min',bool_),('fmt','|S8')]) + info['val'] = numpy.arange(vmin, vmax+1) + info['fmt'] = '' + dates_ = info['val'] #............................................ (min_anndef, maj_anndef) = _get_default_annual_spacing(span) - major_idx = dates % maj_anndef == 0 - if aslocator: - major = dates[major_idx] - minor = dates[(dates % min_anndef == 0)] - else: - format[major_idx] = '%Y' + major_idx = dates_ % maj_anndef == 0 + info['maj'][major_idx] = True + info['min'][(dates_ % min_anndef == 0)] = True + if asformatter: + info['fmt'][major_idx] = '%Y' #............................................ - if aslocator: - return minor, major - else: - formatted = (format != '') - return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) + return info #............................................................................... class TimeSeries_DateLocator(Locator): @@ -490,10 +466,10 @@ def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." - (minor, major) = self.finder(vmin, vmax, self.freq, True) + locator = self.finder(vmin, vmax, self.freq, False) if self.isminor: - return minor - return major + return numpy.compress(locator['min'], locator['val']) + return numpy.compress(locator['maj'], locator['val']) def __call__(self): 'Return the locations of the ticks.' @@ -560,7 +536,13 @@ def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." - self.formatdict = self.finder(vmin, vmax, self.freq, False) + info = self.finder(vmin, vmax, self.freq, True) + if self.isminor: + format = numpy.compress(info['min'] & numpy.logical_not(info['maj']), + info) + else: + format = numpy.compress(info['maj'], info) + self.formatdict = dict([(x,f) for (x,_,_,f) in format]) return self.formatdict def set_locs(self, locs): @@ -571,15 +553,8 @@ self._set_default_format(locs[0], locs[-1]) # def __call__(self, x, pos=0): - if self.isminor: - fmt = self.formatdict.pop(x, '') - if fmt is not '': - retval = Date(self.freq, value=int(x)).strfmt(fmt) - else: - retval = '' - else: - retval = '' - return retval + fmt = self.formatdict.pop(x, '') + return Date(self.freq, value=int(x)).strftime(fmt) @@ -593,12 +568,10 @@ """ Accepts the same keywords as a standard subplot, plus a specific `series` keyword. -:Parameters: - `fig` : Figure +*Parameters*: + fig : {Figure} Base figure. - -:Keywords: - `series` : TimeSeries + series : {TimeSeries}, optional Data to plot """ @@ -719,26 +692,18 @@ #...................................................... def tsplot(self,*parms,**kwargs): """Plots the data parsed in argument. -This command accepts the same keywords as `matplotlib.plot`.""" +This command accepts the same keywords as matplotlib.plot.""" # parms = tuple(list(parms) + kwargs.pop('series',None)) # print "Parameters: %s - %i" % (parms, len(parms)) # print "OPtions: %s - %i" % (kwargs, len(kwargs)) parms = self._check_plot_params(*parms) self.legendlabels.append(kwargs.get('label',None)) - Subplot.plot(self, *parms,**kwargs) + plotted = Subplot.plot(self, *parms,**kwargs) self.format_dateaxis() + return plotted #...................................................... - def format_dateaxis(self,maj_spacing=None, min_spacing=None, - strformat="%Y", rotate=True): + def format_dateaxis(self): """Pretty-formats the date axis (x-axis). - -:Parameters: - `major` : Integer *[5]* - Major tick locator, in years (major tick every `major` years). - `minor` : Integer *[12]* - Minor tick locator, in months (minor ticks every `minor` months). - `strformat` : String *['%Y']* - String format for major ticks ("%Y"). """ # Get the locator class ................. majlocator = TimeSeries_DateLocator(self.freq, dynamic_mode=True, @@ -754,6 +719,7 @@ minor_locator=True) self.xaxis.set_major_formatter(majformatter) self.xaxis.set_minor_formatter(minformatter) + pylab.draw_if_interactive() #........................................ # if rcParams['backend'] == 'PS': # rotate = False @@ -766,10 +732,10 @@ """Sets the date limits of the plot to start_date and end_date. The dates can be given as timeseries.Date objects, strings or integers. -:Inputs: - start_date : var *[None]* +*Parameters*: + start_date : {var} Starting date of the plot. If None, the current left limit is used. - end_date : var *[None]* + end_date : {var} Ending date of the plot. If None, the current right limit is used. """ freq = self.freq @@ -806,23 +772,23 @@ **kwargs): """Adds a second y-axis to a plot. -:Parameters: - `fsp` : Subplot *[None]* - Subplot to which the secondary y-axis is added. If *None*, the current - subplot is selected - `position` : String in `('left','right')` *['right']* - Position of the new axis. - `yscale` : String, in `('log', 'linear')` *[None]* - Scale of the new axis. If None, uses the same scale as the first y -axis - `basey` : Integer *[10]* +*Parameters*: + fsp : {Subplot} + Subplot to which the secondary y-axis is added. + If None, the current subplot is selected + position : {string} + Position of the new axis, as either 'left' or 'right'. + yscale : {string} + Scale of the new axis, as either 'log', 'linear' or None. + If None, uses the same scale as the first y axis + basey : {integer} Base of the logarithm for the new axis (if needed). - `subsy` : sequence *[None]* + subsy : {sequence} Sequence of the location of the minor ticks; None defaults to autosubs, which depend on the number of decades in -the plot. + the plot. Eg for base 10, subsy=(1,2,5) will put minor ticks on 1,2,5,11,12,15, -21, .... + 21, .... To turn off minor ticking, set subsy=[] """ @@ -888,10 +854,10 @@ def tsfigure(series=None, **figargs): """Creates a new `TimeSeriesFigure` object. -:Parameters: - `series` : TimeSeries object +*Parameters*: + series : {TimeSeries object} Input data. - `figargs` : Dictionary + figargs : {dictionary} Figure options [`figsize`, `dpi`, `facecolor`, `edgecolor`, `frameon`]. """ figargs.update(FigureClass=TSFigure) Modified: branches/scipy.scons/scipy/sandbox/timeseries/report.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/report.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/report.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -328,7 +328,7 @@ if datefmt is None: def datefmt_func(date): return str(date) else: - def datefmt_func(date): return date.strfmt(datefmt) + def datefmt_func(date): return date.strftime(datefmt) if dates is None: tseries = ts.align_series(*tseries) Modified: branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c 2007-11-24 10:53:58 UTC (rev 3583) @@ -1649,9 +1649,12 @@ } static char DateObject_strfmt_doc[] = +"Deprecated alias for strftime method"; + +static char DateObject_strftime_doc[] = "Returns string representation of Date object according to format specified.\n\n" -":Parameters:\n" -" - fmt : string\n" +"*Parameters*:\n" +" fmt : {str}\n" " Formatting string. Uses the same directives as in the time.strftime\n" " function in the standard Python time module. In addition, a few other\n" " directives are supported:\n" @@ -1665,7 +1668,7 @@ " the current quarter. This is the same as %Y unless the\n" " Date is one of the 'qtr-s' frequencies\n"; static PyObject * -DateObject_strfmt(DateObject *self, PyObject *args) +DateObject_strftime(DateObject *self, PyObject *args) { char *orig_fmt_str, *fmt_str; @@ -1689,7 +1692,7 @@ long (*toDaily)(long, char, asfreq_info*) = NULL; asfreq_info af_info; - if (!PyArg_ParseTuple(args, "s:strfmt(fmt)", &orig_fmt_str)) return NULL; + if (!PyArg_ParseTuple(args, "s:strftime(fmt)", &orig_fmt_str)) return NULL; toDaily = get_asfreq_func(self->freq, FR_DAY, 0); get_asfreq_info(self->freq, FR_DAY, &af_info); @@ -1821,7 +1824,7 @@ if (string_arg == NULL) { return NULL; } - retval = DateObject_strfmt(self, string_arg); + retval = DateObject_strftime(self, string_arg); Py_DECREF(string_arg); return retval; @@ -2098,7 +2101,7 @@ } static PyObject * -DateObject_day_of_week(DateObject *self, void *closure) { +DateObject_weekday(DateObject *self, void *closure) { struct date_info dinfo; if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; return PyInt_FromLong(dinfo.day_of_week); @@ -2173,8 +2176,11 @@ "Returns the week.", NULL}, {"day", (getter)DateObject_day, (setter)DateObject_ReadOnlyErr, "Returns the day of month.", NULL}, - {"day_of_week", (getter)DateObject_day_of_week, (setter)DateObject_ReadOnlyErr, + {"weekday", (getter)DateObject_weekday, (setter)DateObject_ReadOnlyErr, "Returns the day of week.", NULL}, + // deprecated alias for weekday property + {"day_of_week", (getter)DateObject_weekday, (setter)DateObject_ReadOnlyErr, + "Returns the day of week.", NULL}, {"day_of_year", (getter)DateObject_day_of_year, (setter)DateObject_ReadOnlyErr, "Returns the day of year.", NULL}, {"second", (getter)DateObject_second, (setter)DateObject_ReadOnlyErr, @@ -2223,7 +2229,10 @@ static PyMethodDef DateObject_methods[] = { {"toordinal", (PyCFunction)DateObject_toordinal, METH_NOARGS, DateObject_toordinal_doc}, - {"strfmt", (PyCFunction)DateObject_strfmt, METH_VARARGS, + {"strftime", (PyCFunction)DateObject_strftime, METH_VARARGS, + DateObject_strftime_doc}, + // deprecated alias for strftime + {"strfmt", (PyCFunction)DateObject_strftime, METH_VARARGS, DateObject_strfmt_doc}, {"asfreq", (PyCFunction)DateObject_asfreq, METH_VARARGS | METH_KEYWORDS, DateObject_asfreq_doc}, @@ -2331,7 +2340,7 @@ } PyObject * -c_dates_thisday(PyObject *self, PyObject *args) { +c_dates_now(PyObject *self, PyObject *args) { PyObject *freq, *init_args, *init_kwargs; time_t rawtime; @@ -2340,7 +2349,7 @@ DateObject *secondly_date; - if (!PyArg_ParseTuple(args, "O:thisday(freq)", &freq)) return NULL; + if (!PyArg_ParseTuple(args, "O:now(freq)", &freq)) return NULL; if ((freq_val = check_freq(freq)) == INT_ERR_CODE) return NULL; @@ -2635,7 +2644,7 @@ skip_periods = __skip_periods_day(freq); break; case 'W': //day of week - getDateInfo = &DateObject_day_of_week; + getDateInfo = &DateObject_weekday; skip_periods = __skip_periods_day(freq); break; case 'I': //week of year Modified: branches/scipy.scons/scipy/sandbox/timeseries/src/cseries.c =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/src/cseries.c 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/src/cseries.c 2007-11-24 10:53:58 UTC (rev 3583) @@ -26,11 +26,11 @@ METH_VARARGS, ""}, - {"thisday", (PyCFunction)c_dates_thisday, + {"now", (PyCFunction)c_dates_now, METH_VARARGS, - "Returns today's date, at the given frequency\n\n" - ":Parameters:\n" - " - freq : string/int\n" + "Returns the current date/time, at the given frequency\n\n" + "*Parameters*:\n" + " freq : {freq_spec}\n" " Frequency to convert the Date to. Accepts any valid frequency\n" " specification (string or integer)\n"}, Modified: branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -29,7 +29,7 @@ from timeseries import const as C from timeseries.parser import DateFromString, DateTimeFromString from timeseries import Date, DateArray,\ - thisday, today, date_array, date_array_fromlist + now, date_array, date_array_fromlist from timeseries.cseries import freq_dict @@ -122,8 +122,8 @@ freqs = [x[0] for x in freq_dict.values() if x[0] != 'U'] for f in freqs: - today = thisday(f) - assert_equal(Date(freq=f, value=today.value), today) + _now = now(f) + assert_equal(Date(freq=f, value=_now.value), _now) print "finished test_consistent_value" def test_shortcuts(self): @@ -134,14 +134,14 @@ assert_equal(Date('D','2007-01'), Date('D', value=732677)) assert_equal(Date('D',732677), Date('D', value=732677)) # DateArray shortcuts - n = today('M') + n = now('M') d = date_array(start_date=n, length=3) assert_equal(date_array(n,length=3), d) assert_equal(date_array(n, n+2), d) print "finished test_shortcuts" class TestDateProperties(NumpyTestCase): - "Test properties such as year, month, day_of_week, etc...." + "Test properties such as year, month, weekday, etc...." def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) @@ -201,21 +201,21 @@ assert_equal(b_date.quarter, 1) assert_equal(b_date.month, 1) assert_equal(b_date.day, 1) - assert_equal(b_date.day_of_week, 0) + assert_equal(b_date.weekday, 0) assert_equal(b_date.day_of_year, 1) assert_equal(d_date.year, 2007) assert_equal(d_date.quarter, 1) assert_equal(d_date.month, 1) assert_equal(d_date.day, 1) - assert_equal(d_date.day_of_week, 0) + assert_equal(d_date.weekday, 0) assert_equal(d_date.day_of_year, 1) assert_equal(h_date.year, 2007) assert_equal(h_date.quarter, 1) assert_equal(h_date.month, 1) assert_equal(h_date.day, 1) - assert_equal(h_date.day_of_week, 0) + assert_equal(h_date.weekday, 0) assert_equal(h_date.day_of_year, 1) assert_equal(h_date.hour, 0) @@ -223,7 +223,7 @@ assert_equal(t_date.quarter, 1) assert_equal(t_date.month, 1) assert_equal(t_date.day, 1) - assert_equal(t_date.day_of_week, 0) + assert_equal(t_date.weekday, 0) assert_equal(t_date.day_of_year, 1) assert_equal(t_date.hour, 0) assert_equal(t_date.minute, 0) @@ -232,7 +232,7 @@ assert_equal(s_date.quarter, 1) assert_equal(s_date.month, 1) assert_equal(s_date.day, 1) - assert_equal(s_date.day_of_week, 0) + assert_equal(s_date.weekday, 0) assert_equal(s_date.day_of_year, 1) assert_equal(s_date.hour, 0) assert_equal(s_date.minute, 0) @@ -483,17 +483,17 @@ date_W_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) date_W_to_M = dWrap(Date(freq='M', year=2007, month=1)) - if Date(freq='D', year=2007, month=12, day=31).day_of_week == 6: + if Date(freq='D', year=2007, month=12, day=31).weekday == 6: date_W_to_A_end_of_year = dWrap(Date(freq='A', year=2007)) else: date_W_to_A_end_of_year = dWrap(Date(freq='A', year=2008)) - if Date(freq='D', year=2007, month=3, day=31).day_of_week == 6: + if Date(freq='D', year=2007, month=3, day=31).weekday == 6: date_W_to_Q_end_of_quarter = dWrap(Date(freq='Q', year=2007, quarter=1)) else: date_W_to_Q_end_of_quarter = dWrap(Date(freq='Q', year=2007, quarter=2)) - if Date(freq='D', year=2007, month=1, day=31).day_of_week == 6: + if Date(freq='D', year=2007, month=1, day=31).weekday == 6: date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=1)) else: date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=2)) @@ -877,7 +877,7 @@ assert_equal(empty_darray.get_steps(), None) def test_cachedinfo(self): - D = date_array(start_date=thisday('D'), length=5) + D = date_array(start_date=now('D'), length=5) Dstr = D.tostring() assert_equal(D.tostring(), Dstr) DL = D[[0,-1]] Modified: branches/scipy.scons/scipy/sandbox/timeseries/tseries.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/tseries.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sandbox/timeseries/tseries.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -35,7 +35,7 @@ import dates from dates import DateError, InsufficientDateError from dates import Date, isDate, DateArray, isDateArray, \ - date_array, date_array_fromlist, date_array_fromrange, thisday, today, \ + date_array, date_array_fromlist, date_array_fromrange, now, \ check_freq, check_freq_str import cseries @@ -56,6 +56,7 @@ 'quarter', 'second','split', 'stack', 'tofile','tshift', +'week', 'year', ] @@ -595,9 +596,11 @@ """Returns the day of month for each date in self._dates.""" return self._dates.day @property - def day_of_week(self): + def weekday(self): """Returns the day of week for each date in self._dates.""" - return self._dates.day_of_week + return self._dates.weekday + # deprecated alias for weekday + day_of_week = weekday @property def day_of_year(self): """Returns the day of year for each date in self._dates.""" @@ -632,7 +635,7 @@ return self._dates.week days = day - weekdays = day_of_week + weekdays = weekday yeardays = day_of_year months = month quarters = quarter @@ -873,8 +876,11 @@ except SystemError: return getattr(numpy,self._methodname).__call__(caller, *args, **params) #............................ -day_of_week = _frommethod('day_of_week') +weekday = _frommethod('weekday') +# deprecated alias for weekday +day_of_week = weekday day_of_year = _frommethod('day_of_year') +week = _frommethod('week') year = _frommethod('year') quarter = _frommethod('quarter') month = _frommethod('month') @@ -1544,8 +1550,8 @@ saved. Otherwise, only the first occurence of the date is conserved. Example ->>> a = time_series([1,2,3], start_date=today('D')) ->>> b = time_series([10,20,30], start_date=today('D')+1) +>>> a = time_series([1,2,3], start_date=now('D')) +>>> b = time_series([10,20,30], start_date=now('D')+1) >>> c = concatenate((a,b)) >>> c._series masked_array(data = [ 1 2 3 30], Modified: branches/scipy.scons/scipy/signal/signaltools.py =================================================================== --- branches/scipy.scons/scipy/signal/signaltools.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/signal/signaltools.py 2007-11-24 10:53:58 UTC (rev 3583) @@ -12,7 +12,7 @@ ravel, size, less_equal, sum, r_, iscomplexobj, take, \ argsort, allclose, expand_dims, unique, prod, sort, reshape, c_, \ transpose, dot, any, minimum, maximum, mean, cosh, arccosh, \ - arccos + arccos, concatenate import numpy from scipy.fftpack import fftn, ifftn, fft from scipy.misc import factorial From scipy-svn at scipy.org Sat Nov 24 06:07:09 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 05:07:09 -0600 (CST) Subject: [Scipy-svn] r3584 - branches/scipy.scons/scipy/sparse Message-ID: <20071124110709.655BD39C00C@new.scipy.org> Author: cdavid Date: 2007-11-24 05:06:35 -0600 (Sat, 24 Nov 2007) New Revision: 3584 Added: branches/scipy.scons/scipy/sparse/SConstruct branches/scipy.scons/scipy/sparse/setupscons.py Log: Sparse now builds with scons Copied: branches/scipy.scons/scipy/sparse/SConstruct (from rev 3582, branches/scipy.scons/scipy/cluster/SConstruct) =================================================================== --- branches/scipy.scons/scipy/cluster/SConstruct 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sparse/SConstruct 2007-11-24 11:06:35 UTC (rev 3584) @@ -0,0 +1,18 @@ +# Last Change: Sat Nov 24 07:00 PM 2007 J +# vim:syntax=python +from os.path import join + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) + +env.NumpyPythonExtension('_sparsetools', + source = [join('sparsetools', 'sparsetools_wrap.cxx')]) + +# Copy this python file into the distutils lib dir +env.Command(join(env['distutils_installdir'], 'sparsetools.py'), + join('sparsetools', 'sparsetools.py'), + Copy('$TARGET', '$SOURCE')) Copied: branches/scipy.scons/scipy/sparse/setupscons.py (from rev 3582, branches/scipy.scons/scipy/sparse/setup.py) =================================================================== --- branches/scipy.scons/scipy/sparse/setup.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/sparse/setupscons.py 2007-11-24 11:06:35 UTC (rev 3584) @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from os.path import join +import sys + +def configuration(parent_package='',top_path=None): + import numpy + from numpy.distutils.misc_util import Configuration + + config = Configuration('sparse',parent_package,top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + +## sparsetools_i_file = config.paths(join('sparsetools','sparsetools.i'))[0] +## def sparsetools_i(ext, build_dir): +## return sparsetools_i_file +## config.add_extension('_sparsetools', +## sources= [sparsetools_i_file], +## include_dirs=['sparsetools'], +## depends = [join('sparsetools', x) for x in +## ['sparsetools.i', 'sparsetools.h']] +## ) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 06:38:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 05:38:08 -0600 (CST) Subject: [Scipy-svn] r3585 - branches/scipy.scons/scipy/special Message-ID: <20071124113808.ED88C39C00C@new.scipy.org> Author: cdavid Date: 2007-11-24 05:37:53 -0600 (Sat, 24 Nov 2007) New Revision: 3585 Added: branches/scipy.scons/scipy/special/SConstruct branches/scipy.scons/scipy/special/setupscons.py Log: special now build with scons Copied: branches/scipy.scons/scipy/special/SConstruct (from rev 3582, branches/scipy.scons/scipy/integrate/SConstruct) =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/special/SConstruct 2007-11-24 11:37:53 UTC (rev 3585) @@ -0,0 +1,50 @@ +# Last Change: Sat Nov 24 08:00 PM 2007 J +# vim:syntax=python +from os.path import join as pjoin +import glob +import sys +from distutils.sysconfig import get_python_inc + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) + +if sys.platform=='win32': +# define_macros.append(('NOINFINITIES',None)) +# define_macros.append(('NONANS',None)) + env.AppendUnique(CPPDEFINES = '_USE_MATH_DEFINES') + +def build_lib(name, ext): + """ext should be .f or .c""" + src = glob.glob(pjoin(name, '*%s' % ext)) + env.NumpyStaticExtLibrary(name, source = src) + +# C libraries +build_lib('c_misc', '.c') +build_lib('cephes', '.c') + +# F libraries +build_lib('mach', '.f') +build_lib('toms', '.f') +build_lib('amos', '.f') +build_lib('cdf', '.f') +build_lib('specfun', '.f') + +env.AppendUnique(LIBPATH = env['build_dir']) + +# Cephes extension +src = ['_cephesmodule.c', 'amos_wrappers.c', 'specfun_wrappers.c', \ + 'toms_wrappers.c','cdf_wrappers.c','ufunc_extras.c'] + +env.NumpyPythonExtension('_cephes', + source = src, + LIBS = ['amos', 'toms', 'c_misc', 'cephes', 'mach',\ + 'cdf', 'specfun']) + +# Specfun extension +env.NumpyPythonExtension('specfun', source = 'specfun.pyf', LIBS = 'specfun', \ + F2PYOPTIONS = ["--no-wrap-functions"]) Copied: branches/scipy.scons/scipy/special/setupscons.py (from rev 3582, branches/scipy.scons/scipy/special/setup.py) =================================================================== --- branches/scipy.scons/scipy/special/setup.py 2007-11-24 10:49:51 UTC (rev 3582) +++ branches/scipy.scons/scipy/special/setupscons.py 2007-11-24 11:37:53 UTC (rev 3585) @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import os +import sys +from os.path import join +from distutils.sysconfig import get_python_inc + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('special', parent_package, top_path) + + config.add_sconscript('SConstruct') + config.add_data_dir('tests') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 06:39:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 05:39:38 -0600 (CST) Subject: [Scipy-svn] r3586 - branches/scipy.scons/scipy Message-ID: <20071124113938.DDBD039C00C@new.scipy.org> Author: cdavid Date: 2007-11-24 05:39:28 -0600 (Sat, 24 Nov 2007) New Revision: 3586 Modified: branches/scipy.scons/scipy/setupscons.py Log: Update root setupscons.py Modified: branches/scipy.scons/scipy/setupscons.py =================================================================== --- branches/scipy.scons/scipy/setupscons.py 2007-11-24 11:37:53 UTC (rev 3585) +++ branches/scipy.scons/scipy/setupscons.py 2007-11-24 11:39:28 UTC (rev 3586) @@ -16,8 +16,8 @@ config.add_subpackage('optimize') #config.add_subpackage('sandbox') config.add_subpackage('signal') - #config.add_subpackage('sparse') - #config.add_subpackage('special') + config.add_subpackage('sparse') + config.add_subpackage('special') #config.add_subpackage('stats') config.add_subpackage('ndimage') #config.add_subpackage('stsci') From scipy-svn at scipy.org Sat Nov 24 06:50:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 05:50:23 -0600 (CST) Subject: [Scipy-svn] r3587 - in branches/scipy.scons/scipy: lib/lapack sparse Message-ID: <20071124115023.A5476C7C00D@new.scipy.org> Author: cdavid Date: 2007-11-24 05:50:15 -0600 (Sat, 24 Nov 2007) New Revision: 3587 Modified: branches/scipy.scons/scipy/lib/lapack/SConstruct branches/scipy.scons/scipy/sparse/SConstruct Log: Correct two typos for scons build of scipy Modified: branches/scipy.scons/scipy/lib/lapack/SConstruct =================================================================== --- branches/scipy.scons/scipy/lib/lapack/SConstruct 2007-11-24 11:39:28 UTC (rev 3586) +++ branches/scipy.scons/scipy/lib/lapack/SConstruct 2007-11-24 11:50:15 UTC (rev 3587) @@ -1,4 +1,4 @@ -# Last Change: Sat Nov 24 05:00 PM 2007 J +# Last Change: Sat Nov 24 08:00 PM 2007 J # vim:syntax=python import os @@ -26,9 +26,7 @@ #======================= # Starting Configuration #======================= -config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS, - 'CheckBLAS' : CheckF77BLAS, - 'CheckCLAPACK' : CheckCLAPACK, +config = env.NumpyConfigure(custom_tests = {'CheckCLAPACK' : CheckCLAPACK, 'CheckLAPACK' : CheckF77LAPACK}) #-------------- Modified: branches/scipy.scons/scipy/sparse/SConstruct =================================================================== --- branches/scipy.scons/scipy/sparse/SConstruct 2007-11-24 11:39:28 UTC (rev 3586) +++ branches/scipy.scons/scipy/sparse/SConstruct 2007-11-24 11:50:15 UTC (rev 3587) @@ -1,4 +1,4 @@ -# Last Change: Sat Nov 24 07:00 PM 2007 J +# Last Change: Sat Nov 24 08:00 PM 2007 J # vim:syntax=python from os.path import join @@ -14,5 +14,5 @@ # Copy this python file into the distutils lib dir env.Command(join(env['distutils_installdir'], 'sparsetools.py'), - join('sparsetools', 'sparsetools.py'), + join(env['src_dir'], 'sparsetools', 'sparsetools.py'), Copy('$TARGET', '$SOURCE')) From scipy-svn at scipy.org Sat Nov 24 07:48:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 06:48:00 -0600 (CST) Subject: [Scipy-svn] r3588 - in branches/scipy.scons/scipy: . stats stats/models Message-ID: <20071124124800.B547739C1EC@new.scipy.org> Author: cdavid Date: 2007-11-24 06:47:48 -0600 (Sat, 24 Nov 2007) New Revision: 3588 Added: branches/scipy.scons/scipy/stats/models/setupscons.py branches/scipy.scons/scipy/stats/setupscons.py Modified: branches/scipy.scons/scipy/setupscons.py Log: stats now builds with scons Modified: branches/scipy.scons/scipy/setupscons.py =================================================================== --- branches/scipy.scons/scipy/setupscons.py 2007-11-24 11:50:15 UTC (rev 3587) +++ branches/scipy.scons/scipy/setupscons.py 2007-11-24 12:47:48 UTC (rev 3588) @@ -18,7 +18,7 @@ config.add_subpackage('signal') config.add_subpackage('sparse') config.add_subpackage('special') - #config.add_subpackage('stats') + config.add_subpackage('stats') config.add_subpackage('ndimage') #config.add_subpackage('stsci') config.add_subpackage('weave') Copied: branches/scipy.scons/scipy/stats/models/setupscons.py (from rev 3587, branches/scipy.scons/scipy/stats/models/setup.py) Copied: branches/scipy.scons/scipy/stats/setupscons.py (from rev 3587, branches/scipy.scons/scipy/stats/setup.py) =================================================================== --- branches/scipy.scons/scipy/stats/setup.py 2007-11-24 11:50:15 UTC (rev 3587) +++ branches/scipy.scons/scipy/stats/setupscons.py 2007-11-24 12:47:48 UTC (rev 3588) @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +from os.path import join + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('stats', parent_package, top_path, setup_name = 'setupscons.py') + + config.add_subpackage('models') + config.add_data_dir('tests') + + config.add_sconscript('SConstruct') + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict()) From scipy-svn at scipy.org Sat Nov 24 12:43:35 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 24 Nov 2007 11:43:35 -0600 (CST) Subject: [Scipy-svn] r3589 - trunk/scipy/sandbox/timeseries Message-ID: <20071124174335.23EA439C30A@new.scipy.org> Author: pierregm Date: 2007-11-24 11:43:31 -0600 (Sat, 24 Nov 2007) New Revision: 3589 Modified: trunk/scipy/sandbox/timeseries/plotlib.py Log: plotlib : fixed a bug in _daily_finder and _annual_finder Modified: trunk/scipy/sandbox/timeseries/plotlib.py =================================================================== --- trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-24 12:47:48 UTC (rev 3588) +++ trunk/scipy/sandbox/timeseries/plotlib.py 2007-11-24 17:43:31 UTC (rev 3589) @@ -223,7 +223,7 @@ info['fmt'][first_label(month_start)] = '%d\n%b\n%Y' # Case 2. Less than three months elif span <= periodsperyear//4: - month_start = period_break(dates,'month') + month_start = period_break(dates_,'month') info['maj'][month_start] = True info['min'] = True if asformatter: @@ -287,7 +287,7 @@ info['fmt'][year_start] = '%Y' # Case 6. More than 12 years ................ else: - year_start = period_break(dates,'year') + year_start = period_break(dates_,'year') year_break = dates_[year_start].years nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) From scipy-svn at scipy.org Sun Nov 25 12:34:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 25 Nov 2007 11:34:23 -0600 (CST) Subject: [Scipy-svn] r3590 - in branches/scipy.scons/scipy/special: . tests Message-ID: <20071125173423.8A0A639C143@new.scipy.org> Author: cdavid Date: 2007-11-25 11:34:13 -0600 (Sun, 25 Nov 2007) New Revision: 3590 Modified: branches/scipy.scons/scipy/special/spfun_stats.py branches/scipy.scons/scipy/special/tests/test_basic.py Log: Avoid importing from scipy to stay as local as possible Modified: branches/scipy.scons/scipy/special/spfun_stats.py =================================================================== --- branches/scipy.scons/scipy/special/spfun_stats.py 2007-11-24 17:43:31 UTC (rev 3589) +++ branches/scipy.scons/scipy/special/spfun_stats.py 2007-11-25 17:34:13 UTC (rev 3590) @@ -34,7 +34,7 @@ analysis.""" import numpy as N -from scipy.special import gammaln as loggam +from _cephes import gammaln as loggam def multigammaln(a, d): """returns the log of multivariate gamma, also sometimes called the Modified: branches/scipy.scons/scipy/special/tests/test_basic.py =================================================================== --- branches/scipy.scons/scipy/special/tests/test_basic.py 2007-11-24 17:43:31 UTC (rev 3589) +++ branches/scipy.scons/scipy/special/tests/test_basic.py 2007-11-25 17:34:13 UTC (rev 3590) @@ -36,8 +36,8 @@ from numpy.testing import * set_package_path() -from scipy.special import * -import scipy.special._cephes as cephes +from special import * +import special._cephes as cephes restore_path() class TestCephes(NumpyTestCase): From scipy-svn at scipy.org Sun Nov 25 12:47:30 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 25 Nov 2007 11:47:30 -0600 (CST) Subject: [Scipy-svn] r3591 - in trunk/scipy/sandbox/timeseries: . src tests Message-ID: <20071125174730.665F439C10B@new.scipy.org> Author: mattknox_ca Date: 2007-11-25 11:47:23 -0600 (Sun, 25 Nov 2007) New Revision: 3591 Modified: trunk/scipy/sandbox/timeseries/dates.py trunk/scipy/sandbox/timeseries/src/c_dates.c trunk/scipy/sandbox/timeseries/src/c_tseries.c trunk/scipy/sandbox/timeseries/tests/test_dates.py trunk/scipy/sandbox/timeseries/tests/test_timeseries.py trunk/scipy/sandbox/timeseries/tseries.py Log: - changed relation parameter of asfreq functions/methods to accept 'START'/'END' ('BEFORE'/'AFTER' are now deprecated, but still work for now) - enhanced documentation for several functions Modified: trunk/scipy/sandbox/timeseries/dates.py =================================================================== --- trunk/scipy/sandbox/timeseries/dates.py 2007-11-25 17:34:13 UTC (rev 3590) +++ trunk/scipy/sandbox/timeseries/dates.py 2007-11-25 17:47:23 UTC (rev 3591) @@ -392,15 +392,35 @@ self._cachedinfo['tostr'] = tostr return self._cachedinfo['tostr'] # - def asfreq(self, freq=None, relation="AFTER"): - "Converts the dates to another frequency." + def asfreq(self, freq=None, relation="END"): + """Converts the dates to another frequency. + +*Parameters*: + freq : {freq_spec} + Frequency to convert the DateArray to. Accepts any valid frequency + specification (string or integer) + relation : {"END", "START"} (optional) + Applies only when converting a lower frequency Date to a higher + frequency Date, or when converting a weekend Date to a business + frequency Date. Valid values are 'START' and 'END'. + + For example, if converting a monthly date to a daily date, specifying + 'START' ('END') would result in the first (last) day in the month. +""" # Note: As we define a new object, we don't need caching if freq is None or freq == _c.FR_UND: return self tofreq = check_freq(freq) if tofreq == self.freq: return self + _rel = relation.upper()[0] + + # support for deprecated values of relation parameter ('BEFORE' and + # 'AFTER') + if _rel == 'A': _rel = 'E' + if _rel == 'B': _rel = 'S' + fromfreq = self.freq if fromfreq == _c.FR_UND: fromfreq = _c.FR_DAY Modified: trunk/scipy/sandbox/timeseries/src/c_dates.c =================================================================== --- trunk/scipy/sandbox/timeseries/src/c_dates.c 2007-11-25 17:34:13 UTC (rev 3590) +++ trunk/scipy/sandbox/timeseries/src/c_dates.c 2007-11-25 17:47:23 UTC (rev 3591) @@ -427,7 +427,7 @@ /////////////////////////////////////////////// // frequency specifc conversion routines -// each function must take an integer fromDate and a char relation ('B' or 'A' for 'BEFORE' or 'AFTER') +// each function must take an integer fromDate and a char relation ('S' or 'E' for 'START' or 'END') //************ FROM DAILY *************** @@ -487,7 +487,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { + if (relation == 'S') { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); @@ -512,7 +512,7 @@ static long asfreq_DtoHIGHFREQ(long fromDate, char relation, long periodsPerDay) { if (fromDate >= HIGHFREQ_ORIG) { - if (relation == 'B') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; } + if (relation == 'S') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; } else { return (fromDate - HIGHFREQ_ORIG + 1)*(periodsPerDay); } } else { return -1; } } @@ -568,7 +568,7 @@ static long asfreq_TtoH(long fromDate, char relation, asfreq_info *af_info) { return (fromDate - 1)/60 + 1; } static long asfreq_TtoS(long fromDate, char relation, asfreq_info *af_info) { - if (relation == 'B') { return fromDate*60 - 59; } + if (relation == 'S') { return fromDate*60 - 59; } else { return fromDate*60; }} //************ FROM HOURLY *************** @@ -593,7 +593,7 @@ static long asfreq_HtoT(long fromDate, char relation, asfreq_info *af_info) { return asfreq_TtoS(fromDate, relation, &NULL_AF_INFO); } static long asfreq_HtoS(long fromDate, char relation, asfreq_info *af_info) { - if (relation == 'B') { return fromDate*60*60 - 60*60 + 1; } + if (relation == 'S') { return fromDate*60*60 - 60*60 + 1; } else { return fromDate*60*60; }} //************ FROM BUSINESS *************** @@ -625,16 +625,16 @@ //************ FROM WEEKLY *************** static long asfreq_WtoD(long fromDate, char relation, asfreq_info *af_info) { - if (relation == 'B') { return fromDate * 7 - 6 + af_info->from_week_end;} + if (relation == 'S') { return fromDate * 7 - 6 + af_info->from_week_end;} else { return fromDate * 7 + af_info->from_week_end; } } static long asfreq_WtoA(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } + return asfreq_DtoA(asfreq_WtoD(fromDate, 'E', af_info), relation, af_info); } static long asfreq_WtoQ(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } + return asfreq_DtoQ(asfreq_WtoD(fromDate, 'E', af_info), relation, af_info); } static long asfreq_WtoM(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); } + return asfreq_DtoM(asfreq_WtoD(fromDate, 'E', af_info), relation, &NULL_AF_INFO); } static long asfreq_WtoW(long fromDate, char relation, asfreq_info *af_info) { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, af_info); } @@ -645,7 +645,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -667,7 +667,7 @@ long y, m, absdate; - if (relation == 'B') { + if (relation == 'S') { MtoD_ym(fromDate, &y, &m); if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; @@ -679,10 +679,10 @@ } static long asfreq_MtoA(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoA(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); } + return asfreq_DtoA(asfreq_MtoD(fromDate, 'E', &NULL_AF_INFO), relation, af_info); } static long asfreq_MtoQ(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoQ(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); } + return asfreq_DtoQ(asfreq_MtoD(fromDate, 'E', &NULL_AF_INFO), relation, af_info); } static long asfreq_MtoW(long fromDate, char relation, asfreq_info *af_info) { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } @@ -693,7 +693,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -722,7 +722,7 @@ long y, m, absdate; - if (relation == 'B') { + if (relation == 'S') { QtoD_ym(fromDate, &y, &m, af_info); if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; @@ -751,7 +751,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -773,7 +773,7 @@ if (month == 0) { month = 1; } else { month += 1; } - if (relation == 'B') { + if (relation == 'S') { if (af_info->from_a_year_end == 12) {year = fromDate;} else {year = fromDate - 1;} final_adj = 0; @@ -805,7 +805,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_AtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -1034,7 +1034,7 @@ return 24*60*60 - 1; } - startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay); + startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'S', periodsPerDay); return (24*60*60)*((double)(originalDate - startOfDay))/((double)periodsPerDay); } @@ -1569,20 +1569,20 @@ toDaily = get_asfreq_func(self->freq, FR_DAY, 0); get_asfreq_info(self->freq, FR_DAY, &af_info); - return PyInt_FromLong(toDaily(self->value, 'A', &af_info)); + return PyInt_FromLong(toDaily(self->value, 'E', &af_info)); } } static char DateObject_asfreq_doc[] = "Returns a date converted to a specified frequency.\n\n" -":Parameters:\n" -" - freq : string/int\n" -" Frequency to convert the Date to. Accepts any valid frequency\n" -" specification (string or integer)\n" -" - relation :string *['After']*\n" -" Applies only when converting a lower frequency Date to a higher\n" -" frequency Date, or when converting a weekend Date to a business\n" -" frequency Date. Valid values are 'before', 'after', 'b', and 'a'."; +"*Parameters*:\n" +" freq : {freq_spec}\n" +" Frequency to convert the Date to. Accepts any valid frequency\n" +" specification (string or integer)\n" +" relation : {'END', 'START'} (optional)\n" +" Applies only when converting a lower frequency Date to a higher\n" +" frequency Date, or when converting a weekend Date to a business\n" +" frequency Date. Valid values are 'START' and 'END'."; static PyObject * DateObject_asfreq(DateObject *self, PyObject *args, PyObject *kwds) { @@ -1609,12 +1609,17 @@ if((relation_uc = str_uppercase(relation_raw)) == NULL) {return PyErr_NoMemory();} - if (strcmp(relation_uc, "BEFORE") == 0 || + // 'BEFORE' and 'AFTER' values for this parameter are deprecated + if (strcmp(relation_uc, "END") == 0 || + strcmp(relation_uc, "E") == 0 || + strcmp(relation_uc, "START") == 0 || + strcmp(relation_uc, "S") == 0 || + strcmp(relation_uc, "BEFORE") == 0 || strcmp(relation_uc, "B") == 0 || strcmp(relation_uc, "AFTER") == 0 || strcmp(relation_uc, "A") == 0) { - if(relation_uc[0] == 'A') { relation = 'A'; } - else { relation = 'B'; } + if(relation_uc[0] == 'E' || relation_uc[0] == 'A') { relation = 'E'; } + else { relation = 'S'; } } else { invalid_relation=1; } @@ -1629,7 +1634,7 @@ return NULL; } } else { - relation = 'A'; + relation = 'E'; } if ((toFreq = check_freq(freq)) == INT_ERR_CODE) return NULL; @@ -1697,7 +1702,7 @@ toDaily = get_asfreq_func(self->freq, FR_DAY, 0); get_asfreq_info(self->freq, FR_DAY, &af_info); - absdate = toDaily(self->value, 'A', &af_info); + absdate = toDaily(self->value, 'E', &af_info); abstime = getAbsTime(self->freq, absdate, self->value); if(dInfoCalc_SetFromAbsDateTime(&tempDate, absdate, abstime, @@ -2384,7 +2389,7 @@ get_asfreq_info(FR_SEC, freq_val, &af_info); asfreq_func = get_asfreq_func(FR_SEC, freq_val, 0); - date_val = asfreq_func(secondly_date->value, 'B', &af_info); + date_val = asfreq_func(secondly_date->value, 'S', &af_info); Py_DECREF(secondly_date); Modified: trunk/scipy/sandbox/timeseries/src/c_tseries.c =================================================================== --- trunk/scipy/sandbox/timeseries/src/c_tseries.c 2007-11-25 17:34:13 UTC (rev 3590) +++ trunk/scipy/sandbox/timeseries/src/c_tseries.c 2007-11-25 17:47:23 UTC (rev 3591) @@ -167,11 +167,11 @@ { case 'S': // start -> before - relation = 'B'; + relation = 'S'; break; case 'E': // end -> after - relation = 'A'; + relation = 'E'; break; default: return NULL; @@ -184,16 +184,16 @@ asfreq_endpoints = get_asfreq_func(fromFreq, toFreq, 0); //convert start index to new frequency - CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B', &af_info)); + CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'S', &af_info)); if (newStartTemp < 1) { - CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A', &af_info)); + CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'E', &af_info)); } else { newStart = newStartTemp; } //convert end index to new frequency - CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A', &af_info)); + CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'E', &af_info)); if (newEndTemp < 1) { - CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B', &af_info)); + CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'S', &af_info)); } else { newEnd = newEndTemp; } @@ -212,7 +212,7 @@ get_asfreq_info(toFreq, fromFreq, &af_info_rev); asfreq_reverse = get_asfreq_func(toFreq, fromFreq, 0); - CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B', &af_info_rev)); + CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'S', &af_info_rev)); currPerLen = startIndex - tempval; nd = 2; Modified: trunk/scipy/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-25 17:34:13 UTC (rev 3590) +++ trunk/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-25 17:47:23 UTC (rev 3591) @@ -263,61 +263,61 @@ date_AJUN = dWrap(Date(freq=C.FR_ANNJUN, year=2007)) date_ANOV = dWrap(Date(freq=C.FR_ANNNOV, year=2007)) - date_A_to_Q_before = dWrap(Date(freq='Q', year=2007, quarter=1)) - date_A_to_Q_after = dWrap(Date(freq='Q', year=2007, quarter=4)) - date_A_to_M_before = dWrap(Date(freq='M', year=2007, month=1)) - date_A_to_M_after = dWrap(Date(freq='M', year=2007, month=12)) - date_A_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) - date_A_to_W_after = dWrap(Date(freq='W', year=2007, month=12, day=31)) - date_A_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_A_to_B_after = dWrap(Date(freq='B', year=2007, month=12, day=31)) - date_A_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_A_to_D_after = dWrap(Date(freq='D', year=2007, month=12, day=31)) - date_A_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_A_to_Q_start = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_A_to_Q_end = dWrap(Date(freq='Q', year=2007, quarter=4)) + date_A_to_M_start = dWrap(Date(freq='M', year=2007, month=1)) + date_A_to_M_end = dWrap(Date(freq='M', year=2007, month=12)) + date_A_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_A_to_W_end = dWrap(Date(freq='W', year=2007, month=12, day=31)) + date_A_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_A_to_B_end = dWrap(Date(freq='B', year=2007, month=12, day=31)) + date_A_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_A_to_D_end = dWrap(Date(freq='D', year=2007, month=12, day=31)) + date_A_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_A_to_H_after = dWrap(Date(freq='H', year=2007, month=12, day=31, + date_A_to_H_end = dWrap(Date(freq='H', year=2007, month=12, day=31, hour=23)) - date_A_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_A_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_A_to_T_after = dWrap(Date(freq='T', year=2007, month=12, day=31, + date_A_to_T_end = dWrap(Date(freq='T', year=2007, month=12, day=31, hour=23, minute=59)) - date_A_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_A_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_A_to_S_after = dWrap(Date(freq='S', year=2007, month=12, day=31, + date_A_to_S_end = dWrap(Date(freq='S', year=2007, month=12, day=31, hour=23, minute=59, second=59)) - date_AJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31)) - date_AJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1)) - date_AJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=6, day=30)) - date_AJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1)) - date_ANOV_to_D_after = dWrap(Date(freq='D', year=2007, month=11, day=30)) - date_ANOV_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=1)) + date_AJAN_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=31)) + date_AJAN_to_D_start = dWrap(Date(freq='D', year=2006, month=2, day=1)) + date_AJUN_to_D_end = dWrap(Date(freq='D', year=2007, month=6, day=30)) + date_AJUN_to_D_start = dWrap(Date(freq='D', year=2006, month=7, day=1)) + date_ANOV_to_D_end = dWrap(Date(freq='D', year=2007, month=11, day=30)) + date_ANOV_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=1)) - assert_func(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) - assert_func(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) - assert_func(date_A.asfreq('M', "BEFORE"), date_A_to_M_before) - assert_func(date_A.asfreq('M', "AFTER"), date_A_to_M_after) - assert_func(date_A.asfreq('W', "BEFORE"), date_A_to_W_before) - assert_func(date_A.asfreq('W', "AFTER"), date_A_to_W_after) - assert_func(date_A.asfreq('B', "BEFORE"), date_A_to_B_before) - assert_func(date_A.asfreq('B', "AFTER"), date_A_to_B_after) - assert_func(date_A.asfreq('D', "BEFORE"), date_A_to_D_before) - assert_func(date_A.asfreq('D', "AFTER"), date_A_to_D_after) - assert_func(date_A.asfreq('H', "BEFORE"), date_A_to_H_before) - assert_func(date_A.asfreq('H', "AFTER"), date_A_to_H_after) - assert_func(date_A.asfreq('T', "BEFORE"), date_A_to_T_before) - assert_func(date_A.asfreq('T', "AFTER"), date_A_to_T_after) - assert_func(date_A.asfreq('S', "BEFORE"), date_A_to_S_before) - assert_func(date_A.asfreq('S', "AFTER"), date_A_to_S_after) + assert_func(date_A.asfreq('Q', "START"), date_A_to_Q_start) + assert_func(date_A.asfreq('Q', "END"), date_A_to_Q_end) + assert_func(date_A.asfreq('M', "START"), date_A_to_M_start) + assert_func(date_A.asfreq('M', "END"), date_A_to_M_end) + assert_func(date_A.asfreq('W', "START"), date_A_to_W_start) + assert_func(date_A.asfreq('W', "END"), date_A_to_W_end) + assert_func(date_A.asfreq('B', "START"), date_A_to_B_start) + assert_func(date_A.asfreq('B', "END"), date_A_to_B_end) + assert_func(date_A.asfreq('D', "START"), date_A_to_D_start) + assert_func(date_A.asfreq('D', "END"), date_A_to_D_end) + assert_func(date_A.asfreq('H', "START"), date_A_to_H_start) + assert_func(date_A.asfreq('H', "END"), date_A_to_H_end) + assert_func(date_A.asfreq('T', "START"), date_A_to_T_start) + assert_func(date_A.asfreq('T', "END"), date_A_to_T_end) + assert_func(date_A.asfreq('S', "START"), date_A_to_S_start) + assert_func(date_A.asfreq('S', "END"), date_A_to_S_end) - assert_func(date_AJAN.asfreq('D', "BEFORE"), date_AJAN_to_D_before) - assert_func(date_AJAN.asfreq('D', "AFTER"), date_AJAN_to_D_after) + assert_func(date_AJAN.asfreq('D', "START"), date_AJAN_to_D_start) + assert_func(date_AJAN.asfreq('D', "END"), date_AJAN_to_D_end) - assert_func(date_AJUN.asfreq('D', "BEFORE"), date_AJUN_to_D_before) - assert_func(date_AJUN.asfreq('D', "AFTER"), date_AJUN_to_D_after) + assert_func(date_AJUN.asfreq('D', "START"), date_AJUN_to_D_start) + assert_func(date_AJUN.asfreq('D', "END"), date_AJUN_to_D_end) - assert_func(date_ANOV.asfreq('D', "BEFORE"), date_ANOV_to_D_before) - assert_func(date_ANOV.asfreq('D', "AFTER"), date_ANOV_to_D_after) + assert_func(date_ANOV.asfreq('D', "START"), date_ANOV_to_D_start) + assert_func(date_ANOV.asfreq('D', "END"), date_ANOV_to_D_end) def test_conv_quarterly(self): "frequency conversion tests: from Quarterly Frequency" @@ -334,71 +334,71 @@ date_QSDEC = dWrap(Date(freq=C.FR_QTRSDEC, year=2007, quarter=1)) date_Q_to_A = dWrap(Date(freq='A', year=2007)) - date_Q_to_M_before = dWrap(Date(freq='M', year=2007, month=1)) - date_Q_to_M_after = dWrap(Date(freq='M', year=2007, month=3)) - date_Q_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) - date_Q_to_W_after = dWrap(Date(freq='W', year=2007, month=3, day=31)) - date_Q_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_Q_to_B_after = dWrap(Date(freq='B', year=2007, month=3, day=30)) - date_Q_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_Q_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31)) - date_Q_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_Q_to_M_start = dWrap(Date(freq='M', year=2007, month=1)) + date_Q_to_M_end = dWrap(Date(freq='M', year=2007, month=3)) + date_Q_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_Q_to_W_end = dWrap(Date(freq='W', year=2007, month=3, day=31)) + date_Q_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_Q_to_B_end = dWrap(Date(freq='B', year=2007, month=3, day=30)) + date_Q_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_Q_to_D_end = dWrap(Date(freq='D', year=2007, month=3, day=31)) + date_Q_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_Q_to_H_after = dWrap(Date(freq='H', year=2007, month=3, day=31, + date_Q_to_H_end = dWrap(Date(freq='H', year=2007, month=3, day=31, hour=23)) - date_Q_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_Q_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_Q_to_T_after = dWrap(Date(freq='T', year=2007, month=3, day=31, + date_Q_to_T_end = dWrap(Date(freq='T', year=2007, month=3, day=31, hour=23, minute=59)) - date_Q_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_Q_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_Q_to_S_after = dWrap(Date(freq='S', year=2007, month=3, day=31, + date_Q_to_S_end = dWrap(Date(freq='S', year=2007, month=3, day=31, hour=23, minute=59, second=59)) - date_QEJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1)) - date_QEJAN_to_D_after = dWrap(Date(freq='D', year=2006, month=4, day=30)) + date_QEJAN_to_D_start = dWrap(Date(freq='D', year=2006, month=2, day=1)) + date_QEJAN_to_D_end = dWrap(Date(freq='D', year=2006, month=4, day=30)) - date_QEJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1)) - date_QEJUN_to_D_after = dWrap(Date(freq='D', year=2006, month=9, day=30)) + date_QEJUN_to_D_start = dWrap(Date(freq='D', year=2006, month=7, day=1)) + date_QEJUN_to_D_end = dWrap(Date(freq='D', year=2006, month=9, day=30)) - date_QSJAN_to_D_before = dWrap(Date(freq='D', year=2007, month=2, day=1)) - date_QSJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=4, day=30)) + date_QSJAN_to_D_start = dWrap(Date(freq='D', year=2007, month=2, day=1)) + date_QSJAN_to_D_end = dWrap(Date(freq='D', year=2007, month=4, day=30)) - date_QSJUN_to_D_before = dWrap(Date(freq='D', year=2007, month=7, day=1)) - date_QSJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=9, day=30)) + date_QSJUN_to_D_start = dWrap(Date(freq='D', year=2007, month=7, day=1)) + date_QSJUN_to_D_end = dWrap(Date(freq='D', year=2007, month=9, day=30)) - date_QSDEC_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_QSDEC_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31)) + date_QSDEC_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_QSDEC_to_D_end = dWrap(Date(freq='D', year=2007, month=3, day=31)) assert_func(date_Q.asfreq('A'), date_Q_to_A) assert_func(date_Q_end_of_year.asfreq('A'), date_Q_to_A) - assert_func(date_Q.asfreq('M', "BEFORE"), date_Q_to_M_before) - assert_func(date_Q.asfreq('M', "AFTER"), date_Q_to_M_after) - assert_func(date_Q.asfreq('W', "BEFORE"), date_Q_to_W_before) - assert_func(date_Q.asfreq('W', "AFTER"), date_Q_to_W_after) - assert_func(date_Q.asfreq('B', "BEFORE"), date_Q_to_B_before) - assert_func(date_Q.asfreq('B', "AFTER"), date_Q_to_B_after) - assert_func(date_Q.asfreq('D', "BEFORE"), date_Q_to_D_before) - assert_func(date_Q.asfreq('D', "AFTER"), date_Q_to_D_after) - assert_func(date_Q.asfreq('H', "BEFORE"), date_Q_to_H_before) - assert_func(date_Q.asfreq('H', "AFTER"), date_Q_to_H_after) - assert_func(date_Q.asfreq('T', "BEFORE"), date_Q_to_T_before) - assert_func(date_Q.asfreq('T', "AFTER"), date_Q_to_T_after) - assert_func(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before) - assert_func(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after) + assert_func(date_Q.asfreq('M', "START"), date_Q_to_M_start) + assert_func(date_Q.asfreq('M', "END"), date_Q_to_M_end) + assert_func(date_Q.asfreq('W', "START"), date_Q_to_W_start) + assert_func(date_Q.asfreq('W', "END"), date_Q_to_W_end) + assert_func(date_Q.asfreq('B', "START"), date_Q_to_B_start) + assert_func(date_Q.asfreq('B', "END"), date_Q_to_B_end) + assert_func(date_Q.asfreq('D', "START"), date_Q_to_D_start) + assert_func(date_Q.asfreq('D', "END"), date_Q_to_D_end) + assert_func(date_Q.asfreq('H', "START"), date_Q_to_H_start) + assert_func(date_Q.asfreq('H', "END"), date_Q_to_H_end) + assert_func(date_Q.asfreq('T', "START"), date_Q_to_T_start) + assert_func(date_Q.asfreq('T', "END"), date_Q_to_T_end) + assert_func(date_Q.asfreq('S', "START"), date_Q_to_S_start) + assert_func(date_Q.asfreq('S', "END"), date_Q_to_S_end) - assert_func(date_QEJAN.asfreq('D', "BEFORE"), date_QEJAN_to_D_before) - assert_func(date_QEJAN.asfreq('D', "AFTER"), date_QEJAN_to_D_after) - assert_func(date_QEJUN.asfreq('D', "BEFORE"), date_QEJUN_to_D_before) - assert_func(date_QEJUN.asfreq('D', "AFTER"), date_QEJUN_to_D_after) + assert_func(date_QEJAN.asfreq('D', "START"), date_QEJAN_to_D_start) + assert_func(date_QEJAN.asfreq('D', "END"), date_QEJAN_to_D_end) + assert_func(date_QEJUN.asfreq('D', "START"), date_QEJUN_to_D_start) + assert_func(date_QEJUN.asfreq('D', "END"), date_QEJUN_to_D_end) - assert_func(date_QSJAN.asfreq('D', "BEFORE"), date_QSJAN_to_D_before) - assert_func(date_QSJAN.asfreq('D', "AFTER"), date_QSJAN_to_D_after) - assert_func(date_QSJUN.asfreq('D', "BEFORE"), date_QSJUN_to_D_before) - assert_func(date_QSJUN.asfreq('D', "AFTER"), date_QSJUN_to_D_after) - assert_func(date_QSDEC.asfreq('D', "BEFORE"), date_QSDEC_to_D_before) - assert_func(date_QSDEC.asfreq('D', "AFTER"), date_QSDEC_to_D_after) + assert_func(date_QSJAN.asfreq('D', "START"), date_QSJAN_to_D_start) + assert_func(date_QSJAN.asfreq('D', "END"), date_QSJAN_to_D_end) + assert_func(date_QSJUN.asfreq('D', "START"), date_QSJUN_to_D_start) + assert_func(date_QSJUN.asfreq('D', "END"), date_QSJUN_to_D_end) + assert_func(date_QSDEC.asfreq('D', "START"), date_QSDEC_to_D_start) + assert_func(date_QSDEC.asfreq('D', "END"), date_QSDEC_to_D_end) def test_conv_monthly(self): "frequency conversion tests: from Monthly Frequency" @@ -409,23 +409,23 @@ date_M_end_of_quarter = dWrap(Date(freq='M', year=2007, month=3)) date_M_to_A = dWrap(Date(freq='A', year=2007)) date_M_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) - date_M_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) - date_M_to_W_after = dWrap(Date(freq='W', year=2007, month=1, day=31)) - date_M_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_M_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=31)) - date_M_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_M_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31)) - date_M_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_M_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_M_to_W_end = dWrap(Date(freq='W', year=2007, month=1, day=31)) + date_M_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_M_to_B_end = dWrap(Date(freq='B', year=2007, month=1, day=31)) + date_M_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_M_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=31)) + date_M_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_M_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=31, + date_M_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=31, hour=23)) - date_M_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_M_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_M_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=31, + date_M_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=31, hour=23, minute=59)) - date_M_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_M_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_M_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=31, + date_M_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=31, hour=23, minute=59, second=59)) assert_func(date_M.asfreq('A'), date_M_to_A) @@ -433,18 +433,18 @@ assert_func(date_M.asfreq('Q'), date_M_to_Q) assert_func(date_M_end_of_quarter.asfreq('Q'), date_M_to_Q) - assert_func(date_M.asfreq('W', "BEFORE"), date_M_to_W_before) - assert_func(date_M.asfreq('W', "AFTER"), date_M_to_W_after) - assert_func(date_M.asfreq('B', "BEFORE"), date_M_to_B_before) - assert_func(date_M.asfreq('B', "AFTER"), date_M_to_B_after) - assert_func(date_M.asfreq('D', "BEFORE"), date_M_to_D_before) - assert_func(date_M.asfreq('D', "AFTER"), date_M_to_D_after) - assert_func(date_M.asfreq('H', "BEFORE"), date_M_to_H_before) - assert_func(date_M.asfreq('H', "AFTER"), date_M_to_H_after) - assert_func(date_M.asfreq('T', "BEFORE"), date_M_to_T_before) - assert_func(date_M.asfreq('T', "AFTER"), date_M_to_T_after) - assert_func(date_M.asfreq('S', "BEFORE"), date_M_to_S_before) - assert_func(date_M.asfreq('S', "AFTER"), date_M_to_S_after) + assert_func(date_M.asfreq('W', "START"), date_M_to_W_start) + assert_func(date_M.asfreq('W', "END"), date_M_to_W_end) + assert_func(date_M.asfreq('B', "START"), date_M_to_B_start) + assert_func(date_M.asfreq('B', "END"), date_M_to_B_end) + assert_func(date_M.asfreq('D', "START"), date_M_to_D_start) + assert_func(date_M.asfreq('D', "END"), date_M_to_D_end) + assert_func(date_M.asfreq('H', "START"), date_M_to_H_start) + assert_func(date_M.asfreq('H', "END"), date_M_to_H_end) + assert_func(date_M.asfreq('T', "START"), date_M_to_T_start) + assert_func(date_M.asfreq('T', "END"), date_M_to_T_end) + assert_func(date_M.asfreq('S', "START"), date_M_to_S_start) + assert_func(date_M.asfreq('S', "END"), date_M_to_S_end) def test_conv_weekly(self): @@ -461,20 +461,20 @@ date_WTUE = dWrap(Date(freq='W-TUE', year=2007, month=1, day=2)) date_WMON = dWrap(Date(freq='W-MON', year=2007, month=1, day=1)) - date_WSUN_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_WSUN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7)) - date_WSAT_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=31)) - date_WSAT_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=6)) - date_WFRI_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=30)) - date_WFRI_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=5)) - date_WTHU_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=29)) - date_WTHU_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=4)) - date_WWED_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=28)) - date_WWED_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=3)) - date_WTUE_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=27)) - date_WTUE_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=2)) - date_WMON_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=26)) - date_WMON_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_WSUN_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_WSUN_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=7)) + date_WSAT_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=31)) + date_WSAT_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=6)) + date_WFRI_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=30)) + date_WFRI_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=5)) + date_WTHU_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=29)) + date_WTHU_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=4)) + date_WWED_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=28)) + date_WWED_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=3)) + date_WTUE_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=27)) + date_WTUE_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=2)) + date_WMON_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=26)) + date_WMON_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_W_end_of_year = dWrap(Date(freq='W', year=2007, month=12, day=31)) date_W_end_of_quarter = dWrap(Date(freq='W', year=2007, month=3, day=31)) @@ -498,21 +498,21 @@ else: date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=2)) - date_W_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_W_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=5)) - date_W_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_W_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7)) - date_W_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_W_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_W_to_B_end = dWrap(Date(freq='B', year=2007, month=1, day=5)) + date_W_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_W_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=7)) + date_W_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_W_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=7, + date_W_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=7, hour=23)) - date_W_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_W_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_W_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=7, + date_W_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=7, hour=23, minute=59)) - date_W_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_W_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_W_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=7, + date_W_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=7, hour=23, minute=59, second=59)) assert_func(date_W.asfreq('A'), date_W_to_A) @@ -522,33 +522,33 @@ assert_func(date_W.asfreq('M'), date_W_to_M) assert_func(date_W_end_of_month.asfreq('M'), date_W_to_M_end_of_month) - assert_func(date_W.asfreq('B', "BEFORE"), date_W_to_B_before) - assert_func(date_W.asfreq('B', "AFTER"), date_W_to_B_after) + assert_func(date_W.asfreq('B', "START"), date_W_to_B_start) + assert_func(date_W.asfreq('B', "END"), date_W_to_B_end) - assert_func(date_W.asfreq('D', "BEFORE"), date_W_to_D_before) - assert_func(date_W.asfreq('D', "AFTER"), date_W_to_D_after) + assert_func(date_W.asfreq('D', "START"), date_W_to_D_start) + assert_func(date_W.asfreq('D', "END"), date_W_to_D_end) - assert_func(date_WSUN.asfreq('D', "BEFORE"), date_WSUN_to_D_before) - assert_func(date_WSUN.asfreq('D', "AFTER"), date_WSUN_to_D_after) - assert_func(date_WSAT.asfreq('D', "BEFORE"), date_WSAT_to_D_before) - assert_func(date_WSAT.asfreq('D', "AFTER"), date_WSAT_to_D_after) - assert_func(date_WFRI.asfreq('D', "BEFORE"), date_WFRI_to_D_before) - assert_func(date_WFRI.asfreq('D', "AFTER"), date_WFRI_to_D_after) - assert_func(date_WTHU.asfreq('D', "BEFORE"), date_WTHU_to_D_before) - assert_func(date_WTHU.asfreq('D', "AFTER"), date_WTHU_to_D_after) - assert_func(date_WWED.asfreq('D', "BEFORE"), date_WWED_to_D_before) - assert_func(date_WWED.asfreq('D', "AFTER"), date_WWED_to_D_after) - assert_func(date_WTUE.asfreq('D', "BEFORE"), date_WTUE_to_D_before) - assert_func(date_WTUE.asfreq('D', "AFTER"), date_WTUE_to_D_after) - assert_func(date_WMON.asfreq('D', "BEFORE"), date_WMON_to_D_before) - assert_func(date_WMON.asfreq('D', "AFTER"), date_WMON_to_D_after) + assert_func(date_WSUN.asfreq('D', "START"), date_WSUN_to_D_start) + assert_func(date_WSUN.asfreq('D', "END"), date_WSUN_to_D_end) + assert_func(date_WSAT.asfreq('D', "START"), date_WSAT_to_D_start) + assert_func(date_WSAT.asfreq('D', "END"), date_WSAT_to_D_end) + assert_func(date_WFRI.asfreq('D', "START"), date_WFRI_to_D_start) + assert_func(date_WFRI.asfreq('D', "END"), date_WFRI_to_D_end) + assert_func(date_WTHU.asfreq('D', "START"), date_WTHU_to_D_start) + assert_func(date_WTHU.asfreq('D', "END"), date_WTHU_to_D_end) + assert_func(date_WWED.asfreq('D', "START"), date_WWED_to_D_start) + assert_func(date_WWED.asfreq('D', "END"), date_WWED_to_D_end) + assert_func(date_WTUE.asfreq('D', "START"), date_WTUE_to_D_start) + assert_func(date_WTUE.asfreq('D', "END"), date_WTUE_to_D_end) + assert_func(date_WMON.asfreq('D', "START"), date_WMON_to_D_start) + assert_func(date_WMON.asfreq('D', "END"), date_WMON_to_D_end) - assert_func(date_W.asfreq('H', "BEFORE"), date_W_to_H_before) - assert_func(date_W.asfreq('H', "AFTER"), date_W_to_H_after) - assert_func(date_W.asfreq('T', "BEFORE"), date_W_to_T_before) - assert_func(date_W.asfreq('T', "AFTER"), date_W_to_T_after) - assert_func(date_W.asfreq('S', "BEFORE"), date_W_to_S_before) - assert_func(date_W.asfreq('S', "AFTER"), date_W_to_S_after) + assert_func(date_W.asfreq('H', "START"), date_W_to_H_start) + assert_func(date_W.asfreq('H', "END"), date_W_to_H_end) + assert_func(date_W.asfreq('T', "START"), date_W_to_T_start) + assert_func(date_W.asfreq('T', "END"), date_W_to_T_end) + assert_func(date_W.asfreq('S', "START"), date_W_to_S_start) + assert_func(date_W.asfreq('S', "END"), date_W_to_S_end) def test_conv_business(self): "frequency conversion tests: from Business Frequency" @@ -565,17 +565,17 @@ date_B_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_B_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) date_B_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_B_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_B_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_B_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_B_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_B_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_B_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_B_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_B_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_B_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_B_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_B_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_B_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) assert_func(date_B.asfreq('A'), date_B_to_A) @@ -589,12 +589,12 @@ assert_func(date_B.asfreq('D'), date_B_to_D) - assert_func(date_B.asfreq('H', "BEFORE"), date_B_to_H_before) - assert_func(date_B.asfreq('H', "AFTER"), date_B_to_H_after) - assert_func(date_B.asfreq('T', "BEFORE"), date_B_to_T_before) - assert_func(date_B.asfreq('T', "AFTER"), date_B_to_T_after) - assert_func(date_B.asfreq('S', "BEFORE"), date_B_to_S_before) - assert_func(date_B.asfreq('S', "AFTER"), date_B_to_S_after) + assert_func(date_B.asfreq('H', "START"), date_B_to_H_start) + assert_func(date_B.asfreq('H', "END"), date_B_to_H_end) + assert_func(date_B.asfreq('T', "START"), date_B_to_T_start) + assert_func(date_B.asfreq('T', "END"), date_B_to_T_end) + assert_func(date_B.asfreq('S', "START"), date_B_to_S_start) + assert_func(date_B.asfreq('S', "END"), date_B_to_S_end) def test_conv_daily(self): "frequency conversion tests: from Business Frequency" @@ -631,17 +631,17 @@ date_D_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_D_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) - date_D_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_D_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_D_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_D_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_D_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_D_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_D_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_D_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_D_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_D_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_D_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_D_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) assert_func(date_D.asfreq('A'), date_D_to_A) @@ -664,17 +664,17 @@ assert_func(date_D_end_of_week.asfreq('W'), date_D_to_W) assert_func(date_D_friday.asfreq('B'), date_B_friday) - assert_func(date_D_saturday.asfreq('B', "BEFORE"), date_B_friday) - assert_func(date_D_saturday.asfreq('B', "AFTER"), date_B_monday) - assert_func(date_D_sunday.asfreq('B', "BEFORE"), date_B_friday) - assert_func(date_D_sunday.asfreq('B', "AFTER"), date_B_monday) + assert_func(date_D_saturday.asfreq('B', "START"), date_B_friday) + assert_func(date_D_saturday.asfreq('B', "END"), date_B_monday) + assert_func(date_D_sunday.asfreq('B', "START"), date_B_friday) + assert_func(date_D_sunday.asfreq('B', "END"), date_B_monday) - assert_func(date_D.asfreq('H', "BEFORE"), date_D_to_H_before) - assert_func(date_D.asfreq('H', "AFTER"), date_D_to_H_after) - assert_func(date_D.asfreq('T', "BEFORE"), date_D_to_T_before) - assert_func(date_D.asfreq('T', "AFTER"), date_D_to_T_after) - assert_func(date_D.asfreq('S', "BEFORE"), date_D_to_S_before) - assert_func(date_D.asfreq('S', "AFTER"), date_D_to_S_after) + assert_func(date_D.asfreq('H', "START"), date_D_to_H_start) + assert_func(date_D.asfreq('H', "END"), date_D_to_H_end) + assert_func(date_D.asfreq('T', "START"), date_D_to_T_start) + assert_func(date_D.asfreq('T', "END"), date_D_to_T_end) + assert_func(date_D.asfreq('S', "START"), date_D_to_S_start) + assert_func(date_D.asfreq('S', "END"), date_D_to_S_end) def test_conv_hourly(self): "frequency conversion tests: from Hourly Frequency" @@ -701,13 +701,13 @@ date_H_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_H_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_H_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_H_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_H_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_H_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=59)) - date_H_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_H_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_H_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_H_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=59, second=59)) assert_func(date_H.asfreq('A'), date_H_to_A) @@ -723,10 +723,10 @@ assert_func(date_H.asfreq('B'), date_H_to_B) assert_func(date_H_end_of_bus.asfreq('B'), date_H_to_B) - assert_func(date_H.asfreq('T', "BEFORE"), date_H_to_T_before) - assert_func(date_H.asfreq('T', "AFTER"), date_H_to_T_after) - assert_func(date_H.asfreq('S', "BEFORE"), date_H_to_S_before) - assert_func(date_H.asfreq('S', "AFTER"), date_H_to_S_after) + assert_func(date_H.asfreq('T', "START"), date_H_to_T_start) + assert_func(date_H.asfreq('T', "END"), date_H_to_T_end) + assert_func(date_H.asfreq('S', "START"), date_H_to_S_start) + assert_func(date_H.asfreq('S', "END"), date_H_to_S_end) def test_conv_minutely(self): "frequency conversion tests: from Minutely Frequency" @@ -757,9 +757,9 @@ date_T_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) date_T_to_H = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_T_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_T_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_T_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_T_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=59)) assert_func(date_T.asfreq('A'), date_T_to_A) @@ -777,8 +777,8 @@ assert_func(date_T.asfreq('H'), date_T_to_H) assert_func(date_T_end_of_hour.asfreq('H'), date_T_to_H) - assert_func(date_T.asfreq('S', "BEFORE"), date_T_to_S_before) - assert_func(date_T.asfreq('S', "AFTER"), date_T_to_S_after) + assert_func(date_T.asfreq('S', "START"), date_T_to_S_start) + assert_func(date_T.asfreq('S', "END"), date_T_to_S_end) def test_conv_secondly(self): Modified: trunk/scipy/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/scipy/sandbox/timeseries/tests/test_timeseries.py 2007-11-25 17:34:13 UTC (rev 3590) +++ trunk/scipy/sandbox/timeseries/tests/test_timeseries.py 2007-11-25 17:47:23 UTC (rev 3591) @@ -411,9 +411,9 @@ lowToHigh_start = lowFreqSeries.convert('B', position='START') assert_equal(lowToHigh_start.start_date, - Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE")) + Date(freq='m', year=2005, month=6).asfreq("B", relation="START")) assert_equal(lowToHigh_start.end_date, - (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER")) + (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="END")) assert_equal(lowToHigh_start._mask[0], False) assert_equal(lowToHigh_start._mask[-1], True) @@ -421,9 +421,9 @@ lowToHigh_end = lowFreqSeries.convert('B', position='END') assert_equal(lowToHigh_end.start_date, - Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE")) + Date(freq='m', year=2005, month=6).asfreq("B", relation="START")) assert_equal(lowToHigh_end.end_date, - (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER")) + (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="END")) assert_equal(lowToHigh_end._mask[0], True) assert_equal(lowToHigh_end._mask[-1], False) Modified: trunk/scipy/sandbox/timeseries/tseries.py =================================================================== --- trunk/scipy/sandbox/timeseries/tseries.py 2007-11-25 17:34:13 UTC (rev 3590) +++ trunk/scipy/sandbox/timeseries/tseries.py 2007-11-25 17:47:23 UTC (rev 3591) @@ -688,7 +688,7 @@ """Returns the index corresponding to a given date, as an integer.""" return self._dates.date_to_index(date) #..................................................... - def asfreq(self, freq, relation="AFTER"): + def asfreq(self, freq, relation="END"): """Converts the dates portion of the TimeSeries to another frequency. The resulting TimeSeries will have the same shape and dimensions as the @@ -696,7 +696,7 @@ *Parameters*: freq : {freq_spec} - relation : {'AFTER', 'BEFORE'} , optional + relation : {'END', 'START'} (optional) *Returns*: a new TimeSeries with the .dates DateArray at the specified frequency (the @@ -1307,17 +1307,34 @@ def convert(series, freq, func=None, position='END', *args, **kwargs): """Converts a series to a frequency. Private function called by convert - When converting to a lower frequency, func is a function that acts - on a 1-d array and returns a scalar or 1-d array. func should handle - masked values appropriately. If func is None, then a 2D array is returned, - where each column represents the values appropriately grouped into the new - frequency. `position` will be ignored in this case. +*Parameters*: + series : {TimeSeries} + the series to convert. Skip this parameter if you are calling this as + a method of the TimeSeries object instead of the module function. + freq : {freq_spec} + Frequency to convert the TimeSeries to. Accepts any valid frequency + specification (string or integer) + func : {function} (optional) + When converting to a lower frequency, func is a function that acts on + one date's worth of data. func should handle masked values appropriately. + If func is None, then each data point in the resulting series will a + group of data points that fall into the date at the lower frequency. - When converting to a higher frequency, position is 'START' or 'END' - and determines where the data point is in each period (eg. if going - from monthly to daily, and position is 'END', then each data point is - placed at the end of the month). - """ + For example, if converting from monthly to daily and you wanted each + data point in the resulting series to be the average value for each + month, you could specify maskedarray.average for the 'func' parameter. + position : {'END', 'START'} (optional) + When converting to a higher frequency, position is 'START' or 'END' + and determines where the data point is in each period. For example, if + going from monthly to daily, and position is 'END', then each data + point is placed at the end of the month. + *args : {extra arguments for func parameter} (optional) + if a func is specified that requires additional parameters, specify + them here. + **kwargs : {extra keyword arguments for func parameter} (optional) + if a func is specified that requires additional keyword parameters, + specify them here. +""" if series.ndim == 1: obj = _convert1d(series, freq, func, position, *args, **kwargs) elif series.ndim == 2: @@ -1341,8 +1358,8 @@ def group_byperiod(series, freq, position='END'): """Converts a series to a frequency, without any processing. If the series - has missing data, it is first filled with masked data. Duplicate values in the - series will raise an exception. +has missing data, it is first filled with masked data. Duplicate values in the +series will raise an exception. """ if series.has_duplicated_dates(): raise TimeSeriesError("The input series must not have duplicated dates!") @@ -1357,16 +1374,16 @@ """Returns a series of the same size as `series`, with the same start_date and end_date, but values shifted by `nper`. -:Parameters: - - series : (TimeSeries) +*Parameters*: + series : {TimeSeries} TimeSeries object to shift - - nper : (int) + nper : {int} number of periods to shift. Negative numbers shift values to the right, positive to the left - - copy : (boolean, *[True]*) + copy : {True, False} (optional) copies the data if True, returns a view if False. -:Example: +*Example*: >>> series = time_series([0,1,2,3], start_date=Date(freq='A', year=2005)) >>> series timeseries(data = [0 1 2 3], @@ -1376,7 +1393,8 @@ timeseries(data = [-- 0 1 2], dates = [2005 ... 2008], freq = A-DEC) ->>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1)""" +>>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1) +""" newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if copy: @@ -1400,13 +1418,13 @@ def pct(series, nper=1): """Returns the rolling percentage change of the series. -:Parameters: - - series : (TimeSeries) +*Parameters*: + series : {TimeSeries} TimeSeries object to to calculate percentage chage for - - nper : (int) + nper : {int} number of periods for percentage change -:Example: +*Example*: >>> series = time_series([2.,1.,2.,3.], start_date=Date(freq='A', year=2005)) >>> pct(series) timeseries(data = [-- -50.0 100.0 50.0], @@ -1415,8 +1433,8 @@ >>> pct(series, 2) timeseries(data = [-- -- 0.0 200.0], dates = [2005 ... 2008], - freq = A-DEC)""" - + freq = A-DEC) +""" newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if nper < newdata.size: @@ -1427,21 +1445,23 @@ return newseries TimeSeries.pct = pct #............................................................................... -def fill_missing_dates(data, dates=None, freq=None,fill_value=None): - """Finds and fills the missing dates in a time series. -The data corresponding to the initially missing dates are masked, or filled to +def fill_missing_dates(data, dates=None, freq=None, fill_value=None): + """Finds and fills the missing dates in a time series. The data +corresponding to the initially missing dates are masked, or filled to `fill_value`. -:Parameters: - `data` +*Parameters*: + data : {TimeSeries, ndarray} Initial array of data. - `dates` - Initial array of dates. - `freq` : float *[None]* - New date resolutions. If *None*, the initial resolution is used instead. - `fill_value` : float *[None]* - Default value for missing data. If None, the data are just masked. - """ + dates : {DateArray} (optional) + Initial array of dates. Specify this if you are passing a plain ndarray + for the data instead of a TimeSeries. + freq : {freq_spec} (optional) + Frequency of result. If not specified, the initial frequency is used. + fill_value : {scalar of type data.dtype} (optional) + Default value for missing data. If Not specified, the data are just + masked. +""" # Check the frequency ........ orig_freq = freq freq = check_freq(freq) From scipy-svn at scipy.org Sun Nov 25 12:50:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 25 Nov 2007 11:50:16 -0600 (CST) Subject: [Scipy-svn] r3592 - branches/scipy.scons/scipy/special Message-ID: <20071125175016.6A84E39C10B@new.scipy.org> Author: cdavid Date: 2007-11-25 11:50:12 -0600 (Sun, 25 Nov 2007) New Revision: 3592 Modified: branches/scipy.scons/scipy/special/SConstruct Log: Fix fortran linking step for scons build of special Modified: branches/scipy.scons/scipy/special/SConstruct =================================================================== --- branches/scipy.scons/scipy/special/SConstruct 2007-11-25 17:47:23 UTC (rev 3591) +++ branches/scipy.scons/scipy/special/SConstruct 2007-11-25 17:50:12 UTC (rev 3592) @@ -1,12 +1,13 @@ # Last Change: Sat Nov 24 08:00 PM 2007 J # vim:syntax=python -from os.path import join as pjoin +from os.path import join as pjoin, basename as pbasename +import sys import glob -import sys from distutils.sysconfig import get_python_inc from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckF77Clib env = GetNumpyEnvironment(ARGUMENTS) @@ -18,20 +19,32 @@ # define_macros.append(('NONANS',None)) env.AppendUnique(CPPDEFINES = '_USE_MATH_DEFINES') -def build_lib(name, ext): +config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib}) +if not config.CheckF77Clib(): + raise RuntimeError("Could not get C/F77 runtime information") +config.Finish() + +def build_lib(name, ext, libname = None): """ext should be .f or .c""" - src = glob.glob(pjoin(name, '*%s' % ext)) - env.NumpyStaticExtLibrary(name, source = src) + if not libname: + libname = name + src = glob.glob(pjoin(env['src_dir'], name, '*%s' % ext)) + assert len(src) > 0 + env.NumpyStaticExtLibrary(libname, + source = [pjoin(name, + pbasename(i)) + for i in src]) # C libraries build_lib('c_misc', '.c') build_lib('cephes', '.c') # F libraries +# XXX: handle no opt flags for mach build_lib('mach', '.f') build_lib('toms', '.f') build_lib('amos', '.f') -build_lib('cdf', '.f') +build_lib('cdflib', '.f', 'cdf') build_lib('specfun', '.f') env.AppendUnique(LIBPATH = env['build_dir']) @@ -43,8 +56,10 @@ env.NumpyPythonExtension('_cephes', source = src, LIBS = ['amos', 'toms', 'c_misc', 'cephes', 'mach',\ - 'cdf', 'specfun']) + 'cdf', 'specfun'], + LINKFLAGSEND = env['F77_LDFLAGS']) # Specfun extension env.NumpyPythonExtension('specfun', source = 'specfun.pyf', LIBS = 'specfun', \ - F2PYOPTIONS = ["--no-wrap-functions"]) + F2PYOPTIONS = ["--no-wrap-functions"], + LINKFLAGSEND = env['F77_LDFLAGS']) From scipy-svn at scipy.org Sun Nov 25 12:51:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 25 Nov 2007 11:51:38 -0600 (CST) Subject: [Scipy-svn] r3593 - branches/scipy.scons/scipy Message-ID: <20071125175138.8320039C10B@new.scipy.org> Author: cdavid Date: 2007-11-25 11:51:34 -0600 (Sun, 25 Nov 2007) New Revision: 3593 Modified: branches/scipy.scons/scipy/setupscons.py Log: Add scons config info to scipy Modified: branches/scipy.scons/scipy/setupscons.py =================================================================== --- branches/scipy.scons/scipy/setupscons.py 2007-11-25 17:50:12 UTC (rev 3592) +++ branches/scipy.scons/scipy/setupscons.py 2007-11-25 17:51:34 UTC (rev 3593) @@ -23,7 +23,7 @@ #config.add_subpackage('stsci') config.add_subpackage('weave') config.make_svn_version_py() # installs __svn_version__.py - config.make_config_py() + config.scons_make_config_py() # installs __config__.py return config if __name__ == '__main__': From scipy-svn at scipy.org Mon Nov 26 00:32:18 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 25 Nov 2007 23:32:18 -0600 (CST) Subject: [Scipy-svn] r3594 - branches/scipy.scons/scipy/stats Message-ID: <20071126053218.6F69039C1B1@new.scipy.org> Author: cdavid Date: 2007-11-25 23:32:08 -0600 (Sun, 25 Nov 2007) New Revision: 3594 Added: branches/scipy.scons/scipy/stats/SConstruct Modified: branches/scipy.scons/scipy/stats/setupscons.py Log: stats now builds with scons Copied: branches/scipy.scons/scipy/stats/SConstruct (from rev 3593, branches/scipy.scons/scipy/special/SConstruct) =================================================================== --- branches/scipy.scons/scipy/special/SConstruct 2007-11-25 17:51:34 UTC (rev 3593) +++ branches/scipy.scons/scipy/stats/SConstruct 2007-11-26 05:32:08 UTC (rev 3594) @@ -0,0 +1,39 @@ +# Last Change: Mon Nov 26 02:00 PM 2007 J +# vim:syntax=python +from os.path import join as pjoin, basename as pbasename +import sys +import glob +from distutils.sysconfig import get_python_inc + +from numpy.distutils.misc_util import get_numpy_include_dirs +from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import CheckF77Clib + +env = GetNumpyEnvironment(ARGUMENTS) + +env.AppendUnique(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) + +config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib}) +if not config.CheckF77Clib(): + raise RuntimeError("Could not get C/F77 runtime information") +config.Finish() + +# Statlib library +src = glob.glob(pjoin(env['src_dir'], 'statlib', '*.f' )) +env.NumpyStaticExtLibrary('statlib', + source = [pjoin('statlib', pbasename(i)) for i in src]) + +env.AppendUnique(LIBPATH = env['build_dir']) + +# Statlib extension +env.NumpyPythonExtension('statlib', source = 'statlib.pyf', + F2PYOPTIONS = ["--no-wrap-functions"], + LIBS = 'statlib', + LINKFLAGSEND = env['F77_LDFLAGS']) + +# futil extension +futil_src = env.F2py(pjoin(env['build_dir'], 'futilmodule.c'), + pjoin(env['build_dir'], 'futil.f')) +env.NumpyPythonExtension('futil', source = futil_src + ['futil.f'], + LINKFLAGSEND = env['F77_LDFLAGS']) Modified: branches/scipy.scons/scipy/stats/setupscons.py =================================================================== --- branches/scipy.scons/scipy/stats/setupscons.py 2007-11-25 17:51:34 UTC (rev 3593) +++ branches/scipy.scons/scipy/stats/setupscons.py 2007-11-26 05:32:08 UTC (rev 3594) @@ -6,7 +6,7 @@ from numpy.distutils.misc_util import Configuration config = Configuration('stats', parent_package, top_path, setup_name = 'setupscons.py') - config.add_subpackage('models') + #config.add_subpackage('models') config.add_data_dir('tests') config.add_sconscript('SConstruct') From scipy-svn at scipy.org Mon Nov 26 00:33:45 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 25 Nov 2007 23:33:45 -0600 (CST) Subject: [Scipy-svn] r3595 - in branches/scipy.scons: . scipy/sandbox/timeseries scipy/sandbox/timeseries/src scipy/sandbox/timeseries/tests Message-ID: <20071126053345.D30F839C1B1@new.scipy.org> Author: cdavid Date: 2007-11-25 23:33:22 -0600 (Sun, 25 Nov 2007) New Revision: 3595 Modified: branches/scipy.scons/ branches/scipy.scons/scipy/sandbox/timeseries/dates.py branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py branches/scipy.scons/scipy/sandbox/timeseries/tseries.py Log: Merged revisions 3583-3593 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r3589 | pierregm | 2007-11-25 02:43:31 +0900 (Sun, 25 Nov 2007) | 1 line plotlib : fixed a bug in _daily_finder and _annual_finder ........ r3591 | mattknox_ca | 2007-11-26 02:47:23 +0900 (Mon, 26 Nov 2007) | 2 lines - changed relation parameter of asfreq functions/methods to accept 'START'/'END' ('BEFORE'/'AFTER' are now deprecated, but still work for now) - enhanced documentation for several functions ........ Property changes on: branches/scipy.scons ___________________________________________________________________ Name: svnmerge-integrated - /trunk:1-3582 + /trunk:1-3593 Modified: branches/scipy.scons/scipy/sandbox/timeseries/dates.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/dates.py 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/dates.py 2007-11-26 05:33:22 UTC (rev 3595) @@ -392,15 +392,35 @@ self._cachedinfo['tostr'] = tostr return self._cachedinfo['tostr'] # - def asfreq(self, freq=None, relation="AFTER"): - "Converts the dates to another frequency." + def asfreq(self, freq=None, relation="END"): + """Converts the dates to another frequency. + +*Parameters*: + freq : {freq_spec} + Frequency to convert the DateArray to. Accepts any valid frequency + specification (string or integer) + relation : {"END", "START"} (optional) + Applies only when converting a lower frequency Date to a higher + frequency Date, or when converting a weekend Date to a business + frequency Date. Valid values are 'START' and 'END'. + + For example, if converting a monthly date to a daily date, specifying + 'START' ('END') would result in the first (last) day in the month. +""" # Note: As we define a new object, we don't need caching if freq is None or freq == _c.FR_UND: return self tofreq = check_freq(freq) if tofreq == self.freq: return self + _rel = relation.upper()[0] + + # support for deprecated values of relation parameter ('BEFORE' and + # 'AFTER') + if _rel == 'A': _rel = 'E' + if _rel == 'B': _rel = 'S' + fromfreq = self.freq if fromfreq == _c.FR_UND: fromfreq = _c.FR_DAY Modified: branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py 2007-11-26 05:33:22 UTC (rev 3595) @@ -223,7 +223,7 @@ info['fmt'][first_label(month_start)] = '%d\n%b\n%Y' # Case 2. Less than three months elif span <= periodsperyear//4: - month_start = period_break(dates,'month') + month_start = period_break(dates_,'month') info['maj'][month_start] = True info['min'] = True if asformatter: @@ -287,7 +287,7 @@ info['fmt'][year_start] = '%Y' # Case 6. More than 12 years ................ else: - year_start = period_break(dates,'year') + year_start = period_break(dates_,'year') year_break = dates_[year_start].years nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) Modified: branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c 2007-11-26 05:33:22 UTC (rev 3595) @@ -427,7 +427,7 @@ /////////////////////////////////////////////// // frequency specifc conversion routines -// each function must take an integer fromDate and a char relation ('B' or 'A' for 'BEFORE' or 'AFTER') +// each function must take an integer fromDate and a char relation ('S' or 'E' for 'START' or 'END') //************ FROM DAILY *************** @@ -487,7 +487,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { + if (relation == 'S') { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); @@ -512,7 +512,7 @@ static long asfreq_DtoHIGHFREQ(long fromDate, char relation, long periodsPerDay) { if (fromDate >= HIGHFREQ_ORIG) { - if (relation == 'B') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; } + if (relation == 'S') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; } else { return (fromDate - HIGHFREQ_ORIG + 1)*(periodsPerDay); } } else { return -1; } } @@ -568,7 +568,7 @@ static long asfreq_TtoH(long fromDate, char relation, asfreq_info *af_info) { return (fromDate - 1)/60 + 1; } static long asfreq_TtoS(long fromDate, char relation, asfreq_info *af_info) { - if (relation == 'B') { return fromDate*60 - 59; } + if (relation == 'S') { return fromDate*60 - 59; } else { return fromDate*60; }} //************ FROM HOURLY *************** @@ -593,7 +593,7 @@ static long asfreq_HtoT(long fromDate, char relation, asfreq_info *af_info) { return asfreq_TtoS(fromDate, relation, &NULL_AF_INFO); } static long asfreq_HtoS(long fromDate, char relation, asfreq_info *af_info) { - if (relation == 'B') { return fromDate*60*60 - 60*60 + 1; } + if (relation == 'S') { return fromDate*60*60 - 60*60 + 1; } else { return fromDate*60*60; }} //************ FROM BUSINESS *************** @@ -625,16 +625,16 @@ //************ FROM WEEKLY *************** static long asfreq_WtoD(long fromDate, char relation, asfreq_info *af_info) { - if (relation == 'B') { return fromDate * 7 - 6 + af_info->from_week_end;} + if (relation == 'S') { return fromDate * 7 - 6 + af_info->from_week_end;} else { return fromDate * 7 + af_info->from_week_end; } } static long asfreq_WtoA(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } + return asfreq_DtoA(asfreq_WtoD(fromDate, 'E', af_info), relation, af_info); } static long asfreq_WtoQ(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } + return asfreq_DtoQ(asfreq_WtoD(fromDate, 'E', af_info), relation, af_info); } static long asfreq_WtoM(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); } + return asfreq_DtoM(asfreq_WtoD(fromDate, 'E', af_info), relation, &NULL_AF_INFO); } static long asfreq_WtoW(long fromDate, char relation, asfreq_info *af_info) { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, af_info); } @@ -645,7 +645,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -667,7 +667,7 @@ long y, m, absdate; - if (relation == 'B') { + if (relation == 'S') { MtoD_ym(fromDate, &y, &m); if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; @@ -679,10 +679,10 @@ } static long asfreq_MtoA(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoA(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); } + return asfreq_DtoA(asfreq_MtoD(fromDate, 'E', &NULL_AF_INFO), relation, af_info); } static long asfreq_MtoQ(long fromDate, char relation, asfreq_info *af_info) { - return asfreq_DtoQ(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); } + return asfreq_DtoQ(asfreq_MtoD(fromDate, 'E', &NULL_AF_INFO), relation, af_info); } static long asfreq_MtoW(long fromDate, char relation, asfreq_info *af_info) { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } @@ -693,7 +693,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -722,7 +722,7 @@ long y, m, absdate; - if (relation == 'B') { + if (relation == 'S') { QtoD_ym(fromDate, &y, &m, af_info); if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; @@ -751,7 +751,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -773,7 +773,7 @@ if (month == 0) { month = 1; } else { month += 1; } - if (relation == 'B') { + if (relation == 'S') { if (af_info->from_a_year_end == 12) {year = fromDate;} else {year = fromDate - 1;} final_adj = 0; @@ -805,7 +805,7 @@ if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_AtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -1034,7 +1034,7 @@ return 24*60*60 - 1; } - startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay); + startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'S', periodsPerDay); return (24*60*60)*((double)(originalDate - startOfDay))/((double)periodsPerDay); } @@ -1569,20 +1569,20 @@ toDaily = get_asfreq_func(self->freq, FR_DAY, 0); get_asfreq_info(self->freq, FR_DAY, &af_info); - return PyInt_FromLong(toDaily(self->value, 'A', &af_info)); + return PyInt_FromLong(toDaily(self->value, 'E', &af_info)); } } static char DateObject_asfreq_doc[] = "Returns a date converted to a specified frequency.\n\n" -":Parameters:\n" -" - freq : string/int\n" -" Frequency to convert the Date to. Accepts any valid frequency\n" -" specification (string or integer)\n" -" - relation :string *['After']*\n" -" Applies only when converting a lower frequency Date to a higher\n" -" frequency Date, or when converting a weekend Date to a business\n" -" frequency Date. Valid values are 'before', 'after', 'b', and 'a'."; +"*Parameters*:\n" +" freq : {freq_spec}\n" +" Frequency to convert the Date to. Accepts any valid frequency\n" +" specification (string or integer)\n" +" relation : {'END', 'START'} (optional)\n" +" Applies only when converting a lower frequency Date to a higher\n" +" frequency Date, or when converting a weekend Date to a business\n" +" frequency Date. Valid values are 'START' and 'END'."; static PyObject * DateObject_asfreq(DateObject *self, PyObject *args, PyObject *kwds) { @@ -1609,12 +1609,17 @@ if((relation_uc = str_uppercase(relation_raw)) == NULL) {return PyErr_NoMemory();} - if (strcmp(relation_uc, "BEFORE") == 0 || + // 'BEFORE' and 'AFTER' values for this parameter are deprecated + if (strcmp(relation_uc, "END") == 0 || + strcmp(relation_uc, "E") == 0 || + strcmp(relation_uc, "START") == 0 || + strcmp(relation_uc, "S") == 0 || + strcmp(relation_uc, "BEFORE") == 0 || strcmp(relation_uc, "B") == 0 || strcmp(relation_uc, "AFTER") == 0 || strcmp(relation_uc, "A") == 0) { - if(relation_uc[0] == 'A') { relation = 'A'; } - else { relation = 'B'; } + if(relation_uc[0] == 'E' || relation_uc[0] == 'A') { relation = 'E'; } + else { relation = 'S'; } } else { invalid_relation=1; } @@ -1629,7 +1634,7 @@ return NULL; } } else { - relation = 'A'; + relation = 'E'; } if ((toFreq = check_freq(freq)) == INT_ERR_CODE) return NULL; @@ -1697,7 +1702,7 @@ toDaily = get_asfreq_func(self->freq, FR_DAY, 0); get_asfreq_info(self->freq, FR_DAY, &af_info); - absdate = toDaily(self->value, 'A', &af_info); + absdate = toDaily(self->value, 'E', &af_info); abstime = getAbsTime(self->freq, absdate, self->value); if(dInfoCalc_SetFromAbsDateTime(&tempDate, absdate, abstime, @@ -2384,7 +2389,7 @@ get_asfreq_info(FR_SEC, freq_val, &af_info); asfreq_func = get_asfreq_func(FR_SEC, freq_val, 0); - date_val = asfreq_func(secondly_date->value, 'B', &af_info); + date_val = asfreq_func(secondly_date->value, 'S', &af_info); Py_DECREF(secondly_date); Modified: branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c 2007-11-26 05:33:22 UTC (rev 3595) @@ -167,11 +167,11 @@ { case 'S': // start -> before - relation = 'B'; + relation = 'S'; break; case 'E': // end -> after - relation = 'A'; + relation = 'E'; break; default: return NULL; @@ -184,16 +184,16 @@ asfreq_endpoints = get_asfreq_func(fromFreq, toFreq, 0); //convert start index to new frequency - CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B', &af_info)); + CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'S', &af_info)); if (newStartTemp < 1) { - CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A', &af_info)); + CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'E', &af_info)); } else { newStart = newStartTemp; } //convert end index to new frequency - CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A', &af_info)); + CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'E', &af_info)); if (newEndTemp < 1) { - CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B', &af_info)); + CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'S', &af_info)); } else { newEnd = newEndTemp; } @@ -212,7 +212,7 @@ get_asfreq_info(toFreq, fromFreq, &af_info_rev); asfreq_reverse = get_asfreq_func(toFreq, fromFreq, 0); - CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B', &af_info_rev)); + CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'S', &af_info_rev)); currPerLen = startIndex - tempval; nd = 2; Modified: branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py 2007-11-26 05:33:22 UTC (rev 3595) @@ -263,61 +263,61 @@ date_AJUN = dWrap(Date(freq=C.FR_ANNJUN, year=2007)) date_ANOV = dWrap(Date(freq=C.FR_ANNNOV, year=2007)) - date_A_to_Q_before = dWrap(Date(freq='Q', year=2007, quarter=1)) - date_A_to_Q_after = dWrap(Date(freq='Q', year=2007, quarter=4)) - date_A_to_M_before = dWrap(Date(freq='M', year=2007, month=1)) - date_A_to_M_after = dWrap(Date(freq='M', year=2007, month=12)) - date_A_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) - date_A_to_W_after = dWrap(Date(freq='W', year=2007, month=12, day=31)) - date_A_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_A_to_B_after = dWrap(Date(freq='B', year=2007, month=12, day=31)) - date_A_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_A_to_D_after = dWrap(Date(freq='D', year=2007, month=12, day=31)) - date_A_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_A_to_Q_start = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_A_to_Q_end = dWrap(Date(freq='Q', year=2007, quarter=4)) + date_A_to_M_start = dWrap(Date(freq='M', year=2007, month=1)) + date_A_to_M_end = dWrap(Date(freq='M', year=2007, month=12)) + date_A_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_A_to_W_end = dWrap(Date(freq='W', year=2007, month=12, day=31)) + date_A_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_A_to_B_end = dWrap(Date(freq='B', year=2007, month=12, day=31)) + date_A_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_A_to_D_end = dWrap(Date(freq='D', year=2007, month=12, day=31)) + date_A_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_A_to_H_after = dWrap(Date(freq='H', year=2007, month=12, day=31, + date_A_to_H_end = dWrap(Date(freq='H', year=2007, month=12, day=31, hour=23)) - date_A_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_A_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_A_to_T_after = dWrap(Date(freq='T', year=2007, month=12, day=31, + date_A_to_T_end = dWrap(Date(freq='T', year=2007, month=12, day=31, hour=23, minute=59)) - date_A_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_A_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_A_to_S_after = dWrap(Date(freq='S', year=2007, month=12, day=31, + date_A_to_S_end = dWrap(Date(freq='S', year=2007, month=12, day=31, hour=23, minute=59, second=59)) - date_AJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31)) - date_AJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1)) - date_AJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=6, day=30)) - date_AJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1)) - date_ANOV_to_D_after = dWrap(Date(freq='D', year=2007, month=11, day=30)) - date_ANOV_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=1)) + date_AJAN_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=31)) + date_AJAN_to_D_start = dWrap(Date(freq='D', year=2006, month=2, day=1)) + date_AJUN_to_D_end = dWrap(Date(freq='D', year=2007, month=6, day=30)) + date_AJUN_to_D_start = dWrap(Date(freq='D', year=2006, month=7, day=1)) + date_ANOV_to_D_end = dWrap(Date(freq='D', year=2007, month=11, day=30)) + date_ANOV_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=1)) - assert_func(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) - assert_func(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) - assert_func(date_A.asfreq('M', "BEFORE"), date_A_to_M_before) - assert_func(date_A.asfreq('M', "AFTER"), date_A_to_M_after) - assert_func(date_A.asfreq('W', "BEFORE"), date_A_to_W_before) - assert_func(date_A.asfreq('W', "AFTER"), date_A_to_W_after) - assert_func(date_A.asfreq('B', "BEFORE"), date_A_to_B_before) - assert_func(date_A.asfreq('B', "AFTER"), date_A_to_B_after) - assert_func(date_A.asfreq('D', "BEFORE"), date_A_to_D_before) - assert_func(date_A.asfreq('D', "AFTER"), date_A_to_D_after) - assert_func(date_A.asfreq('H', "BEFORE"), date_A_to_H_before) - assert_func(date_A.asfreq('H', "AFTER"), date_A_to_H_after) - assert_func(date_A.asfreq('T', "BEFORE"), date_A_to_T_before) - assert_func(date_A.asfreq('T', "AFTER"), date_A_to_T_after) - assert_func(date_A.asfreq('S', "BEFORE"), date_A_to_S_before) - assert_func(date_A.asfreq('S', "AFTER"), date_A_to_S_after) + assert_func(date_A.asfreq('Q', "START"), date_A_to_Q_start) + assert_func(date_A.asfreq('Q', "END"), date_A_to_Q_end) + assert_func(date_A.asfreq('M', "START"), date_A_to_M_start) + assert_func(date_A.asfreq('M', "END"), date_A_to_M_end) + assert_func(date_A.asfreq('W', "START"), date_A_to_W_start) + assert_func(date_A.asfreq('W', "END"), date_A_to_W_end) + assert_func(date_A.asfreq('B', "START"), date_A_to_B_start) + assert_func(date_A.asfreq('B', "END"), date_A_to_B_end) + assert_func(date_A.asfreq('D', "START"), date_A_to_D_start) + assert_func(date_A.asfreq('D', "END"), date_A_to_D_end) + assert_func(date_A.asfreq('H', "START"), date_A_to_H_start) + assert_func(date_A.asfreq('H', "END"), date_A_to_H_end) + assert_func(date_A.asfreq('T', "START"), date_A_to_T_start) + assert_func(date_A.asfreq('T', "END"), date_A_to_T_end) + assert_func(date_A.asfreq('S', "START"), date_A_to_S_start) + assert_func(date_A.asfreq('S', "END"), date_A_to_S_end) - assert_func(date_AJAN.asfreq('D', "BEFORE"), date_AJAN_to_D_before) - assert_func(date_AJAN.asfreq('D', "AFTER"), date_AJAN_to_D_after) + assert_func(date_AJAN.asfreq('D', "START"), date_AJAN_to_D_start) + assert_func(date_AJAN.asfreq('D', "END"), date_AJAN_to_D_end) - assert_func(date_AJUN.asfreq('D', "BEFORE"), date_AJUN_to_D_before) - assert_func(date_AJUN.asfreq('D', "AFTER"), date_AJUN_to_D_after) + assert_func(date_AJUN.asfreq('D', "START"), date_AJUN_to_D_start) + assert_func(date_AJUN.asfreq('D', "END"), date_AJUN_to_D_end) - assert_func(date_ANOV.asfreq('D', "BEFORE"), date_ANOV_to_D_before) - assert_func(date_ANOV.asfreq('D', "AFTER"), date_ANOV_to_D_after) + assert_func(date_ANOV.asfreq('D', "START"), date_ANOV_to_D_start) + assert_func(date_ANOV.asfreq('D', "END"), date_ANOV_to_D_end) def test_conv_quarterly(self): "frequency conversion tests: from Quarterly Frequency" @@ -334,71 +334,71 @@ date_QSDEC = dWrap(Date(freq=C.FR_QTRSDEC, year=2007, quarter=1)) date_Q_to_A = dWrap(Date(freq='A', year=2007)) - date_Q_to_M_before = dWrap(Date(freq='M', year=2007, month=1)) - date_Q_to_M_after = dWrap(Date(freq='M', year=2007, month=3)) - date_Q_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) - date_Q_to_W_after = dWrap(Date(freq='W', year=2007, month=3, day=31)) - date_Q_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_Q_to_B_after = dWrap(Date(freq='B', year=2007, month=3, day=30)) - date_Q_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_Q_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31)) - date_Q_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_Q_to_M_start = dWrap(Date(freq='M', year=2007, month=1)) + date_Q_to_M_end = dWrap(Date(freq='M', year=2007, month=3)) + date_Q_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_Q_to_W_end = dWrap(Date(freq='W', year=2007, month=3, day=31)) + date_Q_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_Q_to_B_end = dWrap(Date(freq='B', year=2007, month=3, day=30)) + date_Q_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_Q_to_D_end = dWrap(Date(freq='D', year=2007, month=3, day=31)) + date_Q_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_Q_to_H_after = dWrap(Date(freq='H', year=2007, month=3, day=31, + date_Q_to_H_end = dWrap(Date(freq='H', year=2007, month=3, day=31, hour=23)) - date_Q_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_Q_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_Q_to_T_after = dWrap(Date(freq='T', year=2007, month=3, day=31, + date_Q_to_T_end = dWrap(Date(freq='T', year=2007, month=3, day=31, hour=23, minute=59)) - date_Q_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_Q_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_Q_to_S_after = dWrap(Date(freq='S', year=2007, month=3, day=31, + date_Q_to_S_end = dWrap(Date(freq='S', year=2007, month=3, day=31, hour=23, minute=59, second=59)) - date_QEJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1)) - date_QEJAN_to_D_after = dWrap(Date(freq='D', year=2006, month=4, day=30)) + date_QEJAN_to_D_start = dWrap(Date(freq='D', year=2006, month=2, day=1)) + date_QEJAN_to_D_end = dWrap(Date(freq='D', year=2006, month=4, day=30)) - date_QEJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1)) - date_QEJUN_to_D_after = dWrap(Date(freq='D', year=2006, month=9, day=30)) + date_QEJUN_to_D_start = dWrap(Date(freq='D', year=2006, month=7, day=1)) + date_QEJUN_to_D_end = dWrap(Date(freq='D', year=2006, month=9, day=30)) - date_QSJAN_to_D_before = dWrap(Date(freq='D', year=2007, month=2, day=1)) - date_QSJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=4, day=30)) + date_QSJAN_to_D_start = dWrap(Date(freq='D', year=2007, month=2, day=1)) + date_QSJAN_to_D_end = dWrap(Date(freq='D', year=2007, month=4, day=30)) - date_QSJUN_to_D_before = dWrap(Date(freq='D', year=2007, month=7, day=1)) - date_QSJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=9, day=30)) + date_QSJUN_to_D_start = dWrap(Date(freq='D', year=2007, month=7, day=1)) + date_QSJUN_to_D_end = dWrap(Date(freq='D', year=2007, month=9, day=30)) - date_QSDEC_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_QSDEC_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31)) + date_QSDEC_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_QSDEC_to_D_end = dWrap(Date(freq='D', year=2007, month=3, day=31)) assert_func(date_Q.asfreq('A'), date_Q_to_A) assert_func(date_Q_end_of_year.asfreq('A'), date_Q_to_A) - assert_func(date_Q.asfreq('M', "BEFORE"), date_Q_to_M_before) - assert_func(date_Q.asfreq('M', "AFTER"), date_Q_to_M_after) - assert_func(date_Q.asfreq('W', "BEFORE"), date_Q_to_W_before) - assert_func(date_Q.asfreq('W', "AFTER"), date_Q_to_W_after) - assert_func(date_Q.asfreq('B', "BEFORE"), date_Q_to_B_before) - assert_func(date_Q.asfreq('B', "AFTER"), date_Q_to_B_after) - assert_func(date_Q.asfreq('D', "BEFORE"), date_Q_to_D_before) - assert_func(date_Q.asfreq('D', "AFTER"), date_Q_to_D_after) - assert_func(date_Q.asfreq('H', "BEFORE"), date_Q_to_H_before) - assert_func(date_Q.asfreq('H', "AFTER"), date_Q_to_H_after) - assert_func(date_Q.asfreq('T', "BEFORE"), date_Q_to_T_before) - assert_func(date_Q.asfreq('T', "AFTER"), date_Q_to_T_after) - assert_func(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before) - assert_func(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after) + assert_func(date_Q.asfreq('M', "START"), date_Q_to_M_start) + assert_func(date_Q.asfreq('M', "END"), date_Q_to_M_end) + assert_func(date_Q.asfreq('W', "START"), date_Q_to_W_start) + assert_func(date_Q.asfreq('W', "END"), date_Q_to_W_end) + assert_func(date_Q.asfreq('B', "START"), date_Q_to_B_start) + assert_func(date_Q.asfreq('B', "END"), date_Q_to_B_end) + assert_func(date_Q.asfreq('D', "START"), date_Q_to_D_start) + assert_func(date_Q.asfreq('D', "END"), date_Q_to_D_end) + assert_func(date_Q.asfreq('H', "START"), date_Q_to_H_start) + assert_func(date_Q.asfreq('H', "END"), date_Q_to_H_end) + assert_func(date_Q.asfreq('T', "START"), date_Q_to_T_start) + assert_func(date_Q.asfreq('T', "END"), date_Q_to_T_end) + assert_func(date_Q.asfreq('S', "START"), date_Q_to_S_start) + assert_func(date_Q.asfreq('S', "END"), date_Q_to_S_end) - assert_func(date_QEJAN.asfreq('D', "BEFORE"), date_QEJAN_to_D_before) - assert_func(date_QEJAN.asfreq('D', "AFTER"), date_QEJAN_to_D_after) - assert_func(date_QEJUN.asfreq('D', "BEFORE"), date_QEJUN_to_D_before) - assert_func(date_QEJUN.asfreq('D', "AFTER"), date_QEJUN_to_D_after) + assert_func(date_QEJAN.asfreq('D', "START"), date_QEJAN_to_D_start) + assert_func(date_QEJAN.asfreq('D', "END"), date_QEJAN_to_D_end) + assert_func(date_QEJUN.asfreq('D', "START"), date_QEJUN_to_D_start) + assert_func(date_QEJUN.asfreq('D', "END"), date_QEJUN_to_D_end) - assert_func(date_QSJAN.asfreq('D', "BEFORE"), date_QSJAN_to_D_before) - assert_func(date_QSJAN.asfreq('D', "AFTER"), date_QSJAN_to_D_after) - assert_func(date_QSJUN.asfreq('D', "BEFORE"), date_QSJUN_to_D_before) - assert_func(date_QSJUN.asfreq('D', "AFTER"), date_QSJUN_to_D_after) - assert_func(date_QSDEC.asfreq('D', "BEFORE"), date_QSDEC_to_D_before) - assert_func(date_QSDEC.asfreq('D', "AFTER"), date_QSDEC_to_D_after) + assert_func(date_QSJAN.asfreq('D', "START"), date_QSJAN_to_D_start) + assert_func(date_QSJAN.asfreq('D', "END"), date_QSJAN_to_D_end) + assert_func(date_QSJUN.asfreq('D', "START"), date_QSJUN_to_D_start) + assert_func(date_QSJUN.asfreq('D', "END"), date_QSJUN_to_D_end) + assert_func(date_QSDEC.asfreq('D', "START"), date_QSDEC_to_D_start) + assert_func(date_QSDEC.asfreq('D', "END"), date_QSDEC_to_D_end) def test_conv_monthly(self): "frequency conversion tests: from Monthly Frequency" @@ -409,23 +409,23 @@ date_M_end_of_quarter = dWrap(Date(freq='M', year=2007, month=3)) date_M_to_A = dWrap(Date(freq='A', year=2007)) date_M_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) - date_M_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) - date_M_to_W_after = dWrap(Date(freq='W', year=2007, month=1, day=31)) - date_M_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_M_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=31)) - date_M_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_M_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31)) - date_M_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_M_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_M_to_W_end = dWrap(Date(freq='W', year=2007, month=1, day=31)) + date_M_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_M_to_B_end = dWrap(Date(freq='B', year=2007, month=1, day=31)) + date_M_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_M_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=31)) + date_M_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_M_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=31, + date_M_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=31, hour=23)) - date_M_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_M_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_M_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=31, + date_M_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=31, hour=23, minute=59)) - date_M_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_M_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_M_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=31, + date_M_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=31, hour=23, minute=59, second=59)) assert_func(date_M.asfreq('A'), date_M_to_A) @@ -433,18 +433,18 @@ assert_func(date_M.asfreq('Q'), date_M_to_Q) assert_func(date_M_end_of_quarter.asfreq('Q'), date_M_to_Q) - assert_func(date_M.asfreq('W', "BEFORE"), date_M_to_W_before) - assert_func(date_M.asfreq('W', "AFTER"), date_M_to_W_after) - assert_func(date_M.asfreq('B', "BEFORE"), date_M_to_B_before) - assert_func(date_M.asfreq('B', "AFTER"), date_M_to_B_after) - assert_func(date_M.asfreq('D', "BEFORE"), date_M_to_D_before) - assert_func(date_M.asfreq('D', "AFTER"), date_M_to_D_after) - assert_func(date_M.asfreq('H', "BEFORE"), date_M_to_H_before) - assert_func(date_M.asfreq('H', "AFTER"), date_M_to_H_after) - assert_func(date_M.asfreq('T', "BEFORE"), date_M_to_T_before) - assert_func(date_M.asfreq('T', "AFTER"), date_M_to_T_after) - assert_func(date_M.asfreq('S', "BEFORE"), date_M_to_S_before) - assert_func(date_M.asfreq('S', "AFTER"), date_M_to_S_after) + assert_func(date_M.asfreq('W', "START"), date_M_to_W_start) + assert_func(date_M.asfreq('W', "END"), date_M_to_W_end) + assert_func(date_M.asfreq('B', "START"), date_M_to_B_start) + assert_func(date_M.asfreq('B', "END"), date_M_to_B_end) + assert_func(date_M.asfreq('D', "START"), date_M_to_D_start) + assert_func(date_M.asfreq('D', "END"), date_M_to_D_end) + assert_func(date_M.asfreq('H', "START"), date_M_to_H_start) + assert_func(date_M.asfreq('H', "END"), date_M_to_H_end) + assert_func(date_M.asfreq('T', "START"), date_M_to_T_start) + assert_func(date_M.asfreq('T', "END"), date_M_to_T_end) + assert_func(date_M.asfreq('S', "START"), date_M_to_S_start) + assert_func(date_M.asfreq('S', "END"), date_M_to_S_end) def test_conv_weekly(self): @@ -461,20 +461,20 @@ date_WTUE = dWrap(Date(freq='W-TUE', year=2007, month=1, day=2)) date_WMON = dWrap(Date(freq='W-MON', year=2007, month=1, day=1)) - date_WSUN_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_WSUN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7)) - date_WSAT_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=31)) - date_WSAT_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=6)) - date_WFRI_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=30)) - date_WFRI_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=5)) - date_WTHU_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=29)) - date_WTHU_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=4)) - date_WWED_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=28)) - date_WWED_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=3)) - date_WTUE_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=27)) - date_WTUE_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=2)) - date_WMON_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=26)) - date_WMON_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_WSUN_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_WSUN_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=7)) + date_WSAT_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=31)) + date_WSAT_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=6)) + date_WFRI_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=30)) + date_WFRI_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=5)) + date_WTHU_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=29)) + date_WTHU_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=4)) + date_WWED_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=28)) + date_WWED_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=3)) + date_WTUE_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=27)) + date_WTUE_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=2)) + date_WMON_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=26)) + date_WMON_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_W_end_of_year = dWrap(Date(freq='W', year=2007, month=12, day=31)) date_W_end_of_quarter = dWrap(Date(freq='W', year=2007, month=3, day=31)) @@ -498,21 +498,21 @@ else: date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=2)) - date_W_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_W_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=5)) - date_W_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_W_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7)) - date_W_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_W_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1)) + date_W_to_B_end = dWrap(Date(freq='B', year=2007, month=1, day=5)) + date_W_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_W_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=7)) + date_W_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_W_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=7, + date_W_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=7, hour=23)) - date_W_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_W_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_W_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=7, + date_W_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=7, hour=23, minute=59)) - date_W_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_W_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_W_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=7, + date_W_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=7, hour=23, minute=59, second=59)) assert_func(date_W.asfreq('A'), date_W_to_A) @@ -522,33 +522,33 @@ assert_func(date_W.asfreq('M'), date_W_to_M) assert_func(date_W_end_of_month.asfreq('M'), date_W_to_M_end_of_month) - assert_func(date_W.asfreq('B', "BEFORE"), date_W_to_B_before) - assert_func(date_W.asfreq('B', "AFTER"), date_W_to_B_after) + assert_func(date_W.asfreq('B', "START"), date_W_to_B_start) + assert_func(date_W.asfreq('B', "END"), date_W_to_B_end) - assert_func(date_W.asfreq('D', "BEFORE"), date_W_to_D_before) - assert_func(date_W.asfreq('D', "AFTER"), date_W_to_D_after) + assert_func(date_W.asfreq('D', "START"), date_W_to_D_start) + assert_func(date_W.asfreq('D', "END"), date_W_to_D_end) - assert_func(date_WSUN.asfreq('D', "BEFORE"), date_WSUN_to_D_before) - assert_func(date_WSUN.asfreq('D', "AFTER"), date_WSUN_to_D_after) - assert_func(date_WSAT.asfreq('D', "BEFORE"), date_WSAT_to_D_before) - assert_func(date_WSAT.asfreq('D', "AFTER"), date_WSAT_to_D_after) - assert_func(date_WFRI.asfreq('D', "BEFORE"), date_WFRI_to_D_before) - assert_func(date_WFRI.asfreq('D', "AFTER"), date_WFRI_to_D_after) - assert_func(date_WTHU.asfreq('D', "BEFORE"), date_WTHU_to_D_before) - assert_func(date_WTHU.asfreq('D', "AFTER"), date_WTHU_to_D_after) - assert_func(date_WWED.asfreq('D', "BEFORE"), date_WWED_to_D_before) - assert_func(date_WWED.asfreq('D', "AFTER"), date_WWED_to_D_after) - assert_func(date_WTUE.asfreq('D', "BEFORE"), date_WTUE_to_D_before) - assert_func(date_WTUE.asfreq('D', "AFTER"), date_WTUE_to_D_after) - assert_func(date_WMON.asfreq('D', "BEFORE"), date_WMON_to_D_before) - assert_func(date_WMON.asfreq('D', "AFTER"), date_WMON_to_D_after) + assert_func(date_WSUN.asfreq('D', "START"), date_WSUN_to_D_start) + assert_func(date_WSUN.asfreq('D', "END"), date_WSUN_to_D_end) + assert_func(date_WSAT.asfreq('D', "START"), date_WSAT_to_D_start) + assert_func(date_WSAT.asfreq('D', "END"), date_WSAT_to_D_end) + assert_func(date_WFRI.asfreq('D', "START"), date_WFRI_to_D_start) + assert_func(date_WFRI.asfreq('D', "END"), date_WFRI_to_D_end) + assert_func(date_WTHU.asfreq('D', "START"), date_WTHU_to_D_start) + assert_func(date_WTHU.asfreq('D', "END"), date_WTHU_to_D_end) + assert_func(date_WWED.asfreq('D', "START"), date_WWED_to_D_start) + assert_func(date_WWED.asfreq('D', "END"), date_WWED_to_D_end) + assert_func(date_WTUE.asfreq('D', "START"), date_WTUE_to_D_start) + assert_func(date_WTUE.asfreq('D', "END"), date_WTUE_to_D_end) + assert_func(date_WMON.asfreq('D', "START"), date_WMON_to_D_start) + assert_func(date_WMON.asfreq('D', "END"), date_WMON_to_D_end) - assert_func(date_W.asfreq('H', "BEFORE"), date_W_to_H_before) - assert_func(date_W.asfreq('H', "AFTER"), date_W_to_H_after) - assert_func(date_W.asfreq('T', "BEFORE"), date_W_to_T_before) - assert_func(date_W.asfreq('T', "AFTER"), date_W_to_T_after) - assert_func(date_W.asfreq('S', "BEFORE"), date_W_to_S_before) - assert_func(date_W.asfreq('S', "AFTER"), date_W_to_S_after) + assert_func(date_W.asfreq('H', "START"), date_W_to_H_start) + assert_func(date_W.asfreq('H', "END"), date_W_to_H_end) + assert_func(date_W.asfreq('T', "START"), date_W_to_T_start) + assert_func(date_W.asfreq('T', "END"), date_W_to_T_end) + assert_func(date_W.asfreq('S', "START"), date_W_to_S_start) + assert_func(date_W.asfreq('S', "END"), date_W_to_S_end) def test_conv_business(self): "frequency conversion tests: from Business Frequency" @@ -565,17 +565,17 @@ date_B_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_B_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) date_B_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_B_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_B_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_B_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_B_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_B_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_B_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_B_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_B_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_B_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_B_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_B_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_B_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) assert_func(date_B.asfreq('A'), date_B_to_A) @@ -589,12 +589,12 @@ assert_func(date_B.asfreq('D'), date_B_to_D) - assert_func(date_B.asfreq('H', "BEFORE"), date_B_to_H_before) - assert_func(date_B.asfreq('H', "AFTER"), date_B_to_H_after) - assert_func(date_B.asfreq('T', "BEFORE"), date_B_to_T_before) - assert_func(date_B.asfreq('T', "AFTER"), date_B_to_T_after) - assert_func(date_B.asfreq('S', "BEFORE"), date_B_to_S_before) - assert_func(date_B.asfreq('S', "AFTER"), date_B_to_S_after) + assert_func(date_B.asfreq('H', "START"), date_B_to_H_start) + assert_func(date_B.asfreq('H', "END"), date_B_to_H_end) + assert_func(date_B.asfreq('T', "START"), date_B_to_T_start) + assert_func(date_B.asfreq('T', "END"), date_B_to_T_end) + assert_func(date_B.asfreq('S', "START"), date_B_to_S_start) + assert_func(date_B.asfreq('S', "END"), date_B_to_S_end) def test_conv_daily(self): "frequency conversion tests: from Business Frequency" @@ -631,17 +631,17 @@ date_D_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_D_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) - date_D_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_D_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_D_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_D_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_D_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_D_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_D_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_D_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_D_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_D_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_D_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_D_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) assert_func(date_D.asfreq('A'), date_D_to_A) @@ -664,17 +664,17 @@ assert_func(date_D_end_of_week.asfreq('W'), date_D_to_W) assert_func(date_D_friday.asfreq('B'), date_B_friday) - assert_func(date_D_saturday.asfreq('B', "BEFORE"), date_B_friday) - assert_func(date_D_saturday.asfreq('B', "AFTER"), date_B_monday) - assert_func(date_D_sunday.asfreq('B', "BEFORE"), date_B_friday) - assert_func(date_D_sunday.asfreq('B', "AFTER"), date_B_monday) + assert_func(date_D_saturday.asfreq('B', "START"), date_B_friday) + assert_func(date_D_saturday.asfreq('B', "END"), date_B_monday) + assert_func(date_D_sunday.asfreq('B', "START"), date_B_friday) + assert_func(date_D_sunday.asfreq('B', "END"), date_B_monday) - assert_func(date_D.asfreq('H', "BEFORE"), date_D_to_H_before) - assert_func(date_D.asfreq('H', "AFTER"), date_D_to_H_after) - assert_func(date_D.asfreq('T', "BEFORE"), date_D_to_T_before) - assert_func(date_D.asfreq('T', "AFTER"), date_D_to_T_after) - assert_func(date_D.asfreq('S', "BEFORE"), date_D_to_S_before) - assert_func(date_D.asfreq('S', "AFTER"), date_D_to_S_after) + assert_func(date_D.asfreq('H', "START"), date_D_to_H_start) + assert_func(date_D.asfreq('H', "END"), date_D_to_H_end) + assert_func(date_D.asfreq('T', "START"), date_D_to_T_start) + assert_func(date_D.asfreq('T', "END"), date_D_to_T_end) + assert_func(date_D.asfreq('S', "START"), date_D_to_S_start) + assert_func(date_D.asfreq('S', "END"), date_D_to_S_end) def test_conv_hourly(self): "frequency conversion tests: from Hourly Frequency" @@ -701,13 +701,13 @@ date_H_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_H_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_H_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_H_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_H_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_H_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=59)) - date_H_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_H_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_H_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_H_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=59, second=59)) assert_func(date_H.asfreq('A'), date_H_to_A) @@ -723,10 +723,10 @@ assert_func(date_H.asfreq('B'), date_H_to_B) assert_func(date_H_end_of_bus.asfreq('B'), date_H_to_B) - assert_func(date_H.asfreq('T', "BEFORE"), date_H_to_T_before) - assert_func(date_H.asfreq('T', "AFTER"), date_H_to_T_after) - assert_func(date_H.asfreq('S', "BEFORE"), date_H_to_S_before) - assert_func(date_H.asfreq('S', "AFTER"), date_H_to_S_after) + assert_func(date_H.asfreq('T', "START"), date_H_to_T_start) + assert_func(date_H.asfreq('T', "END"), date_H_to_T_end) + assert_func(date_H.asfreq('S', "START"), date_H_to_S_start) + assert_func(date_H.asfreq('S', "END"), date_H_to_S_end) def test_conv_minutely(self): "frequency conversion tests: from Minutely Frequency" @@ -757,9 +757,9 @@ date_T_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) date_T_to_H = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_T_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_T_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_T_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_T_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=59)) assert_func(date_T.asfreq('A'), date_T_to_A) @@ -777,8 +777,8 @@ assert_func(date_T.asfreq('H'), date_T_to_H) assert_func(date_T_end_of_hour.asfreq('H'), date_T_to_H) - assert_func(date_T.asfreq('S', "BEFORE"), date_T_to_S_before) - assert_func(date_T.asfreq('S', "AFTER"), date_T_to_S_after) + assert_func(date_T.asfreq('S', "START"), date_T_to_S_start) + assert_func(date_T.asfreq('S', "END"), date_T_to_S_end) def test_conv_secondly(self): Modified: branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py 2007-11-26 05:33:22 UTC (rev 3595) @@ -411,9 +411,9 @@ lowToHigh_start = lowFreqSeries.convert('B', position='START') assert_equal(lowToHigh_start.start_date, - Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE")) + Date(freq='m', year=2005, month=6).asfreq("B", relation="START")) assert_equal(lowToHigh_start.end_date, - (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER")) + (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="END")) assert_equal(lowToHigh_start._mask[0], False) assert_equal(lowToHigh_start._mask[-1], True) @@ -421,9 +421,9 @@ lowToHigh_end = lowFreqSeries.convert('B', position='END') assert_equal(lowToHigh_end.start_date, - Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE")) + Date(freq='m', year=2005, month=6).asfreq("B", relation="START")) assert_equal(lowToHigh_end.end_date, - (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER")) + (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="END")) assert_equal(lowToHigh_end._mask[0], True) assert_equal(lowToHigh_end._mask[-1], False) Modified: branches/scipy.scons/scipy/sandbox/timeseries/tseries.py =================================================================== --- branches/scipy.scons/scipy/sandbox/timeseries/tseries.py 2007-11-26 05:32:08 UTC (rev 3594) +++ branches/scipy.scons/scipy/sandbox/timeseries/tseries.py 2007-11-26 05:33:22 UTC (rev 3595) @@ -688,7 +688,7 @@ """Returns the index corresponding to a given date, as an integer.""" return self._dates.date_to_index(date) #..................................................... - def asfreq(self, freq, relation="AFTER"): + def asfreq(self, freq, relation="END"): """Converts the dates portion of the TimeSeries to another frequency. The resulting TimeSeries will have the same shape and dimensions as the @@ -696,7 +696,7 @@ *Parameters*: freq : {freq_spec} - relation : {'AFTER', 'BEFORE'} , optional + relation : {'END', 'START'} (optional) *Returns*: a new TimeSeries with the .dates DateArray at the specified frequency (the @@ -1307,17 +1307,34 @@ def convert(series, freq, func=None, position='END', *args, **kwargs): """Converts a series to a frequency. Private function called by convert - When converting to a lower frequency, func is a function that acts - on a 1-d array and returns a scalar or 1-d array. func should handle - masked values appropriately. If func is None, then a 2D array is returned, - where each column represents the values appropriately grouped into the new - frequency. `position` will be ignored in this case. +*Parameters*: + series : {TimeSeries} + the series to convert. Skip this parameter if you are calling this as + a method of the TimeSeries object instead of the module function. + freq : {freq_spec} + Frequency to convert the TimeSeries to. Accepts any valid frequency + specification (string or integer) + func : {function} (optional) + When converting to a lower frequency, func is a function that acts on + one date's worth of data. func should handle masked values appropriately. + If func is None, then each data point in the resulting series will a + group of data points that fall into the date at the lower frequency. - When converting to a higher frequency, position is 'START' or 'END' - and determines where the data point is in each period (eg. if going - from monthly to daily, and position is 'END', then each data point is - placed at the end of the month). - """ + For example, if converting from monthly to daily and you wanted each + data point in the resulting series to be the average value for each + month, you could specify maskedarray.average for the 'func' parameter. + position : {'END', 'START'} (optional) + When converting to a higher frequency, position is 'START' or 'END' + and determines where the data point is in each period. For example, if + going from monthly to daily, and position is 'END', then each data + point is placed at the end of the month. + *args : {extra arguments for func parameter} (optional) + if a func is specified that requires additional parameters, specify + them here. + **kwargs : {extra keyword arguments for func parameter} (optional) + if a func is specified that requires additional keyword parameters, + specify them here. +""" if series.ndim == 1: obj = _convert1d(series, freq, func, position, *args, **kwargs) elif series.ndim == 2: @@ -1341,8 +1358,8 @@ def group_byperiod(series, freq, position='END'): """Converts a series to a frequency, without any processing. If the series - has missing data, it is first filled with masked data. Duplicate values in the - series will raise an exception. +has missing data, it is first filled with masked data. Duplicate values in the +series will raise an exception. """ if series.has_duplicated_dates(): raise TimeSeriesError("The input series must not have duplicated dates!") @@ -1357,16 +1374,16 @@ """Returns a series of the same size as `series`, with the same start_date and end_date, but values shifted by `nper`. -:Parameters: - - series : (TimeSeries) +*Parameters*: + series : {TimeSeries} TimeSeries object to shift - - nper : (int) + nper : {int} number of periods to shift. Negative numbers shift values to the right, positive to the left - - copy : (boolean, *[True]*) + copy : {True, False} (optional) copies the data if True, returns a view if False. -:Example: +*Example*: >>> series = time_series([0,1,2,3], start_date=Date(freq='A', year=2005)) >>> series timeseries(data = [0 1 2 3], @@ -1376,7 +1393,8 @@ timeseries(data = [-- 0 1 2], dates = [2005 ... 2008], freq = A-DEC) ->>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1)""" +>>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1) +""" newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if copy: @@ -1400,13 +1418,13 @@ def pct(series, nper=1): """Returns the rolling percentage change of the series. -:Parameters: - - series : (TimeSeries) +*Parameters*: + series : {TimeSeries} TimeSeries object to to calculate percentage chage for - - nper : (int) + nper : {int} number of periods for percentage change -:Example: +*Example*: >>> series = time_series([2.,1.,2.,3.], start_date=Date(freq='A', year=2005)) >>> pct(series) timeseries(data = [-- -50.0 100.0 50.0], @@ -1415,8 +1433,8 @@ >>> pct(series, 2) timeseries(data = [-- -- 0.0 200.0], dates = [2005 ... 2008], - freq = A-DEC)""" - + freq = A-DEC) +""" newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if nper < newdata.size: @@ -1427,21 +1445,23 @@ return newseries TimeSeries.pct = pct #............................................................................... -def fill_missing_dates(data, dates=None, freq=None,fill_value=None): - """Finds and fills the missing dates in a time series. -The data corresponding to the initially missing dates are masked, or filled to +def fill_missing_dates(data, dates=None, freq=None, fill_value=None): + """Finds and fills the missing dates in a time series. The data +corresponding to the initially missing dates are masked, or filled to `fill_value`. -:Parameters: - `data` +*Parameters*: + data : {TimeSeries, ndarray} Initial array of data. - `dates` - Initial array of dates. - `freq` : float *[None]* - New date resolutions. If *None*, the initial resolution is used instead. - `fill_value` : float *[None]* - Default value for missing data. If None, the data are just masked. - """ + dates : {DateArray} (optional) + Initial array of dates. Specify this if you are passing a plain ndarray + for the data instead of a TimeSeries. + freq : {freq_spec} (optional) + Frequency of result. If not specified, the initial frequency is used. + fill_value : {scalar of type data.dtype} (optional) + Default value for missing data. If Not specified, the data are just + masked. +""" # Check the frequency ........ orig_freq = freq freq = check_freq(freq) From scipy-svn at scipy.org Mon Nov 26 01:24:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 00:24:57 -0600 (CST) Subject: [Scipy-svn] r3596 - branches/scipy.scons/scipy/stats Message-ID: <20071126062457.672CD39C03B@new.scipy.org> Author: cdavid Date: 2007-11-26 00:24:52 -0600 (Mon, 26 Nov 2007) New Revision: 3596 Modified: branches/scipy.scons/scipy/stats/SConstruct branches/scipy.scons/scipy/stats/setupscons.py Log: add forgotten mvn extension in scipy.stats Modified: branches/scipy.scons/scipy/stats/SConstruct =================================================================== --- branches/scipy.scons/scipy/stats/SConstruct 2007-11-26 05:33:22 UTC (rev 3595) +++ branches/scipy.scons/scipy/stats/SConstruct 2007-11-26 06:24:52 UTC (rev 3596) @@ -1,4 +1,4 @@ -# Last Change: Mon Nov 26 02:00 PM 2007 J +# Last Change: Mon Nov 26 03:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin, basename as pbasename import sys @@ -20,9 +20,8 @@ config.Finish() # Statlib library -src = glob.glob(pjoin(env['src_dir'], 'statlib', '*.f' )) -env.NumpyStaticExtLibrary('statlib', - source = [pjoin('statlib', pbasename(i)) for i in src]) +src = env.NumpyGlob(pjoin('statlib', '*.f' )) +env.NumpyStaticExtLibrary('statlib', source = src) env.AppendUnique(LIBPATH = env['build_dir']) @@ -37,3 +36,7 @@ pjoin(env['build_dir'], 'futil.f')) env.NumpyPythonExtension('futil', source = futil_src + ['futil.f'], LINKFLAGSEND = env['F77_LDFLAGS']) + +# mvn extension +env.NumpyPythonExtension('mvn', source = ['mvn.pyf', 'mvndst.f'], + LINKFLAGSEND = env['F77_LDFLAGS']) Modified: branches/scipy.scons/scipy/stats/setupscons.py =================================================================== --- branches/scipy.scons/scipy/stats/setupscons.py 2007-11-26 05:33:22 UTC (rev 3595) +++ branches/scipy.scons/scipy/stats/setupscons.py 2007-11-26 06:24:52 UTC (rev 3596) @@ -4,9 +4,10 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('stats', parent_package, top_path, setup_name = 'setupscons.py') + config = Configuration('stats', parent_package, top_path, + setup_name = 'setupscons.py') - #config.add_subpackage('models') + config.add_subpackage('models') config.add_data_dir('tests') config.add_sconscript('SConstruct') From scipy-svn at scipy.org Mon Nov 26 01:55:30 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 00:55:30 -0600 (CST) Subject: [Scipy-svn] r3597 - branches/scipy.scons/scipy/fftpack Message-ID: <20071126065530.C657B39C049@new.scipy.org> Author: cdavid Date: 2007-11-26 00:55:26 -0600 (Mon, 26 Nov 2007) New Revision: 3597 Modified: branches/scipy.scons/scipy/fftpack/SConstruct Log: Using NumpyGlob for fftpack Modified: branches/scipy.scons/scipy/fftpack/SConstruct =================================================================== --- branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-26 06:24:52 UTC (rev 3596) +++ branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) @@ -1,4 +1,4 @@ -# Last Change: Thu Nov 22 12:00 PM 2007 J +# Last Change: Mon Nov 26 03:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin import glob @@ -14,7 +14,7 @@ # XXX: implement fft checkers ... # Build dfftpack -src = glob.glob(pjoin('dfftpack', '*.f')) +src = env.NumpyGlob(pjoin('dfftpack', '*.f')) dfftpack = env.NumpyStaticExtLibrary('dfftpack', source = src) env.AppendUnique(LIBS = ['dfftpack']) env.AppendUnique(LIBPATH = env['build_dir']) From scipy-svn at scipy.org Mon Nov 26 02:02:31 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 01:02:31 -0600 (CST) Subject: [Scipy-svn] r3598 - in branches/scipy.scons/scipy: fftpack integrate interpolate linsolve optimize special stats Message-ID: <20071126070231.CD87D39C049@new.scipy.org> Author: cdavid Date: 2007-11-26 01:02:19 -0600 (Mon, 26 Nov 2007) New Revision: 3598 Modified: branches/scipy.scons/scipy/fftpack/SConstruct branches/scipy.scons/scipy/integrate/SConstruct branches/scipy.scons/scipy/interpolate/SConstruct branches/scipy.scons/scipy/linsolve/SConstruct branches/scipy.scons/scipy/optimize/SConstruct branches/scipy.scons/scipy/special/SConstruct branches/scipy.scons/scipy/stats/SConstruct Log: Remove any glob use in sconscript, replace with NumpyGlob Modified: branches/scipy.scons/scipy/fftpack/SConstruct =================================================================== --- branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/fftpack/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -1,8 +1,8 @@ # Last Change: Mon Nov 26 03:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin -import glob + from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import GetNumpyEnvironment Modified: branches/scipy.scons/scipy/integrate/SConstruct =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/integrate/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -1,8 +1,8 @@ # Last Change: Thu Nov 22 12:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin -import glob + from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import GetNumpyEnvironment @@ -14,19 +14,19 @@ # XXX: blas/lapack integration # Build linpack_lite -src = glob.glob(pjoin('linpack_lite', '*.f')) +src = env.NumpyGlob(pjoin('linpack_lite', '*.f')) linpack_lite = env.NumpyStaticExtLibrary('linpack_lite', source = src) # Build mach -src = glob.glob(pjoin('mach', '*.f')) +src = env.NumpyGlob(pjoin('mach', '*.f')) mach = env.NumpyStaticExtLibrary('mach', source = src) # Build quadpack -src = glob.glob(pjoin('quadpack', '*.f')) +src = env.NumpyGlob(pjoin('quadpack', '*.f')) quadpack = env.NumpyStaticExtLibrary('quadpack', source = src) # Build odepack -src = glob.glob(pjoin('odepack', '*.f')) +src = env.NumpyGlob(pjoin('odepack', '*.f')) odepack = env.NumpyStaticExtLibrary('odepack', source = src) env.AppendUnique(LIBS = ['linpack_lite', 'quadpack', 'odepack']) Modified: branches/scipy.scons/scipy/interpolate/SConstruct =================================================================== --- branches/scipy.scons/scipy/interpolate/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/interpolate/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -1,8 +1,8 @@ # Last Change: Thu Nov 22 12:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin -import glob + from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import GetNumpyEnvironment, CheckF77Clib @@ -18,7 +18,7 @@ env.AppendUnique(LINKFLAGS = env['F77_LDFLAGS']) # Build fitpack -src = glob.glob(pjoin('fitpack', '*.f')) +src = env.NumpyGlob(pjoin('fitpack', '*.f')) fitpack = env.NumpyStaticExtLibrary('fitpack', source = src) env.AppendUnique(LIBS = ['fitpack']) Modified: branches/scipy.scons/scipy/linsolve/SConstruct =================================================================== --- branches/scipy.scons/scipy/linsolve/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/linsolve/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -1,7 +1,7 @@ # Last Change: Sat Nov 24 05:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin -import glob + import sys from distutils.sysconfig import get_python_inc @@ -21,7 +21,7 @@ superlu_defs = [] # Build superlu -src = glob.glob(pjoin('SuperLU', 'SRC', '*.c')) +src = env.NumpyGlob(pjoin('SuperLU', 'SRC', '*.c')) superlu = env.NumpyStaticExtLibrary('superlu_src', source = src, CPPDEFINES = superlu_defs) Modified: branches/scipy.scons/scipy/optimize/SConstruct =================================================================== --- branches/scipy.scons/scipy/optimize/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/optimize/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -1,10 +1,10 @@ -# Last Change: Sat Nov 24 07:00 PM 2007 J +# Last Change: Mon Nov 26 03:00 PM 2007 J # vim:syntax=python import os from os.path import join as pjoin, splitext -import glob + from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir from numpy.distutils.scons import GetNumpyEnvironment @@ -43,11 +43,11 @@ #========== # minpack lib -minpack_src = glob.glob(pjoin('minpack', '*.f')) +minpack_src = env.NumpyGlob(pjoin('minpack', '*.f')) env.NumpyStaticExtLibrary('minpack', source = minpack_src) # rootfind lib -rootfind_src = glob.glob(pjoin('Zeros', '*.c')) +rootfind_src = env.NumpyGlob(pjoin('Zeros', '*.c')) env.NumpyStaticExtLibrary('rootfind', source = rootfind_src) env.AppendUnique(LIBS = ['minpack', 'rootfind']) Modified: branches/scipy.scons/scipy/special/SConstruct =================================================================== --- branches/scipy.scons/scipy/special/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/special/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -1,8 +1,8 @@ -# Last Change: Sat Nov 24 08:00 PM 2007 J +# Last Change: Mon Nov 26 03:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin, basename as pbasename import sys -import glob + from distutils.sysconfig import get_python_inc from numpy.distutils.misc_util import get_numpy_include_dirs @@ -28,12 +28,8 @@ """ext should be .f or .c""" if not libname: libname = name - src = glob.glob(pjoin(env['src_dir'], name, '*%s' % ext)) - assert len(src) > 0 - env.NumpyStaticExtLibrary(libname, - source = [pjoin(name, - pbasename(i)) - for i in src]) + src = env.NumpyGlob(pjoin(name, '*%s' % ext)) + env.NumpyStaticExtLibrary(libname, source = src) # C libraries build_lib('c_misc', '.c') Modified: branches/scipy.scons/scipy/stats/SConstruct =================================================================== --- branches/scipy.scons/scipy/stats/SConstruct 2007-11-26 06:55:26 UTC (rev 3597) +++ branches/scipy.scons/scipy/stats/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) @@ -2,7 +2,7 @@ # vim:syntax=python from os.path import join as pjoin, basename as pbasename import sys -import glob + from distutils.sysconfig import get_python_inc from numpy.distutils.misc_util import get_numpy_include_dirs From scipy-svn at scipy.org Mon Nov 26 02:29:06 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 01:29:06 -0600 (CST) Subject: [Scipy-svn] r3599 - branches/scipy.scons/scipy/integrate Message-ID: <20071126072906.1653839C153@new.scipy.org> Author: cdavid Date: 2007-11-26 01:28:58 -0600 (Mon, 26 Nov 2007) New Revision: 3599 Modified: branches/scipy.scons/scipy/integrate/SConstruct Log: Fix linking problems with scons build of integrate Modified: branches/scipy.scons/scipy/integrate/SConstruct =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-26 07:02:19 UTC (rev 3598) +++ branches/scipy.scons/scipy/integrate/SConstruct 2007-11-26 07:28:58 UTC (rev 3599) @@ -1,23 +1,35 @@ -# Last Change: Thu Nov 22 12:00 PM 2007 J +# Last Change: Mon Nov 26 04:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin +import warnings - from numpy.distutils.misc_util import get_numpy_include_dirs -from numpy.distutils.scons import GetNumpyEnvironment +from numpy.distutils.scons import GetNumpyEnvironment, CheckF77Clib, CheckF77BLAS env = GetNumpyEnvironment(ARGUMENTS) +# Configuration +config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib, + 'CheckF77BLAS' : CheckF77BLAS}) + +#if not config.CheckF77Clib(): +# raise Exception("Could not check F77 runtime, needed for interpolate") +if not config.CheckF77BLAS(): + warnings.warn("Could not find F77 BLAS") + +config.Finish() + env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -# XXX: blas/lapack integration +# XXX: lapack integration # Build linpack_lite src = env.NumpyGlob(pjoin('linpack_lite', '*.f')) linpack_lite = env.NumpyStaticExtLibrary('linpack_lite', source = src) # Build mach +# XXX: do not use optimization flags for mach src = env.NumpyGlob(pjoin('mach', '*.f')) mach = env.NumpyStaticExtLibrary('mach', source = src) @@ -29,14 +41,17 @@ src = env.NumpyGlob(pjoin('odepack', '*.f')) odepack = env.NumpyStaticExtLibrary('odepack', source = src) -env.AppendUnique(LIBS = ['linpack_lite', 'quadpack', 'odepack']) +#env.AppendUnique(LIBS = ['linpack_lite', 'quadpack', 'odepack', 'mach']) env.AppendUnique(LIBPATH = env['build_dir']) # Build _quadpack -env.NumpyPythonExtension('_quadpack', source = '_quadpackmodule.c') +env.NumpyPythonExtension('_quadpack', source = '_quadpackmodule.c', + LIBS = ['quadpack', 'linpack_lite', 'mach']) # Build _odepack -env.NumpyPythonExtension('_odepack', source = '_odepackmodule.c') +env.NumpyPythonExtension('_odepack', source = '_odepackmodule.c', + LIBS = ['odepack', 'linpack_lite', 'mach']) # Build vode -env.NumpyPythonExtension('vode', source = 'vode.pyf') +env.NumpyPythonExtension('vode', source = 'vode.pyf', + LIBS = ['odepack', 'linpack_lite', 'mach']) From scipy-svn at scipy.org Mon Nov 26 03:33:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 02:33:57 -0600 (CST) Subject: [Scipy-svn] r3600 - branches/scipy.scons/scipy/integrate Message-ID: <20071126083357.BC30539C158@new.scipy.org> Author: cdavid Date: 2007-11-26 02:33:53 -0600 (Mon, 26 Nov 2007) New Revision: 3600 Modified: branches/scipy.scons/scipy/integrate/SConstruct Log: Fix fortran / C linking problem with scons build for integrate Modified: branches/scipy.scons/scipy/integrate/SConstruct =================================================================== --- branches/scipy.scons/scipy/integrate/SConstruct 2007-11-26 07:28:58 UTC (rev 3599) +++ branches/scipy.scons/scipy/integrate/SConstruct 2007-11-26 08:33:53 UTC (rev 3600) @@ -1,4 +1,4 @@ -# Last Change: Mon Nov 26 04:00 PM 2007 J +# Last Change: Mon Nov 26 05:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin import warnings @@ -12,8 +12,8 @@ config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib, 'CheckF77BLAS' : CheckF77BLAS}) -#if not config.CheckF77Clib(): -# raise Exception("Could not check F77 runtime, needed for interpolate") +if not config.CheckF77Clib(): + raise Exception("Could not check F77 runtime, needed for interpolate") if not config.CheckF77BLAS(): warnings.warn("Could not find F77 BLAS") @@ -46,12 +46,15 @@ # Build _quadpack env.NumpyPythonExtension('_quadpack', source = '_quadpackmodule.c', - LIBS = ['quadpack', 'linpack_lite', 'mach']) + LIBS = ['quadpack', 'linpack_lite', 'mach'], + LINKFLAGSEND = env['F77_LDFLAGS']) # Build _odepack env.NumpyPythonExtension('_odepack', source = '_odepackmodule.c', - LIBS = ['odepack', 'linpack_lite', 'mach']) + LIBS = ['odepack', 'linpack_lite', 'mach'], + LINKFLAGSEND = env['F77_LDFLAGS']) # Build vode env.NumpyPythonExtension('vode', source = 'vode.pyf', - LIBS = ['odepack', 'linpack_lite', 'mach']) + LIBS = ['odepack', 'linpack_lite', 'mach'], + LINKFLAGSEND = env['F77_LDFLAGS']) From scipy-svn at scipy.org Mon Nov 26 04:19:09 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 03:19:09 -0600 (CST) Subject: [Scipy-svn] r3601 - in branches/scipy.scons/scipy: lib/lapack linalg linsolve linsolve/umfpack odr optimize Message-ID: <20071126091909.771EF39C11D@new.scipy.org> Author: cdavid Date: 2007-11-26 03:18:24 -0600 (Mon, 26 Nov 2007) New Revision: 3601 Modified: branches/scipy.scons/scipy/lib/lapack/SConstruct branches/scipy.scons/scipy/linalg/SConstruct branches/scipy.scons/scipy/linsolve/SConstruct branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py branches/scipy.scons/scipy/odr/SConstruct branches/scipy.scons/scipy/optimize/SConstruct Log: Fix remaining C/F linking problems for scons build; gcc + ifort now pass all tests Modified: branches/scipy.scons/scipy/lib/lapack/SConstruct =================================================================== --- branches/scipy.scons/scipy/lib/lapack/SConstruct 2007-11-26 08:33:53 UTC (rev 3600) +++ branches/scipy.scons/scipy/lib/lapack/SConstruct 2007-11-26 09:18:24 UTC (rev 3601) @@ -1,4 +1,4 @@ -# Last Change: Sat Nov 24 08:00 PM 2007 J +# Last Change: Mon Nov 26 05:00 PM 2007 J # vim:syntax=python import os @@ -9,7 +9,8 @@ from numpy.distutils.scons import GetNumpyEnvironment from numpy.distutils.scons import CheckF77LAPACK,\ CheckCLAPACK, \ - IsATLAS, GetATLASVersion + IsATLAS, GetATLASVersion, \ + CheckF77Clib from scons_support import do_generate_fake_interface, \ generate_interface_emitter @@ -27,11 +28,16 @@ # Starting Configuration #======================= config = env.NumpyConfigure(custom_tests = {'CheckCLAPACK' : CheckCLAPACK, - 'CheckLAPACK' : CheckF77LAPACK}) + 'CheckLAPACK' : CheckF77LAPACK, + 'CheckF77Clib' : CheckF77Clib}) #-------------- # Checking Blas #-------------- +if not config.CheckF77Clib(): + raise RuntimeError("Could not check F/C runtime library for %s/%s, " \ + "contact the maintainer" % (env['CC'], env['F77'])) + st = config.CheckLAPACK(check_version = 1) if not st: raise RuntimeError("no lapack found, necessary for lapack module") @@ -79,7 +85,8 @@ #---------------- calc_src = env.F2py(pjoin(env['build_dir'], 'calc_lworkmodule.c'), source = pjoin(env['build_dir'], 'calc_lwork.f')) -env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f']) +env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f'], + LINKFLAGSEND = env['F77_LDFLAGS']) #-------------- # Atlas version Modified: branches/scipy.scons/scipy/linalg/SConstruct =================================================================== --- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-26 08:33:53 UTC (rev 3600) +++ branches/scipy.scons/scipy/linalg/SConstruct 2007-11-26 09:18:24 UTC (rev 3601) @@ -1,4 +1,4 @@ -# Last Change: Sat Nov 24 12:00 PM 2007 J +# Last Change: Mon Nov 26 05:00 PM 2007 J # vim:syntax=python import os @@ -9,7 +9,7 @@ from numpy.distutils.scons import GetNumpyEnvironment from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ CheckCLAPACK, IsVeclib, IsAccelerate, \ - IsATLAS, GetATLASVersion + IsATLAS, GetATLASVersion, CheckF77Clib from scons_support import do_generate_interface, do_generate_fake_interface, \ generate_interface_emitter @@ -32,11 +32,16 @@ config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS, 'CheckBLAS' : CheckF77BLAS, 'CheckCLAPACK' : CheckCLAPACK, - 'CheckLAPACK' : CheckF77LAPACK}) + 'CheckLAPACK' : CheckF77LAPACK, + 'CheckF77Clib' : CheckF77Clib}) #-------------- # Checking Blas #-------------- +if not config.CheckF77Clib(): + raise RuntimeError("Could not check F/C runtime library for %s/%s, " \ + "contact the maintainer" % (env['CC'], env['F77'])) + st = config.CheckBLAS(check_version = 1) if not st: raise RuntimeError("no blas found, necessary for linalg module") @@ -131,7 +136,8 @@ calc_src = env.F2py(pjoin(env['build_dir'], 'src', 'calc_lworkmodule.c'), source = pjoin(env['build_dir'], 'src', 'calc_lwork.f')) env.NumpyPythonExtension('calc_lwork', - source = calc_src + [pjoin('src', 'calc_lwork.f')]) + source = calc_src + [pjoin('src', 'calc_lwork.f')], + LINKFLAGSEND = env['F77_LDFLAGS']) #-------------------- # iterative methods Modified: branches/scipy.scons/scipy/linsolve/SConstruct =================================================================== --- branches/scipy.scons/scipy/linsolve/SConstruct 2007-11-26 08:33:53 UTC (rev 3600) +++ branches/scipy.scons/scipy/linsolve/SConstruct 2007-11-26 09:18:24 UTC (rev 3601) @@ -1,4 +1,4 @@ -# Last Change: Sat Nov 24 05:00 PM 2007 J +# Last Change: Mon Nov 26 04:00 PM 2007 J # vim:syntax=python from os.path import join as pjoin @@ -12,14 +12,22 @@ env = GetNumpyEnvironment(ARGUMENTS) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) +# Configuration +config = env.NumpyConfigure(custom_tests = {'CheckF77LAPACK' : CheckF77LAPACK}) +if not config.CheckF77LAPACK(): + warnings.warn("Could not find F77 LAPACK") +config.Finish() if sys.platform=='win32': superlu_defs = [('NO_TIMER',1)] else: superlu_defs = [] +superlu_defs.append(('USE_VENDOR_BLAS', 1)) +env.AppendUnique(CPPDEFINES = superlu_defs) +env.AppendUnique(CPPPATH = get_numpy_include_dirs()) +env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) + # Build superlu src = env.NumpyGlob(pjoin('SuperLU', 'SRC', '*.c')) superlu = env.NumpyStaticExtLibrary('superlu_src', source = src, Modified: branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py =================================================================== --- branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py 2007-11-26 08:33:53 UTC (rev 3600) +++ branches/scipy.scons/scipy/linsolve/umfpack/setupscons.py 2007-11-26 09:18:24 UTC (rev 3601) @@ -9,6 +9,7 @@ config = Configuration( 'umfpack', parent_package, top_path ) config.add_data_dir('tests') + # XXX: Implement umfpack tester # umf_info = get_info( 'umfpack', notfound_action = 1 ) # # umfpack_i_file = config.paths('umfpack.i')[0] Modified: branches/scipy.scons/scipy/odr/SConstruct =================================================================== --- branches/scipy.scons/scipy/odr/SConstruct 2007-11-26 08:33:53 UTC (rev 3600) +++ branches/scipy.scons/scipy/odr/SConstruct 2007-11-26 09:18:24 UTC (rev 3601) @@ -1,4 +1,4 @@ -# Last Change: Sat Nov 24 06:00 PM 2007 J +# Last Change: Mon Nov 26 06:00 PM 2007 J # vim:syntax=python import os @@ -7,7 +7,7 @@ from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir from numpy.distutils.scons import GetNumpyEnvironment -from numpy.distutils.scons import CheckF77BLAS +from numpy.distutils.scons import CheckF77BLAS, CheckF77Clib from numpy.distutils.scons.configuration import write_info @@ -22,8 +22,13 @@ #======================= # Starting Configuration #======================= -config = env.NumpyConfigure(custom_tests = {'CheckBLAS' : CheckF77BLAS}) +config = env.NumpyConfigure(custom_tests = {'CheckBLAS' : CheckF77BLAS, + 'CheckF77Clib' : CheckF77Clib}) +if not config.CheckF77Clib(): + raise RuntimeError("Could not check F/C runtime library for %s/%s, " \ + "contact the maintainer" % (env['CC'], env['F77'])) + #-------------- # Checking Blas #-------------- @@ -47,9 +52,10 @@ else: libodr_src.append(pjoin('odrpack', 'd_lpkbls.f')) -env.NumpyStaticExtLibrary('odr', source = libodr_src) -env.AppendUnique(LIBS = 'odr') +env.NumpyStaticExtLibrary('odrpack', source = libodr_src) +env.AppendUnique(LIBS = 'odrpack') env.AppendUnique(LIBPATH = env['build_dir']) # odr pyextension -env.NumpyPythonExtension('__odrpack', '__odrpack.c') +env.NumpyPythonExtension('__odrpack', '__odrpack.c', + LINKFLAGSEND = env['F77_LDFLAGS']) Modified: branches/scipy.scons/scipy/optimize/SConstruct =================================================================== --- branches/scipy.scons/scipy/optimize/SConstruct 2007-11-26 08:33:53 UTC (rev 3600) +++ branches/scipy.scons/scipy/optimize/SConstruct 2007-11-26 09:18:24 UTC (rev 3601) @@ -1,4 +1,4 @@ -# Last Change: Mon Nov 26 03:00 PM 2007 J +# Last Change: Mon Nov 26 05:00 PM 2007 J # vim:syntax=python import os @@ -8,7 +8,7 @@ from numpy.distutils.misc_util import get_numpy_include_dirs from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir from numpy.distutils.scons import GetNumpyEnvironment -from numpy.distutils.scons import CheckF77LAPACK +from numpy.distutils.scons import CheckF77LAPACK, CheckF77Clib from numpy.distutils.scons.configuration import write_info @@ -24,11 +24,16 @@ #======================= # Starting Configuration #======================= -config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) +config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK, + 'CheckF77Clib' : CheckF77Clib}) #----------------- # Checking Lapack #----------------- +if not config.CheckF77Clib(): + raise RuntimeLibrary("Could not check C/F runtime library for %s/%s"\ + " , contact the maintainer" % (env['CC'], env['F77'])) + st = config.CheckLAPACK() if not st: has_lapack = 0 @@ -54,7 +59,8 @@ env.AppendUnique(LIBPATH = env['build_dir']) # _minpack pyextension -env.NumpyPythonExtension('_minpack', '_minpackmodule.c') +env.NumpyPythonExtension('_minpack', '_minpackmodule.c', + LINKFLAGSEND = env['F77_LDFLAGS']) # _zeros pyextension env.NumpyPythonExtension('_zeros', 'zeros.c') @@ -63,19 +69,22 @@ src = pjoin('lbfgsb', 'routines.f') lbfgsb_src = env.F2py(pjoin(env['build_dir'], '_lbfgsbmodule.c'), pjoin(env['build_dir'], 'lbfgsb', 'lbfgsb.pyf')) -env.NumpyPythonExtension('_lbfgsb', source = [src] + lbfgsb_src) +env.NumpyPythonExtension('_lbfgsb', source = [src] + lbfgsb_src, + LINKFLAGSEND = env['F77_LDFLAGS']) # _cobyla pyextension src = [pjoin('cobyla', i) for i in ['cobyla2.f', 'trstlp.f']] wrap_src = env.F2py(pjoin(env['build_dir'], 'cobyla', '_cobylamodule.c'), pjoin(env['build_dir'], 'cobyla', 'cobyla.pyf')) -env.NumpyPythonExtension('_cobyla', source = src + wrap_src) +env.NumpyPythonExtension('_cobyla', source = src + wrap_src, + LINKFLAGSEND = env['F77_LDFLAGS']) # _minpack2 pyextension src = [pjoin('minpack2', i) for i in ['dcsrch.f', 'dcstep.f']] wrap_src = env.F2py(pjoin(env['build_dir'], 'minpack2', 'minpack2module.c'), pjoin(env['build_dir'], 'minpack2', 'minpack2.pyf')) -env.NumpyPythonExtension('minpack2', source = src + wrap_src) +env.NumpyPythonExtension('minpack2', source = src + wrap_src, + LINKFLAGSEND = env['F77_LDFLAGS']) # moduleTNC pyextension env.NumpyPythonExtension('moduleTNC', From scipy-svn at scipy.org Mon Nov 26 09:31:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Nov 2007 08:31:26 -0600 (CST) Subject: [Scipy-svn] r3602 - trunk/scipy/linsolve/umfpack Message-ID: <20071126143126.49C7739C1C8@new.scipy.org> Author: rc Date: 2007-11-26 08:31:21 -0600 (Mon, 26 Nov 2007) New Revision: 3602 Modified: trunk/scipy/linsolve/umfpack/info.py Log: improved module docstring Modified: trunk/scipy/linsolve/umfpack/info.py =================================================================== --- trunk/scipy/linsolve/umfpack/info.py 2007-11-26 09:18:24 UTC (rev 3601) +++ trunk/scipy/linsolve/umfpack/info.py 2007-11-26 14:31:21 UTC (rev 3602) @@ -1,6 +1,6 @@ """ -Interface to the UMFPACK library. -================================= +:Interface to the UMFPACK library: +================================== :Contains: UmfpackContext class @@ -21,6 +21,7 @@ Example site.cfg entry: + UMFPACK v4.4 in : [amd] @@ -44,8 +45,8 @@ library_dirs = /UFsparse/UMFPACK/Lib include_dirs = /UFsparse/UMFPACK/Include, /UFsparse/UFconfig umfpack_libs = umfpack + - :Examples: ---------- @@ -55,6 +56,7 @@ Righthand-side: rhs Solution: sol + # Contruct the solver. umfpack = um.UmfpackContext() # Use default 'di' family of UMFPACK routines. @@ -62,9 +64,11 @@ sol = umfpack( um.UMFPACK_A, mtx, rhs, autoTranspose = True ) # same as: sol = umfpack.linsolve( um.UMFPACK_A, mtx, rhs, autoTranspose = True ) + -or- + # Make LU decomposition. umfpack.numeric( mtx ) ... @@ -74,15 +78,17 @@ # same as: sol1 = umfpack.solve( um.UMFPACK_A, mtx, rhs1, autoTranspose = True ) sol2 = umfpack.solve( um.UMFPACK_A, mtx, rhs2, autoTranspose = True ) + -or- + # Make symbolic decomposition. umfpack.symbolic( mtx0 ) # Print statistics. umfpack.report_symbolic() -... +# ... # Make LU decomposition of mtx1 which has same structure as mtx0. umfpack.numeric( mtx1 ) @@ -92,7 +98,7 @@ # Use already LU-decomposed matrix. sol1 = umfpack( um.UMFPACK_A, mtx1, rhs1, autoTranspose = True ) -... +# ... # Make LU decomposition of mtx2 which has same structure as mtx0. umfpack.numeric( mtx2 ) @@ -100,37 +106,43 @@ # Print all statistics. umfpack.report_info() + -or- + # Get LU factors and permutation matrices of a matrix. L, U, P, Q, R, do_recip = umfpack.lu( mtx ) + -Then: - L - Lower triangular m-by-min(m,n) CSR matrix - U - Upper triangular min(m,n)-by-n CSC matrix - P - Vector of row permuations - Q - Vector of column permuations - R - Vector of diagonal row scalings - do_recip - boolean +:Returns: + - `L` : Lower triangular m-by-min(m,n) CSR matrix + - `U` : Upper triangular min(m,n)-by-n CSC matrix + - `P` : Vector of row permuations + - `Q` : Vector of column permuations + - `R` : Vector of diagonal row scalings + - `do_recip` : boolean - For a given matrix A, the decomposition satisfies: - LU = PRAQ when do_recip is true - LU = P(R^-1)AQ when do_recip is false +:Note: + For a given matrix A, the decomposition satisfies: + $LU = PRAQ$ when do_recip is true, + $LU = P(R^{-1})AQ$ when do_recip is false -:Arguments of UmfpackContext solution methods: ----------------------------------------------- -This holds for: umfpack(), umfpack.linsolve(), umfpack.solve() +:UmfpackContext solution methods: +--------------------------------- - sys - one of UMFPACK system description constants, like - UMFPACK_A, UMFPACK_At, see umfSys list and UMFPACK - docs - mtx - sparse matrix (CSR or CSC) - rhs - right hand side vector - autoTranspose - automatically changes 'sys' to the - transposed type, if 'mtx' is in CSR, since UMFPACK - assumes CSC internally +umfpack(), umfpack.linsolve(), umfpack.solve() +:Parameters: + - `sys` : constant, + one of UMFPACK system description constants, like + UMFPACK_A, UMFPACK_At, see umfSys list and UMFPACK docs + - `mtx` : sparse matrix (CSR or CSC) + - `rhs` : right hand side vector + - `autoTranspose` : bool + automatically changes 'sys' to the transposed type, if 'mtx' is in CSR, + since UMFPACK assumes CSC internally + :Setting control parameters: ---------------------------- @@ -143,8 +155,10 @@ functions). These attributes are in fact indices into the control array - to set the corresponding control array value, just do the following: + umfpack = um.UmfpackContext() umfpack.control[um.UMFPACK_PRL] = 4 # Let's be more verbose. + -- :Author: Robert Cimrman