From scipy-svn at scipy.org Tue Jul 1 00:55:37 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 30 Jun 2008 23:55:37 -0500 (CDT) Subject: [Scipy-svn] r4511 - in branches/refactor_fft: . scipy scipy/cluster scipy/cluster/src scipy/cluster/tests scipy/fftpack scipy/integrate scipy/interpolate scipy/interpolate/tests scipy/io scipy/io/matlab scipy/io/matlab/tests scipy/io/tests scipy/lib/blas scipy/lib/lapack scipy/linalg scipy/ndimage scipy/ndimage/src/register scipy/ndimage/tests scipy/odr scipy/optimize scipy/sandbox scipy/sandbox/mkufunc scipy/sandbox/mkufunc/examples scipy/sandbox/mkufunc/mkufunc scipy/signal scipy/sparse scipy/sparse/linalg/dsolve scipy/sparse/linalg/dsolve/umfpack scipy/sparse/linalg/eigen/arpack scipy/sparse/linalg/eigen/lobpcg scipy/sparse/linalg/eigen/lobpcg/tests scipy/sparse/linalg/isolve scipy/sparse/sparsetools scipy/sparse/tests scipy/special scipy/special/tests scipy/stats scipy/stats/models scipy/stats/models/tests scipy/stats/tests scipy/stsci/convolve scipy/stsci/image scipy/testing scipy/weave/tests Message-ID: <20080701045537.B40E939C52D@scipy.org> Author: cdavid Date: 2008-06-30 23:52:00 -0500 (Mon, 30 Jun 2008) New Revision: 4511 Added: branches/refactor_fft/scipy/cluster/SConscript branches/refactor_fft/scipy/cluster/SConstruct branches/refactor_fft/scipy/cluster/distance.py branches/refactor_fft/scipy/cluster/src/common.h branches/refactor_fft/scipy/cluster/src/distance.c branches/refactor_fft/scipy/cluster/src/distance.h branches/refactor_fft/scipy/cluster/src/distance_wrap.c branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt branches/refactor_fft/scipy/cluster/tests/linkage-X.txt branches/refactor_fft/scipy/cluster/tests/linkage-average-tdist.txt branches/refactor_fft/scipy/cluster/tests/linkage-complete-tdist.txt branches/refactor_fft/scipy/cluster/tests/linkage-single-tdist.txt branches/refactor_fft/scipy/cluster/tests/linkage-weighted-tdist.txt branches/refactor_fft/scipy/cluster/tests/random-bool-data.txt branches/refactor_fft/scipy/fftpack/SConscript branches/refactor_fft/scipy/fftpack/SConstruct branches/refactor_fft/scipy/integrate/SConscript branches/refactor_fft/scipy/integrate/SConstruct branches/refactor_fft/scipy/interpolate/SConscript branches/refactor_fft/scipy/interpolate/SConstruct branches/refactor_fft/scipy/io/SConscript branches/refactor_fft/scipy/io/SConstruct branches/refactor_fft/scipy/lib/blas/SConscript branches/refactor_fft/scipy/lib/blas/SConstruct branches/refactor_fft/scipy/lib/lapack/SConscript branches/refactor_fft/scipy/lib/lapack/SConstruct branches/refactor_fft/scipy/linalg/SConscript branches/refactor_fft/scipy/linalg/SConstruct branches/refactor_fft/scipy/ndimage/SConscript branches/refactor_fft/scipy/ndimage/SConstruct branches/refactor_fft/scipy/ndimage/tests/test_registration.py branches/refactor_fft/scipy/ndimage/tests/test_regression.py branches/refactor_fft/scipy/odr/SConscript branches/refactor_fft/scipy/odr/SConstruct branches/refactor_fft/scipy/optimize/SConscript branches/refactor_fft/scipy/optimize/SConstruct branches/refactor_fft/scipy/sandbox/mkufunc/ branches/refactor_fft/scipy/sandbox/mkufunc/README.txt branches/refactor_fft/scipy/sandbox/mkufunc/TODO.txt branches/refactor_fft/scipy/sandbox/mkufunc/docs/ branches/refactor_fft/scipy/sandbox/mkufunc/examples/ branches/refactor_fft/scipy/sandbox/mkufunc/examples/benchmark.py branches/refactor_fft/scipy/sandbox/mkufunc/examples/primes.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/__init__.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/api.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/driver.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/interactive.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/pypy.h branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py branches/refactor_fft/scipy/sandbox/mkufunc/setup.py branches/refactor_fft/scipy/signal/SConscript branches/refactor_fft/scipy/signal/SConstruct branches/refactor_fft/scipy/sparse/.svnignore branches/refactor_fft/scipy/sparse/linalg/dsolve/SConscript branches/refactor_fft/scipy/sparse/linalg/dsolve/SConstruct branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConscript branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConstruct branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConscript branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConstruct branches/refactor_fft/scipy/sparse/linalg/isolve/SConscript branches/refactor_fft/scipy/sparse/linalg/isolve/SConstruct branches/refactor_fft/scipy/sparse/sparsetools/SConscript branches/refactor_fft/scipy/sparse/sparsetools/SConstruct branches/refactor_fft/scipy/special/SConscript branches/refactor_fft/scipy/special/SConstruct branches/refactor_fft/scipy/stats/SConscript branches/refactor_fft/scipy/stats/SConstruct branches/refactor_fft/scipy/stsci/convolve/SConscript branches/refactor_fft/scipy/stsci/convolve/SConstruct branches/refactor_fft/scipy/stsci/image/SConscript branches/refactor_fft/scipy/stsci/image/SConstruct Removed: branches/refactor_fft/scipy/cluster/SConstruct branches/refactor_fft/scipy/integrate/SConstruct branches/refactor_fft/scipy/interpolate/SConstruct branches/refactor_fft/scipy/io/SConstruct branches/refactor_fft/scipy/lib/blas/SConstruct branches/refactor_fft/scipy/lib/lapack/SConstruct branches/refactor_fft/scipy/linalg/SConstruct branches/refactor_fft/scipy/ndimage/SConstruct branches/refactor_fft/scipy/odr/SConstruct branches/refactor_fft/scipy/optimize/SConstruct branches/refactor_fft/scipy/sandbox/mkufunc/README.txt branches/refactor_fft/scipy/sandbox/mkufunc/TODO.txt branches/refactor_fft/scipy/sandbox/mkufunc/docs/ branches/refactor_fft/scipy/sandbox/mkufunc/examples/ branches/refactor_fft/scipy/sandbox/mkufunc/examples/benchmark.py branches/refactor_fft/scipy/sandbox/mkufunc/examples/primes.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/__init__.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/api.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/driver.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/interactive.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/pypy.h branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py branches/refactor_fft/scipy/sandbox/mkufunc/setup.py branches/refactor_fft/scipy/signal/SConstruct branches/refactor_fft/scipy/sparse/linalg/dsolve/SConstruct branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConstruct branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConstruct branches/refactor_fft/scipy/sparse/linalg/isolve/SConstruct branches/refactor_fft/scipy/sparse/sparsetools/SConstruct branches/refactor_fft/scipy/special/SConstruct branches/refactor_fft/scipy/splinalg/ branches/refactor_fft/scipy/stats/SConstruct branches/refactor_fft/scipy/stsci/convolve/SConstruct branches/refactor_fft/scipy/stsci/image/SConstruct branches/refactor_fft/scipy/testing/nulltester.py Modified: branches/refactor_fft/ branches/refactor_fft/INSTALL.txt branches/refactor_fft/THANKS.txt branches/refactor_fft/scipy/__init__.py branches/refactor_fft/scipy/cluster/__init__.py branches/refactor_fft/scipy/cluster/hierarchy.py branches/refactor_fft/scipy/cluster/info.py branches/refactor_fft/scipy/cluster/setup.py branches/refactor_fft/scipy/cluster/src/hierarchy.c branches/refactor_fft/scipy/cluster/src/hierarchy.h branches/refactor_fft/scipy/cluster/src/hierarchy_wrap.c branches/refactor_fft/scipy/cluster/tests/test_hierarchy.py branches/refactor_fft/scipy/cluster/tests/test_vq.py branches/refactor_fft/scipy/cluster/vq.py branches/refactor_fft/scipy/integrate/__odepack.h branches/refactor_fft/scipy/integrate/odepack.py branches/refactor_fft/scipy/interpolate/fitpack.py branches/refactor_fft/scipy/interpolate/fitpack.pyf branches/refactor_fft/scipy/interpolate/fitpack2.py branches/refactor_fft/scipy/interpolate/interpolate.py branches/refactor_fft/scipy/interpolate/rbf.py branches/refactor_fft/scipy/interpolate/tests/test_fitpack.py branches/refactor_fft/scipy/interpolate/tests/test_interpolate.py branches/refactor_fft/scipy/io/array_import.py branches/refactor_fft/scipy/io/matlab/miobase.py branches/refactor_fft/scipy/io/matlab/tests/test_mio.py branches/refactor_fft/scipy/io/mmio.py branches/refactor_fft/scipy/io/tests/test_mmio.py branches/refactor_fft/scipy/io/wavfile.py branches/refactor_fft/scipy/lib/blas/scons_support.py branches/refactor_fft/scipy/lib/lapack/scons_support.py branches/refactor_fft/scipy/linalg/scons_support.py branches/refactor_fft/scipy/ndimage/_registration.py branches/refactor_fft/scipy/ndimage/src/register/Register_EXT.c branches/refactor_fft/scipy/ndimage/src/register/Register_IMPL.c branches/refactor_fft/scipy/ndimage/tests/test_segment.py branches/refactor_fft/scipy/optimize/anneal.py branches/refactor_fft/scipy/optimize/minpack.py branches/refactor_fft/scipy/setup.py branches/refactor_fft/scipy/setupscons.py branches/refactor_fft/scipy/signal/signaltools.py branches/refactor_fft/scipy/sparse/base.py branches/refactor_fft/scipy/sparse/compressed.py branches/refactor_fft/scipy/sparse/construct.py branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/arpack.py branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/speigs.py branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py branches/refactor_fft/scipy/sparse/linalg/isolve/utils.py branches/refactor_fft/scipy/sparse/sparsetools/coo.h branches/refactor_fft/scipy/sparse/tests/test_base.py branches/refactor_fft/scipy/special/_cephesmodule.c branches/refactor_fft/scipy/special/specfun.pyf branches/refactor_fft/scipy/special/specfun_wrappers.c branches/refactor_fft/scipy/special/specfun_wrappers.h branches/refactor_fft/scipy/special/tests/test_basic.py branches/refactor_fft/scipy/stats/models/formula.py branches/refactor_fft/scipy/stats/models/tests/test_bspline.py branches/refactor_fft/scipy/stats/mstats.py branches/refactor_fft/scipy/stats/stats.py branches/refactor_fft/scipy/stats/tests/test_stats.py branches/refactor_fft/scipy/testing/__init__.py branches/refactor_fft/scipy/testing/decorators.py branches/refactor_fft/scipy/testing/nosetester.py branches/refactor_fft/scipy/testing/pkgtester.py branches/refactor_fft/scipy/weave/tests/test_wx_spec.py Log: Merged revisions 4379-4510 via svnmerge from http://svn.scipy.org/svn/scipy/trunk ........ r4389 | chris.burns | 2008-05-29 05:17:44 +0900 (Thu, 29 May 2008) | 1 line Fix nose call to run test. ........ r4390 | chris.burns | 2008-05-29 05:34:43 +0900 (Thu, 29 May 2008) | 1 line Modify imports to match scipy standards. ........ r4391 | oliphant | 2008-05-29 08:46:58 +0900 (Thu, 29 May 2008) | 1 line Add filtfilt function to scipy. Make fixed_point into a vectorized function. ........ r4392 | tom.waite | 2008-05-29 08:58:51 +0900 (Thu, 29 May 2008) | 1 line Added lower triangular tensor product for NIPY normalize ........ r4393 | tom.waite | 2008-05-29 08:59:15 +0900 (Thu, 29 May 2008) | 1 line Added lower triangular tensor product for NIPY normalize ........ r4394 | tom.waite | 2008-05-30 10:21:37 +0900 (Fri, 30 May 2008) | 1 line removed the integer truncation of image resample gradients. ........ r4395 | damian.eads | 2008-05-30 11:23:09 +0900 (Fri, 30 May 2008) | 1 line Added some more test data. ........ r4396 | damian.eads | 2008-05-31 04:36:47 +0900 (Sat, 31 May 2008) | 1 line Added some initial tests for hierarchy.linkage and hierarchy.squareform ........ r4397 | damian.eads | 2008-05-31 05:30:15 +0900 (Sat, 31 May 2008) | 1 line Fixed bug in hierarchy.is_valid_linkage. Wrote tests for hierarchy.numobs. ........ r4398 | damian.eads | 2008-05-31 05:57:27 +0900 (Sat, 31 May 2008) | 1 line Fixed a boundary condition bug in hierarchy.squareform with 0-length pdist arrays. ........ r4399 | damian.eads | 2008-05-31 06:38:29 +0900 (Sat, 31 May 2008) | 1 line Added tests for hierarchy.{yule,sokalsneath,matching,jaccard} ........ r4400 | damian.eads | 2008-05-31 06:57:10 +0900 (Sat, 31 May 2008) | 1 line Polishing some tests. ........ r4401 | oliphant | 2008-05-31 08:51:35 +0900 (Sat, 31 May 2008) | 1 line Re-factor scipy.optimize.fixed_point to handle vector and scalar portions separately. ........ r4402 | oliphant | 2008-05-31 09:15:46 +0900 (Sat, 31 May 2008) | 1 line Fix wavfile reading for 64-bit platforms. ........ r4403 | wnbell | 2008-06-03 11:00:08 +0900 (Tue, 03 Jun 2008) | 3 lines fixed missing import of numpy.multiply resolves ticket #680 ........ r4404 | damian.eads | 2008-06-03 13:41:10 +0900 (Tue, 03 Jun 2008) | 1 line Added small boolean observation vector data set for testing boolean distance metrics. ........ r4405 | damian.eads | 2008-06-03 15:50:49 +0900 (Tue, 03 Jun 2008) | 1 line Removed unnecessary imports in hierarchy and refactored its code. Wrote more tests. ........ r4406 | damian.eads | 2008-06-03 16:35:10 +0900 (Tue, 03 Jun 2008) | 1 line Removed unnecessary imports in hierarchy and refactored its code. Wrote more tests. ........ r4407 | damian.eads | 2008-06-03 16:48:54 +0900 (Tue, 03 Jun 2008) | 1 line Convert non-double arrays to double so that hierarchy functions can be called with more input types. ........ r4408 | damian.eads | 2008-06-03 17:51:31 +0900 (Tue, 03 Jun 2008) | 1 line Fixed minor dtype conversion bug in hierarchy.linkage. ........ r4409 | jarrod.millman | 2008-06-04 00:55:06 +0900 (Wed, 04 Jun 2008) | 2 lines updated 1.0.5 to 1.1.0 ........ r4410 | damian.eads | 2008-06-04 02:50:47 +0900 (Wed, 04 Jun 2008) | 1 line Removed more unnecessary imports in hierarchy, namely sys and math. Now uses np.ndarray instead of _array_type for type checking. ........ r4411 | damian.eads | 2008-06-04 02:53:23 +0900 (Wed, 04 Jun 2008) | 1 line Changed allocation of result arrays in hierarchy so np.int is used instead of np.int32. Will assume np.int corresponds to the int data type in C on the host machine. ........ r4412 | damian.eads | 2008-06-04 17:08:30 +0900 (Wed, 04 Jun 2008) | 1 line Fixed issue with cosine. ........ r4413 | pierregm | 2008-06-05 01:21:10 +0900 (Thu, 05 Jun 2008) | 2 lines * Fixed some documentation * Fixed theilslopes ........ r4414 | wnbell | 2008-06-06 15:29:48 +0900 (Fri, 06 Jun 2008) | 2 lines minor cleanup of lobpcg ........ r4415 | wnbell | 2008-06-06 15:54:44 +0900 (Fri, 06 Jun 2008) | 2 lines renamed lobpcg parameters to better conform to other iterative methods ........ r4416 | wnbell | 2008-06-07 17:13:02 +0900 (Sat, 07 Jun 2008) | 2 lines added coo_matvec ........ r4417 | damian.eads | 2008-06-09 14:55:44 +0900 (Mon, 09 Jun 2008) | 1 line Moved distance functions to new module. ........ r4418 | damian.eads | 2008-06-09 14:59:39 +0900 (Mon, 09 Jun 2008) | 1 line Added information on distance module in cluster/info.py ........ r4419 | damian.eads | 2008-06-09 15:01:51 +0900 (Mon, 09 Jun 2008) | 1 line Added extension building code for distance_wrap to cluster/SConstruct ........ r4420 | damian.eads | 2008-06-09 15:05:10 +0900 (Mon, 09 Jun 2008) | 1 line Added import to cluster/__init__.py. Removed pdist import from hierarchy. ........ r4421 | tom.waite | 2008-06-10 07:42:02 +0900 (Tue, 10 Jun 2008) | 2 lines bug fixes ........ r4422 | wnbell | 2008-06-10 12:40:56 +0900 (Tue, 10 Jun 2008) | 3 lines Added patch by Andrew Straw to fix MATLAB support on gzip files resolves ticket #682 ........ r4423 | rkern | 2008-06-10 15:35:31 +0900 (Tue, 10 Jun 2008) | 1 line Correct syntax typo. Fix a few undefined references while I'm at it, too. pyflakes rules. ........ r4424 | rkern | 2008-06-11 19:47:02 +0900 (Wed, 11 Jun 2008) | 1 line Use local imports to avoid importing nose until tests are actually requested. This speeds up the load-time of scipy. ........ r4425 | cdavid | 2008-06-12 00:36:30 +0900 (Thu, 12 Jun 2008) | 1 line Remove executable bit for test_stats.py ........ r4426 | cdavid | 2008-06-12 00:38:20 +0900 (Thu, 12 Jun 2008) | 1 line Put nanmean, nanstd and nanmedian into scipy.stats namespace + adapt tests. ........ r4427 | cdavid | 2008-06-12 19:07:55 +0900 (Thu, 12 Jun 2008) | 1 line Move all scons SConstruct to SConscript, for upcoming adpatation to new numscons build_dir architecture. ........ r4428 | cdavid | 2008-06-12 19:14:16 +0900 (Thu, 12 Jun 2008) | 1 line Add SConstruct file for scipy.cluter. ........ r4429 | cdavid | 2008-06-12 19:16:21 +0900 (Thu, 12 Jun 2008) | 1 line Add SConstruct files for all pkgs built with scons script. ........ r4430 | cdavid | 2008-06-12 19:18:28 +0900 (Thu, 12 Jun 2008) | 1 line Renamve NumpyPythonExtension to DistutilsPythonExtension. ........ r4431 | cdavid | 2008-06-12 19:20:52 +0900 (Thu, 12 Jun 2008) | 1 line rename numpyf2py to f2py scons tool; numpyf2py is deprecated. ........ r4432 | cdavid | 2008-06-12 19:23:33 +0900 (Thu, 12 Jun 2008) | 1 line Rename NumpyStaticExtLibrary to DistutilsStaticExtLibrary. ........ r4433 | cdavid | 2008-06-12 19:25:25 +0900 (Thu, 12 Jun 2008) | 1 line Fix libpath issue with new scons build_dir. ........ r4434 | cdavid | 2008-06-12 19:38:29 +0900 (Thu, 12 Jun 2008) | 1 line Replace build_dir by current directory when used as a LIBPATH. ........ r4435 | cdavid | 2008-06-12 19:45:57 +0900 (Thu, 12 Jun 2008) | 1 line Do not play with build_dir anymore in emitters. ........ r4436 | cdavid | 2008-06-12 19:47:48 +0900 (Thu, 12 Jun 2008) | 1 line Remove last build_dir uses. ........ r4437 | cdavid | 2008-06-12 19:58:13 +0900 (Thu, 12 Jun 2008) | 1 line Replace depreacted NumpyFrom*Template builders by their new names. ........ r4438 | cdavid | 2008-06-12 19:59:41 +0900 (Thu, 12 Jun 2008) | 1 line Replace depreacted NumpyF2py builder by their new names. ........ r4439 | cdavid | 2008-06-12 20:23:17 +0900 (Thu, 12 Jun 2008) | 1 line Fix some include paths related to scons build_dir arch changes. ........ r4440 | cdavid | 2008-06-12 20:26:55 +0900 (Thu, 12 Jun 2008) | 1 line Use Glob instead of NumpyGlob, which is not needed anymore. ........ r4441 | wnbell | 2008-06-13 06:39:52 +0900 (Fri, 13 Jun 2008) | 3 lines fixed bug reported by James Philbin http://thread.gmane.org/gmane.comp.python.scientific.user/16720 ........ r4442 | wnbell | 2008-06-13 07:09:16 +0900 (Fri, 13 Jun 2008) | 2 lines removed splinalg ........ r4443 | wnbell | 2008-06-13 07:14:49 +0900 (Fri, 13 Jun 2008) | 2 lines silenced ARPACK debugging output ........ r4444 | wnbell | 2008-06-13 12:08:49 +0900 (Fri, 13 Jun 2008) | 2 lines fix problem with writing CSR/CSC matrices in MatrixMarket format ........ r4445 | wnbell | 2008-06-13 12:16:04 +0900 (Fri, 13 Jun 2008) | 2 lines add sparse ignore filter ........ r4446 | rkern | 2008-06-17 10:19:04 +0900 (Tue, 17 Jun 2008) | 1 line BUG: Ensure that no subpackage name is added to scipy.__all__. ........ r4447 | tom.waite | 2008-06-19 04:04:15 +0900 (Thu, 19 Jun 2008) | 1 line Parameter checking. Replace c-extension integrated histogram thresholding with pure numpy version. ........ r4448 | tom.waite | 2008-06-19 07:15:03 +0900 (Thu, 19 Jun 2008) | 1 line added for testing registration ........ r4449 | tom.waite | 2008-06-19 07:36:32 +0900 (Thu, 19 Jun 2008) | 1 line remove demo methods which go to nipy registration ........ r4450 | tom.waite | 2008-06-19 08:13:03 +0900 (Thu, 19 Jun 2008) | 1 line fixed axis bug in build_fwhm method ........ r4455 | wnbell | 2008-06-21 18:04:55 +0900 (Sat, 21 Jun 2008) | 3 lines should fix ticket #611 the code seemed to be capturing the wrong Exception type ........ r4456 | cdavid | 2008-06-21 20:28:01 +0900 (Sat, 21 Jun 2008) | 1 line No splinalg anymore, remove it from scons build. ........ r4457 | cdavid | 2008-06-22 01:48:48 +0900 (Sun, 22 Jun 2008) | 1 line Add regression test for #413. ........ r4458 | cdavid | 2008-06-23 00:14:43 +0900 (Mon, 23 Jun 2008) | 1 line Do not run bspline tests if _bspline is not available. ........ r4459 | cdavid | 2008-06-23 00:45:05 +0900 (Mon, 23 Jun 2008) | 1 line Fix weave test: conditionally import wx to avoid ImportError for platforms wo wx. ........ r4460 | cdavid | 2008-06-23 01:25:32 +0900 (Mon, 23 Jun 2008) | 1 line Add a note on CFLAGS and co. ........ r4461 | cdavid | 2008-06-23 01:27:28 +0900 (Mon, 23 Jun 2008) | 1 line Revert accidentaly commited print debug statement. ........ r4462 | cdavid | 2008-06-23 22:57:33 +0900 (Mon, 23 Jun 2008) | 1 line Flag some memory hungry tests as slow. ........ r4463 | cdavid | 2008-06-23 22:58:24 +0900 (Mon, 23 Jun 2008) | 1 line Do not run wx tests if wx not found. ........ r4464 | cdavid | 2008-06-23 23:30:58 +0900 (Mon, 23 Jun 2008) | 1 line Maybe I will get this right at some point: set DONOTRUN to False by default to decide wether we should run some weave test or not. ........ r4465 | cdavid | 2008-06-23 23:37:03 +0900 (Mon, 23 Jun 2008) | 1 line Fix #505 in scipy.cluster: unhelpful message when size 0 arrays are input. ........ r4466 | ptvirtan | 2008-06-24 05:53:22 +0900 (Tue, 24 Jun 2008) | 1 line Reformat integrate.odeint docstring ........ r4467 | ptvirtan | 2008-06-24 06:14:11 +0900 (Tue, 24 Jun 2008) | 1 line Wrap and expose dblint from dfitpack. (Implements #206). Add corresponding tests. ........ r4468 | wnbell | 2008-06-24 09:54:19 +0900 (Tue, 24 Jun 2008) | 2 lines addresses ticket #659 ........ r4469 | cdavid | 2008-06-24 16:46:46 +0900 (Tue, 24 Jun 2008) | 1 line Fix #535 with tests. ........ r4470 | cdavid | 2008-06-24 16:59:43 +0900 (Tue, 24 Jun 2008) | 1 line Handle bogus number of clusters better + test. ........ r4471 | cdavid | 2008-06-24 17:01:24 +0900 (Tue, 24 Jun 2008) | 1 line Fix 535 first comment. ........ r4472 | cdavid | 2008-06-24 17:02:32 +0900 (Tue, 24 Jun 2008) | 1 line Set regression test to correct number. ........ r4474 | cdavid | 2008-06-24 19:52:35 +0900 (Tue, 24 Jun 2008) | 1 line Add test for #8. ........ r4475 | cdavid | 2008-06-24 20:41:19 +0900 (Tue, 24 Jun 2008) | 1 line Do not set imxer to unitiliazed value if not set by fortran. ........ r4476 | wnbell | 2008-06-24 22:53:46 +0900 (Tue, 24 Jun 2008) | 2 lines edited a few docstrings ........ r4477 | cdavid | 2008-06-24 23:23:09 +0900 (Tue, 24 Jun 2008) | 1 line Add Damiean Eads and me in THANKS.txt. ........ r4478 | rkern | 2008-06-25 02:48:31 +0900 (Wed, 25 Jun 2008) | 1 line BUG: Allow __del__ to work even when self.file never got constructed. Thanks to Yosef Meller for finding this bug and suggesting the fix. #681 ........ r4479 | ilan | 2008-06-26 00:43:39 +0900 (Thu, 26 Jun 2008) | 1 line Adding project mkufunc (make U function decorator) to sandbox ........ r4480 | ilan | 2008-06-26 00:59:50 +0900 (Thu, 26 Jun 2008) | 2 lines Testing output files ........ r4481 | ilan | 2008-06-26 01:12:15 +0900 (Thu, 26 Jun 2008) | 1 line Added readme file ........ r4482 | tom.waite | 2008-06-27 03:49:38 +0900 (Fri, 27 Jun 2008) | 1 line replace parameter vector with inverse affine matrix as input to remap_image method ........ r4483 | ilan | 2008-06-27 11:14:16 +0900 (Fri, 27 Jun 2008) | 1 line Added test for speed comparison ........ r4484 | ilan | 2008-06-27 12:04:21 +0900 (Fri, 27 Jun 2008) | 1 line Adding documentation ........ r4485 | ilan | 2008-06-27 22:24:23 +0900 (Fri, 27 Jun 2008) | 1 line Started unittest suite and other small changes ........ r4486 | rkern | 2008-06-28 04:37:49 +0900 (Sat, 28 Jun 2008) | 1 line BUG: fix missing import and 'gausian' typo. Thanks to Lorenzo Bolla for the patch. ........ r4487 | ilan | 2008-06-28 07:29:20 +0900 (Sat, 28 Jun 2008) | 1 line Added blitz ........ r4488 | ilan | 2008-06-28 10:34:29 +0900 (Sat, 28 Jun 2008) | 1 line started work on typecasting ........ r4489 | ptvirtan | 2008-06-28 22:54:11 +0900 (Sat, 28 Jun 2008) | 1 line interpolate: Fix #289. Make interp1d order axes in the result correctly when y.ndim > 2. Fix a bug in splmake that was triggered when y.ndim > 2. Add corresponding tests. ........ r4490 | ilan | 2008-06-28 23:36:29 +0900 (Sat, 28 Jun 2008) | 1 line Improved dispatch on type in mkufunc and added more tests ........ r4491 | ilan | 2008-06-29 00:40:16 +0900 (Sun, 29 Jun 2008) | 1 line Moved some tests ........ r4492 | ilan | 2008-06-29 04:05:29 +0900 (Sun, 29 Jun 2008) | 1 line Implemented multiple input arguments ........ r4493 | ilan | 2008-06-29 05:37:04 +0900 (Sun, 29 Jun 2008) | 1 line Added more test cases ........ r4494 | ilan | 2008-06-29 06:17:58 +0900 (Sun, 29 Jun 2008) | 1 line Improved type checking and added tests to see if TypeError was raised ........ r4495 | ilan | 2008-06-29 09:45:36 +0900 (Sun, 29 Jun 2008) | 1 line Refactoring ........ r4496 | ilan | 2008-06-29 09:47:14 +0900 (Sun, 29 Jun 2008) | 2 lines Now all in test_mkufunc.py ........ r4497 | ilan | 2008-06-29 17:47:38 +0900 (Sun, 29 Jun 2008) | 1 line Implements a function for getting an MD5 from the bytecode of a function ........ r4498 | ilan | 2008-06-29 17:53:48 +0900 (Sun, 29 Jun 2008) | 1 line Numerous changes, mostly regarding for preparing caching ........ r4499 | ilan | 2008-06-29 19:30:22 +0900 (Sun, 29 Jun 2008) | 1 line Free variables still need work ........ r4500 | ilan | 2008-06-30 07:21:36 +0900 (Mon, 30 Jun 2008) | 1 line Implemented caching for pypy translated functions, also temp files are now stored in weave's temp directory. ........ r4501 | ilan | 2008-06-30 09:07:36 +0900 (Mon, 30 Jun 2008) | 1 line Moved tests into seperate file ........ r4502 | ilan | 2008-06-30 10:32:41 +0900 (Mon, 30 Jun 2008) | 1 line Refactoring ........ r4503 | ilan | 2008-06-30 12:19:29 +0900 (Mon, 30 Jun 2008) | 1 line PyPy output source now also in support code; no more pypy.c ........ r4504 | ilan | 2008-06-30 23:08:53 +0900 (Mon, 30 Jun 2008) | 1 line Added test for function with no args ........ r4505 | rkern | 2008-07-01 01:21:16 +0900 (Tue, 01 Jul 2008) | 1 line BUG: handle a broader range of function outputs. Thanks to Yosef Meller for the fix. ........ r4506 | ilan | 2008-07-01 04:19:55 +0900 (Tue, 01 Jul 2008) | 1 line Simplyfied func_hash and put into main file ........ r4507 | ilan | 2008-07-01 09:32:12 +0900 (Tue, 01 Jul 2008) | 1 line Made a package which uses setuptools ........ r4508 | ilan | 2008-07-01 09:35:15 +0900 (Tue, 01 Jul 2008) | 1 line Moved into mkufunc/ ........ r4509 | ilan | 2008-07-01 09:36:02 +0900 (Tue, 01 Jul 2008) | 1 line Moved into mkufunc/ ........ r4510 | ilan | 2008-07-01 09:46:27 +0900 (Tue, 01 Jul 2008) | 1 line Test removed ........ Property changes on: branches/refactor_fft ___________________________________________________________________ Name: svnmerge-integrated - /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4378 + /branches/build_with_scons:1-3868 /branches/scipy.scons:1-3533 /branches/sparse_build_reduce_mem:1-4005 /branches/testing_cleanup:1-3662 /trunk:1-4510 Modified: branches/refactor_fft/INSTALL.txt =================================================================== --- branches/refactor_fft/INSTALL.txt 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/INSTALL.txt 2008-07-01 04:52:00 UTC (rev 4511) @@ -32,7 +32,7 @@ __ http://www.python.org -2) NumPy__ 1.0.5 or newer +2) NumPy__ 1.1.0 or newer Debian package: python-numpy @@ -178,6 +178,11 @@ It is not necessary to install blas or lapack libraries in addition. + 4) Compiler flags customization (FFLAGS, CFLAGS, etc...). If you customize + CFLAGS and other related flags from the command line or the shell environment, + beware that is does not have the standard behavior of appending options. + Instead, it overrides the options. As such, you have to give all options in the + flag for the build to be successful. GETTING SCIPY ============= Modified: branches/refactor_fft/THANKS.txt =================================================================== --- branches/refactor_fft/THANKS.txt 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/THANKS.txt 2008-07-01 04:52:00 UTC (rev 4511) @@ -29,6 +29,8 @@ sparse matrix module Travis Vaught -- initial work on stats module clean up Jeff Whitaker -- Mac OS X support +David Cournapeau -- bug-fixes, refactor of fftpack and cluster, numscons build. +Damian Eads -- hiearchical clustering Testing: Modified: branches/refactor_fft/scipy/__init__.py =================================================================== --- branches/refactor_fft/scipy/__init__.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/__init__.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -44,6 +44,7 @@ # Remove the linalg imported from numpy so that the scipy.linalg package can be # imported. del linalg +__all__.remove('linalg') try: from __config__ import show as show_config @@ -61,6 +62,20 @@ del _os pkgload = PackageLoader() pkgload(verbose=SCIPY_IMPORT_VERBOSE,postpone=True) + +# Remove subpackage names from __all__ such that they are not imported via +# "from scipy import *". This works around a numpy bug present in < 1.2. +subpackages = """cluster constants fftpack integrate interpolate io lib linalg +linsolve maxentropy misc ndimage odr optimize sandbox signal sparse special +splinalg stats stsci testing weave""".split() +for name in subpackages: + try: + __all__.remove(name) + except ValueError: + pass + +del name, subpackages + __doc__ += """ Available subpackages Copied: branches/refactor_fft/scipy/cluster/SConscript (from rev 4510, trunk/scipy/cluster/SConscript) Deleted: branches/refactor_fft/scipy/cluster/SConstruct =================================================================== --- branches/refactor_fft/scipy/cluster/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,15 +0,0 @@ -# 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 numscons 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')]) - -env.NumpyPythonExtension('_hierarchy_wrap', source = [join('src', 'hierarchy_wrap.c'), - join('src', 'hierarchy.c')]) Copied: branches/refactor_fft/scipy/cluster/SConstruct (from rev 4510, trunk/scipy/cluster/SConstruct) Modified: branches/refactor_fft/scipy/cluster/__init__.py =================================================================== --- branches/refactor_fft/scipy/cluster/__init__.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/__init__.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -4,8 +4,8 @@ from info import __doc__ -__all__ = ['vq', 'hierarchy'] +__all__ = ['vq', 'hierarchy', 'distance'] -import vq, hierarchy +import vq, hierarchy, distance from scipy.testing.pkgtester import Tester test = Tester().test Copied: branches/refactor_fft/scipy/cluster/distance.py (from rev 4510, trunk/scipy/cluster/distance.py) Modified: branches/refactor_fft/scipy/cluster/hierarchy.py =================================================================== --- branches/refactor_fft/scipy/cluster/hierarchy.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/hierarchy.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -22,9 +22,6 @@ median the median/WPGMC algorithm. (alias) ward the Ward/incremental algorithm. (alias) -Distance matrix computation from a collection of raw observation vectors - - pdist computes distances between each observation pair. squareform converts a sq. D.M. to a condensed one and vice versa. Statistic computations on hierarchies @@ -47,30 +44,6 @@ lvlist a left-to-right traversal of the leaves. totree represents a linkage matrix as a tree object. -Distance functions between two vectors u and v - - braycurtis the Bray-Curtis distance. - canberra the Canberra distance. - chebyshev the Chebyshev distance. - cityblock the Manhattan distance. - correlation the Correlation distance. - cosine the Cosine distance. - dice the Dice dissimilarity (boolean). - euclidean the Euclidean distance. - hamming the Hamming distance (boolean). - jaccard the Jaccard distance (boolean). - kulsinski the Kulsinski distance (boolean). - mahalanobis the Mahalanobis distance. - matching the matching dissimilarity (boolean). - minkowski the Minkowski distance. - rogerstanimoto the Rogers-Tanimoto dissimilarity (boolean). - russellrao the Russell-Rao dissimilarity (boolean). - seuclidean the normalized Euclidean distance. - sokalmichener the Sokal-Michener dissimilarity (boolean). - sokalsneath the Sokal-Sneath dissimilarity (boolean). - sqeuclidean the squared Euclidean distance. - yule the Yule dissimilarity (boolean). - Predicates is_valid_dm checks for a valid distance matrix. @@ -175,32 +148,23 @@ """ import numpy as np -import _hierarchy_wrap, scipy, types, math, sys, scipy.stats +import _hierarchy_wrap, types +import distance _cpy_non_euclid_methods = {'single': 0, 'complete': 1, 'average': 2, 'weighted': 6} _cpy_euclid_methods = {'centroid': 3, 'median': 4, 'ward': 5} _cpy_linkage_methods = set(_cpy_non_euclid_methods.keys()).union( set(_cpy_euclid_methods.keys())) -_array_type = np.ndarray try: import warnings def _warning(s): - warnings.warn('scipy-cluster: %s' % s, stacklevel=3) + warnings.warn('scipy.cluster: %s' % s, stacklevel=3) except: def _warning(s): - print ('[WARNING] scipy-cluster: %s' % s) + print ('[WARNING] scipy.cluster: %s' % s) -def _unbiased_variance(X): - """ - Computes the unbiased variance of each dimension of a collection of - observation vectors, represented by a matrix where the rows are the - observations. - """ - #n = np.double(X.shape[1]) - return scipy.stats.var(X, axis=0) # * n / (n - 1.0) - def _copy_array_if_base_present(a): """ Copies the array if its base points to a parent array. @@ -452,7 +416,7 @@ if not isinstance(method, str): raise TypeError("Argument 'method' must be a string.") - y = np.asarray(y) + y = _convert_to_double(np.asarray(y)) s = y.shape if len(s) == 1: @@ -473,14 +437,14 @@ if method not in _cpy_linkage_methods: raise ValueError('Invalid method: %s' % method) if method in _cpy_non_euclid_methods.keys(): - dm = pdist(X, metric) + dm = distance.pdist(X, metric) Z = np.zeros((n - 1, 4)) _hierarchy_wrap.linkage_wrap(dm, Z, n, \ int(_cpy_non_euclid_methods[method])) elif method in _cpy_euclid_methods.keys(): if metric != 'euclidean': raise ValueError('Method %s requires the distance metric to be euclidean' % s) - dm = pdist(X, metric) + dm = distance.pdist(X, metric) Z = np.zeros((n - 1, 4)) _hierarchy_wrap.linkage_euclid_wrap(dm, Z, X, m, n, int(_cpy_euclid_methods[method])) @@ -638,6 +602,8 @@ functions in this library. """ + Z = np.asarray(Z) + is_valid_linkage(Z, throw=True, name='Z') # The number of original objects is equal to the number of rows minus @@ -721,7 +687,7 @@ transformation. """ - X = np.asarray(X) + X = _convert_to_double(np.asarray(X)) if not np.issubsctype(X, np.double): raise TypeError('A double array must be passed.') @@ -730,12 +696,14 @@ # X = squareform(v) if len(s) == 1 and force != 'tomatrix': + if X.shape[0] == 0: + return np.zeros((1,1), dtype=np.double) + # Grab the closest value to the square root of the number # of elements times 2 to see if the number of elements # is indeed a binomial coefficient. d = int(np.ceil(np.sqrt(X.shape[0] * 2))) - print d, s[0] # Check that v is of valid dimensions. if d * (d - 1) / 2 != int(s[0]): raise ValueError('Incompatible vector size. It must be a binomial coefficient n choose 2 for some integer n >= 2.') @@ -760,13 +728,16 @@ raise ValueError('The matrix argument must be square.') if checks: if np.sum(np.sum(X == X.transpose())) != np.product(X.shape): - raise ValueError('The distance matrix must be symmetrical.') + raise ValueError('The distance matrix array must be symmetrical.') if (X.diagonal() != 0).any(): - raise ValueError('The distance matrix must have zeros along the diagonal.') + raise ValueError('The distance matrix array must have zeros along the diagonal.') # One-side of the dimensions is set here. d = s[0] + if d <= 1: + return np.array([], dtype=np.double) + # Create a vector. v = np.zeros(((d * (d - 1) / 2),), dtype=np.double) @@ -780,717 +751,22 @@ elif len(s) != 2 and force.lower() == 'tomatrix': raise ValueError("Forcing 'tomatrix' but input X is not a distance vector.") else: - raise ValueError('The first argument must be a vector or matrix. A %d-dimensional array is not permitted' % len(s)) + raise ValueError('The first argument must be one or two dimensional array. A %d-dimensional array is not permitted' % len(s)) -def minkowski(u, v, p): - """ - d = minkowski(u, v, p) +def _convert_to_bool(X): + if X.dtype != np.bool: + X = np.bool_(X) + if not X.flags.contiguous: + X = X.copy() + return X - Returns the Minkowski distance between two vectors u and v, +def _convert_to_double(X): + if X.dtype != np.double: + X = np.double(X) + if not X.flags.contiguous: + X = X.copy() + return X - ||u-v||_p = (\sum {|u_i - v_i|^p})^(1/p). - """ - if p < 1: - raise ValueError("p must be at least 1") - return math.pow((abs(u-v)**p).sum(), 1.0/p) - -def euclidean(u, v): - """ - d = euclidean(u, v) - - Computes the Euclidean distance between two n-vectors u and v, ||u-v||_2 - """ - q=np.matrix(u-v) - return np.sqrt((q*q.T).sum()) - -def sqeuclidean(u, v): - """ - d = sqeuclidean(u, v) - - Computes the squared Euclidean distance between two n-vectors u and v, - (||u-v||_2)^2. - """ - return ((u-v)*(u-v).T).sum() - -def cosine(u, v): - """ - d = cosine(u, v) - - Computes the Cosine distance between two n-vectors u and v, - (1-uv^T)/(||u||_2 * ||v||_2). - """ - return (1.0 - (scipy.dot(u, v.T) / \ - (np.sqrt(scipy.dot(u, u.T)) * np.sqrt(scipy.dot(v, v.T))))) - -def correlation(u, v): - """ - d = correlation(u, v) - - Computes the correlation distance between two n-vectors u and v, - - 1 - (u - n|u|_1)(v - n|v|_1)^T - --------------------------------- , - |(u - n|u|_1)|_2 |(v - n|v|_1)|^T - - where |*|_1 is the Manhattan norm and n is the common dimensionality - of the vectors. - """ - umu = u.mean() - vmu = v.mean() - um = u - umu - vm = v - vmu - return 1.0 - (scipy.dot(um, vm) / - (np.sqrt(scipy.dot(um, um)) \ - * np.sqrt(scipy.dot(vm, vm)))) - -def hamming(u, v): - """ - d = hamming(u, v) - - Computes the Hamming distance between two n-vectors u and v, - which is simply the proportion of disagreeing components in u - and v. If u and v are boolean vectors, the hamming distance is - - (c_{01} + c_{10}) / n - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n. - """ - return (u != v).mean() - -def jaccard(u, v): - """ - d = jaccard(u, v) - - Computes the Jaccard-Needham dissimilarity between two boolean - n-vectors u and v, which is - - c_{TF} + c_{FT} - ------------------------ - c_{TT} + c_{FT} + c_{TF} - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n. - """ - return (np.double(np.bitwise_and((u != v), - np.bitwise_or(u != 0, v != 0)).sum()) - / np.double(np.bitwise_or(u != 0, v != 0).sum())) - -def kulsinski(u, v): - """ - d = kulsinski(u, v) - - Computes the Kulsinski dissimilarity between two boolean n-vectors - u and v, which is - - c_{TF} + c_{FT} - c_{TT} + n - ---------------------------- - c_{FT} + c_{TF} + n - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n. - """ - (nff, nft, ntf, ntt) = _nbool_correspond_all(u, v) - - return (ntf + nft - ntt + n) / (ntf + nft + n) - -def seuclidean(u, v, V): - """ - d = seuclidean(u, v, V) - - Returns the standardized Euclidean distance between two - n-vectors u and v. V is a m-dimensional vector of component - variances. It is usually computed among a larger collection vectors. - """ - V = np.asarray(V) - if len(V.shape) != 1 or V.shape[0] != u.shape[0] or u.shape[0] != v.shape[0]: - raise TypeError('V must be a 1-D array of the same dimension as u and v.') - return np.sqrt(((u-v)**2 / V).sum()) - -def cityblock(u, v): - """ - d = cityblock(u, v) - - Computes the Manhattan distance between two n-vectors u and v, - \sum {u_i-v_i}. - """ - return abs(u-v).sum() - -def mahalanobis(u, v, VI): - """ - d = mahalanobis(u, v, VI) - - Computes the Mahalanobis distance between two n-vectors u and v, - (u-v)VI(u-v)^T - where VI is the inverse covariance matrix. - """ - V = np.asarray(V) - return np.sqrt(np.dot(np.dot((u-v),VI),(u-v).T).sum()) - -def chebyshev(u, v): - """ - d = chebyshev(u, v) - - Computes the Chebyshev distance between two n-vectors u and v, - \max {|u_i-v_i|}. - """ - return max(abs(u-v)) - -def braycurtis(u, v): - """ - d = braycurtis(u, v) - - Computes the Bray-Curtis distance between two n-vectors u and v, - \sum{|u_i-v_i|} / \sum{|u_i+v_i|}. - """ - return abs(u-v).sum() / abs(u+v).sum() - -def canberra(u, v): - """ - d = canberra(u, v) - - Computes the Canberra distance between two n-vectors u and v, - \sum{|u_i-v_i|} / \sum{|u_i|+|v_i}. - """ - return abs(u-v).sum() / (abs(u).sum() + abs(v).sum()) - -def _nbool_correspond_all(u, v): - not_u = scipy.bitwise_not(u) - not_v = scipy.bitwise_not(v) - nff = scipy.bitwise_and(not_u, not_v).sum() - nft = scipy.bitwise_and(not_u, v).sum() - ntf = scipy.bitwise_and(u, not_v).sum() - ntt = scipy.bitwise_and(u, v).sum() - return (nff, nft, ntf, ntt) - -def _nbool_correspond_ft_tf(u, v): - not_u = scipy.bitwise_not(u) - not_v = scipy.bitwise_not(v) - nft = scipy.bitwise_and(not_u, v).sum() - ntf = scipy.bitwise_and(u, not_v).sum() - return (nft, ntf) - -def yule(u, v): - """ - d = yule(u, v) - Computes the Yule dissimilarity between two boolean n-vectors u and v, - - R - --------------------- - c_{TT} + c_{FF} + R/2 - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n, and - - R = 2.0 * (c_{TF} + c_{FT}). - """ - (nff, nft, ntf, ntt) = _nbool_correspond_all(u, v) - return float(2.0 * ntf * nft) / float(ntt * nff + ntf * nft) - -def matching(u, v): - """ - d = matching(u, v) - - Computes the Matching dissimilarity between two boolean n-vectors - u and v, which is - - (c_{TF} + c_{FT}) / n - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n. - """ - (nft, ntf) = _nbool_correspond_ft_tf(u, v) - return float(nft + ntf) / float(len(u)) - -def dice(u, v): - """ - d = dice(u, v) - - Computes the Dice dissimilarity between two boolean n-vectors - u and v, which is - - c_{TF} + c_{FT} - ---------------------------- - 2 * c_{TT} + c_{FT} + c_{TF} - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n. - """ - ntt = scipy.bitwise_and(u, v).sum() - (nft, ntf) = _nbool_correspond_ft_tf(u, v) - return float(ntf + nft)/float(2.0 * ntt + ntf + nft) - -def rogerstanimoto(u, v): - """ - d = rogerstanimoto(u, v) - - Computes the Rogers-Tanimoto dissimilarity between two boolean - n-vectors u and v, - - R - ------------------- - c_{TT} + c_{FF} + R - - where c_{ij} is the number of occurrences of - - u[k] == i and v[k] == j - - for k < n, and - - R = 2.0 * (c_{TF} + c_{FT}). - - """ - (nff, nft, ntf, ntt) = _nbool_correspond_all(u, v) - return float(2.0 * (ntf + nft)) / float(ntt + nff + (2.0 * (ntf + nft))) - -def russellrao(u, v): - """ - d = russellrao(u, v) - - Computes the Russell-Rao dissimilarity between two boolean n-vectors - u and v, (n - c_{TT}) / n where c_{ij} is the number of occurrences - of u[k] == i and v[k] == j for k < n. - """ - ntt = scipy.bitwise_and(u, v).sum() - return float(len(u) - ntt) / float(len(u)) - -def sokalmichener(u, v): - """ - d = sokalmichener(u, v) - - Computes the Sokal-Michener dissimilarity between two boolean vectors - u and v, 2R / (S + 2R) where c_{ij} is the number of occurrences of - u[k] == i and v[k] == j for k < n and R = 2 * (c_{TF} + c{FT}) and - S = c_{FF} + c_{TT}. - """ - ntt = scipy.bitwise_and(u, v).sum() - nff = scipy.bitwise_and(scipy.bitwise_not(u), scipy.bitwise_not(v)).sum() - (nft, ntf) = _nbool_correspond_ft_tf(u, v) - return float(2.0 * (ntf + nft))/float(ntt + nff + 2.0 * (ntf + nft)) - -def sokalsneath(u, v): - """ - d = sokalsneath(u, v) - - Computes the Sokal-Sneath dissimilarity between two boolean vectors - u and v, 2R / (c_{TT} + 2R) where c_{ij} is the number of occurrences - of u[k] == i and v[k] == j for k < n and R = 2 * (c_{TF} + c{FT}). - """ - ntt = scipy.bitwise_and(u, v).sum() - (nft, ntf) = _nbool_correspond_ft_tf(u, v) - return float(2.0 * (ntf + nft))/float(ntt + 2.0 * (ntf + nft)) - -# V means pass covariance -_pdist_metric_info = {'euclidean': ['double'], - 'seuclidean': ['double'], - 'sqeuclidean': ['double'], - 'minkowski': ['double'], - 'cityblock': ['double'], - 'cosine': ['double'], - 'correlation': ['double'], - 'hamming': ['double','bool'], - 'jaccard': ['double', 'bool'], - 'chebyshev': ['double'], - 'canberra': ['double'], - 'braycurtis': ['double'], - 'mahalanobis': ['bool'], - 'yule': ['bool'], - 'matching': ['bool'], - 'dice': ['bool'], - 'kulsinski': ['bool'], - 'rogerstanimoto': ['bool'], - 'russellrao': ['bool'], - 'sokalmichener': ['bool'], - 'sokalsneath': ['bool']} - -def pdist(X, metric='euclidean', p=2, V=None, VI=None): - """ Y = pdist(X, method='euclidean', p=2) - - Computes the distance between m original observations in - n-dimensional space. Returns a condensed distance matrix Y. - For each i and j (i=1. - - 3. Y = pdist(X, 'cityblock') - - Computes the city block or Manhattan distance between the - points. - - 4. Y = pdist(X, 'seuclidean', V=None) - - Computes the standardized Euclidean distance. The standardized - Euclidean distance between two n-vectors u and v is - - sqrt(\sum {(u_i-v_i)^2 / V[x_i]}). - - V is the variance vector; V[i] is the variance computed over all - the i'th components of the points. If not passed, it is - automatically computed. - - 5. Y = pdist(X, 'sqeuclidean') - - Computes the squared Euclidean distance ||u-v||_2^2 between - the vectors. - - 6. Y = pdist(X, 'cosine') - - Computes the cosine distance between vectors u and v, - - 1 - uv^T - ----------- - |u|_2 |v|_2 - - where |*|_2 is the 2 norm of its argument *. - - 7. Y = pdist(X, 'correlation') - - Computes the correlation distance between vectors u and v. This is - - 1 - (u - n|u|_1)(v - n|v|_1)^T - --------------------------------- , - |(u - n|u|_1)|_2 |(v - n|v|_1)|^T - - where |*|_1 is the Manhattan (or 1-norm) of its argument *, - and n is the common dimensionality of the vectors. - - 8. Y = pdist(X, 'hamming') - - Computes the normalized Hamming distance, or the proportion - of those vector elements between two n-vectors u and v which - disagree. To save memory, the matrix X can be of type boolean. - - 9. Y = pdist(X, 'jaccard') - - Computes the Jaccard distance between the points. Given two - vectors, u and v, the Jaccard distance is the proportion of - those elements u_i and v_i that disagree where at least one - of them is non-zero. - - 10. Y = pdist(X, 'chebyshev') - - Computes the Chebyshev distance between the points. The - Chebyshev distance between two n-vectors u and v is the maximum - norm-1 distance between their respective elements. More - precisely, the distance is given by - - d(u,v) = max {|u_i-v_i|}. - - 11. Y = pdist(X, 'canberra') - - Computes the Canberra distance between the points. The - Canberra distance between two points u and v is - - |u_1-v_1| |u_2-v_2| |u_n-v_n| - d(u,v) = ----------- + ----------- + ... + ----------- - |u_1|+|v_1| |u_2|+|v_2| |u_n|+|v_n| - - 12. Y = pdist(X, 'braycurtis') - - Computes the Bray-Curtis distance between the points. The - Bray-Curtis distance between two points u and v is - - |u_1-v_1| + |u_2-v_2| + ... + |u_n-v_n| - d(u,v) = --------------------------------------- - |u_1+v_1| + |u_2+v_2| + ... + |u_n+v_n| - - 13. Y = pdist(X, 'mahalanobis', VI=None) - - Computes the Mahalanobis distance between the points. The - Mahalanobis distance between two points u and v is - (u-v)(1/V)(u-v)^T - where (1/V) is the inverse covariance. If VI is not None, - VI will be used as the inverse covariance matrix. - - 14. Y = pdist(X, 'yule') - - Computes the Yule distance between each pair of boolean - vectors. (see yule function documentation) - - 15. Y = pdist(X, 'matching') - - Computes the matching distance between each pair of boolean - vectors. (see matching function documentation) - - 16. Y = pdist(X, 'dice') - - Computes the Dice distance between each pair of boolean - vectors. (see dice function documentation) - - 17. Y = pdist(X, 'kulsinski') - - Computes the Kulsinski distance between each pair of - boolean vectors. (see kulsinski function documentation) - - 17. Y = pdist(X, 'rogerstanimoto') - - Computes the Rogers-Tanimoto distance between each pair of - boolean vectors. (see rogerstanimoto function documentation) - - 18. Y = pdist(X, 'russellrao') - - Computes the Russell-Rao distance between each pair of - boolean vectors. (see russellrao function documentation) - - 19. Y = pdist(X, 'sokalmichener') - - Computes the Sokal-Michener distance between each pair of - boolean vectors. (see sokalmichener function documentation) - - 20. Y = pdist(X, 'sokalsneath') - - Computes the Sokal-Sneath distance between each pair of - boolean vectors. (see sokalsneath function documentation) - - 21. Y = pdist(X, f) - - Computes the distance between all pairs of vectors in X - using the user supplied 2-arity function f. For example, - Euclidean distance between the vectors could be computed - as follows, - - dm = pdist(X, (lambda u, v: np.sqrt(((u-v)*(u-v).T).sum()))) - - Note that you should avoid passing a reference to one of - the distance functions defined in this library. For example, - - dm = pdist(X, sokalsneath) - - would calculate the pair-wise distances between the vectors - in X using the Python function sokalsneath. This would result - in sokalsneath being called {n \choose 2} times, which is - inefficient. Instead, the optimized C version is more - efficient, and we call it using the following syntax. - - dm = pdist(X, 'sokalsneath') - """ -# 21. Y = pdist(X, 'test_Y') -# -# Computes the distance between all pairs of vectors in X -# using the distance metric Y but with a more succint, -# verifiable, but less efficient implementation. - - - X = np.asarray(X) - - if np.issubsctype(X, np.floating) and not np.issubsctype(X, np.double): - raise TypeError('Floating point arrays must be 64-bit (got %r).' % - (X.dtype.type,)) - - # The C code doesn't do striding. - [X] = _copy_arrays_if_base_present([X]) - - s = X.shape - - if len(s) != 2: - raise ValueError('A 2-dimensional array must be passed.'); - - m = s[0] - n = s[1] - dm = np.zeros((m * (m - 1) / 2,), dtype=np.double) - - mtype = type(metric) - if mtype is types.FunctionType: - k = 0 - if metric == minkowski: - for i in xrange(0, m - 1): - for j in xrange(i+1, m): - dm[k] = minkowski(X[i, :], X[j, :], p) - k = k + 1 - elif metric == seuclidean: - for i in xrange(0, m - 1): - for j in xrange(i+1, m): - dm[k] = seuclidean(X[i, :], X[j, :], V) - k = k + 1 - elif metric == mahalanobis: - for i in xrange(0, m - 1): - for j in xrange(i+1, m): - dm[k] = mahalanobis(X[i, :], X[j, :], V) - k = k + 1 - else: - for i in xrange(0, m - 1): - for j in xrange(i+1, m): - dm[k] = metric(X[i, :], X[j, :]) - k = k + 1 - - elif mtype is types.StringType: - mstr = metric.lower() - - if X.dtype != np.double and \ - (mstr != 'hamming' and mstr != 'jaccard'): - TypeError('A double array must be passed.') - if mstr in set(['euclidean', 'euclid', 'eu', 'e']): - _hierarchy_wrap.pdist_euclidean_wrap(X, dm) - elif mstr in set(['sqeuclidean']): - _hierarchy_wrap.pdist_euclidean_wrap(X, dm) - dm = dm ** 2.0 - elif mstr in set(['cityblock', 'cblock', 'cb', 'c']): - _hierarchy_wrap.pdist_city_block_wrap(X, dm) - elif mstr in set(['hamming', 'hamm', 'ha', 'h']): - if X.dtype == np.double: - _hierarchy_wrap.pdist_hamming_wrap(X, dm) - elif X.dtype == bool: - _hierarchy_wrap.pdist_hamming_bool_wrap(X, dm) - else: - raise TypeError('Invalid input array value type %s ' - 'for hamming.' % str(X.dtype)) - elif mstr in set(['jaccard', 'jacc', 'ja', 'j']): - if X.dtype == np.double: - _hierarchy_wrap.pdist_jaccard_wrap(X, dm) - elif X.dtype == np.bool: - _hierarchy_wrap.pdist_jaccard_bool_wrap(X, dm) - else: - raise TypeError('Invalid input array value type %s for ' - 'jaccard.' % str(X.dtype)) - elif mstr in set(['chebychev', 'chebyshev', 'cheby', 'cheb', 'ch']): - _hierarchy_wrap.pdist_chebyshev_wrap(X, dm) - elif mstr in set(['minkowski', 'mi', 'm']): - _hierarchy_wrap.pdist_minkowski_wrap(X, dm, p) - elif mstr in set(['seuclidean', 'se', 's']): - if V is not None: - if type(V) is not _array_type: - raise TypeError('Variance vector V must be a numpy array') - if V.dtype != np.double: - raise TypeError('Variance vector V must contain doubles.') - if len(V.shape) != 1: - raise ValueError('Variance vector V must be one-dimensional.') - if V.shape[0] != n: - raise ValueError('Variance vector V must be of the same dimension as the vectors on which the distances are computed.') - # The C code doesn't do striding. - [VV] = _copy_arrays_if_base_present([V]) - else: - VV = _unbiased_variance(X) - _hierarchy_wrap.pdist_seuclidean_wrap(X, VV, dm) - # Need to test whether vectorized cosine works better. - # Find out: Is there a dot subtraction operator so I can - # subtract matrices in a similar way to multiplying them? - # Need to get rid of as much unnecessary C code as possible. - elif mstr in set(['cosine_old', 'cos_old']): - norms = np.sqrt(np.sum(X * X, axis=1)) - _hierarchy_wrap.pdist_cosine_wrap(X, dm, norms) - elif mstr in set(['cosine', 'cos']): - norms = np.sqrt(np.sum(X * X, axis=1)) - nV = norms.reshape(m, 1) - # The numerator u * v - nm = np.dot(X, X.T) - # The denom. ||u||*||v|| - de = np.dot(nV, nV.T); - dm = 1 - (nm / de) - dm[xrange(0,m),xrange(0,m)] = 0 - dm = squareform(dm) - elif mstr in set(['correlation', 'co']): - X2 = X - X.mean(1)[:,np.newaxis] - #X2 = X - np.matlib.repmat(np.mean(X, axis=1).reshape(m, 1), 1, n) - norms = np.sqrt(np.sum(X2 * X2, axis=1)) - _hierarchy_wrap.pdist_cosine_wrap(X2, dm, norms) - elif mstr in set(['mahalanobis', 'mahal', 'mah']): - if VI is not None: - if type(VI) != _array_type: - raise TypeError('VI must be a numpy array.') - if VI.dtype != np.double: - raise TypeError('The array must contain 64-bit floats.') - [VI] = _copy_arrays_if_base_present([VI]) - else: - V = np.cov(X.T) - VI = np.linalg.inv(V).T.copy() - # (u-v)V^(-1)(u-v)^T - _hierarchy_wrap.pdist_mahalanobis_wrap(X, VI, dm) - elif mstr == 'canberra': - _hierarchy_wrap.pdist_canberra_wrap(X, dm) - elif mstr == 'braycurtis': - _hierarchy_wrap.pdist_bray_curtis_wrap(X, dm) - elif mstr == 'yule': - _hierarchy_wrap.pdist_yule_bool_wrap(X, dm) - elif mstr == 'matching': - _hierarchy_wrap.pdist_matching_bool_wrap(X, dm) - elif mstr == 'kulsinski': - _hierarchy_wrap.pdist_kulsinski_bool_wrap(X, dm) - elif mstr == 'dice': - _hierarchy_wrap.pdist_dice_bool_wrap(X, dm) - elif mstr == 'rogerstanimoto': - _hierarchy_wrap.pdist_rogerstanimoto_bool_wrap(X, dm) - elif mstr == 'russellrao': - _hierarchy_wrap.pdist_russellrao_bool_wrap(X, dm) - elif mstr == 'sokalmichener': - _hierarchy_wrap.pdist_sokalmichener_bool_wrap(X, dm) - elif mstr == 'sokalsneath': - _hierarchy_wrap.pdist_sokalsneath_bool_wrap(X, dm) - elif metric == 'test_euclidean': - dm = pdist(X, euclidean) - elif metric == 'test_sqeuclidean': - if V is None: - V = _unbiased_variance(X) - dm = pdist(X, lambda u, v: seuclidean(u, v, V)) - elif metric == 'test_braycurtis': - dm = pdist(X, braycurtis) - elif metric == 'test_mahalanobis': - if VI is None: - V = np.cov(X.T) - VI = np.linalg.inv(V) - [VI] = _copy_arrays_if_base_present([VI]) - # (u-v)V^(-1)(u-v)^T - dm = pdist(X, (lambda u, v: mahalanobis(u, v, VI))) - elif metric == 'test_cityblock': - dm = pdist(X, cityblock) - elif metric == 'test_minkowski': - dm = pdist(X, minkowski, p) - elif metric == 'test_cosine': - dm = pdist(X, cosine) - elif metric == 'test_correlation': - dm = pdist(X, correlation) - elif metric == 'test_hamming': - dm = pdist(X, hamming) - elif metric == 'test_jaccard': - dm = pdist(X, jaccard) - elif metric == 'test_chebyshev' or metric == 'test_chebychev': - dm = pdist(X, chebyshev) - elif metric == 'test_yule': - dm = pdist(X, yule) - elif metric == 'test_matching': - dm = pdist(X, matching) - elif metric == 'test_dice': - dm = pdist(X, dice) - elif metric == 'test_rogerstanimoto': - dm = pdist(X, rogerstanimoto) - elif metric == 'test_russellrao': - dm = pdist(X, russellrao) - elif metric == 'test_sokalsneath': - dm = pdist(X, sokalsneath) - else: - raise ValueError('Unknown Distance Metric: %s' % mstr) - else: - raise TypeError('2nd argument metric must be a string identifier or a function.') - return dm - def cophenet(*args, **kwargs): """ d = cophenet(Z) @@ -1518,6 +794,8 @@ Also returns the cophenetic distance matrix in condensed form. """ + Z = np.asarray(Z) + nargs = len(args) if nargs < 1: @@ -1531,7 +809,7 @@ zz = np.zeros((n*(n-1)/2,), dtype=np.double) # Since the C code does not support striding using strides. # The dimensions are used instead. - [Z] = _copy_arrays_if_base_present([Z]) + Z = _convert_to_double(Z) _hierarchy_wrap.cophenetic_distances_wrap(Z, zz, int(n)) if nargs == 1: @@ -1575,6 +853,7 @@ This function behaves similarly to the MATLAB(TM) inconsistent function. """ + Z = np.asarray(Z) Zs = Z.shape is_valid_linkage(Z, throw=True, name='Z') @@ -1607,7 +886,7 @@ the number of original observations (leaves) in the non-singleton cluster i. """ - is_valid_linkage(Z, throw=True, name='Z') + Z = np.asarray(Z) Zs = Z.shape Zpart = Z[:,0:2] Zd = Z[:,2].reshape(Zs[0], 1) @@ -1629,6 +908,7 @@ last column removed and the cluster indices converted to use 1..N indexing. """ + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') return np.hstack([Z[:,0:2] + 1, Z[:,2]]) @@ -1641,6 +921,7 @@ if for every cluster s and t joined, the distance between them is no less than the distance between any previously joined clusters. """ + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') # We expect the i'th value to be greater than its successor. @@ -1655,18 +936,19 @@ must be nonnegative. The link counts R[:,2] must be positive and no greater than n-1. """ + R = np.asarray(R) valid = True try: - if type(R) is not _array_type: + if type(R) != np.ndarray: if name: raise TypeError('Variable \'%s\' passed as inconsistency matrix is not a numpy array.' % name) else: raise TypeError('Variable passed as inconsistency matrix is not a numpy array.') if R.dtype != np.double: if name: - raise TypeError('Inconsistency matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Inconsistency matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Inconsistency matrix must contain doubles (float64).') + raise TypeError('Inconsistency matrix must contain doubles (double).') if len(R.shape) != 2: if name: raise ValueError('Inconsistency matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) @@ -1714,18 +996,19 @@ variable. """ + Z = np.asarray(Z) valid = True try: - if type(Z) is not _array_type: + if type(Z) != np.ndarray: if name: raise TypeError('\'%s\' passed as a linkage is not a valid array.' % name) else: raise TypeError('Variable is not a valid array.') if Z.dtype != np.double: if name: - raise TypeError('Linkage matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Linkage matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Linkage matrix must contain doubles (float64).') + raise TypeError('Linkage matrix must contain doubles (double).') if len(Z.shape) != 2: if name: raise ValueError('Linkage matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) @@ -1737,12 +1020,13 @@ else: raise ValueError('Linkage matrix must have 4 columns.') n = Z.shape[0] - if not ((Z[:,0]-xrange(n-1, n*2-1) < 0).any()) or \ - not (Z[:,1]-xrange(n-1, n*2-1) < 0).any(): - if name: - raise ValueError('Linkage \'%s\' contains negative indices.' % name) - else: - raise ValueError('Linkage contains negative indices.') + if n > 1: + if ((Z[:,0] < 0).any() or + (Z[:,1] < 0).any()): + if name: + raise ValueError('Linkage \'%s\' contains negative indices.' % name) + else: + raise ValueError('Linkage contains negative indices.') except Exception, e: if throw: raise @@ -1774,18 +1058,19 @@ referencing the offending variable. """ + y = np.asarray(y) valid = True try: - if type(y) is not _array_type: + if type(y) != np.ndarray: if name: raise TypeError('\'%s\' passed as a condensed distance matrix is not a numpy array.' % name) else: raise TypeError('Variable is not a numpy array.') if y.dtype != np.double: if name: - raise TypeError('Condensed distance matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Condensed distance matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Condensed distance matrix must contain doubles (float64).') + raise TypeError('Condensed distance matrix must contain doubles (double).') if len(y.shape) != 1: if name: raise ValueError('Condensed distance matrix \'%s\' must have shape=1 (i.e. be one-dimensional).' % name) @@ -1807,7 +1092,7 @@ return valid -def is_valid_dm(D, t=0.0): +def is_valid_dm(D, tol=0.0, throw=False, name="D"): """ is_valid_dm(D) @@ -1815,12 +1100,12 @@ Distance matrices must be 2-dimensional numpy arrays containing doubles. They must have a zero-diagonal, and they must be symmetric. - is_valid_dm(D, t) + is_valid_dm(D, tol) Returns True if the variable D passed is a valid distance matrix. Small numerical differences in D and D.T and non-zeroness of the diagonal are ignored if they are within the tolerance specified - by t. + by tol. is_valid_dm(..., warning=True, name='V') @@ -1835,25 +1120,26 @@ the offending variable. """ - + D = np.asarray(D) valid = True try: - if type(D) is not _array_type: + if type(D) != np.ndarray: if name: raise TypeError('\'%s\' passed as a distance matrix is not a numpy array.' % name) else: raise TypeError('Variable is not a numpy array.') + s = D.shape if D.dtype != np.double: if name: - raise TypeError('Distance matrix \'%s\' must contain doubles (float64).' % name) + raise TypeError('Distance matrix \'%s\' must contain doubles (double).' % name) else: - raise TypeError('Distance matrix must contain doubles (float64).') + raise TypeError('Distance matrix must contain doubles (double).') if len(D.shape) != 2: if name: raise ValueError('Distance matrix \'%s\' must have shape=2 (i.e. be two-dimensional).' % name) else: raise ValueError('Distance matrix must have shape=2 (i.e. be two-dimensional).') - if t == 0.0: + if tol == 0.0: if not (D == D.T).all(): if name: raise ValueError('Distance matrix \'%s\' must be symmetric.' % name) @@ -1865,16 +1151,16 @@ else: raise ValueError('Distance matrix diagonal must be zero.') else: - if not (D - D.T <= t).all(): + if not (D - D.T <= tol).all(): if name: - raise ValueError('Distance matrix \'%s\' must be symmetric within tolerance %d.' % (name, t)) + raise ValueError('Distance matrix \'%s\' must be symmetric within tolerance %d.' % (name, tol)) else: - raise ValueError('Distance matrix must be symmetric within tolerance %d.' % t) - if not (D[xrange(0, s[0]), xrange(0, s[0])] <= t).all(): + raise ValueError('Distance matrix must be symmetric within tolerance %5.5f.' % tol) + if not (D[xrange(0, s[0]), xrange(0, s[0])] <= tol).all(): if name: - raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %d.' % (name, t)) + raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %5.5f.' % (name, tol)) else: - raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %d.' % t) + raise ValueError('Distance matrix \'%s\' diagonal must be close to zero within tolerance %5.5f.' % tol) except Exception, e: if throw: raise @@ -1888,8 +1174,9 @@ Returns the number of original observations that correspond to a linkage matrix Z. """ + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') - return (Z.shape[0] - 1) + return (Z.shape[0] + 1) def numobs_dm(D): """ @@ -1898,7 +1185,8 @@ Returns the number of original observations that correspond to a square, non-condensed distance matrix D. """ - is_valid_dm(D, tol=Inf, throw=True, name='D') + D = np.asarray(D) + is_valid_dm(D, tol=np.inf, throw=True, name='D') return D.shape[0] def numobs_y(Y): @@ -1908,8 +1196,9 @@ Returns the number of original observations that correspond to a condensed distance matrix Y. """ - is_valid_y(y, throw=True, name='Y') - d = int(np.ceil(np.sqrt(y.shape[0] * 2))) + Y = np.asarray(Y) + is_valid_y(Y, throw=True, name='Y') + d = int(np.ceil(np.sqrt(Y.shape[0] * 2))) return d def Z_y_correspond(Z, Y): @@ -1922,6 +1211,8 @@ check in algorithms that make extensive use of linkage and distance matrices that must correspond to the same set of original observations. """ + Z = np.asarray(Z) + Y = np.asarray(Y) return numobs_y(Y) == numobs_Z(Z) def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None): @@ -1981,10 +1272,11 @@ cluster(Z, t=3, criterion='maxclust_monocrit', monocrit=MI) """ + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') n = Z.shape[0] + 1 - T = np.zeros((n,), dtype=np.int32) + T = np.zeros((n,), dtype=np.int) # Since the C code does not support striding using strides. # The dimensions are used instead. @@ -1994,6 +1286,7 @@ if R is None: R = inconsistent(Z, depth) else: + R = np.asarray(R) is_valid_im(R, throw=True, name='R') # Since the C code does not support striding using strides. # The dimensions are used instead. @@ -2048,7 +1341,7 @@ descriptions. distance: the distance metric for calculating pairwise - distances. See pdist for descriptions and + distances. See distance.pdist for descriptions and linkage to verify compatibility with the linkage method. @@ -2063,14 +1356,17 @@ This function is similar to MATLAB(TM) clusterdata function. """ + X = np.asarray(X) - if type(X) is not _array_type or len(X.shape) != 2: - raise TypeError('X must be an n by m numpy array.') + if type(X) != np.ndarray or len(X.shape) != 2: + raise TypeError('The observation matrix X must be an n by m numpy array.') - Y = pdist(X, metric=distance) + Y = distance.pdist(X, metric=distance) Z = linkage(Y, method=method) if R is None: R = inconsistent(Z, d=depth) + else: + R = np.asarray(R) T = fcluster(Z, criterion=criterion, depth=depth, R=R, t=t) return T @@ -2081,9 +1377,10 @@ Returns a list of leaf node ids as they appear in the tree from left to right. Z is a linkage matrix. """ + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') n = Z.shape[0] + 1 - ML = np.zeros((n,), dtype=np.int32) + ML = np.zeros((n,), dtype=np.int) [Z] = _copy_arrays_if_base_present([Z]) _hierarchy_wrap.prelist_wrap(Z, ML, int(n)) return ML @@ -2102,10 +1399,10 @@ # p <= 20, size="12" # 20 < p <= 30, size="10" # 30 < p <= 50, size="8" - # 50 < p <= scipy.inf, size="6" + # 50 < p <= np.inf, size="6" - _dtextsizes = {20: 12, 30: 10, 50: 8, 85: 6, scipy.inf: 5} - _drotation = {20: 0, 40: 45, scipy.inf: 90} + _dtextsizes = {20: 12, 30: 10, 50: 8, 85: 6, np.inf: 5} + _drotation = {20: 0, 40: 45, np.inf: 90} _dtextsortedkeys = list(_dtextsizes.keys()) _dtextsortedkeys.sort() _drotationsortedkeys = list(_drotation.keys()) @@ -2141,7 +1438,7 @@ ivw = len(ivl) * 10 # Depenendent variable plot height dvw = mh + mh * 0.05 - ivticks = scipy.arange(5, len(ivl)*10+5, 10) + ivticks = np.arange(5, len(ivl)*10+5, 10) if orientation == 'top': axis.set_ylim([0, dvw]) axis.set_xlim([0, ivw]) @@ -2519,6 +1816,7 @@ # or results in a crossing, an exception will be thrown. Passing # None orders leaf nodes based on the order they appear in the # pre-order traversal. + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') Zs = Z.shape @@ -2537,7 +1835,7 @@ if truncate_mode == 'mtica' or truncate_mode == 'level': if p <= 0: - p = scipy.inf + p = np.inf if get_leaves: lvs = [] else: @@ -2637,7 +1935,7 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \ - colorthreshold=scipy.inf, get_leaves=True, \ + colorthreshold=np.inf, get_leaves=True, \ orientation='top', labels=None, \ count_sort=False, distance_sort=False, \ show_leaf_counts=False, i=-1, iv=0.0, \ @@ -2882,9 +2180,12 @@ Returns True iff two different cluster assignments T1 and T2 are equivalent. T1 and T2 must be arrays of the same size. """ - if type(T1) is not _array_type: + T1 = np.asarray(T1) + T2 = np.asarray(T2) + + if type(T1) != np.ndarray: raise TypeError('T1 must be a numpy array.') - if type(T2) is not _array_type: + if type(T2) != np.ndarray: raise TypeError('T2 must be a numpy array.') T1S = T1.shape @@ -2919,6 +2220,7 @@ Note that when Z[:,2] is monotonic, Z[:,2] and MD should not differ. See linkage for more information on this issue. """ + Z = np.asarray(Z) is_valid_linkage(Z, throw=True, name='Z') n = Z.shape[0] + 1 @@ -2936,6 +2238,8 @@ inconsistency matrix. MI is a monotonic (n-1)-sized numpy array of doubles. """ + Z = np.asarray(Z) + R = np.asarray(R) is_valid_linkage(Z, throw=True, name='Z') is_valid_im(R, throw=True, name='R') @@ -2954,6 +2258,8 @@ is the maximum over R[Q(j)-n, i] where Q(j) the set of all node ids corresponding to nodes below and including j. """ + Z = np.asarray(Z) + R = np.asarray(R) is_valid_linkage(Z, throw=True, name='Z') is_valid_im(R, throw=True, name='R') if type(i) is not types.IntType: @@ -2989,7 +2295,9 @@ i < n, i corresponds to an original observation, otherwise it corresponds to a non-singleton cluster. """ - if type(T) != _array_type or T.dtype != np.int: + Z = np.asarray(Z) + T = np.asarray(T) + if type(T) != np.ndarray or T.dtype != np.int: raise TypeError('T must be a one-dimensional numpy array of integers.') is_valid_linkage(Z, throw=True, name='Z') if len(T) != Z.shape[0] + 1: @@ -2997,8 +2305,8 @@ Cl = np.unique(T) kk = len(Cl) - L = np.zeros((kk,), dtype=np.int32) - M = np.zeros((kk,), dtype=np.int32) + L = np.zeros((kk,), dtype=np.int) + M = np.zeros((kk,), dtype=np.int) n = Z.shape[0] + 1 [Z, T] = _copy_arrays_if_base_present([Z, T]) s = _hierarchy_wrap.leaders_wrap(Z, T, L, M, int(kk), int(n)) Modified: branches/refactor_fft/scipy/cluster/info.py =================================================================== --- branches/refactor_fft/scipy/cluster/info.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/info.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -14,6 +14,12 @@ clustering. Its features include generating hierarchical clusters from distance matrices, computing distance matrices from observation vectors, calculating statistics on clusters, cutting linkages to generate flat - clusters, and visualizing clusters with dendrograms. + clusters, and visualizing clusters with dendrograms. +Distance Computation +==================== + + The distance module provides functions for computing distances between + pairs of vectors from a set of observation vectors. + """ Modified: branches/refactor_fft/scipy/cluster/setup.py =================================================================== --- branches/refactor_fft/scipy/cluster/setup.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/setup.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -12,6 +12,10 @@ sources=[join('src', 'vq_module.c'), join('src', 'vq.c')], include_dirs = [get_numpy_include_dirs()]) + config.add_extension('_distance_wrap', + sources=[join('src', 'distance_wrap.c'), join('src', 'distance.c')], + include_dirs = [get_numpy_include_dirs()]) + config.add_extension('_hierarchy_wrap', sources=[join('src', 'hierarchy_wrap.c'), join('src', 'hierarchy.c')], include_dirs = [get_numpy_include_dirs()]) Copied: branches/refactor_fft/scipy/cluster/src/common.h (from rev 4510, trunk/scipy/cluster/src/common.h) Copied: branches/refactor_fft/scipy/cluster/src/distance.c (from rev 4510, trunk/scipy/cluster/src/distance.c) Copied: branches/refactor_fft/scipy/cluster/src/distance.h (from rev 4510, trunk/scipy/cluster/src/distance.h) Copied: branches/refactor_fft/scipy/cluster/src/distance_wrap.c (from rev 4510, trunk/scipy/cluster/src/distance_wrap.c) Modified: branches/refactor_fft/scipy/cluster/src/hierarchy.c =================================================================== --- branches/refactor_fft/scipy/cluster/src/hierarchy.c 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/src/hierarchy.c 2008-07-01 04:52:00 UTC (rev 4511) @@ -34,12 +34,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define NCHOOSE2(_n) ((_n)*(_n-1)/2) +#include "common.h" + #define ISCLUSTER(_nd) ((_nd)->id >= n) #define GETCLUSTER(_id) ((lists + _id - n)) -#define CPY_MAX(_x, _y) ((_x > _y) ? (_x) : (_y)) -#define CPY_MIN(_x, _y) ((_x < _y) ? (_x) : (_y)) /** The number of link stats (for the inconsistency computation) for each cluster. */ @@ -61,39 +60,15 @@ #define CPY_LIN_DIST 2 #define CPY_LIN_CNT 3 -#define CPY_BITS_PER_CHAR (sizeof(unsigned char) * 8) -#define CPY_FLAG_ARRAY_SIZE_BYTES(num_bits) (CPY_CEIL_DIV((num_bits), \ - CPY_BITS_PER_CHAR)) -#define CPY_GET_BIT(_xx, i) (((_xx)[(i) / CPY_BITS_PER_CHAR] >> \ - ((CPY_BITS_PER_CHAR-1) - \ - ((i) % CPY_BITS_PER_CHAR))) & 0x1) -#define CPY_SET_BIT(_xx, i) ((_xx)[(i) / CPY_BITS_PER_CHAR] |= \ - ((0x1) << ((CPY_BITS_PER_CHAR-1) \ - -((i) % CPY_BITS_PER_CHAR)))) -#define CPY_CLEAR_BIT(_xx, i) ((_xx)[(i) / CPY_BITS_PER_CHAR] &= \ - ~((0x1) << ((CPY_BITS_PER_CHAR-1) \ - -((i) % CPY_BITS_PER_CHAR)))) - -#ifndef CPY_CEIL_DIV -#define CPY_CEIL_DIV(x, y) ((((double)x)/(double)y) == \ - ((double)((x)/(y))) ? ((x)/(y)) : ((x)/(y) + 1)) -#endif - - -#ifdef CPY_DEBUG -#define CPY_DEBUG_MSG(...) fprintf(stderr, __VA_ARGS__) -#else -#define CPY_DEBUG_MSG(...) -#endif - #include #include #include #include #include "hierarchy.h" +#include "distance.h" -double euclidean_distance(const double *u, const double *v, int n) { +static inline double euclidean_distance(const double *u, const double *v, int n) { int i = 0; double s = 0.0, d; for (i = 0; i < n; i++) { @@ -103,548 +78,6 @@ return sqrt(s); } -double ess_distance(const double *u, const double *v, int n) { - int i = 0; - double s = 0.0, d; - for (i = 0; i < n; i++) { - d = fabs(u[i] - v[i]); - s = s + d * d; - } - return s; -} - -double chebyshev_distance(const double *u, const double *v, int n) { - int i = 0; - double d, maxv = 0.0; - for (i = 0; i < n; i++) { - d = fabs(u[i] - v[i]); - if (d > maxv) { - maxv = d; - } - } - return maxv; -} - -double canberra_distance(const double *u, const double *v, int n) { - int i; - double s = 0.0; - for (i = 0; i < n; i++) { - s += (fabs(u[i] - v[i]) / (fabs(u[i]) + fabs(v[i]))); - } - return s; -} - -double bray_curtis_distance(const double *u, const double *v, int n) { - int i; - double s1 = 0.0, s2 = 0.0; - for (i = 0; i < n; i++) { - s1 += fabs(u[i] - v[i]); - s2 += fabs(u[i] + v[i]); - } - return s1 / s2; -} - -double mahalanobis_distance(const double *u, const double *v, - const double *covinv, double *dimbuf1, - double *dimbuf2, int n) { - int i, j; - double s; - const double *covrow = covinv; - for (i = 0; i < n; i++) { - dimbuf1[i] = u[i] - v[i]; - } - for (i = 0; i < n; i++) { - covrow = covinv + (i * n); - s = 0.0; - for (j = 0; j < n; j++) { - s += dimbuf1[j] * covrow[j]; - } - dimbuf2[i] = s; - } - s = 0.0; - for (i = 0; i < n; i++) { - s += dimbuf1[i] * dimbuf2[i]; - } - return sqrt(s); -} - -double hamming_distance(const double *u, const double *v, int n) { - int i = 0; - double s = 0.0; - for (i = 0; i < n; i++) { - s = s + (u[i] != v[i]); - } - return s / (double)n; -} - -double hamming_distance_bool(const char *u, const char *v, int n) { - int i = 0; - double s = 0.0; - for (i = 0; i < n; i++) { - s = s + (u[i] != v[i]); - } - return s / (double)n; -} - -double yule_distance_bool(const char *u, const char *v, int n) { - int i = 0; - int ntt = 0, nff = 0, nft = 0, ntf = 0; - for (i = 0; i < n; i++) { - ntt += (u[i] && v[i]); - ntf += (u[i] && !v[i]); - nft += (!u[i] && v[i]); - nff += (!u[i] && !v[i]); - } - return (2.0 * ntf * nft) / (double)(ntt * nff + ntf * nft); -} - -double matching_distance_bool(const char *u, const char *v, int n) { - int i = 0; - int nft = 0, ntf = 0; - for (i = 0; i < n; i++) { - ntf += (u[i] && !v[i]); - nft += (!u[i] && v[i]); - } - return (double)(ntf + nft) / (double)(n); -} - -double dice_distance_bool(const char *u, const char *v, int n) { - int i = 0; - int ntt = 0, nft = 0, ntf = 0; - for (i = 0; i < n; i++) { - ntt += (u[i] && v[i]); - ntf += (u[i] && !v[i]); - nft += (!u[i] && v[i]); - } - return (double)(nft + ntf) / (double)(2.0 * ntt + ntf + nft); -} - - -double rogerstanimoto_distance_bool(const char *u, const char *v, int n) { - int i = 0; - int ntt = 0, nff = 0, nft = 0, ntf = 0; - for (i = 0; i < n; i++) { - ntt += (u[i] && v[i]); - ntf += (u[i] && !v[i]); - nft += (!u[i] && v[i]); - nff += (!u[i] && !v[i]); - } - return (2.0 * (ntf + nft)) / ((double)ntt + nff + (2.0 * (ntf + nft))); -} - -double russellrao_distance_bool(const char *u, const char *v, int n) { - int i = 0; - /** int nff = 0, nft = 0, ntf = 0;**/ - int ntt = 0; - for (i = 0; i < n; i++) { - /** nff += (!u[i] && !v[i]); - ntf += (u[i] && !v[i]); - nft += (!u[i] && v[i]);**/ - ntt += (u[i] && v[i]); - } - /** return (double)(ntf + nft + nff) / (double)n;**/ - return (double) (n - ntt) / (double) n; -} - -static inline double kulsinski_distance_bool(const char *u, const char *v, int n) { - int _i = 0; - int ntt = 0, nft = 0, ntf = 0, nff = 0; - for (_i = 0; _i < n; _i++) { - ntt += (u[_i] && v[_i]); - ntf += (u[_i] && !v[_i]); - nft += (!u[_i] && v[_i]); - nff += (!u[_i] && !v[_i]); - } - return ((double)(ntf + nft - ntt + n)) / ((double)(ntf + nft + n)); -} - -static inline double sokalsneath_distance_bool(const char *u, const char *v, int n) { - int _i = 0; - int ntt = 0, nft = 0, ntf = 0; - for (_i = 0; _i < n; _i++) { - ntt += (u[_i] && v[_i]); - ntf += (u[_i] && !v[_i]); - nft += (!u[_i] && v[_i]); - } - return (2.0 * (ntf + nft))/(2.0 * (ntf + nft) + ntt); -} - -static inline double sokalmichener_distance_bool(const char *u, const char *v, int n) { - int _i = 0; - int ntt = 0, nft = 0, ntf = 0, nff = 0; - for (_i = 0; _i < n; _i++) { - ntt += (u[_i] && v[_i]); - nff += (!u[_i] && !v[_i]); - ntf += (u[_i] && !v[_i]); - nft += (!u[_i] && v[_i]); - } - return (2.0 * (ntf + nft))/(2.0 * (ntf + nft) + ntt + nff); -} - -double jaccard_distance(const double *u, const double *v, int n) { - int i = 0; - double denom = 0.0, num = 0.0; - for (i = 0; i < n; i++) { - num += (u[i] != v[i]) && ((u[i] != 0.0) || (v[i] != 0.0)); - denom += (u[i] != 0.0) || (v[i] != 0.0); - } - return num / denom; -} - -double jaccard_distance_bool(const char *u, const char *v, int n) { - int i = 0; - double num = 0.0, denom = 0.0; - for (i = 0; i < n; i++) { - num += (u[i] != v[i]) && ((u[i] != 0) || (v[i] != 0)); - denom += (u[i] != 0) || (v[i] != 0); - } - return num / denom; -} - -double dot_product(const double *u, const double *v, int n) { - int i; - double s = 0.0; - for (i = 0; i < n; i++) { - s += u[i] * v[i]; - } - return s; -} - -double cosine_distance(const double *u, const double *v, int n, - const double nu, const double nv) { - return 1.0 - (dot_product(u, v, n) / (nu * nv)); -} - -double seuclidean_distance(const double *var, - const double *u, const double *v, int n) { - int i = 0; - double s = 0.0, d; - for (i = 0; i < n; i++) { - d = u[i] - v[i]; - s = s + (d * d) / var[i]; - } - return sqrt(s); -} - -double city_block_distance(const double *u, const double *v, int n) { - int i = 0; - double s = 0.0, d; - for (i = 0; i < n; i++) { - d = fabs(u[i] - v[i]); - s = s + d; - } - return s; -} - -double minkowski_distance(const double *u, const double *v, int n, double p) { - int i = 0; - double s = 0.0, d; - for (i = 0; i < n; i++) { - d = fabs(u[i] - v[i]); - s = s + pow(d, p); - } - return pow(s, 1.0 / p); -} - -void compute_mean_vector(double *res, const double *X, int m, int n) { - int i, j; - const double *v; - for (i = 0; i < n; i++) { - res[i] = 0.0; - } - for (j = 0; j < m; j++) { - - v = X + (j * n); - for (i = 0; i < n; i++) { - res[i] += v[i]; - } - } - for (i = 0; i < n; i++) { - res[i] /= (double)m; - } -} - -void pdist_euclidean(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = euclidean_distance(u, v, n); - } - } -} - -void pdist_mahalanobis(const double *X, const double *covinv, - double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - double *dimbuf1, *dimbuf2; - dimbuf1 = (double*)malloc(sizeof(double) * 2 * n); - dimbuf2 = dimbuf1 + n; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = mahalanobis_distance(u, v, covinv, dimbuf1, dimbuf2, n); - } - } - dimbuf2 = 0; - free(dimbuf1); -} - -void pdist_bray_curtis(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = bray_curtis_distance(u, v, n); - } - } -} - -void pdist_canberra(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = canberra_distance(u, v, n); - } - } -} - -void pdist_hamming(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = hamming_distance(u, v, n); - } - } -} - -void pdist_hamming_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = hamming_distance_bool(u, v, n); - } - } -} - -void pdist_jaccard(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = jaccard_distance(u, v, n); - } - } -} - -void pdist_jaccard_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = jaccard_distance_bool(u, v, n); - } - } -} - - -void pdist_chebyshev(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = chebyshev_distance(u, v, n); - } - } -} - -void pdist_cosine(const double *X, double *dm, int m, int n, const double *norms) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = cosine_distance(u, v, n, norms[i], norms[j]); - } - } -} - -void pdist_seuclidean(const double *X, const double *var, - double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = seuclidean_distance(var, u, v, n); - } - } -} - -void pdist_city_block(const double *X, double *dm, int m, int n) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = city_block_distance(u, v, n); - } - } -} - -void pdist_minkowski(const double *X, double *dm, int m, int n, double p) { - int i, j; - const double *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = minkowski_distance(u, v, n, p); - } - } -} - -void pdist_yule_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = yule_distance_bool(u, v, n); - } - } -} - -void pdist_matching_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = matching_distance_bool(u, v, n); - } - } -} - -void pdist_dice_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = dice_distance_bool(u, v, n); - } - } -} - -void pdist_rogerstanimoto_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = rogerstanimoto_distance_bool(u, v, n); - } - } -} - -void pdist_russellrao_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = russellrao_distance_bool(u, v, n); - } - } -} - -void pdist_kulsinski_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = kulsinski_distance_bool(u, v, n); - } - } -} - -void pdist_sokalsneath_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = sokalsneath_distance_bool(u, v, n); - } - } -} - -void pdist_sokalmichener_bool(const char *X, double *dm, int m, int n) { - int i, j; - const char *u, *v; - double *it = dm; - for (i = 0; i < m; i++) { - for (j = i + 1; j < m; j++, it++) { - u = X + (n * i); - v = X + (n * j); - *it = sokalmichener_distance_bool(u, v, n); - } - } -} - void chopmins(int *ind, int mini, int minj, int np) { int i; for (i = mini; i < minj - 1; i++) { @@ -734,7 +167,7 @@ xi = inds[i]; cnode *xnd = info->nodes + xi; xn = xnd->n; - mply = 1.0 / (((double)xn) * rscnt); + mply = (double)1.0 / (((double)xn) * rscnt); *bit = mply * ((drx * (rc * xn)) + (dsx * (sc * xn))); } for (i = mini + 1; i < minj; i++, bit++) { @@ -743,7 +176,7 @@ xi = inds[i]; cnode *xnd = info->nodes + xi; xn = xnd->n; - mply = 1.0 / (((double)xn) * rscnt); + mply = (double)1.0 / (((double)xn) * rscnt); *bit = mply * ((drx * (rc * xn)) + (dsx * (sc * xn))); } for (i = minj + 1; i < np; i++, bit++) { @@ -752,7 +185,7 @@ xi = inds[i]; cnode *xnd = info->nodes + xi; xn = xnd->n; - mply = 1.0 / (((double)xn) * rscnt); + mply = (double)1.0 / (((double)xn) * rscnt); *bit = mply * ((drx * (rc * xn)) + (dsx * (sc * xn))); } } Modified: branches/refactor_fft/scipy/cluster/src/hierarchy.h =================================================================== --- branches/refactor_fft/scipy/cluster/src/hierarchy.h 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/src/hierarchy.h 2008-07-01 04:52:00 UTC (rev 4511) @@ -34,8 +34,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _CPY_CLUSTER_H -#define _CPY_CLUSTER_H +#ifndef _CPY_HIERARCHY_H +#define _CPY_HIERARCHY_H #define CPY_LINKAGE_SINGLE 0 #define CPY_LINKAGE_COMPLETE 1 @@ -89,35 +89,9 @@ void dist_to_squareform_from_vector(double *M, const double *v, int n); void dist_to_vector_from_squareform(const double *M, double *v, int n); -void pdist_euclidean(const double *X, double *dm, int m, int n); -void pdist_seuclidean(const double *X, - const double *var, double *dm, int m, int n); -void pdist_mahalanobis(const double *X, const double *covinv, - double *dm, int m, int n); -void pdist_bray_curtis(const double *X, double *dm, int m, int n); -void pdist_canberra(const double *X, double *dm, int m, int n); -void pdist_hamming(const double *X, double *dm, int m, int n); -void pdist_hamming_bool(const char *X, double *dm, int m, int n); -void pdist_city_block(const double *X, double *dm, int m, int n); -void pdist_cosine(const double *X, double *dm, int m, int n, const double *norms); -void pdist_chebyshev(const double *X, double *dm, int m, int n); -void pdist_jaccard(const double *X, double *dm, int m, int n); -void pdist_jaccard_bool(const char *X, double *dm, int m, int n); -void pdist_kulsinski_bool(const char *X, double *dm, int m, int n); -void pdist_minkowski(const double *X, double *dm, int m, int n, double p); -void pdist_yule_bool(const char *X, double *dm, int m, int n); -void pdist_matching_bool(const char *X, double *dm, int m, int n); -void pdist_dice_bool(const char *X, double *dm, int m, int n); -void pdist_rogerstanimoto_bool(const char *X, double *dm, int m, int n); -void pdist_russellrao_bool(const char *X, double *dm, int m, int n); -void pdist_sokalmichener_bool(const char *X, double *dm, int m, int n); -void pdist_sokalsneath_bool(const char *X, double *dm, int m, int n); - void inconsistency_calculation(const double *Z, double *R, int n, int d); void inconsistency_calculation_alt(const double *Z, double *R, int n, int d); -double dot_product(const double *u, const double *v, int n); - void chopmins(int *ind, int mini, int minj, int np); void chopmins_ns_i(double *ind, int mini, int np); void chopmins_ns_ij(double *ind, int mini, int minj, int np); Modified: branches/refactor_fft/scipy/cluster/src/hierarchy_wrap.c =================================================================== --- branches/refactor_fft/scipy/cluster/src/hierarchy_wrap.c 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/src/hierarchy_wrap.c 2008-07-01 04:52:00 UTC (rev 4511) @@ -332,18 +332,6 @@ return Py_BuildValue("d", 0.0); } -extern PyObject *dot_product_wrap(PyObject *self, PyObject *args) { - PyArrayObject *d1_, *d2_; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &d1_, - &PyArray_Type, &d2_)) { - return 0; - } - return Py_BuildValue("d", dot_product((const double*)d1_->data, - (const double*)d2_->data, - d1_->dimensions[0])); -} - extern PyObject *to_squareform_from_vector_wrap(PyObject *self, PyObject *args) { PyArrayObject *M_, *v_; int n; @@ -382,459 +370,6 @@ return Py_BuildValue("d", 0.0); } -extern PyObject *pdist_euclidean_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_euclidean(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_canberra_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_canberra(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_bray_curtis_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_bray_curtis(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - - -extern PyObject *pdist_mahalanobis_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *covinv_, *dm_; - int m, n; - double *dm; - const double *X; - const double *covinv; - if (!PyArg_ParseTuple(args, "O!O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &covinv_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - covinv = (const double*)covinv_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_mahalanobis(X, covinv, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - - -extern PyObject *pdist_chebyshev_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_chebyshev(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - - -extern PyObject *pdist_cosine_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_, *norms_; - int m, n; - double *dm; - const double *X, *norms; - if (!PyArg_ParseTuple(args, "O!O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_, - &PyArray_Type, &norms_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - norms = (const double*)norms_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_cosine(X, dm, m, n, norms); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_seuclidean_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_, *var_; - int m, n; - double *dm; - const double *X, *var; - if (!PyArg_ParseTuple(args, "O!O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &var_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (double*)X_->data; - dm = (double*)dm_->data; - var = (double*)var_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_seuclidean(X, var, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_city_block_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_city_block(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_hamming_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_hamming(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_hamming_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_hamming_bool(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_jaccard_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const double *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_jaccard(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_jaccard_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_jaccard_bool(X, dm, m, n); - } - return Py_BuildValue("d", 0.0); -} - -extern PyObject *pdist_minkowski_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm, *X; - double p; - if (!PyArg_ParseTuple(args, "O!O!d", - &PyArray_Type, &X_, - &PyArray_Type, &dm_, - &p)) { - return 0; - } - else { - X = (double*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_minkowski(X, dm, m, n, p); - } - return Py_BuildValue("d", 0.0); -} - - -extern PyObject *pdist_yule_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_yule_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_matching_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_matching_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_dice_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_dice_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_rogerstanimoto_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_rogerstanimoto_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_russellrao_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_russellrao_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_kulsinski_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_kulsinski_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_sokalmichener_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_sokalmichener_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - -extern PyObject *pdist_sokalsneath_bool_wrap(PyObject *self, PyObject *args) { - PyArrayObject *X_, *dm_; - int m, n; - double *dm; - const char *X; - if (!PyArg_ParseTuple(args, "O!O!", - &PyArray_Type, &X_, - &PyArray_Type, &dm_)) { - return 0; - } - else { - X = (const char*)X_->data; - dm = (double*)dm_->data; - m = X_->dimensions[0]; - n = X_->dimensions[1]; - - pdist_sokalsneath_bool(X, dm, m, n); - } - return Py_BuildValue(""); -} - extern PyObject *leaders_wrap(PyObject *self, PyObject *args) { PyArrayObject *Z_, *T_, *L_, *M_; int kk, n, res; @@ -864,7 +399,6 @@ {"cluster_maxclust_monocrit_wrap", cluster_maxclust_monocrit_wrap, METH_VARARGS}, {"cluster_monocrit_wrap", cluster_monocrit_wrap, METH_VARARGS}, {"cophenetic_distances_wrap", cophenetic_distances_wrap, METH_VARARGS}, - {"dot_product_wrap", dot_product_wrap, METH_VARARGS}, {"get_max_dist_for_each_cluster_wrap", get_max_dist_for_each_cluster_wrap, METH_VARARGS}, {"get_max_Rfield_for_each_cluster_wrap", @@ -873,27 +407,6 @@ {"leaders_wrap", leaders_wrap, METH_VARARGS}, {"linkage_euclid_wrap", linkage_euclid_wrap, METH_VARARGS}, {"linkage_wrap", linkage_wrap, METH_VARARGS}, - {"pdist_bray_curtis_wrap", pdist_bray_curtis_wrap, METH_VARARGS}, - {"pdist_canberra_wrap", pdist_canberra_wrap, METH_VARARGS}, - {"pdist_chebyshev_wrap", pdist_chebyshev_wrap, METH_VARARGS}, - {"pdist_city_block_wrap", pdist_city_block_wrap, METH_VARARGS}, - {"pdist_cosine_wrap", pdist_cosine_wrap, METH_VARARGS}, - {"pdist_dice_bool_wrap", pdist_dice_bool_wrap, METH_VARARGS}, - {"pdist_euclidean_wrap", pdist_euclidean_wrap, METH_VARARGS}, - {"pdist_hamming_wrap", pdist_hamming_wrap, METH_VARARGS}, - {"pdist_hamming_bool_wrap", pdist_hamming_bool_wrap, METH_VARARGS}, - {"pdist_jaccard_wrap", pdist_jaccard_wrap, METH_VARARGS}, - {"pdist_jaccard_bool_wrap", pdist_jaccard_bool_wrap, METH_VARARGS}, - {"pdist_kulsinski_bool_wrap", pdist_kulsinski_bool_wrap, METH_VARARGS}, - {"pdist_mahalanobis_wrap", pdist_mahalanobis_wrap, METH_VARARGS}, - {"pdist_matching_bool_wrap", pdist_matching_bool_wrap, METH_VARARGS}, - {"pdist_minkowski_wrap", pdist_minkowski_wrap, METH_VARARGS}, - {"pdist_rogerstanimoto_bool_wrap", pdist_rogerstanimoto_bool_wrap, METH_VARARGS}, - {"pdist_russellrao_bool_wrap", pdist_russellrao_bool_wrap, METH_VARARGS}, - {"pdist_seuclidean_wrap", pdist_seuclidean_wrap, METH_VARARGS}, - {"pdist_sokalmichener_bool_wrap", pdist_sokalmichener_bool_wrap, METH_VARARGS}, - {"pdist_sokalsneath_bool_wrap", pdist_sokalsneath_bool_wrap, METH_VARARGS}, - {"pdist_yule_bool_wrap", pdist_yule_bool_wrap, METH_VARARGS}, {"prelist_wrap", prelist_wrap, METH_VARARGS}, {"to_squareform_from_vector_wrap", to_squareform_from_vector_wrap, METH_VARARGS}, Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-1.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-2.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-3.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-complete-tdist-depth-4.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-0.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-1.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-2.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-3.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-4.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist-depth-5.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-single-tdist.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-single-tdist.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-1.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-2.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-3.txt) Copied: branches/refactor_fft/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt (from rev 4510, trunk/scipy/cluster/tests/inconsistent-weighted-tdist-depth-4.txt) Copied: branches/refactor_fft/scipy/cluster/tests/linkage-X.txt (from rev 4510, trunk/scipy/cluster/tests/linkage-X.txt) Copied: branches/refactor_fft/scipy/cluster/tests/linkage-average-tdist.txt (from rev 4510, trunk/scipy/cluster/tests/linkage-average-tdist.txt) Copied: branches/refactor_fft/scipy/cluster/tests/linkage-complete-tdist.txt (from rev 4510, trunk/scipy/cluster/tests/linkage-complete-tdist.txt) Copied: branches/refactor_fft/scipy/cluster/tests/linkage-single-tdist.txt (from rev 4510, trunk/scipy/cluster/tests/linkage-single-tdist.txt) Copied: branches/refactor_fft/scipy/cluster/tests/linkage-weighted-tdist.txt (from rev 4510, trunk/scipy/cluster/tests/linkage-weighted-tdist.txt) Copied: branches/refactor_fft/scipy/cluster/tests/random-bool-data.txt (from rev 4510, trunk/scipy/cluster/tests/random-bool-data.txt) Modified: branches/refactor_fft/scipy/cluster/tests/test_hierarchy.py =================================================================== --- branches/refactor_fft/scipy/cluster/tests/test_hierarchy.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/tests/test_hierarchy.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -33,524 +33,178 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - import sys import os.path -from scipy.testing import * -from scipy.cluster.hierarchy import pdist - import numpy -#import math -#from scipy.cluster.hierarchy import pdist, euclidean +from scipy.testing import * +from scipy.cluster.hierarchy import squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage +from scipy.cluster.distance import pdist, matching, jaccard, dice, sokalsneath, rogerstanimoto, russellrao, yule -_filenames = ["iris.txt", - "pdist-hamming-ml.txt", - "pdist-boolean-inp.txt", - "pdist-jaccard-ml.txt", - "pdist-cityblock-ml-iris.txt", - "pdist-minkowski-3.2-ml-iris.txt", - "pdist-cityblock-ml.txt", - "pdist-correlation-ml-iris.txt", - "pdist-minkowski-5.8-ml-iris.txt", - "pdist-correlation-ml.txt", - "pdist-minkowski-3.2-ml.txt", - "pdist-cosine-ml-iris.txt", - "pdist-seuclidean-ml-iris.txt", - "pdist-cosine-ml.txt", - "pdist-seuclidean-ml.txt", - "pdist-double-inp.txt", - "pdist-spearman-ml.txt", - "pdist-euclidean-ml.txt", - "pdist-euclidean-ml-iris.txt", - "pdist-chebychev-ml.txt", - "pdist-chebychev-ml-iris.txt"] +_tdist = numpy.array([[0, 662, 877, 255, 412, 996], + [662, 0, 295, 468, 268, 400], + [877, 295, 0, 754, 564, 138], + [255, 468, 754, 0, 219, 869], + [412, 268, 564, 219, 0, 669], + [996, 400, 138, 869, 669, 0 ]], dtype='double') -# A hashmap of expected output arrays for the tests. These arrays -# come from a list of text files, which are read prior to testing. +_ytdist = squareform(_tdist) + eo = {} +_filenames = ["iris.txt", + "linkage-single-tdist.txt", + "linkage-complete-tdist.txt", + "linkage-average-tdist.txt", + "linkage-weighted-tdist.txt", + "random-bool-data.txt"] + + def load_testing_files(): for fn in _filenames: name = fn.replace(".txt", "").replace("-ml", "") fqfn = os.path.join(os.path.dirname(__file__), fn) eo[name] = numpy.loadtxt(open(fqfn)) #print "%s: %s %s" % (name, str(eo[name].shape), str(eo[name].dtype)) - eo['pdist-boolean-inp'] = numpy.bool_(eo['pdist-boolean-inp']) + #eo['pdist-boolean-inp'] = numpy.bool_(eo['pdist-boolean-inp']) load_testing_files() -#print eo.keys() +class TestSquareForm(TestCase): + ################### squareform + def test_squareform_empty_matrix(self): + "Tests squareform on an empty matrix." + A = numpy.zeros((0,0)) + rA = squareform(numpy.array(A, dtype='double')) + self.failUnless(rA.shape == (0,)) -#print numpy.abs(Y_test2 - Y_right).max() -#print numpy.abs(Y_test1 - Y_right).max() + def test_squareform_empty_vector(self): + v = numpy.zeros((0,)) + rv = squareform(numpy.array(v, dtype='double')) + self.failUnless(rv.shape == (1,1)) + self.failUnless(rv[0, 0] == 0) -class TestPdist(TestCase): + def test_squareform_1by1_matrix(self): + "Tests squareform on a 1x1 matrix." + A = numpy.zeros((1,1)) + rA = squareform(numpy.array(A, dtype='double')) + self.failUnless(rA.shape == (0,)) - def test_pdist_raises_type_error_float32(self): - "Testing whether passing a float32 observation array generates an exception." - X = numpy.zeros((10, 10), dtype=numpy.float32) - try: - pdist(X, 'euclidean') - except TypeError: - pass - except: - self.fail("float32 observation matrices should generate an error in pdist.") + def test_squareform_one_vector(self): + "Tests squareform on a 1-D array, length=1." + v = numpy.ones((1,)) * 8.3 + rv = squareform(numpy.array(v, dtype='double')) + self.failUnless(rv.shape == (2,2)) + self.failUnless(rv[0,1] == 8.3) + self.failUnless(rv[1,0] == 8.3) - def test_pdist_raises_type_error_longdouble(self): - "Testing whether passing a longdouble observation array generates an exception." - X = numpy.zeros((10, 10), dtype=numpy.longdouble) - try: - pdist(X, 'euclidean') - except TypeError: - pass - except: - self.fail("longdouble observation matrices should generate an error in pdist.") + def test_squareform_2by2_matrix(self): + "Tests squareform on a 2x2 matrix." + A = numpy.zeros((2,2)) + A[0,1]=0.8 + A[1,0]=0.8 + rA = squareform(numpy.array(A, dtype='double')) + self.failUnless(rA.shape == (1,)) + self.failUnless(rA[0] == 0.8) - def test_pdist_var_raises_type_error_float32(self): - "Testing whether passing a float32 variance matrix generates an exception." - X = numpy.zeros((10, 10)) - V = numpy.zeros((10, 10), dtype=numpy.float32) - try: - pdist(X, 'seuclidean', V=V) - except TypeError: - pass - except: - self.fail("float32 V matrices should generate an error in pdist('seuclidean').") + def test_squareform_multi_matrix(self): + "Tests squareform on a square matrices of multiple sizes." + for n in xrange(2, 5): + yield self.check_squareform_multi_matrix(n) - def test_pdist_var_raises_type_error_longdouble(self): - "Testing whether passing a longdouble variance matrix generates an exception." - X = numpy.zeros((10, 10)) - V = numpy.zeros((10, 10), dtype=numpy.longdouble) + def check_squareform_multi_matrix(self, n): + X = numpy.random.rand(n, 4) + Y = pdist(X) + self.failUnless(len(Y.shape) == 1) + A = squareform(Y) + Yr = squareform(A) + s = A.shape + k = 0 + print A.shape, Y.shape, Yr.shape + self.failUnless(len(s) == 2) + self.failUnless(len(Yr.shape) == 1) + self.failUnless(s[0] == s[1]) + for i in xrange(0, s[0]): + for j in xrange(i+1, s[1]): + if i != j: + #print i, j, k, A[i, j], Y[k] + self.failUnless(A[i, j] == Y[k]) + k += 1 + else: + self.failUnless(A[i, j] == 0) - try: - pdist(X, 'seuclidean', V=V) - except TypeError: - pass - except: - self.fail("longdouble matrices should generate an error in pdist('seuclidean').") +class TestNumObs(TestCase): - def test_pdist_ivar_raises_type_error_float32(self): - "Testing whether passing a float32 variance matrix generates an exception." - X = numpy.zeros((10, 10)) - VI = numpy.zeros((10, 10), dtype=numpy.float32) - try: - pdist(X, 'mahalanobis', VI=VI) - except TypeError: - pass - except: - self.fail("float32 matrices should generate an error in pdist('mahalanobis').") + ############## numobs_dm + def test_numobs_dm_multi_matrix(self): + "Tests numobs_dm with observation matrices of multiple sizes." + for n in xrange(1, 10): + X = numpy.random.rand(n, 4) + Y = pdist(X) + A = squareform(Y) + print A.shape, Y.shape + self.failUnless(numobs_dm(A) == n) - def test_pdist_ivar_raises_type_error_longdouble(self): - "Testing whether passing a longdouble variance matrix generates an exception." - X = numpy.zeros((10, 10)) - VI = numpy.zeros((10, 10), dtype=numpy.longdouble) + def test_numobs_y_multi_matrix(self): + "Tests numobs_y with observation matrices of multiple sizes." + for n in xrange(2, 10): + X = numpy.random.rand(n, 4) + Y = pdist(X) + #print A.shape, Y.shape, Yr.shape + self.failUnless(numobs_y(Y) == n) - try: - pdist(X, 'mahalanobis', VI=VI) - except TypeError: - pass - except: - self.fail("longdouble matrices should generate an error in pdist('mahalanobis').") + def test_numobs_linkage_multi_matrix(self): + "Tests numobs_linkage with observation matrices of multiple sizes." + for n in xrange(2, 10): + X = numpy.random.rand(n, 4) + Y = pdist(X) + Z = linkage(Y) + #print Z + #print A.shape, Y.shape, Yr.shape + self.failUnless(numobs_linkage(Z) == n) - ################### pdist: euclidean - def test_pdist_euclidean_random(self): - "Tests pdist(X, 'euclidean') on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-euclidean'] +class TestLinkage(TestCase): - Y_test1 = pdist(X, 'euclidean') - self.failUnless(within_tol(Y_test1, Y_right, eps)) + ################### linkage + def test_linkage_single_tdist(self): + "Tests linkage(Y, 'single') on the tdist data set." + Z = linkage(_ytdist, 'single') + Zmlab = eo['linkage-single-tdist'] + eps = 1e-10 + expectedZ = from_mlab_linkage(Zmlab) + self.failUnless(within_tol(Z, expectedZ, eps)) - def test_pdist_euclidean_random_nonC(self): - "Tests pdist(X, 'test_euclidean') [the non-C implementation] on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-euclidean'] - Y_test2 = pdist(X, 'test_euclidean') - self.failUnless(within_tol(Y_test2, Y_right, eps)) + def test_linkage_complete_tdist(self): + "Tests linkage(Y, 'complete') on the tdist data set." + Z = linkage(_ytdist, 'complete') + Zmlab = eo['linkage-complete-tdist'] + eps = 1e-10 + expectedZ = from_mlab_linkage(Zmlab) + self.failUnless(within_tol(Z, expectedZ, eps)) - def test_pdist_euclidean_iris(self): - "Tests pdist(X, 'euclidean') on the Iris data set." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-euclidean-iris'] - - Y_test1 = pdist(X, 'euclidean') - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_euclidean_iris_nonC(self): - "Tests pdist(X, 'test_euclidean') [the non-C implementation] on the Iris data set." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-euclidean-iris'] - Y_test2 = pdist(X, 'test_euclidean') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: seuclidean - def test_pdist_seuclidean_random(self): - "Tests pdist(X, 'seuclidean') on random data." + def test_linkage_average_tdist(self): + "Tests linkage(Y, 'average') on the tdist data set." + Z = linkage(_ytdist, 'average') + Zmlab = eo['linkage-average-tdist'] eps = 1e-05 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-seuclidean'] + expectedZ = from_mlab_linkage(Zmlab) + #print Z, expectedZ, numpy.abs(Z - expectedZ).max() + self.failUnless(within_tol(Z, expectedZ, eps)) - Y_test1 = pdist(X, 'seuclidean') - self.failUnless(within_tol(Y_test1, Y_right, eps)) + def test_linkage_weighted_tdist(self): + "Tests linkage(Y, 'weighted') on the tdist data set." + Z = linkage(_ytdist, 'weighted') + Zmlab = eo['linkage-weighted-tdist'] + eps = 1e-10 + expectedZ = from_mlab_linkage(Zmlab) + #print Z, expectedZ, numpy.abs(Z - expectedZ).max() + self.failUnless(within_tol(Z, expectedZ, eps)) - def test_pdist_seuclidean_random_nonC(self): - "Tests pdist(X, 'test_sqeuclidean') [the non-C implementation] on random data." - eps = 1e-05 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-seuclidean'] - Y_test2 = pdist(X, 'test_sqeuclidean') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_seuclidean_iris(self): - "Tests pdist(X, 'seuclidean') on the Iris data set." - eps = 1e-05 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-seuclidean-iris'] - - Y_test1 = pdist(X, 'seuclidean') - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_seuclidean_iris_nonC(self): - "Tests pdist(X, 'test_seuclidean') [the non-C implementation] on the Iris data set." - eps = 1e-05 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-seuclidean-iris'] - Y_test2 = pdist(X, 'test_sqeuclidean') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: cosine - def test_pdist_cosine_random(self): - "Tests pdist(X, 'cosine') on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-cosine'] - - Y_test1 = pdist(X, 'cosine') - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_cosine_random_nonC(self): - "Tests pdist(X, 'test_cosine') [the non-C implementation] on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-cosine'] - Y_test2 = pdist(X, 'test_cosine') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_cosine_iris(self): - "Tests pdist(X, 'cosine') on the Iris data set." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-cosine-iris'] - - Y_test1 = pdist(X, 'cosine') - self.failUnless(within_tol(Y_test1, Y_right, eps)) - #print "cosine-iris", numpy.abs(Y_test1 - Y_right).max() - - def test_pdist_cosine_iris_nonC(self): - "Tests pdist(X, 'test_cosine') [the non-C implementation] on the Iris data set." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-cosine-iris'] - Y_test2 = pdist(X, 'test_cosine') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: cityblock - def test_pdist_cityblock_random(self): - "Tests pdist(X, 'cityblock') on random data." - eps = 1e-06 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-cityblock'] - - Y_test1 = pdist(X, 'cityblock') - #print "cityblock", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_cityblock_random_nonC(self): - "Tests pdist(X, 'test_cityblock') [the non-C implementation] on random data." - eps = 1e-06 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-cityblock'] - Y_test2 = pdist(X, 'test_cityblock') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_cityblock_iris(self): - "Tests pdist(X, 'cityblock') on the Iris data set." - eps = 1e-14 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-cityblock-iris'] - - Y_test1 = pdist(X, 'cityblock') - self.failUnless(within_tol(Y_test1, Y_right, eps)) - #print "cityblock-iris", numpy.abs(Y_test1 - Y_right).max() - - def test_pdist_cityblock_iris_nonC(self): - "Tests pdist(X, 'test_cityblock') [the non-C implementation] on the Iris data set." - eps = 1e-14 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-cityblock-iris'] - Y_test2 = pdist(X, 'test_cityblock') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: correlation - def test_pdist_correlation_random(self): - "Tests pdist(X, 'correlation') on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-correlation'] - - Y_test1 = pdist(X, 'correlation') - #print "correlation", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_correlation_random_nonC(self): - "Tests pdist(X, 'test_correlation') [the non-C implementation] on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-correlation'] - Y_test2 = pdist(X, 'test_correlation') - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_correlation_iris(self): - "Tests pdist(X, 'correlation') on the Iris data set." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-correlation-iris'] - - Y_test1 = pdist(X, 'correlation') - #print "correlation-iris", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_correlation_iris_nonC(self): - "Tests pdist(X, 'test_correlation') [the non-C implementation] on the Iris data set." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-correlation-iris'] - Y_test2 = pdist(X, 'test_correlation') - #print "test-correlation-iris", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################# minkowski - - def test_pdist_minkowski_random(self): - "Tests pdist(X, 'minkowski') on random data." - eps = 1e-05 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-minkowski-3.2'] - - Y_test1 = pdist(X, 'minkowski', 3.2) - #print "minkowski", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_minkowski_random_nonC(self): - "Tests pdist(X, 'test_minkowski') [the non-C implementation] on random data." - eps = 1e-05 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-minkowski-3.2'] - Y_test2 = pdist(X, 'test_minkowski', 3.2) - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_minkowski_iris(self): - "Tests pdist(X, 'minkowski') on iris data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-minkowski-3.2-iris'] - - Y_test1 = pdist(X, 'minkowski', 3.2) - #print "minkowski-iris-3.2", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_minkowski_iris_nonC(self): - "Tests pdist(X, 'test_minkowski') [the non-C implementation] on iris data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-minkowski-3.2-iris'] - Y_test2 = pdist(X, 'test_minkowski', 3.2) - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_minkowski_iris(self): - "Tests pdist(X, 'minkowski') on iris data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-minkowski-5.8-iris'] - - Y_test1 = pdist(X, 'minkowski', 5.8) - #print "minkowski-iris-5.8", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_minkowski_iris_nonC(self): - "Tests pdist(X, 'test_minkowski') [the non-C implementation] on iris data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-minkowski-5.8-iris'] - Y_test2 = pdist(X, 'test_minkowski', 5.8) - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: hamming - def test_pdist_hamming_random(self): - "Tests pdist(X, 'hamming') on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['pdist-boolean-inp'] - Y_right = eo['pdist-hamming'] - - Y_test1 = pdist(X, 'hamming') - #print "hamming", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_hamming_random_nonC(self): - "Tests pdist(X, 'test_hamming') [the non-C implementation] on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = eo['pdist-boolean-inp'] - Y_right = eo['pdist-hamming'] - Y_test2 = pdist(X, 'test_hamming') - #print "test-hamming", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: hamming (double) - def test_pdist_dhamming_random(self): - "Tests pdist(X, 'hamming') on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = numpy.float64(eo['pdist-boolean-inp']) - Y_right = eo['pdist-hamming'] - - Y_test1 = pdist(X, 'hamming') - #print "hamming", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_dhamming_random_nonC(self): - "Tests pdist(X, 'test_hamming') [the non-C implementation] on random data." - eps = 1e-07 - # Get the data: the input matrix and the right output. - X = numpy.float64(eo['pdist-boolean-inp']) - Y_right = eo['pdist-hamming'] - Y_test2 = pdist(X, 'test_hamming') - #print "test-hamming", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: jaccard - def test_pdist_jaccard_random(self): - "Tests pdist(X, 'jaccard') on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['pdist-boolean-inp'] - Y_right = eo['pdist-jaccard'] - - Y_test1 = pdist(X, 'jaccard') - #print "jaccard", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_jaccard_random_nonC(self): - "Tests pdist(X, 'test_jaccard') [the non-C implementation] on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['pdist-boolean-inp'] - Y_right = eo['pdist-jaccard'] - Y_test2 = pdist(X, 'test_jaccard') - #print "test-jaccard", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: jaccard (double) - def test_pdist_djaccard_random(self): - "Tests pdist(X, 'jaccard') on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = numpy.float64(eo['pdist-boolean-inp']) - Y_right = eo['pdist-jaccard'] - - Y_test1 = pdist(X, 'jaccard') - #print "jaccard", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_djaccard_random_nonC(self): - "Tests pdist(X, 'test_jaccard') [the non-C implementation] on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = numpy.float64(eo['pdist-boolean-inp']) - Y_right = eo['pdist-jaccard'] - Y_test2 = pdist(X, 'test_jaccard') - #print "test-jaccard", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - ################### pdist: chebychev - def test_pdist_chebychev_random(self): - "Tests pdist(X, 'chebychev') on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-chebychev'] - - Y_test1 = pdist(X, 'chebychev') - #print "chebychev", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_chebychev_random_nonC(self): - "Tests pdist(X, 'test_chebychev') [the non-C implementation] on random data." - eps = 1e-08 - # Get the data: the input matrix and the right output. - X = eo['pdist-double-inp'] - Y_right = eo['pdist-chebychev'] - Y_test2 = pdist(X, 'test_chebychev') - #print "test-chebychev", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - - def test_pdist_chebychev_iris(self): - "Tests pdist(X, 'chebychev') on the Iris data set." - eps = 1e-15 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-chebychev-iris'] - - Y_test1 = pdist(X, 'chebychev') - #print "chebychev-iris", numpy.abs(Y_test1 - Y_right).max() - self.failUnless(within_tol(Y_test1, Y_right, eps)) - - def test_pdist_chebychev_iris_nonC(self): - "Tests pdist(X, 'test_chebychev') [the non-C implementation] on the Iris data set." - eps = 1e-15 - # Get the data: the input matrix and the right output. - X = eo['iris'] - Y_right = eo['pdist-chebychev-iris'] - Y_test2 = pdist(X, 'test_chebychev') - #print "test-chebychev-iris", numpy.abs(Y_test2 - Y_right).max() - self.failUnless(within_tol(Y_test2, Y_right, eps)) - def within_tol(a, b, tol): return numpy.abs(a - b).max() < tol if __name__ == "__main__": nose.run(argv=['', __file__]) + Modified: branches/refactor_fft/scipy/cluster/tests/test_vq.py =================================================================== --- branches/refactor_fft/scipy/cluster/tests/test_vq.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/tests/test_vq.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,7 +1,7 @@ #! /usr/bin/env python # David Cournapeau -# Last Change: Tue Jul 03 08:00 PM 2007 J +# Last Change: Tue Jun 24 04:00 PM 2008 J # For now, just copy the tests from sandbox.pyem, so we can check that # kmeans works OK for trivial examples. @@ -152,5 +152,34 @@ kmeans2(data, 3, minit = 'random') kmeans2(data, 3, minit = 'points') + def test_kmeans2_empty(self): + """Ticket #505.""" + try: + kmeans2([], 2) + raise AssertionError("This should not succeed.") + except ValueError, e: + # OK, that's what we expect + pass + + def test_kmeans_0k(self): + """Regression test for #546: fail when k arg is 0.""" + try: + kmeans(X, 0) + raise AssertionError("kmeans with 0 clusters should fail.") + except ValueError: + pass + + try: + kmeans2(X, 0) + raise AssertionError("kmeans2 with 0 clusters should fail.") + except ValueError: + pass + + try: + kmeans2(X, N.array([])) + raise AssertionError("kmeans2 with 0 clusters should fail.") + except ValueError: + pass + if __name__ == "__main__": nose.run(argv=['', __file__]) Modified: branches/refactor_fft/scipy/cluster/vq.py =================================================================== --- branches/refactor_fft/scipy/cluster/vq.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/cluster/vq.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -370,10 +370,10 @@ """ code_book = array(guess, copy = True) - nc = code_book.shape[0] avg_dist = [] diff = thresh+1. while diff > thresh: + nc = code_book.shape[0] #compute membership and distances between obs and code_book obs_code, distort = vq(obs, code_book) avg_dist.append(mean(distort, axis=-1)) @@ -479,13 +479,17 @@ raise ValueError, 'iter must be >= to 1.' if type(k_or_guess) == type(array([])): guess = k_or_guess + if guess.size < 1: + raise ValueError("Asked for 0 cluster ? initial book was %s" % \ + guess) result = _kmeans(obs, guess, thresh = thresh) else: #initialize best distance value to a large value best_dist = 100000 No = obs.shape[0] k = k_or_guess - #print 'kmeans iter: ', + if k < 1: + raise ValueError("Asked for 0 cluster ? ") for i in range(iter): #the intial code book is randomly selected from observations guess = take(obs, randint(0, No, k), 0) @@ -633,6 +637,9 @@ else: raise ValueError("Input of rank > 2 not supported") + if N.size(data) < 1: + raise ValueError("Input has 0 items.") + # If k is not a single value, then it should be compatible with data's # shape if N.size(k) > 1 or minit == 'matrix': @@ -647,7 +654,14 @@ data") clusters = k.copy() else: - nc = int(k) + try: + nc = int(k) + except TypeError: + raise ValueError("k (%s) could not be converted to an integer " % str(k)) + + if nc < 1: + raise ValueError("kmeans2 for 0 clusters ? (k was %s)" % str(k)) + if not nc == k: warnings.warn("k was not an integer, was converted.") try: Copied: branches/refactor_fft/scipy/fftpack/SConscript (from rev 4510, trunk/scipy/fftpack/SConscript) Copied: branches/refactor_fft/scipy/fftpack/SConstruct (from rev 4510, trunk/scipy/fftpack/SConstruct) Copied: branches/refactor_fft/scipy/integrate/SConscript (from rev 4510, trunk/scipy/integrate/SConscript) Deleted: branches/refactor_fft/scipy/integrate/SConstruct =================================================================== --- branches/refactor_fft/scipy/integrate/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/integrate/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,61 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 J -# vim:syntax=python -from os.path import join as pjoin -import warnings - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment, CheckF77Clib, CheckF77BLAS - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') - -# 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(): - raise Exception("Could not find F77 BLAS, needed for integrate package") - -config.Finish() - -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) - -# XXX: lapack integration - -# Build linpack_lite -src = [str(s) for s in 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 = [str(s) for s in env.NumpyGlob(pjoin('mach', '*.f'))] -mach = env.NumpyStaticExtLibrary('mach', source = src) - -# Build quadpack -src = [str(s) for s in env.NumpyGlob(pjoin('quadpack', '*.f'))] -quadpack = env.NumpyStaticExtLibrary('quadpack', source = src) - -# Build odepack -src = [str(s) for s in env.NumpyGlob(pjoin('odepack', '*.f'))] -odepack = env.NumpyStaticExtLibrary('odepack', source = src) - -env.AppendUnique(LIBPATH = env['build_dir']) -env.AppendUnique(LINKFLAGSEND = env['F77_LDFLAGS']) - -quadenv = env.Clone() -quadenv.Prepend(LIBS = ['quadpack', 'linpack_lite', 'mach']) - -odenv = env.Clone() -odenv.Prepend(LIBS = ['odepack', 'linpack_lite', 'mach']) - -# Build _quadpack -quadenv.NumpyPythonExtension('_quadpack', source = '_quadpackmodule.c') - -# Build _odepack -odenv.NumpyPythonExtension('_odepack', source = '_odepackmodule.c') - -# Build vode -odenv.NumpyPythonExtension('vode', source = 'vode.pyf') Copied: branches/refactor_fft/scipy/integrate/SConstruct (from rev 4510, trunk/scipy/integrate/SConstruct) Modified: branches/refactor_fft/scipy/integrate/__odepack.h =================================================================== --- branches/refactor_fft/scipy/integrate/__odepack.h 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/integrate/__odepack.h 2008-07-01 04:52:00 UTC (rev 4511) @@ -326,7 +326,11 @@ *((int *)ap_nfe->data + (k-1)) = iwork[11]; *((int *)ap_nje->data + (k-1)) = iwork[12]; *((int *)ap_nqu->data + (k-1)) = iwork[13]; - imxer = iwork[15]; + if (istate == -5 || istate == -4) { + imxer = iwork[15]; + } else { + imxer = -1; + } lenrw = iwork[16]; leniw = iwork[17]; *((int *)ap_mused->data + (k-1)) = iwork[18]; @@ -348,7 +352,20 @@ /* Do Full output */ if (full_output) { - return Py_BuildValue("N{s:N,s:N,s:N,s:N,s:N,s:N,s:N,s:N,s:i,s:i,s:i,s:N}i",PyArray_Return(ap_yout),"hu",PyArray_Return(ap_hu),"tcur",PyArray_Return(ap_tcur),"tolsf",PyArray_Return(ap_tolsf),"tsw",PyArray_Return(ap_tsw),"nst",PyArray_Return(ap_nst),"nfe",PyArray_Return(ap_nfe),"nje",PyArray_Return(ap_nje),"nqu",PyArray_Return(ap_nqu),"imxer",imxer,"lenrw",lenrw,"leniw",leniw,"mused",PyArray_Return(ap_mused),istate); + return Py_BuildValue("N{s:N,s:N,s:N,s:N,s:N,s:N,s:N,s:N,s:i,s:i,s:i,s:N}i",PyArray_Return(ap_yout), + "hu",PyArray_Return(ap_hu), + "tcur",PyArray_Return(ap_tcur), + "tolsf",PyArray_Return(ap_tolsf), + "tsw",PyArray_Return(ap_tsw), + "nst",PyArray_Return(ap_nst), + "nfe",PyArray_Return(ap_nfe), + "nje",PyArray_Return(ap_nje), + "nqu",PyArray_Return(ap_nqu), + "imxer",imxer, + "lenrw",lenrw, + "leniw",leniw, + "mused",PyArray_Return(ap_mused), + istate); } else { return Py_BuildValue("Ni",PyArray_Return(ap_yout),istate); Modified: branches/refactor_fft/scipy/integrate/odepack.py =================================================================== --- branches/refactor_fft/scipy/integrate/odepack.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/integrate/odepack.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -21,96 +21,116 @@ ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0, hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12, mxords=5, printmessg=0): - """Integrate a system of ordinary differential equations. - Description: + Solve a system of ordinary differential equations using lsoda from the + FORTRAN library odepack. - Solve a system of ordinary differential equations Using lsoda from the - FORTRAN library odepack. + Solves the initial value problem for stiff or non-stiff systems + of first order ode-s:: + + dy/dt = func(y,t0,...) - Solves the initial value problem for stiff or non-stiff systems - of first order ode-s: - dy/dt = func(y,t0,...) where y can be a vector. + where y can be a vector. - Inputs: + Parameters + ---------- + func : callable(y, t0, ...) + Computes the derivative of y at t0. + y0 : array + Initial condition on y (can be a vector). + t : array + A sequence of time points for which to solve for y. The initial + value point should be the first element of this sequence. + args : tuple + Extra arguments to pass to function. + Dfun : callable(y, t0, ...) + Gradient (Jacobian) of func. + col_deriv : boolean + True if Dfun defines derivatives down columns (faster), + otherwise Dfun should define derivatives across rows. + full_output : boolean + True if to return a dictionary of optional outputs as the second output + printmessg : boolean + Whether to print the convergence message - func -- func(y,t0,...) computes the derivative of y at t0. - y0 -- initial condition on y (can be a vector). - t -- a sequence of time points for which to solve for y. The intial - value point should be the first element of this sequence. - args -- extra arguments to pass to function. - Dfun -- the gradient (Jacobian) of func (same input signature as func). - col_deriv -- non-zero implies that Dfun defines derivatives down - columns (faster), otherwise Dfun should define derivatives - across rows. - full_output -- non-zero to return a dictionary of optional outputs as - the second output. - printmessg -- print the convergence message. + Returns + ------- + y : array, shape (len(y0), len(t)) + Array containing the value of y for each desired time in t, + with the initial value y0 in the first row. + + infodict : dict, only returned if full_output == True + Dictionary containing additional output information + + ======= ============================================================ + key meaning + ======= ============================================================ + 'hu' vector of step sizes successfully used for each time step. + 'tcur' vector with the value of t reached for each time step. + (will always be at least as large as the input times). + 'tolsf' vector of tolerance scale factors, greater than 1.0, + computed when a request for too much accuracy was detected. + 'tsw' value of t at the time of the last method switch + (given for each time step) + 'nst' cumulative number of time steps + 'nfe' cumulative number of function evaluations for each time step + 'nje' cumulative number of jacobian evaluations for each time step + 'nqu' a vector of method orders for each successful step. + 'imxer' index of the component of largest magnitude in the + weighted local error vector (e / ewt) on an error return, -1 + otherwise. + 'lenrw' the length of the double work array required. + 'leniw' the length of integer work array required. + 'mused' a vector of method indicators for each successful time step: + 1: adams (nonstiff), 2: bdf (stiff) + ======= ============================================================ + + Other Parameters + ---------------- + ml, mu : integer + If either of these are not-None or non-negative, then the + Jacobian is assumed to be banded. These give the number of + lower and upper non-zero diagonals in this banded matrix. + For the banded case, Dfun should return a matrix whose + columns contain the non-zero bands (starting with the + lowest diagonal). Thus, the return matrix from Dfun should + have shape len(y0) * (ml + mu + 1) when ml >=0 or mu >=0 + rtol, atol : float + The input parameters rtol and atol determine the error + control performed by the solver. The solver will control the + vector, e, of estimated local errors in y, according to an + inequality of the form:: + max-norm of (e / ewt) <= 1 + where ewt is a vector of positive error weights computed as:: + ewt = rtol * abs(y) + atol + rtol and atol can be either vectors the same length as y or scalars. + tcrit : array + Vector of critical points (e.g. singularities) where integration + care should be taken. + h0 : float, (0: solver-determined) + The step size to be attempted on the first step. + hmax : float, (0: solver-determined) + The maximum absolute step size allowed. + hmin : float, (0: solver-determined) + The minimum absolute step size allowed. + ixpr : boolean + Whether to generate extra printing at method switches. + mxstep : integer, (0: solver-determined) + Maximum number of (internally defined) steps allowed for each + integration point in t. + mxhnil : integer, (0: solver-determined) + Maximum number of messages printed. + mxordn : integer, (0: solver-determined) + Maximum order to be allowed for the nonstiff (Adams) method. + mxords : integer, (0: solver-determined) + Maximum order to be allowed for the stiff (BDF) method. - Outputs: (y, {infodict,}) - - y -- a rank-2 array containing the value of y in each row for each - desired time in t (with the initial value y0 in the first row). - - infodict -- a dictionary of optional outputs: - 'hu' : a vector of step sizes successfully used for each time step. - 'tcur' : a vector with the value of t reached for each time step. - (will always be at least as large as the input times). - 'tolsf' : a vector of tolerance scale factors, greater than 1.0, - computed when a request for too much accuracy was detected. - 'tsw' : the value of t at the time of the last method switch - (given for each time step). - 'nst' : the cumulative number of time steps. - 'nfe' : the cumulative number of function evaluations for eadh - time step. - 'nje' : the cumulative number of jacobian evaluations for each - time step. - 'nqu' : a vector of method orders for each successful step. - 'imxer' : index of the component of largest magnitude in the - weighted local error vector (e / ewt) on an error return. - 'lenrw' : the length of the double work array required. - 'leniw' : the length of integer work array required. - 'mused' : a vector of method indicators for each successful time step: - 1 -- adams (nonstiff) - 2 -- bdf (stiff) - - Additional Inputs: - - ml, mu -- If either of these are not-None or non-negative, then the - Jacobian is assumed to be banded. These give the number of - lower and upper non-zero diagonals in this banded matrix. - For the banded case, Dfun should return a matrix whose - columns contain the non-zero bands (starting with the - lowest diagonal). Thus, the return matrix from Dfun should - have shape len(y0) x (ml + mu + 1) when ml >=0 or mu >=0 - rtol -- The input parameters rtol and atol determine the error - atol control performed by the solver. The solver will control the - vector, e, of estimated local errors in y, according to an - inequality of the form - max-norm of (e / ewt) <= 1 - where ewt is a vector of positive error weights computed as - ewt = rtol * abs(y) + atol - rtol and atol can be either vectors the same length as y or - scalars. - tcrit -- a vector of critical points (e.g. singularities) where - integration care should be taken. - - (For the next inputs a zero default means the solver determines it). - - h0 -- the step size to be attempted on the first step. - hmax -- the maximum absolute step size allowed. - hmin -- the minimum absolute step size allowed. - ixpr -- non-zero to generate extra printing at method switches. - mxstep -- maximum number of (internally defined) steps allowed - for each integration point in t. - mxhnil -- maximum number of messages printed. - mxordn -- maximum order to be allowed for the nonstiff (Adams) method. - mxords -- maximum order to be allowed for the stiff (BDF) method. - - See also: - ode - a more object-oriented integrator based on VODE - quad - for finding the area under a curve + See Also + -------- + ode : a more object-oriented integrator based on VODE + quad : for finding the area under a curve + """ if ml is None: Copied: branches/refactor_fft/scipy/interpolate/SConscript (from rev 4510, trunk/scipy/interpolate/SConscript) Deleted: branches/refactor_fft/scipy/interpolate/SConstruct =================================================================== --- branches/refactor_fft/scipy/interpolate/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,31 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 J -# vim:syntax=python -from os.path import join as pjoin - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment, CheckF77Clib - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') - -config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib}) -if not config.CheckF77Clib(): - raise Exception("Could not check F77 runtime, needed for interpolate") -config.Finish() - -env.PrependUnique(CPPPATH = get_numpy_include_dirs()) -env.PrependUnique(CPPPATH = env['F2PYINCLUDEDIR']) -env.AppendUnique(LINKFLAGSEND = env['F77_LDFLAGS']) - -# Build fitpack -src = [str(s) for s in env.NumpyGlob(pjoin('fitpack', '*.f'))] -fitpack = env.NumpyStaticExtLibrary('fitpack', source = src) - -env.PrependUnique(LIBS = ['fitpack']) -env.PrependUnique(LIBPATH = [env['build_dir']]) - -# Build _fitpack -env.NumpyPythonExtension('_fitpack', source = '_fitpackmodule.c') - -# Build dfitpack -env.NumpyPythonExtension('dfitpack', source = 'fitpack.pyf') Copied: branches/refactor_fft/scipy/interpolate/SConstruct (from rev 4510, trunk/scipy/interpolate/SConstruct) Modified: branches/refactor_fft/scipy/interpolate/fitpack.py =================================================================== --- branches/refactor_fft/scipy/interpolate/fitpack.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/fitpack.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -842,6 +842,28 @@ if len(z[0])>1: return z[0] return z[0][0] +def dblint(xa,xb,ya,yb,tck): + """Evaluate the integral of a spline over area [xa,xb] x [ya,yb]. + + Parameters + ---------- + xa, xb : float + The end-points of the x integration interval. + ya, yb : float + The end-points of the y integration interval. + tck : list [tx, ty, c, kx, ky] + A sequence of length 5 returned by bisplrep containing the knot + locations tx, ty, the coefficients c, and the degrees kx, ky + of the spline. + + Returns + ------- + integ : float + The value of the resulting integral. + """ + tx,ty,c,kx,ky=tck + return dfitpack.dblint(tx,ty,c,kx,ky,xb,xe,yb,ye) + def insert(x,tck,m=1,per=0): """Insert knots into a B-spline. Modified: branches/refactor_fft/scipy/interpolate/fitpack.pyf =================================================================== --- branches/refactor_fft/scipy/interpolate/fitpack.pyf 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/fitpack.pyf 2008-07-01 04:52:00 UTC (rev 4511) @@ -456,7 +456,24 @@ :: kwrk=3+mx+my+nxest+nyest integer intent(out) :: ier end subroutine regrid_smth - + + function dblint(tx,nx,ty,ny,c,kx,ky,xb,xe,yb,ye,wrk) + ! iy = dblint(tx,ty,c,kx,ky,xb,xe,yb,ye) + real*8 dimension(nx),intent(in) :: tx + integer intent(hide),depend(tx) :: nx=len(tx) + real*8 dimension(ny),intent(in) :: ty + integer intent(hide),depend(ty) :: ny=len(ty) + real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& + check(len(c)==(nx-kx-1)*(ny-ky-1)):: c + integer :: kx + integer :: ky + real*8 intent(in) :: xb + real*8 intent(in) :: xe + real*8 intent(in) :: yb + real*8 intent(in) :: ye + real*8 dimension(nx+ny-kx-ky-2),depend(nx,ny,kx,ky),intent(cache,hide) :: wrk + real*8 :: dblint + end function dblint end interface end python module dfitpack Modified: branches/refactor_fft/scipy/interpolate/fitpack2.py =================================================================== --- branches/refactor_fft/scipy/interpolate/fitpack2.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/fitpack2.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -352,6 +352,27 @@ assert ier==0,'Invalid input: ier='+`ier` return z raise NotImplementedError + + def integral(self, xa, xb, ya, yb): + """ + Evaluate the integral of the spline over area [xa,xb] x [ya,yb]. + + Parameters + ---------- + xa, xb : float + The end-points of the x integration interval. + ya, yb : float + The end-points of the y integration interval. + + Returns + ------- + integ : float + The value of the resulting integral. + + """ + tx,ty,c = self.tck[:3] + kx,ky = self.degrees + return dfitpack.dblint(tx,ty,c,kx,ky,xa,xb,ya,yb) class SmoothBivariateSpline(BivariateSpline): """ Smooth bivariate spline approximation. Modified: branches/refactor_fft/scipy/interpolate/interpolate.py =================================================================== --- branches/refactor_fft/scipy/interpolate/interpolate.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/interpolate.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -152,9 +152,6 @@ UnivariateSpline - a more recent wrapper of the FITPACK routines """ - _interp_axis = -1 # used to set which is default interpolation - # axis. DO NOT CHANGE OR CODE WILL BREAK. - def __init__(self, x, y, kind='linear', axis=-1, copy=True, bounds_error=True, fill_value=np.nan): """ Initialize a 1D linear interpolation class. @@ -226,12 +223,18 @@ if kind == 'linear': # Make a "view" of the y array that is rotated to the interpolation # axis. - oriented_y = y.swapaxes(self._interp_axis, axis) + axes = range(y.ndim) + del axes[self.axis] + axes.append(self.axis) + oriented_y = y.transpose(axes) minval = 2 - len_y = oriented_y.shape[self._interp_axis] + len_y = oriented_y.shape[-1] self._call = self._call_linear else: - oriented_y = y.swapaxes(0, axis) + axes = range(y.ndim) + del axes[self.axis] + axes.insert(0, self.axis) + oriented_y = y.transpose(axes) minval = order + 1 len_y = oriented_y.shape[0] self._call = self._call_spline @@ -322,10 +325,10 @@ return y_new.transpose(axes) else: y_new[out_of_bounds] = self.fill_value - axes = range(ny - nx, ny) - axes[self.axis:self.axis] = range(ny - nx) + axes = range(nx, ny) + axes[self.axis:self.axis] = range(nx) return y_new.transpose(axes) - + def _check_bounds(self, x_new): """ Check the inputs for being in the bounds of the interpolated data. @@ -407,6 +410,16 @@ fromspline = classmethod(fromspline) +def _dot0(a, b): + """Similar to numpy.dot, but sum over last axis of a and 1st axis of b""" + if b.ndim <= 2: + return dot(a, b) + else: + axes = range(b.ndim) + axes.insert(-1, 0) + axes.pop(0) + return dot(a, b.transpose(axes)) + def _find_smoothest(xk, yk, order, conds=None, B=None): # construct Bmatrix, and Jmatrix # e = J*c @@ -431,9 +444,8 @@ tmp = dot(tmp,V1) tmp = dot(tmp,np.diag(1.0/s)) tmp = dot(tmp,u.T) - return dot(tmp, yk) + return _dot0(tmp, yk) - def _setdiag(a, k, v): assert (a.ndim==2) M,N = a.shape @@ -471,7 +483,7 @@ V2[1::2] = -1 V2 /= math.sqrt(Np1) dk = np.diff(xk) - b = 2*np.diff(yk)/dk + b = 2*np.diff(yk, axis=0)/dk J = np.zeros((N-1,N+1)) idk = 1.0/dk _setdiag(J,0,idk[:-1]) @@ -480,7 +492,7 @@ A = dot(J.T,J) val = dot(V2,dot(A,V2)) res1 = dot(np.outer(V2,V2)/val,A) - mk = dot(np.eye(Np1)-res1,dot(Bd,b)) + mk = dot(np.eye(Np1)-res1, _dot0(Bd,b)) return mk def _get_spline2_Bb(xk, yk, kind, conds): Modified: branches/refactor_fft/scipy/interpolate/rbf.py =================================================================== --- branches/refactor_fft/scipy/interpolate/rbf.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/rbf.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -from numpy import sqrt, log, asarray, newaxis, all, dot, float64, eye +from numpy import sqrt, log, asarray, newaxis, all, dot, float64, exp, eye from scipy import linalg class Rbf(object): @@ -58,7 +58,7 @@ return sqrt((1.0/self.epsilon*r)**2 + 1) elif self.function.lower() == 'inverse multiquadric': return 1.0/sqrt((1.0/self.epsilon*r)**2 + 1) - elif self.function.lower() == 'gausian': + elif self.function.lower() == 'gaussian': return exp(-(self.epsilon*r)**2) elif self.function.lower() == 'cubic': return r**3 @@ -84,7 +84,7 @@ :: 'multiquadric': sqrt((self.epsilon*r)**2 + 1) 'inverse multiquadric': 1.0/sqrt((self.epsilon*r)**2 + 1) - 'gausian': exp(-(self.epsilon*r)**2) + 'gaussian': exp(-(self.epsilon*r)**2) 'cubic': r**3 'quintic': r**5 'thin-plate': r**2 * log(r) Modified: branches/refactor_fft/scipy/interpolate/tests/test_fitpack.py =================================================================== --- branches/refactor_fft/scipy/interpolate/tests/test_fitpack.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/tests/test_fitpack.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -14,7 +14,7 @@ import sys from scipy.testing import * -from numpy import array +from numpy import array, diff from scipy.interpolate.fitpack2 import UnivariateSpline,LSQUnivariateSpline,\ InterpolatedUnivariateSpline from scipy.interpolate.fitpack2 import LSQBivariateSpline, \ @@ -48,10 +48,49 @@ tx = [1+s,3-s] ty = [1+s,3-s] lut = LSQBivariateSpline(x,y,z,tx,ty,kx=1,ky=1) - #print lut.get_knots() - #print lut.get_coeffs() - #print lut.get_residual() + assert_almost_equal(lut(2,2), 3.) + + def test_bilinearity(self): + x = [1,1,1,2,2,2,3,3,3] + y = [1,2,3,1,2,3,1,2,3] + z = [0,7,8,3,4,7,1,3,4] + s = 0.1 + tx = [1+s,3-s] + ty = [1+s,3-s] + lut = LSQBivariateSpline(x,y,z,tx,ty,kx=1,ky=1) + + tx, ty = lut.get_knots() + + for xa, xb in zip(tx[:-1], tx[1:]): + for ya, yb in zip(ty[:-1], ty[1:]): + for t in [0.1, 0.5, 0.9]: + for s in [0.3, 0.4, 0.7]: + xp = xa*(1-t) + xb*t + yp = ya*(1-s) + yb*s + zp = (+ lut(xa, ya)*(1-t)*(1-s) + + lut(xb, ya)*t*(1-s) + + lut(xa, yb)*(1-t)*s + + lut(xb, yb)*t*s) + assert_almost_equal(lut(xp,yp), zp) + + def test_integral(self): + x = [1,1,1,2,2,2,8,8,8] + y = [1,2,3,1,2,3,1,2,3] + z = array([0,7,8,3,4,7,1,3,4]) + + s = 0.1 + tx = [1+s,3-s] + ty = [1+s,3-s] + lut = LSQBivariateSpline(x,y,z,tx,ty,kx=1,ky=1) + tx, ty = lut.get_knots() + + tz = lut(tx, ty) + trpz = .25*(diff(tx)[:,None]*diff(ty)[None,:] + *(tz[:-1,:-1]+tz[1:,:-1]+tz[:-1,1:]+tz[1:,1:])).sum() + + assert_almost_equal(lut.integral(tx[0], tx[-1], ty[0], ty[-1]), trpz) + class TestSmoothBivariateSpline(TestCase): def test_linear_constant(self): x = [1,1,1,2,2,2,3,3,3] @@ -73,6 +112,29 @@ assert_almost_equal(lut.get_residual(),0.0) assert_array_almost_equal(lut([1,1.5,2],[1,1.5]),[[0,0],[1,1],[2,2]]) + def test_integral(self): + x = [1,1,1,2,2,2,4,4,4] + y = [1,2,3,1,2,3,1,2,3] + z = array([0,7,8,3,4,7,1,3,4]) + + lut = SmoothBivariateSpline(x,y,z,kx=1,ky=1,s=0) + tx = [1,2,4] + ty = [1,2,3] + + tz = lut(tx, ty) + trpz = .25*(diff(tx)[:,None]*diff(ty)[None,:] + *(tz[:-1,:-1]+tz[1:,:-1]+tz[:-1,1:]+tz[1:,1:])).sum() + assert_almost_equal(lut.integral(tx[0], tx[-1], ty[0], ty[-1]), trpz) + + lut2 = SmoothBivariateSpline(x,y,z,kx=2,ky=2,s=0) + assert_almost_equal(lut2.integral(tx[0], tx[-1], ty[0], ty[-1]), trpz, + decimal=0) # the quadratures give 23.75 and 23.85 + + tz = lut(tx[:-1], ty[:-1]) + trpz = .25*(diff(tx[:-1])[:,None]*diff(ty[:-1])[None,:] + *(tz[:-1,:-1]+tz[1:,:-1]+tz[:-1,1:]+tz[1:,1:])).sum() + assert_almost_equal(lut.integral(tx[0], tx[-2], ty[0], ty[-2]), trpz) + class TestRectBivariateSpline(TestCase): def test_defaults(self): x = array([1,2,3,4,5]) Modified: branches/refactor_fft/scipy/interpolate/tests/test_interpolate.py =================================================================== --- branches/refactor_fft/scipy/interpolate/tests/test_interpolate.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/interpolate/tests/test_interpolate.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -29,7 +29,7 @@ self.y210 = np.arange(20.).reshape((2, 10)) self.y102 = np.arange(20.).reshape((10, 2)) - + self.fill_value = -100.0 def test_validation(self): @@ -125,13 +125,30 @@ np.array([2.4, 5.6, 6.0]), ) + def test_cubic(self): + """ Check the actual implementation of spline interpolation. + """ - def test_bounds(self): + interp10 = interp1d(self.x10, self.y10, kind='cubic') + assert_array_almost_equal( + interp10(self.x10), + self.y10, + ) + assert_array_almost_equal( + interp10(1.2), + np.array([1.2]), + ) + assert_array_almost_equal( + interp10([2.4, 5.6, 6.0]), + np.array([2.4, 5.6, 6.0]), + ) + + def _bounds_check(self, kind='linear'): """ Test that our handling of out-of-bounds input is correct. """ extrap10 = interp1d(self.x10, self.y10, fill_value=self.fill_value, - bounds_error=False) + bounds_error=False, kind=kind) assert_array_equal( extrap10(11.2), np.array([self.fill_value]), @@ -145,25 +162,28 @@ np.array([True, False, False, False, True]), ) - raises_bounds_error = interp1d(self.x10, self.y10, bounds_error=True) + raises_bounds_error = interp1d(self.x10, self.y10, bounds_error=True, + kind=kind) self.assertRaises(ValueError, raises_bounds_error, -1.0) self.assertRaises(ValueError, raises_bounds_error, 11.0) raises_bounds_error([0.0, 5.0, 9.0]) + def test_bounds(self): + for kind in ('linear', 'cubic'): + self._bounds_check(kind=kind) - def test_nd(self): + def _nd_check(self, kind='linear'): """ Check the behavior when the inputs and outputs are multidimensional. """ - # Multidimensional input. - interp10 = interp1d(self.x10, self.y10) + interp10 = interp1d(self.x10, self.y10, kind=kind) assert_array_almost_equal( interp10(np.array([[3.4, 5.6], [2.4, 7.8]])), np.array([[3.4, 5.6], [2.4, 7.8]]), ) - + # Multidimensional outputs. - interp210 = interp1d(self.x10, self.y210) + interp210 = interp1d(self.x10, self.y210, kind=kind) assert_array_almost_equal( interp210(1.5), np.array([[1.5], [11.5]]), @@ -174,7 +194,7 @@ [11.5, 12.4]]), ) - interp102 = interp1d(self.x10, self.y102, axis=0) + interp102 = interp1d(self.x10, self.y102, axis=0, kind=kind) assert_array_almost_equal( interp102(1.5), np.array([[3.0, 4.0]]), @@ -197,7 +217,24 @@ np.array([[[6.8, 7.8], [11.2, 12.2]], [[4.8, 5.8], [15.6, 16.6]]]), ) + + # Check large ndim output + a = [4, 5, 6, 7] + y = np.arange(np.prod(a)).reshape(*a) + for n, s in enumerate(a): + x = np.arange(s) + z = interp1d(x, y, axis=n, kind=kind) + assert_array_almost_equal(z(x), y) + + x2 = np.arange(2*3*1).reshape((2,3,1)) / 12. + b = list(a) + b[n:n+1] = [2,3,1] + assert_array_almost_equal(z(x2).shape, b) + def test_nd(self): + for kind in ('linear', 'cubic'): + self._nd_check(kind=kind) + class TestLagrange(TestCase): def test_lagrange(self): Copied: branches/refactor_fft/scipy/io/SConscript (from rev 4510, trunk/scipy/io/SConscript) Deleted: branches/refactor_fft/scipy/io/SConstruct =================================================================== --- branches/refactor_fft/scipy/io/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,11 +0,0 @@ -# Last Change: Wed Mar 05 03:00 PM 2008 J -# vim:syntax=python -from os.path import join - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment - -env = GetNumpyEnvironment(ARGUMENTS) - -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.NumpyPythonExtension('numpyio', source = 'numpyiomodule.c') Copied: branches/refactor_fft/scipy/io/SConstruct (from rev 4510, trunk/scipy/io/SConstruct) Modified: branches/refactor_fft/scipy/io/array_import.py =================================================================== --- branches/refactor_fft/scipy/io/array_import.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/array_import.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -169,7 +169,7 @@ return lines[:-1] def __del__(self): - if hasattr(self.file,'close') and self.should_close_file: + if hasattr(getattr(self, 'file', None),'close') and self.should_close_file: self.file.close() def __getitem__(self, item): Modified: branches/refactor_fft/scipy/io/matlab/miobase.py =================================================================== --- branches/refactor_fft/scipy/io/matlab/miobase.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/matlab/miobase.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -284,7 +284,8 @@ def end_of_stream(self): b = self.mat_stream.read(1) - self.mat_stream.seek(-1,1) + curpos = self.mat_stream.tell() + self.mat_stream.seek(curpos-1) return len(b) == 0 Modified: branches/refactor_fft/scipy/io/matlab/tests/test_mio.py =================================================================== --- branches/refactor_fft/scipy/io/matlab/tests/test_mio.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/matlab/tests/test_mio.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -3,7 +3,7 @@ import os from glob import glob from cStringIO import StringIO -from tempfile import mkstemp +from tempfile import mkstemp, mkdtemp from scipy.testing import * from numpy import arange, array, eye, pi, cos, exp, sin, sqrt, ndarray, \ zeros, reshape, transpose, empty @@ -12,6 +12,9 @@ from scipy.io.matlab.mio import loadmat, savemat from scipy.io.matlab.mio5 import mat_obj, mat_struct +import shutil +import gzip + try: # Python 2.3 support from sets import Set as set except: @@ -238,3 +241,29 @@ expected = case['expected'] format = case in case_table4 and '4' or '5' yield _make_rt_check_case, name, expected, format + +def test_gzip_simple(): + xdense = zeros((20,20)) + xdense[2,3]=2.3 + xdense[4,5]=4.5 + x = SP.csc_matrix(xdense) + + name = 'gzip_test' + expected = {'x':x} + format='4' + + tmpdir = mkdtemp() + try: + fname = os.path.join(tmpdir,name) + mat_stream = gzip.open( fname,mode='wb') + savemat(mat_stream, expected, format=format) + mat_stream.close() + + mat_stream = gzip.open( fname,mode='rb') + actual = loadmat(mat_stream) + mat_stream.close() + finally: + shutil.rmtree(tmpdir) + + assert_array_almost_equal(actual['x'].todense(), + expected['x'].todense()) Modified: branches/refactor_fft/scipy/io/mmio.py =================================================================== --- branches/refactor_fft/scipy/io/mmio.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/mmio.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -554,16 +554,16 @@ coo = a.tocoo() # convert to COOrdinate format # write shape spec - stream.write('%i %i %i\n' % (rows,cols,coo.nnz)) + stream.write('%i %i %i\n' % (rows, cols, coo.nnz)) fmt = '%%.%dg' % precision if field == self.FIELD_PATTERN: - IJV = vstack((a.row, a.col)).T + IJV = vstack((coo.row, coo.col)).T elif field in [ self.FIELD_INTEGER, self.FIELD_REAL ]: - IJV = vstack((a.row, a.col, a.data)).T + IJV = vstack((coo.row, coo.col, coo.data)).T elif field == self.FIELD_COMPLEX: - IJV = vstack((a.row, a.col, a.data.real, a.data.imag)).T + IJV = vstack((coo.row, coo.col, coo.data.real, coo.data.imag)).T else: raise TypeError('Unknown field type %s' % `field`) Modified: branches/refactor_fft/scipy/io/tests/test_mmio.py =================================================================== --- branches/refactor_fft/scipy/io/tests/test_mmio.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/tests/test_mmio.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -291,5 +291,28 @@ b = mmread(fn).todense() assert_array_almost_equal(a,b) + def test_sparse_formats(self): + mats = [] + + I = array([0, 0, 1, 2, 3, 3, 3, 4]) + J = array([0, 3, 1, 2, 1, 3, 4, 4]) + + V = array([ 1.0, 6.0, 10.5, 0.015, 250.5, -280.0, 33.32, 12.0 ]) + mats.append( scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5)) ) + + V = array([ 1.0 + 3j, 6.0 + 2j, 10.50 + 0.9j, 0.015 + -4.4j, + 250.5 + 0j, -280.0 + 5j, 33.32 + 6.4j, 12.00 + 0.8j]) + mats.append( scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5)) ) + + for mat in mats: + expected = mat.todense() + for fmt in ['csr','csc','coo']: + fn = mktemp() + mmwrite(fn, mat.asformat(fmt)) + + result = mmread(fn).todense() + assert_array_almost_equal(result, expected) + + if __name__ == "__main__": nose.run(argv=['', __file__]) Modified: branches/refactor_fft/scipy/io/wavfile.py =================================================================== --- branches/refactor_fft/scipy/io/wavfile.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/io/wavfile.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -15,7 +15,7 @@ # assumes file pointer is immediately # after the 'data' id def _read_data_chunk(fid, noc, bits): - size = struct.unpack('l',fid.read(4))[0] + size = struct.unpack('i',fid.read(4))[0] if bits == 8: data = numpy.fromfile(fid, dtype=numpy.ubyte, count=size) if noc > 1: @@ -30,7 +30,7 @@ def _read_riff_chunk(fid): str1 = fid.read(4) - fsize = struct.unpack('L', fid.read(4))[0] + 8 + fsize = struct.unpack('I', fid.read(4))[0] + 8 str2 = fid.read(4) if (str1 != 'RIFF' or str2 != 'WAVE'): raise ValueError, "Not a WAV file." @@ -64,7 +64,7 @@ data = _read_data_chunk(fid, noc, bits) else: print "Warning: %s chunk not understood" - size = struct.unpack('L',fid.read(4))[0] + size = struct.unpack('I',fid.read(4))[0] bytes = fid.read(size) fid.close() return rate, data @@ -99,11 +99,11 @@ fid.write(struct.pack('lhHLLHH', 16, 1, noc, rate, sbytes, ba, bits)) # data chunk fid.write('data') - fid.write(struct.pack('l', data.nbytes)) + fid.write(struct.pack('i', data.nbytes)) data.tofile(fid) # Determine file size and place it in correct # position at start of the file. size = fid.tell() fid.seek(4) - fid.write(struct.pack('l', size-8)) + fid.write(struct.pack('i', size-8)) fid.close() Copied: branches/refactor_fft/scipy/lib/blas/SConscript (from rev 4510, trunk/scipy/lib/blas/SConscript) Deleted: branches/refactor_fft/scipy/lib/blas/SConstruct =================================================================== --- branches/refactor_fft/scipy/lib/blas/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/lib/blas/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,85 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 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 numscons import get_python_inc#, get_pythonlib_dir -from numscons import GetNumpyEnvironment -from numscons import CheckCBLAS, CheckF77BLAS,\ - IsVeclib, IsAccelerate, \ - IsATLAS, GetATLASVersion -from numscons import write_info - -from scons_support import do_generate_fake_interface, generate_interface_emitter - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') - -env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) -#if os.name == 'nt': -# # NT needs the pythonlib to run any code importing Python.h, including -# # simple code using only typedef and so on, so we need it for configuration -# # checks -# env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) - -env['BUILDERS']['GenerateFakePyf'] = Builder(action = do_generate_fake_interface, - emitter = generate_interface_emitter) - -#======================= -# 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) - 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') -else: - print env.GenerateFakePyf('cblas', 'cblas.pyf.src') -env.NumpyPythonExtension('cblas', source) Copied: branches/refactor_fft/scipy/lib/blas/SConstruct (from rev 4510, trunk/scipy/lib/blas/SConstruct) Modified: branches/refactor_fft/scipy/lib/blas/scons_support.py =================================================================== --- branches/refactor_fft/scipy/lib/blas/scons_support.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/lib/blas/scons_support.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,8 +1,6 @@ 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) Copied: branches/refactor_fft/scipy/lib/lapack/SConscript (from rev 4510, trunk/scipy/lib/lapack/SConscript) Deleted: branches/refactor_fft/scipy/lib/lapack/SConstruct =================================================================== --- branches/refactor_fft/scipy/lib/lapack/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/lib/lapack/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,95 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 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 numscons import get_python_inc -from numscons import GetNumpyEnvironment -from numscons import CheckF77LAPACK,\ - CheckCLAPACK, \ - IsATLAS, GetATLASVersion, \ - CheckF77Clib -from numscons import write_info - -from scons_support import do_generate_fake_interface, \ - generate_interface_emitter - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') -env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) -#if os.name == 'nt': -# # NT needs the pythonlib to run any code importing Python.h, including -# # 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 = {'CheckCLAPACK' : CheckCLAPACK, - '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") - -if IsATLAS(env, 'lapack'): - version = GetATLASVersion(env) - 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.NumpyF2py(pjoin('calc_lworkmodule.c'), - source = pjoin('calc_lwork.f')) -env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f'], - LINKFLAGSEND = env['F77_LDFLAGS']) - -#-------------- -# Atlas version -#-------------- -env.NumpyPythonExtension('atlas_version', 'atlas_version.c') Copied: branches/refactor_fft/scipy/lib/lapack/SConstruct (from rev 4510, trunk/scipy/lib/lapack/SConstruct) Modified: branches/refactor_fft/scipy/lib/lapack/scons_support.py =================================================================== --- branches/refactor_fft/scipy/lib/lapack/scons_support.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/lib/lapack/scons_support.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,8 +1,6 @@ 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) Copied: branches/refactor_fft/scipy/linalg/SConscript (from rev 4510, trunk/scipy/linalg/SConscript) Deleted: branches/refactor_fft/scipy/linalg/SConstruct =================================================================== --- branches/refactor_fft/scipy/linalg/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/linalg/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,159 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 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 numscons import get_python_inc#, get_pythonlib_dir -from numscons import GetNumpyEnvironment -from numscons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ - CheckCLAPACK, IsVeclib, IsAccelerate, \ - IsATLAS, GetATLASVersion, CheckF77Clib -from numscons import write_info - -from scons_support import do_generate_interface, do_generate_fake_interface, \ - generate_interface_emitter - -#from scons_support import CheckBrokenMathlib, define_no_smp, \ -# generate_config_header, generate_config_header_emitter - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') -env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) - -# XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -env.AppendUnique(F2PYOPTIONS = '--quiet') - -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) - -#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()]) - -fenv = env.Clone() - -#======================= -# Starting Configuration -#======================= -config = env.Configure(custom_tests = {'CheckCBLAS' : CheckCBLAS, - 'CheckCLAPACK' : CheckCLAPACK}) - -#------------------------- -# Checking cblas/clapack -#------------------------- -if config.CheckCBLAS(): - has_cblas = 1 -else: - has_cblas = 0 -if has_cblas: - if IsATLAS(env, 'cblas'): - version = GetATLASVersion(env) - 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) - -#--------------------------- -# Checking F77 blas/lapack -#--------------------------- -fconfig = fenv.Configure(custom_tests = {'CheckBLAS' : CheckF77BLAS, - 'CheckLAPACK' : CheckF77LAPACK, - 'CheckF77Clib' : CheckF77Clib}) - -if not fconfig.CheckF77Clib(): - raise RuntimeError("Could not check F/C runtime library for %s/%s, " \ - "contact the maintainer" % (fenv['CC'], fenv['F77'])) - -st = fconfig.CheckBLAS(check_version = 1) -if not st: - raise RuntimeError("no blas found, necessary for linalg module") -if IsATLAS(fenv, 'blas'): - version = GetATLASVersion(fenv) - env.Append(CPPDEFINES = [('ATLAS_INFO', '"\\"%s"\\"' % version)]) -else: - env.Append(CPPDEFINES = [('NO_ATLAS_INFO', 1)]) - -st = fconfig.CheckLAPACK() -if not st: - raise RuntimeError("no lapack found, necessary for linalg module") -fconfig.Finish() -write_info(fenv) - - -#========== -# Build -#========== -#------------ -# fblas -#------------ -fenv.haha('fblas', 'generic_fblas.pyf') -source = ['fblas.pyf'] -if IsVeclib(fenv, 'blas') or IsAccelerate(fenv, 'blas'): - source.append(pjoin('src', 'fblaswrap_veclib_c.c')) -else: - source.append(pjoin('src', 'fblaswrap.f')) -fenv.NumpyPythonExtension('fblas', source) - -#------------ -# cblas -#------------ -if has_cblas: - env.haha('cblas', 'generic_cblas.pyf') -else: - env.hihi('cblas', 'generic_cblas.pyf') -env.NumpyPythonExtension('cblas', source = 'cblas.pyf') - -#------------ -# flapack -#------------ -yop = fenv.haha('flapack', 'generic_flapack.pyf') -# XXX: automatically scan dependency on flapack_user_routines.pyf ? -fenv.Depends(yop, pjoin(env['build_dir'], 'flapack_user_routines.pyf')) -fenv.NumpyPythonExtension('flapack', 'flapack.pyf') - -#------------ -# 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 = [pjoin('src', i) for i in ['det.f', 'lu.f']] -flinalg_src = fenv.NumpyF2py(pjoin('src', '_flinalgmodule.c'), flinalg_fsrc) - -fenv.NumpyPythonExtension('_flinalg', source = flinalg_src + flinalg_fsrc) - -#---------------- -# calc_lwork: -#---------------- -calc_fsrc = [pjoin('src', 'calc_lwork.f')] -calc_src = env.NumpyF2py(pjoin('src', 'calc_lworkmodule.c'), calc_fsrc) -fenv.NumpyPythonExtension('calc_lwork', calc_src + calc_fsrc) - -#-------------- -# Atlas version -#-------------- -atlas_env = env.Clone() -if not IsATLAS(env, 'cblas'): - atlas_env.AppendUnique(CPPDEFINES = "NO_ATLAS_INFO") -atlas_env.NumpyPythonExtension('atlas_version', 'atlas_version.c') Copied: branches/refactor_fft/scipy/linalg/SConstruct (from rev 4510, trunk/scipy/linalg/SConstruct) Modified: branches/refactor_fft/scipy/linalg/scons_support.py =================================================================== --- branches/refactor_fft/scipy/linalg/scons_support.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/linalg/scons_support.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -14,8 +14,6 @@ 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) Copied: branches/refactor_fft/scipy/ndimage/SConscript (from rev 4510, trunk/scipy/ndimage/SConscript) Deleted: branches/refactor_fft/scipy/ndimage/SConstruct =================================================================== --- branches/refactor_fft/scipy/ndimage/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/ndimage/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,22 +0,0 @@ -# Last Change: Wed Mar 05 09:00 PM 2008 J -from os.path import join - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment - -env = GetNumpyEnvironment(ARGUMENTS) - -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.AppendUnique(CPPPATH = 'src') - -ndimage_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 ndimage_src]) - -segment_src = ['Segmenter_EXT.c', 'Segmenter_IMPL.c'] -env.NumpyPythonExtension('_segment', source = [join('src', 'segment', i) - for i in segment_src]) - -register_src = ['Register_EXT.c', 'Register_IMPL.c'] -env.NumpyPythonExtension('_register', source = [join('src', 'register', i) - for i in register_src]) Copied: branches/refactor_fft/scipy/ndimage/SConstruct (from rev 4510, trunk/scipy/ndimage/SConstruct) Modified: branches/refactor_fft/scipy/ndimage/_registration.py =================================================================== --- branches/refactor_fft/scipy/ndimage/_registration.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/ndimage/_registration.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,10 +1,17 @@ +# +# written by Tom Waite +# rigid body 3D registration +# + + import math -import os -import numpy as NP -import scipy.ndimage._register as R -import scipy.special as SP -import scipy.ndimage as NDI -import scipy.optimize as OPT +import numpy as np +from scipy.special import erf +from scipy.ndimage import correlate1d +from scipy.optimize import fmin_powell, fmin_cg + +import scipy.ndimage._register as reg + import time import glob @@ -29,71 +36,60 @@ # ---- co-registration and IO ---- # -def resize_image(imageG, imageF_mat): +def resize_image(imageS, imageS_mat, imageR_mat): """ - zoom_image = resize_image(source_image, reference_image[mat]) + zoom_image = resize_image(imageS, imageS_mat, imageR_mat) - Fractional resample source_image to reference_imagesize. The - resample is implemented with 3D cubic spline. The reference - image [mat] is the 4x4 voxel-to-physical conversion matrix. + Fractional resample source_image to reference_image size. The + resample is implemented with 3D cubic spline. The source + imageS_mat is the 4x4 voxel-to-physical conversion matrix. Parameters ---------- - imageG : {dictionary} - imageG is the source image to be resized. it is a dictionary with - the data as an ndarray in the ['data'] component. + imageS: {ndarray} + imageS is the source image to be resized. - reference_image[mat] : {ndarray} - refernce_image is the image whose sampling dimensions the source - image is to be remapped to. [mat] refers to the component - of the image dictionary, reference_image['mat'] that is the - sampling dimensions. + imageS_mat : {ndarray} + the 4x4 transform of the source image that maps voxel to physical. + imageR_mat : {ndarray} + the 4x4 transform of the destination image that maps voxel to physical. + Returns ------- - zoom_image : {dictionary} + zoom_image : {ndarray} Examples -------- >>> import _registration as reg - >>> measures, imageF_anat, fmri_series = reg.demo_MRI_coregistration() + >>> measures, image_anat, image_anat_mat, image_fmri_mat, fmri_series = reg.demo_MRI_coregistration() - >>> resampled_fmri = reg.resize_image(fmri_series[10], imageF_anat['mat']) + >>> resampled_fmri = reg.resize_image(fmri_series[10], image_fmri_mat, image_anat_mat) - image 10 in the fmri_series is resampled to imageF_anat coordinates + image 10 in the fmri_series is resampled from image_fmri_mat to image_anat coordinates """ - Z = NP.zeros(3, dtype=NP.float64); # get the zoom - Z[0] = imageG['mat'][0][0] / imageF_mat[0][0] - Z[1] = imageG['mat'][1][1] / imageF_mat[1][1] - Z[2] = imageG['mat'][2][2] / imageF_mat[2][2] + Z = imageS_mat.diagonal() / imageR_mat.diagonal() - # new volume dimensions (rounded) - D = NP.zeros(3, dtype=NP.int32); - D[0] = int(float(imageG['dim'][0])*Z[0]+0.5) - D[1] = int(float(imageG['dim'][1])*Z[1]+0.5) - D[2] = int(float(imageG['dim'][2])*Z[2]+0.5) + # new volume dimensions (rounded). D, imageS and Z are 3D and this is a vector element product + D = (imageS.shape * Z + 0.5).astype(np.int16) - M = NP.eye(4, dtype=NP.float64); - # for the test data, set the xyz voxel sizes for fMRI volume - M[0][0] = imageG['mat'][0][0]/Z[0] - M[1][1] = imageG['mat'][1][1]/Z[1] - M[2][2] = imageG['mat'][2][2]/Z[2] + # for the test data, set the xyz voxel sizes for fMRI volume. M is a 4x4 matrix. + M = np.diag(imageS_mat.diagonal() / Z) - image = NP.zeros(D[2]*D[1]*D[0], dtype=NP.uint8).reshape(D[2], D[0], D[1]) + image = np.zeros((D[2],D[1],D[0]),np.uint8) + mode = 2 scale = 0 - R.register_volume_resample(imageG['data'], image, Z, scale, mode) - F = NP.zeros(3, dtype=NP.float64); - zoom_image = {'data' : image, 'mat' : M, 'dim' : D, 'fwhm' : F} + reg.register_volume_resample(imageS, image, Z, scale, mode) - return zoom_image + return image, M -def remap_image(image, parm_vector, resample='linear'): +def remap_image(image, M_inverse, resample='linear'): """ remaped_image = remap_image(image, parm_vector, resample='linear') @@ -103,51 +99,44 @@ Parameters ---------- - image : {dictionary} - image is the source image to be remapped. it is a dictionary with - the data as an ndarray in the ['data'] component. + image : {ndarray} + image is the source image to be remapped. - parm_vector : {ndarray} - parm_vector is the 6-dimensional vector (3 angles, 3 translations) - generated from the registration. + M_inverse : {ndarray} + M_inverse is the 4x4 inverse affine matrix resample : {'linear', 'cubic'}, optional Returns ------- - remaped_image : {dictionary} + remaped_image : {ndarray} Examples -------- image = fmri_series[i] x[0:6] = measures[i]['align_rotate'][0:6] + M = get_inverse_mappings(x) # overwrite the fMRI volume with the aligned volume - fmri_series[i] = remap_image(image, x, resample='cubic') + fmri_series[i] = remap_image(image, M, resample='cubic') """ - # - # remap imageG to coordinates of imageF (creates imageG') - # use the 6 dim parm_vector (3 angles, 3 translations) to remap - # - M_inverse = get_inverse_mappings(parm_vector) - (layers, rows, cols) = image['data'].shape # allocate the zero image - remaped_image = NP.zeros(layers*rows*cols, dtype=NP.uint8).reshape(layers, rows, cols) - remaped_image = {'data' : remaped_image, 'mat' : image['mat'], - 'dim' : image['dim'], 'fwhm' : image['fwhm']} - imdata = build_structs() + remaped_image = np.zeros(image.shape, dtype=np.uint8) + step = np.array([1, 1, 1], dtype=np.int32) + if resample == 'linear': # trilinear interpolation mapping. - R.register_linear_resample(image['data'], remaped_image['data'], M_inverse, imdata['step']) + reg.register_linear_resample(image, remaped_image, M_inverse, step) elif resample == 'cubic': # tricubic convolve interpolation mapping. - R.register_cubic_resample(image['data'], remaped_image['data'], M_inverse, imdata['step']) + reg.register_cubic_resample(image, remaped_image, M_inverse, step) return remaped_image + def get_inverse_mappings(parm_vector): """ M_inverse = get_inverse_mappings(parm_vector) @@ -168,7 +157,7 @@ >>> import numpy as NP >>> import _registration as reg - >>> array = NP.zeros(6, dtype=float) + >>> array = np.zeros(6, dtype=float) >>> M = reg.get_inverse_mappings(array) >>> M @@ -180,55 +169,53 @@ """ # get the inverse mapping to rotate the G matrix to F space following registration - imdata = build_structs() - # inverse angles and translations - imdata['parms'][0] = -parm_vector[0] - imdata['parms'][1] = -parm_vector[1] - imdata['parms'][2] = -parm_vector[2] - imdata['parms'][3] = -parm_vector[3] - imdata['parms'][4] = -parm_vector[4] - imdata['parms'][5] = -parm_vector[5] - M_inverse = build_rotate_matrix(imdata['parms']) + # -parm_vector is the inverse angles and translations + M_inverse = build_rotate_matrix(-parm_vector) return M_inverse -def python_coreg(image1, image2, imdata, ftype=1, smimage=0, lite=0, smhist=0, - method='nmi', opt_method='powell'): +def register(image1, image1_mat, image2, image2_mat, multires=[4, 2], histo_fwhm=3, + ftype=1, lite=0, smhist=0, method='nmi', opt_method='hybrid', + optimize_function=None): + """ - parm_vector = python_coreg(image1, image2, imdata, ftype=1, smimage=0, lite=0, - smhist=0, method='nmi', opt_method='powell'): + parm_vector = register(image1, image1_mat, image2, image2_mat, multires=[4, 2], histo_fwhm=3, + ftype=1, lite=0, smhist=0, method='nmi', opt_method='powell'): - takes two images and the image data descriptor (imdata) and determines the optimal alignment of the two images (measured by mutual information or cross correlation) using optimization search of 3 angle and 3 translation parameters. The optimization uses either the Powell or Conjugate Gradient methods in the scipy optimization - package. The optimal parameter is returned. + package. The optimal rigid body parameter is returned. Parameters ---------- - image1 : {dictionary} + image1 : {nd_array} image1 is the source image to be remapped during the registration. - it is a dictionary with the data as an ndarray in the ['data'] component. - image2 : {dictionary} + image1_mat : {nd_array} + image1_mat is the source image MAT + image2 : {nd_array} image2 is the reference image that image1 gets mapped to. - imdata : {dictionary} - image sampling and optimization information. + image2_mat : {nd_array} + image2_mat is the source image MAT + multires: {list}, optional + the volume subsample values for each pass of the registration. + the default is 2 passes with subsample 4 in pass 1 and subsample 2 in pass 2 + histo_fwhm : {int}, optional + used for the filter kernel in the low pass filter of the joint histogram ftype : {0, 1}, optional flag for type of low pass filter. 0 is Gauss-Spline 1 is pure Gauss. Sigma determined from volume sampling info. - smimage : {0, 1}, optional - flag for volume 3D low pass filtering of image 2. - 0 for no filter, 1 for do filter. lite : {0, 1}, optional lite of 1 is to jitter both images during resampling. 0 is to not jitter. jittering is for non-aliased volumes. smhist: {0, 1}, optional flag for joint histogram low pass filtering. 0 for no filter, 1 for do filter. - method: {'nmi', 'mi', 'ncc', 'ecc'}, optional + method: {'nmi', 'mi', 'ncc', 'ecc', 'mse'}, optional flag for type of registration metric. nmi is normalized mutual information; mi is mutual information; ecc is entropy cross - correlation; ncc is normalized cross correlation. - opt_method: {'powell', 'hybrid'}, optional + correlation; ncc is normalized cross correlation. mse is mean + squared error. + opt_method: {'powell', 'cg', 'hybrid'}, optional registration is two pass. Pass 1 is low res to get close to alignment and pass 2 starts at the pass 1 optimal alignment. In powell pass 1 and 2 are powell, in hybrid pass 2 is conjugate gradient. @@ -246,107 +233,169 @@ >>> import numpy as NP >>> import _registration as reg - >>> image1, image2, imdata = reg.demo_MRI_volume_align() - >>> parm_vector = python_coreg(image1, image2, imdata) + >>> image1, image2, fwhm, improc = reg.demo_build_dual_volumes() + >>> parm_vector = register(image1, image2, fwhm, improc) """ - start = time.time() - # smooth of the images - if smimage: - image_F_xyz2 = filter_image_3D(image2['data'], image2['fwhm'], ftype) - image2['data'] = image_F_xyz2 - parm_vector = multires_registration(image1, image2, imdata, lite, smhist, method, opt_method) - stop = time.time() - print 'Total Optimizer Time is ', (stop-start) + + # do the parameter validity checking. this is specific to this 3D registration. + # make sure the image is 3D and the mats are 4x4 with nonzero diagonal + + if image1.ndim != 3: + raise ValueError, "Image 1 is not 3 dimensional" + + if image2.ndim != 3: + raise ValueError, "Image 2 is not 3 dimensional" + + if image1.dtype != np.uint8: + raise ValueError, "Image 1 is not 8 bit (required for joint histogram)" + + if image2.dtype != np.uint8: + raise ValueError, "Image 2 is not 8 bit (required for joint histogram)" + + if image1_mat.shape != (4,4): + raise ValueError, "Image1 MAT is not 4x4" + + if image2_mat.shape != (4,4): + raise ValueError, "Image2 MAT is not 4x4" + + if (np.diag(image1_mat)).prod() == 0: + raise ValueError, "Image1 MAT has a 0 on the diagonal" + + if (np.diag(image2_mat)).prod() == 0: + raise ValueError, "Image2 MAT has a 0 on the diagonal" + + if opt_method=='hybrid' and np.size(multires) != 2: + raise ValueError, "hybrid method must be 2 pass registration" + + if ftype != 0 and ftype != 1: + raise ValueError, "choose filter type 0 or 1 only" + + if lite != 0 and lite != 1: + raise ValueError, "choose histogram generation type 0 or 1 only" + + if smhist != 0 and smhist != 1: + raise ValueError, "choose histogram smoothing type 0 or 1 only" + + if method != 'nmi' and method != 'mi' and method != 'ncc'\ + and method != 'ecc' and method != 'mse': + raise ValueError, "choose cost method nmi, mi, ecc, mse, ncc" + + if opt_method != 'powell' and opt_method != 'cg' and opt_method != 'hybrid': + raise ValueError, "only optimize methods powell, cg or hybrid are supported" + + # default is to use the cost_function I provided. + # this shows you can override this but the parameters will have to + # be changed for the new cost function if it is different + + if optimize_function == None: + optimize_function = cost_function + + parm_vector = multires_registration(optimize_function, image1, image1_mat, image2, image2_mat, + multires, histo_fwhm, lite, smhist, method, opt_method) + return parm_vector -def multires_registration(image1, image2, imdata, lite, smhist, method, opt_method): +def multires_registration(optimize_function, image1, image1_mat, image2, image2_mat, + multires, histo_fwhm, lite, smhist, method, opt_method): + """ - x = multires_registration(image1, image2, imdata, lite, smhist, method, opt_method) - to be called by python_coreg() which optionally does 3D image filtering and - provies timing for registration. + to be called by register() which does parameter validation Parameters ---------- - - image1 : {dictionary} + image1 : {nd_array} image1 is the source image to be remapped during the registration. - it is a dictionary with the data as an ndarray in the ['data'] component. - image2 : {dictionary} + image1_mat : {nd_array} + image1_mat is the source image MAT + image2 : {nd_array} image2 is the reference image that image1 gets mapped to. - imdata : {dictionary} - image sampling and optimization information. - lite : {integer} + image2_mat : {nd_array} + image2_mat is the source image MAT + multires: {list}, optional + the volume subsample values for each pass of the registration. + the default is 2 passes with subsample 4 in pass 1 and subsample 2 in pass 2 + histo_fwhm : {int}, optional + used for the filter kernel in the low pass filter of the joint histogram + ftype : {0, 1}, optional + flag for type of low pass filter. 0 is Gauss-Spline + 1 is pure Gauss. Sigma determined from volume sampling info. + lite : {0, 1}, optional lite of 1 is to jitter both images during resampling. 0 is to not jitter. jittering is for non-aliased volumes. - smhist: {integer} + smhist: {0, 1}, optional flag for joint histogram low pass filtering. 0 for no filter, 1 for do filter. - method: {'nmi', 'mi', 'ncc', 'ecc'} + method: {'nmi', 'mi', 'ncc', 'ecc', 'mse'}, optional flag for type of registration metric. nmi is normalized mutual information; mi is mutual information; ecc is entropy cross - correlation; ncc is normalized cross correlation. - opt_method: {'powell', 'hybrid'} + correlation; ncc is normalized cross correlation. mse is mean + squared error. + opt_method: {'powell', 'cg', 'hybrid'}, optional registration is two pass. Pass 1 is low res to get close to alignment and pass 2 starts at the pass 1 optimal alignment. In powell pass 1 and 2 are powell, in hybrid pass 2 is conjugate gradient. + Returns ------- - x : {nd_array} + parm_vector : {nd_array} this is the optimal alignment (6-dim) array with 3 angles and 3 translations. Examples -------- - (calling this from python_coreg which optionally filters image2) + (calling this from register which optionally filters image2) >>> import numpy as NP >>> import _registration as reg - >>> image1, image2, imdata = reg.demo_MRI_volume_align() - >>> parm_vector = python_coreg(image1, image2, imdata) + >>> image1, mat1, image2, mat2 = reg.demo_build_dual_volumes() + >>> parm_vector = register(image1, image2, imdata) """ ret_histo=0 - # zero out the start parameter; but this may be set to large values - # if the head is out of range and well off the optimal alignment skirt - imdata['parms'][0:5] = 0.0 + step = np.array([1, 1, 1], dtype=np.int32) + fwhm = np.zeros(2, dtype=np.int32) # make the step a scalar to can put in a multi-res loop - loop = range(imdata['sample'].size) - x = imdata['parms'] + loop = range(np.size(multires)) + # 6-D zero vector + x = np.zeros(6, dtype=np.float64); + # the kernel fwhm value for the x and y joint histogram filter + fwhm[:] = histo_fwhm for i in loop: - step = imdata['sample'][i] - imdata['step'][:] = step - optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, - method, ret_histo) + # this is the volume subsample + step[:] = multires[i] + # optfunc_args is specific to the cost_function in this file + # this will need to change if you use another optimize_function. + optfunc_args = (image1, image1_mat, image2, image2_mat, step, histo_fwhm, + lite, smhist, method, ret_histo) p_args = (optfunc_args,) if opt_method=='powell': print 'POWELL multi-res registration step size ', step print 'vector ', x - x = OPT.fmin_powell(optimize_function, x, args=p_args, - callback=callback_powell) + x = fmin_powell(optimize_function, x, args=p_args, callback=callback_powell) elif opt_method=='cg': print 'CG multi-res registration step size ', step print 'vector ', x - x = OPT.fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) + x = fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) elif opt_method=='hybrid': if i==0: print 'Hybrid POWELL multi-res registration step size ', step print 'vector ', x lite = 0 - optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, - method, ret_histo) + optfunc_args = (image1, image1_mat, image2, image2_mat, step, histo_fwhm, + lite, smhist, method, ret_histo) p_args = (optfunc_args,) - x = OPT.fmin_powell(optimize_function, x, args=p_args, callback=callback_powell) + x = fmin_powell(optimize_function, x, args=p_args, callback=callback_powell) elif i==1: print 'Hybrid CG multi-res registration step size ', step print 'vector ', x lite = 1 - optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, - smhist, method, ret_histo) + optfunc_args = (image1, image1_mat, image2, image2_mat, step, histo_fwhm, + lite, smhist, method, ret_histo) p_args = (optfunc_args,) - x = OPT.fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) + x = fmin_cg(optimize_function, x, args=p_args, callback=callback_cg) return x @@ -367,7 +416,7 @@ print x return -def smooth_kernel(fwhm, x, ktype=1): +def smooth_kernel(fwhm, x, pixel_scale=8.0, ktype=1): """ kernel = smooth_kernel(fwhm, x, ktype=1) @@ -395,8 +444,8 @@ >>> import _registration as reg >>> fwhm = 3 >>> ftype = 2 - >>> p = NP.ceil(2*fwhm).astype(int) - >>> x = NP.array(range(-p, p+1)) + >>> p = np.ceil(2*fwhm).astype(int) + >>> x = np.array(range(-p, p+1)) >>> kernel = reg.smooth_kernel(fwhm, x, ktype=ftype) >>> kernel @@ -409,24 +458,26 @@ """ eps = 0.00001 - s = NP.square((fwhm/math.sqrt(8.0*math.log(2.0)))) + eps + s = np.square((fwhm/math.sqrt(pixel_scale*math.log(2.0)))) + eps if ktype==1: # from SPM: Gauss kernel convolved with 1st degree B spline w1 = 0.5 * math.sqrt(2.0/s) w2 = -0.5 / s w3 = math.sqrt((s*math.pi) /2.0) - kernel = 0.5*(SP.erf(w1*(x+1))*(x+1) + SP.erf(w1*(x-1))*(x-1) - 2.0*SP.erf(w1*(x))*(x) + - w3*(NP.exp(w2*NP.square(x+1))) + NP.exp(w2*(NP.square(x-1))) - 2.0*NP.exp(w2*NP.square(x))) + kernel = 0.5*(erf(w1*(x+1))*(x+1) + erf(w1*(x-1))*(x-1) + - 2.0*erf(w1*(x))*(x) + w3*(np.exp(w2*np.square(x+1))) + + np.exp(w2*(np.square(x-1))) + - 2.0*np.exp(w2*np.square(x))) kernel[kernel<0] = 0 kernel = kernel / kernel.sum() else: # Gauss kernel - kernel = (1.0/math.sqrt(2.0*math.pi*s)) * NP.exp(-NP.square(x)/(2.0*s)) + kernel = (1.0/math.sqrt(2.0*math.pi*s)) * np.exp(-np.square(x)/(2.0*s)) kernel = kernel / kernel.sum() return kernel -def filter_image_3D(imageRaw, fwhm, ftype=2): +def filter_image_3D(imageRaw, fwhm, ftype=2, give_2D=0): """ image_F_xyz = filter_image_3D(imageRaw, fwhm, ftype=2): does 3D separable digital filtering using scipy.ndimage.correlate1d @@ -436,9 +487,9 @@ imageRaw : {nd_array} the unfiltered 3D volume image fwhm : {int} - used for kernel width + used for kernel width. this is 3 elements (one for each dimension) ktype: {1, 2}, optional - kernel type. 1 is Gauss convoled with spline, 2 is Gauss + kernel type. 1 is Gauss convoled with spline (SPM), 2 is Gauss Returns ------- @@ -449,31 +500,39 @@ -------- >>> import _registration as reg - >>> image1, image2, imdata = reg.demo_MRI_volume_align() + >>> image1, image2, imdata = reg.demo_build_dual_volumes() >>> ftype = 1 - >>> image_Filter_xyz = filter_image_3D(image1['data'], image1['fwhm'], ftype) + >>> image_Filter_xyz = filter_image_3D(image, fwhm, ftype) >>> image1['data'] = image_Filter_xyz """ - p = NP.ceil(2*fwhm[0]).astype(int) - x = NP.array(range(-p, p+1)) + p = np.ceil(2*fwhm).astype(int) + x = np.array(range(-p[0], p[0]+1)) kernel_x = smooth_kernel(fwhm[0], x, ktype=ftype) - p = NP.ceil(2*fwhm[1]).astype(int) - x = NP.array(range(-p, p+1)) + + x = np.array(range(-p[1], p[1]+1)) kernel_y = smooth_kernel(fwhm[1], x, ktype=ftype) - p = NP.ceil(2*fwhm[2]).astype(int) - x = NP.array(range(-p, p+1)) + + x = np.array(range(-p[2], p[2]+1)) kernel_z = smooth_kernel(fwhm[2], x, ktype=ftype) + output=None - # 3D filter in 3 1D separable stages + # 3D filter in 3 1D separable stages. keep the image + # names at each stage separate in case you need them + # for example may need an image that is 2D slice filtered only axis = 0 - image_F_x = NDI.correlate1d(imageRaw, kernel_x, axis, output) + image_F_x = correlate1d(imageRaw, kernel_x, axis, output) axis = 1 - image_F_xy = NDI.correlate1d(image_F_x, kernel_y, axis, output) + image_F_xy = correlate1d(image_F_x, kernel_y, axis, output) axis = 2 - image_F_xyz = NDI.correlate1d(image_F_xy, kernel_z, axis, output) - return image_F_xyz + image_F_xyz = correlate1d(image_F_xy, kernel_z, axis, output) + if give_2D==0: + return image_F_xyz + else: + return image_F_xyz, image_F_xy + + def build_fwhm(M, S): """ fwhm = build_fwhm(M, S) @@ -500,28 +559,28 @@ >>> import _registration as reg >>> anat_desc = reg.load_anatMRI_desc() >>> image1 = reg.load_volume(anat_desc, imagename='ANAT1_V0001.img') - >>> imdata = reg.build_structs() >>> image1['fwhm'] = reg.build_fwhm(image1['mat'], imdata['step']) """ - view_3x3 = NP.square(M[0:3, 0:3]) - # sum the elements inn the first row - vxg = NP.sqrt(view_3x3.sum(axis=0)) - # assumes that sampling is the same for xyz - size = NP.array([1,1,1])*S[0] - x = NP.square(size) - NP.square(vxg) + # M contains the voxel to physical mapping + view_3x3 = np.square(M[0:3, 0:3]) + # sum the elements in the first row + vxg = np.sqrt(view_3x3.sum(axis=1)) + # assumes that voxel sampling is the same for xyz as S is the step + size = np.array([1,1,1])*S[0] + x = np.square(size) - np.square(vxg) # clip x[x<0] = 0 - fwhm = NP.sqrt(x) / vxg + fwhm = np.sqrt(x) / vxg # pathology when stepsize = 1 for MAT equal to the identity matrix fwhm[fwhm==0] = 1 # return the 3D Gaussian kernel width (xyz) return fwhm -def optimize_function(x, optfunc_args): +def cost_function(x, optfunc_args): """ - cost = optimize_function(x, optfunc_args) --- OR --- - cost, joint_histogram = optimize_function(x, optfunc_args) + cost = cost_function(x, optfunc_args) --- OR --- + cost, joint_histogram = cost_function(x, optfunc_args) computes the alignment between 2 volumes using cross correlation or mutual information metrics. In both the 8 bit joint histogram of the 2 images is @@ -588,7 +647,6 @@ >>> anat_desc = reg.load_anatMRI_desc() >>> image1 = reg.load_volume(anat_desc, imagename='ANAT1_V0001.img') >>> image2 = reg.load_volume(anat_desc, imagename='ANAT1_V0001.img') - >>> imdata = reg.build_structs() >>> image1['fwhm'] = reg.build_fwhm(image1['mat'], imdata['step']) >>> image2['fwhm'] = reg.build_fwhm(image2['mat'], imdata['step']) >>> method = 'ncc' @@ -596,46 +654,47 @@ >>> smhist = 0 >>> ret_histo = 1 >>> optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, method, ret_histo) - >>> x = NP.zeros(6, dtype=NP.float64) - >>> return cost, joint_histogram = reg.optimize_function(x, optfunc_args) + >>> x = np.zeros(6, dtype=np.float64) + >>> return cost, joint_histogram = reg.cost_function(x, optfunc_args) """ image_F = optfunc_args[0] - image_G = optfunc_args[1] - sample_vector = optfunc_args[2] - fwhm = optfunc_args[3] - do_lite = optfunc_args[4] - smooth = optfunc_args[5] - method = optfunc_args[6] - ret_histo = optfunc_args[7] + image_F_mat = optfunc_args[1] + image_G = optfunc_args[2] + image_G_mat = optfunc_args[3] + sample_vector = optfunc_args[4] + fwhm = optfunc_args[5] + do_lite = optfunc_args[6] + smooth = optfunc_args[7] + method = optfunc_args[8] + ret_histo = optfunc_args[9] rot_matrix = build_rotate_matrix(x) cost = 0.0 epsilon = 2.2e-16 # image_G is base image # image_F is the to-be-rotated image - # rot_matrix is the 4x4 constructed (current angles and translates) transform matrix + # rot_matrix is the 4x4 constructed (rigid body) transform matrix # sample_vector is the subsample vector for x-y-z - F_inv = NP.linalg.inv(image_F['mat']) - composite = NP.dot(F_inv, image_G['mat']) - composite = NP.dot(composite, rot_matrix) + F_inv = np.linalg.inv(image_F_mat) + composite = np.dot(F_inv, image_G_mat) + composite = np.dot(composite, rot_matrix) if method == 'mse': # # mean squard error method # - (layers, rows, cols) = image_F['data'].shape # allocate the zero image - remap_image_F = NP.zeros(layers*rows*cols, dtype=NP.uint8).reshape(layers, rows, cols) - imdata = build_structs() + #(layers, rows, cols) = image_F.shape + remap_image_F = np.zeros(image_F.shape, dtype=np.uint8) # trilinear interpolation mapping. - R.register_linear_resample(image_F['data'], remap_image_F, composite, - imdata['step']) - cost = (NP.square(image_G['data']-remap_image_F)).mean() + reg.register_linear_resample(image_F, remap_image_F, composite, sample_vector) + cost = (np.square(image_G-remap_image_F)).mean() + # cost is min when G and F are aligned so keep cost positive return cost @@ -645,29 +704,25 @@ # # allocate memory for 2D histogram - joint_histogram = NP.zeros([256, 256], dtype=NP.float64); + joint_histogram = np.zeros([256, 256], dtype=np.float64) if do_lite: - R.register_histogram_lite(image_F['data'], image_G['data'], composite, - sample_vector, joint_histogram) + reg.register_histogram_lite(image_F, image_G, composite, sample_vector, joint_histogram) else: - R.register_histogram(image_F['data'], image_G['data'], composite, - sample_vector, joint_histogram) + reg.register_histogram(image_F, image_G, composite, sample_vector, joint_histogram) # smooth the histogram if smooth: - p = NP.ceil(2*fwhm[0]).astype(int) - x = NP.array(range(-p, p+1)) - kernel1 = smooth_kernel(fwhm[0], x) - p = NP.ceil(2*fwhm[1]).astype(int) - x = NP.array(range(-p, p+1)) - kernel2 = smooth_kernel(fwhm[1], x) + p = np.ceil(2*fwhm).astype(int) + x = np.array(range(-p, p+1)) + hkernel = smooth_kernel(fwhm, x) output=None - # 2D filter in 1D separable stages + # 2D filter in 1D separable stages using the same kernel. SPM + # has options for a 2D fwhm kernel yet only uses 1 element axis = 0 - result = NDI.correlate1d(joint_histogram, kernel1, axis, output) + joint_histogram = correlate1d(joint_histogram, hkernel, axis, output) axis = 1 - joint_histogram = NDI.correlate1d(result, kernel1, axis, output) + joint_histogram = correlate1d(joint_histogram, hkernel, axis, output) joint_histogram += epsilon # prevent log(0) # normalize the joint histogram @@ -678,44 +733,44 @@ if method == 'mi': # mutual information - marginal_outer = NP.outer(marginal_col, marginal_row) - H = joint_histogram * NP.log(joint_histogram / marginal_outer) + marginal_outer = np.outer(marginal_col, marginal_row) + H = joint_histogram * np.log(joint_histogram / marginal_outer) mutual_information = H.sum() cost = -mutual_information elif method == 'ecc': # entropy correlation coefficient - marginal_outer = NP.outer(marginal_col, marginal_row) - H = joint_histogram * NP.log(joint_histogram / marginal_outer) + marginal_outer = np.outer(marginal_col, marginal_row) + H = joint_histogram * np.log(joint_histogram / marginal_outer) mutual_information = H.sum() - row_entropy = marginal_row * NP.log(marginal_row) - col_entropy = marginal_col * NP.log(marginal_col) + row_entropy = marginal_row * np.log(marginal_row) + col_entropy = marginal_col * np.log(marginal_col) ecc = -2.0*mutual_information/(row_entropy.sum() + col_entropy.sum()) cost = -ecc elif method == 'nmi': # normalized mutual information - row_entropy = marginal_row * NP.log(marginal_row) - col_entropy = marginal_col * NP.log(marginal_col) - H = joint_histogram * NP.log(joint_histogram) - nmi = (row_entropy.sum() + col_entropy.sum()) / (H.sum()) + row_entropy = marginal_row * np.log(marginal_row) + col_entropy = marginal_col * np.log(marginal_col) + H = joint_histogram * np.log(joint_histogram) + nmi = (row_entropy.sum() + col_entropy.sum()) / (H.sum()) cost = -nmi elif method == 'ncc': # cross correlation from the joint histogram r, c = joint_histogram.shape - i = NP.array(range(1,c+1)) - j = NP.array(range(1,r+1)) + i = np.array(range(1,c+1)) + j = np.array(range(1,r+1)) m1 = (marginal_row * i).sum() m2 = (marginal_col * j).sum() - sig1 = NP.sqrt((marginal_row*(NP.square(i-m1))).sum()) - sig2 = NP.sqrt((marginal_col*(NP.square(j-m2))).sum()) - [a, b] = NP.mgrid[1:c+1, 1:r+1] + sig1 = np.sqrt((marginal_row*(np.square(i-m1))).sum()) + sig2 = np.sqrt((marginal_col*(np.square(j-m2))).sum()) + [a, b] = np.mgrid[1:c+1, 1:r+1] a = a - m1 b = b - m2 # element multiplies in the joint histogram and grids H = ((joint_histogram * a) * b).sum() - ncc = H / (NP.dot(sig1, sig2)) + ncc = H / (np.dot(sig1, sig2)) cost = -ncc if ret_histo: @@ -724,64 +779,6 @@ return cost -def build_structs(step=1): - """ - img_data = build_structs(step=1) - - builds the image data (imdata) dictionary for later use as parameter - storage in the co-registration. - - Parameters - ---------- - step : {int} : optional - default is 1 and is the sample increment in voxels. This sets the sample - for x,y,z and is the same value in all 3 axes. only change the default for debug. - - Returns - ------- - img_data : {dictionary} - - Examples - -------- - - >>> import numpy as NP - >>> import _registration as reg - >>> imdata = reg.build_structs() - - """ - - # build image data structures here - P = NP.zeros(6, dtype=NP.float64); - T = NP.zeros(6, dtype=NP.float64); - F = NP.zeros(2, dtype=NP.int32); - S = NP.ones(3, dtype=NP.int32); - sample = NP.zeros(2, dtype=NP.int32); - S[0] = step - S[1] = step - S[2] = step - # image/histogram smoothing - F[0] = 3 - F[1] = 3 - # subsample for multiresolution registration - sample[0] = 4 - sample[1] = 2 - # tolerances for angle (0-2) and translation (3-5) - T[0] = 0.02 - T[1] = 0.02 - T[2] = 0.02 - T[3] = 0.001 - T[4] = 0.001 - T[5] = 0.001 - # P[0] = alpha <=> pitch. + alpha is moving back in the sagittal plane - # P[1] = beta <=> roll. + beta is moving right in the coronal plane - # P[2] = gamma <=> yaw. + gamma is right turn in the transverse plane - # P[3] = Tx - # P[4] = Ty - # P[5] = Tz - img_data = {'parms' : P, 'step' : S, 'fwhm' : F, 'tol' : T, 'sample' : sample} - return img_data - - def build_rotate_matrix(img_data_parms): """ rot_matrix = reg.build_rotate_matrix(img_data_parms) @@ -803,8 +800,7 @@ >>> import numpy as NP >>> import _registration as reg - >>> imdata = reg.build_structs() - >>> x = NP.zeros(6, dtype=NP.float64) + >>> x = np.zeros(6, dtype=np.float64) >>> M = reg.build_rotate_matrix(x) >>> M array([[ 1., 0., 0., 0.], @@ -815,10 +811,10 @@ """ - R1 = NP.zeros([4,4], dtype=NP.float64); - R2 = NP.zeros([4,4], dtype=NP.float64); - R3 = NP.zeros([4,4], dtype=NP.float64); - T = NP.eye(4, dtype=NP.float64); + R1 = np.zeros([4,4], dtype=np.float64); + R2 = np.zeros([4,4], dtype=np.float64); + R3 = np.zeros([4,4], dtype=np.float64); + T = np.eye(4, dtype=np.float64); alpha = math.radians(img_data_parms[0]) beta = math.radians(img_data_parms[1]) @@ -853,404 +849,196 @@ T[1][3] = img_data_parms[4] T[2][3] = img_data_parms[5] - rot_matrix = NP.dot(T, R1); - rot_matrix = NP.dot(rot_matrix, R2); - rot_matrix = NP.dot(rot_matrix, R3); + rot_matrix = np.dot(T, R1); + rot_matrix = np.dot(rot_matrix, R2); + rot_matrix = np.dot(rot_matrix, R3); return rot_matrix -def load_volume(imagedesc, imagename=None, threshold=0.999, debug=0): +def build_gauss_volume(imagedesc, S=[1500.0, 2500.0, 1000.0]): """ - image = load_volume(imagedesc, imagename=None, threshold=0.999, debug=0) --- OR --- - image, h, ih, index = load_volume(imagedesc, imagename=None, threshold=0.999, debug=0) + build a 3D Gaussian volume. user passes in image dims in imagedesc + the sigma for each axis is S[3] where 0=z, 1=y, 2=x - gets an image descriptor and optional filename and returns a scaled 8 bit volume. The - scaling is designed to make full use of the 8 bits (ignoring high amplitude outliers). - The current method uses numpy fromfile and will be replaced by neuroimage nifti load. + volume3D = build_test_volume(imagedesc, S) Parameters ---------- - imagedesc : {dictionary} - imagedesc is the descriptor of the image to be read. + imagedesc : {dictionary} + volume dimensions and sampling - imagename : {string} : optional - name of image file. No name creates a blank image that is used for creating - a rotated test image or image rescaling. + S : {tuple} + the Gaussian sigma for Z, Y and X - threshold : {float} : optional - this is the threshold for upper cutoff in the 8 bit scaling. The volume histogram - and integrated histogram is computed and the upper amplitude cutoff is where the - integrated histogram crosses the value set in the threshold. setting threshold to - 1.0 means the scaling is done over the min to max amplitude range. - - debug : {0, 1} : optional - when debug=1 the method returns the volume histogram, integrated histogram and the - amplitude index where the provided threshold occured. - Returns ------- - image : {dictionary} - the volume data assoicated with the filename or a blank volume of the same - dimensions as specified in imagedesc. - --- OR --- (if debug = 1) + volume3D : {nd_array} + the 3D volume for testing - image : {dictionary} - the volume data assoicated with the filename or a blank volume of the same - dimensions as specified in imagedesc. + """ + layers = imagedesc['layers'] + rows = imagedesc['rows'] + cols = imagedesc['cols'] - h : {nd_array} - the volume 1D amplitude histogram + L = layers/2 + R = rows/2 + C = cols/2 - ih : {nd_array} - the volume 1D amplitude integrated histogram + # build coordinates for 3D Gaussian volume + # coordinates are centered at (0, 0, 0) + [a, b, c] = np.mgrid[-L:L, -R:R, -C:C] - index : {int} - the amplitude (histogram index) where the integrated histogram - crosses the 'threshold' provided. + sigma = np.array([S[0], S[1], S[2]]) + aa = (np.square(a))/sigma[0] + bb = (np.square(b))/sigma[1] + cc = (np.square(c))/sigma[2] + volume3D = (255.0*np.exp(-(aa + bb + cc))).astype(np.uint8) - Examples - -------- + return volume3D - >>> import numpy as NP - >>> import _registration as reg - >>> anat_desc = reg.load_anatMRI_desc() - >>> image_anat, h, ih, index = reg.load_volume(anat_desc, imagename='ANAT1_V0001.img', debug=1) - >>> index - 210 +def scale_image(image, max_amp=255, image_type=np.uint8, threshold=0.999, fetch_ih=0): """ + scale and threshold clip the volume using the integrated histogram + to set the high threshold - # load MRI or fMRI volume and return an autoscaled 8 bit image. - # autoscale is using integrated histogram to deal with outlier high amplitude voxels - if imagename == None: - # imagename of none means to create a blank image - ImageVolume = NP.zeros(imagedesc['layers']*imagedesc['rows']*imagedesc['cols'], - dtype=NP.uint16).reshape(imagedesc['layers'], imagedesc['rows'], imagedesc['cols']) - else: - ImageVolume = NP.fromfile(imagename, - dtype=NP.uint16).reshape(imagedesc['layers'], imagedesc['rows'], imagedesc['cols']); + Parameters + ---------- + image : {nd_array} + raw unscaled volume - # the mat (voxel to physical) matrix - M = NP.eye(4, dtype=NP.float64); - # for now just the sample size (mm units) in x, y and z - M[0][0] = imagedesc['sample_x'] - M[1][1] = imagedesc['sample_y'] - M[2][2] = imagedesc['sample_z'] - # dimensions - D = NP.zeros(3, dtype=NP.int32); - # Gaussian kernel - fill in with build_fwhm() - F = NP.zeros(3, dtype=NP.float64); - D[0] = imagedesc['rows'] - D[1] = imagedesc['cols'] - D[2] = imagedesc['layers'] + max_amp : int (default 255) + the maximum value of the scaled image - if imagename == None: - # no voxels to scale to 8 bits - ImageVolume = ImageVolume.astype(NP.uint8) - image = {'data' : ImageVolume, 'mat' : M, 'dim' : D, 'fwhm' : F} - return image + image_type : nd_array dtype (default uint8) + the type of the volume to return. - # 8 bit scale with threshold clip of the volume integrated histogram - max = ImageVolume.max() - min = ImageVolume.min() - ih = NP.zeros(max-min+1, dtype=NP.float64); - h = NP.zeros(max-min+1, dtype=NP.float64); - if threshold <= 0: - threshold = 0.999 - elif threshold > 1.0: - threshold = 1.0 - # get the integrated histogram of the volume and get max from - # the threshold crossing in the integrated histogram - index = R.register_image_threshold(ImageVolume, h, ih, threshold) - scale = 255.0 / (index-min) - # generate the scaled 8 bit image - images = (scale*(ImageVolume.astype(NP.float)-min)) - images[images>255] = 255 - image = {'data' : images.astype(NP.uint8), 'mat' : M, 'dim' : D, 'fwhm' : F} - if debug == 1: - return image, h, ih, index - else: - return image + threshold : float (default 0.999) + the value of the normalized integrated histogram + that when reached sets the high threshold index + Returns + ------- + image : {nd_array} + the scaled volume + ih : {nd_array} + the integrated histogram. can be used for image display + purpose (histogram equalization) + """ -# -# ---- demo/debug routines ---- -# + max = image.max() + min = image.min() + if max == 0 and min == 0: + raise ValueError, "Zero image. cannot be scaled" -def load_anatMRI_desc(): - # this is for demo on the test MRI and fMRI volumes - rows = 256 - cols = 256 - layers = 90 - xsamp = 0.9375 - ysamp = 0.9375 - zsamp = 1.5 - desc = {'rows' : rows, 'cols' : cols, 'layers' : layers, - 'sample_x' : xsamp, 'sample_y' : ysamp, 'sample_z' : zsamp} - return desc + # need range of pixels for the number of bins + h, edges = np.histogram(image, bins=(max-min)) + ih = (np.cumsum(h)).astype(np.float64) + # normalize the integrated histogram + ih = ih / ih.max() + indices = np.where(ih >= threshold) + # wind up getting all the indices where the ih >= threshold + # and only need the first index. tuple has one nd_array and + # get the 0 element from it ([0][0]) + index = indices[0][0] + scale = float(max_amp) / (index-min) + image = (scale*(image.astype(np.float)-min)) + image[image>max_amp] = max_amp + # down type. usually will go from float to 8 bit (needed for the 8 bit joint histogram) + image = image.astype(image_type) -def load_fMRI_desc(): - # this is for demo on the test MRI and fMRI volumes - rows = 64 - cols = 64 - layers = 28 - xsamp = 3.75 - ysamp = 3.75 - zsamp = 5.0 - desc = {'rows' : rows, 'cols' : cols, 'layers' : layers, - 'sample_x' : xsamp, 'sample_y' : ysamp, 'sample_z' : zsamp} - return desc - -def read_fMRI_directory(path): - files_fMRI = glob.glob(path) - return files_fMRI - - -def check_alignment(image1, image2, imdata, method='ncc', lite=0, smhist=0, - alpha=0.0, beta=0.0, gamma=0.0, Tx=0, Ty=0, Tz=0, ret_histo=0): - - # - # to test the cost function and view the joint histogram - # for 2 images. used for debug - # - imdata['parms'][0] = alpha - imdata['parms'][1] = beta - imdata['parms'][2] = gamma - imdata['parms'][3] = Tx - imdata['parms'][4] = Ty - imdata['parms'][5] = Tz - M = build_rotate_matrix(imdata['parms']) - optfunc_args = (image1, image2, imdata['step'], imdata['fwhm'], lite, smhist, method, ret_histo) - - if ret_histo: - cost, joint_histogram = optimize_function(imdata['parms'], optfunc_args) - return cost, joint_histogram + if fetch_ih == 1: + return image, ih else: - cost = optimize_function(imdata['parms'], optfunc_args) - return cost + return image -def build_scale_image(image, scale): - # - # rescale the 'mat' (voxel to physical mapping matrix) - # - (layers, rows, cols) = image['data'].shape - M = image['mat'] * scale - # dimensions - D = NP.zeros(3, dtype=NP.int32); - # Gaussian kernel - fill in with build_fwhm() - F = NP.zeros(3, dtype=NP.float64); - Z = NP.zeros(3, dtype=NP.float64); - D[0] = rows/scale - D[1] = cols/scale - D[2] = layers/scale - image2 = NP.zeros(D[2]*D[1]*D[0], dtype=NP.uint8).reshape(D[2], D[0], D[1]); - mode = 1; - R.register_volume_resample(image['data'], image2, Z, scale, mode) - scaled_image = {'data' : image2, 'mat' : M, 'dim' : D, 'fwhm' : F} - return scaled_image - -def demo_MRI_volume_align(scale=2, alpha=3.0, beta=4.0, gamma=5.0, Tx = 0.0, Ty = 0.0, Tz = 0.0): +def check_alignment(image1, image1_mat, image2, image2_mat, histo_fwhm=3, method='ncc', lite=0, + smhist=0, alpha=0.0, beta=0.0, gamma=0.0, Tx=0, Ty=0, Tz=0, ret_histo=0): + """ - demo with (must have file ANAT1_V0001.img) + test the cost function and (optional) view the joint histogram. can be used + during intra-modal registration to measure the current alignment (return + the cross correlation). would measure before and after registration - image1, image2, imdata = reg.demo_MRI_volume_align() - x = reg.python_coreg(image1, image2, imdata, method='ncc', lite=1) - image2r = reg.remap_image(image2, x, resample='cubic') - image2rz = reg.resize_image(image2r, image1['mat']) - slice1 = image1['data'][45, :, :] - slice2 = image2['data'][45/2, :, :] - slice2r = image2r['data'][45/2, :, :] - slice2rz = image2rz['data'][45, :, :] - - pylab.figure(1) - pylab.bone() - pylab.imshow(slice1) - pylab.imshow(slice1) - pylab.figure(2) - pylab.imshow(slice2) - pylab.figure(3) - pylab.imshow(slice2r) - pylab.figure(4) - pylab.imshow(slice2rz) - pylab.show() - """ - # - # this is for coreg MRI / fMRI scale test. The volume is anatomical MRI. - # the image is rotated in 3D. after rotation the image is scaled. - # - anat_desc = load_anatMRI_desc() - image1 = load_volume(anat_desc, imagename='ANAT1_V0001.img') - image2 = load_volume(anat_desc, imagename=None) - imdata = build_structs() - image1['fwhm'] = build_fwhm(image1['mat'], imdata['step']) - image2['fwhm'] = build_fwhm(image2['mat'], imdata['step']) - imdata['parms'][0] = alpha - imdata['parms'][1] = beta - imdata['parms'][2] = gamma - imdata['parms'][3] = Tx - imdata['parms'][4] = Ty - imdata['parms'][5] = Tz - M = build_rotate_matrix(imdata['parms']) - # rotate volume. linear interpolation means the volume is low pass filtered - R.register_linear_resample(image1['data'], image2['data'], M, imdata['step']) - # subsample volume - image3 = build_scale_image(image2, scale) - return image1, image3, imdata + # do the parameter validity checking. this is specific to this 3D registration. + # make sure the image is 3D and the mats are 4x4 with nonzero diagonal -def demo_rotate_fMRI_volume(fMRIVol, x): - # - # return rotated fMRIVol. the fMRIVol is already loaded, and gets rotated - # + if image1.ndim != 3: + raise ValueError, "Image 1 is not 3 dimensional" - desc = load_fMRI_desc() - image = load_volume(desc, imagename=None) - imdata = build_structs() - image['fwhm'] = build_fwhm(image['mat'], imdata['step']) - imdata['parms'][0] = x[0] # alpha - imdata['parms'][1] = x[1] # beta - imdata['parms'][2] = x[2] # gamma - imdata['parms'][3] = x[3] # Tx - imdata['parms'][4] = x[4] # Ty - imdata['parms'][5] = x[5] # Tz - M = build_rotate_matrix(imdata['parms']) - # rotate volume. cubic spline interpolation means the volume is NOT low pass filtered - R.register_cubic_resample(fMRIVol['data'], image['data'], M, imdata['step']) - return image + if image2.ndim != 3: + raise ValueError, "Image 2 is not 3 dimensional" -def demo_MRI_coregistration(optimizer_method='powell', histo_method=1, smooth_histo=0, smooth_image=0, ftype=1): - """ - demo with (must have file ANAT1_V0001.img and fMRI directory fMRIData) + if image1.dtype != np.uint8: + raise ValueError, "Image 1 is not 8 bit (required for joint histogram)" - measures, imageF_anat, fmri_series = reg.demo_MRI_coregistration() + if image2.dtype != np.uint8: + raise ValueError, "Image 2 is not 8 bit (required for joint histogram)" - show results with + if image1_mat.shape != (4,4): + raise ValueError, "Image1 MAT is not 4x4" - In [59]: measures[25]['cost'] - Out[59]: -0.48607185 + if image2_mat.shape != (4,4): + raise ValueError, "Image2 MAT is not 4x4" - In [60]: measures[25]['align_cost'] - Out[60]: -0.99514639 + if (np.diag(image1_mat)).prod() == 0: + raise ValueError, "Image1 MAT has a 0 on the diagonal" - In [61]: measures[25]['align_rotate'] - Out[61]: - array([ 1.94480181, 5.64703989, 5.35002136, -5.00544405, -2.2712214, -1.42249691], dtype=float32) + if (np.diag(image2_mat)).prod() == 0: + raise ValueError, "Image2 MAT has a 0 on the diagonal" - In [62]: measures[25]['rotate'] - Out[62]: - array([ 1.36566341, 4.70644331, 4.68198586, -4.32256889, -2.47607017, -2.39173937], dtype=float32) + if method != 'nmi' and method != 'mi' and method != 'ncc'\ + and method != 'ecc' and method != 'mse': + raise ValueError, "choose cost method nmi, mi, ecc, mse, ncc" + P = np.zeros(6, dtype=np.float64); + P[0] = alpha + P[1] = beta + P[2] = gamma + P[3] = Tx + P[4] = Ty + P[5] = Tz - """ + step = np.array([1, 1, 1], dtype=np.int32) + optfunc_args = (image1, image1_mat, image2, image2_mat, step, histo_fwhm, lite, + smhist, method, ret_histo) + + if ret_histo: + cost, joint_histogram = cost_function(P, optfunc_args) + return cost, joint_histogram + else: + cost = cost_function(P, optfunc_args) + return cost - # demo of alignment of fMRI series with anatomical MRI - # in this demo, each fMRI volume is first perturbed (rotated, translated) - # by a random value. The initial registration is measured, then the optimal - # alignment is computed and the registration measure made following the volume remap. - # The fMRI registration is done with the first fMRI volume using normalized cross-correlation. - # Each fMRI volume is rotated to the fMRI-0 volume and the series is ensemble averaged. - # The ensemble averaged is then registered with the anatomical MRI volume using normalized mutual information. - # The fMRI series is then rotated with this parameter. The alignments are done with 3D cubic splines. - # read the anatomical MRI volume - anat_desc = load_anatMRI_desc() - imageF_anat = load_volume(anat_desc, imagename='ANAT1_V0001.img') - # the sampling structure - imdata = build_structs() - # the volume filter - imageF_anat['fwhm'] = build_fwhm(imageF_anat['mat'], imdata['step']) - # read in the file list of the fMRI data - metric_test = NP.dtype([('cost', 'f'), - ('align_cost', 'f'), - ('rotate', 'f', 6), - ('align_rotate', 'f', 6)]) +def build_scale_volume(image, mat, scale): + # + # rescale the 'mat' (voxel to physical mapping matrix) + # + M = mat * scale + (layers, rows, cols) = image.shape + # dimensions + D = np.zeros(3, dtype=np.int32); + Z = np.zeros(3, dtype=np.float64); + D[0] = rows/scale + D[1] = cols/scale + D[2] = layers/scale + image2 = np.zeros([D[2], D[0], D[1]], dtype=np.uint8) + mode = 1; + reg.register_volume_resample(image, image2, Z, scale, mode) + return image2, M - fMRIdata = read_fMRI_directory('fMRIData\*.img') - fmri_desc = load_fMRI_desc() - fmri_series = {} - ave_fMRI_volume = NP.zeros(fmri_desc['layers']*fmri_desc['rows']*fmri_desc['cols'], - dtype=NP.float64).reshape(fmri_desc['layers'], fmri_desc['rows'], fmri_desc['cols']) - count = 0 - number_volumes = len(fMRIdata) - measures = NP.zeros(number_volumes, dtype=metric_test) - # load and perturb (rotation, translation) the fMRI volumes - for i in fMRIdata: - image = load_volume(fmri_desc, i) - # random perturbation of angle, translation for each volume beyond the first - if count == 0: - image['fwhm'] = build_fwhm(image['mat'], imdata['step']) - fmri_series[count] = image - count = count + 1 - else: - x = NP.random.random(6) - 0.5 - x = 10.0 * x - fmri_series[count] = demo_rotate_fMRI_volume(image, x) - measures[count]['rotate'][0:6] = x[0:6] - count = count + 1 - # load and register the fMRI volumes with volume_0 using normalized cross correlation metric - imageF = fmri_series[0] - if smooth_image: - image_F_xyz = filter_image_3D(imageF['data'], imageF['fwhm'], ftype) - imageF['data'] = image_F_xyz - for i in range(1, number_volumes): - imageG = fmri_series[i] - # the measure prior to alignment - measures[i]['cost'] = check_alignment(imageF, imageG, imdata, method='ncc', - lite=histo_method, smhist=smooth_histo) - x = python_coreg(imageF, imageG, imdata, lite=histo_method, method='ncc', - opt_method=optimizer_method, smhist=smooth_histo, smimage=smooth_image) - measures[i]['align_rotate'][0:6] = x[0:6] - measures[i]['align_cost'] = check_alignment(imageF, imageG, imdata, method='ncc', - lite=histo_method, smhist=smooth_histo, - alpha=x[0], beta=x[1], gamma=x[2], Tx=x[3], Ty=x[4], Tz=x[5]) - - # align the volumes and average them for co-registration with the anatomical MRI - ave_fMRI_volume = fmri_series[0]['data'].astype(NP.float64) - for i in range(1, number_volumes): - image = fmri_series[i] - x[0:6] = measures[i]['align_rotate'][0:6] - # overwrite the fMRI volume with the aligned volume - fmri_series[i] = remap_image(image, x, resample='cubic') - ave_fMRI_volume = ave_fMRI_volume + fmri_series[i]['data'].astype(NP.float64) - - ave_fMRI_volume = (ave_fMRI_volume / float(number_volumes)).astype(NP.uint8) - ave_fMRI_volume = {'data' : ave_fMRI_volume, 'mat' : imageF['mat'], - 'dim' : imageF['dim'], 'fwhm' : imageF['fwhm']} - # register (using normalized mutual information) with the anatomical MRI - if smooth_image: - image_F_anat_xyz = filter_image_3D(imageF_anat['data'], imageF_anat['fwhm'], ftype) - imageF_anat['data'] = image_F_anat_xyz - x = python_coreg(imageF_anat, ave_fMRI_volume, imdata, lite=histo_method, - method='nmi', opt_method=optimizer_method, smhist=smooth_histo, smimage=smooth_image) - print 'functional-anatomical align parameters ' - print x - for i in range(number_volumes): - image = fmri_series[i] - # overwrite the fMRI volume with the anatomical-aligned volume - fmri_series[i] = remap_image(image, x, resample='cubic') - - return measures, imageF_anat, fmri_series - - -def demo_fMRI_resample(imageF_anat, fmri_series): - resampled_fmri_series = {} - number_volumes = len(fmri_series) - for i in range(number_volumes): - resampled_fmri_series[i] = resize_image(fmri_series[i], imageF_anat['mat']) - - return resampled_fmri_series - - Modified: branches/refactor_fft/scipy/ndimage/src/register/Register_EXT.c =================================================================== --- branches/refactor_fft/scipy/ndimage/src/register/Register_EXT.c 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/ndimage/src/register/Register_EXT.c 2008-07-01 04:52:00 UTC (rev 4511) @@ -629,9 +629,108 @@ } +static PyObject *Register_Complete_Symmetry(PyObject *self, PyObject *args) +{ + int nx; + int ny; + int nz; + int ni; + double *A; + PyObject *AlphaArray = NULL; + + if(!PyArg_ParseTuple(args, "Oiiii", &AlphaArray, &nx, &ny, &nz, &ni)) + goto exit; + + A = (double *)PyArray_DATA(AlphaArray); + + if(!NI_Complete_Symmetry(A, nx, ny, nz, ni)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + + +static PyObject *Register_LT_Tensor_Product(PyObject *self, PyObject *args) +{ + int M1; + int M2; + int rows; + int cur_row; + int coeff_1; + int coeff_2; + double *A1; + double *A2; + double *B1; + double *B2; + double *Basis; + PyObject *AlphaArray1 = NULL; + PyObject *AlphaArray2 = NULL; + PyObject *BetaArray1 = NULL; + PyObject *BetaArray2 = NULL; + PyObject *BasisArray = NULL; + + if(!PyArg_ParseTuple(args, "OOOOOiiiiii", &AlphaArray1, &AlphaArray2, &BetaArray1, &BetaArray2, + &BasisArray, &M1, &M2, &rows, &cur_row, &coeff_1, &coeff_2)) + goto exit; + + A1 = (double *)PyArray_DATA(AlphaArray1); + A2 = (double *)PyArray_DATA(AlphaArray2); + B1 = (double *)PyArray_DATA(BetaArray1); + B2 = (double *)PyArray_DATA(BetaArray2); + Basis = (double *)PyArray_DATA(BasisArray); + + if(!NI_LT_Tensor_Product(A1, A2, B1, B2, Basis, M1, M2, rows, cur_row, coeff_1, coeff_2)) + goto exit; + + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + + +static PyObject *Register_LT_Mrqcof(PyObject *self, PyObject *args) +{ + + int M1; + double wt; + double value; + double *A; + double *B; + double *V; + PyObject *AlphaArray = NULL; + PyObject *BetaArray = NULL; + PyObject *VArray = NULL; + + if(!PyArg_ParseTuple(args, "OOOddi", &AlphaArray, &BetaArray, &VArray, &wt, &value, &M1)) + goto exit; + + A = (double *)PyArray_DATA(AlphaArray); + B = (double *)PyArray_DATA(BetaArray); + V = (double *)PyArray_DATA(VArray); + + if(!NI_LT_Mrqcof(A, B, V, wt, value, M1)) + goto exit; + +exit: + + return PyErr_Occurred() ? NULL : (PyObject*)Py_BuildValue(""); + +} + + static PyMethodDef RegisterMethods[] = { + { "register_complete_symmetry", Register_Complete_Symmetry, METH_VARARGS, NULL }, + { "register_lt_mrqcof", Register_LT_Mrqcof, METH_VARARGS, NULL }, + { "register_lt_tensor_product", Register_LT_Tensor_Product, METH_VARARGS, NULL }, { "register_find_mask", Register_Find_Mask, METH_VARARGS, NULL }, { "register_resample_coords", Register_Resample_Coords, METH_VARARGS, NULL }, { "register_resample_gradient_coords", Register_Resample_Gradient_Coords, METH_VARARGS, NULL }, Modified: branches/refactor_fft/scipy/ndimage/src/register/Register_IMPL.c =================================================================== --- branches/refactor_fft/scipy/ndimage/src/register/Register_IMPL.c 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/ndimage/src/register/Register_IMPL.c 2008-07-01 04:52:00 UTC (rev 4511) @@ -936,9 +936,9 @@ V110 * (dx1) * (dy1) * (-1.0) + V111 * (dx1) * (dy1) * (1.0); - gradientX[sliceD+rowD+(int)x] = (int)(gradX*scale[(int)zp]); - gradientY[sliceD+rowD+(int)x] = (int)(gradY*scale[(int)zp]); - gradientZ[sliceD+rowD+(int)x] = (int)(gradZ*scale[(int)zp]); + gradientX[sliceD+rowD+(int)x] = (gradX*scale[(int)zp]); + gradientY[sliceD+rowD+(int)x] = (gradY*scale[(int)zp]); + gradientZ[sliceD+rowD+(int)x] = (gradZ*scale[(int)zp]); } } @@ -1083,9 +1083,9 @@ V111 * (dx1) * (dy1) * (1.0); /* gradients saved in the unrolled clipped gradient volume */ - gradientX[i] = (int)(gradX*scale[(int)zp]); - gradientY[i] = (int)(gradY*scale[(int)zp]); - gradientZ[i] = (int)(gradZ*scale[(int)zp]); + gradientX[i] = (gradX*scale[(int)zp]); + gradientY[i] = (gradY*scale[(int)zp]); + gradientZ[i] = (gradZ*scale[(int)zp]); } @@ -1203,3 +1203,167 @@ +int NI_LT_Mrqcof(double *alpha, double *beta, double *V, double wt, double value, int M1){ + + int i, j; + double v1; + int status; + + for(i = 0; i < M1; ++i){ + v1 = V[i]; + beta[i] = v1 * value * wt; + for(j = 0; j <= i; ++j){ + alpha[M1*i+j] = v1 * V[j]; + } + } + + status = 1; + + return status; + +} + + +int NI_LT_Tensor_Product(double *alpha_1, double *alpha_2, double *beta_1, double *beta_2, double *basis, + int M1, int M2, int rows, int row_number, int coeff_1, int coeff_2){ + + + // + // lower triangular tensor product + // + + int i, j, k, m; + int loop3_outer, loop3_inner; + int status; + double wt1; + double wt2; + double *ptr1; + double *ptr2; + + for(i = 0; i < coeff_1; ++i){ + wt1 = basis[rows*i + row_number]; + for(loop3_outer = 0; loop3_outer < 3; ++loop3_outer){ + // + // spatial-spatial covariances + // + for(loop3_inner = 0; loop3_inner <= loop3_outer; ++loop3_inner){ + for(j = 0; j <= i; ++j){ + // + // outer product of basis array + // + wt2 = wt1 * basis[rows*j + row_number]; + ptr1 = &alpha_1[coeff_2*(M1*(coeff_1*loop3_outer+i)+(coeff_1*loop3_inner)+j)]; + ptr2 = &alpha_2[coeff_2*(M2*loop3_outer+loop3_inner)]; + for(k = 0; k < coeff_2; ++k){ + for(m = 0; m <= k; ++m){ + ptr1[M1*k+m] += (wt2 * ptr2[M2*k+m]); + } + } + } + // + // spatial-intensity covariances (single G volume assumed) + // + ptr1 = &alpha_1[coeff_2*(M1*coeff_1*3+(coeff_1*loop3_inner)+i)]; + ptr2 = &alpha_2[coeff_2*(M2*3+loop3_outer)]; + for(k = 0; k < coeff_2; ++k){ + ptr1[M1+k] += (wt1 * ptr2[M2+k]); + } + // + // spatial component of beta + // + for(k = 0; k < coeff_2; ++k){ + beta_1[k+coeff_2*(coeff_1*loop3_outer+i)] += (wt1 * beta_2[coeff_2*loop3_outer+k]); + } + } + } + } + + // + // intensity-intensity covariances + // + ptr1 = &alpha_1[coeff_2*(M1*coeff_1*3+(coeff_1*3))]; + ptr2 = &alpha_2[coeff_2*(M2*3+3)]; + for(k = 0; k < coeff_2; ++k){ + ptr1[k] += ptr2[k]; + } + + // + // intensity component of beta + // + + beta_1[coeff_2*coeff_1*3] += beta_2[coeff_2*3]; + + status = 1; + + return status; + +} + + + +int NI_Complete_Symmetry(double *Alpha, int nx, int ny, int nz, int ni4){ + + // + // complete symmetry of Alpha matrix over the 3D brain volume + // + + int z1, z2; + int y1, y2; + int x1, x2; + int loop3_outer, loop3_inner; + int M1; + int status; + double *ptrx; + double *ptry; + double *ptrz; + + M1 = 3*nx*ny*nz + ni4; + + for(loop3_outer = 0; loop3_outer < 3; ++loop3_outer){ + for(loop3_inner = 0; loop3_inner <= loop3_outer; ++loop3_inner){ + ptrz = &Alpha[nx*ny*nz*(M1*loop3_outer+loop3_inner)]; + for(z1 = 0; z1 < nz; ++z1){ + for(z2 = 0; z2 <= z1; ++z2){ + ptry = ptrz + nx*ny*(M1*z1 + z2); + for(y1 = 0; y1 < ny; ++y1){ + for(y2 = 0; y2 <= y1; ++y2){ + ptrx = ptry + nx*(M1*y1 + y2); + for(x1 = 0; x1 <= nx; ++x1){ + for(y2 = 0; y2 <= y1; ++y2){ + ptrx[M1*x2+x1] = ptrx[M1*x1+x2]; + } + } + } + } + for(x1 = 0; x1 < nx*ny; ++x1){ + for(x2 = 0; x2 < x1; ++x2){ + ptry[M1*x2+x1] = ptry[M1*x1+x2]; + } + } + } + for(x1 = 0; x1 < nx*ny*nz; ++x1){ + for(x2 = 0; x2 < x1; ++x2){ + ptrz[M1*x2+x1] = ptrz[M1*x1+x2]; + } + } + + } + } + } + + for(x1 = 0; x1 < nx*ny*nz*3+ni4; ++x1){ + for(x2 = 0; x2 < x1; ++x2){ + Alpha[M1*x2+x1] = Alpha[M1*x1+x2]; + } + } + + + status = 1; + + return status; + +} + + + + Copied: branches/refactor_fft/scipy/ndimage/tests/test_registration.py (from rev 4510, trunk/scipy/ndimage/tests/test_registration.py) Copied: branches/refactor_fft/scipy/ndimage/tests/test_regression.py (from rev 4510, trunk/scipy/ndimage/tests/test_regression.py) Modified: branches/refactor_fft/scipy/ndimage/tests/test_segment.py =================================================================== --- branches/refactor_fft/scipy/ndimage/tests/test_segment.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/ndimage/tests/test_segment.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -155,5 +155,5 @@ return if __name__ == "__main__": - inittest.main() + nose.runmodule() Copied: branches/refactor_fft/scipy/odr/SConscript (from rev 4510, trunk/scipy/odr/SConscript) Deleted: branches/refactor_fft/scipy/odr/SConstruct =================================================================== --- branches/refactor_fft/scipy/odr/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/odr/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,62 +0,0 @@ -# Last Change: Wed Mar 05 04:00 PM 2008 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 numscons import get_python_inc#, get_pythonlib_dir -from numscons import GetNumpyEnvironment -from numscons import CheckF77BLAS, CheckF77Clib - -from numscons 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, - '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 -#-------------- -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('odrpack', source = libodr_src) - -env.PrependUnique(LIBS = 'odrpack') -env.PrependUnique(LIBPATH = env['build_dir']) - -# odr pyextension -env.NumpyPythonExtension('__odrpack', '__odrpack.c', - LINKFLAGSEND = env['F77_LDFLAGS']) Copied: branches/refactor_fft/scipy/odr/SConstruct (from rev 4510, trunk/scipy/odr/SConstruct) Copied: branches/refactor_fft/scipy/optimize/SConscript (from rev 4510, trunk/scipy/optimize/SConscript) Deleted: branches/refactor_fft/scipy/optimize/SConstruct =================================================================== --- branches/refactor_fft/scipy/optimize/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/optimize/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,91 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 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 numscons import get_python_inc#, get_pythonlib_dir -from numscons import GetNumpyEnvironment -from numscons import CheckF77LAPACK, CheckF77Clib - -from numscons import write_info - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') -env.Append(CPPPATH = get_numpy_include_dirs()) -env.Append(CPPPATH = env['F2PYINCLUDEDIR']) -#if os.name == 'nt': -# # 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, - '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 -else: - has_lapack = 1 - -config.Finish() -write_info(env) - -#========== -# Build -#========== - -# minpack lib -minpack_src = [str(s) for s in env.NumpyGlob(pjoin('minpack', '*.f'))] -env.NumpyStaticExtLibrary('minpack', source = minpack_src) - -# rootfind lib -rootfind_src = [str(s) for s in env.NumpyGlob(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', - LINKFLAGSEND = env['F77_LDFLAGS']) - -# _zeros pyextension -env.NumpyPythonExtension('_zeros', 'zeros.c') - -# _lbfgsb pyextension -src = [pjoin('lbfgsb', i) for i in ['lbfgsb.pyf', 'routines.f']] -env.NumpyPythonExtension('_lbfgsb', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) - -# _cobyla pyextension -src = [pjoin('cobyla', i) for i in ['cobyla2.f', 'trstlp.f', 'cobyla.pyf']] -env.NumpyPythonExtension('_cobyla', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) - -# _minpack2 pyextension -src = [pjoin('minpack2', i) for i in ['dcsrch.f', 'dcstep.f', 'minpack2.pyf']] -env.NumpyPythonExtension('minpack2', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) - -# moduleTNC pyextension -env.NumpyPythonExtension('moduleTNC', - source = [pjoin('tnc', i) for i in \ - ['moduleTNC.c', 'tnc.c']]) - -# _slsqp pyextension -src = [pjoin('slsqp', i) for i in ['slsqp_optmz.f', 'slsqp.pyf']] -env.NumpyPythonExtension('_slsqp', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) Copied: branches/refactor_fft/scipy/optimize/SConstruct (from rev 4510, trunk/scipy/optimize/SConstruct) Modified: branches/refactor_fft/scipy/optimize/anneal.py =================================================================== --- branches/refactor_fft/scipy/optimize/anneal.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/optimize/anneal.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -9,6 +9,7 @@ __all__ = ['anneal'] +_double_min = numpy.finfo(float).min _double_max = numpy.finfo(float).max class base_schedule(object): def __init__(self): @@ -35,11 +36,25 @@ self.tests = 0 def getstart_temp(self, best_state): + """ Find a matching starting temperature and starting parameters vector + i.e. find x0 such that func(x0) = T0. + + Parameters + ---------- + best_state : _state + A _state object to store the function value and x0 found. + + Returns + ------- + x0 : array + The starting parameters vector. + """ + assert(not self.dims is None) lrange = self.lower urange = self.upper - fmax = -300e8 - fmin = 300e8 + fmax = _double_min + fmin = _double_max for _ in range(self.Ninit): x0 = random.uniform(size=self.dims)*(urange-lrange) + lrange fval = self.func(x0, *self.args) @@ -50,6 +65,7 @@ fmin = fval best_state.cost = fval best_state.x = array(x0) + self.T0 = (fmax-fmin)*1.5 return best_state.x Modified: branches/refactor_fft/scipy/optimize/minpack.py =================================================================== --- branches/refactor_fft/scipy/optimize/minpack.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/optimize/minpack.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,7 +1,8 @@ import _minpack from numpy import atleast_1d, dot, take, triu, shape, eye, \ - transpose, zeros, product, greater, array + transpose, zeros, product, greater, array, \ + any, all, where, isscalar, asarray, ndarray error = _minpack.error @@ -103,7 +104,7 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder + fixed_point -- scalar and vector fixed-point finder """ x0 = array(x0,ndmin=1) @@ -256,7 +257,7 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder + fixed_point -- scalar and vector fixed-point finder """ x0 = array(x0,ndmin=1) @@ -372,8 +373,8 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder - + fixed_point -- scalar and vector fixed-point finder + """ if fprime is not None: @@ -411,10 +412,26 @@ # Steffensen's Method using Aitken's Del^2 convergence acceleration. -def fixed_point(func, x0, args=(), xtol=1e-10, maxiter=500): - """Given a function of one variable and a starting point, find a +def fixed_point(func, x0, args=(), xtol=1e-8, maxiter=500): + """Find the point where func(x) == x + + Given a function of one or more variables and a starting point, find a fixed-point of the function: i.e. where func(x)=x. + Uses Steffensen's Method using Aitken's Del^2 convergence acceleration. + See Burden, Faires, "Numerical Analysis", 5th edition, pg. 80 + + Example + ------- + >>> from numpy import sqrt, array + >>> from scipy.optimize import fixed_point + >>> def func(x, c1, c2): + return sqrt(c1/(x+c2)) + >>> c1 = array([10,12.]) + >>> c2 = array([3, 5.]) + >>> fixed_point(func, [1.2, 1.3], args=(c1,c2)) + array([ 1.4920333 , 1.37228132]) + See also: fmin, fmin_powell, fmin_cg, @@ -432,26 +449,39 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder - """ + if not isscalar(x0): + x0 = asarray(x0) + p0 = x0 + for iter in range(maxiter): + p1 = func(p0, *args) + p2 = func(p1, *args) + d = p2 - 2.0 * p1 + p0 + p = where(d == 0, p2, p0 - (p1 - p0)*(p1-p0) / d) + relerr = where(p0 == 0, p, (p-p0)/p0) + if all(relerr < xtol): + return p + p0 = p + else: + p0 = x0 + for iter in range(maxiter): + p1 = func(p0, *args) + p2 = func(p1, *args) + d = p2 - 2.0 * p1 + p0 + if d == 0.0: + return p2 + else: + p = p0 - (p1 - p0)*(p1-p0) / d + if p0 == 0: + relerr = p + else: + relerr = (p-p0)/p0 + if relerr < xtol: + return p + p0 = p + raise RuntimeError, "Failed to converge after %d iterations, value is %s" % (maxiter,p) - p0 = x0 - for iter in range(maxiter): - p1 = func(*((p0,)+args)) - p2 = func(*((p1,)+args)) - d = p2 - 2.0 * p1 + p0 - if d == 0.0: - print "Warning: Difference in estimates is %g" % (abs(p2-p1)) - return p2 - else: - p = p0 - (p1 - p0)*(p1-p0) / d - if abs(p-p0) < xtol: - return p - p0 = p - raise RuntimeError, "Failed to converge after %d iterations, value is %f" % (maxiter,p) - def bisection(func, a, b, args=(), xtol=1e-10, maxiter=400): """Bisection root-finding method. Given a function and an interval with func(a) * func(b) < 0, find the root between a and b. @@ -473,7 +503,7 @@ brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding - fixed_point -- scalar fixed-point finder + fixed_point -- scalar and vector fixed-point finder """ i = 1 Copied: branches/refactor_fft/scipy/sandbox/mkufunc (from rev 4510, trunk/scipy/sandbox/mkufunc) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/README.txt =================================================================== --- trunk/scipy/sandbox/mkufunc/README.txt 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/README.txt 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,19 +0,0 @@ - -mkufunc (make universal function) is a tool which lets you create -a C compiled version of a universal function (UFunc). - -It works by translating the python function into C and then uses -scipy.weave to create a UFunc which calls the appropriate C function -in the inner 1-d loop. This means that there are no Python calls -when the calculation is performed, making the calculation -fast (in particular when the arrays involved in the calculation -are very large). - -Requirements: - - pypy - -You need the pypy path in your PYTHONPATH environment: - -$ export PYTHONPATH=/giant/src/pypy-dist - Copied: branches/refactor_fft/scipy/sandbox/mkufunc/README.txt (from rev 4510, trunk/scipy/sandbox/mkufunc/README.txt) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/TODO.txt =================================================================== Copied: branches/refactor_fft/scipy/sandbox/mkufunc/TODO.txt (from rev 4510, trunk/scipy/sandbox/mkufunc/TODO.txt) Copied: branches/refactor_fft/scipy/sandbox/mkufunc/docs (from rev 4510, trunk/scipy/sandbox/mkufunc/docs) Copied: branches/refactor_fft/scipy/sandbox/mkufunc/examples (from rev 4510, trunk/scipy/sandbox/mkufunc/examples) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/examples/benchmark.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,49 +0,0 @@ -#!/usr/bin/env python -from math import sin, cos -import time - -from numpy import arange, vectorize, allclose -from scipy import weave - -from mkufunc.api import mkufunc - - -def f(x): - return 4.2 * x * x + 3.7 * x + 1.5 - - -vfunc = vectorize(f) - -ufunc = mkufunc([(float, float)])(f) - - -x = arange(0, 1000, 0.001) #print "x =", x, x.dtype - -start_time = time.time() -b_y = x.copy() -weave.blitz("b_y[:] = 4.2 * x[:] * x[:] + 3.7 * x[:] + 1.5") -b_time = time.time() - start_time -print 'blitz: %.6f sec' % b_time - -start_time = time.time() -n_y = f(x) -n_time = time.time() - start_time -print 'numpy: %.6f sec' % n_time - -start_time = time.time() -v_y = vfunc(x) -v_time = time.time() - start_time -print 'vectorize: %.6f sec' % v_time - -start_time = time.time() -u_y = ufunc(x) -u_time = time.time() - start_time -print 'mkufunc: %.6f sec' % u_time - -print "speedup over blitz:", b_time/u_time -print "speedup over numpy:", n_time/u_time -print "speedup over vectorize:", v_time/u_time - -assert allclose(b_y, n_y) -assert allclose(v_y, n_y) -assert allclose(u_y, n_y) Copied: branches/refactor_fft/scipy/sandbox/mkufunc/examples/benchmark.py (from rev 4510, trunk/scipy/sandbox/mkufunc/examples/benchmark.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/examples/primes.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/examples/primes.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,29 +0,0 @@ -#!/usr/bin/env python -from math import sqrt -import time - -from numpy import arange - -from mkufunc.api import mkufunc - - -def is_prime(n): - if n < 2: - return 0 - for i in xrange(2, min(n, int(sqrt(n)+2.0))): - if n %i == 0: - return 0 - return 1 - - -start_time = time.time() -assert sum(is_prime(n) for n in xrange(1000000)) == 78498 -print 'Python: %.6f sec' % (time.time() - start_time) - - -is_prime = mkufunc(int)(is_prime) - - -start_time = time.time() -assert is_prime(arange(1000000)).sum() == 78498 -print 'Compiled: %.6f sec' % (time.time() - start_time) Copied: branches/refactor_fft/scipy/sandbox/mkufunc/examples/primes.py (from rev 4510, trunk/scipy/sandbox/mkufunc/examples/primes.py) Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/__init__.py =================================================================== Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/__init__.py (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/__init__.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/api.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/api.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/api.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,346 +0,0 @@ -""" mkufunc (make U function) - - -Author: Ilan Schnell (with help from Travis Oliphant and Eric Jones) -""" -import sys -import re -import os, os.path -import cStringIO -import hashlib -from types import FunctionType - -import numpy -from scipy import weave - - -verbose = 0 - -def func_hash(f, salt=None): - """ Return a MD5 hash for a function object as string. - """ - co = f.func_code - return hashlib.md5(co.co_code + repr(co.co_names) + repr(salt) - ).hexdigest() - - -def translate(f, argtypes): - """ Return pypy's C output for a given function and argument types. - The cache files are in weave's directory. - """ - cache_file_name = os.path.join(weave.catalog.default_dir(), - 'pypy_%s.c' % func_hash(f, salt=argtypes)) - try: - return open(cache_file_name).read() - - except IOError: - from interactive import Translation - - t = Translation(f, backend='c') - t.annotate(argtypes) - t.source() - - os.rename(t.driver.c_source_filename, cache_file_name) - - return translate(f, argtypes) - - -class Ctype: - def __init__(self, npy, c): - self.npy = npy - self.c = c - -typedict = { - int: Ctype('NPY_LONG', 'long' ), - float: Ctype('NPY_DOUBLE', 'double'), -} - - -class Cfunc(object): - """ C compiled python functions - - >>> def sqr(x): - ... return x * x - - >>> signature = [int, int] # only the input arguments are used here - - compilation is done upon initialization - >>> x = Cfunc(sqr, signature, 123) - ... - >>> x.nin # number of input arguments - 1 - >>> x.nout # number of output arguments (must be 1 for now) - 1 - >>> x.sig - [, ] - - Attributes: - f -- the Python function object - n -- id number - sig -- signature - nin -- number of input arguments - nout -- number of output arguments - cname -- name of the C function - - Methods: - decl() -- returns the C declaration for the function - cfunc() -- returns the C function (as string) - ufunc_support_code() - -- generate the C support code to make this - function part work with PyUFuncGenericFunction - """ - def __init__(self, f, signature, n): - self.f = f - self.n = n - self.sig = signature - self.nin = f.func_code.co_argcount - self.nout = len(self.sig) - self.nin - assert self.nout == 1 # for now - - src = translate(f, signature[:self.nin]) - - self._prefix = 'f%i_' % self.n - self._allCsrc = src.replace('pypy_', self._prefix + 'pypy_') - self.cname = self._prefix + 'pypy_g_' + f.__name__ - - def cfunc(self): - p = re.compile(r'^\w+[*\s\w]+' + self.cname + - r'\s*\([^)]*\)\s*\{.*?[\n\r]\}[\n\r]', - re.DOTALL | re.MULTILINE | re.VERBOSE) - - found = p.findall(self._allCsrc) - assert len(found) == 1 - res = found[0] - res = res.replace(self._prefix + 'pypy_g_ll_math_ll_math_', '') - return 'inline ' + res + '\n' - - def ufunc_support_code(self): - # Unfortunately the code in here is very hard to read. - # In order to make the code clearer, one would need a real template - # engine link Cheetah (http://cheetahtemplate.org/). - # However, somehting like that would be too much overhead for scipy. - n = self.n - nin = self.nin - cname = self.cname - - def varname(i): - return chr(i + ord('a')) - - declargs = ', '.join('%s %s' % (typedict[self.sig[i]].c, varname(i)) - for i in xrange(self.nin)) - - args = ', '.join(varname(i) for i in xrange(self.nin)) - - isn_steps = '\n\t'.join('npy_intp is%i = steps[%i];' % (i, i) - for i in xrange(self.nin)) - - ipn_args = '\n\t'.join('char *ip%i = args[%i];' % (i, i) - for i in xrange(self.nin)) - - body1d_in = '\n\t\t'.join('%s *in%i = (%s *)ip%i;' % - (2*(typedict[self.sig[i]].c, i)) - for i in xrange(self.nin)) - - body1d_add = '\n\t\t'.join('ip%i += is%i;' % (i, i) - for i in xrange(self.nin)) - - ptrargs = ', '.join('*in%i' % i for i in xrange(self.nin)) - - rettype = typedict[self.sig[-1]].c - - return ''' -static %(rettype)s wrap_%(cname)s(%(declargs)s) -{ - return %(cname)s(%(args)s); -} - -typedef %(rettype)s Func_%(n)i(%(declargs)s); - -static void -PyUFunc_%(n)i(char **args, npy_intp *dimensions, npy_intp *steps, void *func) -{ - npy_intp i, n; - %(isn_steps)s - npy_intp os = steps[%(nin)s]; - %(ipn_args)s - char *op = args[%(nin)s]; - Func_%(n)i *f = (Func_%(n)i *) func; - n = dimensions[0]; - - for(i = 0; i < n; i++) { - %(body1d_in)s - %(rettype)s *out = (%(rettype)s *)op; - - *out = (%(rettype)s) f(%(ptrargs)s); - - %(body1d_add)s - op += os; - } -} -''' % locals() - - -def support_code(cfuncs): - """ Given a list of Cfunc instances, return the support code for weave. - """ - acc = cStringIO.StringIO() - - acc.write('/********************* start pypy.h **************/\n\n') - acc.write(open(os.path.join(os.path.dirname(__file__), - 'pypy.h')).read()) - acc.write('/********************** end pypy.h ****************/\n\n') - - for cf in cfuncs: - acc.write(cf.cfunc()) - acc.write(cf.ufunc_support_code()) - - fname = cfuncs[0].f.__name__ - - pyufuncs = ''.join('\tPyUFunc_%i,\n' % cf.n for cf in cfuncs) - - data = ''.join('\t(void *) wrap_%s,\n' % cf.cname for cf in cfuncs) - - types = ''.join('\t%s /* %i */\n' % - (''.join(typedict[t].npy + ', ' for t in cf.sig), cf.n) - for cf in cfuncs) - - acc.write(''' -static PyUFuncGenericFunction %(fname)s_functions[] = { -%(pyufuncs)s}; - -static void *%(fname)s_data[] = { -%(data)s}; - -static char %(fname)s_types[] = { -%(types)s}; -''' % locals()) - - if verbose: - print '------------------ start support_code -----------------' - print acc.getvalue() - print '------------------- end support_code ------------------' - - return acc.getvalue() - - -def code(f, signatures): - """ Return the code for weave. - """ - nin = f.func_code.co_argcount - ntypes = len(signatures) - fname = f.__name__ - fhash = func_hash(f) - - res = ''' -import_ufunc(); - -/**************************************************************************** -** function name: %(fname)s -** signatures: %(signatures)r -** fhash: %(fhash)s -*****************************************************************************/ - -return_val = PyUFunc_FromFuncAndData( - %(fname)s_functions, - %(fname)s_data, - %(fname)s_types, - %(ntypes)i, /* ntypes */ - %(nin)i, /* nin */ - 1, /* nout */ - PyUFunc_None, /* identity */ - "%(fname)s", /* name */ - "UFunc created by mkufunc", /* doc */ - 0); -''' % locals() - - if verbose: - print '---------------------- start code ---------------------' - print res - print '----------------------- end code ----------------------' - - return res - - -def genufunc(f, signatures): - """ Return the Ufunc Python object for given function and signatures. - """ - if len(signatures) == 0: - raise ValueError("At least one signature needed") - - signatures.sort(key=lambda sig: [numpy.dtype(typ).num for typ in sig]) - - cfuncs = [Cfunc(f, sig, n) for n, sig in enumerate(signatures)] - - ufunc_info = weave.base_info.custom_info() - ufunc_info.add_header('"numpy/ufuncobject.h"') - - return weave.inline(code(f, signatures), - verbose=verbose, - support_code=support_code(cfuncs), - customize=ufunc_info) - - -def mkufunc(arg0=[float]): - """ Python decorator which returns compiled UFunc of the function given. - - >>> from numpy import arange - >>> from mkufunc.api import mkufunc - >>> @mkufunc - ... def foo(x): - ... return 4.2 * x * x - x + 6.3 - ... - >>> a = arange(5) - >>> a - array([0, 1, 2, 3, 4]) - >>> foo(a) - array([ 6.3, 9.5, 21.1, 41.1, 69.5]) - """ - class UFunc(object): - - def __init__(self, f): - nin = f.func_code.co_argcount - nout = 1 - for i, sig in enumerate(signatures): - if isinstance(sig, tuple): - pass - elif sig in typedict.keys(): - signatures[i] = (nin + nout) * (sig,) - else: - raise TypeError("no match for %r" % sig) - - for sig in signatures: - assert isinstance(sig, tuple) - if len(sig) != nin + nout: - raise TypeError("signature %r does not match the " - "number of args of function %s" % - (sig, f.__name__)) - for t in sig: - if t not in typedict.keys(): - raise TypeError("no match for %r" % t) - - self.ufunc = genufunc(f, signatures) - - def __call__(self, *args): - return self.ufunc(*args) - - if isinstance(arg0, FunctionType): - f = arg0 - signatures = [float] - return UFunc(f) - - elif isinstance(arg0, list): - signatures = arg0 - return UFunc - - elif arg0 in typedict.keys(): - signatures = [arg0] - return UFunc - - else: - raise TypeError("first argument has to be a function, a type, or " - "a list of signatures") - - -if __name__ == '__main__': - import doctest - doctest.testmod() Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/api.py (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/api.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/driver.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/driver.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/driver.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,728 +0,0 @@ -import sys, os - -from pypy.translator.translator import TranslationContext, graphof -from pypy.translator.tool.taskengine import SimpleTaskEngine -from pypy.translator.goal import query -from pypy.translator.goal.timing import Timer -from pypy.annotation import model as annmodel -from pypy.annotation.listdef import s_list_of_strings -from pypy.annotation import policy as annpolicy -from py.compat import optparse -from pypy.tool.udir import udir - -import py -from pypy.tool.ansi_print import ansi_log -log = py.log.Producer("translation") -py.log.setconsumer("translation", ansi_log) - -DEFAULTS = { - 'translation.gc': 'ref', - 'translation.cc': None, - 'translation.profopt': None, - - 'translation.thread': False, # influences GC policy - - 'translation.stackless': False, - 'translation.debug': True, - 'translation.insist': False, - 'translation.backend': 'c', - 'translation.fork_before': None, - 'translation.backendopt.raisingop2direct_call' : False, - 'translation.backendopt.merge_if_blocks': True, -} - - -def taskdef(taskfunc, deps, title, new_state=None, expected_states=[], - idemp=False, earlycheck=None): - taskfunc.task_deps = deps - taskfunc.task_title = title - taskfunc.task_newstate = None - taskfunc.task_expected_states = expected_states - taskfunc.task_idempotent = idemp - taskfunc.task_earlycheck = earlycheck - return taskfunc - -# TODO: -# sanity-checks using states - -_BACKEND_TO_TYPESYSTEM = { - 'c': 'lltype', - 'llvm': 'lltype' -} - -def backend_to_typesystem(backend): - return _BACKEND_TO_TYPESYSTEM.get(backend, 'ootype') - -# set of translation steps to profile -PROFILE = set([]) - -class Instrument(Exception): - pass - - -class ProfInstrument(object): - name = "profinstrument" - def __init__(self, datafile, compiler): - self.datafile = datafile - self.compiler = compiler - - def first(self): - self.compiler._build() - - def probe(self, exe, args): - from py.compat import subprocess - env = os.environ.copy() - env['_INSTRUMENT_COUNTERS'] = str(self.datafile) - subprocess.call("'%s' %s" % (exe, args), env=env, shell=True) - - def after(self): - # xxx - os._exit(0) - - -class TranslationDriver(SimpleTaskEngine): - - def __init__(self, setopts=None, default_goal=None, - disable=[], - exe_name=None, extmod_name=None, - config=None, overrides=None): - self.timer = Timer() - SimpleTaskEngine.__init__(self) - - self.log = log - - if config is None: - from pypy.config.pypyoption import get_pypy_config - config = get_pypy_config(DEFAULTS, translating=True) - self.config = config - if overrides is not None: - self.config.override(overrides) - - if setopts is not None: - self.config.set(**setopts) - - self.exe_name = exe_name - self.extmod_name = extmod_name - - self.done = {} - - self.disable(disable) - - if default_goal: - default_goal, = self.backend_select_goals([default_goal]) - if default_goal in self._maybe_skip(): - default_goal = None - - self.default_goal = default_goal - self.extra_goals = [] - self.exposed = [] - - # expose tasks - def expose_task(task, backend_goal=None): - if backend_goal is None: - backend_goal = task - def proc(): - return self.proceed(backend_goal) - self.exposed.append(task) - setattr(self, task, proc) - - backend, ts = self.get_backend_and_type_system() - for task in self.tasks: - explicit_task = task - parts = task.split('_') - if len(parts) == 1: - if task in ('annotate'): - expose_task(task) - else: - task, postfix = parts - if task in ('rtype', 'backendopt', 'llinterpret', - 'prehannotatebackendopt', 'hintannotate', - 'timeshift'): - if ts: - if ts == postfix: - expose_task(task, explicit_task) - else: - expose_task(explicit_task) - elif task in ('source', 'compile', 'run'): - if backend: - if backend == postfix: - expose_task(task, explicit_task) - elif ts: - if ts == backend_to_typesystem(postfix): - expose_task(explicit_task) - else: - expose_task(explicit_task) - - def set_extra_goals(self, goals): - self.extra_goals = goals - - def get_info(self): # XXX more? - d = {'backend': self.config.translation.backend} - return d - - def get_backend_and_type_system(self): - type_system = self.config.translation.type_system - backend = self.config.translation.backend - return backend, type_system - - def backend_select_goals(self, goals): - backend, ts = self.get_backend_and_type_system() - postfixes = [''] + ['_'+p for p in (backend, ts) if p] - l = [] - for goal in goals: - for postfix in postfixes: - cand = "%s%s" % (goal, postfix) - if cand in self.tasks: - new_goal = cand - break - else: - raise Exception, "cannot infer complete goal from: %r" % goal - l.append(new_goal) - return l - - def disable(self, to_disable): - self._disabled = to_disable - - def _maybe_skip(self): - maybe_skip = [] - if self._disabled: - for goal in self.backend_select_goals(self._disabled): - maybe_skip.extend(self._depending_on_closure(goal)) - return dict.fromkeys(maybe_skip).keys() - - - def setup(self, entry_point, inputtypes, policy=None, extra={}, empty_translator=None): - standalone = inputtypes is None - self.standalone = standalone - - if standalone: - inputtypes = [s_list_of_strings] - self.inputtypes = inputtypes - - if policy is None: - policy = annpolicy.AnnotatorPolicy() - if standalone: - policy.allow_someobjects = False - self.policy = policy - - self.extra = extra - - if empty_translator: - translator = empty_translator - else: - translator = TranslationContext(config=self.config) - - self.entry_point = entry_point - self.translator = translator - self.libdef = None - - self.translator.driver_instrument_result = self.instrument_result - - def setup_library(self, libdef, policy=None, extra={}, empty_translator=None): - self.setup(None, None, policy, extra, empty_translator) - self.libdef = libdef - - def instrument_result(self, args): - backend, ts = self.get_backend_and_type_system() - if backend != 'c' or sys.platform == 'win32': - raise Exception("instrumentation requires the c backend" - " and unix for now") - from pypy.tool.udir import udir - - datafile = udir.join('_instrument_counters') - makeProfInstrument = lambda compiler: ProfInstrument(datafile, compiler) - - pid = os.fork() - if pid == 0: - # child compiling and running with instrumentation - self.config.translation.instrument = True - self.config.translation.instrumentctl = (makeProfInstrument, - args) - raise Instrument - else: - pid, status = os.waitpid(pid, 0) - if os.WIFEXITED(status): - status = os.WEXITSTATUS(status) - if status != 0: - raise Exception, "instrumentation child failed: %d" % status - else: - raise Exception, "instrumentation child aborted" - import array, struct - n = datafile.size()//struct.calcsize('L') - datafile = datafile.open('rb') - counters = array.array('L') - counters.fromfile(datafile, n) - datafile.close() - return counters - - def info(self, msg): - log.info(msg) - - def _profile(self, goal, func): - from cProfile import Profile - from pypy.tool.lsprofcalltree import KCacheGrind - d = {'func':func} - prof = Profile() - prof.runctx("res = func()", globals(), d) - KCacheGrind(prof).output(open(goal + ".out", "w")) - return d['res'] - - def _do(self, goal, func, *args, **kwds): - title = func.task_title - if goal in self.done: - self.log.info("already done: %s" % title) - return - else: - self.log.info("%s..." % title) - self.timer.start_event(goal) - try: - instrument = False - try: - if goal in PROFILE: - res = self._profile(goal, func) - else: - res = func() - except Instrument: - instrument = True - if not func.task_idempotent: - self.done[goal] = True - if instrument: - self.proceed('compile') - assert False, 'we should not get here' - finally: - self.timer.end_event(goal) - return res - - def task_annotate(self): - # includes annotation and annotatation simplifications - translator = self.translator - policy = self.policy - self.log.info('with policy: %s.%s' % - (policy.__class__.__module__, policy.__class__.__name__)) - - annmodel.DEBUG = self.config.translation.debug - annotator = translator.buildannotator(policy=policy) - - if self.entry_point: - s = annotator.build_types(self.entry_point, self.inputtypes) - - self.sanity_check_annotation() - if self.standalone and s.knowntype != int: - raise Exception("stand-alone program entry point must return an " - "int (and not, e.g., None or always raise an " - "exception).") - annotator.simplify() - return s - else: - assert self.libdef is not None - for func, inputtypes in self.libdef.functions: - annotator.build_types(func, inputtypes) - self.sanity_check_annotation() - annotator.simplify() - # - task_annotate = taskdef(task_annotate, [], "Annotating&simplifying") - - - def sanity_check_annotation(self): - translator = self.translator - irreg = query.qoutput(query.check_exceptblocks_qgen(translator)) - if irreg: - self.log.info("Some exceptblocks seem insane") - - lost = query.qoutput(query.check_methods_qgen(translator)) - assert not lost, "lost methods, something gone wrong with the annotation of method defs" - - so = query.qoutput(query.polluted_qgen(translator)) - tot = len(translator.graphs) - percent = int(tot and (100.0*so / tot) or 0) - # if there are a few SomeObjects even if the policy doesn't allow - # them, it means that they were put there in a controlled way - # and then it's not a warning. - if not translator.annotator.policy.allow_someobjects: - pr = self.log.info - elif percent == 0: - pr = self.log.info - else: - pr = log.WARNING - pr("-- someobjectness %2d%% (%d of %d functions polluted by SomeObjects)" % (percent, so, tot)) - - - - def task_rtype_lltype(self): - rtyper = self.translator.buildrtyper(type_system='lltype') - insist = not self.config.translation.insist - rtyper.specialize(dont_simplify_again=True, - crash_on_first_typeerror=insist) - # - task_rtype_lltype = taskdef(task_rtype_lltype, ['annotate'], "RTyping") - RTYPE = 'rtype_lltype' - - def task_rtype_ootype(self): - # Maybe type_system should simply be an option used in task_rtype - insist = not self.config.translation.insist - rtyper = self.translator.buildrtyper(type_system="ootype") - rtyper.specialize(dont_simplify_again=True, - crash_on_first_typeerror=insist) - # - task_rtype_ootype = taskdef(task_rtype_ootype, ['annotate'], "ootyping") - OOTYPE = 'rtype_ootype' - - def task_prehannotatebackendopt_lltype(self): - from pypy.translator.backendopt.all import backend_optimizations - backend_optimizations(self.translator, - inline_threshold=0, - merge_if_blocks=True, - constfold=True, - raisingop2direct_call=False, - remove_asserts=True) - # - task_prehannotatebackendopt_lltype = taskdef( - task_prehannotatebackendopt_lltype, - [RTYPE], - "Backendopt before Hint-annotate") - - def task_hintannotate_lltype(self): - from pypy.jit.hintannotator.annotator import HintAnnotator - from pypy.jit.hintannotator.model import OriginFlags - from pypy.jit.hintannotator.model import SomeLLAbstractConstant - - get_portal = self.extra['portal'] - PORTAL, POLICY = get_portal(self) - t = self.translator - self.portal_graph = graphof(t, PORTAL) - - hannotator = HintAnnotator(base_translator=t, policy=POLICY) - self.hint_translator = hannotator.translator - hs = hannotator.build_types(self.portal_graph, - [SomeLLAbstractConstant(v.concretetype, - {OriginFlags(): True}) - for v in self.portal_graph.getargs()]) - count = hannotator.bookkeeper.nonstuboriggraphcount - stubcount = hannotator.bookkeeper.stuboriggraphcount - self.log.info("The hint-annotator saw %d graphs" - " (and made stubs for %d graphs)." % (count, stubcount)) - n = len(list(hannotator.translator.graphs[0].iterblocks())) - self.log.info("portal has %d blocks" % n) - self.hannotator = hannotator - # - task_hintannotate_lltype = taskdef(task_hintannotate_lltype, - ['prehannotatebackendopt_lltype'], - "Hint-annotate") - - def task_timeshift_lltype(self): - from pypy.jit.timeshifter.hrtyper import HintRTyper - from pypy.jit.codegen import detect_cpu - cpu = detect_cpu.autodetect() - if cpu == 'i386': - from pypy.jit.codegen.i386.rgenop import RI386GenOp as RGenOp - RGenOp.MC_SIZE = 32 * 1024 * 1024 - elif cpu == 'ppc': - from pypy.jit.codegen.ppc.rgenop import RPPCGenOp as RGenOp - RGenOp.MC_SIZE = 32 * 1024 * 1024 - else: - raise Exception('Unsuported cpu %r'%cpu) - - del self.hint_translator - ha = self.hannotator - t = self.translator - # make the timeshifted graphs - hrtyper = HintRTyper(ha, t.rtyper, RGenOp) - hrtyper.specialize(origportalgraph=self.portal_graph, view=False) - # - task_timeshift_lltype = taskdef(task_timeshift_lltype, - ["hintannotate_lltype"], - "Timeshift") - - def task_backendopt_lltype(self): - from pypy.translator.backendopt.all import backend_optimizations - backend_optimizations(self.translator) - # - task_backendopt_lltype = taskdef(task_backendopt_lltype, - [RTYPE, - '??timeshift_lltype'], - "lltype back-end optimisations") - BACKENDOPT = 'backendopt_lltype' - - def task_backendopt_ootype(self): - from pypy.translator.backendopt.all import backend_optimizations - backend_optimizations(self.translator) - # - task_backendopt_ootype = taskdef(task_backendopt_ootype, - [OOTYPE], "ootype back-end optimisations") - OOBACKENDOPT = 'backendopt_ootype' - - - def task_stackcheckinsertion_lltype(self): - from pypy.translator.transform import insert_ll_stackcheck - count = insert_ll_stackcheck(self.translator) - self.log.info("inserted %d stack checks." % (count,)) - - task_stackcheckinsertion_lltype = taskdef( - task_stackcheckinsertion_lltype, - ['?'+BACKENDOPT, RTYPE, 'annotate'], - "inserting stack checks") - STACKCHECKINSERTION = 'stackcheckinsertion_lltype' - - def possibly_check_for_boehm(self): - if self.config.translation.gc == "boehm": - from pypy.translator.tool.cbuild import check_boehm_presence - from pypy.translator.tool.cbuild import CompilationError - try: - check_boehm_presence(noerr=False) - except CompilationError, e: - i = 'Boehm GC not installed. Try e.g. "translate.py --gc=hybrid"' - raise CompilationError('%s\n--------------------\n%s' % (e, i)) - - def task_database_c(self): - translator = self.translator - if translator.annotator is not None: - translator.frozen = True - - standalone = self.standalone - - if standalone: - from pypy.translator.c.genc import CStandaloneBuilder as CBuilder - else: - from pypy.translator.c.genc import CExtModuleBuilder as CBuilder - cbuilder = CBuilder(self.translator, self.entry_point, - config=self.config) - cbuilder.stackless = self.config.translation.stackless - if not standalone: # xxx more messy - cbuilder.modulename = self.extmod_name - database = cbuilder.build_database() - self.log.info("database for generating C source was created") - self.cbuilder = cbuilder - self.database = database - # - task_database_c = taskdef(task_database_c, - [STACKCHECKINSERTION, '?'+BACKENDOPT, RTYPE, '?annotate'], - "Creating database for generating c source", - earlycheck = possibly_check_for_boehm) - - def task_source_c(self): # xxx messy - translator = self.translator - cbuilder = self.cbuilder - database = self.database - c_source_filename = cbuilder.generate_source(database) - self.log.info("written: %s" % (c_source_filename,)) - self.c_source_filename = str(c_source_filename) - # - task_source_c = taskdef(task_source_c, ['database_c'], "Generating c source") - - def task_compile_c(self): # xxx messy - cbuilder = self.cbuilder - cbuilder.compile() - - if self.standalone: - self.c_entryp = cbuilder.executable_name - self.create_exe() - else: - self.c_entryp = cbuilder.get_entry_point() - # - task_compile_c = taskdef(task_compile_c, ['source_c'], "Compiling c source") - - - def task_run_c(self): - self.backend_run('c') - # - task_run_c = taskdef(task_run_c, ['compile_c'], - "Running compiled c source", - idemp=True) - - def task_llinterpret_lltype(self): - from pypy.rpython.llinterp import LLInterpreter - py.log.setconsumer("llinterp operation", None) - - translator = self.translator - interp = LLInterpreter(translator.rtyper) - bk = translator.annotator.bookkeeper - graph = bk.getdesc(self.entry_point).getuniquegraph() - v = interp.eval_graph(graph, - self.extra.get('get_llinterp_args', - lambda: [])()) - - log.llinterpret.event("result -> %s" % v) - # - task_llinterpret_lltype = taskdef(task_llinterpret_lltype, - [STACKCHECKINSERTION, '?'+BACKENDOPT, RTYPE], - "LLInterpreting") - - def task_source_llvm(self): - translator = self.translator - if translator.annotator is None: - raise ValueError, "llvm requires annotation." - - from pypy.translator.llvm import genllvm - - self.llvmgen = genllvm.GenLLVM(translator, self.standalone) - - llvm_filename = self.llvmgen.gen_source(self.entry_point) - self.log.info("written: %s" % (llvm_filename,)) - # - task_source_llvm = taskdef(task_source_llvm, - [STACKCHECKINSERTION, BACKENDOPT, RTYPE], - "Generating llvm source") - - def task_compile_llvm(self): - gen = self.llvmgen - if self.standalone: - exe_name = (self.exe_name or 'testing') % self.get_info() - self.c_entryp = gen.compile_standalone(exe_name) - self.create_exe() - else: - self.c_module, self.c_entryp = gen.compile_module() - # - task_compile_llvm = taskdef(task_compile_llvm, - ['source_llvm'], - "Compiling llvm source") - - def task_run_llvm(self): - self.backend_run('llvm') - # - task_run_llvm = taskdef(task_run_llvm, ['compile_llvm'], - "Running compiled llvm source", - idemp=True) - - def task_source_js(self): - from pypy.translator.js.js import JS - self.gen = JS(self.translator, functions=[self.entry_point], - stackless=self.config.translation.stackless) - filename = self.gen.write_source() - self.log.info("Wrote %s" % (filename,)) - task_source_js = taskdef(task_source_js, - [OOTYPE], - 'Generating Javascript source') - - def task_compile_js(self): - pass - task_compile_js = taskdef(task_compile_js, ['source_js'], - 'Skipping Javascript compilation') - - def task_run_js(self): - pass - task_run_js = taskdef(task_run_js, ['compile_js'], - 'Please manually run the generated code') - - def task_source_cli(self): - from pypy.translator.cli.gencli import GenCli - from pypy.translator.cli.entrypoint import get_entrypoint - - if self.entry_point is not None: # executable mode - entry_point_graph = self.translator.graphs[0] - entry_point = get_entrypoint(entry_point_graph) - else: - # library mode - assert self.libdef is not None - bk = self.translator.annotator.bookkeeper - entry_point = self.libdef.get_entrypoint(bk) - - self.gen = GenCli(udir, self.translator, entry_point, config=self.config) - filename = self.gen.generate_source() - self.log.info("Wrote %s" % (filename,)) - task_source_cli = taskdef(task_source_cli, ["?" + OOBACKENDOPT, OOTYPE], - 'Generating CLI source') - - def task_compile_cli(self): - from pypy.translator.oosupport.support import unpatch_os - from pypy.translator.cli.test.runtest import CliFunctionWrapper - filename = self.gen.build_exe() - self.c_entryp = CliFunctionWrapper(filename) - # restore original os values - if hasattr(self, 'old_cli_defs'): - unpatch_os(self.old_cli_defs) - - self.log.info("Compiled %s" % filename) - if self.standalone and self.exe_name: - self.copy_cli_exe() - task_compile_cli = taskdef(task_compile_cli, ['source_cli'], - 'Compiling CLI source') - - def task_run_cli(self): - pass - task_run_cli = taskdef(task_run_cli, ['compile_cli'], - 'XXX') - - def task_source_jvm(self): - from pypy.translator.jvm.genjvm import GenJvm - from pypy.translator.jvm.node import EntryPoint - - entry_point_graph = self.translator.graphs[0] - is_func = not self.standalone - entry_point = EntryPoint(entry_point_graph, is_func, is_func) - self.gen = GenJvm(udir, self.translator, entry_point) - self.jvmsource = self.gen.generate_source() - self.log.info("Wrote JVM code") - task_source_jvm = taskdef(task_source_jvm, ["?" + OOBACKENDOPT, OOTYPE], - 'Generating JVM source') - - def task_compile_jvm(self): - from pypy.translator.oosupport.support import unpatch_os - from pypy.translator.jvm.test.runtest import JvmGeneratedSourceWrapper - self.jvmsource.compile() - self.c_entryp = JvmGeneratedSourceWrapper(self.jvmsource) - # restore original os values - if hasattr(self, 'old_cli_defs'): - unpatch_os(self.old_cli_defs) - self.log.info("Compiled JVM source") - if self.standalone and self.exe_name: - self.copy_jvm_jar() - task_compile_jvm = taskdef(task_compile_jvm, ['source_jvm'], - 'Compiling JVM source') - - def task_run_jvm(self): - pass - task_run_jvm = taskdef(task_run_jvm, ['compile_jvm'], - 'XXX') - - def proceed(self, goals): - if not goals: - if self.default_goal: - goals = [self.default_goal] - else: - self.log.info("nothing to do") - return - elif isinstance(goals, str): - goals = [goals] - goals.extend(self.extra_goals) - goals = self.backend_select_goals(goals) - return self._execute(goals, task_skip = self._maybe_skip()) - - def from_targetspec(targetspec_dic, config=None, args=None, - empty_translator=None, - disable=[], - default_goal=None): - if args is None: - args = [] - - driver = TranslationDriver(config=config, default_goal=default_goal, - disable=disable) - # patch some attributes of the os module to make sure they - # have the same value on every platform. - backend, ts = driver.get_backend_and_type_system() - if backend in ('cli', 'jvm'): - from pypy.translator.oosupport.support import patch_os - driver.old_cli_defs = patch_os() - - target = targetspec_dic['target'] - spec = target(driver, args) - - try: - entry_point, inputtypes, policy = spec - except ValueError: - entry_point, inputtypes = spec - policy = None - - driver.setup(entry_point, inputtypes, - policy=policy, - extra=targetspec_dic, - empty_translator=empty_translator) - - return driver - - from_targetspec = staticmethod(from_targetspec) - - def prereq_checkpt_rtype(self): - assert 'pypy.rpython.rmodel' not in sys.modules, ( - "cannot fork because the rtyper has already been imported") - prereq_checkpt_rtype_lltype = prereq_checkpt_rtype - prereq_checkpt_rtype_ootype = prereq_checkpt_rtype Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/driver.py (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/driver.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/interactive.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/interactive.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/interactive.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,115 +0,0 @@ -import driver - -from pypy.translator.translator import TranslationContext - - -DEFAULTS = { - 'translation.backend': None, - 'translation.type_system': None, - 'translation.verbose': False, -} - -class Translation(object): - - def __init__(self, entry_point, argtypes=None, **kwds): - self.driver = driver.TranslationDriver(overrides=DEFAULTS) - self.config = self.driver.config - - self.entry_point = entry_point - self.context = TranslationContext(config=self.config) - - # hook into driver events - driver_own_event = self.driver._event - def _event(kind, goal, func): - self.driver_event(kind, goal, func) - driver_own_event(kind, goal, func) - self.driver._event = _event - self.driver_setup = False - - self.update_options(argtypes, kwds) - # for t.view() to work just after construction - graph = self.context.buildflowgraph(entry_point) - self.context._prebuilt_graphs[entry_point] = graph - - def driver_event(self, kind, goal, func): - if kind == 'pre': - self.ensure_setup() - - def ensure_setup(self, argtypes=None, policy=None, standalone=False): - if not self.driver_setup: - if standalone: - assert argtypes is None - else: - if argtypes is None: - argtypes = [] - self.driver.setup(self.entry_point, argtypes, policy, - empty_translator=self.context) - self.ann_argtypes = argtypes - self.ann_policy = policy - self.driver_setup = True - else: - # check consistency - if standalone: - assert argtypes is None - assert self.ann_argtypes is None - elif argtypes is not None and argtypes != self.ann_argtypes: - raise Exception("inconsistent argtype supplied") - if policy is not None and policy != self.ann_policy: - raise Exception("inconsistent annotation polish supplied") - - def update_options(self, argtypes, kwds): - if argtypes or kwds.get('policy') or kwds.get('standalone'): - self.ensure_setup(argtypes, kwds.get('policy'), - kwds.get('standalone')) - kwds.pop('policy', None) - kwds.pop('standalone', None) - self.config.translation.set(**kwds) - - def ensure_opt(self, name, value=None, fallback=None): - if value is not None: - self.update_options(None, {name: value}) - return value - val = getattr(self.config.translation, name, None) - if fallback is not None and val is None: - self.update_options(None, {name: fallback}) - return fallback - if val is not None: - return val - raise Exception( - "the %r option should have been specified at this point" %name) - - def ensure_type_system(self, type_system=None): - if self.config.translation.backend is not None: - return self.ensure_opt('type_system') - return self.ensure_opt('type_system', type_system, 'lltype') - - def ensure_backend(self, backend=None): - backend = self.ensure_opt('backend', backend) - self.ensure_type_system() - return backend - - # backend independent - - def annotate(self, argtypes=None, **kwds): - self.update_options(argtypes, kwds) - return self.driver.annotate() - - # type system dependent - - def rtype(self, argtypes=None, **kwds): - self.update_options(argtypes, kwds) - ts = self.ensure_type_system() - return getattr(self.driver, 'rtype_'+ts)() - - # backend depedent - - def source(self, argtypes=None, **kwds): - self.update_options(argtypes, kwds) - backend = self.ensure_backend() - self.driver.source_c() - - def compile(self, argtypes=None, **kwds): - self.update_options(argtypes, kwds) - backend = self.ensure_backend() - self.driver.compile_c() - return self.driver.c_entryp Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/interactive.py (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/interactive.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/pypy.h =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/pypy.h 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/pypy.h 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,381 +0,0 @@ - -#include -#include -#include - -/* ================================================== g_prerequisite.h === */ - -typedef unsigned char bool_t; - -/* ================================================== exception.h ======== */ - -#define RPY_DEBUG_RETURN() /* nothing */ - - -/* ================================================== int.h ============== */ - -/*** unary operations ***/ - -#define OP_INT_IS_TRUE(x,r) OP_INT_NE(x,0,r) - -#define OP_INT_INVERT(x,r) r = ~((x)) - -#define OP_INT_NEG(x,r) r = -(x) - -#define OP_INT_NEG_OVF(x,r) \ - if ((x) == LONG_MIN) FAIL_OVF("integer negate"); \ - OP_INT_NEG(x,r) -#define OP_LLONG_NEG_OVF(x,r) \ - if ((x) == LLONG_MIN) FAIL_OVF("integer negate"); \ - OP_LLONG_NEG(x,r) - -#define OP_INT_ABS(x,r) r = (x) >= 0 ? x : -(x) - -#define OP_INT_ABS_OVF(x,r) \ - if ((x) == LONG_MIN) FAIL_OVF("integer absolute"); \ - OP_INT_ABS(x,r) -#define OP_LLONG_ABS_OVF(x,r) \ - if ((x) == LLONG_MIN) FAIL_OVF("integer absolute"); \ - OP_LLONG_ABS(x,r) - -/*** binary operations ***/ - -#define OP_INT_EQ(x,y,r) r = ((x) == (y)) -#define OP_INT_NE(x,y,r) r = ((x) != (y)) -#define OP_INT_LE(x,y,r) r = ((x) <= (y)) -#define OP_INT_GT(x,y,r) r = ((x) > (y)) -#define OP_INT_LT(x,y,r) r = ((x) < (y)) -#define OP_INT_GE(x,y,r) r = ((x) >= (y)) - -/* addition, subtraction */ - -#define OP_INT_ADD(x,y,r) r = (x) + (y) - -#define OP_INT_ADD_OVF(x,y,r) \ - OP_INT_ADD(x,y,r); \ - if ((r^(x)) >= 0 || (r^(y)) >= 0); \ - else FAIL_OVF("integer addition") - -#define OP_INT_ADD_NONNEG_OVF(x,y,r) /* y can be assumed >= 0 */ \ - OP_INT_ADD(x,y,r); \ - if (r >= (x)); \ - else FAIL_OVF("integer addition") -/* XXX can a C compiler be too clever and think it can "prove" that - * r >= x always hold above? */ - -#define OP_INT_SUB(x,y,r) r = (x) - (y) - -#define OP_INT_SUB_OVF(x,y,r) \ - OP_INT_SUB(x,y,r); \ - if ((r^(x)) >= 0 || (r^~(y)) >= 0); \ - else FAIL_OVF("integer subtraction") - -#define OP_INT_MUL(x,y,r) r = (x) * (y) - -#if defined(HAVE_LONG_LONG) && SIZE_OF_LONG_LONG < SIZE_OF_LONG -# define OP_INT_MUL_OVF_LL 1 -#lse -# define OP_INT_MUL_OVF_LL 0 -#endif - -#if !OP_INT_MUL_OVF_LL - -#define OP_INT_MUL_OVF(x,y,r) \ - if (op_int_mul_ovf(x,y,&r)); \ - else FAIL_OVF("integer multiplication") - -#else - -#define OP_INT_MUL_OVF(x,y,r) \ - { \ - PY_LONG_LONG lr = (PY_LONG_LONG)(x) * (PY_LONG_LONG)(y); \ - r = (long)lr; \ - if ((PY_LONG_LONG)r == lr); \ - else FAIL_OVF("integer multiplication"); \ - } -#endif - -/* shifting */ - -/* NB. shifting has same limitations as C: the shift count must be - >= 0 and < LONG_BITS. */ -#define OP_INT_RSHIFT(x,y,r) r = Py_ARITHMETIC_RIGHT_SHIFT(long, x, y) -#define OP_UINT_RSHIFT(x,y,r) r = (x) >> (y) -#define OP_LLONG_RSHIFT(x,y,r) r = Py_ARITHMETIC_RIGHT_SHIFT(PY_LONG_LONG,x,y) -#define OP_ULLONG_RSHIFT(x,y,r) r = (x) >> (y) - -#define OP_INT_LSHIFT(x,y,r) r = (x) << (y) -#define OP_UINT_LSHIFT(x,y,r) r = (x) << (y) -#define OP_LLONG_LSHIFT(x,y,r) r = (x) << (y) -#define OP_ULLONG_LSHIFT(x,y,r) r = (x) << (y) - -#define OP_INT_LSHIFT_OVF(x,y,r) \ - OP_INT_LSHIFT(x,y,r); \ - if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(long, r, (y))) \ - FAIL_OVF("x<= 0) { OP_INT_RSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") -#define OP_LLONG_RSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_LLONG_RSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") - -#define OP_INT_LSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_INT_LSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") -#define OP_LLONG_LSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_LLONG_LSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") - -#define OP_INT_LSHIFT_OVF_VAL(x,y,r) \ - if ((y) >= 0) { OP_INT_LSHIFT_OVF(x,y,r); } \ - else FAIL_VAL("negative shift count") - -/* pff */ -#define OP_UINT_LSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_UINT_LSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") -#define OP_ULLONG_LSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_ULLONG_LSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") - -#define OP_UINT_RSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_UINT_RSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") -#define OP_ULLONG_RSHIFT_VAL(x,y,r) \ - if ((y) >= 0) { OP_ULLONG_RSHIFT(x,y,r); } \ - else FAIL_VAL("negative shift count") - - -/* floor division */ - -#define OP_INT_FLOORDIV(x,y,r) r = (x) / (y) -#define OP_UINT_FLOORDIV(x,y,r) r = (x) / (y) -#define OP_LLONG_FLOORDIV(x,y,r) r = (x) / (y) -#define OP_ULLONG_FLOORDIV(x,y,r) r = (x) / (y) - -#define OP_INT_FLOORDIV_OVF(x,y,r) \ - if ((y) == -1 && (x) == LONG_MIN) \ - { FAIL_OVF("integer division"); } \ - else OP_INT_FLOORDIV(x,y,r) - -#define OP_INT_FLOORDIV_ZER(x,y,r) \ - if ((y)) { OP_INT_FLOORDIV(x,y,r); } \ - else FAIL_ZER("integer division") -#define OP_UINT_FLOORDIV_ZER(x,y,r) \ - if ((y)) { OP_UINT_FLOORDIV(x,y,r); } \ - else FAIL_ZER("unsigned integer division") -#define OP_LLONG_FLOORDIV_ZER(x,y,r) \ - if ((y)) { OP_LLONG_FLOORDIV(x,y,r); } \ - else FAIL_ZER("integer division") -#define OP_ULLONG_FLOORDIV_ZER(x,y,r) \ - if ((y)) { OP_ULLONG_FLOORDIV(x,y,r); } \ - else FAIL_ZER("unsigned integer division") - -#define OP_INT_FLOORDIV_OVF_ZER(x,y,r) \ - if ((y)) { OP_INT_FLOORDIV_OVF(x,y,r); } \ - else FAIL_ZER("integer division") - -/* modulus */ - -#define OP_INT_MOD(x,y,r) r = (x) % (y) -#define OP_UINT_MOD(x,y,r) r = (x) % (y) -#define OP_LLONG_MOD(x,y,r) r = (x) % (y) -#define OP_ULLONG_MOD(x,y,r) r = (x) % (y) - -#define OP_INT_MOD_OVF(x,y,r) \ - if ((y) == -1 && (x) == LONG_MIN) \ - { FAIL_OVF("integer modulo"); }\ - else OP_INT_MOD(x,y,r) - -#define OP_INT_MOD_ZER(x,y,r) \ - if ((y)) { OP_INT_MOD(x,y,r); } \ - else FAIL_ZER("integer modulo") -#define OP_UINT_MOD_ZER(x,y,r) \ - if ((y)) { OP_UINT_MOD(x,y,r); } \ - else FAIL_ZER("unsigned integer modulo") -#define OP_LLONG_MOD_ZER(x,y,r) \ - if ((y)) { OP_LLONG_MOD(x,y,r); } \ - else FAIL_ZER("integer modulo") -#define OP_ULLONG_MOD_ZER(x,y,r) \ - if ((y)) { OP_ULLONG_MOD(x,y,r); } \ - else FAIL_ZER("integer modulo") - -#define OP_INT_MOD_OVF_ZER(x,y,r) \ - if ((y)) { OP_INT_MOD_OVF(x,y,r); } \ - else FAIL_ZER("integer modulo") - -/* bit operations */ - -#define OP_INT_AND(x,y,r) r = (x) & (y) -#define OP_INT_OR( x,y,r) r = (x) | (y) -#define OP_INT_XOR(x,y,r) r = (x) ^ (y) - -/*** conversions ***/ - -#define OP_CAST_BOOL_TO_INT(x,r) r = (long)(x) -#define OP_CAST_BOOL_TO_UINT(x,r) r = (unsigned long)(x) -#define OP_CAST_UINT_TO_INT(x,r) r = (long)(x) -#define OP_CAST_INT_TO_UINT(x,r) r = (unsigned long)(x) -#define OP_CAST_INT_TO_LONGLONG(x,r) r = (long long)(x) -#define OP_CAST_CHAR_TO_INT(x,r) r = (long)((unsigned char)(x)) -#define OP_CAST_INT_TO_CHAR(x,r) r = (char)(x) -#define OP_CAST_PTR_TO_INT(x,r) r = (long)(x) /* XXX */ - -#define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (long)(x) - -#define OP_CAST_UNICHAR_TO_INT(x,r) r = (long)((unsigned long)(x)) /*?*/ -#define OP_CAST_INT_TO_UNICHAR(x,r) r = (unsigned int)(x) - -/* bool operations */ - -#define OP_BOOL_NOT(x, r) r = !(x) - -/* _________________ certain implementations __________________ */ - -#if !OP_INT_MUL_OVF_LL -/* adjusted from intobject.c, Python 2.3.3 */ - -/* prototypes */ - -int op_int_mul_ovf(long a, long b, long *longprod); - -/* implementations */ - -#ifndef PYPY_NOT_MAIN_FILE - -int -op_int_mul_ovf(long a, long b, long *longprod) -{ - double doubled_longprod; /* (double)longprod */ - double doubleprod; /* (double)a * (double)b */ - - *longprod = a * b; - doubleprod = (double)a * (double)b; - doubled_longprod = (double)*longprod; - - /* Fast path for normal case: small multiplicands, and no info - is lost in either method. */ - if (doubled_longprod == doubleprod) - return 1; - - /* Somebody somewhere lost info. Close enough, or way off? Note - that a != 0 and b != 0 (else doubled_longprod == doubleprod == 0). - The difference either is or isn't significant compared to the - true value (of which doubleprod is a good approximation). - */ - { - const double diff = doubled_longprod - doubleprod; - const double absdiff = diff >= 0.0 ? diff : -diff; - const double absprod = doubleprod >= 0.0 ? doubleprod : - -doubleprod; - /* absdiff/absprod <= 1/32 iff - 32 * absdiff <= absprod -- 5 good bits is "close enough" */ - if (32.0 * absdiff <= absprod) - return 1; - return 0; - } -} - -#endif /* PYPY_NOT_MAIN_FILE */ - -#endif /* !OP_INT_MUL_OVF_LL */ - -/* implementations */ - -#define OP_UINT_IS_TRUE OP_INT_IS_TRUE -#define OP_UINT_INVERT OP_INT_INVERT -#define OP_UINT_ADD OP_INT_ADD -#define OP_UINT_SUB OP_INT_SUB -#define OP_UINT_MUL OP_INT_MUL -#define OP_UINT_LT OP_INT_LT -#define OP_UINT_LE OP_INT_LE -#define OP_UINT_EQ OP_INT_EQ -#define OP_UINT_NE OP_INT_NE -#define OP_UINT_GT OP_INT_GT -#define OP_UINT_GE OP_INT_GE -#define OP_UINT_AND OP_INT_AND -#define OP_UINT_OR OP_INT_OR -#define OP_UINT_XOR OP_INT_XOR - -#define OP_LLONG_IS_TRUE OP_INT_IS_TRUE -#define OP_LLONG_NEG OP_INT_NEG -#define OP_LLONG_ABS OP_INT_ABS -#define OP_LLONG_INVERT OP_INT_INVERT - -#define OP_LLONG_ADD OP_INT_ADD -#define OP_LLONG_SUB OP_INT_SUB -#define OP_LLONG_MUL OP_INT_MUL -#define OP_LLONG_LT OP_INT_LT -#define OP_LLONG_LE OP_INT_LE -#define OP_LLONG_EQ OP_INT_EQ -#define OP_LLONG_NE OP_INT_NE -#define OP_LLONG_GT OP_INT_GT -#define OP_LLONG_GE OP_INT_GE -#define OP_LLONG_AND OP_INT_AND -#define OP_LLONG_OR OP_INT_OR -#define OP_LLONG_XOR OP_INT_XOR - -#define OP_ULLONG_IS_TRUE OP_LLONG_IS_TRUE -#define OP_ULLONG_INVERT OP_LLONG_INVERT -#define OP_ULLONG_ADD OP_LLONG_ADD -#define OP_ULLONG_SUB OP_LLONG_SUB -#define OP_ULLONG_MUL OP_LLONG_MUL -#define OP_ULLONG_LT OP_LLONG_LT -#define OP_ULLONG_LE OP_LLONG_LE -#define OP_ULLONG_EQ OP_LLONG_EQ -#define OP_ULLONG_NE OP_LLONG_NE -#define OP_ULLONG_GT OP_LLONG_GT -#define OP_ULLONG_GE OP_LLONG_GE -#define OP_ULLONG_AND OP_LLONG_AND -#define OP_ULLONG_OR OP_LLONG_OR -#define OP_ULLONG_XOR OP_LLONG_XOR - -/* ================================================== float.h ============ */ - -/*** unary operations ***/ - -#define OP_FLOAT_IS_TRUE(x,r) OP_FLOAT_NE(x,0.0,r) -#define OP_FLOAT_NEG(x,r) r = -x -#define OP_FLOAT_ABS(x,r) r = fabs(x) - -/*** binary operations ***/ - -#define OP_FLOAT_EQ(x,y,r) r = (x == y) -#define OP_FLOAT_NE(x,y,r) r = (x != y) -#define OP_FLOAT_LE(x,y,r) r = (x <= y) -#define OP_FLOAT_GT(x,y,r) r = (x > y) -#define OP_FLOAT_LT(x,y,r) r = (x < y) -#define OP_FLOAT_GE(x,y,r) r = (x >= y) - -#define OP_FLOAT_CMP(x,y,r) \ - r = ((x > y) - (x < y)) - -/* addition, subtraction */ - -#define OP_FLOAT_ADD(x,y,r) r = x + y -#define OP_FLOAT_SUB(x,y,r) r = x - y -#define OP_FLOAT_MUL(x,y,r) r = x * y -#define OP_FLOAT_TRUEDIV(x,y,r) r = x / y -#define OP_FLOAT_POW(x,y,r) r = pow(x, y) - -/*** conversions ***/ - -#define OP_CAST_FLOAT_TO_INT(x,r) r = (long)(x) -#define OP_CAST_FLOAT_TO_UINT(x,r) r = (unsigned long)(x) -#define OP_CAST_INT_TO_FLOAT(x,r) r = (double)(x) -#define OP_CAST_UINT_TO_FLOAT(x,r) r = (double)(x) -#define OP_CAST_LONGLONG_TO_FLOAT(x,r) r = (double)(x) -#define OP_CAST_BOOL_TO_FLOAT(x,r) r = (double)(x) - -#ifdef HAVE_LONG_LONG -#define OP_CAST_FLOAT_TO_LONGLONG(x,r) r = (long long)(x) -#endif - -/* ================================================== support.h ========== */ - -#define RPyField(ptr, name) NULL - Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/pypy.h (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/pypy.h) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,48 +0,0 @@ -import unittest - -from api import func_hash - - -class Tests(unittest.TestCase): - - # These tests are very (Python) version specific. - - def test_simple(self): - - def f(x): - return 2.5 * x * x + 4.7 * x - - self.assertEqual(func_hash(f), - '5f12e97debf1d2cb9e0a2f92e045b1fb') - - - def test_extra(self): - - def f(x): - return 2.5 * x * x + 4.7 * x - - self.assertEqual(func_hash(f, salt=[(int, int), (float, float)]), - 'e637d9825ef20cb56d364041118ca72e') - - def test_const(self): - - def add_a(b): - return a + b # a in globals - - self.assertEqual(func_hash(add_a), - '9ff237f372bf233470ce940edd58f60d') - - def test_inner(self): - - def foo(x): - inner1 = lambda t: t/3.0 - def inner2(n): - return n + 3 - return inner1(x) + inner2(int(x)) - - self.assertEqual(func_hash(foo), - '814c113dfc77e7ebb52915dd3ce9c37a') - - -if __name__ == '__main__': - unittest.main() Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,255 +0,0 @@ -import math -import unittest - -from numpy import array, arange, allclose - -from api import Cfunc, genufunc, mkufunc - - -class Util: - - def assertClose(self, x, y): - self.assert_(allclose(x, y), '%s != %s' % (x, y)) - - -class Internal_Tests(unittest.TestCase, Util): - - def test_Cfunc(self): - def sqr(x): - return x * x - cf = Cfunc(sqr, [int, int], 42) - self.assertEqual(cf.nin, 1) - self.assertEqual(cf.nout, 1) - self.assertEqual(cf.cname, 'f42_pypy_g_sqr') - - def test_genufunc(self): - def foo(x): - return x + 17 - uf = genufunc(foo, [ - (float, float), - (int, int), - ]) - self.assertEqual(uf(4), 21) - x = array([1.1, 2.3]) - y = uf(x) - self.assertClose(y, [18.1, 19.3]) - self.assert_(str(y.dtype).startswith('float')) - - x = array([1, 4]) - y = uf(x) - self.assertEqual(list(y), [18, 21]) - self.assert_(str(y.dtype).startswith('int')) - - -class Arg_Tests(unittest.TestCase, Util): - - def check_ufunc(self, f): - for arg in (array([0.0, 1.0, 2.5]), - [0.0, 1.0, 2.5], - (0.0, 1.0, 2.5)): - self.assertClose(f(arg), [0.0, 1.0, 6.25]) - - self.assertEqual(f(3), 9) - self.assert_(f(-2.5) - 6.25 < 1E-10) - - def test_direct(self): - @mkufunc - def f(x): - return x * x - self.check_ufunc(f) - - def test_noargs(self): - @mkufunc() - def f(x): - return x * x - self.check_ufunc(f) - - def test_varargs(self): - for arg in (float, - [float], - [(float, float)]): - @mkufunc(arg) - def f(x): - return x * x - self.check_ufunc(f) - - def test_int(self): - @mkufunc(int) - def f(x): - return x * x - self.assertEqual(f(3), 9) - self.assert_(isinstance(f(42), int)) - - def test_mixed(self): - @mkufunc([(int, float, int), float]) - def f(n, x): - return n + x * x - - y = f(2, 3.9) # Note that int(2 + 3.9 * 3.9) = 17 - self.assertEqual(y, 17) - self.assert_(isinstance(y, int)) - - y = f(2.0, 3.9) - self.assertClose(y, 17.21) - self.assert_(isinstance(y, float)) - - def test_exceptions(self): - def f(x): - return x - - self.assertRaises(TypeError, mkufunc, {}) - self.assertRaises(TypeError, mkufunc([(float,)]), f) - self.assertRaises(TypeError, mkufunc([3*(float,)]), f) - self.assertRaises(TypeError, mkufunc([{}]), f) - self.assertRaises(TypeError, mkufunc([(int, {})]), f) - self.assertRaises(ValueError, mkufunc([]), f) - - -class Math_Tests(unittest.TestCase, Util): - - def assertFuncsEqual(self, uf, f): - x = 0.4376 - a = uf(x) - b = f(x) - self.assertClose(a, b) - xx = arange(0.1, 0.9, 0.01) - a = uf(xx) - b = [f(x) for x in xx] - self.assertClose(a, b) - - def test_exp(self): - @mkufunc - def f(x): return math.exp(x) - self.assertFuncsEqual(f, math.exp) - - def test_log(self): - @mkufunc - def f(x): return math.log(x) - self.assertFuncsEqual(f, math.log) - - def test_sqrt(self): - @mkufunc - def f(x): return math.sqrt(x) - self.assertFuncsEqual(f, math.sqrt) - - def test_cos(self): - @mkufunc - def f(x): return math.cos(x) - self.assertFuncsEqual(f, math.cos) - - def test_sin(self): - @mkufunc - def f(x): return math.sin(x) - self.assertFuncsEqual(f, math.sin) - - def test_tan(self): - @mkufunc - def f(x): return math.tan(x) - self.assertFuncsEqual(f, math.tan) - - def test_acos(self): - @mkufunc - def f(x): return math.acos(x) - self.assertFuncsEqual(f, math.acos) - - def test_asin(self): - @mkufunc - def f(x): return math.asin(x) - self.assertFuncsEqual(f, math.asin) - - def test_atan(self): - @mkufunc - def f(x): return math.atan(x) - self.assertFuncsEqual(f, math.atan) - - def test_atan2(self): - @mkufunc - def f(x, y): - return math.atan2(x, y) - - self.assertClose(f(4, 5), math.atan2(4, 5)) - - xx = array([1.0, 3.0, -2.4, 3.1, -2.3]) - yy = array([1.0, 2.0, 7.5, -8.7, 0.0]) - a = f(xx, yy) - b = [math.atan2(x, y) for x, y in zip(xx, yy)] - self.assertClose(a, b) - - def test_arithmetic(self): - def f(x): - return (4 * x + 2) / (x * x - 7 * x + 1) - uf = mkufunc(f) - x = arange(0, 2, 0.1) - self.assertClose(uf(x), f(x)) - - -class Control_Flow_Tests(unittest.TestCase): - - def test_if(self): - @mkufunc(int) - def f(n): - if n < 4: - return n - else: - return n * n - - self.assertEqual(f(3), 3) - self.assertEqual(f(4), 16) - - def test_switch(self): - @mkufunc(int) - def f(n): - if n < 4: - return n - elif n == 4: - return 42 - elif n == 5: - return 73 - else: - return n * n - - self.assertEqual(f(3), 3) - self.assertEqual(f(4), 42) - self.assertEqual(f(5), 73) - self.assertEqual(f(6), 36) - - def test_loop(self): - @mkufunc(int) - def f(n): - res = 0 - for i in xrange(n): - res += i*i - return res - - self.assertEqual(f(3), 5) - self.assertEqual(f(95), 281295) - - -class FreeVariable_Tests(unittest.TestCase, Util): - - def test_const(self): - a = 13.6 - @mkufunc - def f(x): - return a * x - - x = arange(0, 1, 0.1) - self.assertClose(f(x), a * x) - - def test_const2(self): - from math import sin, pi, sqrt - @mkufunc - def sin_deg(angle): - return sin(angle / 180.0 * pi) - - self.assertClose(sin_deg([0, 30, 45, 60, 90, 180, 270, 360]), - [0, 0.5, 1/sqrt(2), sqrt(3)/2, 1, 0, -1, 0]) - - -class Misc_Tests(unittest.TestCase, Util): - - pass - - -if __name__ == '__main__': - unittest.main() Copied: branches/refactor_fft/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py (from rev 4510, trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py) Deleted: branches/refactor_fft/scipy/sandbox/mkufunc/setup.py =================================================================== --- trunk/scipy/sandbox/mkufunc/setup.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sandbox/mkufunc/setup.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,15 +0,0 @@ -from setuptools import setup, find_packages - -setup( - author = 'Ilan Schnell', - author_email = 'ischnell at enthought.com', - description = 'C compiled UFuncs from python source', - - name = "mkufunc", - version = "0.1", - - zip_safe = False, - package_data = {'': ['*.h']}, - packages = find_packages(), - install_requires = ['scipy >= 0.6.0'] - ) Copied: branches/refactor_fft/scipy/sandbox/mkufunc/setup.py (from rev 4510, trunk/scipy/sandbox/mkufunc/setup.py) Modified: branches/refactor_fft/scipy/setup.py =================================================================== --- branches/refactor_fft/scipy/setup.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/setup.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -19,7 +19,6 @@ config.add_subpackage('signal') config.add_subpackage('sparse') config.add_subpackage('special') - config.add_subpackage('splinalg') config.add_subpackage('stats') config.add_subpackage('ndimage') config.add_subpackage('stsci') Modified: branches/refactor_fft/scipy/setupscons.py =================================================================== --- branches/refactor_fft/scipy/setupscons.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/setupscons.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -18,7 +18,6 @@ config.add_subpackage('signal') config.add_subpackage('sparse') config.add_subpackage('special') - config.add_subpackage('splinalg') config.add_subpackage('stats') config.add_subpackage('ndimage') config.add_subpackage('stsci') Copied: branches/refactor_fft/scipy/signal/SConscript (from rev 4510, trunk/scipy/signal/SConscript) Deleted: branches/refactor_fft/scipy/signal/SConstruct =================================================================== --- branches/refactor_fft/scipy/signal/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/signal/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,19 +0,0 @@ -# Last Change: Wed Mar 05 05:00 PM 2008 J -# vim:syntax=python -from os.path import join - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons 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/refactor_fft/scipy/signal/SConstruct (from rev 4510, trunk/scipy/signal/SConstruct) Modified: branches/refactor_fft/scipy/signal/signaltools.py =================================================================== --- branches/refactor_fft/scipy/signal/signaltools.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/signal/signaltools.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1446,3 +1446,35 @@ olddims = vals[:axis] + [0] + vals[axis:] ret = transpose(ret,tuple(olddims)) return ret + +def filtfilt(b,a,x): + # FIXME: For now only accepting 1d arrays + ntaps=max(len(a),len(b)) + edge=ntaps*3 + + if x.ndim != 1: + raise ValueError, "Filiflit is only accepting 1 dimension arrays." + + #x must be bigger than edge + if x.size < edge: + raise ValueError, "Input vector needs to be bigger than 3 * max(len(a),len(b)." + + if len(a) < ntaps: + a=r_[a,zeros(len(b)-len(a))] + + if len(b) < ntaps: + b=r_[b,zeros(len(a)-len(b))] + + zi=lfilter_zi(b,a) + + #Grow the signal to have edges for stabilizing + #the filter with inverted replicas of the signal + s=r_[2*x[0]-x[edge:1:-1],x,2*x[-1]-x[-1:-edge:-1]] + #in the case of one go we only need one of the extrems + # both are needed for filtfilt + + (y,zf)=lfilter(b,a,s,-1,zi*s[0]) + + (y,zf)=lfilter(b,a,flipud(y),-1,zi*y[-1]) + + return flipud(y[edge-1:-edge+1]) Copied: branches/refactor_fft/scipy/sparse/.svnignore (from rev 4510, trunk/scipy/sparse/.svnignore) Modified: branches/refactor_fft/scipy/sparse/base.py =================================================================== --- branches/refactor_fft/scipy/sparse/base.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/base.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -195,13 +195,14 @@ """Return this matrix in a given sparse format Parameters - ========== - - format : desired sparse matrix format - - If format is None then no conversion is performed - - Other possible values include: - - "csr" for csr_matrix format - - "csc" for csc_matrix format - - "dok" for dok_matrix format and so on + ---------- + format : {string, None} + desired sparse matrix format + - None for no format conversion + - "csr" for csr_matrix format + - "csc" for csc_matrix format + - "lil" for lil_matrix format + - "dok" for dok_matrix format and so on """ Modified: branches/refactor_fft/scipy/sparse/compressed.py =================================================================== --- branches/refactor_fft/scipy/sparse/compressed.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/compressed.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -251,11 +251,13 @@ def __truediv__(self,other): if isscalarlike(other): return self * (1./other) + elif isspmatrix(other): - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" + if other.shape != self.shape: + raise ValueError('inconsistent shapes') return self._binopt(other,'_eldiv_') + else: raise NotImplementedError @@ -263,11 +265,11 @@ def multiply(self, other): """Point-wise multiplication by another matrix """ - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" + if other.shape != self.shape: + raise ValueError('inconsistent shapes') if isdense(other): - return multiply(self.todense(),other) + return numpy.multiply(self.todense(),other) else: other = self.__class__(other) return self._binopt(other,'_elmul_') Modified: branches/refactor_fft/scipy/sparse/construct.py =================================================================== --- branches/refactor_fft/scipy/sparse/construct.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/construct.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -27,30 +27,32 @@ def spdiags(data, diags, m, n, format=None): - """Return a sparse matrix given its diagonals. + """Return a sparse matrix from diagonals. Parameters ---------- - - data : matrix whose rows contain the diagonal values - - diags : diagonals to set - - k = 0 - the main diagonal - - k > 0 - the k-th upper diagonal - - k < 0 - the k-th lower diagonal - - m, n : dimensions of the result - - format : format of the result (e.g. "csr") - - By default (format=None) an appropriate sparse matrix - format is returned. This choice is subject to change. + data : array_like + matrix diagonals stored row-wise + diags : diagonals to set + - k = 0 the main diagonal + - k > 0 the k-th upper diagonal + - k < 0 the k-th lower diagonal + m, n : int + shape of the result + format : format of the result (e.g. "csr") + By default (format=None) an appropriate sparse matrix + format is returned. This choice is subject to change. See Also -------- - The dia_matrix class which implements the DIAgonal format. + The dia_matrix class which implements the DIAgonal format. Example ------- - >>> data = array([[1,2,3,4]]).repeat(3,axis=0) + >>> data = array([[1,2,3,4],[1,2,3,4],[1,2,3,4]]) >>> diags = array([0,-1,2]) - >>> spdiags(data,diags,4,4).todense() + >>> spdiags(data, diags, 4, 4).todense() matrix([[1, 0, 3, 0], [1, 2, 0, 4], [0, 2, 3, 0], @@ -87,8 +89,12 @@ Parameters ---------- - A,B : dense or sparse matrices - format : format of the result (e.g. "csr") + A + matrix + B + matrix + format : string + format of the result (e.g. "csr") Returns ------- @@ -169,15 +175,19 @@ Parameters ---------- - A,B : square dense or sparse matrices - format : format of the result (e.g. "csr") + A + square matrix + B + square matrix + format : string + format of the result (e.g. "csr") Returns - ======= - kronecker sum in a sparse matrix format + ------- + kronecker sum in a sparse matrix format Examples - ======== + -------- """ @@ -206,7 +216,8 @@ blocks sequence of sparse matrices with compatible shapes - format : sparse format of the result (e.g. "csr") + format : string + sparse format of the result (e.g. "csr") by default an appropriate sparse matrix format is returned. This choice is subject to change. @@ -232,7 +243,8 @@ blocks sequence of sparse matrices with compatible shapes - format : sparse format of the result (e.g. "csr") + format : string + sparse format of the result (e.g. "csr") by default an appropriate sparse matrix format is returned. This choice is subject to change. Copied: branches/refactor_fft/scipy/sparse/linalg/dsolve/SConscript (from rev 4510, trunk/scipy/sparse/linalg/dsolve/SConscript) Deleted: branches/refactor_fft/scipy/sparse/linalg/dsolve/SConstruct =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/dsolve/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/dsolve/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,47 +0,0 @@ -from os.path import join as pjoin -import sys - -from numpy.distutils.misc_util import get_numpy_include_dirs - -from numscons import GetNumpyEnvironment -from numscons import CheckF77LAPACK -from numscons import write_info - -env = GetNumpyEnvironment(ARGUMENTS) - -#======================= -# Starting Configuration -#======================= -config = env.NumpyConfigure(custom_tests = {'CheckLapack' : CheckF77LAPACK}) - -#----------------- -# Checking Lapack -#----------------- -st = config.CheckLapack() -if not st: - raise RuntimeError("no lapack found, necessary for dsolve module") - -config.Finish() -write_info(env) - -# Build superlu lib -superlu_env = env.Clone() -superlu_def = {} -if sys.platform == 'win32': - superlu_def['NO_TIMER'] = 1 -superlu_def['USE_VENDOR_BLAS'] = 2 -superlu_env.Append(CPPDEFINES = superlu_def) - -superlu_src = superlu_env.NumpyGlob(pjoin('SuperLU', 'SRC', '*.c')) -superlu = superlu_env.NumpyStaticExtLibrary('superlu_src', source = superlu_src) - -# Build python extensions -pyenv = env.Clone() -pyenv.Append(CPPPATH = [get_numpy_include_dirs(), env['src_dir']]) -pyenv.Prepend(LIBS = superlu) -common_src = ['_superlu_utils.c', '_superluobject.c'] - -for prec in ['z', 'd', 'c', 's']: - pyenv.NumpyPythonExtension('_%ssuperlu' % prec, - source = common_src + \ - ['_%ssuperlumodule.c' % prec]) Copied: branches/refactor_fft/scipy/sparse/linalg/dsolve/SConstruct (from rev 4510, trunk/scipy/sparse/linalg/dsolve/SConstruct) Copied: branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConscript (from rev 4510, trunk/scipy/sparse/linalg/dsolve/umfpack/SConscript) Deleted: branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,35 +0,0 @@ -from os.path import join as pjoin - -from numpy.distutils.misc_util import get_numpy_include_dirs - -from numscons import GetNumpyEnvironment -from numscons import CheckF77BLAS, CheckF77Clib, NumpyCheckLibAndHeader -from numscons import write_info - -env = GetNumpyEnvironment(ARGUMENTS) - -#======================= -# Starting Configuration -#======================= -config = env.NumpyConfigure(custom_tests = - {'CheckBLAS' : CheckF77BLAS, - 'CheckF77Clib' : CheckF77Clib, - 'NumpyCheckLibAndHeader' : NumpyCheckLibAndHeader}) - -#----------------- -# Checking Lapack -#----------------- -st = config.CheckBLAS() -if not st: - raise RuntimeError("no blas found, necessary for umfpack module") - -has_umfpack = config.NumpyCheckLibAndHeader( - 'umfpack', None, 'umfpack.h', section = 'umfpack', autoadd = 1) -config.Finish() -write_info(env) - -if has_umfpack: - env.Append(SWIGFLAGS = '-python') - env.Append(SWIGFLAGS = '$_CPPINCFLAGS') - env.Append(CPPPATH = get_numpy_include_dirs()) - env.NumpyPythonExtension('__umfpack', source = 'umfpack.i') Copied: branches/refactor_fft/scipy/sparse/linalg/dsolve/umfpack/SConstruct (from rev 4510, trunk/scipy/sparse/linalg/dsolve/umfpack/SConstruct) Copied: branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConscript (from rev 4510, trunk/scipy/sparse/linalg/eigen/arpack/SConscript) Deleted: branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConstruct =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,47 +0,0 @@ -from os.path import join as pjoin - -from numpy.distutils.misc_util import get_numpy_include_dirs - -from numscons import GetNumpyEnvironment -from numscons import CheckF77LAPACK, CheckF77Clib -from numscons import write_info - -env = GetNumpyEnvironment(ARGUMENTS) - -#======================= -# Starting Configuration -#======================= -config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK, - 'CheckF77Clib' : CheckF77Clib}) - -env.Tool('numpyf2py') -#----------------- -# Checking Lapack -#----------------- -st = config.CheckF77Clib() -st = config.CheckLAPACK(autoadd = 1) -if not st: - raise RuntimeError("no lapack found, necessary for arpack module") - -config.Finish() -write_info(env) - -# Build arpack -arpack_src = env.NumpyGlob(pjoin('ARPACK', 'SRC', '*.f')) -arpack_src += env.NumpyGlob(pjoin('ARPACK', 'UTIL', '*.f')) -arpack_src += env.NumpyGlob(pjoin('ARPACK', 'LAPACK', '*.f')) - -src = [str(s) for s in arpack_src] - -env.AppendUnique(CPPPATH = pjoin('ARPACK', 'SRC')) -env.AppendUnique(F77PATH = pjoin(env['src_dir'], 'ARPACK', 'SRC')) -env.AppendUnique(LIBPATH = env['build_dir']) -arpack_lib = env.NumpyStaticExtLibrary('arpack', source = src) - -# Build _arpack extension -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) - -env.NumpyFromFTemplate('arpack.pyf', 'arpack.pyf.src') -env.Prepend(LIBS = 'arpack') -env.NumpyPythonExtension('_arpack', 'arpack.pyf') Copied: branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/SConstruct (from rev 4510, trunk/scipy/sparse/linalg/eigen/arpack/SConstruct) Modified: branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/arpack.py =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/arpack.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/arpack.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -62,7 +62,7 @@ Parameters ---------- - A : A : matrix, array, or object with matvec(x) method + A : matrix, array, or object with matvec(x) method An N x N matrix, array, or an object with matvec(x) method to perform the matrix vector product A * x. The sparse matrix formats in scipy.sparse are appropriate for A. @@ -76,8 +76,8 @@ Array of k eigenvalues v : array - An array of k eigenvectors - The v[i] is the eigenvector corresponding to the eigenvector w[i] + An array of k eigenvectors + The v[i] is the eigenvector corresponding to the eigenvector w[i] Other Parameters ---------------- @@ -460,12 +460,16 @@ else: break - if info < -1 : - raise RuntimeError("Error info=%d in arpack"%info) + if info < -1 : + raise RuntimeError("Error info=%d in arpack" % info) return None - if info == -1: - warnings.warn("Maximum number of iterations taken: %s"%iparam[2]) + if info == 1: + warnings.warn("Maximum number of iterations taken: %s" % iparam[2]) + + if iparam[4] < k: + warnings.warn("Only %d/%d eigenvectors converged" % (iparam[4], k)) + # now extract eigenvalues and (optionally) eigenvectors rvec = return_eigenvectors ierr = 0 Modified: branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/speigs.py =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/speigs.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/eigen/arpack/speigs.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -191,7 +191,7 @@ def ARPACK_iteration(matvec, sigma_solve, n, bmat, which, nev, tol, ncv, mode): ncv, maxitr = check_init(n, nev, ncv) ipntr, d, resid, workd, workl, v = init_workspaces(n,nev,ncv) - init_debug() + #init_debug() ishfts = 1 # Some random arpack parameter # Some random arpack parameter (I think it tells ARPACK to solve the # general eigenproblem using shift-invert Modified: branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -5,20 +5,20 @@ License: BSD -(c) Robert Cimrman, Andrew Knyazev +Authors: Robert Cimrman, Andrew Knyazev Examples in tests directory contributed by Nils Wagner. """ -import types from warnings import warn -import numpy as nm -import scipy as sc -import scipy.sparse as sp -import scipy.io as io +import numpy as np +import scipy as sp + from scipy.sparse.linalg import aslinearoperator, LinearOperator +__all__ = ['lobpcg'] + ## try: ## from symeig import symeig ## except: @@ -28,7 +28,7 @@ import scipy.linalg as sla import scipy.lib.lapack as ll if select is None: - if nm.iscomplexobj( mtxA ): + if np.iscomplexobj( mtxA ): if mtxB is None: fun = ll.get_lapack_funcs( ['heev'], arrays = (mtxA,) )[0] else: @@ -51,7 +51,7 @@ else: out = sla.eig( mtxA, mtxB, right = eigenvectors ) w = out[0] - ii = nm.argsort( w ) + ii = np.argsort( w ) w = w[slice( *select )] if eigenvectors: v = out[1][:,ii] @@ -66,7 +66,8 @@ raw_input() def save( ar, fileName ): - io.write_array( fileName, ar, precision = 8 ) + from scipy.io import write_array + write_array( fileName, ar, precision = 8 ) ## # 21.05.2007, c @@ -78,7 +79,7 @@ if ar.ndim == 2: return ar else: # Assume 1! - aux = nm.array( ar, copy = False ) + aux = np.array( ar, copy = False ) aux.shape = (ar.shape[0], 1) return aux @@ -90,8 +91,9 @@ Example ------- - A = makeOperator( arrayA, (n, n) ) - vectorB = A( vectorX ) + >>> A = makeOperator( arrayA, (n, n) ) + >>> vectorB = A( vectorX ) + """ if operatorInput is None: def ident(x): @@ -111,10 +113,10 @@ def applyConstraints( blockVectorV, factYBY, blockVectorBY, blockVectorY ): """Internal. Changes blockVectorV in place.""" - gramYBV = sc.dot( blockVectorBY.T, blockVectorV ) + gramYBV = sp.dot( blockVectorBY.T, blockVectorV ) import scipy.linalg as sla tmp = sla.cho_solve( factYBY, gramYBV ) - blockVectorV -= sc.dot( blockVectorY, tmp ) + blockVectorV -= sp.dot( blockVectorY, tmp ) def b_orthonormalize( B, blockVectorV, @@ -126,22 +128,22 @@ blockVectorBV = B( blockVectorV ) else: blockVectorBV = blockVectorV # Shared data!!! - gramVBV = sc.dot( blockVectorV.T, blockVectorBV ) + gramVBV = sp.dot( blockVectorV.T, blockVectorBV ) gramVBV = sla.cholesky( gramVBV ) sla.inv( gramVBV, overwrite_a = True ) # gramVBV is now R^{-1}. - blockVectorV = sc.dot( blockVectorV, gramVBV ) + blockVectorV = sp.dot( blockVectorV, gramVBV ) if B is not None: - blockVectorBV = sc.dot( blockVectorBV, gramVBV ) + blockVectorBV = sp.dot( blockVectorBV, gramVBV ) if retInvR: return blockVectorV, blockVectorBV, gramVBV else: return blockVectorV, blockVectorBV -def lobpcg( blockVectorX, A, - B = None, M = None, blockVectorY = None, - residualTolerance = None, maxIterations = 20, +def lobpcg( A, X, + B=None, M=None, Y=None, + tol= None, maxiter=20, largest = True, verbosityLevel = 0, retLambdaHistory = False, retResidualNormsHistory = False ): """Solve symmetric partial eigenproblems with optional preconditioning @@ -149,23 +151,24 @@ This function implements the Locally Optimal Block Preconditioned Conjugate Gradient Method (LOBPCG). - TODO write in terms of Ax=lambda B x - + Parameters ---------- - blockVectorX : array_like - initial approximation to eigenvectors shape=(n,blockSize) - A : {dense matrix, sparse matrix, LinearOperator} - the linear operator of the problem, usually a sparse matrix - often called the "stiffness matrix" + A : {sparse matrix, dense matrix, LinearOperator} + The symmetric linear operator of the problem, usually a + sparse matrix. Often called the "stiffness matrix". + X : array_like + Initial approximation to the k eigenvectors. If A has + shape=(n,n) then X should have shape shape=(n,k). Returns ------- - (lambda,blockVectorV) : tuple of arrays - blockVectorX and lambda are computed blockSize eigenpairs, where - blockSize=size(blockVectorX,2) for the initial guess blockVectorX - if it is full rank. + w : array + Array of k eigenvalues + v : array + An array of k eigenvectors. V has the same shape as X. + Optional Parameters ------------------- B : {dense matrix, sparse matrix, LinearOperator} @@ -175,18 +178,19 @@ M : {dense matrix, sparse matrix, LinearOperator} preconditioner to A; by default M = Identity M should approximate the inverse of A - blockVectorY : array_like + Y : array_like n-by-sizeY matrix of constraints, sizeY < n The iterations will be performed in the B-orthogonal complement - of the column-space of blockVectorY. blockVectorY must be full rank. + of the column-space of Y. Y must be full rank. Other Parameters ---------------- - residualTolerance : scalar - solver tolerance. default: residualTolerance=n*sqrt(eps) - maxIterations: integer + tol : scalar + Solver tolerance (stopping criterion) + by default: tol=n*sqrt(eps) + maxiter: integer maximum number of iterations - by default: maxIterations=min(n,20) + by default: maxiter=min(n,20) largest : boolean when True, solve for the largest eigenvalues, otherwise the smallest verbosityLevel : integer @@ -200,13 +204,18 @@ Notes ----- If both retLambdaHistory and retResidualNormsHistory are True, the - return tuple has the following format: - (lambda, blockVectorV, lambda history, residual norms history) + return tuple has the following format + (lambda, V, lambda history, residual norms history) """ failureFlag = True import scipy.linalg as sla + blockVectorX = X + blockVectorY = Y + residualTolerance = tol + maxIterations = maxiter + if blockVectorY is not None: sizeY = blockVectorY.shape[1] else: @@ -214,11 +223,11 @@ # Block size. if len(blockVectorX.shape) != 2: - raise ValueError('expected rank-2 array for argument blockVectorX') + raise ValueError('expected rank-2 array for argument X') n, sizeX = blockVectorX.shape if sizeX > n: - raise ValueError('blockVectorX column dimension exceeds the row dimension') + raise ValueError('X column dimension exceeds the row dimension') A = makeOperator(A, (n,n)) B = makeOperator(B, (n,n)) @@ -236,10 +245,10 @@ else: lohi = (1, sizeX) - A_dense = A(nm.eye(n)) + A_dense = A(np.eye(n)) if B is not None: - B_dense = B(nm.eye(n)) + B_dense = B(np.eye(n)) _lambda, eigBlockVector = symeig(A_dense, B_dense, select=lohi ) else: _lambda, eigBlockVector = symeig(A_dense, select=lohi ) @@ -248,7 +257,7 @@ if residualTolerance is None: - residualTolerance = nm.sqrt( 1e-15 ) * n + residualTolerance = np.sqrt( 1e-15 ) * n maxIterations = min( n, maxIterations ) @@ -283,7 +292,7 @@ blockVectorBY = blockVectorY # gramYBY is a dense array. - gramYBY = sc.dot( blockVectorY.T, blockVectorBY ) + gramYBY = sp.dot( blockVectorY.T, blockVectorBY ) try: # gramYBY is a Cholesky factor from now on... gramYBY = sla.cho_factor( gramYBY ) @@ -299,32 +308,32 @@ ## # Compute the initial Ritz vectors: solve the eigenproblem. blockVectorAX = A( blockVectorX ) - gramXAX = sc.dot( blockVectorX.T, blockVectorAX ) + gramXAX = sp.dot( blockVectorX.T, blockVectorAX ) # gramXBX is X^T * X. - gramXBX = sc.dot( blockVectorX.T, blockVectorX ) + gramXBX = sp.dot( blockVectorX.T, blockVectorX ) _lambda, eigBlockVector = symeig( gramXAX ) - ii = nm.argsort( _lambda )[:sizeX] + ii = np.argsort( _lambda )[:sizeX] if largest: ii = ii[::-1] _lambda = _lambda[ii] - eigBlockVector = nm.asarray( eigBlockVector[:,ii] ) - blockVectorX = sc.dot( blockVectorX, eigBlockVector ) - blockVectorAX = sc.dot( blockVectorAX, eigBlockVector ) + eigBlockVector = np.asarray( eigBlockVector[:,ii] ) + blockVectorX = sp.dot( blockVectorX, eigBlockVector ) + blockVectorAX = sp.dot( blockVectorAX, eigBlockVector ) if B is not None: - blockVectorBX = sc.dot( blockVectorBX, eigBlockVector ) + blockVectorBX = sp.dot( blockVectorBX, eigBlockVector ) ## # Active index set. - activeMask = nm.ones( (sizeX,), dtype = nm.bool ) + activeMask = np.ones( (sizeX,), dtype = np.bool ) lambdaHistory = [_lambda] residualNormsHistory = [] previousBlockSize = sizeX - ident = nm.eye( sizeX, dtype = A.dtype ) - ident0 = nm.eye( sizeX, dtype = A.dtype ) + ident = np.eye( sizeX, dtype = A.dtype ) + ident0 = np.eye( sizeX, dtype = A.dtype ) ## # Main iteration loop. @@ -332,15 +341,15 @@ if verbosityLevel > 0: print 'iteration %d' % iterationNumber - aux = blockVectorBX * _lambda[nm.newaxis,:] + aux = blockVectorBX * _lambda[np.newaxis,:] blockVectorR = blockVectorAX - aux - aux = nm.sum( blockVectorR.conjugate() * blockVectorR, 0 ) - residualNorms = nm.sqrt( aux ) + aux = np.sum( blockVectorR.conjugate() * blockVectorR, 0 ) + residualNorms = np.sqrt( aux ) residualNormsHistory.append( residualNorms ) - ii = nm.where( residualNorms > residualTolerance, True, False ) + ii = np.where( residualNorms > residualTolerance, True, False ) activeMask = activeMask & ii if verbosityLevel > 2: print activeMask @@ -348,7 +357,7 @@ currentBlockSize = activeMask.sum() if currentBlockSize != previousBlockSize: previousBlockSize = currentBlockSize - ident = nm.eye( currentBlockSize, dtype = A.dtype ) + ident = np.eye( currentBlockSize, dtype = A.dtype ) if currentBlockSize == 0: failureFlag = False # All eigenpairs converged. @@ -390,44 +399,44 @@ aux = b_orthonormalize( B, activeBlockVectorP, activeBlockVectorBP, retInvR = True ) activeBlockVectorP, activeBlockVectorBP, invR = aux - activeBlockVectorAP = sc.dot( activeBlockVectorAP, invR ) + activeBlockVectorAP = sp.dot( activeBlockVectorAP, invR ) ## # Perform the Rayleigh Ritz Procedure: # Compute symmetric Gram matrices: - xaw = sc.dot( blockVectorX.T, activeBlockVectorAR ) - waw = sc.dot( activeBlockVectorR.T, activeBlockVectorAR ) - xbw = sc.dot( blockVectorX.T, activeBlockVectorBR ) + xaw = sp.dot( blockVectorX.T, activeBlockVectorAR ) + waw = sp.dot( activeBlockVectorR.T, activeBlockVectorAR ) + xbw = sp.dot( blockVectorX.T, activeBlockVectorBR ) if iterationNumber > 0: - xap = sc.dot( blockVectorX.T, activeBlockVectorAP ) - wap = sc.dot( activeBlockVectorR.T, activeBlockVectorAP ) - pap = sc.dot( activeBlockVectorP.T, activeBlockVectorAP ) - xbp = sc.dot( blockVectorX.T, activeBlockVectorBP ) - wbp = sc.dot( activeBlockVectorR.T, activeBlockVectorBP ) + xap = sp.dot( blockVectorX.T, activeBlockVectorAP ) + wap = sp.dot( activeBlockVectorR.T, activeBlockVectorAP ) + pap = sp.dot( activeBlockVectorP.T, activeBlockVectorAP ) + xbp = sp.dot( blockVectorX.T, activeBlockVectorBP ) + wbp = sp.dot( activeBlockVectorR.T, activeBlockVectorBP ) - gramA = nm.bmat( [[nm.diag( _lambda ), xaw, xap], + gramA = np.bmat( [[np.diag( _lambda ), xaw, xap], [ xaw.T, waw, wap], [ xap.T, wap.T, pap]] ) - gramB = nm.bmat( [[ident0, xbw, xbp], + gramB = np.bmat( [[ident0, xbw, xbp], [ xbw.T, ident, wbp], [ xbp.T, wbp.T, ident]] ) else: - gramA = nm.bmat( [[nm.diag( _lambda ), xaw], + gramA = np.bmat( [[np.diag( _lambda ), xaw], [ xaw.T, waw]] ) - gramB = nm.bmat( [[ident0, xbw], + gramB = np.bmat( [[ident0, xbw], [ xbw.T, ident]] ) try: - assert nm.allclose( gramA.T, gramA ) + assert np.allclose( gramA.T, gramA ) except: print gramA.T - gramA raise try: - assert nm.allclose( gramB.T, gramB ) + assert np.allclose( gramB.T, gramB ) except: print gramB.T - gramB raise @@ -440,23 +449,23 @@ # Solve the generalized eigenvalue problem. # _lambda, eigBlockVector = la.eig( gramA, gramB ) _lambda, eigBlockVector = symeig( gramA, gramB ) - ii = nm.argsort( _lambda )[:sizeX] + ii = np.argsort( _lambda )[:sizeX] if largest: ii = ii[::-1] if verbosityLevel > 10: print ii - _lambda = _lambda[ii].astype( nm.float64 ) - eigBlockVector = nm.asarray( eigBlockVector[:,ii].astype( nm.float64 ) ) + _lambda = _lambda[ii].astype( np.float64 ) + eigBlockVector = np.asarray( eigBlockVector[:,ii].astype( np.float64 ) ) lambdaHistory.append( _lambda ) if verbosityLevel > 10: print 'lambda:', _lambda ## # Normalize eigenvectors! -## aux = nm.sum( eigBlockVector.conjugate() * eigBlockVector, 0 ) -## eigVecNorms = nm.sqrt( aux ) -## eigBlockVector = eigBlockVector / eigVecNorms[nm.newaxis,:] +## aux = np.sum( eigBlockVector.conjugate() * eigBlockVector, 0 ) +## eigVecNorms = np.sqrt( aux ) +## eigBlockVector = eigBlockVector / eigVecNorms[np.newaxis,:] # eigBlockVector, aux = b_orthonormalize( B, eigBlockVector ) if verbosityLevel > 10: @@ -470,21 +479,21 @@ eigBlockVectorR = eigBlockVector[sizeX:sizeX+currentBlockSize] eigBlockVectorP = eigBlockVector[sizeX+currentBlockSize:] - pp = sc.dot( activeBlockVectorR, eigBlockVectorR ) - pp += sc.dot( activeBlockVectorP, eigBlockVectorP ) + pp = sp.dot( activeBlockVectorR, eigBlockVectorR ) + pp += sp.dot( activeBlockVectorP, eigBlockVectorP ) - app = sc.dot( activeBlockVectorAR, eigBlockVectorR ) - app += sc.dot( activeBlockVectorAP, eigBlockVectorP ) + app = sp.dot( activeBlockVectorAR, eigBlockVectorR ) + app += sp.dot( activeBlockVectorAP, eigBlockVectorP ) - bpp = sc.dot( activeBlockVectorBR, eigBlockVectorR ) - bpp += sc.dot( activeBlockVectorBP, eigBlockVectorP ) + bpp = sp.dot( activeBlockVectorBR, eigBlockVectorR ) + bpp += sp.dot( activeBlockVectorBP, eigBlockVectorP ) else: eigBlockVectorX = eigBlockVector[:sizeX] eigBlockVectorR = eigBlockVector[sizeX:] - pp = sc.dot( activeBlockVectorR, eigBlockVectorR ) - app = sc.dot( activeBlockVectorAR, eigBlockVectorR ) - bpp = sc.dot( activeBlockVectorBR, eigBlockVectorR ) + pp = sp.dot( activeBlockVectorR, eigBlockVectorR ) + app = sp.dot( activeBlockVectorAR, eigBlockVectorR ) + bpp = sp.dot( activeBlockVectorBR, eigBlockVectorR ) if verbosityLevel > 10: print pp @@ -492,17 +501,17 @@ print bpp pause() - blockVectorX = sc.dot( blockVectorX, eigBlockVectorX ) + pp - blockVectorAX = sc.dot( blockVectorAX, eigBlockVectorX ) + app - blockVectorBX = sc.dot( blockVectorBX, eigBlockVectorX ) + bpp + blockVectorX = sp.dot( blockVectorX, eigBlockVectorX ) + pp + blockVectorAX = sp.dot( blockVectorAX, eigBlockVectorX ) + app + blockVectorBX = sp.dot( blockVectorBX, eigBlockVectorX ) + bpp blockVectorP, blockVectorAP, blockVectorBP = pp, app, bpp - aux = blockVectorBX * _lambda[nm.newaxis,:] + aux = blockVectorBX * _lambda[np.newaxis,:] blockVectorR = blockVectorAX - aux - aux = nm.sum( blockVectorR.conjugate() * blockVectorR, 0 ) - residualNorms = nm.sqrt( aux ) + aux = np.sum( blockVectorR.conjugate() * blockVectorR, 0 ) + residualNorms = np.sqrt( aux ) if verbosityLevel > 0: @@ -522,31 +531,31 @@ ########################################################################### if __name__ == '__main__': - from scipy.sparse import spdiags, speye + from scipy.sparse import spdiags, speye, issparse import time ## def B( vec ): ## return vec n = 100 - vals = [nm.arange( n, dtype = nm.float64 ) + 1] + vals = [np.arange( n, dtype = np.float64 ) + 1] A = spdiags( vals, 0, n, n ) B = speye( n, n ) # B[0,0] = 0 - B = nm.eye( n, n ) - Y = nm.eye( n, 3 ) + B = np.eye( n, n ) + Y = np.eye( n, 3 ) -# X = sc.rand( n, 3 ) +# X = sp.rand( n, 3 ) xfile = {100 : 'X.txt', 1000 : 'X2.txt', 10000 : 'X3.txt'} - X = nm.fromfile( xfile[n], dtype = nm.float64, sep = ' ' ) + X = np.fromfile( xfile[n], dtype = np.float64, sep = ' ' ) X.shape = (n, 3) ivals = [1./vals[0]] def precond( x ): invA = spdiags( ivals, 0, n, n ) y = invA * x - if sp.issparse( y ): + if issparse( y ): y = y.toarray() return as2d( y ) Modified: branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env pytho n """ Test functions for the sparse.linalg.eigen.lobpcg module """ @@ -8,7 +8,7 @@ from scipy import array, arange, ones, sort, cos, pi, rand, \ set_printoptions, r_, diag, linalg from scipy.linalg import eig -from scipy.sparse.linalg.eigen import lobpcg +from scipy.sparse.linalg.eigen.lobpcg import lobpcg set_printoptions(precision=3,linewidth=90) @@ -47,7 +47,7 @@ V = rand(n,m) X = linalg.orth(V) - eigs,vecs = lobpcg.lobpcg(X,A,B,residualTolerance=1e-5, maxIterations=30) + eigs,vecs = lobpcg(A, X, B=B, tol=1e-5, maxiter=30) eigs.sort() #w,v = symeig(A,B) Copied: branches/refactor_fft/scipy/sparse/linalg/isolve/SConscript (from rev 4510, trunk/scipy/sparse/linalg/isolve/SConscript) Deleted: branches/refactor_fft/scipy/sparse/linalg/isolve/SConstruct =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/isolve/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/isolve/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,58 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 J -# vim:syntax=python - -from os.path import join as pjoin, splitext - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment -from numscons import CheckF77LAPACK - -from numscons import write_info - -env = GetNumpyEnvironment(ARGUMENTS) -env.Tool('numpyf2py') -env.Append(CPPPATH = [get_numpy_include_dirs(), env['F2PYINCLUDEDIR']]) -#if os.name == 'nt': -# # NT needs the pythonlib to run any code importing Python.h, including -# # 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: - raise RuntimeError("no lapack found, necessary for isolve module") - -config.Finish() -write_info(env) - -#-------------------- -# 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) Copied: branches/refactor_fft/scipy/sparse/linalg/isolve/SConstruct (from rev 4510, trunk/scipy/sparse/linalg/isolve/SConstruct) Modified: branches/refactor_fft/scipy/sparse/linalg/isolve/utils.py =================================================================== --- branches/refactor_fft/scipy/sparse/linalg/isolve/utils.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/linalg/isolve/utils.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,3 +1,7 @@ +__docformat__ = "restructuredtext en" + +__all__ = [] + from warnings import warn from numpy import asanyarray, asarray, asmatrix, array, matrix, zeros @@ -24,27 +28,34 @@ def make_system(A, M, x0, b, xtype=None): """Make a linear system Ax=b - Parameters: - A - LinearOperator - - sparse or dense matrix (or any valid input to aslinearoperator) - M - LinearOperator or None - - preconditioner - - sparse or dense matrix (or any valid input to aslinearoperator) - x0 - array_like or None - - initial guess to iterative method - b - array_like - - right hand side - xtype - None or one of 'fdFD' - - dtype of the x vector + Parameters + ---------- + A : LinearOperator + sparse or dense matrix (or any valid input to aslinearoperator) + M : {LinearOperator, Nones} + preconditioner + sparse or dense matrix (or any valid input to aslinearoperator) + x0 : {array_like, None} + initial guess to iterative method + b : array_like + right hand side + xtype : {'f', 'd', 'F', 'D', None} + dtype of the x vector - Returns: - (A, M, x, b, postprocess) where: - - A is a LinearOperator - - M is a LinearOperator - - x is the initial guess (rank 1 array) - - b is the rhs (rank 1 array) - - postprocess is a function that converts the solution vector - to the appropriate type and dimensions (e.g. (N,1) matrix) + Returns + ------- + (A, M, x, b, postprocess) + A : LinearOperator + matrix of the linear system + M : LinearOperator + preconditioner + x : rank 1 ndarray + initial guess + b : rank 1 ndarray + right hand side + postprocess : function + converts the solution vector to the appropriate + type and dimensions (e.g. (N,1) matrix) """ A_ = A Copied: branches/refactor_fft/scipy/sparse/sparsetools/SConscript (from rev 4510, trunk/scipy/sparse/sparsetools/SConscript) Deleted: branches/refactor_fft/scipy/sparse/sparsetools/SConstruct =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/sparsetools/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,12 +0,0 @@ -# Last Change: Wed Mar 05 09:00 PM 2008 J -# vim:syntax=python -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment - -env = GetNumpyEnvironment(ARGUMENTS) - -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) - -for fmt in ['csr','csc','coo','bsr','dia']: - sources = [ fmt + '_wrap.cxx' ] - env.NumpyPythonExtension('_%s' % fmt, source = sources) Copied: branches/refactor_fft/scipy/sparse/sparsetools/SConstruct (from rev 4510, trunk/scipy/sparse/sparsetools/SConstruct) Modified: branches/refactor_fft/scipy/sparse/sparsetools/coo.h =================================================================== --- branches/refactor_fft/scipy/sparse/sparsetools/coo.h 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/sparsetools/coo.h 2008-07-01 04:52:00 UTC (rev 4511) @@ -116,5 +116,37 @@ } +/* + * Compute Y += A*X for COO matrix A and dense vectors X,Y + * + * + * Input Arguments: + * I nnz - number of nonzeros in A + * I Ai[nnz] - row indices + * I Aj[nnz] - column indices + * T Ax[nnz] - nonzero values + * T Xx[n_col] - input vector + * + * Output Arguments: + * T Yx[n_row] - output vector + * + * Notes: + * Output array Yx must be preallocated + * + * Complexity: Linear. Specifically O(nnz(A)) + * + */ +template +void coo_matvec(const I nnz, + const I Ai[], + const I Aj[], + const T Ax[], + const T Xx[], + T Yx[]) +{ + for(I n = 0; n < nnz; n++){ + Yx[Ai[n]] += Ax[n] * Xx[Aj[n]]; + } +} #endif Modified: branches/refactor_fft/scipy/sparse/tests/test_base.py =================================================================== --- branches/refactor_fft/scipy/sparse/tests/test_base.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/sparse/tests/test_base.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -215,19 +215,27 @@ assert_array_equal(self.datsp - A.todense(),self.dat - A.todense()) def test_elmul(self): - temp = self.dat.copy() - temp[0,2] = 2.0 - temp = self.spmatrix(temp) - c = temp.multiply(self.datsp) - assert_array_equal(c.todense(),[[1,0,0,4],[9,0,1,0],[0,4,0,0]]) - - # complex - A = array([[1-2j,0+5j,-1+0j],[4-3j,-3+6j,5]]) - B = array([[5+2j,7-3j,-2+1j],[0-1j,-4+2j,9]]) + # real/real + A = array([[4,0,9],[2,-3,5]]) + B = array([[0,7,0],[0,-4,0]]) Asp = self.spmatrix(A) Bsp = self.spmatrix(B) - assert_almost_equal( Asp.multiply(Bsp).todense(), A*B) + assert_almost_equal( Asp.multiply(Bsp).todense(), A*B) #sparse/sparse + assert_almost_equal( Asp.multiply(B), A*B) #sparse/dense + # complex/complex + C = array([[1-2j,0+5j,-1+0j],[4-3j,-3+6j,5]]) + D = array([[5+2j,7-3j,-2+1j],[0-1j,-4+2j,9]]) + Csp = self.spmatrix(C) + Dsp = self.spmatrix(D) + assert_almost_equal( Csp.multiply(Dsp).todense(), C*D) #sparse/sparse + assert_almost_equal( Csp.multiply(D), C*D) #sparse/dense + + # real/complex + assert_almost_equal( Asp.multiply(Dsp).todense(), A*D) #sparse/sparse + assert_almost_equal( Asp.multiply(D), A*D) #sparse/dense + + def test_eldiv(self): expected = [[1,0,0,1],[1,0,1,0],[0,1,0,0]] assert_array_equal((self.datsp / self.datsp).todense(),expected) Copied: branches/refactor_fft/scipy/special/SConscript (from rev 4510, trunk/scipy/special/SConscript) Deleted: branches/refactor_fft/scipy/special/SConstruct =================================================================== --- branches/refactor_fft/scipy/special/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/special/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,65 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 J -# vim:syntax=python -from os.path import join as pjoin, basename as pbasename -import sys - -from distutils.sysconfig import get_python_inc - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment -from numscons import CheckF77Clib - -env = GetNumpyEnvironment(ARGUMENTS) - -env.Tool('numpyf2py') - -env.AppendUnique(CPPPATH = [get_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') - -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""" - if not libname: - libname = name - src = env.NumpyGlob(pjoin(name, '*%s' % ext)) - assert len(src) > 0 - env.NumpyStaticExtLibrary(libname, source = 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('cdflib', '.f', 'cdf') -build_lib('specfun', '.f', 'specfunlib') - -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', 'specfunlib'], - LINKFLAGSEND = env['F77_LDFLAGS']) - -# Specfun extension -env.Prepend(LIBS = ['specfunlib']) -env.NumpyPythonExtension('specfun', source = 'specfun.pyf', - F2PYOPTIONS = ["--no-wrap-functions"], - LINKFLAGSEND = env['F77_LDFLAGS']) Copied: branches/refactor_fft/scipy/special/SConstruct (from rev 4510, trunk/scipy/special/SConstruct) Modified: branches/refactor_fft/scipy/special/_cephesmodule.c =================================================================== --- branches/refactor_fft/scipy/special/_cephesmodule.c 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/special/_cephesmodule.c 2008-07-01 04:52:00 UTC (rev 4511) @@ -108,7 +108,7 @@ static void * gdtri_data[] = { (void *)gdtri, (void *)gdtri, }; */ static void * hyp2f1_data[] = { (void *)hyp2f1, (void *)hyp2f1, (void *)chyp2f1_wrap, (void *)chyp2f1_wrap}; -static void * hyperg_data[] = { (void *)hyperg, (void *)hyperg, (void *)chyp1f1_wrap, (void *)chyp1f1_wrap}; +static void * hyp1f1_data[] = { (void *)hyp1f1_wrap, (void *)hyp1f1_wrap, (void *)chyp1f1_wrap, (void *)chyp1f1_wrap}; static void * hypU_data[] = { (void *)hypU_wrap, (void *)hypU_wrap, }; static void * hyp2f0_data[] = { (void *)hyp2f0, (void *)hyp2f0, }; static void * threef0_data[] = { (void *)threef0, (void *)threef0, }; @@ -441,7 +441,7 @@ f = PyUFunc_FromFuncAndData(cephes4_functions, hyp2f1_data, cephes_5c2_types, 4, 4, 1, PyUFunc_None, "hyp2f1", hyp2f1_doc, 0); PyDict_SetItemString(dictionary, "hyp2f1", f); Py_DECREF(f); - f = PyUFunc_FromFuncAndData(cephes3_functions, hyperg_data, cephes_4c_types, 4, 3, 1, PyUFunc_None, "hyp1f1", hyp1f1_doc, 0); + f = PyUFunc_FromFuncAndData(cephes3_functions, hyp1f1_data, cephes_4c_types, 4, 3, 1, PyUFunc_None, "hyp1f1", hyp1f1_doc, 0); PyDict_SetItemString(dictionary, "hyp1f1", f); Py_DECREF(f); Modified: branches/refactor_fft/scipy/special/specfun.pyf =================================================================== --- branches/refactor_fft/scipy/special/specfun.pyf 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/special/specfun.pyf 2008-07-01 04:52:00 UTC (rev 4511) @@ -242,7 +242,12 @@ ! eix ! e1xb - ! chgm + subroutine chgm(a,b,x,hg) ! in :specfun:specfun.f + double precision intent(in) :: a + double precision intent(in) :: b + double precision intent(in) :: x + double precision intent(out) :: hg + end subroutine chgm ! stvh0 Modified: branches/refactor_fft/scipy/special/specfun_wrappers.c =================================================================== --- branches/refactor_fft/scipy/special/specfun_wrappers.c 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/special/specfun_wrappers.c 2008-07-01 04:52:00 UTC (rev 4511) @@ -29,6 +29,7 @@ extern void F_FUNC(cpsi,CPSI)(double*,double*,double*,double*); extern void F_FUNC(hygfz,HYGFZ)(double*,double*,double*,Py_complex*,Py_complex*); extern void F_FUNC(cchg,CCHG)(double*,double*,Py_complex*,Py_complex*); +extern void F_FUNC(chgm,CHGM)(double*,double*,double*,double*); extern void F_FUNC(chgu,CHGU)(double*,double*,double*,double*,int*); extern void F_FUNC(itairy,ITAIRY)(double*,double*,double*,double*,double*); extern void F_FUNC(e1xb,E1XB)(double*,double*); @@ -147,6 +148,15 @@ } +double hyp1f1_wrap(double a, double b, double x) { + double outy; + + F_FUNC(chgm,CHGM)(&a, &b, &x, &outy); + if (outy == 1e300) { + outy = INFINITY; + } + return outy; +} int itairy_wrap(double x, double *apt, double *bpt, double *ant, double *bnt) { double tmp; Modified: branches/refactor_fft/scipy/special/specfun_wrappers.h =================================================================== --- branches/refactor_fft/scipy/special/specfun_wrappers.h 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/special/specfun_wrappers.h 2008-07-01 04:52:00 UTC (rev 4511) @@ -31,6 +31,7 @@ Py_complex crgamma_wrap( Py_complex z); Py_complex chyp2f1_wrap( double a, double b, double c, Py_complex z); Py_complex chyp1f1_wrap( double a, double b, Py_complex z); +double hyp1f1_wrap( double a, double b, double x); double hypU_wrap(double a, double b, double x); double exp1_wrap(double x); double expi_wrap(double x); Modified: branches/refactor_fft/scipy/special/tests/test_basic.py =================================================================== --- branches/refactor_fft/scipy/special/tests/test_basic.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/special/tests/test_basic.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -32,7 +32,7 @@ #8 test_sh_jacobi #8 test_sh_legendre -from numpy import dot +from numpy import dot, array from scipy.testing import * @@ -1177,6 +1177,116 @@ hyp1 = hyp1f1(.1,.1,.3) assert_almost_equal(hyp1, 1.3498588075760032,7) + # test contributed by Moritz Deger (2008-05-29) + # http://projects.scipy.org/scipy/scipy/ticket/659 + + # reference data obtained from mathematica [ a, b, x, m(a,b,x)]: + # produced with test_hyp1f1.nb + ref_data = array([[ -8.38132975e+00, -1.28436461e+01, -2.91081397e+01, 1.04178330e+04], + [ 2.91076882e+00, -6.35234333e+00, -1.27083993e+01, 6.68132725e+00], + [ -1.42938258e+01, 1.80869131e-01, 1.90038728e+01, 1.01385897e+05], + [ 5.84069088e+00, 1.33187908e+01, 2.91290106e+01, 1.59469411e+08], + [ -2.70433202e+01, -1.16274873e+01, -2.89582384e+01, 1.39900152e+24], + [ 4.26344966e+00, -2.32701773e+01, 1.91635759e+01, 6.13816915e+21], + [ 1.20514340e+01, -3.40260240e+00, 7.26832235e+00, 1.17696112e+13], + [ 2.77372955e+01, -1.99424687e+00, 3.61332246e+00, 3.07419615e+13], + [ 1.50310939e+01, -2.91198675e+01, -1.53581080e+01, -3.79166033e+02], + [ 1.43995827e+01, 9.84311196e+00, 1.93204553e+01, 2.55836264e+10], + [ -4.08759686e+00, 1.34437025e+01, -1.42072843e+01, 1.70778449e+01], + [ 8.05595738e+00, -1.31019838e+01, 1.52180721e+01, 3.06233294e+21], + [ 1.81815804e+01, -1.42908793e+01, 9.57868793e+00, -2.84771348e+20], + [ -2.49671396e+01, 1.25082843e+01, -1.71562286e+01, 2.36290426e+07], + [ 2.67277673e+01, 1.70315414e+01, 6.12701450e+00, 7.77917232e+03], + [ 2.49565476e+01, 2.91694684e+01, 6.29622660e+00, 2.35300027e+02], + [ 6.11924542e+00, -1.59943768e+00, 9.57009289e+00, 1.32906326e+11], + [ -1.47863653e+01, 2.41691301e+01, -1.89981821e+01, 2.73064953e+03], + [ 2.24070483e+01, -2.93647433e+00, 8.19281432e+00, -6.42000372e+17], + [ 8.04042600e-01, 1.82710085e+01, -1.97814534e+01, 5.48372441e-01], + [ 1.39590390e+01, 1.97318686e+01, 2.37606635e+00, 5.51923681e+00], + [ -4.66640483e+00, -2.00237930e+01, 7.40365095e+00, 4.50310752e+00], + [ 2.76821999e+01, -6.36563968e+00, 1.11533984e+01, -9.28725179e+23], + [ -2.56764457e+01, 1.24544906e+00, 1.06407572e+01, 1.25922076e+01], + [ 3.20447808e+00, 1.30874383e+01, 2.26098014e+01, 2.03202059e+04], + [ -1.24809647e+01, 4.15137113e+00, -2.92265700e+01, 2.39621411e+08], + [ 2.14778108e+01, -2.35162960e+00, -1.13758664e+01, 4.46882152e-01], + [ -9.85469168e+00, -3.28157680e+00, 1.67447548e+01, -1.07342390e+07], + [ 1.08122310e+01, -2.47353236e+01, -1.15622349e+01, -2.91733796e+03], + [ -2.67933347e+01, -3.39100709e+00, 2.56006986e+01, -5.29275382e+09], + [ -8.60066776e+00, -8.02200924e+00, 1.07231926e+01, 1.33548320e+06], + [ -1.01724238e-01, -1.18479709e+01, -2.55407104e+01, 1.55436570e+00], + [ -3.93356771e+00, 2.11106818e+01, -2.57598485e+01, 2.13467840e+01], + [ 3.74750503e+00, 1.55687633e+01, -2.92841720e+01, 1.43873509e-02], + [ 6.99726781e+00, 2.69855571e+01, -1.63707771e+01, 3.08098673e-02], + [ -2.31996011e+01, 3.47631054e+00, 9.75119815e-01, 1.79971073e-02], + [ 2.38951044e+01, -2.91460190e+01, -2.50774708e+00, 9.56934814e+00], + [ 1.52730825e+01, 5.77062507e+00, 1.21922003e+01, 1.32345307e+09], + [ 1.74673917e+01, 1.89723426e+01, 4.94903250e+00, 9.90859484e+01], + [ 1.88971241e+01, 2.86255413e+01, 5.52360109e-01, 1.44165360e+00], + [ 1.02002319e+01, -1.66855152e+01, -2.55426235e+01, 6.56481554e+02], + [ -1.79474153e+01, 1.22210200e+01, -1.84058212e+01, 8.24041812e+05], + [ -1.36147103e+01, 1.32365492e+00, -7.22375200e+00, 9.92446491e+05], + [ 7.57407832e+00, 2.59738234e+01, -1.34139168e+01, 3.64037761e-02], + [ 2.21110169e+00, 1.28012666e+01, 1.62529102e+01, 1.33433085e+02], + [ -2.64297569e+01, -1.63176658e+01, -1.11642006e+01, -2.44797251e+13], + [ -2.46622944e+01, -3.02147372e+00, 8.29159315e+00, -3.21799070e+05], + [ -1.37215095e+01, -1.96680183e+01, 2.91940118e+01, 3.21457520e+12], + [ -5.45566105e+00, 2.81292086e+01, 1.72548215e-01, 9.66973000e-01], + [ -1.55751298e+00, -8.65703373e+00, 2.68622026e+01, -3.17190834e+16], + [ 2.45393609e+01, -2.70571903e+01, 1.96815505e+01, 1.80708004e+37], + [ 5.77482829e+00, 1.53203143e+01, 2.50534322e+01, 1.14304242e+06], + [ -1.02626819e+01, 2.36887658e+01, -2.32152102e+01, 7.28965646e+02], + [ -1.30833446e+00, -1.28310210e+01, 1.87275544e+01, -9.33487904e+12], + [ 5.83024676e+00, -1.49279672e+01, 2.44957538e+01, -7.61083070e+27], + [ -2.03130747e+01, 2.59641715e+01, -2.06174328e+01, 4.54744859e+04], + [ 1.97684551e+01, -2.21410519e+01, -2.26728740e+01, 3.53113026e+06], + [ 2.73673444e+01, 2.64491725e+01, 1.57599882e+01, 1.07385118e+07], + [ 5.73287971e+00, 1.21111904e+01, 1.33080171e+01, 2.63220467e+03], + [ -2.82751072e+01, 2.08605881e+01, 9.09838900e+00, -6.60957033e-07], + [ 1.87270691e+01, -1.74437016e+01, 1.52413599e+01, 6.59572851e+27], + [ 6.60681457e+00, -2.69449855e+00, 9.78972047e+00, -2.38587870e+12], + [ 1.20895561e+01, -2.51355765e+01, 2.30096101e+01, 7.58739886e+32], + [ -2.44682278e+01, 2.10673441e+01, -1.36705538e+01, 4.54213550e+04], + [ -4.50665152e+00, 3.72292059e+00, -4.83403707e+00, 2.68938214e+01], + [ -7.46540049e+00, -1.08422222e+01, -1.72203805e+01, -2.09402162e+02], + [ -2.00307551e+01, -7.50604431e+00, -2.78640020e+01, 4.15985444e+19], + [ 1.99890876e+01, 2.20677419e+01, -2.51301778e+01, 1.23840297e-09], + [ 2.03183823e+01, -7.66942559e+00, 2.10340070e+01, 1.46285095e+31], + [ -2.90315825e+00, -2.55785967e+01, -9.58779316e+00, 2.65714264e-01], + [ 2.73960829e+01, -1.80097203e+01, -2.03070131e+00, 2.52908999e+02], + [ -2.11708058e+01, -2.70304032e+01, 2.48257944e+01, 3.09027527e+08], + [ 2.21959758e+01, 4.00258675e+00, -1.62853977e+01, -9.16280090e-09], + [ 1.61661840e+01, -2.26845150e+01, 2.17226940e+01, -8.24774394e+33], + [ -3.35030306e+00, 1.32670581e+00, 9.39711214e+00, -1.47303163e+01], + [ 7.23720726e+00, -2.29763909e+01, 2.34709682e+01, -9.20711735e+29], + [ 2.71013568e+01, 1.61951087e+01, -7.11388906e-01, 2.98750911e-01], + [ 8.40057933e+00, -7.49665220e+00, 2.95587388e+01, 6.59465635e+29], + [ -1.51603423e+01, 1.94032322e+01, -7.60044357e+00, 1.05186941e+02], + [ -8.83788031e+00, -2.72018313e+01, 1.88269907e+00, 1.81687019e+00], + [ -1.87283712e+01, 5.87479570e+00, -1.91210203e+01, 2.52235612e+08], + [ -5.61338513e-01, 2.69490237e+01, 1.16660111e-01, 9.97567783e-01], + [ -5.44354025e+00, -1.26721408e+01, -4.66831036e+00, 1.06660735e-01], + [ -2.18846497e+00, 2.33299566e+01, 9.62564397e+00, 3.03842061e-01], + [ 6.65661299e+00, -2.39048713e+01, 1.04191807e+01, 4.73700451e+13], + [ -2.57298921e+01, -2.60811296e+01, 2.74398110e+01, -5.32566307e+11], + [ -1.11431826e+01, -1.59420160e+01, -1.84880553e+01, -1.01514747e+02], + [ 6.50301931e+00, 2.59859051e+01, -2.33270137e+01, 1.22760500e-02], + [ -1.94987891e+01, -2.62123262e+01, 3.90323225e+00, 1.71658894e+01], + [ 7.26164601e+00, -1.41469402e+01, 2.81499763e+01, -2.50068329e+31], + [ -1.52424040e+01, 2.99719005e+01, -2.85753678e+01, 1.31906693e+04], + [ 5.24149291e+00, -1.72807223e+01, 2.22129493e+01, 2.50748475e+25], + [ 3.63207230e-01, -9.54120862e-02, -2.83874044e+01, 9.43854939e-01], + [ -2.11326457e+00, -1.25707023e+01, 1.17172130e+00, 1.20812698e+00], + [ 2.48513582e+00, 1.03652647e+01, -1.84625148e+01, 6.47910997e-02], + [ 2.65395942e+01, 2.74794672e+01, 1.29413428e+01, 2.89306132e+05], + [ -9.49445460e+00, 1.59930921e+01, -1.49596331e+01, 3.27574841e+02], + [ -5.89173945e+00, 9.96742426e+00, 2.60318889e+01, -3.15842908e-01], + [ -1.15387239e+01, -2.21433107e+01, -2.17686413e+01, 1.56724718e-01], + [ -5.30592244e+00, -2.42752190e+01, 1.29734035e+00, 1.31985534e+00]]) + + for a,b,c,expected in ref_data: + result = hyp1f1(a,b,c) + assert(abs(expected - result)/expected < 1e-4) + def test_hyp1f2(self): pass Copied: branches/refactor_fft/scipy/stats/SConscript (from rev 4510, trunk/scipy/stats/SConscript) Deleted: branches/refactor_fft/scipy/stats/SConstruct =================================================================== --- branches/refactor_fft/scipy/stats/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stats/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,39 +0,0 @@ -# Last Change: Sat May 03 02:00 PM 2008 J -# vim:syntax=python -from os.path import join as pjoin - -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import GetNumpyEnvironment, CheckF77Clib - -env = GetNumpyEnvironment(ARGUMENTS) - -t = env.Tool('numpyf2py') - -env.AppendUnique(CPPPATH = [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 = env.NumpyGlob(pjoin('statlib', '*.f' )) -env.NumpyStaticExtLibrary('statlibimp', source = src) - -env.AppendUnique(LIBPATH = [env['build_dir']]) - -# Statlib extension -env.NumpyPythonExtension('statlib', source = 'statlib.pyf', - F2PYOPTIONS = ["--no-wrap-functions"], - LIBS = 'statlibimp', - LINKFLAGSEND = env['F77_LDFLAGS']) - -# futil extension -futil_src = env.NumpyF2py(pjoin('futilmodule.c'), pjoin('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']) Copied: branches/refactor_fft/scipy/stats/SConstruct (from rev 4510, trunk/scipy/stats/SConstruct) Modified: branches/refactor_fft/scipy/stats/models/formula.py =================================================================== --- branches/refactor_fft/scipy/stats/models/formula.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stats/models/formula.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -269,9 +269,9 @@ if reference is None: reference = 0 else: - try: + if reference in names: reference = names.index(reference) - except IndexError: + else: reference = int(reference) def maineffect_func(value, reference=reference): Modified: branches/refactor_fft/scipy/stats/models/tests/test_bspline.py =================================================================== --- branches/refactor_fft/scipy/stats/models/tests/test_bspline.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stats/models/tests/test_bspline.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -6,17 +6,21 @@ from scipy.testing import * import scipy.stats.models as S -import scipy.stats.models.bspline as B +try: + import scipy.stats.models.bspline as B +except ImportError: + B = None class TestBSpline(TestCase): def test1(self): - b = B.BSpline(N.linspace(0,10,11), x=N.linspace(0,10,101)) - old = b._basisx.shape - b.x = N.linspace(0,10,51) - new = b._basisx.shape - self.assertEqual((old[0], 51), new) + if B: + b = B.BSpline(N.linspace(0,10,11), x=N.linspace(0,10,101)) + old = b._basisx.shape + b.x = N.linspace(0,10,51) + new = b._basisx.shape + self.assertEqual((old[0], 51), new) if __name__ == "__main__": Modified: branches/refactor_fft/scipy/stats/mstats.py =================================================================== --- branches/refactor_fft/scipy/stats/mstats.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stats/mstats.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -518,8 +518,8 @@ def kendalltau(x, y, use_ties=True, use_missing=False): """Computes Kendall's rank correlation tau on two variables *x* and *y*. -Parameters ----------- + Parameters + ---------- xdata: sequence First data list (for example, time). ydata: sequence @@ -529,6 +529,13 @@ use_missing: {False, True} optional Whether missing data should be allocated a rank of 0 (False) or the average rank (True) + + Returns + ------- + tau : float + Kendall tau + prob : float + Approximate 2-side p-value. """ (x, y, n) = _chk_size(x, y) (x, y) = (x.flatten(), y.flatten()) @@ -724,6 +731,17 @@ Independent variable. If None, use arange(len(y)) instead. alpha : float Confidence degree. + + Returns + ------- + medslope : float + Theil slope + medintercept : float + Intercept of the Theil line, as median(y)-medslope*median(x) + lo_slope : float + Lower bound of the confidence interval on medslope + up_slope : float + Upper bound of the confidence interval on medslope """ y = ma.asarray(y).flatten() @@ -755,8 +773,8 @@ sigsq -= np.sum(v*k*(k-1)*(2*k+5) for (k,v) in yties.iteritems()) sigma = np.sqrt(sigsq) - Ru = np.round((nt - z*sigma)/2. + 1) - Rl = np.round((nt + z*sigma)/2.) + Ru = min(np.round((nt - z*sigma)/2. + 1), len(slopes)-1) + Rl = max(np.round((nt + z*sigma)/2.), 0) delta = slopes[[Rl,Ru]] return medslope, medinter, delta[0], delta[1] Modified: branches/refactor_fft/scipy/stats/stats.py =================================================================== --- branches/refactor_fft/scipy/stats/stats.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stats/stats.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -50,6 +50,10 @@ kurtosis normaltest (for arrays only) +MOMENTS HANDLING NAN: nanmean + nanmedian + nanstd + ALTERED VERSIONS: tmean tvar tstd @@ -214,6 +218,7 @@ 'f_value', 'f_value_multivariate', 'ss', 'square_of_sums', 'fastsort', 'rankdata', + 'nanmean', 'nanstd', 'nanmedian', ] Modified: branches/refactor_fft/scipy/stats/tests/test_stats.py =================================================================== --- branches/refactor_fft/scipy/stats/tests/test_stats.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stats/tests/test_stats.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -197,47 +197,47 @@ def test_nanmean_none(self): """Check nanmean when no values are nan.""" - m = stats.stats.nanmean(X) + m = stats.nanmean(X) assert_approx_equal(m, X[4]) def test_nanmean_some(self): """Check nanmean when some values only are nan.""" - m = stats.stats.nanmean(self.Xsome) + m = stats.nanmean(self.Xsome) assert_approx_equal(m, 5.5) def test_nanmean_all(self): """Check nanmean when all values are nan.""" - m = stats.stats.nanmean(self.Xall) + m = stats.nanmean(self.Xall) assert numpy.isnan(m) def test_nanstd_none(self): """Check nanstd when no values are nan.""" - s = stats.stats.nanstd(self.X) - assert_approx_equal(s, stats.stats.std(self.X)) + s = stats.nanstd(self.X) + assert_approx_equal(s, stats.std(self.X)) def test_nanstd_some(self): """Check nanstd when some values only are nan.""" - s = stats.stats.nanstd(self.Xsome) - assert_approx_equal(s, stats.stats.std(self.Xsomet)) + s = stats.nanstd(self.Xsome) + assert_approx_equal(s, stats.std(self.Xsomet)) def test_nanstd_all(self): """Check nanstd when all values are nan.""" - s = stats.stats.nanstd(self.Xall) + s = stats.nanstd(self.Xall) assert numpy.isnan(s) def test_nanmedian_none(self): """Check nanmedian when no values are nan.""" - m = stats.stats.nanmedian(self.X) - assert_approx_equal(m, stats.stats.median(self.X)) + m = stats.nanmedian(self.X) + assert_approx_equal(m, stats.median(self.X)) def test_nanmedian_some(self): """Check nanmedian when some values only are nan.""" - m = stats.stats.nanmedian(self.Xsome) - assert_approx_equal(m, stats.stats.median(self.Xsomet)) + m = stats.nanmedian(self.Xsome) + assert_approx_equal(m, stats.median(self.Xsomet)) def test_nanmedian_all(self): """Check nanmedian when all values are nan.""" - m = stats.stats.nanmedian(self.Xall) + m = stats.nanmedian(self.Xall) assert numpy.isnan(m) class TestCorr(TestCase): @@ -482,6 +482,15 @@ assert_almost_equal(intercept,0.0) assert_almost_equal(r,0.0) + def test_regress_simple(self): + """Regress a line with sinusoidal noise.""" + x = numpy.linspace(0, 100, 100) + y = 0.2 * numpy.linspace(0, 100, 100) + 10 + y += numpy.sin(numpy.linspace(0, 20, 100)) + + res = stats.linregress(x, y) + assert_almost_equal(res[4], 4.3609875083149268e-3) + # Utility def compare_results(res,desired): Property changes on: branches/refactor_fft/scipy/stats/tests/test_stats.py ___________________________________________________________________ Name: svn:executable - * Copied: branches/refactor_fft/scipy/stsci/convolve/SConscript (from rev 4510, trunk/scipy/stsci/convolve/SConscript) Deleted: branches/refactor_fft/scipy/stsci/convolve/SConstruct =================================================================== --- branches/refactor_fft/scipy/stsci/convolve/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stsci/convolve/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,13 +0,0 @@ -# Last Change: Wed Mar 05 09:00 PM 2008 J -from numpy.distutils.misc_util import get_numpy_include_dirs -from numpy import get_numarray_include -from numscons import GetNumpyEnvironment - -env = GetNumpyEnvironment(ARGUMENTS) - -env.AppendUnique(CPPPATH = [get_numpy_include_dirs(), get_numarray_include()]) -env.AppendUnique(CPPDEFINES = {'NUMPY': '1'}) - -# _correlate extension -env.NumpyPythonExtension('_correlate', source = 'src/_correlatemodule.c') -env.NumpyPythonExtension('_lineshape', source = 'src/_lineshapemodule.c') Copied: branches/refactor_fft/scipy/stsci/convolve/SConstruct (from rev 4510, trunk/scipy/stsci/convolve/SConstruct) Copied: branches/refactor_fft/scipy/stsci/image/SConscript (from rev 4510, trunk/scipy/stsci/image/SConscript) Deleted: branches/refactor_fft/scipy/stsci/image/SConstruct =================================================================== --- branches/refactor_fft/scipy/stsci/image/SConstruct 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/stsci/image/SConstruct 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,11 +0,0 @@ -# Last Change: Wed Mar 05 09:00 PM 2008 J -from numpy.distutils.misc_util import get_numpy_include_dirs -from numpy import get_numarray_include -from numscons import GetNumpyEnvironment - -env = GetNumpyEnvironment(ARGUMENTS) - -env.AppendUnique(CPPPATH = [get_numpy_include_dirs(), get_numarray_include()]) -env.AppendUnique(CPPDEFINES = {'NUMPY': '1'}) - -env.NumpyPythonExtension('_combine', source = 'src/_combinemodule.c') Copied: branches/refactor_fft/scipy/stsci/image/SConstruct (from rev 4510, trunk/scipy/stsci/image/SConstruct) Modified: branches/refactor_fft/scipy/testing/__init__.py =================================================================== --- branches/refactor_fft/scipy/testing/__init__.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/testing/__init__.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -8,11 +8,6 @@ import unittest from unittest import TestCase -try: - import nose -except ImportError: - pass - import decorators as dec from numpy.testing.utils import * from utils import * Modified: branches/refactor_fft/scipy/testing/decorators.py =================================================================== --- branches/refactor_fft/scipy/testing/decorators.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/testing/decorators.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -10,11 +10,6 @@ """ -try: - import nose -except ImportError: - pass - def slow(t): """Labels a test as 'slow'. @@ -76,6 +71,9 @@ if msg is None: msg = 'Test skipped due to test condition' def skip_decorator(f): + # Local import to avoid a hard nose dependency and only incur the import + # time overhead at actual test-time. + import nose def skipper(*args, **kwargs): if skip_condition: raise nose.SkipTest, msg @@ -87,6 +85,9 @@ def skipknownfailure(f): ''' Decorator to raise SkipTest for test known to fail ''' + # Local import to avoid a hard nose dependency and only incur the import + # time overhead at actual test-time. + import nose def skipper(*args, **kwargs): raise nose.SkipTest, 'This test is known to fail' return nose.tools.make_decorator(f)(skipper) Modified: branches/refactor_fft/scipy/testing/nosetester.py =================================================================== --- branches/refactor_fft/scipy/testing/nosetester.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/testing/nosetester.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -7,8 +7,26 @@ import sys import re -import nose +def import_nose(): + """ Import nose only when needed. + """ + fine_nose = True + try: + import nose + except ImportError: + fine_nose = False + else: + nose_version = nose.__versioninfo__ + if nose_version[0] < 1 and nose_version[1] < 10: + fine_nose = False + + if not fine_nose: + raise ImportError('Need nose >=0.10 for tests - see ' + 'http://somethingaboutorange.com/mrl/projects/nose') + + return nose + class NoseTester(object): """ Nose test runner. @@ -112,6 +130,7 @@ doctests : boolean If True, run doctests in module, default False ''' + nose = import_nose() argv = self._test_argv(label, verbose, extra_argv) if doctests: argv+=['--with-doctest'] @@ -122,6 +141,7 @@ ''' Run benchmarks for module using nose %(test_header)s''' + nose = import_nose() argv = self._test_argv(label, verbose, extra_argv) argv += ['--match', r'(?:^|[\\b_\\.%s-])[Bb]ench' % os.sep] nose.run(argv=argv) Deleted: branches/refactor_fft/scipy/testing/nulltester.py =================================================================== --- branches/refactor_fft/scipy/testing/nulltester.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/testing/nulltester.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -1,15 +0,0 @@ -''' Null tester to signal nose tests disabled - -Merely returns error reporting lack of nose package or version number -below requirements. - -See pkgtester, nosetester modules - -''' - -class NullTester(object): - def test(self, labels=None, *args, **kwargs): - raise ImportError, \ - 'Need nose >=0.10 for tests - see %s' % \ - 'http://somethingaboutorange.com/mrl/projects/nose' - bench = test Modified: branches/refactor_fft/scipy/testing/pkgtester.py =================================================================== --- branches/refactor_fft/scipy/testing/pkgtester.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/testing/pkgtester.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -11,17 +11,4 @@ See nosetester module for test implementation ''' -fine_nose = True -try: - import nose -except ImportError: - fine_nose = False -else: - nose_version = nose.__versioninfo__ - if nose_version[0] < 1 and nose_version[1] < 10: - fine_nose = False - -if fine_nose: - from scipy.testing.nosetester import NoseTester as Tester -else: - from scipy.testing.nulltester import NullTester as Tester +from scipy.testing.nosetester import NoseTester as Tester Modified: branches/refactor_fft/scipy/weave/tests/test_wx_spec.py =================================================================== --- branches/refactor_fft/scipy/weave/tests/test_wx_spec.py 2008-07-01 00:46:27 UTC (rev 4510) +++ branches/refactor_fft/scipy/weave/tests/test_wx_spec.py 2008-07-01 04:52:00 UTC (rev 4511) @@ -10,15 +10,25 @@ from scipy.testing import * -from scipy.weave import ext_tools, wx_spec +e = None +DONOTRUN = False +try: + from scipy.weave import ext_tools, wx_spec + import wx +except ImportError, e: + wx = None + DONOTRUN = True +except RuntimeError, e: + wx = None + DONOTRUN = True +skip = dec.skipif(DONOTRUN, "(error was %s)" % str(e)) -import wx - class TestWxConverter(TestCase): def setUp(self): - self.app = wx.App() - self.s = wx_spec.wx_converter() + if not DONOTRUN: + self.app = wx.App() + self.s = wx_spec.wx_converter() @dec.slow def test_type_match_string(self): @@ -107,5 +117,7 @@ c = wx_return.test(b) assert(c == 'hello') +decorate_methods(TestWxConverter, skip) + if __name__ == "__main__": nose.run(argv=['', __file__]) From scipy-svn at scipy.org Tue Jul 1 00:58:52 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 30 Jun 2008 23:58:52 -0500 (CDT) Subject: [Scipy-svn] r4512 - in trunk/scipy/fftpack: . tests Message-ID: <20080701045852.D36C539C678@scipy.org> Author: cdavid Date: 2008-06-30 23:58:48 -0500 (Mon, 30 Jun 2008) New Revision: 4512 Modified: trunk/scipy/fftpack/basic.py trunk/scipy/fftpack/tests/test_basic.py Log: Raise a proper exception instead of assertion when s argument shape is longer than x.shape in fftn. Modified: trunk/scipy/fftpack/basic.py =================================================================== --- trunk/scipy/fftpack/basic.py 2008-07-01 04:52:00 UTC (rev 4511) +++ trunk/scipy/fftpack/basic.py 2008-07-01 04:58:48 UTC (rev 4512) @@ -227,12 +227,14 @@ """ Internal auxiliary function for fftnd, ifftnd.""" if s is None: s = x.shape - s = tuple(s) - if s!=x.shape: - assert len(s)<=len(x.shape) + else: + s = tuple(s) + if len(s) > len(x.shape): + raise ValueError("s shape cannot be longer than x shape.") for i in range(-len(s),0): if x.shape[i]!=s[i]: x = _fix_shape(x,s[i],i) + if axes is None: return work_function(x,s,direction,overwrite_x=overwrite_x) Modified: trunk/scipy/fftpack/tests/test_basic.py =================================================================== --- trunk/scipy/fftpack/tests/test_basic.py 2008-07-01 04:52:00 UTC (rev 4511) +++ trunk/scipy/fftpack/tests/test_basic.py 2008-07-01 04:58:48 UTC (rev 4512) @@ -358,7 +358,18 @@ assert_array_almost_equal (y,swapaxes(\ fftn(swapaxes(large_x1,-1,-2)),-1,-2)) + def test_shape_argument_more(self): + # Test that fftn raise a value error exception when s.shape is longer + # than x.shape + x = zeros((4, 4, 2)) + try: + fx = fftn(x, shape = (8, 8, 2, 1)) + raise AssertionError("s.shape longer than x.shape succeded, "\ + "but should not have.") + except ValueError: + pass + class TestIfftn(TestCase): def test_definition(self): From scipy-svn at scipy.org Tue Jul 1 03:41:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 1 Jul 2008 02:41:41 -0500 (CDT) Subject: [Scipy-svn] r4513 - in trunk/scipy/sparse: . tests Message-ID: <20080701074141.61EF539C27D@scipy.org> Author: wnbell Date: 2008-07-01 02:40:59 -0500 (Tue, 01 Jul 2008) New Revision: 4513 Modified: trunk/scipy/sparse/base.py trunk/scipy/sparse/tests/test_base.py Log: added .nonzero() to sparse matrices resolves ticket #695 Modified: trunk/scipy/sparse/base.py =================================================================== --- trunk/scipy/sparse/base.py 2008-07-01 04:58:48 UTC (rev 4512) +++ trunk/scipy/sparse/base.py 2008-07-01 07:40:59 UTC (rev 4513) @@ -335,6 +335,29 @@ def _imag(self): return self.tocsr()._imag() + + def nonzero(self): + """nonzero indices + + Returns a tuple of arrays (row,col) containing the indices + of the non-zero elements of the matrix. + + Example + ------- + + >>> from scipy.sparse import csr_matrix + >>> A = csr_matrix([[1,2,0],[0,0,3],[4,0,5]]) + >>> A.nonzero() + (array([0, 0, 1, 2, 2]), array([0, 1, 2, 0, 2])) + + """ + + # convert to COOrdinate format + A = self.tocoo() + nz_mask = A.data != 0 + return (A.row[nz_mask],A.col[nz_mask]) + + def getcol(self, j): """Returns a copy of column j of the matrix, as an (m x 1) sparse matrix (column vector). Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-07-01 04:58:48 UTC (rev 4512) +++ trunk/scipy/sparse/tests/test_base.py 2008-07-01 07:40:59 UTC (rev 4513) @@ -105,6 +105,16 @@ assert_equal(self.spmatrix(m).diagonal(),diag(m)) + def test_nonzero(self): + A = array([[1, 0, 1],[0, 1, 1],[ 0, 0, 1]]) + Asp = self.spmatrix(A) + + A_nz = set( [tuple(ij) for ij in transpose(A.nonzero())] ) + Asp_nz = set( [tuple(ij) for ij in transpose(Asp.nonzero())] ) + + assert_equal(A_nz, Asp_nz) + + def test_getrow(self): assert_array_equal(self.datsp.getrow(1).todense(), self.dat[1,:]) From scipy-svn at scipy.org Tue Jul 1 09:33:21 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 1 Jul 2008 08:33:21 -0500 (CDT) Subject: [Scipy-svn] r4514 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080701133321.52FC139C665@scipy.org> Author: ilan Date: 2008-07-01 08:33:19 -0500 (Tue, 01 Jul 2008) New Revision: 4514 Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py Log: Improved primes example Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-01 07:40:59 UTC (rev 4513) +++ trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-01 13:33:19 UTC (rev 4514) @@ -2,28 +2,28 @@ from math import sqrt import time -from numpy import arange - from mkufunc.api import mkufunc -def is_prime(n): - if n < 2: - return 0 - for i in xrange(2, min(n, int(sqrt(n)+2.0))): - if n %i == 0: - return 0 - return 1 +def count_primes(N): + res = 0 + for n in xrange(2, N): + for i in xrange(2, min(n, int(sqrt(n)+2.0))): + if n % i == 0: + break + else: + res += 1 + return res start_time = time.time() -assert sum(is_prime(n) for n in xrange(1000000)) == 78498 +assert count_primes(1000000) == 78498 print 'Python: %.6f sec' % (time.time() - start_time) -is_prime = mkufunc(int)(is_prime) +count_primes = mkufunc(int)(count_primes) start_time = time.time() -assert is_prime(arange(1000000)).sum() == 78498 +assert count_primes(1000000) == 78498 print 'Compiled: %.6f sec' % (time.time() - start_time) From scipy-svn at scipy.org Tue Jul 1 10:20:08 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 1 Jul 2008 09:20:08 -0500 (CDT) Subject: [Scipy-svn] r4515 - trunk/scipy/sandbox/mkufunc/mkufunc Message-ID: <20080701142008.2A4A839C9C3@scipy.org> Author: ilan Date: 2008-07-01 09:20:07 -0500 (Tue, 01 Jul 2008) New Revision: 4515 Modified: trunk/scipy/sandbox/mkufunc/mkufunc/api.py Log: Made regular expression readable Modified: trunk/scipy/sandbox/mkufunc/mkufunc/api.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/api.py 2008-07-01 13:33:19 UTC (rev 4514) +++ trunk/scipy/sandbox/mkufunc/mkufunc/api.py 2008-07-01 14:20:07 UTC (rev 4515) @@ -104,9 +104,17 @@ self.cname = self._prefix + 'pypy_g_' + f.__name__ def cfunc(self): - p = re.compile(r'^\w+[*\s\w]+' + self.cname + - r'\s*\([^)]*\)\s*\{.*?[\n\r]\}[\n\r]', - re.DOTALL | re.MULTILINE | re.VERBOSE) + p = re.compile( + r''' + ^\w+ # return type of function + [\s]+ # whitespace + %s # function name + \s* # possibly whitespace + \([^)]*\) # argument types + \s* # possibly whitespace + \{.*?[\n\r]\}[\n\r] # function body ending with } in single line + ''' % self.cname, + re.DOTALL | re.MULTILINE | re.VERBOSE) found = p.findall(self._allCsrc) assert len(found) == 1 From scipy-svn at scipy.org Tue Jul 1 12:24:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 1 Jul 2008 11:24:20 -0500 (CDT) Subject: [Scipy-svn] r4516 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080701162420.549EA39C64A@scipy.org> Author: ilan Date: 2008-07-01 11:24:20 -0500 (Tue, 01 Jul 2008) New Revision: 4516 Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py Log: Added hand written weave version (slightly faster) Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 14:20:07 UTC (rev 4515) +++ trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 16:24:20 UTC (rev 4516) @@ -14,11 +14,77 @@ vfunc = vectorize(f) -ufunc = mkufunc([(float, float)])(f) +mfunc = mkufunc([(float, float)])(f) +##################################################################### +support_code = ''' +double foo(double x) +{ + return x; +} -x = arange(0, 1000, 0.001) #print "x =", x, x.dtype +typedef double Func_0(double a); +static void +PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) +{ + npy_intp i, n; + npy_intp is0 = steps[0]; + npy_intp os = steps[1]; + char *ip0 = args[0]; + char *op = args[1]; + Func_0 *f = (Func_0 *) func; + n = dimensions[0]; + + for(i = 0; i < n; i++) { + double x = (double *)ip0; + double *out = (double *)op; + + *out = 4.2 * x*x + 3.7 * x + 1.5; + + ip0 += is0; + op += os; + } +} + +static PyUFuncGenericFunction f_functions[] = { + PyUFunc_0, +}; + +static void *f_data[] = { + (void *) foo, +}; + +static char f_types[] = { + NPY_DOUBLE, NPY_DOUBLE, /* 0 */ +}; +''' +ufunc_info = weave.base_info.custom_info() +ufunc_info.add_header('"numpy/ufuncobject.h"') + +ufunc = weave.inline(''' +import_ufunc(); + +return_val = PyUFunc_FromFuncAndData( + f_functions, + f_data, + f_types, + 1, /* ntypes */ + 1, /* nin */ + 1, /* nout */ + PyUFunc_None, /* identity */ + "f", /* name */ + "doc", /* doc */ + 0); + ''', + support_code=support_code, + verbose=0, + customize=ufunc_info) +############################################################# + + +x = arange(0, 1000, 0.0001) #print "x =", x, x.dtype + start_time = time.time() b_y = x.copy() weave.blitz("b_y[:] = 4.2 * x[:] * x[:] + 3.7 * x[:] + 1.5") @@ -36,14 +102,21 @@ print 'vectorize: %.6f sec' % v_time start_time = time.time() +m_y = mfunc(x) +m_time = time.time() - start_time +print 'mkufunc: %.6f sec' % m_time + +start_time = time.time() u_y = ufunc(x) u_time = time.time() - start_time -print 'mkufunc: %.6f sec' % u_time +print 'ufunc: %.6f sec' % u_time -print "speedup over blitz:", b_time/u_time -print "speedup over numpy:", n_time/u_time -print "speedup over vectorize:", v_time/u_time +print "speedup over blitz:", b_time/m_time +print "speedup over numpy:", n_time/m_time +print "speedup over vectorize:", v_time/m_time +print "speedup over ufunc:", u_time/m_time assert allclose(b_y, n_y) assert allclose(v_y, n_y) +assert allclose(m_y, n_y) assert allclose(u_y, n_y) From scipy-svn at scipy.org Tue Jul 1 17:38:29 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 1 Jul 2008 16:38:29 -0500 (CDT) Subject: [Scipy-svn] r4517 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080701213829.0BF8639C0AE@scipy.org> Author: ilan Date: 2008-07-01 16:38:28 -0500 (Tue, 01 Jul 2008) New Revision: 4517 Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py Log: simplified benchmark C code Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 16:24:20 UTC (rev 4516) +++ trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 21:38:28 UTC (rev 4517) @@ -1,6 +1,6 @@ #!/usr/bin/env python from math import sin, cos -import time +import time, hashlib from numpy import arange, vectorize, allclose from scipy import weave @@ -18,13 +18,6 @@ ##################################################################### support_code = ''' -double foo(double x) -{ - return x; -} - -typedef double Func_0(double a); - static void PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) { @@ -33,13 +26,13 @@ npy_intp os = steps[1]; char *ip0 = args[0]; char *op = args[1]; - Func_0 *f = (Func_0 *) func; n = dimensions[0]; + double x; for(i = 0; i < n; i++) { - double x = (double *)ip0; + x = *(double *)ip0; double *out = (double *)op; - + *out = 4.2 * x*x + 3.7 * x + 1.5; ip0 += is0; @@ -51,23 +44,19 @@ PyUFunc_0, }; -static void *f_data[] = { - (void *) foo, -}; - static char f_types[] = { - NPY_DOUBLE, NPY_DOUBLE, /* 0 */ + NPY_DOUBLE, NPY_DOUBLE, }; ''' ufunc_info = weave.base_info.custom_info() ufunc_info.add_header('"numpy/ufuncobject.h"') -ufunc = weave.inline(''' +ufunc = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/ import_ufunc(); return_val = PyUFunc_FromFuncAndData( f_functions, - f_data, + NULL, f_types, 1, /* ntypes */ 1, /* nin */ From scipy-svn at scipy.org Tue Jul 1 17:56:13 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 1 Jul 2008 16:56:13 -0500 (CDT) Subject: [Scipy-svn] r4518 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080701215613.9A86539C0F7@scipy.org> Author: ilan Date: 2008-07-01 16:56:12 -0500 (Tue, 01 Jul 2008) New Revision: 4518 Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py Log: Using empty_like is much faster than .copy() Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 21:38:28 UTC (rev 4517) +++ trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 21:56:12 UTC (rev 4518) @@ -2,7 +2,7 @@ from math import sin, cos import time, hashlib -from numpy import arange, vectorize, allclose +from numpy import arange, vectorize, allclose, empty_like from scipy import weave from mkufunc.api import mkufunc @@ -75,7 +75,7 @@ x = arange(0, 1000, 0.0001) #print "x =", x, x.dtype start_time = time.time() -b_y = x.copy() +b_y = empty_like(x) weave.blitz("b_y[:] = 4.2 * x[:] * x[:] + 3.7 * x[:] + 1.5") b_time = time.time() - start_time print 'blitz: %.6f sec' % b_time From scipy-svn at scipy.org Wed Jul 2 03:41:16 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 02:41:16 -0500 (CDT) Subject: [Scipy-svn] r4519 - trunk/scipy/fftpack Message-ID: <20080702074116.5B40E39C07A@scipy.org> Author: cdavid Date: 2008-07-02 02:40:52 -0500 (Wed, 02 Jul 2008) New Revision: 4519 Modified: trunk/scipy/fftpack/basic.py Log: Correct typo in exception message. Modified: trunk/scipy/fftpack/basic.py =================================================================== --- trunk/scipy/fftpack/basic.py 2008-07-01 21:56:12 UTC (rev 4518) +++ trunk/scipy/fftpack/basic.py 2008-07-02 07:40:52 UTC (rev 4519) @@ -230,7 +230,7 @@ else: s = tuple(s) if len(s) > len(x.shape): - raise ValueError("s shape cannot be longer than x shape.") + raise ValueError("shape cannot be longer than x shape.") for i in range(-len(s),0): if x.shape[i]!=s[i]: x = _fix_shape(x,s[i],i) From scipy-svn at scipy.org Wed Jul 2 04:08:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 03:08:53 -0500 (CDT) Subject: [Scipy-svn] r4520 - in trunk/scipy/fftpack: . tests Message-ID: <20080702080853.2B4E439C65D@scipy.org> Author: cdavid Date: 2008-07-02 03:08:20 -0500 (Wed, 02 Jul 2008) New Revision: 4520 Modified: trunk/scipy/fftpack/basic.py trunk/scipy/fftpack/tests/test_basic.py Log: Forbid shape and axes to be of different lengths for fftn. Modified: trunk/scipy/fftpack/basic.py =================================================================== --- trunk/scipy/fftpack/basic.py 2008-07-02 07:40:52 UTC (rev 4519) +++ trunk/scipy/fftpack/basic.py 2008-07-02 08:08:20 UTC (rev 4520) @@ -229,6 +229,12 @@ s = x.shape else: s = tuple(s) + if axes is None: + axes = range(len(s)) + elif not len(axes) == len(s): + raise ValueError("when given, axes and shape arguments "\ + "have to be of the same length") + if len(s) > len(x.shape): raise ValueError("shape cannot be longer than x shape.") for i in range(-len(s),0): Modified: trunk/scipy/fftpack/tests/test_basic.py =================================================================== --- trunk/scipy/fftpack/tests/test_basic.py 2008-07-02 07:40:52 UTC (rev 4519) +++ trunk/scipy/fftpack/tests/test_basic.py 2008-07-02 08:08:20 UTC (rev 4520) @@ -346,12 +346,13 @@ [4,5,6,0], [7,8,9,0], [0,0,0,0]]) - y = fftn(small_x,shape=(4,4),axes=(-1,)) - for i in range(4): - assert_array_almost_equal (y[i],fft(large_x1[i])) - y = fftn(small_x,shape=(4,4),axes=(-2,)) - for i in range(4): - assert_array_almost_equal (y[:,i],fft(large_x1[:,i])) + # Disable tests with shape and axes of different lengths + #y = fftn(small_x,shape=(4,4),axes=(-1,)) + #for i in range(4): + # assert_array_almost_equal (y[i],fft(large_x1[i])) + #y = fftn(small_x,shape=(4,4),axes=(-2,)) + #for i in range(4): + # assert_array_almost_equal (y[:,i],fft(large_x1[:,i])) y = fftn(small_x,shape=(4,4),axes=(-2,-1)) assert_array_almost_equal (y,fftn(large_x1)) y = fftn(small_x,shape=(4,4),axes=(-1,-2)) From scipy-svn at scipy.org Wed Jul 2 09:24:48 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 08:24:48 -0500 (CDT) Subject: [Scipy-svn] r4521 - trunk/scipy/sandbox/mkufunc/mkufunc Message-ID: <20080702132448.42B0E39C9D0@scipy.org> Author: ilan Date: 2008-07-02 08:24:46 -0500 (Wed, 02 Jul 2008) New Revision: 4521 Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py Log: Added more math tests, also a test for lambda (which fails). Lambda functions are not supported. Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-02 08:08:20 UTC (rev 4520) +++ trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-02 13:24:46 UTC (rev 4521) @@ -117,6 +117,16 @@ b = [f(x) for x in xx] self.assertClose(a, b) + def test_pi(self): + @mkufunc + def f(x): return math.pi * x + self.assertFuncsEqual(f, lambda x: math.pi * x) + + def test_e(self): + @mkufunc#(show=1) + def f(x): return math.e * x + self.assertFuncsEqual(f, lambda x: math.e * x) + def test_exp(self): @mkufunc def f(x): return math.exp(x) @@ -127,6 +137,11 @@ def f(x): return math.log(x) self.assertFuncsEqual(f, math.log) + def test_log10(self): + @mkufunc + def f(x): return math.log10(x) + self.assertFuncsEqual(f, math.log10) + def test_sqrt(self): @mkufunc def f(x): return math.sqrt(x) @@ -147,6 +162,21 @@ def f(x): return math.tan(x) self.assertFuncsEqual(f, math.tan) + def test_cosh(self): + @mkufunc + def f(x): return math.cosh(x) + self.assertFuncsEqual(f, math.cosh) + + def test_sinh(self): + @mkufunc + def f(x): return math.sinh(x) + self.assertFuncsEqual(f, math.sinh) + + def test_tanh(self): + @mkufunc + def f(x): return math.tanh(x) + self.assertFuncsEqual(f, math.tanh) + def test_acos(self): @mkufunc def f(x): return math.acos(x) @@ -156,7 +186,7 @@ @mkufunc def f(x): return math.asin(x) self.assertFuncsEqual(f, math.asin) - + def test_atan(self): @mkufunc def f(x): return math.atan(x) @@ -169,12 +199,25 @@ self.assertClose(f(4, 5), math.atan2(4, 5)) - xx = array([1.0, 3.0, -2.4, 3.1, -2.3]) - yy = array([1.0, 2.0, 7.5, -8.7, 0.0]) + xx = array([1.0, 3.0, -2.4, 3.1, -2.3, -1.0]) + yy = array([1.0, 2.0, 7.5, -8.7, 0.0, -3.2]) a = f(xx, yy) b = [math.atan2(x, y) for x, y in zip(xx, yy)] self.assertClose(a, b) + + def test_pow(self): + @mkufunc + def f(x, y): + return math.pow(x, y) + self.assertClose(f(2, 3), 8) + + xx = array([1.0, 3.0, 2.4, 0.0, 0.0, 0.0, 2.3, 2.0]) + yy = array([1.0, 2.0, 7.5, 0.0, 0.5, 1.0, 0.0, -1.0]) + a = f(xx, yy) + b = [math.pow(x, y) for x, y in zip(xx, yy)] + self.assertClose(a, b) + def test_arithmetic(self): def f(x): return (4 * x + 2) / (x * x - 7 * x + 1) @@ -236,7 +279,13 @@ x = arange(0, 1, 0.1) self.assertClose(f(x), a * x) - def test_const2(self): + +class Misc_Tests(unittest.TestCase, Util): + + def test_lambda(self): + self.assertRaises(AssertionError, mkufunc, lambda x: x*x + 2) + + def test_angle(self): from math import sin, pi, sqrt @mkufunc def sin_deg(angle): @@ -244,12 +293,9 @@ self.assertClose(sin_deg([0, 30, 45, 60, 90, 180, 270, 360]), [0, 0.5, 1/sqrt(2), sqrt(3)/2, 1, 0, -1, 0]) - + -class Misc_Tests(unittest.TestCase, Util): - pass - if __name__ == '__main__': unittest.main() From scipy-svn at scipy.org Wed Jul 2 14:21:39 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 13:21:39 -0500 (CDT) Subject: [Scipy-svn] r4522 - trunk/scipy/sandbox/mkufunc/mkufunc Message-ID: <20080702182139.DD4F739C696@scipy.org> Author: ilan Date: 2008-07-02 13:21:39 -0500 (Wed, 02 Jul 2008) New Revision: 4522 Modified: trunk/scipy/sandbox/mkufunc/mkufunc/api.py trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py Log: Added tests. src keyword to mkufunc to show translated C source Modified: trunk/scipy/sandbox/mkufunc/mkufunc/api.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/api.py 2008-07-02 13:24:46 UTC (rev 4521) +++ trunk/scipy/sandbox/mkufunc/mkufunc/api.py 2008-07-02 18:21:39 UTC (rev 4522) @@ -15,6 +15,7 @@ verbose = 0 +showC = 0 def func_hash(f, salt=None): """ Return a MD5 hash for a function object as string. @@ -112,7 +113,7 @@ \s* # possibly whitespace \([^)]*\) # argument types \s* # possibly whitespace - \{.*?[\n\r]\}[\n\r] # function body ending with } in single line + \{.*?\n\}\n # function body ending with } in single line ''' % self.cname, re.DOTALL | re.MULTILINE | re.VERBOSE) @@ -120,7 +121,12 @@ assert len(found) == 1 res = found[0] res = res.replace(self._prefix + 'pypy_g_ll_math_ll_math_', '') - return 'inline ' + res + '\n' + if showC: + print '------------------' + print res + print '------------------' + + return 'inline %s\n' % res def ufunc_support_code(self): # Unfortunately the code in here is very hard to read. @@ -288,7 +294,7 @@ customize=ufunc_info) -def mkufunc(arg0=[float]): +def mkufunc(arg0=[float], src=0): """ Python decorator which returns compiled UFunc of the function given. >>> from numpy import arange @@ -330,7 +336,10 @@ def __call__(self, *args): return self.ufunc(*args) - + + global showC + showC = src + if isinstance(arg0, FunctionType): f = arg0 signatures = [float] Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-02 13:24:46 UTC (rev 4521) +++ trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-02 18:21:39 UTC (rev 4522) @@ -123,10 +123,10 @@ self.assertFuncsEqual(f, lambda x: math.pi * x) def test_e(self): - @mkufunc#(show=1) + @mkufunc def f(x): return math.e * x self.assertFuncsEqual(f, lambda x: math.e * x) - + def test_exp(self): @mkufunc def f(x): return math.exp(x) @@ -217,6 +217,19 @@ a = f(xx, yy) b = [math.pow(x, y) for x, y in zip(xx, yy)] self.assertClose(a, b) + + def test_hypot(self): + @mkufunc + def f(x, y): + return math.hypot(x, y) + + self.assertClose(f(3, 4), 5) + + xx = array([3.0, 2.4, -2.4, 3.1, -2.3, -1.0]) + yy = array([4.0, 7.5, 7.5, -8.7, 0.0, -3.2]) + a = f(xx, yy) + b = [math.hypot(x, y) for x, y in zip(xx, yy)] + self.assertClose(a, b) def test_arithmetic(self): def f(x): From scipy-svn at scipy.org Wed Jul 2 14:33:52 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 13:33:52 -0500 (CDT) Subject: [Scipy-svn] r4523 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080702183352.97ACB39C2B4@scipy.org> Author: ilan Date: 2008-07-02 13:33:52 -0500 (Wed, 02 Jul 2008) New Revision: 4523 Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py trunk/scipy/sandbox/mkufunc/examples/primes.py Log: Primes imports from local directory Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-02 18:21:39 UTC (rev 4522) +++ trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-02 18:33:52 UTC (rev 4523) @@ -2,7 +2,7 @@ from math import sin, cos import time, hashlib -from numpy import arange, vectorize, allclose, empty_like +from numpy import linspace, vectorize, allclose, empty_like from scipy import weave from mkufunc.api import mkufunc @@ -72,7 +72,7 @@ ############################################################# -x = arange(0, 1000, 0.0001) #print "x =", x, x.dtype +x = linspace(0, 1, 10000*1000) start_time = time.time() b_y = empty_like(x) Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-02 18:21:39 UTC (rev 4522) +++ trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-02 18:33:52 UTC (rev 4523) @@ -1,8 +1,11 @@ #!/usr/bin/env python +import sys +sys.path.append('../mkufunc') + from math import sqrt import time -from mkufunc.api import mkufunc +from api import mkufunc def count_primes(N): @@ -17,13 +20,13 @@ start_time = time.time() -assert count_primes(1000000) == 78498 +print count_primes(100000) print 'Python: %.6f sec' % (time.time() - start_time) -count_primes = mkufunc(int)(count_primes) +count_primes = mkufunc(int, src=len(sys.argv)-1)(count_primes) start_time = time.time() -assert count_primes(1000000) == 78498 +print count_primes(100000) print 'Compiled: %.6f sec' % (time.time() - start_time) From scipy-svn at scipy.org Wed Jul 2 19:37:51 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 18:37:51 -0500 (CDT) Subject: [Scipy-svn] r4524 - trunk/scipy/interpolate Message-ID: <20080702233751.C099739C30B@scipy.org> Author: fcady Date: 2008-07-02 18:37:48 -0500 (Wed, 02 Jul 2008) New Revision: 4524 Added: trunk/scipy/interpolate/README Log: added preliminary README file Added: trunk/scipy/interpolate/README =================================================================== --- trunk/scipy/interpolate/README 2008-07-02 18:33:52 UTC (rev 4523) +++ trunk/scipy/interpolate/README 2008-07-02 23:37:48 UTC (rev 4524) @@ -0,0 +1,102 @@ +README FOR INTERPOLATION MODULE + + +Author: Enthought, Inc + Austin, TX + enthough-dev at mail.enthought.com + + +Interpolate is a central package in SciPy, an open-source software package for scientific computing in Python which is maintained by Enthought, Inc. Interpolate provides functionality for a variety of interpolation techniques, particularly those based on splines. + + +A large portion of scipy.interpolate is Python wrappers around the functionality of FITPACK, a Fortran package produced by Pleasant Valley Software for working with curves and surfaces. Scipy.interpolate provides the following wrappers around FITPACK functions: + + splrep -- find smoothing spline given (x,y) points on curve. + splprep -- find smoothing spline given parametrically defined curve. + splev -- evaluate the spline or its derivatives. + splint -- compute definite integral of a spline. + sproot -- find the roots of a cubic spline. + spalde -- compute all derivatives of a spline at given points. + bisplrep -- find bivariate smoothing spline representation. + bisplev -- evaluate bivariate smoothing spline. + + +Other available functions include + + UnivariateSpline -- A more recent, object-oriented wrapper; + finds a (possibly smoothed) interpolating + spline. + InterpolatedUnivariateSpline -- Identical to InivariateSpline, but with + less error checking + LSQUnivariateSpline -- Appears to be identical to UnivariateSplin + with more error checking. Uses weighted + least squares fitting + BivariateSpline -- A more recent, object-oriented wrapper; + finds a interpolating spline for a + bivariate function. + SmoothBivariateSpline -- Smooth bivariate spline approximation + + +A number of other functions and classes are provided, for which README documentation is forthcoming. + +Introductions to interpolation and splines can be found online at: + +http://en.wikipedia.org/wiki/Interpolation + The Wikipedia article on interpolation. Provides an accesible + overview of major areas of the subject, including spline + interpolation. +http://en.wikipedia.org/wiki/Spline_interpolation + The Wikipedia article on spline interpolation. It is accessible + as a conceptual introduction, and contains links to various + algorithms, but discussion is limited to 1D interpolation. + + + +interpolate.BivariateSpline +interpolate.InterpolatedUnivariateSpline +interpolate.LSQBivariateSpline +interpolate.LSQUnivariateSpline +interpolate.NumpyTest +interpolate.RectBivariateSpline +interpolate.SmoothBivariateSpline +interpolate.UnivariateSpline +interpolate.__all__ +interpolate.__class__ +interpolate.__delattr__ +interpolate.__dict__ +interpolate.__doc__ +interpolate.__file__ +interpolate.__getattribute__ +interpolate.__hash__ +interpolate.__init__ +interpolate.__name__ +interpolate.__new__ +interpolate.__path__ +interpolate.__reduce__ +interpolate.__reduce_ex__ +interpolate.__repr__ +interpolate.__setattr__ +interpolate.__str__ +interpolate._fitpack +interpolate.bisplev +interpolate.bisplrep +interpolate.dfitpack +interpolate.fitpack +interpolate.fitpack2 +interpolate.insert +interpolate.interp1d +interpolate.interp2d +interpolate.interpolate +interpolate.lagrange +interpolate.ppform +interpolate.spalde +interpolate.splev +interpolate.spleval +interpolate.spline +interpolate.splint +interpolate.splmake +interpolate.splprep +interpolate.splrep +interpolate.spltopp +interpolate.sproot +interpolate.test From scipy-svn at scipy.org Wed Jul 2 21:11:44 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 20:11:44 -0500 (CDT) Subject: [Scipy-svn] r4525 - in trunk/scipy/sandbox/mkufunc: examples mkufunc Message-ID: <20080703011144.2BE7539C089@scipy.org> Author: ilan Date: 2008-07-02 20:11:42 -0500 (Wed, 02 Jul 2008) New Revision: 4525 Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py trunk/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py Log: Changed imports Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-02 23:37:48 UTC (rev 4524) +++ trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-03 01:11:42 UTC (rev 4525) @@ -1,11 +1,8 @@ #!/usr/bin/env python -import sys -sys.path.append('../mkufunc') - from math import sqrt import time -from api import mkufunc +from mkufunc.api import mkufunc def count_primes(N): Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py 2008-07-02 23:37:48 UTC (rev 4524) +++ trunk/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py 2008-07-03 01:11:42 UTC (rev 4525) @@ -1,6 +1,6 @@ import unittest -from api import func_hash +from mkufunc.api import func_hash class Tests(unittest.TestCase): Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-02 23:37:48 UTC (rev 4524) +++ trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-03 01:11:42 UTC (rev 4525) @@ -3,7 +3,7 @@ from numpy import array, arange, allclose -from api import Cfunc, genufunc, mkufunc +from mkufunc.api import Cfunc, genufunc, mkufunc class Util: From scipy-svn at scipy.org Wed Jul 2 21:18:05 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 2 Jul 2008 20:18:05 -0500 (CDT) Subject: [Scipy-svn] r4526 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080703011805.D808439C089@scipy.org> Author: ilan Date: 2008-07-02 20:18:05 -0500 (Wed, 02 Jul 2008) New Revision: 4526 Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py Log: Added option s (to show C source) to prime.py Modified: trunk/scipy/sandbox/mkufunc/examples/primes.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-03 01:11:42 UTC (rev 4525) +++ trunk/scipy/sandbox/mkufunc/examples/primes.py 2008-07-03 01:18:05 UTC (rev 4526) @@ -1,7 +1,13 @@ #!/usr/bin/env python from math import sqrt -import time +import time, sys +src = 0 +if len(sys.argv) == 2 and sys.argv[1] == 's': + src = 1 + + + from mkufunc.api import mkufunc @@ -21,7 +27,7 @@ print 'Python: %.6f sec' % (time.time() - start_time) -count_primes = mkufunc(int, src=len(sys.argv)-1)(count_primes) +count_primes = mkufunc(int, src=src)(count_primes) start_time = time.time() From scipy-svn at scipy.org Thu Jul 3 13:21:21 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 3 Jul 2008 12:21:21 -0500 (CDT) Subject: [Scipy-svn] r4527 - trunk/scipy/sandbox/mkufunc Message-ID: <20080703172121.E667539C820@scipy.org> Author: ilan Date: 2008-07-03 12:21:20 -0500 (Thu, 03 Jul 2008) New Revision: 4527 Modified: trunk/scipy/sandbox/mkufunc/TODO.txt Log: Modified: trunk/scipy/sandbox/mkufunc/TODO.txt =================================================================== --- trunk/scipy/sandbox/mkufunc/TODO.txt 2008-07-03 01:18:05 UTC (rev 4526) +++ trunk/scipy/sandbox/mkufunc/TODO.txt 2008-07-03 17:21:20 UTC (rev 4527) @@ -0,0 +1,6 @@ + +- add Csrc attribute to ufunc object + +- Mandelbrot + + From scipy-svn at scipy.org Fri Jul 4 14:28:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 4 Jul 2008 13:28:33 -0500 (CDT) Subject: [Scipy-svn] r4528 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080704182833.19EFE39C11D@scipy.org> Author: ilan Date: 2008-07-04 13:28:31 -0500 (Fri, 04 Jul 2008) New Revision: 4528 Added: trunk/scipy/sandbox/mkufunc/examples/mandel.py Log: Added Mandelbrot UFunc example Added: trunk/scipy/sandbox/mkufunc/examples/mandel.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel.py 2008-07-03 17:21:20 UTC (rev 4527) +++ trunk/scipy/sandbox/mkufunc/examples/mandel.py 2008-07-04 18:28:31 UTC (rev 4528) @@ -0,0 +1,93 @@ +#!/usr/bin/env python +""" +>>> mandel(-1, .3) +36 +>>> mandel(0, 0) +-1 +>>> mandel(10, 10) +1 +>>> mandel(N.array([-1, 0, 10]), N.array([.3, 0, 10])) +array([36, -1, 1]) +""" +import hashlib + +import numpy as N +from scipy import weave + +support_code = ''' +#define D 1000 + +long depth(double cr, double ci) +{ + long d = 1; + double zr=cr, zi=ci, zr2, zi2; + for(;;) { + zr2 = zr * zr; + zi2 = zi * zi; + if( zr2+zi2 > 16.0 ) return d; + if( ++d == D ) return -1; + zi = 2.0 * zr * zi + ci; + zr = zr2 - zi2 + cr; + } +} + +static void +PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) +{ + npy_intp i, n; + npy_intp is0 = steps[0]; + npy_intp is1 = steps[1]; + npy_intp os = steps[2]; + char *ip0 = args[0]; + char *ip1 = args[1]; + char *op = args[2]; + n = dimensions[0]; + double cr, ci; + + for(i = 0; i < n; i++) { + cr = *(double *)ip0; + ci = *(double *)ip1; + long *out = (long *)op; + + *out = depth(cr, ci); + + ip0 += is0; + ip1 += is1; + op += os; + } +} + +static PyUFuncGenericFunction f_functions[] = { + PyUFunc_0, +}; + +static char f_types[] = { + NPY_DOUBLE, NPY_DOUBLE, NPY_LONG, +}; +''' +ufunc_info = weave.base_info.custom_info() +ufunc_info.add_header('"numpy/ufuncobject.h"') + +mandel = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/ +import_ufunc(); + +return_val = PyUFunc_FromFuncAndData( + f_functions, + NULL, + f_types, + 1, /* ntypes */ + 2, /* nin */ + 1, /* nout */ + PyUFunc_None, /* identity */ + "mandel", /* name */ + "returns depth from cr, ci", /* doc */ + 0); + ''', + support_code=support_code, + verbose=0, + customize=ufunc_info) + + +if __name__ == '__main__': + import doctest + doctest.testmod() Property changes on: trunk/scipy/sandbox/mkufunc/examples/mandel.py ___________________________________________________________________ Name: svn:executable + * From scipy-svn at scipy.org Sat Jul 5 12:18:47 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 5 Jul 2008 11:18:47 -0500 (CDT) Subject: [Scipy-svn] r4529 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080705161847.4A24C39C04C@scipy.org> Author: ilan Date: 2008-07-05 11:18:46 -0500 (Sat, 05 Jul 2008) New Revision: 4529 Modified: trunk/scipy/sandbox/mkufunc/examples/mandel.py Log: Improved example Modified: trunk/scipy/sandbox/mkufunc/examples/mandel.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel.py 2008-07-04 18:28:31 UTC (rev 4528) +++ trunk/scipy/sandbox/mkufunc/examples/mandel.py 2008-07-05 16:18:46 UTC (rev 4529) @@ -6,18 +6,18 @@ -1 >>> mandel(10, 10) 1 ->>> mandel(N.array([-1, 0, 10]), N.array([.3, 0, 10])) +>>> mandel(array([-1, 0, 10]), array([.3, 0, 10])) array([36, -1, 1]) """ import hashlib -import numpy as N +from numpy import array from scipy import weave support_code = ''' #define D 1000 -long depth(double cr, double ci) +long iterations(double cr, double ci) { long d = 1; double zr=cr, zi=ci, zr2, zi2; @@ -42,15 +42,10 @@ char *ip1 = args[1]; char *op = args[2]; n = dimensions[0]; - double cr, ci; for(i = 0; i < n; i++) { - cr = *(double *)ip0; - ci = *(double *)ip1; - long *out = (long *)op; - - *out = depth(cr, ci); - + *(long *)op = iterations(*(double *)ip0, + *(double *)ip1); ip0 += is0; ip1 += is1; op += os; @@ -80,7 +75,7 @@ 1, /* nout */ PyUFunc_None, /* identity */ "mandel", /* name */ - "returns depth from cr, ci", /* doc */ + "returns number of iterations from cr, ci", /* doc */ 0); ''', support_code=support_code, From scipy-svn at scipy.org Sun Jul 6 09:34:07 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 6 Jul 2008 08:34:07 -0500 (CDT) Subject: [Scipy-svn] r4530 - trunk/scipy/fftpack Message-ID: <20080706133407.E4F0D39C743@scipy.org> Author: cdavid Date: 2008-07-06 08:33:56 -0500 (Sun, 06 Jul 2008) New Revision: 4530 Modified: trunk/scipy/fftpack/SConscript Log: Do not use Glob until reorder bug in scons is solved. Modified: trunk/scipy/fftpack/SConscript =================================================================== --- trunk/scipy/fftpack/SConscript 2008-07-05 16:18:46 UTC (rev 4529) +++ trunk/scipy/fftpack/SConscript 2008-07-06 13:33:56 UTC (rev 4530) @@ -30,7 +30,11 @@ pass # Build dfftpack -src = env.Glob(pjoin('dfftpack', '*.f')) +src = [pjoin("dfftpack", i) for i in [ "dcosqb.f", "dcosqf.f", "dcosqi.f", +"dcost.f", "dcosti.f", "dfftb.f", "dfftb1.f", "dfftf.f", "dfftf1.f", "dffti.f", +"dffti1.f", "dsinqb.f", "dsinqf.f", "dsinqi.f", "dsint.f", "dsint1.f", +"dsinti.f", "zfftb.f", "zfftb1.f", "zfftf.f", "zfftf1.f", "zffti.f", +"zffti1.f"]] dfftpack = env.DistutilsStaticExtLibrary('dfftpack', source = [str(s) for s in src]) env.PrependUnique(LIBS = ['dfftpack']) env.PrependUnique(LIBPATH = ['.']) From scipy-svn at scipy.org Sun Jul 6 12:41:06 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 6 Jul 2008 11:41:06 -0500 (CDT) Subject: [Scipy-svn] r4531 - in trunk/scipy: integrate interpolate optimize sparse/linalg/dsolve sparse/linalg/eigen/arpack stats Message-ID: <20080706164106.2C40F39C3F0@scipy.org> Author: cdavid Date: 2008-07-06 11:40:48 -0500 (Sun, 06 Jul 2008) New Revision: 4531 Modified: trunk/scipy/integrate/SConscript trunk/scipy/interpolate/SConscript trunk/scipy/optimize/SConscript trunk/scipy/sparse/linalg/dsolve/SConscript trunk/scipy/sparse/linalg/eigen/arpack/SConscript trunk/scipy/stats/SConscript Log: Remove most Glob usage as a temp workaround for Glob scons ordering bug. Modified: trunk/scipy/integrate/SConscript =================================================================== --- trunk/scipy/integrate/SConscript 2008-07-06 13:33:56 UTC (rev 4530) +++ trunk/scipy/integrate/SConscript 2008-07-06 16:40:48 UTC (rev 4531) @@ -26,20 +26,37 @@ # XXX: lapack integration # Build linpack_lite -src = [str(s) for s in env.Glob(pjoin('linpack_lite', '*.f'))] +src = [pjoin("linpack_lite", s) for s in [ "dgbfa.f", "dgbsl.f", "dgefa.f", +"dgesl.f", "dgtsl.f", "zgbfa.f", "zgbsl.f", "zgefa.f", "zgesl.f"]] linpack_lite = env.DistutilsStaticExtLibrary('linpack_lite', source = src) # Build mach # XXX: do not use optimization flags for mach -src = [str(s) for s in env.Glob(pjoin('mach', '*.f'))] +src = [pjoin("mach", s) for s in ["d1mach.f", "i1mach.f", "r1mach.f", +"xerror.f"]] mach = env.DistutilsStaticExtLibrary('mach', source = src) # Build quadpack -src = [str(s) for s in env.Glob(pjoin('quadpack', '*.f'))] +src = [pjoin("quadpack", s) for s in ["dqag.f", "dqage.f", "dqagi.f", +"dqagie.f", "dqagp.f", "dqagpe.f", "dqags.f", "dqagse.f", "dqawc.f", +"dqawce.f", "dqawf.f", "dqawfe.f", "dqawo.f", "dqawoe.f", "dqaws.f", +"dqawse.f", "dqc25c.f", "dqc25f.f", "dqc25s.f", "dqcheb.f", "dqelg.f", +"dqk15.f", "dqk15i.f", "dqk15w.f", "dqk21.f", "dqk31.f", "dqk41.f", "dqk51.f", +"dqk61.f", "dqmomo.f", "dqng.f", "dqpsrt.f", "dqwgtc.f", "dqwgtf.f", +"dqwgts.f"]] quadpack = env.DistutilsStaticExtLibrary('quadpack', source = src) # Build odepack -src = [str(s) for s in env.Glob(pjoin('odepack', '*.f'))] +src = [pjoin("odepack", s) for s in [ "adjlr.f", "aigbt.f", "ainvg.f", +"blkdta000.f", "bnorm.f", "cdrv.f", "cfode.f", "cntnzu.f", "ddasrt.f", +"ddassl.f", "decbt.f", "ewset.f", "fnorm.f", "intdy.f", "iprep.f", "jgroup.f", +"lsoda.f", "lsodar.f", "lsode.f", "lsodes.f", "lsodi.f", "lsoibt.f", "md.f", +"mdi.f", "mdm.f", "mdp.f", "mdu.f", "nnfc.f", "nnsc.f", "nntc.f", "nroc.f", +"nsfc.f", "odrv.f", "pjibt.f", "prep.f", "prepj.f", "prepji.f", "prja.f", +"prjs.f", "rchek.f", "roots.f", "slsbt.f", "slss.f", "solbt.f", +"solsy.f", "srcar.f", "srcma.f", "srcms.f", "srcom.f", "sro.f", "stoda.f", +"stode.f", "stodi.f", "vmnorm.f", "vnorm.f", "vode.f", "xerrwv.f", "xsetf.f", +"xsetun.f", "zvode.f"]] odepack = env.DistutilsStaticExtLibrary('odepack', source = src) env.AppendUnique(LIBPATH = '.') Modified: trunk/scipy/interpolate/SConscript =================================================================== --- trunk/scipy/interpolate/SConscript 2008-07-06 13:33:56 UTC (rev 4530) +++ trunk/scipy/interpolate/SConscript 2008-07-06 16:40:48 UTC (rev 4531) @@ -18,7 +18,21 @@ env.AppendUnique(LINKFLAGSEND = env['F77_LDFLAGS']) # Build fitpack -src = [str(s) for s in env.Glob(pjoin('fitpack', '*.f'))] +src = [pjoin("fitpack", s) for s in ["bispev.f", "clocur.f", "cocosp.f", +"concon.f", "concur.f", "cualde.f", "curev.f", "curfit.f", "dblint.f", +"evapol.f", "fourco.f", "fpader.f", "fpadno.f", "fpadpo.f", "fpback.f", +"fpbacp.f", "fpbfout.f", "fpbisp.f", "fpbspl.f", "fpchec.f", "fpched.f", +"fpchep.f", "fpclos.f", "fpcoco.f", "fpcons.f", "fpcosp.f", "fpcsin.f", +"fpcurf.f", "fpcuro.f", "fpcyt1.f", "fpcyt2.f", "fpdeno.f", "fpdisc.f", +"fpfrno.f", "fpgivs.f", "fpgrdi.f", "fpgrpa.f", "fpgrre.f", "fpgrsp.f", +"fpinst.f", "fpintb.f", "fpknot.f", "fpopdi.f", "fpopsp.f", "fporde.f", +"fppara.f", "fppasu.f", "fpperi.f", "fppocu.f", "fppogr.f", "fppola.f", +"fprank.f", "fprati.f", "fpregr.f", "fprota.f", "fprppo.f", "fprpsp.f", +"fpseno.f", "fpspgr.f", "fpsphe.f", "fpsuev.f", "fpsurf.f", "fpsysy.f", +"fptrnp.f", "fptrpe.f", "insert.f", "parcur.f", "parder.f", "parsur.f", +"percur.f", "pogrid.f", "polar.f", "profil.f", "regrid.f", "spalde.f", +"spgrid.f", "sphere.f", "splder.f", "splev.f", "splint.f", "sproot.f", +"surev.f", "surfit.f"]] fitpack = env.DistutilsStaticExtLibrary('fitpack', source = src) env.PrependUnique(LIBS = ['fitpack']) Modified: trunk/scipy/optimize/SConscript =================================================================== --- trunk/scipy/optimize/SConscript 2008-07-06 13:33:56 UTC (rev 4530) +++ trunk/scipy/optimize/SConscript 2008-07-06 16:40:48 UTC (rev 4531) @@ -48,11 +48,16 @@ #========== # minpack lib -minpack_src = [str(s) for s in env.Glob(pjoin('minpack', '*.f'))] +minpack_src = [pjoin("minpack", s) for s in ["chkder.f", "dogleg.f", +"dpmpar.f", "enorm.f", "fdjac1.f", "fdjac2.f", "hybrd.f", "hybrd1.f", +"hybrj.f", "hybrj1.f", "lmder.f", "lmder1.f", "lmdif.f", "lmdif1.f", "lmpar.f", +"lmstr.f", "lmstr1.f", "minpack.txt", "qform.f", "qrfac.f", "qrsolv.f", +"r1mpyq.f", "r1updt.f", "rwupdt.f"]] env.DistutilsStaticExtLibrary('minpack', source = minpack_src) # rootfind lib -rootfind_src = [str(s) for s in env.Glob(pjoin('Zeros', '*.c'))] +rootfind_src = [pjoin("Zeros", s) for s in ["bisect.c", "brenth.c", +"brentq.c", "ridder.c"]] env.DistutilsStaticExtLibrary('rootfind', source = rootfind_src) env.AppendUnique(LIBS = ['minpack', 'rootfind']) Modified: trunk/scipy/sparse/linalg/dsolve/SConscript =================================================================== --- trunk/scipy/sparse/linalg/dsolve/SConscript 2008-07-06 13:33:56 UTC (rev 4530) +++ trunk/scipy/sparse/linalg/dsolve/SConscript 2008-07-06 16:40:48 UTC (rev 4531) @@ -32,7 +32,30 @@ superlu_def['USE_VENDOR_BLAS'] = 2 superlu_env.Append(CPPDEFINES = superlu_def) -superlu_src = superlu_env.Glob(pjoin('SuperLU', 'SRC', '*.c')) +superlu_src = [pjoin('SuperLU', 'SRC', s) for s in [ "ccolumn_bmod.c", +"ccolumn_dfs.c", "ccopy_to_ucol.c", "cgscon.c", "cgsequ.c", "cgsrfs.c", +"cgssv.c", "cgssvx.c", "cgstrf.c", "cgstrs.c", "clacon.c", "clangs.c", +"claqgs.c", "cmemory.c", "colamd.c", "cpanel_bmod.c", "cpanel_dfs.c", +"cpivotL.c", "cpivotgrowth.c", "cpruneL.c", "creadhb.c", "csnode_bmod.c", +"csnode_dfs.c", "csp_blas2.c", "csp_blas3.c", "cutil.c", "dGetDiagU.c", +"dcolumn_bmod.c", "dcolumn_dfs.c", "dcomplex.c", "dcopy_to_ucol.c", "dgscon.c", +"dgsequ.c", "dgsrfs.c", "dgssv.c", "dgssvx.c", "dgstrf.c", "dgstrs.c", +"dgstrsL.c", "dlacon.c", "dlamch.c", "dlangs.c", "dlaqgs.c", "dmemory.c", +"dpanel_bmod.c", "dpanel_dfs.c", "dpivotL.c", "dpivotgrowth.c", "dpruneL.c", +"dreadhb.c", "dsnode_bmod.c", "dsnode_dfs.c", "dsp_blas2.c", "dsp_blas3.c", +"dutil.c", "dzsum1.c", "get_perm_c.c", "heap_relax_snode.c", "icmax1.c", +"izmax1.c", "lsame.c", "memory.c", "mmd.c", "relax_snode.c", "scolumn_bmod.c", +"scolumn_dfs.c", "scomplex.c", "scopy_to_ucol.c", "scsum1.c", "sgscon.c", +"sgsequ.c", "sgsrfs.c", "sgssv.c", "sgssvx.c", "sgstrf.c", "sgstrs.c", +"slacon.c", "slamch.c", "slangs.c", "slaqgs.c", "smemory.c", "sp_coletree.c", +"sp_ienv.c", "sp_preorder.c", "spanel_bmod.c", "spanel_dfs.c", "spivotL.c", +"spivotgrowth.c", "spruneL.c", "sreadhb.c", "ssnode_bmod.c", "ssnode_dfs.c", +"ssp_blas2.c", "ssp_blas3.c", "superlu_timer.c", "sutil.c", "util.c", +"xerbla.c", "zcolumn_bmod.c", "zcolumn_dfs.c", "zcopy_to_ucol.c", "zgscon.c", +"zgsequ.c", "zgsrfs.c", "zgssv.c", "zgssvx.c", "zgstrf.c", "zgstrs.c", +"zlacon.c", "zlangs.c", "zlaqgs.c", "zmemory.c", "zpanel_bmod.c", +"zpanel_dfs.c", "zpivotL.c", "zpivotgrowth.c", "zpruneL.c", "zreadhb.c", +"zsnode_bmod.c", "zsnode_dfs.c", "zsp_blas2.c", "zsp_blas3.c", "zutil.c"]] superlu = superlu_env.DistutilsStaticExtLibrary('superlu_src', source = superlu_src) # Build python extensions Modified: trunk/scipy/sparse/linalg/eigen/arpack/SConscript =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-06 13:33:56 UTC (rev 4530) +++ trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-06 16:40:48 UTC (rev 4531) @@ -27,10 +27,26 @@ write_info(env) # Build arpack -arpack_src = env.Glob(pjoin('ARPACK', 'SRC', '*.f')) -arpack_src += env.Glob(pjoin('ARPACK', 'UTIL', '*.f')) -arpack_src += env.Glob(pjoin('ARPACK', 'LAPACK', '*.f')) +arpack_src = [pjoin("ARPACK", "SRC", s) for s in [ "cgetv0.f", "cnaitr.f", +"cnapps.f", "cnaup2.f", "cnaupd.f", "cneigh.f", "cneupd.f", "cngets.f", +"csortc.f", "cstatn.f", "dgetv0.f", "dlaqrb.f", "dnaitr.f", "dnapps.f", +"dnaup2.f", "dnaupd.f", "dnconv.f", "dneigh.f", "dneupd.f", "dngets.f", +"dsaitr.f", "dsapps.f", "dsaup2.f", "dsaupd.f", "dsconv.f", "dseigt.f", +"dsesrt.f", "dseupd.f", "dsgets.f", "dsortc.f", "dsortr.f", "dstatn.f", +"dstats.f", "dstqrb.f", "sgetv0.f", "slaqrb.f", "snaitr.f", "snapps.f", +"snaup2.f", "snaupd.f", "snconv.f", "sneigh.f", "sneupd.f", "sngets.f", +"ssaitr.f", "ssapps.f", "ssaup2.f", "ssaupd.f", "ssconv.f", "sseigt.f", +"ssesrt.f", "sseupd.f", "ssgets.f", "ssortc.f", "ssortr.f", "sstatn.f", +"sstats.f", "sstqrb.f", "zgetv0.f", "znaitr.f", "znapps.f", "znaup2.f", +"znaupd.f", "zneigh.f", "zneupd.f", "zngets.f", "zsortc.f", "zstatn.f"]] +arpack_src += [pjoin('ARPACK', 'UTIL', s) for s in [ "cmout.f", "cvout.f", +"dmout.f", "dvout.f", "icnteq.f", "icopy.f", "iset.f", "iswap.f", "ivout.f", +"second.f", "smout.f", "svout.f", "zmout.f", "zvout.f"]] + +arpack_src += [pjoin('ARPACK', 'LAPACK', s) for s in [ "clahqr.f", "dlahqr.f", +"slahqr.f", "zlahqr.f"]] + src = [str(s) for s in arpack_src] env.AppendUnique(CPPPATH = pjoin('ARPACK', 'SRC')) Modified: trunk/scipy/stats/SConscript =================================================================== --- trunk/scipy/stats/SConscript 2008-07-06 13:33:56 UTC (rev 4530) +++ trunk/scipy/stats/SConscript 2008-07-06 16:40:48 UTC (rev 4531) @@ -18,7 +18,7 @@ config.Finish() # Statlib library -src = env.Glob(pjoin('statlib', '*.f' )) +src = [pjoin("statlib", s) for s in [ "ansari.f", "spearman.f", "swilk.f"]] env.DistutilsStaticExtLibrary('statlibimp', source = src) env.AppendUnique(LIBPATH = '.') From scipy-svn at scipy.org Tue Jul 8 05:49:01 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 8 Jul 2008 04:49:01 -0500 (CDT) Subject: [Scipy-svn] r4532 - in trunk/scipy/sparse: . benchmarks sparsetools tests Message-ID: <20080708094901.5284539C071@scipy.org> Author: wnbell Date: 2008-07-08 04:47:43 -0500 (Tue, 08 Jul 2008) New Revision: 4532 Modified: trunk/scipy/sparse/base.py trunk/scipy/sparse/benchmarks/bench_sparse.py trunk/scipy/sparse/bsr.py trunk/scipy/sparse/compressed.py trunk/scipy/sparse/coo.py trunk/scipy/sparse/data.py trunk/scipy/sparse/dia.py trunk/scipy/sparse/dok.py trunk/scipy/sparse/lil.py trunk/scipy/sparse/sparsetools/bsr.h trunk/scipy/sparse/sparsetools/bsr_wrap.cxx trunk/scipy/sparse/sparsetools/coo.i trunk/scipy/sparse/sparsetools/coo.py trunk/scipy/sparse/sparsetools/coo_wrap.cxx trunk/scipy/sparse/sparsetools/csc_wrap.cxx trunk/scipy/sparse/sparsetools/csr.h trunk/scipy/sparse/sparsetools/csr_wrap.cxx trunk/scipy/sparse/sparsetools/dia_wrap.cxx trunk/scipy/sparse/tests/test_base.py Log: refactored sparse matrix multiplication handlers added coo.matvec Modified: trunk/scipy/sparse/base.py =================================================================== --- trunk/scipy/sparse/base.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/base.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -6,7 +6,8 @@ from warnings import warn import numpy -from numpy import asarray, asmatrix, asanyarray, ones, deprecate +from numpy import asarray, asmatrix, asanyarray, ones, deprecate, ravel, \ + matrix from sputils import isdense, isscalarlike, isintlike @@ -66,10 +67,10 @@ try: shape = int(shape[0]),int(shape[1]) #floats, other weirdness except: - raise TypeError,'invalid shape' + raise TypeError('invalid shape') if not (shape[0] >= 1 and shape[1] >= 1): - raise TypeError,'invalid shape' + raise TypeError('invalid shape') if (self._shape != shape) and (self._shape is not None): try: @@ -215,6 +216,11 @@ # and operations return in csr format # thus, a new sparse matrix format just needs to define # a tocsr method + + def multiply(self, other): + """Point-wise multiplication by another matrix + """ + return self.tocsr().multiply(other) def __abs__(self): return abs(self.tocsr()) @@ -231,15 +237,85 @@ def __rsub__(self, other): # other - self return self.tocsr().__rsub__(other) + + # old __mul__ interfaces + def matvec(self, other): + return self * other + def matmat(self, other): + return self * other + def dot(self, other): + return self * other - def multiply(self, other): - """Point-wise multiplication by another matrix + def __mul__(self, other): + """interpret other and call one of the following + + self._mul_scalar() + self._mul_vector() + self._mul_sparse_matrix() + self._mul_dense_matrix() """ - return self.tocsr().multiply(other) - def __mul__(self, other): - return self.tocsr().__mul__(other) + M,N = self.shape + + if isscalarlike(other): + # scalar value + return self._mul_scalar(other) + + if issparse(other): + return self._mul_sparse_matrix(other) + try: + other.shape + except AttributeError: + # If it's a list or whatever, treat it like a matrix + other = asanyarray(other) + + if isdense(other) and asarray(other).squeeze().ndim <= 1: + ## + # dense row or column vector + if other.shape != (N,) and other.shape != (N,1): + raise ValueError('dimension mismatch') + + result = self._mul_vector(ravel(other)) + + if isinstance(other, matrix): + result = asmatrix(result) + + if other.ndim == 2 and other.shape[1] == 1: + # If 'other' was an (nx1) column vector, reshape the result + result = result.reshape(-1,1) + + return result + + elif len(other.shape) == 2: + ## + # dense 2D array or matrix + + if other.shape[0] != self.shape[1]: + raise ValueError('dimension mismatch') + + result = self._mul_dense_matrix(asarray(other)) + + if isinstance(other, matrix): + result = asmatrix(result) + + return result + else: + raise ValueError('could not interpret dimensions') + + # by default, use CSR for __mul__ handlers + def _mul_scalar(self, other): + return self.tocsr()._mul_scalar(other) + + def _mul_vector(self, other): + return self.tocsr()._mul_vector(other) + + def _mul_dense_matrix(self, other): + return self.tocsr()._mul_dense_matrix(other) + + def _mul_sparse_matrix(self, other): + return self.tocsr()._mul_sparse_matrix(other) + def __rmul__(self, other): return self.tocsr().__rmul__(other) @@ -384,36 +460,7 @@ a[0, i] = 1 return a * self - def dot(self, other): - """ A generic interface for matrix-matrix or matrix-vector - multiplication. - """ - try: - other.shape - except AttributeError: - # If it's a list or whatever, treat it like a matrix - other = asanyarray(other) - - if isdense(other) and asarray(other).squeeze().ndim <= 1: - # it's a dense row or column vector - return self.matvec(other) - elif len(other.shape) == 2: - # it's a 2d dense array, dense matrix, or sparse matrix - return self.matmat(other) - else: - raise ValueError, "could not interpret dimensions" - - - def matmat(self, other): - return self.tocsr().matmat(other) - - def matvec(self, other): - """Multiplies the sparse matrix by the vector 'other', returning a - dense vector as a result. - """ - return self.tocsr().matvec(other) - def rmatvec(self, other, conjugate=True): """Multiplies the vector 'other' by the sparse matrix, returning a dense vector as a result. @@ -442,7 +489,7 @@ return asmatrix(self.toarray()) def toarray(self): - return self.tocsr().toarray() + return self.tocoo().toarray() def todok(self): return self.tocoo().todok() Modified: trunk/scipy/sparse/benchmarks/bench_sparse.py =================================================================== --- trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -116,6 +116,7 @@ iter = 0 while iter < 5 and time.clock() - start < 1: A.has_sorted_indices = False + A.indices[:2] = 2,1 A.sort_indices() iter += 1 end = time.clock() @@ -130,6 +131,7 @@ matrices.append(('Identity', sparse.identity(10**4,format='dia'))) matrices.append(('Identity', sparse.identity(10**4,format='csr'))) matrices.append(('Poisson5pt', poisson2d(300,format='dia'))) + matrices.append(('Poisson5pt', poisson2d(300,format='coo'))) matrices.append(('Poisson5pt', poisson2d(300,format='csr'))) matrices.append(('Poisson5pt', poisson2d(300,format='bsr'))) Modified: trunk/scipy/sparse/bsr.py =================================================================== --- trunk/scipy/sparse/bsr.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/bsr.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -283,114 +283,72 @@ # Arithmetic methods # ###################### - def matvec(self, other, output=None): - """Sparse matrix vector product (self * other) + def matvec(self, other): + return self * other - 'other' may be a rank 1 array of length N or a rank 2 array - or matrix with shape (N,1). + def matmat(self, other): + return self * other - If the optional 'output' parameter is defined, it will - be used to store the result. Otherwise, a new vector - will be allocated. + def _mul_vector(self, other): + M,N = self.shape + R,C = self.blocksize - """ - if isdense(other): - M,N = self.shape - R,C = self.blocksize + result = zeros( self.shape[0], dtype=upcast(self.dtype, other.dtype) ) - if other.shape != (N,) and other.shape != (N,1): - raise ValueError, "dimension mismatch" + bsr_matvec(M/R, N/C, R, C, \ + self.indptr, self.indices, ravel(self.data), other, result) - #output array - if output is None: - y = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) - else: - if output.shape != (M,) and output.shape != (M,1): - raise ValueError, "output array has improper dimensions" - if not output.flags.c_contiguous: - raise ValueError, "output array must be contiguous" - if output.dtype != upcast(self.dtype,other.dtype): - raise ValueError, "output array has dtype=%s "\ - "dtype=%s is required" % \ - (output.dtype,upcast(self.dtype,other.dtype)) - y = output + return result + def _mul_dense_matrix(self, other): + # TODO make sparse * dense matrix multiplication more efficient + # matvec each column of other + result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) + return result - bsr_matvec(M/R, N/C, R, C, \ - self.indptr, self.indices, ravel(self.data), ravel(other), y) + def _mul_sparse_matrix(self, other): + M, K1 = self.shape + K2, N = other.shape - if isinstance(other, matrix): - y = asmatrix(y) + indptr = empty_like( self.indptr ) - if other.ndim == 2 and other.shape[1] == 1: - # If 'other' was an (nx1) column vector, reshape the result - y = y.reshape(-1,1) + R,n = self.blocksize - return y + #convert to this format + if isspmatrix_bsr(other): + C = other.blocksize[1] + else: + C = 1 - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" + from csr import isspmatrix_csr + if isspmatrix_csr(other) and n == 1: + other = other.tobsr(blocksize=(n,C),copy=False) #convert to this format else: - raise TypeError, "need a dense vector" + other = other.tobsr(blocksize=(n,C)) + csr_matmat_pass1( M/R, N/C, \ + self.indptr, self.indices, \ + other.indptr, other.indices, \ + indptr) - def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" + bnnz = indptr[-1] + indices = empty( bnnz, dtype=intc) + data = empty( R*C*bnnz, dtype=upcast(self.dtype,other.dtype)) - indptr = empty_like( self.indptr ) + bsr_matmat_pass2( M/R, N/C, R, C, n, \ + self.indptr, self.indices, ravel(self.data), \ + other.indptr, other.indices, ravel(other.data), \ + indptr, indices, data) - R,n = self.blocksize + data = data.reshape(-1,R,C) + #TODO eliminate zeros - #convert to this format - if isspmatrix_bsr(other): - C = other.blocksize[1] - else: - C = 1 + return bsr_matrix((data,indices,indptr),shape=(M,N),blocksize=(R,C)) - from csr import isspmatrix_csr - if isspmatrix_csr(other) and n == 1: - other = other.tobsr(blocksize=(n,C),copy=False) #convert to this format - else: - other = other.tobsr(blocksize=(n,C)) - csr_matmat_pass1( M/R, N/C, \ - self.indptr, self.indices, \ - other.indptr, other.indices, \ - indptr) - - bnnz = indptr[-1] - indices = empty( bnnz, dtype=intc) - data = empty( R*C*bnnz, dtype=upcast(self.dtype,other.dtype)) - - bsr_matmat_pass2( M/R, N/C, R, C, n, \ - self.indptr, self.indices, ravel(self.data), \ - other.indptr, other.indices, ravel(other.data), \ - indptr, indices, data) - - data = data.reshape(-1,R,C) - #TODO eliminate zeros - - return bsr_matrix((data,indices,indptr),shape=(M,N),blocksize=(R,C)) - elif isdense(other): - # TODO make sparse * dense matrix multiplication more efficient - - # matvec each column of other - result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) - if isinstance(other, matrix): - result = asmatrix(result) - return result - - else: - raise TypeError, "need a dense or sparse matrix" - - ###################### # Conversion methods # ###################### Modified: trunk/scipy/sparse/compressed.py =================================================================== --- trunk/scipy/sparse/compressed.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/compressed.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -227,15 +227,6 @@ raise NotImplementedError - def __mul__(self, other): # self * other - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - return self._with_data(self.data * other) - else: - return self.dot(other) - - def __rmul__(self, other): # other * self if isscalarlike(other): return self.__mul__(other) @@ -245,7 +236,7 @@ tr = other.transpose() except AttributeError: tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() + return (self.transpose() * tr).transpose() def __truediv__(self,other): @@ -274,102 +265,157 @@ other = self.__class__(other) return self._binopt(other,'_elmul_') - def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - #return self._binopt(other,'mu',in_shape=(M,N),out_shape=(M,N)) + ########################### + # Multiplication handlers # + ########################### - major_axis = self._swap((M,N))[0] - indptr = empty( major_axis + 1, dtype=intc ) + def _mul_vector(self, other): + M,N = self.shape - other = self.__class__(other) #convert to this format - fn = getattr(sparsetools, self.format + '_matmat_pass1') - fn( M, N, self.indptr, self.indices, \ - other.indptr, other.indices, \ - indptr) + #output array + result = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) + + # csrmux, cscmux + fn = getattr(sparsetools,self.format + '_matvec') + fn(M, N, self.indptr, self.indices, self.data, other, result) + + return result - nnz = indptr[-1] - indices = empty( nnz, dtype=intc) - data = empty( nnz, dtype=upcast(self.dtype,other.dtype)) - fn = getattr(sparsetools, self.format + '_matmat_pass2') - fn( M, N, self.indptr, self.indices, self.data, \ - other.indptr, other.indices, other.data, \ - indptr, indices, data) + def _mul_dense_matrix(self,other): + # TODO make sparse * dense matrix multiplication more efficient + # matvec each column of other + return hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) - return self.__class__((data,indices,indptr),shape=(M,N)) + + def _mul_sparse_matrix(self, other): + M, K1 = self.shape + K2, N = other.shape + major_axis = self._swap((M,N))[0] + indptr = empty( major_axis + 1, dtype=intc ) - elif isdense(other): - # TODO make sparse * dense matrix multiplication more efficient - - # matvec each column of other - result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) - if isinstance(other, matrix): - result = asmatrix(result) - return result + other = self.__class__(other) #convert to this format + fn = getattr(sparsetools, self.format + '_matmat_pass1') + fn( M, N, self.indptr, self.indices, \ + other.indptr, other.indices, \ + indptr) - else: - raise TypeError, "need a dense or sparse matrix" + nnz = indptr[-1] + indices = empty( nnz, dtype=intc) + data = empty( nnz, dtype=upcast(self.dtype,other.dtype)) - def matvec(self, other, output=None): - """Sparse matrix vector product (self * other) + fn = getattr(sparsetools, self.format + '_matmat_pass2') + fn( M, N, self.indptr, self.indices, self.data, \ + other.indptr, other.indices, other.data, \ + indptr, indices, data) - 'other' may be a rank 1 array of length N or a rank 2 array - or matrix with shape (N,1). + return self.__class__((data,indices,indptr),shape=(M,N)) + + def matvec(self,other): + return self * other + + def matmat(self,other): + return self * other - """ - #If the optional 'output' parameter is defined, it will - #be used to store the result. Otherwise, a new vector - #will be allocated. + #def matmat(self, other): + # if isspmatrix(other): + # M, K1 = self.shape + # K2, N = other.shape + # if (K1 != K2): + # raise ValueError, "shape mismatch error" - if isdense(other): - M,N = self.shape + # #return self._binopt(other,'mu',in_shape=(M,N),out_shape=(M,N)) - if other.shape != (N,) and other.shape != (N,1): - raise ValueError, "dimension mismatch" + # major_axis = self._swap((M,N))[0] + # indptr = empty( major_axis + 1, dtype=intc ) - # csrmux, cscmux - fn = getattr(sparsetools,self.format + '_matvec') + # other = self.__class__(other) #convert to this format + # fn = getattr(sparsetools, self.format + '_matmat_pass1') + # fn( M, N, self.indptr, self.indices, \ + # other.indptr, other.indices, \ + # indptr) - #output array - y = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) + # nnz = indptr[-1] + # indices = empty( nnz, dtype=intc) + # data = empty( nnz, dtype=upcast(self.dtype,other.dtype)) - #if output is None: - # y = empty( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) - #else: - # if output.shape != (M,) and output.shape != (M,1): - # raise ValueError, "output array has improper dimensions" - # if not output.flags.c_contiguous: - # raise ValueError, "output array must be contiguous" - # if output.dtype != upcast(self.dtype,other.dtype): - # raise ValueError, "output array has dtype=%s "\ - # "dtype=%s is required" % \ - # (output.dtype,upcast(self.dtype,other.dtype)) - # y = output + # fn = getattr(sparsetools, self.format + '_matmat_pass2') + # fn( M, N, self.indptr, self.indices, self.data, \ + # other.indptr, other.indices, other.data, \ + # indptr, indices, data) - fn(self.shape[0], self.shape[1], \ - self.indptr, self.indices, self.data, numpy.ravel(other), y) + # return self.__class__((data,indices,indptr),shape=(M,N)) - if isinstance(other, matrix): - y = asmatrix(y) - if other.ndim == 2 and other.shape[1] == 1: - # If 'other' was an (nx1) column vector, reshape the result - y = y.reshape(-1,1) + # elif isdense(other): + # # TODO make sparse * dense matrix multiplication more efficient + # + # # matvec each column of other + # result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) + # if isinstance(other, matrix): + # result = asmatrix(result) + # return result - return y + # else: + # raise TypeError, "need a dense or sparse matrix" - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" + #def matvec(self, other): + # """Sparse matrix vector product (self * other) + # 'other' may be a rank 1 array of length N or a rank 2 array + # or matrix with shape (N,1). + + # """ + # #If the optional 'output' parameter is defined, it will + # #be used to store the result. Otherwise, a new vector + # #will be allocated. + + # if isdense(other): + # M,N = self.shape + + # if other.shape != (N,) and other.shape != (N,1): + # raise ValueError, "dimension mismatch" + + # # csrmux, cscmux + # fn = getattr(sparsetools,self.format + '_matvec') + + # #output array + # y = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) + + # #if output is None: + # # y = empty( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) + # #else: + # # if output.shape != (M,) and output.shape != (M,1): + # # raise ValueError, "output array has improper dimensions" + # # if not output.flags.c_contiguous: + # # raise ValueError, "output array must be contiguous" + # # if output.dtype != upcast(self.dtype,other.dtype): + # # raise ValueError, "output array has dtype=%s "\ + # # "dtype=%s is required" % \ + # # (output.dtype,upcast(self.dtype,other.dtype)) + # # y = output + + # fn(self.shape[0], self.shape[1], \ + # self.indptr, self.indices, self.data, numpy.ravel(other), y) + + # if isinstance(other, matrix): + # y = asmatrix(y) + + # if other.ndim == 2 and other.shape[1] == 1: + # # If 'other' was an (nx1) column vector, reshape the result + # y = y.reshape(-1,1) + + # return y + + # elif isspmatrix(other): + # raise TypeError, "use matmat() for sparse * sparse" + + # else: + # raise TypeError, "need a dense vector" + def rmatvec(self, other, conjugate=True): """Multiplies the vector 'other' by the sparse matrix, returning a dense vector as a result. @@ -629,10 +675,7 @@ return coo_matrix((data,(row,col)), self.shape) def toarray(self): - A = self.tocoo(copy=False) - M = zeros(self.shape, dtype=self.dtype) - M[A.row, A.col] = A.data - return M + return self.tocoo(copy=False).toarray() ############################################################## # methods that examine or modify the internal data structure # @@ -679,7 +722,7 @@ fn( len(self.indptr) - 1, self.indptr, self.indices) return self.__has_sorted_indices - def __set_sorted(self,val): + def __set_sorted(self, val): self.__has_sorted_indices = bool(val) has_sorted_indices = property(fget=__get_sorted, fset=__set_sorted) @@ -704,6 +747,7 @@ fn( len(self.indptr) - 1, self.indptr, self.indices, self.data) self.has_sorted_indices = True + #TODO remove after 0.7 def ensure_sorted_indices(self, inplace=False): """Return a copy of this matrix where the column indices are sorted """ @@ -717,16 +761,16 @@ return self.sorted_indices() def prune(self): - """ Remove empty space after all non-zero elements. + """Remove empty space after all non-zero elements. """ major_dim = self._swap(self.shape)[0] if len(self.indptr) != major_dim + 1: - raise ValueError, "index pointer has invalid length" + raise ValueError('index pointer has invalid length') if len(self.indices) < self.nnz: - raise ValueError, "indices array has fewer than nnz elements" + raise ValueError('indices array has fewer than nnz elements') if len(self.data) < self.nnz: - raise ValueError, "data array has fewer than nnz elements" + raise ValueError('data array has fewer than nnz elements') self.data = self.data[:self.nnz] self.indices = self.indices[:self.nnz] Modified: trunk/scipy/sparse/coo.py =================================================================== --- trunk/scipy/sparse/coo.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/coo.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -7,11 +7,10 @@ from itertools import izip from warnings import warn -from numpy import array, asarray, empty, intc, zeros, \ - unique, searchsorted, atleast_2d, empty_like, rank, \ - deprecate +from numpy import array, asarray, empty, intc, zeros, \ + unique, searchsorted, atleast_2d, rank, deprecate -from sparsetools import coo_tocsr, coo_tocsc, coo_todense +from sparsetools import coo_tocsr, coo_tocsc, coo_todense, coo_matvec from base import isspmatrix from data import _data_matrix from sputils import upcast, to_native, isshape, getdtype @@ -55,7 +54,6 @@ - does not directly support: + arithmetic operations + slicing - + matrix vector products Intended Usage @@ -118,21 +116,21 @@ try: obj, ij = arg1 except: - raise TypeError, "invalid input format" + raise TypeError('invalid input format') try: if len(ij) != 2: raise TypeError except TypeError: - raise TypeError, "invalid input format" + raise TypeError('invalid input format') - self.row = array(ij[0],copy=copy,dtype=intc) - self.col = array(ij[1],copy=copy,dtype=intc) - self.data = array(obj,copy=copy) + self.row = array(ij[0], copy=copy, dtype=intc) + self.col = array(ij[1], copy=copy, dtype=intc) + self.data = array( obj, copy=copy) if shape is None: if len(self.row) == 0 or len(self.col) == 0: - raise ValueError, "cannot infer dimensions from zero sized index arrays" + raise ValueError('cannot infer dimensions from zero sized index arrays') M = self.row.max() + 1 N = self.col.max() + 1 self.shape = (M, N) @@ -144,13 +142,13 @@ elif arg1 is None: # Initialize an empty matrix. if not isinstance(shape, tuple) or not isintlike(shape[0]): - raise TypeError, "dimensions not understood" + raise TypeError('dimensions not understood') warn('coo_matrix(None, shape=(M,N)) is deprecated, ' \ 'use coo_matrix( (M,N) ) instead', DeprecationWarning) self.shape = shape - self.data = array([],getdtype(dtype, default=float)) - self.row = array([],dtype=intc) - self.col = array([],dtype=intc) + self.data = array([], getdtype(dtype, default=float)) + self.row = array([], dtype=intc) + self.col = array([], dtype=intc) else: if isspmatrix(arg1): if isspmatrix_coo(arg1) and copy: @@ -169,10 +167,10 @@ try: M = atleast_2d(asarray(arg1)) except: - raise TypeError, "invalid input format" + raise TypeError('invalid input format') if len(M.shape) != 2: - raise TypeError, "expected rank <= 2 array or matrix" + raise TypeError('expected rank <= 2 array or matrix') self.shape = M.shape self.row,self.col = (M != 0).nonzero() self.data = M[self.row,self.col] @@ -182,11 +180,10 @@ def getnnz(self): nnz = len(self.data) if (nnz != len(self.row)) or (nnz != len(self.col)): - raise ValueError, "row, column, and data array must all be "\ - "the same length" + raise ValueError('row, column, and data array must all be the same length') if rank(self.data) != 1 or rank(self.row) != 1 or rank(self.col) != 1: - raise ValueError, "row, column, and data arrays must have rank 1" + raise ValueError('row, column, and data arrays must have rank 1') return nnz nnz = property(fget=getnnz) @@ -204,22 +201,20 @@ % self.col.dtype.name ) # only support 32-bit ints for now - self.row = asarray(self.row,dtype=intc) - self.col = asarray(self.col,dtype=intc) + self.row = asarray(self.row, dtype=intc) + self.col = asarray(self.col, dtype=intc) self.data = to_native(self.data) if nnz > 0: - if(self.row.max() >= self.shape[0]): - raise ValueError, "row index exceedes matrix dimensions" - if(self.col.max() >= self.shape[1]): - raise ValueError, "column index exceedes matrix dimensions" - if(self.row.min() < 0): - raise ValueError, "negative row index found" - if(self.col.min() < 0): - raise ValueError, "negative column index found" + if self.row.max() >= self.shape[0]: + raise ValueError('row index exceedes matrix dimensions') + if self.col.max() >= self.shape[1]: + raise ValueError('column index exceedes matrix dimensions') + if self.row.min() < 0: + raise ValueError('negative row index found') + if self.col.min() < 0: + raise ValueError('negative column index found') - # some functions pass floats - self.shape = tuple([int(x) for x in self.shape]) @deprecate def rowcol(self, num): @@ -334,7 +329,16 @@ return coo_matrix( (data, (self.row, self.col) ), \ shape=self.shape, dtype=data.dtype) + ########################### + # Multiplication handlers # + ########################### + def _mul_vector(self, other): + #output array + result = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) + coo_matvec(self.nnz, self.row, self.col, self.data, other, result) + return result + from sputils import _isinstance def isspmatrix_coo( x ): Modified: trunk/scipy/sparse/data.py =================================================================== --- trunk/scipy/sparse/data.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/data.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -58,3 +58,12 @@ def copy(self): return self._with_data(self.data.copy(),copy=True) + + + ########################### + # Multiplication handlers # + ########################### + + def _mul_scalar(self, other): + return self._with_data(self.data * other) + Modified: trunk/scipy/sparse/dia.py =================================================================== --- trunk/scipy/sparse/dia.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/dia.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -142,54 +142,20 @@ nnz = property(fget=getnnz) + def _mul_vector(self, other): + x = other - def __mul__(self, other): # self * other - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - return dia_matrix((other * self.data, self.diags),self.shape) - else: - return self.dot(other) + y = zeros( self.shape[0], dtype=upcast(self.dtype,x.dtype)) - def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - - return self.tocsr() * other - #TODO handle sparse/sparse matmat here - else: - return self.tocsr() * other - #TODO handle sparse/dense matmat here - - - def matvec(self,other): - x = asarray(other) - - if x.ndim == 1: - x = x.reshape(-1,1) - if self.shape[1] != x.shape[0]: - raise ValueError, "dimension mismatch" - - y = zeros((self.shape[0],x.shape[1]), dtype=upcast(self.dtype,x.dtype)) - temp = empty_like( y ) - L = self.data.shape[1] + M,N = self.shape dia_matvec(M,N, len(self.diags), L, self.diags, self.data, x.ravel(), y.ravel()) - if isinstance(other, matrix): - y = asmatrix(y) - - if other.ndim == 1: - # If 'other' was a 1d array, reshape the result - y = y.reshape(-1) - return y + def todia(self,copy=False): if copy: return self.copy() Modified: trunk/scipy/sparse/dok.py =================================================================== --- trunk/scipy/sparse/dok.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/dok.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -349,18 +349,15 @@ new[key] = -self[key] return new - def __mul__(self, other): # self * other - if isscalarlike(other): - new = dok_matrix(self.shape, dtype=self.dtype) - # Multiply this scalar by every element. - for (key, val) in self.iteritems(): - new[key] = val * other - #new.dtype.char = self.dtype.char - return new - else: - return self.dot(other) + def _mul_scalar(self, other): + new = dok_matrix(self.shape, dtype=self.dtype) + # Multiply this scalar by every element. + for (key, val) in self.iteritems(): + new[key] = val * other + #new.dtype.char = self.dtype.char + return new - def __imul__(self, other): # self * other + def __imul__(self, other): if isscalarlike(other): # Multiply this scalar by every element. for (key, val) in self.iteritems(): @@ -370,23 +367,8 @@ else: return NotImplementedError - def __rmul__(self, other): # other * self - if isscalarlike(other): - new = dok_matrix(self.shape, dtype=self.dtype) - # Multiply this scalar by every element. - for (key, val) in self.iteritems(): - new[key] = other * val - #new.dtype.char = self.dtype.char - return new - else: - # Don't use asarray unless we have to - try: - tr = other.transpose() - except AttributeError: - tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() - def __truediv__(self, other): # self * other + def __truediv__(self, other): if isscalarlike(other): new = dok_matrix(self.shape, dtype=self.dtype) # Multiply this scalar by every element. @@ -398,7 +380,7 @@ return self.tocsr() / other - def __itruediv__(self, other): # self * other + def __itruediv__(self, other): if isscalarlike(other): # Multiply this scalar by every element. for (key, val) in self.iteritems(): Modified: trunk/scipy/sparse/lil.py =================================================================== --- trunk/scipy/sparse/lil.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/lil.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -43,7 +43,7 @@ Disadvantages of the LIL format - arithmetic operations LIL + LIL are slow (consider CSR or CSC) - slow column slicing (consider CSC) - - matrix vector products are slower than CSR/CSC + - slow matrix vector products (consider CSR or CSC) Intended Usage - LIL is a convenient format for constructing sparse matrices @@ -322,20 +322,17 @@ else: raise ValueError, "invalid index value: %s" % str((i, j)) - def __mul__(self, other): # self * other - if isscalarlike(other): - if other == 0: - # Multiply by zero: return the zero matrix - new = lil_matrix(shape=self.shape, dtype=self.dtype) - else: - new = self.copy() - # Multiply this scalar by every element. - new.data = numpy.array([[val*other for val in rowvals] for - rowvals in new.data], dtype=object) - return new + def _mul_scalar(self, other): + if other == 0: + # Multiply by zero: return the zero matrix + new = lil_matrix(shape=self.shape, dtype=self.dtype) else: - return self.dot(other) - + new = self.copy() + # Multiply this scalar by every element. + new.data = numpy.array([[val*other for val in rowvals] for + rowvals in new.data], dtype=object) + return new + def __truediv__(self, other): # self / other if isscalarlike(other): new = self.copy() Modified: trunk/scipy/sparse/sparsetools/bsr.h =================================================================== --- trunk/scipy/sparse/sparsetools/bsr.h 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/bsr.h 2008-07-08 09:47:43 UTC (rev 4532) @@ -618,14 +618,11 @@ const T Xx[], T Yx[]) { - for(I i = 0; i < R*n_brow; i++){ - Yx[i] = 0; - } - + const int RC = R*C; for(I i = 0; i < n_brow; i++) { for(I jj = Ap[i]; jj < Ap[i+1]; jj++) { I j = Aj[jj]; - matvec(Ax + jj*R*C, Xx + j*C, Yx + i*R); + matvec(Ax + jj*RC, Xx + j*C, Yx + i*R); } } } @@ -686,11 +683,6 @@ #endif //otherwise use general method - - for(I i = 0; i < R*n_brow; i++){ - Yx[i] = 0; - } - for(I i = 0; i < n_brow; i++){ const T * A = Ax + R * C * Ap[i]; T * y = Yx + R * i; Modified: trunk/scipy/sparse/sparsetools/bsr_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-07-08 09:47:43 UTC (rev 4532) @@ -3185,24 +3185,36 @@ bsr_diagonal< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3301,24 +3313,36 @@ bsr_diagonal< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3417,24 +3441,36 @@ bsr_diagonal< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3533,24 +3569,36 @@ bsr_diagonal< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3649,24 +3697,36 @@ bsr_diagonal< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3765,24 +3825,36 @@ bsr_diagonal< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3881,24 +3953,36 @@ bsr_diagonal< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3997,24 +4081,36 @@ bsr_diagonal< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4113,24 +4209,36 @@ bsr_diagonal< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4229,24 +4337,36 @@ bsr_diagonal< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4345,24 +4465,36 @@ bsr_diagonal< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4461,24 +4593,36 @@ bsr_diagonal< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4577,24 +4721,36 @@ bsr_diagonal< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4693,24 +4849,36 @@ bsr_diagonal< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -5513,24 +5681,36 @@ bsr_scale_rows< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(signed char const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -5629,24 +5809,36 @@ bsr_scale_rows< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned char const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -5745,24 +5937,36 @@ bsr_scale_rows< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(short const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -5861,24 +6065,36 @@ bsr_scale_rows< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned short const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -5977,24 +6193,36 @@ bsr_scale_rows< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(int const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6093,24 +6321,36 @@ bsr_scale_rows< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned int const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6209,24 +6449,36 @@ bsr_scale_rows< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(long long const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6325,24 +6577,36 @@ bsr_scale_rows< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned long long const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6441,24 +6705,36 @@ bsr_scale_rows< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(float const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6557,24 +6833,36 @@ bsr_scale_rows< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(double const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6673,24 +6961,36 @@ bsr_scale_rows< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(long double const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6789,24 +7089,36 @@ bsr_scale_rows< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(npy_cfloat_wrapper const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -6905,24 +7217,36 @@ bsr_scale_rows< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(npy_cdouble_wrapper const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -7021,24 +7345,36 @@ bsr_scale_rows< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(npy_clongdouble_wrapper const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -7841,24 +8177,36 @@ bsr_scale_columns< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(signed char const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -7957,24 +8305,36 @@ bsr_scale_columns< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned char const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8073,24 +8433,36 @@ bsr_scale_columns< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(short const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8189,24 +8561,36 @@ bsr_scale_columns< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned short const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8305,24 +8689,36 @@ bsr_scale_columns< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(int const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8421,24 +8817,36 @@ bsr_scale_columns< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned int const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8537,24 +8945,36 @@ bsr_scale_columns< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(long long const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8653,24 +9073,36 @@ bsr_scale_columns< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(unsigned long long const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8769,24 +9201,36 @@ bsr_scale_columns< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(float const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8885,24 +9329,36 @@ bsr_scale_columns< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(double const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9001,24 +9457,36 @@ bsr_scale_columns< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(long double const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9117,24 +9585,36 @@ bsr_scale_columns< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(npy_cfloat_wrapper const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9233,24 +9713,36 @@ bsr_scale_columns< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(npy_cdouble_wrapper const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9349,24 +9841,36 @@ bsr_scale_columns< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,arg7,(npy_clongdouble_wrapper const (*))arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -10185,24 +10689,36 @@ bsr_transpose< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -10317,24 +10833,36 @@ bsr_transpose< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -10449,24 +10977,36 @@ bsr_transpose< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -10581,24 +11121,36 @@ bsr_transpose< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -10713,24 +11265,36 @@ bsr_transpose< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -10845,24 +11409,36 @@ bsr_transpose< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -10977,24 +11553,36 @@ bsr_transpose< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11109,24 +11697,36 @@ bsr_transpose< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11241,24 +11841,36 @@ bsr_transpose< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11373,24 +11985,36 @@ bsr_transpose< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11505,24 +12129,36 @@ bsr_transpose< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11637,24 +12273,36 @@ bsr_transpose< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11769,24 +12417,36 @@ bsr_transpose< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11901,24 +12561,36 @@ bsr_transpose< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12928,42 +13600,66 @@ bsr_matmat_pass2< int,signed char >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,(int const (*))arg9,(int const (*))arg10,(signed char const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -13129,42 +13825,66 @@ bsr_matmat_pass2< int,unsigned char >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,(int const (*))arg9,(int const (*))arg10,(unsigned char const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -13330,42 +14050,66 @@ bsr_matmat_pass2< int,short >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,(int const (*))arg9,(int const (*))arg10,(short const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -13531,42 +14275,66 @@ bsr_matmat_pass2< int,unsigned short >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,(int const (*))arg9,(int const (*))arg10,(unsigned short const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -13732,42 +14500,66 @@ bsr_matmat_pass2< int,int >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(int const (*))arg10,(int const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -13933,42 +14725,66 @@ bsr_matmat_pass2< int,unsigned int >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,(int const (*))arg9,(int const (*))arg10,(unsigned int const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -14134,42 +14950,66 @@ bsr_matmat_pass2< int,long long >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,(int const (*))arg9,(int const (*))arg10,(long long const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -14335,42 +15175,66 @@ bsr_matmat_pass2< int,unsigned long long >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,(int const (*))arg9,(int const (*))arg10,(unsigned long long const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -14536,42 +15400,66 @@ bsr_matmat_pass2< int,float >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,(int const (*))arg9,(int const (*))arg10,(float const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -14737,42 +15625,66 @@ bsr_matmat_pass2< int,double >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,(int const (*))arg9,(int const (*))arg10,(double const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -14938,42 +15850,66 @@ bsr_matmat_pass2< int,long double >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,(int const (*))arg9,(int const (*))arg10,(long double const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -15139,42 +16075,66 @@ bsr_matmat_pass2< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,(int const (*))arg9,(int const (*))arg10,(npy_cfloat_wrapper const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -15340,42 +16300,66 @@ bsr_matmat_pass2< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,(int const (*))arg9,(int const (*))arg10,(npy_cdouble_wrapper const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -15541,42 +16525,66 @@ bsr_matmat_pass2< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,(int const (*))arg9,(int const (*))arg10,(npy_clongdouble_wrapper const (*))arg11,arg12,arg13,arg14); resultobj = SWIG_Py_Void(); { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return resultobj; fail: { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } { - if (is_new_object11 && array11) Py_DECREF(array11); + if (is_new_object11 && array11) { + Py_DECREF(array11); + } } return NULL; } @@ -16827,30 +17835,46 @@ bsr_matvec< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,(signed char const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16963,30 +17987,46 @@ bsr_matvec< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,(unsigned char const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17099,30 +18139,46 @@ bsr_matvec< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,(short const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17235,30 +18291,46 @@ bsr_matvec< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,(unsigned short const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17371,30 +18443,46 @@ bsr_matvec< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17507,30 +18595,46 @@ bsr_matvec< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,(unsigned int const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17643,30 +18747,46 @@ bsr_matvec< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,(long long const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17779,30 +18899,46 @@ bsr_matvec< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,(unsigned long long const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17915,30 +19051,46 @@ bsr_matvec< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,(float const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18051,30 +19203,46 @@ bsr_matvec< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,(double const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18187,30 +19355,46 @@ bsr_matvec< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,(long double const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18323,30 +19507,46 @@ bsr_matvec< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18459,30 +19659,46 @@ bsr_matvec< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18595,30 +19811,46 @@ bsr_matvec< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -19549,42 +20781,66 @@ bsr_elmul_bsr< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(signed char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -19741,42 +20997,66 @@ bsr_elmul_bsr< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -19933,42 +21213,66 @@ bsr_elmul_bsr< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -20125,42 +21429,66 @@ bsr_elmul_bsr< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -20317,42 +21645,66 @@ bsr_elmul_bsr< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -20509,42 +21861,66 @@ bsr_elmul_bsr< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -20701,42 +22077,66 @@ bsr_elmul_bsr< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -20893,42 +22293,66 @@ bsr_elmul_bsr< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -21085,42 +22509,66 @@ bsr_elmul_bsr< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,(int const (*))arg8,(int const (*))arg9,(float const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -21277,42 +22725,66 @@ bsr_elmul_bsr< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -21469,42 +22941,66 @@ bsr_elmul_bsr< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -21661,42 +23157,66 @@ bsr_elmul_bsr< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cfloat_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -21853,42 +23373,66 @@ bsr_elmul_bsr< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -22045,42 +23589,66 @@ bsr_elmul_bsr< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_clongdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -23291,42 +24859,66 @@ bsr_eldiv_bsr< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(signed char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -23483,42 +25075,66 @@ bsr_eldiv_bsr< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -23675,42 +25291,66 @@ bsr_eldiv_bsr< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -23867,42 +25507,66 @@ bsr_eldiv_bsr< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -24059,42 +25723,66 @@ bsr_eldiv_bsr< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -24251,42 +25939,66 @@ bsr_eldiv_bsr< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -24443,42 +26155,66 @@ bsr_eldiv_bsr< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -24635,42 +26371,66 @@ bsr_eldiv_bsr< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -24827,42 +26587,66 @@ bsr_eldiv_bsr< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,(int const (*))arg8,(int const (*))arg9,(float const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -25019,42 +26803,66 @@ bsr_eldiv_bsr< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -25211,42 +27019,66 @@ bsr_eldiv_bsr< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -25403,42 +27235,66 @@ bsr_eldiv_bsr< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cfloat_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -25595,42 +27451,66 @@ bsr_eldiv_bsr< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -25787,42 +27667,66 @@ bsr_eldiv_bsr< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_clongdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -27033,42 +28937,66 @@ bsr_plus_bsr< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(signed char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -27225,42 +29153,66 @@ bsr_plus_bsr< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -27417,42 +29369,66 @@ bsr_plus_bsr< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -27609,42 +29585,66 @@ bsr_plus_bsr< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -27801,42 +29801,66 @@ bsr_plus_bsr< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -27993,42 +30017,66 @@ bsr_plus_bsr< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -28185,42 +30233,66 @@ bsr_plus_bsr< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -28377,42 +30449,66 @@ bsr_plus_bsr< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -28569,42 +30665,66 @@ bsr_plus_bsr< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,(int const (*))arg8,(int const (*))arg9,(float const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -28761,42 +30881,66 @@ bsr_plus_bsr< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -28953,42 +31097,66 @@ bsr_plus_bsr< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -29145,42 +31313,66 @@ bsr_plus_bsr< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cfloat_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -29337,42 +31529,66 @@ bsr_plus_bsr< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -29529,42 +31745,66 @@ bsr_plus_bsr< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_clongdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -30775,42 +33015,66 @@ bsr_minus_bsr< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(signed char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -30967,42 +33231,66 @@ bsr_minus_bsr< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned char const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -31159,42 +33447,66 @@ bsr_minus_bsr< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -31351,42 +33663,66 @@ bsr_minus_bsr< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned short const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -31543,42 +33879,66 @@ bsr_minus_bsr< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -31735,42 +34095,66 @@ bsr_minus_bsr< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned int const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -31927,42 +34311,66 @@ bsr_minus_bsr< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -32119,42 +34527,66 @@ bsr_minus_bsr< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,(int const (*))arg8,(int const (*))arg9,(unsigned long long const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -32311,42 +34743,66 @@ bsr_minus_bsr< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,(int const (*))arg8,(int const (*))arg9,(float const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -32503,42 +34959,66 @@ bsr_minus_bsr< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -32695,42 +35175,66 @@ bsr_minus_bsr< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,(int const (*))arg8,(int const (*))arg9,(long double const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -32887,42 +35391,66 @@ bsr_minus_bsr< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cfloat_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -33079,42 +35607,66 @@ bsr_minus_bsr< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_cdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -33271,42 +35823,66 @@ bsr_minus_bsr< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,(int const (*))arg8,(int const (*))arg9,(npy_clongdouble_wrapper const (*))arg10,arg11,arg12,arg13); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } { - if (is_new_object9 && array9) Py_DECREF(array9); + if (is_new_object9 && array9) { + Py_DECREF(array9); + } } { - if (is_new_object10 && array10) Py_DECREF(array10); + if (is_new_object10 && array10) { + Py_DECREF(array10); + } } return NULL; } @@ -36966,4 +39542,3 @@ } - Modified: trunk/scipy/sparse/sparsetools/coo.i =================================================================== --- trunk/scipy/sparse/sparsetools/coo.i 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/coo.i 2008-07-08 09:47:43 UTC (rev 4532) @@ -12,4 +12,6 @@ INSTANTIATE_ALL(coo_tocsc) INSTANTIATE_ALL(coo_todense) +INSTANTIATE_ALL(coo_matvec) + Modified: trunk/scipy/sparse/sparsetools/coo.py =================================================================== --- trunk/scipy/sparse/sparsetools/coo.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/coo.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -149,3 +149,32 @@ """ return _coo.coo_todense(*args) +def coo_matvec(*args): + """ + coo_matvec(int nnz, int Ai, int Aj, signed char Ax, signed char Xx, + signed char Yx) + coo_matvec(int nnz, int Ai, int Aj, unsigned char Ax, unsigned char Xx, + unsigned char Yx) + coo_matvec(int nnz, int Ai, int Aj, short Ax, short Xx, short Yx) + coo_matvec(int nnz, int Ai, int Aj, unsigned short Ax, unsigned short Xx, + unsigned short Yx) + coo_matvec(int nnz, int Ai, int Aj, int Ax, int Xx, int Yx) + coo_matvec(int nnz, int Ai, int Aj, unsigned int Ax, unsigned int Xx, + unsigned int Yx) + coo_matvec(int nnz, int Ai, int Aj, long long Ax, long long Xx, + long long Yx) + coo_matvec(int nnz, int Ai, int Aj, unsigned long long Ax, unsigned long long Xx, + unsigned long long Yx) + coo_matvec(int nnz, int Ai, int Aj, float Ax, float Xx, float Yx) + coo_matvec(int nnz, int Ai, int Aj, double Ax, double Xx, double Yx) + coo_matvec(int nnz, int Ai, int Aj, long double Ax, long double Xx, + long double Yx) + coo_matvec(int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + coo_matvec(int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + coo_matvec(int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx) + """ + return _coo.coo_matvec(*args) + Modified: trunk/scipy/sparse/sparsetools/coo_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/coo_wrap.cxx 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/coo_wrap.cxx 2008-07-08 09:47:43 UTC (rev 4532) @@ -3192,24 +3192,36 @@ coo_tocsr< int,signed char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(signed char const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3315,24 +3327,36 @@ coo_tocsr< int,unsigned char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned char const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3438,24 +3462,36 @@ coo_tocsr< int,short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(short const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3561,24 +3597,36 @@ coo_tocsr< int,unsigned short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned short const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3684,24 +3732,36 @@ coo_tocsr< int,int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3807,24 +3867,36 @@ coo_tocsr< int,unsigned int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned int const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3930,24 +4002,36 @@ coo_tocsr< int,long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long long const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4053,24 +4137,36 @@ coo_tocsr< int,unsigned long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned long long const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4176,24 +4272,36 @@ coo_tocsr< int,float >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4299,24 +4407,36 @@ coo_tocsr< int,double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4422,24 +4542,36 @@ coo_tocsr< int,long double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4545,24 +4677,36 @@ coo_tocsr< int,npy_cfloat_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat_wrapper const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4668,24 +4812,36 @@ coo_tocsr< int,npy_cdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble_wrapper const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -4791,24 +4947,36 @@ coo_tocsr< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5674,24 +5842,36 @@ coo_tocsc< int,signed char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(signed char const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5797,24 +5977,36 @@ coo_tocsc< int,unsigned char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned char const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5920,24 +6112,36 @@ coo_tocsc< int,short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(short const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6043,24 +6247,36 @@ coo_tocsc< int,unsigned short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned short const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6166,24 +6382,36 @@ coo_tocsc< int,int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6289,24 +6517,36 @@ coo_tocsc< int,unsigned int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned int const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6412,24 +6652,36 @@ coo_tocsc< int,long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long long const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6535,24 +6787,36 @@ coo_tocsc< int,unsigned long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned long long const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6658,24 +6922,36 @@ coo_tocsc< int,float >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6781,24 +7057,36 @@ coo_tocsc< int,double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6904,24 +7192,36 @@ coo_tocsc< int,long double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7027,24 +7327,36 @@ coo_tocsc< int,npy_cfloat_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat_wrapper const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7150,24 +7462,36 @@ coo_tocsc< int,npy_cdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble_wrapper const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7273,24 +7597,36 @@ coo_tocsc< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8140,24 +8476,36 @@ coo_todense< int,signed char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(signed char const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8247,24 +8595,36 @@ coo_todense< int,unsigned char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned char const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8354,24 +8714,36 @@ coo_todense< int,short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(short const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8461,24 +8833,36 @@ coo_todense< int,unsigned short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned short const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8568,24 +8952,36 @@ coo_todense< int,int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8675,24 +9071,36 @@ coo_todense< int,unsigned int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8782,24 +9190,36 @@ coo_todense< int,long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8889,24 +9309,36 @@ coo_todense< int,unsigned long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned long long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8996,24 +9428,36 @@ coo_todense< int,float >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -9103,24 +9547,36 @@ coo_todense< int,double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -9210,24 +9666,36 @@ coo_todense< int,long double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -9317,24 +9785,36 @@ coo_todense< int,npy_cfloat_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -9424,24 +9904,36 @@ coo_todense< int,npy_cdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -9531,24 +10023,36 @@ coo_todense< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -10174,6 +10678,2278 @@ } +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + signed char *arg4 ; + signed char *arg5 ; + signed char *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_BYTE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (signed char*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_BYTE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (signed char*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_BYTE); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (signed char*) array_data(temp6); + } + coo_matvec< int,signed char >(arg1,(int const (*))arg2,(int const (*))arg3,(signed char const (*))arg4,(signed char const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + unsigned char *arg4 ; + unsigned char *arg5 ; + unsigned char *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_UBYTE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (unsigned char*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_UBYTE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (unsigned char*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_UBYTE); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (unsigned char*) array_data(temp6); + } + coo_matvec< int,unsigned char >(arg1,(int const (*))arg2,(int const (*))arg3,(unsigned char const (*))arg4,(unsigned char const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + short *arg4 ; + short *arg5 ; + short *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_SHORT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (short*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_SHORT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (short*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_SHORT); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (short*) array_data(temp6); + } + coo_matvec< int,short >(arg1,(int const (*))arg2,(int const (*))arg3,(short const (*))arg4,(short const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + unsigned short *arg4 ; + unsigned short *arg5 ; + unsigned short *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_USHORT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (unsigned short*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_USHORT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (unsigned short*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_USHORT); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (unsigned short*) array_data(temp6); + } + coo_matvec< int,unsigned short >(arg1,(int const (*))arg2,(int const (*))arg3,(unsigned short const (*))arg4,(unsigned short const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + int *arg4 ; + int *arg5 ; + int *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_INT); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (int*) array_data(temp6); + } + coo_matvec< int,int >(arg1,(int const (*))arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + unsigned int *arg4 ; + unsigned int *arg5 ; + unsigned int *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_UINT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (unsigned int*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_UINT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (unsigned int*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_UINT); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (unsigned int*) array_data(temp6); + } + coo_matvec< int,unsigned int >(arg1,(int const (*))arg2,(int const (*))arg3,(unsigned int const (*))arg4,(unsigned int const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + long long *arg4 ; + long long *arg5 ; + long long *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_LONGLONG, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (long long*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGLONG, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (long long*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_LONGLONG); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (long long*) array_data(temp6); + } + coo_matvec< int,long long >(arg1,(int const (*))arg2,(int const (*))arg3,(long long const (*))arg4,(long long const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + unsigned long long *arg4 ; + unsigned long long *arg5 ; + unsigned long long *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_ULONGLONG, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (unsigned long long*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_ULONGLONG, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (unsigned long long*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_ULONGLONG); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (unsigned long long*) array_data(temp6); + } + coo_matvec< int,unsigned long long >(arg1,(int const (*))arg2,(int const (*))arg3,(unsigned long long const (*))arg4,(unsigned long long const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_9(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + float *arg4 ; + float *arg5 ; + float *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) 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; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (float*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_FLOAT); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (float*) array_data(temp6); + } + coo_matvec< int,float >(arg1,(int const (*))arg2,(int const (*))arg3,(float const (*))arg4,(float const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_10(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + double *arg4 ; + double *arg5 ; + double *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) 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; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (double*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_DOUBLE); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (double*) array_data(temp6); + } + coo_matvec< int,double >(arg1,(int const (*))arg2,(int const (*))arg3,(double const (*))arg4,(double const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_11(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + long double *arg4 ; + long double *arg5 ; + long double *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_LONGDOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (long double*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (long double*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_LONGDOUBLE); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (long double*) array_data(temp6); + } + coo_matvec< int,long double >(arg1,(int const (*))arg2,(int const (*))arg3,(long double const (*))arg4,(long double const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_12(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + npy_cfloat_wrapper *arg4 ; + npy_cfloat_wrapper *arg5 ; + npy_cfloat_wrapper *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_CFLOAT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (npy_cfloat_wrapper*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (npy_cfloat_wrapper*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_CFLOAT); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (npy_cfloat_wrapper*) array_data(temp6); + } + coo_matvec< int,npy_cfloat_wrapper >(arg1,(int const (*))arg2,(int const (*))arg3,(npy_cfloat_wrapper const (*))arg4,(npy_cfloat_wrapper const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_13(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + npy_cdouble_wrapper *arg4 ; + npy_cdouble_wrapper *arg5 ; + npy_cdouble_wrapper *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_CDOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (npy_cdouble_wrapper*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (npy_cdouble_wrapper*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_CDOUBLE); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (npy_cdouble_wrapper*) array_data(temp6); + } + coo_matvec< int,npy_cdouble_wrapper >(arg1,(int const (*))arg2,(int const (*))arg3,(npy_cdouble_wrapper const (*))arg4,(npy_cdouble_wrapper const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec__SWIG_14(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int *arg2 ; + int *arg3 ; + npy_clongdouble_wrapper *arg4 ; + npy_clongdouble_wrapper *arg5 ; + npy_clongdouble_wrapper *arg6 ; + int 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 *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:coo_matvec",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "coo_matvec" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array2) || !require_native(array2)) SWIG_fail; + + arg2 = (int*) array2->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array3) || !require_native(array3)) SWIG_fail; + + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_CLONGDOUBLE, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (npy_clongdouble_wrapper*) array4->data; + } + { + npy_intp size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (npy_clongdouble_wrapper*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_CLONGDOUBLE); + if (!temp6 || !require_contiguous(temp6) || !require_native(temp6)) SWIG_fail; + arg6 = (npy_clongdouble_wrapper*) array_data(temp6); + } + coo_matvec< int,npy_clongdouble_wrapper >(arg1,(int const (*))arg2,(int const (*))arg3,(npy_clongdouble_wrapper const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,arg6); + 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_object5 && array5) { + Py_DECREF(array5); + } + } + 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_object5 && array5) { + Py_DECREF(array5); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_coo_matvec(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[7]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = (int)PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 6); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_3(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_4(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_5(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_6(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_7(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_8(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 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) { + return _wrap_coo_matvec__SWIG_9(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 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) { + return _wrap_coo_matvec__SWIG_10(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_11(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_12(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_13(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[1]) && PyArray_CanCastSafely(PyArray_TYPE(argv[1]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_coo_matvec__SWIG_14(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'coo_matvec'.\n" + " Possible C/C++ prototypes are:\n" + " coo_matvec< int,signed char >(int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n" + " coo_matvec< int,unsigned char >(int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n" + " coo_matvec< int,short >(int const,int const [],int const [],short const [],short const [],short [])\n" + " coo_matvec< int,unsigned short >(int const,int const [],int const [],unsigned short const [],unsigned short const [],unsigned short [])\n" + " coo_matvec< int,int >(int const,int const [],int const [],int const [],int const [],int [])\n" + " coo_matvec< int,unsigned int >(int const,int const [],int const [],unsigned int const [],unsigned int const [],unsigned int [])\n" + " coo_matvec< int,long long >(int const,int const [],int const [],long long const [],long long const [],long long [])\n" + " coo_matvec< int,unsigned long long >(int const,int const [],int const [],unsigned long long const [],unsigned long long const [],unsigned long long [])\n" + " coo_matvec< int,float >(int const,int const [],int const [],float const [],float const [],float [])\n" + " coo_matvec< int,double >(int const,int const [],int const [],double const [],double const [],double [])\n" + " coo_matvec< int,long double >(int const,int const [],int const [],long double const [],long double const [],long double [])\n" + " coo_matvec< int,npy_cfloat_wrapper >(int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n" + " coo_matvec< int,npy_cdouble_wrapper >(int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n" + " coo_matvec< int,npy_clongdouble_wrapper >(int const,int const [],int const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper [])\n"); + return NULL; +} + + static PyMethodDef SwigMethods[] = { { (char *)"coo_tocsr", _wrap_coo_tocsr, METH_VARARGS, (char *)"\n" "coo_tocsr(int n_row, int n_col, int nnz, int Ai, int Aj, signed char Ax, \n" @@ -10265,6 +13041,32 @@ "coo_todense(int n_row, int n_col, int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, \n" " npy_clongdouble_wrapper Bx)\n" ""}, + { (char *)"coo_matvec", _wrap_coo_matvec, METH_VARARGS, (char *)"\n" + "coo_matvec(int nnz, int Ai, int Aj, signed char Ax, signed char Xx, \n" + " signed char Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, unsigned char Ax, unsigned char Xx, \n" + " unsigned char Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, short Ax, short Xx, short Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, unsigned short Ax, unsigned short Xx, \n" + " unsigned short Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, int Ax, int Xx, int Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, unsigned int Ax, unsigned int Xx, \n" + " unsigned int Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, long long Ax, long long Xx, \n" + " long long Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, unsigned long long Ax, unsigned long long Xx, \n" + " unsigned long long Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, float Ax, float Xx, float Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, double Ax, double Xx, double Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, long double Ax, long double Xx, \n" + " long double Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, \n" + " npy_cfloat_wrapper Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, \n" + " npy_cdouble_wrapper Yx)\n" + "coo_matvec(int nnz, int Ai, int Aj, npy_clongdouble_wrapper Ax, \n" + " npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx)\n" + ""}, { NULL, NULL, 0, NULL } }; @@ -10815,4 +13617,3 @@ } - Modified: trunk/scipy/sparse/sparsetools/csc_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/csc_wrap.cxx 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/csc_wrap.cxx 2008-07-08 09:47:43 UTC (rev 4532) @@ -3181,30 +3181,46 @@ csc_matmat_pass1< int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3285,24 +3301,36 @@ csc_diagonal< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3383,24 +3411,36 @@ csc_diagonal< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3481,24 +3521,36 @@ csc_diagonal< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3579,24 +3631,36 @@ csc_diagonal< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3677,24 +3741,36 @@ csc_diagonal< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3775,24 +3851,36 @@ csc_diagonal< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3873,24 +3961,36 @@ csc_diagonal< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3971,24 +4071,36 @@ csc_diagonal< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4069,24 +4181,36 @@ csc_diagonal< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4167,24 +4291,36 @@ csc_diagonal< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4265,24 +4401,36 @@ csc_diagonal< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4363,24 +4511,36 @@ csc_diagonal< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4461,24 +4621,36 @@ csc_diagonal< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4559,24 +4731,36 @@ csc_diagonal< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5209,24 +5393,36 @@ csc_tocsr< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5323,24 +5519,36 @@ csc_tocsr< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5437,24 +5645,36 @@ csc_tocsr< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5551,24 +5771,36 @@ csc_tocsr< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5665,24 +5897,36 @@ csc_tocsr< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5779,24 +6023,36 @@ csc_tocsr< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5893,24 +6149,36 @@ csc_tocsr< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6007,24 +6275,36 @@ csc_tocsr< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6121,24 +6401,36 @@ csc_tocsr< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6235,24 +6527,36 @@ csc_tocsr< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6349,24 +6653,36 @@ csc_tocsr< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6463,24 +6779,36 @@ csc_tocsr< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6577,24 +6905,36 @@ csc_tocsr< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -6691,24 +7031,36 @@ csc_tocsr< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -7523,42 +7875,66 @@ csc_matmat_pass2< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -7697,42 +8073,66 @@ csc_matmat_pass2< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -7871,42 +8271,66 @@ csc_matmat_pass2< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8045,42 +8469,66 @@ csc_matmat_pass2< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8219,42 +8667,66 @@ csc_matmat_pass2< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8393,42 +8865,66 @@ csc_matmat_pass2< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8567,42 +9063,66 @@ csc_matmat_pass2< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8741,42 +9261,66 @@ csc_matmat_pass2< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -8915,42 +9459,66 @@ csc_matmat_pass2< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9089,42 +9657,66 @@ csc_matmat_pass2< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9263,42 +9855,66 @@ csc_matmat_pass2< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9437,42 +10053,66 @@ csc_matmat_pass2< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9611,42 +10251,66 @@ csc_matmat_pass2< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -9785,42 +10449,66 @@ csc_matmat_pass2< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -10801,30 +11489,46 @@ csc_matvec< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(signed char const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -10919,30 +11623,46 @@ csc_matvec< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(unsigned char const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11037,30 +11757,46 @@ csc_matvec< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(short const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11155,30 +11891,46 @@ csc_matvec< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(unsigned short const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11273,30 +12025,46 @@ csc_matvec< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11391,30 +12159,46 @@ csc_matvec< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(unsigned int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11509,30 +12293,46 @@ csc_matvec< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(long long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11627,30 +12427,46 @@ csc_matvec< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(unsigned long long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11745,30 +12561,46 @@ csc_matvec< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11863,30 +12695,46 @@ csc_matvec< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -11981,30 +12829,46 @@ csc_matvec< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -12099,30 +12963,46 @@ csc_matvec< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(npy_cfloat_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -12217,30 +13097,46 @@ csc_matvec< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(npy_cdouble_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -12335,30 +13231,46 @@ csc_matvec< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -13103,42 +14015,66 @@ csc_elmul_csc< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -13277,42 +14213,66 @@ csc_elmul_csc< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -13451,42 +14411,66 @@ csc_elmul_csc< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -13625,42 +14609,66 @@ csc_elmul_csc< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -13799,42 +14807,66 @@ csc_elmul_csc< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -13973,42 +15005,66 @@ csc_elmul_csc< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14147,42 +15203,66 @@ csc_elmul_csc< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14321,42 +15401,66 @@ csc_elmul_csc< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14495,42 +15599,66 @@ csc_elmul_csc< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14669,42 +15797,66 @@ csc_elmul_csc< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14843,42 +15995,66 @@ csc_elmul_csc< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15017,42 +16193,66 @@ csc_elmul_csc< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15191,42 +16391,66 @@ csc_elmul_csc< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15365,42 +16589,66 @@ csc_elmul_csc< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16425,42 +17673,66 @@ csc_eldiv_csc< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16599,42 +17871,66 @@ csc_eldiv_csc< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16773,42 +18069,66 @@ csc_eldiv_csc< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16947,42 +18267,66 @@ csc_eldiv_csc< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17121,42 +18465,66 @@ csc_eldiv_csc< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17295,42 +18663,66 @@ csc_eldiv_csc< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17469,42 +18861,66 @@ csc_eldiv_csc< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17643,42 +19059,66 @@ csc_eldiv_csc< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17817,42 +19257,66 @@ csc_eldiv_csc< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17991,42 +19455,66 @@ csc_eldiv_csc< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18165,42 +19653,66 @@ csc_eldiv_csc< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18339,42 +19851,66 @@ csc_eldiv_csc< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18513,42 +20049,66 @@ csc_eldiv_csc< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -18687,42 +20247,66 @@ csc_eldiv_csc< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -19747,42 +21331,66 @@ csc_plus_csc< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -19921,42 +21529,66 @@ csc_plus_csc< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20095,42 +21727,66 @@ csc_plus_csc< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20269,42 +21925,66 @@ csc_plus_csc< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20443,42 +22123,66 @@ csc_plus_csc< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20617,42 +22321,66 @@ csc_plus_csc< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20791,42 +22519,66 @@ csc_plus_csc< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20965,42 +22717,66 @@ csc_plus_csc< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21139,42 +22915,66 @@ csc_plus_csc< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21313,42 +23113,66 @@ csc_plus_csc< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21487,42 +23311,66 @@ csc_plus_csc< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21661,42 +23509,66 @@ csc_plus_csc< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21835,42 +23707,66 @@ csc_plus_csc< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -22009,42 +23905,66 @@ csc_plus_csc< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23069,42 +24989,66 @@ csc_minus_csc< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23243,42 +25187,66 @@ csc_minus_csc< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23417,42 +25385,66 @@ csc_minus_csc< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23591,42 +25583,66 @@ csc_minus_csc< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23765,42 +25781,66 @@ csc_minus_csc< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23939,42 +25979,66 @@ csc_minus_csc< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24113,42 +26177,66 @@ csc_minus_csc< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24287,42 +26375,66 @@ csc_minus_csc< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24461,42 +26573,66 @@ csc_minus_csc< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24635,42 +26771,66 @@ csc_minus_csc< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24809,42 +26969,66 @@ csc_minus_csc< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24983,42 +27167,66 @@ csc_minus_csc< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -25157,42 +27365,66 @@ csc_minus_csc< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -25331,42 +27563,66 @@ csc_minus_csc< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27099,4 +29355,3 @@ } - Modified: trunk/scipy/sparse/sparsetools/csr.h =================================================================== --- trunk/scipy/sparse/sparsetools/csr.h 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/csr.h 2008-07-08 09:47:43 UTC (rev 4532) @@ -690,18 +690,18 @@ /* element-wise binary operations*/ template void csr_elmul_csr(const I n_row, const I n_col, - const I Ap [], const I Aj [], const T Ax [], - const I Bp [], const I Bj [], const T Bx [], - I Cp[], I Cj[], T Cx[]) + const I Ap[], const I Aj[], const T Ax[], + const I Bp[], const I Bj[], const T Bx[], + I Cp[], I Cj[], T Cx[]) { csr_binop_csr(n_row,n_col,Ap,Aj,Ax,Bp,Bj,Bx,Cp,Cj,Cx,std::multiplies()); } template void csr_eldiv_csr(const I n_row, const I n_col, - const I Ap [], const I Aj [], const T Ax [], - const I Bp [], const I Bj [], const T Bx [], - I Cp[], I Cj[], T Cx[]) + const I Ap[], const I Aj[], const T Ax[], + const I Bp[], const I Bj[], const T Bx[], + I Cp[], I Cj[], T Cx[]) { csr_binop_csr(n_row,n_col,Ap,Aj,Ax,Bp,Bj,Bx,Cp,Cj,Cx,std::divides()); } @@ -709,18 +709,18 @@ template void csr_plus_csr(const I n_row, const I n_col, - const I Ap [], const I Aj [], const T Ax [], - const I Bp [], const I Bj [], const T Bx [], - I Cp[], I Cj[], T Cx[]) + const I Ap[], const I Aj[], const T Ax[], + const I Bp[], const I Bj[], const T Bx[], + I Cp[], I Cj[], T Cx[]) { csr_binop_csr(n_row,n_col,Ap,Aj,Ax,Bp,Bj,Bx,Cp,Cj,Cx,std::plus()); } template void csr_minus_csr(const I n_row, const I n_col, - const I Ap[], const I Aj [], const T Ax [], - const I Bp[], const I Bj [], const T Bx [], - I Cp[], I Cj[], T Cx[]) + const I Ap[], const I Aj[], const T Ax[], + const I Bp[], const I Bj[], const T Bx[], + I Cp[], I Cj[], T Cx[]) { csr_binop_csr(n_row,n_col,Ap,Aj,Ax,Bp,Bj,Bx,Cp,Cj,Cx,std::minus()); } Modified: trunk/scipy/sparse/sparsetools/csr_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/csr_wrap.cxx 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/csr_wrap.cxx 2008-07-08 09:47:43 UTC (rev 4532) @@ -3161,12 +3161,16 @@ expandptr< int >(arg1,(int const (*))arg2,arg3); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -3244,18 +3248,26 @@ result = (int)csr_count_blocks< int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6); resultobj = SWIG_From_int(static_cast< int >(result)); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3350,30 +3362,46 @@ csr_matmat_pass1< int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -3424,18 +3452,26 @@ result = (bool)csr_has_sorted_indices< int >(arg1,(int const (*))arg2,(int const (*))arg3); resultobj = SWIG_From_bool(static_cast< bool >(result)); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } return NULL; } @@ -3516,24 +3552,36 @@ csr_diagonal< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3614,24 +3662,36 @@ csr_diagonal< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3712,24 +3772,36 @@ csr_diagonal< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3810,24 +3882,36 @@ csr_diagonal< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -3908,24 +3992,36 @@ csr_diagonal< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4006,24 +4102,36 @@ csr_diagonal< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4104,24 +4212,36 @@ csr_diagonal< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4202,24 +4322,36 @@ csr_diagonal< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4300,24 +4432,36 @@ csr_diagonal< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4398,24 +4542,36 @@ csr_diagonal< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4496,24 +4652,36 @@ csr_diagonal< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4594,24 +4762,36 @@ csr_diagonal< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4692,24 +4872,36 @@ csr_diagonal< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -4790,24 +4982,36 @@ csr_diagonal< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -5424,24 +5628,36 @@ csr_scale_rows< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(signed char const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5522,24 +5738,36 @@ csr_scale_rows< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned char const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5620,24 +5848,36 @@ csr_scale_rows< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(short const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5718,24 +5958,36 @@ csr_scale_rows< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned short const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5816,24 +6068,36 @@ csr_scale_rows< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(int const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -5914,24 +6178,36 @@ csr_scale_rows< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned int const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6012,24 +6288,36 @@ csr_scale_rows< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(long long const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6110,24 +6398,36 @@ csr_scale_rows< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned long long const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6208,24 +6508,36 @@ csr_scale_rows< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(float const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6306,24 +6618,36 @@ csr_scale_rows< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(double const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6404,24 +6728,36 @@ csr_scale_rows< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(long double const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6502,24 +6838,36 @@ csr_scale_rows< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(npy_cfloat_wrapper const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6600,24 +6948,36 @@ csr_scale_rows< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(npy_cdouble_wrapper const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -6698,24 +7058,36 @@ csr_scale_rows< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(npy_clongdouble_wrapper const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7332,24 +7704,36 @@ csr_scale_columns< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(signed char const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7430,24 +7814,36 @@ csr_scale_columns< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned char const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7528,24 +7924,36 @@ csr_scale_columns< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(short const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7626,24 +8034,36 @@ csr_scale_columns< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned short const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7724,24 +8144,36 @@ csr_scale_columns< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(int const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7822,24 +8254,36 @@ csr_scale_columns< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned int const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -7920,24 +8364,36 @@ csr_scale_columns< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(long long const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8018,24 +8474,36 @@ csr_scale_columns< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(unsigned long long const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8116,24 +8584,36 @@ csr_scale_columns< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(float const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8214,24 +8694,36 @@ csr_scale_columns< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(double const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8312,24 +8804,36 @@ csr_scale_columns< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(long double const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8410,24 +8914,36 @@ csr_scale_columns< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(npy_cfloat_wrapper const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8508,24 +9024,36 @@ csr_scale_columns< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(npy_cdouble_wrapper const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -8606,24 +9134,36 @@ csr_scale_columns< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,arg5,(npy_clongdouble_wrapper const (*))arg6); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -9256,24 +9796,36 @@ csr_tocsc< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -9370,24 +9922,36 @@ csr_tocsc< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -9484,24 +10048,36 @@ csr_tocsc< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -9598,24 +10174,36 @@ csr_tocsc< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -9712,24 +10300,36 @@ csr_tocsc< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -9826,24 +10426,36 @@ csr_tocsc< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -9940,24 +10552,36 @@ csr_tocsc< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10054,24 +10678,36 @@ csr_tocsc< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10168,24 +10804,36 @@ csr_tocsc< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10282,24 +10930,36 @@ csr_tocsc< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10396,24 +11056,36 @@ csr_tocsc< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10510,24 +11182,36 @@ csr_tocsc< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10624,24 +11308,36 @@ csr_tocsc< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -10738,24 +11434,36 @@ csr_tocsc< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -11546,24 +12254,36 @@ csr_tobsr< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(signed char const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11678,24 +12398,36 @@ csr_tobsr< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned char const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11810,24 +12542,36 @@ csr_tobsr< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(short const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -11942,24 +12686,36 @@ csr_tobsr< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned short const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12074,24 +12830,36 @@ csr_tobsr< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12206,24 +12974,36 @@ csr_tobsr< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned int const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12338,24 +13118,36 @@ csr_tobsr< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long long const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12470,24 +13262,36 @@ csr_tobsr< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(unsigned long long const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12602,24 +13406,36 @@ csr_tobsr< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(float const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12734,24 +13550,36 @@ csr_tobsr< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(double const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12866,24 +13694,36 @@ csr_tobsr< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(long double const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -12998,24 +13838,36 @@ csr_tobsr< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cfloat_wrapper const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -13130,24 +13982,36 @@ csr_tobsr< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_cdouble_wrapper const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -13262,24 +14126,36 @@ csr_tobsr< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,arg8,arg9,arg10); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -14262,42 +15138,66 @@ csr_matmat_pass2< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14436,42 +15336,66 @@ csr_matmat_pass2< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14610,42 +15534,66 @@ csr_matmat_pass2< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14784,42 +15732,66 @@ csr_matmat_pass2< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -14958,42 +15930,66 @@ csr_matmat_pass2< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15132,42 +16128,66 @@ csr_matmat_pass2< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15306,42 +16326,66 @@ csr_matmat_pass2< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15480,42 +16524,66 @@ csr_matmat_pass2< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15654,42 +16722,66 @@ csr_matmat_pass2< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -15828,42 +16920,66 @@ csr_matmat_pass2< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16002,42 +17118,66 @@ csr_matmat_pass2< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16176,42 +17316,66 @@ csr_matmat_pass2< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16350,42 +17514,66 @@ csr_matmat_pass2< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -16524,42 +17712,66 @@ csr_matmat_pass2< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -17540,30 +18752,46 @@ csr_matvec< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(signed char const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -17658,30 +18886,46 @@ csr_matvec< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(unsigned char const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -17776,30 +19020,46 @@ csr_matvec< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(short const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -17894,30 +19154,46 @@ csr_matvec< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(unsigned short const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18012,30 +19288,46 @@ csr_matvec< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18130,30 +19422,46 @@ csr_matvec< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(unsigned int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18248,30 +19556,46 @@ csr_matvec< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(long long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18366,30 +19690,46 @@ csr_matvec< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(unsigned long long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18484,30 +19824,46 @@ csr_matvec< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18602,30 +19958,46 @@ csr_matvec< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18720,30 +20092,46 @@ csr_matvec< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18838,30 +20226,46 @@ csr_matvec< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(npy_cfloat_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -18956,30 +20360,46 @@ csr_matvec< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(npy_cdouble_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -19074,30 +20494,46 @@ csr_matvec< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } return NULL; } @@ -19842,42 +21278,66 @@ csr_elmul_csr< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20016,42 +21476,66 @@ csr_elmul_csr< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20190,42 +21674,66 @@ csr_elmul_csr< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20364,42 +21872,66 @@ csr_elmul_csr< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20538,42 +22070,66 @@ csr_elmul_csr< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20712,42 +22268,66 @@ csr_elmul_csr< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -20886,42 +22466,66 @@ csr_elmul_csr< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21060,42 +22664,66 @@ csr_elmul_csr< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21234,42 +22862,66 @@ csr_elmul_csr< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21408,42 +23060,66 @@ csr_elmul_csr< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21582,42 +23258,66 @@ csr_elmul_csr< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21756,42 +23456,66 @@ csr_elmul_csr< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -21930,42 +23654,66 @@ csr_elmul_csr< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -22104,42 +23852,66 @@ csr_elmul_csr< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23164,42 +24936,66 @@ csr_eldiv_csr< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23338,42 +25134,66 @@ csr_eldiv_csr< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23512,42 +25332,66 @@ csr_eldiv_csr< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23686,42 +25530,66 @@ csr_eldiv_csr< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -23860,42 +25728,66 @@ csr_eldiv_csr< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24034,42 +25926,66 @@ csr_eldiv_csr< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24208,42 +26124,66 @@ csr_eldiv_csr< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24382,42 +26322,66 @@ csr_eldiv_csr< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24556,42 +26520,66 @@ csr_eldiv_csr< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24730,42 +26718,66 @@ csr_eldiv_csr< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -24904,42 +26916,66 @@ csr_eldiv_csr< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -25078,42 +27114,66 @@ csr_eldiv_csr< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -25252,42 +27312,66 @@ csr_eldiv_csr< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -25426,42 +27510,66 @@ csr_eldiv_csr< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -26486,42 +28594,66 @@ csr_plus_csr< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -26660,42 +28792,66 @@ csr_plus_csr< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -26834,42 +28990,66 @@ csr_plus_csr< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27008,42 +29188,66 @@ csr_plus_csr< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27182,42 +29386,66 @@ csr_plus_csr< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27356,42 +29584,66 @@ csr_plus_csr< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27530,42 +29782,66 @@ csr_plus_csr< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27704,42 +29980,66 @@ csr_plus_csr< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -27878,42 +30178,66 @@ csr_plus_csr< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -28052,42 +30376,66 @@ csr_plus_csr< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -28226,42 +30574,66 @@ csr_plus_csr< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -28400,42 +30772,66 @@ csr_plus_csr< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -28574,42 +30970,66 @@ csr_plus_csr< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -28748,42 +31168,66 @@ csr_plus_csr< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -29808,42 +32252,66 @@ csr_minus_csr< int,signed char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(signed char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -29982,42 +32450,66 @@ csr_minus_csr< int,unsigned char >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned char const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -30156,42 +32648,66 @@ csr_minus_csr< int,short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -30330,42 +32846,66 @@ csr_minus_csr< int,unsigned short >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned short const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -30504,42 +33044,66 @@ csr_minus_csr< int,int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -30678,42 +33242,66 @@ csr_minus_csr< int,unsigned int >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -30852,42 +33440,66 @@ csr_minus_csr< int,long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -31026,42 +33638,66 @@ csr_minus_csr< int,unsigned long long >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(unsigned long long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -31200,42 +33836,66 @@ csr_minus_csr< int,float >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -31374,42 +34034,66 @@ csr_minus_csr< int,double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -31548,42 +34232,66 @@ csr_minus_csr< int,long double >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -31722,42 +34430,66 @@ csr_minus_csr< int,npy_cfloat_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -31896,42 +34628,66 @@ csr_minus_csr< int,npy_cdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -32070,42 +34826,66 @@ csr_minus_csr< int,npy_clongdouble_wrapper >(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble_wrapper const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } { - if (is_new_object8 && array8) Py_DECREF(array8); + if (is_new_object8 && array8) { + Py_DECREF(array8); + } } return NULL; } @@ -33043,12 +35823,16 @@ csr_sort_indices< int,signed char >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33100,12 +35884,16 @@ csr_sort_indices< int,unsigned char >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33157,12 +35945,16 @@ csr_sort_indices< int,short >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33214,12 +36006,16 @@ csr_sort_indices< int,unsigned short >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33271,12 +36067,16 @@ csr_sort_indices< int,int >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33328,12 +36128,16 @@ csr_sort_indices< int,unsigned int >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33385,12 +36189,16 @@ csr_sort_indices< int,long long >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33442,12 +36250,16 @@ csr_sort_indices< int,unsigned long long >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33499,12 +36311,16 @@ csr_sort_indices< int,float >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33556,12 +36372,16 @@ csr_sort_indices< int,double >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33613,12 +36433,16 @@ csr_sort_indices< int,long double >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33670,12 +36494,16 @@ csr_sort_indices< int,npy_cfloat_wrapper >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33727,12 +36555,16 @@ csr_sort_indices< int,npy_cdouble_wrapper >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -33784,12 +36616,16 @@ csr_sort_indices< int,npy_clongdouble_wrapper >(arg1,(int const (*))arg2,arg3,arg4); resultobj = SWIG_Py_Void(); { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return resultobj; fail: { - if (is_new_object2 && array2) Py_DECREF(array2); + if (is_new_object2 && array2) { + Py_DECREF(array2); + } } return NULL; } @@ -36763,24 +39599,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -36928,24 +39776,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -37093,24 +39953,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -37258,24 +40130,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -37423,24 +40307,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -37588,24 +40484,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -37753,24 +40661,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -37918,24 +40838,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -38083,24 +41015,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -38248,24 +41192,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -38413,24 +41369,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -38578,24 +41546,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -38743,24 +41723,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -38908,24 +41900,36 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); + if (is_new_object3 && array3) { + Py_DECREF(array3); + } } { - if (is_new_object4 && array4) Py_DECREF(array4); + if (is_new_object4 && array4) { + Py_DECREF(array4); + } } { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } return NULL; } @@ -40812,4 +43816,3 @@ } - Modified: trunk/scipy/sparse/sparsetools/dia_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/dia_wrap.cxx 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/sparsetools/dia_wrap.cxx 2008-07-08 09:47:43 UTC (rev 4532) @@ -3184,24 +3184,36 @@ dia_matvec< int,signed char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(signed char const (*))arg6,(signed char const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3299,24 +3311,36 @@ dia_matvec< int,unsigned char >(arg1,arg2,arg3,arg4,(int const (*))arg5,(unsigned char const (*))arg6,(unsigned char const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3414,24 +3438,36 @@ dia_matvec< int,short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(short const (*))arg6,(short const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3529,24 +3565,36 @@ dia_matvec< int,unsigned short >(arg1,arg2,arg3,arg4,(int const (*))arg5,(unsigned short const (*))arg6,(unsigned short const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3644,24 +3692,36 @@ dia_matvec< int,int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3759,24 +3819,36 @@ dia_matvec< int,unsigned int >(arg1,arg2,arg3,arg4,(int const (*))arg5,(unsigned int const (*))arg6,(unsigned int const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3874,24 +3946,36 @@ dia_matvec< int,long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(long long const (*))arg6,(long long const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -3989,24 +4073,36 @@ dia_matvec< int,unsigned long long >(arg1,arg2,arg3,arg4,(int const (*))arg5,(unsigned long long const (*))arg6,(unsigned long long const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4104,24 +4200,36 @@ dia_matvec< int,float >(arg1,arg2,arg3,arg4,(int const (*))arg5,(float const (*))arg6,(float const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4219,24 +4327,36 @@ dia_matvec< int,double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(double const (*))arg6,(double const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4334,24 +4454,36 @@ dia_matvec< int,long double >(arg1,arg2,arg3,arg4,(int const (*))arg5,(long double const (*))arg6,(long double const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4449,24 +4581,36 @@ dia_matvec< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(npy_cfloat_wrapper const (*))arg6,(npy_cfloat_wrapper const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4564,24 +4708,36 @@ dia_matvec< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(npy_cdouble_wrapper const (*))arg6,(npy_cdouble_wrapper const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -4679,24 +4835,36 @@ dia_matvec< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,(int const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,arg8); resultobj = SWIG_Py_Void(); { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return resultobj; fail: { - if (is_new_object5 && array5) Py_DECREF(array5); + if (is_new_object5 && array5) { + Py_DECREF(array5); + } } { - if (is_new_object6 && array6) Py_DECREF(array6); + if (is_new_object6 && array6) { + Py_DECREF(array6); + } } { - if (is_new_object7 && array7) Py_DECREF(array7); + if (is_new_object7 && array7) { + Py_DECREF(array7); + } } return NULL; } @@ -5992,4 +6160,3 @@ } - Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-07-06 16:40:48 UTC (rev 4531) +++ trunk/scipy/sparse/tests/test_base.py 2008-07-08 09:47:43 UTC (rev 4532) @@ -137,16 +137,18 @@ assert_array_equal(self.dat.mean(axis=0), self.datsp.mean(axis=0)) assert_array_equal(self.dat.mean(axis=1), self.datsp.mean(axis=1)) - def test_fromdense(self): - A = matrix([[1,0,0],[2,3,4],[0,5,0],[0,0,0]]) - assert_array_equal(self.spmatrix(A).todense(),A) - assert_array_equal(self.spmatrix(A.A).todense(),A) - assert_array_equal(self.spmatrix(A.tolist()).todense(),A) + def test_from_array(self): + A = array([[1,0,0],[2,3,4],[0,5,0],[0,0,0]]) + assert_array_equal(self.spmatrix(A).todense(), A) - def test_fromlist(self): + def test_from_matrix(self): A = matrix([[1,0,0],[2,3,4],[0,5,0],[0,0,0]]) - assert_array_equal(self.spmatrix(A.tolist()).todense(),A) + assert_array_equal(self.spmatrix(A).todense(), A) + def test_from_list(self): + A = [[1,0,0],[2,3,4],[0,5,0],[0,0,0]] + assert_array_equal(self.spmatrix(A).todense(), A) + def test_todense(self): chk = self.datsp.todense() assert_array_equal(chk,self.dat) @@ -224,7 +226,7 @@ assert_array_equal(A.todense() - self.datsp,A.todense() - self.dat) assert_array_equal(self.datsp - A.todense(),self.dat - A.todense()) - def test_elmul(self): + def test_elementwise_multiply(self): # real/real A = array([[4,0,9],[2,-3,5]]) B = array([[0,7,0],[0,-4,0]]) @@ -246,7 +248,7 @@ assert_almost_equal( Asp.multiply(D), A*D) #sparse/dense - def test_eldiv(self): + def test_elementwise_divide(self): expected = [[1,0,0,1],[1,0,1,0],[0,1,0,0]] assert_array_equal((self.datsp / self.datsp).todense(),expected) @@ -393,7 +395,7 @@ assert_equal( result.shape, (4,2) ) assert_equal( result, dot(a,b) ) - def test_formatconversions(self): + def test_sparse_format_conversions(self): A = sparse.kron([[1,0,1],[0,1,1],[1,0,0]], [[1,1],[0,1]] ) D = A.todense() A = self.spmatrix(A) @@ -412,12 +414,7 @@ assert_array_equal(c.todense(), D) - - def test_todia(self): - #TODO, add and test .todia(maxdiags) - pass - - def test_tocompressedblock(self): + def test_tobsr(self): x = array([[1,0,2,0],[0,0,0,0],[0,0,4,5]]) y = array([[0,1,2],[3,0,5]]) A = numpy.kron(x,y) @@ -695,61 +692,61 @@ A = self.spmatrix( B ) # [i,j] - assert_equal(A[2,3],B[2,3]) - assert_equal(A[-1,8],B[-1,8]) + assert_equal(A[2,3], B[2,3]) + assert_equal(A[-1,8], B[-1,8]) assert_equal(A[-1,-2],B[-1,-2]) # [i,1:2] - assert_equal(A[2,:].todense(),B[2,:]) + assert_equal(A[2,:].todense(), B[2,:]) assert_equal(A[2,5:-2].todense(),B[2,5:-2]) # [i,[1,2]] - assert_equal(A[3,[1,3]].todense(),B[3,[1,3]]) + assert_equal(A[3,[1,3]].todense(), B[3,[1,3]]) assert_equal(A[-1,[2,-5]].todense(),B[-1,[2,-5]]) # [1:2,j] - assert_equal(A[:,2].todense(),B[:,2]) - assert_equal(A[3:4,9].todense(),B[3:4,9]) + assert_equal(A[:,2].todense(), B[:,2]) + assert_equal(A[3:4,9].todense(), B[3:4,9]) assert_equal(A[1:4,-5].todense(),B[1:4,-5]) assert_equal(A[2:-1,3].todense(),B[2:-1,3]) # [1:2,1:2] assert_equal(A[1:2,1:2].todense(),B[1:2,1:2]) - assert_equal(A[4:,3:].todense(),B[4:,3:]) - assert_equal(A[:4,:5].todense(),B[:4,:5]) + assert_equal(A[4:,3:].todense(), B[4:,3:]) + assert_equal(A[:4,:5].todense(), B[:4,:5]) assert_equal(A[2:-1,:5].todense(),B[2:-1,:5]) # [1:2,[1,2]] assert_equal(A[:,[2,8,3,-1]].todense(),B[:,[2,8,3,-1]]) - assert_equal(A[3:4,[9]].todense(),B[3:4,[9]]) - assert_equal(A[1:4,[-1,-5]].todense(),B[1:4,[-1,-5]]) + assert_equal(A[3:4,[9]].todense(), B[3:4,[9]]) + assert_equal(A[1:4,[-1,-5]].todense(), B[1:4,[-1,-5]]) # [[1,2],j] - assert_equal(A[[1,3],3].todense(),B[[1,3],3]) - assert_equal(A[[2,-5],-4].todense(),B[[2,-5],-4]) + assert_equal(A[[1,3],3].todense(), B[[1,3],3]) + assert_equal(A[[2,-5],-4].todense(), B[[2,-5],-4]) # [[1,2],1:2] - assert_equal(A[[1,3],:].todense(),B[[1,3],:]) + assert_equal(A[[1,3],:].todense(), B[[1,3],:]) assert_equal(A[[2,-5],8:-1].todense(),B[[2,-5],8:-1]) # [[1,2],[1,2]] - assert_equal(A[[1,3],[2,4]],B[[1,3],[2,4]]) + assert_equal(A[[1,3],[2,4]], B[[1,3],[2,4]]) assert_equal(A[[-1,-3],[2,-4]],B[[-1,-3],[2,-4]]) # [[[1],[2]],[1,2]] - assert_equal(A[[[1],[3]],[2,4]].todense(),B[[[1],[3]],[2,4]]) + assert_equal(A[[[1],[3]],[2,4]].todense(), B[[[1],[3]],[2,4]]) assert_equal(A[[[-1],[-3],[-2]],[2,-4]].todense(),B[[[-1],[-3],[-2]],[2,-4]]) # [i] - assert_equal(A[1,:].todense(),B[1,:]) + assert_equal(A[1,:].todense(), B[1,:]) assert_equal(A[-2,:].todense(),B[-2,:]) # [1:2] - assert_equal(A[1:4].todense(),B[1:4]) + assert_equal(A[1:4].todense(), B[1:4]) assert_equal(A[1:-2].todense(),B[1:-2]) # [[1,2]] - assert_equal(A[[1,3]].todense(),B[[1,3]]) + assert_equal(A[[1,3]].todense(), B[[1,3]]) assert_equal(A[[-1,-3]].todense(),B[[-1,-3]]) # [[1,2],:][:,[1,2]] From scipy-svn at scipy.org Tue Jul 8 15:52:48 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 8 Jul 2008 14:52:48 -0500 (CDT) Subject: [Scipy-svn] r4533 - trunk/scipy/sparse/linalg/isolve/iterative Message-ID: <20080708195248.3EA5239C5A1@scipy.org> Author: rkern Date: 2008-07-08 14:52:27 -0500 (Tue, 08 Jul 2008) New Revision: 4533 Modified: trunk/scipy/sparse/linalg/isolve/iterative/BiCGREVCOM.f.src trunk/scipy/sparse/linalg/isolve/iterative/BiCGSTABREVCOM.f.src trunk/scipy/sparse/linalg/isolve/iterative/CGREVCOM.f.src trunk/scipy/sparse/linalg/isolve/iterative/CGSREVCOM.f.src trunk/scipy/sparse/linalg/isolve/iterative/GMRESREVCOM.f.src trunk/scipy/sparse/linalg/isolve/iterative/QMRREVCOM.f.src trunk/scipy/sparse/linalg/isolve/iterative/STOPTEST2.f.src trunk/scipy/sparse/linalg/isolve/iterative/getbreak.f.src Log: Change END SUBROUTINE to just END to satisfy finicky Sun Fortran compilers. Modified: trunk/scipy/sparse/linalg/isolve/iterative/BiCGREVCOM.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/BiCGREVCOM.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/BiCGREVCOM.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -387,7 +387,8 @@ * * End of BICGREVCOM * - END SUBROUTINE <_c>BICGREVCOM + END +* END SUBROUTINE <_c>BICGREVCOM Modified: trunk/scipy/sparse/linalg/isolve/iterative/BiCGSTABREVCOM.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/BiCGSTABREVCOM.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/BiCGSTABREVCOM.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -423,4 +423,5 @@ * * End of BICGSTABREVCOM * - END SUBROUTINE <_c>BICGSTABREVCOM + END +* END SUBROUTINE <_c>BICGSTABREVCOM Modified: trunk/scipy/sparse/linalg/isolve/iterative/CGREVCOM.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/CGREVCOM.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/CGREVCOM.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -314,4 +314,5 @@ * * End of CGREVCOM * - END SUBROUTINE <_c>CGREVCOM + END +* END SUBROUTINE <_c>CGREVCOM Modified: trunk/scipy/sparse/linalg/isolve/iterative/CGSREVCOM.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/CGSREVCOM.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/CGSREVCOM.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -422,7 +422,8 @@ * * End of CGSREVCOM * - END SUBROUTINE <_c>CGSREVCOM + END +* END SUBROUTINE <_c>CGSREVCOM Modified: trunk/scipy/sparse/linalg/isolve/iterative/GMRESREVCOM.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/GMRESREVCOM.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/GMRESREVCOM.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -398,7 +398,8 @@ * * End of GMRESREVCOM * - END SUBROUTINE <_c>GMRESREVCOM + END +* END SUBROUTINE <_c>GMRESREVCOM * * ========================================================= SUBROUTINE <_c>ORTHOH( I, N, H, V, LDV, W ) @@ -426,7 +427,8 @@ * RETURN * - END SUBROUTINE <_c>ORTHOH + END +* END SUBROUTINE <_c>ORTHOH * ========================================================= SUBROUTINE <_c>APPLYGIVENS( I, H, GIVENS, LDG ) * @@ -464,7 +466,8 @@ * RETURN * - END SUBROUTINE <_c>APPLYGIVENS + END +* END SUBROUTINE <_c>APPLYGIVENS * * =============================================================== @@ -492,7 +495,8 @@ * RETURN * - END FUNCTION APPROXRES + END +* END FUNCTION APPROXRES * =============================================================== SUBROUTINE <_c>UPDATE( I, N, X, H, LDH, Y, S, V, LDV ) * @@ -513,7 +517,8 @@ * RETURN * - END SUBROUTINE <_c>UPDATE + END +* END SUBROUTINE <_c>UPDATE * * =============================================================== SUBROUTINE <_c>GETGIV( A, B, C, S ) @@ -542,7 +547,8 @@ * RETURN * - END SUBROUTINE <_c>GETGIV + END +* END SUBROUTINE <_c>GETGIV * * ================================================================ SUBROUTINE <_c>ROTVEC( X, Y, C, S ) @@ -556,7 +562,8 @@ * RETURN * - END SUBROUTINE <_c>ROTVEC + END +* END SUBROUTINE <_c>ROTVEC * * =============================================================== SUBROUTINE <_c>ELEMVEC( I, N, ALPHA, E ) @@ -577,5 +584,6 @@ * RETURN * - END SUBROUTINE <_c>ELEMVEC + END +* END SUBROUTINE <_c>ELEMVEC Modified: trunk/scipy/sparse/linalg/isolve/iterative/QMRREVCOM.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/QMRREVCOM.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/QMRREVCOM.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -557,4 +557,5 @@ * * End of QMRREVCOM * - END SUBROUTINE <_c>QMRREVCOM + END +* END SUBROUTINE <_c>QMRREVCOM Modified: trunk/scipy/sparse/linalg/isolve/iterative/STOPTEST2.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/STOPTEST2.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/STOPTEST2.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -57,5 +57,6 @@ IF ( RESID.LE.TOL ) $ INFO = 1 RETURN - END SUBROUTINE <_c>STOPTEST2 + END +* END SUBROUTINE <_c>STOPTEST2 Modified: trunk/scipy/sparse/linalg/isolve/iterative/getbreak.f.src =================================================================== --- trunk/scipy/sparse/linalg/isolve/iterative/getbreak.f.src 2008-07-08 09:47:43 UTC (rev 4532) +++ trunk/scipy/sparse/linalg/isolve/iterative/getbreak.f.src 2008-07-08 19:52:27 UTC (rev 4533) @@ -13,7 +13,8 @@ * RETURN * - END FUNCTION <_c>GETBREAK + END +* END FUNCTION <_c>GETBREAK From scipy-svn at scipy.org Wed Jul 9 08:06:00 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 9 Jul 2008 07:06:00 -0500 (CDT) Subject: [Scipy-svn] r4534 - in trunk/scipy: cluster fftpack integrate interpolate io lib/blas lib/lapack linalg ndimage odr optimize signal special stats Message-ID: <20080709120600.F2F4F39C5FF@scipy.org> Author: cdavid Date: 2008-07-09 07:05:31 -0500 (Wed, 09 Jul 2008) New Revision: 4534 Modified: trunk/scipy/cluster/SConscript trunk/scipy/fftpack/SConscript trunk/scipy/integrate/SConscript trunk/scipy/interpolate/SConscript trunk/scipy/io/SConscript trunk/scipy/lib/blas/SConscript trunk/scipy/lib/lapack/SConscript trunk/scipy/linalg/SConscript trunk/scipy/ndimage/SConscript trunk/scipy/odr/SConscript trunk/scipy/optimize/SConscript trunk/scipy/signal/SConscript trunk/scipy/special/SConscript trunk/scipy/stats/SConscript Log: Use NumpyPythonExtension builder. Modified: trunk/scipy/cluster/SConscript =================================================================== --- trunk/scipy/cluster/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/cluster/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -2,18 +2,15 @@ # vim:syntax=python from os.path import join -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.DistutilsPythonExtension('_vq', source = [join('src', 'vq_module.c'), +env.NumpyPythonExtension('_vq', source = [join('src', 'vq_module.c'), join('src', 'vq.c')]) -env.DistutilsPythonExtension('_hierarchy_wrap', source = [join('src', 'hierarchy_wrap.c'), +env.NumpyPythonExtension('_hierarchy_wrap', source = [join('src', 'hierarchy_wrap.c'), join('src', 'hierarchy.c')]) - -env.DistutilsPythonExtension('_distance_wrap', source = [join('src', 'distance_wrap.c'), +env.NumpyPythonExtension('_distance_wrap', source = [join('src', 'distance_wrap.c'), join('src', 'distance.c')]) Modified: trunk/scipy/fftpack/SConscript =================================================================== --- trunk/scipy/fftpack/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/fftpack/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -2,16 +2,12 @@ # vim:syntax=python from os.path import join as pjoin -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, write_info from numscons import CheckFFT, IsMKL, IsFFTW2, IsFFTW3 env = GetNumpyEnvironment(ARGUMENTS) env.Tool('f2py') -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) - # Check fft implementation config = env.NumpyConfigure(custom_tests = {'CheckFFT': CheckFFT}) has_fft = config.CheckFFT() @@ -41,8 +37,8 @@ # Build _fftpack src = ['src/zfft.c','src/drfft.c','src/zrfft.c', 'src/zfftnd.c', 'fftpack.pyf'] -env.DistutilsPythonExtension('_fftpack', src) +env.NumpyPythonExtension('_fftpack', src) # Build convolve src = ['src/convolve.c', 'convolve.pyf'] -env.DistutilsPythonExtension('convolve', src) +env.NumpyPythonExtension('convolve', src) Modified: trunk/scipy/integrate/SConscript =================================================================== --- trunk/scipy/integrate/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/integrate/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -3,7 +3,6 @@ from os.path import join as pjoin import warnings -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, CheckF77Clib, CheckF77BLAS env = GetNumpyEnvironment(ARGUMENTS) @@ -20,9 +19,6 @@ config.Finish() -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) - # XXX: lapack integration # Build linpack_lite @@ -69,10 +65,10 @@ odenv.Prepend(LIBS = ['odepack', 'linpack_lite', 'mach']) # Build _quadpack -quadenv.DistutilsPythonExtension('_quadpack', source = '_quadpackmodule.c') +quadenv.NumpyPythonExtension('_quadpack', source = '_quadpackmodule.c') # Build _odepack -odenv.DistutilsPythonExtension('_odepack', source = '_odepackmodule.c') +odenv.NumpyPythonExtension('_odepack', source = '_odepackmodule.c') # Build vode -odenv.DistutilsPythonExtension('vode', source = 'vode.pyf') +odenv.NumpyPythonExtension('vode', source = 'vode.pyf') Modified: trunk/scipy/interpolate/SConscript =================================================================== --- trunk/scipy/interpolate/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/interpolate/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -2,7 +2,6 @@ # vim:syntax=python from os.path import join as pjoin -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, CheckF77Clib env = GetNumpyEnvironment(ARGUMENTS) @@ -13,8 +12,6 @@ raise Exception("Could not check F77 runtime, needed for interpolate") config.Finish() -env.PrependUnique(CPPPATH = get_numpy_include_dirs()) -env.PrependUnique(CPPPATH = env['F2PYINCLUDEDIR']) env.AppendUnique(LINKFLAGSEND = env['F77_LDFLAGS']) # Build fitpack @@ -39,7 +36,7 @@ env.PrependUnique(LIBPATH = ['.']) # Build _fitpack -env.DistutilsPythonExtension('_fitpack', source = '_fitpackmodule.c') +env.NumpyPythonExtension('_fitpack', source = '_fitpackmodule.c') # Build dfitpack -env.DistutilsPythonExtension('dfitpack', source = 'fitpack.pyf') +env.NumpyPythonExtension('dfitpack', source = 'fitpack.pyf') Modified: trunk/scipy/io/SConscript =================================================================== --- trunk/scipy/io/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/io/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -1,11 +1,7 @@ # Last Change: Wed Mar 05 03:00 PM 2008 J # vim:syntax=python -from os.path import join - -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.DistutilsPythonExtension('numpyio', source = 'numpyiomodule.c') +env.NumpyPythonExtension('numpyio', source = 'numpyiomodule.c') Modified: trunk/scipy/lib/blas/SConscript =================================================================== --- trunk/scipy/lib/blas/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/lib/blas/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -4,8 +4,6 @@ import os from os.path import join as pjoin, splitext -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import get_python_inc#, get_pythonlib_dir from numscons import GetNumpyEnvironment from numscons import CheckCBLAS, CheckF77BLAS,\ IsVeclib, IsAccelerate, \ @@ -17,7 +15,6 @@ env = GetNumpyEnvironment(ARGUMENTS) env.Tool('f2py') -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 @@ -58,7 +55,6 @@ #========== # XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) env.AppendUnique(F2PYOPTIONS = '--quiet') #------------ @@ -72,7 +68,7 @@ else: env.FromFTemplate('fblaswrap.f', 'fblaswrap.f.src') source.append('fblaswrap.f') -env.DistutilsPythonExtension('fblas', source) +env.NumpyPythonExtension('fblas', source) #------------ # cblas @@ -82,4 +78,4 @@ env.FromFTemplate('cblas.pyf', 'cblas.pyf.src') else: print env.GenerateFakePyf('cblas', 'cblas.pyf.src') -env.DistutilsPythonExtension('cblas', source) +env.NumpyPythonExtension('cblas', source) Modified: trunk/scipy/lib/lapack/SConscript =================================================================== --- trunk/scipy/lib/lapack/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/lib/lapack/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -4,8 +4,6 @@ import os from os.path import join as pjoin, splitext -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import get_python_inc from numscons import GetNumpyEnvironment from numscons import CheckF77LAPACK,\ CheckCLAPACK, \ @@ -18,7 +16,6 @@ env = GetNumpyEnvironment(ARGUMENTS) env.Tool('f2py') -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 @@ -70,7 +67,7 @@ # flapack #------------ yop = env.FromFTemplate('flapack.pyf', 'flapack.pyf.src') -env.DistutilsPythonExtension('flapack', source = ['flapack.pyf']) +env.NumpyPythonExtension('flapack', source = ['flapack.pyf']) #------------ # clapack @@ -79,17 +76,17 @@ env.FromFTemplate('clapack.pyf', 'clapack.pyf.src') else: env.GenerateFakePyf('clapack', 'clapack.pyf.src') -env.DistutilsPythonExtension('clapack', source = 'clapack.pyf') +env.NumpyPythonExtension('clapack', source = 'clapack.pyf') #---------------- # calc_lwork: #---------------- calc_src = env.F2py(pjoin('calc_lworkmodule.c'), source = pjoin('calc_lwork.f')) -env.DistutilsPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f'], +env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f'], LINKFLAGSEND = env['F77_LDFLAGS']) #-------------- # Atlas version #-------------- -env.DistutilsPythonExtension('atlas_version', 'atlas_version.c') +env.NumpyPythonExtension('atlas_version', 'atlas_version.c') Modified: trunk/scipy/linalg/SConscript =================================================================== --- trunk/scipy/linalg/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/linalg/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -4,8 +4,6 @@ import os from os.path import join as pjoin, splitext -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import get_python_inc#, get_pythonlib_dir from numscons import GetNumpyEnvironment from numscons import CheckCBLAS, CheckF77BLAS, CheckF77LAPACK,\ CheckCLAPACK, IsVeclib, IsAccelerate, \ @@ -20,10 +18,8 @@ env = GetNumpyEnvironment(ARGUMENTS) env.Tool('f2py') -env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()]) # XXX: handle cblas wrapper for complex (check in numpy.scons or here ?) -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) env.AppendUnique(F2PYOPTIONS = '--quiet') env['BUILDERS']['haha'] = Builder(action = do_generate_interface, @@ -107,7 +103,7 @@ source.append(pjoin('src', 'fblaswrap_veclib_c.c')) else: source.append(pjoin('src', 'fblaswrap.f')) -fenv.DistutilsPythonExtension('fblas', source) +fenv.NumpyPythonExtension('fblas', source) #------------ # cblas @@ -116,7 +112,7 @@ env.haha('cblas', 'generic_cblas.pyf') else: env.hihi('cblas', 'generic_cblas.pyf') -env.DistutilsPythonExtension('cblas', source = 'cblas.pyf') +env.NumpyPythonExtension('cblas', source = 'cblas.pyf') #------------ # flapack @@ -124,7 +120,7 @@ yop = fenv.haha('flapack', 'generic_flapack.pyf') # XXX: automatically scan dependency on flapack_user_routines.pyf ? fenv.Depends(yop, 'flapack_user_routines.pyf') -fenv.DistutilsPythonExtension('flapack', 'flapack.pyf') +fenv.NumpyPythonExtension('flapack', 'flapack.pyf') #------------ # clapack @@ -133,7 +129,7 @@ env.haha('clapack', 'generic_clapack.pyf') else: env.hihi('clapack', 'generic_clapack.pyf') -env.DistutilsPythonExtension('clapack', source = 'clapack.pyf') +env.NumpyPythonExtension('clapack', source = 'clapack.pyf') #---------------- # _flinalg @@ -141,14 +137,14 @@ flinalg_fsrc = [pjoin('src', i) for i in ['det.f', 'lu.f']] flinalg_src = fenv.F2py(pjoin('src', '_flinalgmodule.c'), flinalg_fsrc) -fenv.DistutilsPythonExtension('_flinalg', source = flinalg_src + flinalg_fsrc) +fenv.NumpyPythonExtension('_flinalg', source = flinalg_src + flinalg_fsrc) #---------------- # calc_lwork: #---------------- calc_fsrc = [pjoin('src', 'calc_lwork.f')] calc_src = env.F2py(pjoin('src', 'calc_lworkmodule.c'), calc_fsrc) -fenv.DistutilsPythonExtension('calc_lwork', calc_src + calc_fsrc) +fenv.NumpyPythonExtension('calc_lwork', calc_src + calc_fsrc) #-------------- # Atlas version @@ -156,4 +152,4 @@ atlas_env = env.Clone() if not IsATLAS(env, 'cblas'): atlas_env.AppendUnique(CPPDEFINES = "NO_ATLAS_INFO") -atlas_env.DistutilsPythonExtension('atlas_version', 'atlas_version.c') +atlas_env.NumpyPythonExtension('atlas_version', 'atlas_version.c') Modified: trunk/scipy/ndimage/SConscript =================================================================== --- trunk/scipy/ndimage/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/ndimage/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -1,22 +1,20 @@ # Last Change: Wed Mar 05 09:00 PM 2008 J from os.path import join -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) env.AppendUnique(CPPPATH = 'src') ndimage_src = ["nd_image.c", "ni_filters.c", "ni_fourier.c", "ni_interpolation.c", "ni_measure.c", "ni_morphology.c", "ni_support.c"] -env.DistutilsPythonExtension('_nd_image', source = [join('src', i) for i in ndimage_src]) +env.NumpyPythonExtension('_nd_image', source = [join('src', i) for i in ndimage_src]) segment_src = ['Segmenter_EXT.c', 'Segmenter_IMPL.c'] -env.DistutilsPythonExtension('_segment', source = [join('src', 'segment', i) +env.NumpyPythonExtension('_segment', source = [join('src', 'segment', i) for i in segment_src]) register_src = ['Register_EXT.c', 'Register_IMPL.c'] -env.DistutilsPythonExtension('_register', source = [join('src', 'register', i) +env.NumpyPythonExtension('_register', source = [join('src', 'register', i) for i in register_src]) Modified: trunk/scipy/odr/SConscript =================================================================== --- trunk/scipy/odr/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/odr/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -4,15 +4,12 @@ import os from os.path import join as pjoin, splitext -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import get_python_inc#, get_pythonlib_dir from numscons import GetNumpyEnvironment from numscons import CheckF77BLAS, CheckF77Clib from numscons 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 @@ -58,5 +55,5 @@ env.PrependUnique(LIBPATH = '.') # odr pyextension -env.DistutilsPythonExtension('__odrpack', '__odrpack.c', +env.NumpyPythonExtension('__odrpack', '__odrpack.c', LINKFLAGSEND = env['F77_LDFLAGS']) Modified: trunk/scipy/optimize/SConscript =================================================================== --- trunk/scipy/optimize/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/optimize/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -4,8 +4,6 @@ import os from os.path import join as pjoin, splitext -from numpy.distutils.misc_util import get_numpy_include_dirs -from numscons import get_python_inc#, get_pythonlib_dir from numscons import GetNumpyEnvironment from numscons import CheckF77LAPACK, CheckF77Clib @@ -13,8 +11,7 @@ env = GetNumpyEnvironment(ARGUMENTS) env.Tool('f2py') -env.Append(CPPPATH = get_numpy_include_dirs()) -env.Append(CPPPATH = [env['F2PYINCLUDEDIR'], 'Zeros']) +env.Append(CPPPATH = ['Zeros']) #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 @@ -64,33 +61,33 @@ env.AppendUnique(LIBPATH = '.') # _minpack pyextension -env.DistutilsPythonExtension('_minpack', '_minpackmodule.c', +env.NumpyPythonExtension('_minpack', '_minpackmodule.c', LINKFLAGSEND = env['F77_LDFLAGS']) # _zeros pyextension -env.DistutilsPythonExtension('_zeros', 'zeros.c') +env.NumpyPythonExtension('_zeros', 'zeros.c') # _lbfgsb pyextension src = [pjoin('lbfgsb', i) for i in ['lbfgsb.pyf', 'routines.f']] -env.DistutilsPythonExtension('_lbfgsb', source = src, +env.NumpyPythonExtension('_lbfgsb', source = src, LINKFLAGSEND = env['F77_LDFLAGS']) # _cobyla pyextension src = [pjoin('cobyla', i) for i in ['cobyla2.f', 'trstlp.f', 'cobyla.pyf']] -env.DistutilsPythonExtension('_cobyla', source = src, +env.NumpyPythonExtension('_cobyla', source = src, LINKFLAGSEND = env['F77_LDFLAGS']) # _minpack2 pyextension src = [pjoin('minpack2', i) for i in ['dcsrch.f', 'dcstep.f', 'minpack2.pyf']] -env.DistutilsPythonExtension('minpack2', source = src, +env.NumpyPythonExtension('minpack2', source = src, LINKFLAGSEND = env['F77_LDFLAGS']) # moduleTNC pyextension -env.DistutilsPythonExtension('moduleTNC', +env.NumpyPythonExtension('moduleTNC', source = [pjoin('tnc', i) for i in \ ['moduleTNC.c', 'tnc.c']]) # _slsqp pyextension src = [pjoin('slsqp', i) for i in ['slsqp_optmz.f', 'slsqp.pyf']] -env.DistutilsPythonExtension('_slsqp', source = src, +env.NumpyPythonExtension('_slsqp', source = src, LINKFLAGSEND = env['F77_LDFLAGS']) Modified: trunk/scipy/signal/SConscript =================================================================== --- trunk/scipy/signal/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/signal/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -2,18 +2,16 @@ # vim:syntax=python from os.path import join -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) -env.DistutilsPythonExtension('sigtools', +env.NumpyPythonExtension('sigtools', source = ['sigtoolsmodule.c',\ 'firfilter.c', \ 'medianfilter.c']) -env.DistutilsPythonExtension('spline', +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']) Modified: trunk/scipy/special/SConscript =================================================================== --- trunk/scipy/special/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/special/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -3,9 +3,6 @@ from os.path import join as pjoin, basename as pbasename import sys -from distutils.sysconfig import get_python_inc - -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment from numscons import CheckF77Clib @@ -13,9 +10,6 @@ env.Tool('f2py') -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)) @@ -52,7 +46,7 @@ src = ['_cephesmodule.c', 'amos_wrappers.c', 'specfun_wrappers.c', \ 'toms_wrappers.c','cdf_wrappers.c','ufunc_extras.c'] -env.DistutilsPythonExtension('_cephes', +env.NumpyPythonExtension('_cephes', source = src, LIBS = ['amos', 'toms', 'c_misc', 'cephes', 'mach',\ 'cdf', 'specfunlib'], @@ -60,6 +54,6 @@ # Specfun extension env.Prepend(LIBS = ['specfunlib']) -env.DistutilsPythonExtension('specfun', source = 'specfun.pyf', +env.NumpyPythonExtension('specfun', source = 'specfun.pyf', F2PYOPTIONS = ["--no-wrap-functions"], LINKFLAGSEND = env['F77_LDFLAGS']) Modified: trunk/scipy/stats/SConscript =================================================================== --- trunk/scipy/stats/SConscript 2008-07-08 19:52:27 UTC (rev 4533) +++ trunk/scipy/stats/SConscript 2008-07-09 12:05:31 UTC (rev 4534) @@ -2,16 +2,12 @@ # vim:syntax=python from os.path import join as pjoin -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, CheckF77Clib env = GetNumpyEnvironment(ARGUMENTS) t = env.Tool('f2py') -env.AppendUnique(CPPPATH = [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") @@ -24,16 +20,16 @@ env.AppendUnique(LIBPATH = '.') # Statlib extension -env.DistutilsPythonExtension('statlib', source = 'statlib.pyf', +env.NumpyPythonExtension('statlib', source = 'statlib.pyf', F2PYOPTIONS = ["--no-wrap-functions"], LIBS = 'statlibimp', LINKFLAGSEND = env['F77_LDFLAGS']) # futil extension futil_src = env.F2py(pjoin('futilmodule.c'), pjoin('futil.f')) -env.DistutilsPythonExtension('futil', source = futil_src + ['futil.f'], +env.NumpyPythonExtension('futil', source = futil_src + ['futil.f'], LINKFLAGSEND = env['F77_LDFLAGS']) # mvn extension -env.DistutilsPythonExtension('mvn', source = ['mvn.pyf', 'mvndst.f'], +env.NumpyPythonExtension('mvn', source = ['mvn.pyf', 'mvndst.f'], LINKFLAGSEND = env['F77_LDFLAGS']) From scipy-svn at scipy.org Wed Jul 9 08:34:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 9 Jul 2008 07:34:33 -0500 (CDT) Subject: [Scipy-svn] r4535 - in trunk/scipy: sparse/linalg/dsolve sparse/linalg/dsolve/umfpack sparse/linalg/eigen/arpack sparse/linalg/isolve sparse/sparsetools special Message-ID: <20080709123433.76B9A39C2B8@scipy.org> Author: cdavid Date: 2008-07-09 07:34:18 -0500 (Wed, 09 Jul 2008) New Revision: 4535 Modified: trunk/scipy/sparse/linalg/dsolve/SConscript trunk/scipy/sparse/linalg/dsolve/umfpack/SConscript trunk/scipy/sparse/linalg/eigen/arpack/SConscript trunk/scipy/sparse/linalg/isolve/SConscript trunk/scipy/sparse/sparsetools/SConscript trunk/scipy/special/SConscript Log: Use NumpyPythonExtension builder in sparse. Modified: trunk/scipy/sparse/linalg/dsolve/SConscript =================================================================== --- trunk/scipy/sparse/linalg/dsolve/SConscript 2008-07-09 12:05:31 UTC (rev 4534) +++ trunk/scipy/sparse/linalg/dsolve/SConscript 2008-07-09 12:34:18 UTC (rev 4535) @@ -1,8 +1,6 @@ from os.path import join as pjoin import sys -from numpy.distutils.misc_util import get_numpy_include_dirs - from numscons import GetNumpyEnvironment from numscons import CheckF77LAPACK from numscons import write_info @@ -60,11 +58,11 @@ # Build python extensions pyenv = env.Clone() -pyenv.Append(CPPPATH = [get_numpy_include_dirs(), pjoin('SuperLU', 'SRC')]) +pyenv.Append(CPPPATH = [pjoin('SuperLU', 'SRC')]) pyenv.Prepend(LIBS = superlu) common_src = ['_superlu_utils.c', '_superluobject.c'] for prec in ['z', 'd', 'c', 's']: - pyenv.DistutilsPythonExtension('_%ssuperlu' % prec, + pyenv.NumpyPythonExtension('_%ssuperlu' % prec, source = common_src + \ ['_%ssuperlumodule.c' % prec]) Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/SConscript =================================================================== --- trunk/scipy/sparse/linalg/dsolve/umfpack/SConscript 2008-07-09 12:05:31 UTC (rev 4534) +++ trunk/scipy/sparse/linalg/dsolve/umfpack/SConscript 2008-07-09 12:34:18 UTC (rev 4535) @@ -1,7 +1,5 @@ from os.path import join as pjoin -from numpy.distutils.misc_util import get_numpy_include_dirs - from numscons import GetNumpyEnvironment from numscons import CheckF77BLAS, CheckF77Clib, NumpyCheckLibAndHeader from numscons import write_info @@ -31,5 +29,4 @@ if has_umfpack: env.Append(SWIGFLAGS = '-python') env.Append(SWIGFLAGS = '$_CPPINCFLAGS') - env.Append(CPPPATH = get_numpy_include_dirs()) - env.DistutilsPythonExtension('__umfpack', source = 'umfpack.i') + env.NumpyPythonExtension('__umfpack', source = 'umfpack.i') Modified: trunk/scipy/sparse/linalg/eigen/arpack/SConscript =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-09 12:05:31 UTC (rev 4534) +++ trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-09 12:34:18 UTC (rev 4535) @@ -1,7 +1,5 @@ from os.path import join as pjoin -from numpy.distutils.misc_util import get_numpy_include_dirs - from numscons import GetNumpyEnvironment from numscons import CheckF77LAPACK, CheckF77Clib from numscons import write_info @@ -55,9 +53,6 @@ arpack_lib = env.DistutilsStaticExtLibrary('arpack', source = src) # Build _arpack extension -env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR']) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) - env.FromFTemplate('arpack.pyf', 'arpack.pyf.src') env.Prepend(LIBS = 'arpack') -env.DistutilsPythonExtension('_arpack', 'arpack.pyf') +env.NumpyPythonExtension('_arpack', 'arpack.pyf') Modified: trunk/scipy/sparse/linalg/isolve/SConscript =================================================================== --- trunk/scipy/sparse/linalg/isolve/SConscript 2008-07-09 12:05:31 UTC (rev 4534) +++ trunk/scipy/sparse/linalg/isolve/SConscript 2008-07-09 12:34:18 UTC (rev 4535) @@ -3,7 +3,6 @@ from os.path import join as pjoin, splitext -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment from numscons import CheckF77LAPACK @@ -11,7 +10,6 @@ env = GetNumpyEnvironment(ARGUMENTS) env.Tool('f2py') -env.Append(CPPPATH = [get_numpy_include_dirs(), env['F2PYINCLUDEDIR']]) #if os.name == 'nt': # # NT needs the pythonlib to run any code importing Python.h, including # # simple code using only typedef and so on, so we need it for configuration @@ -55,4 +53,4 @@ res = env.FromFTemplate(target, pjoin('iterative', method)) sources.append(res[0]) -env.DistutilsPythonExtension('_iterative', source = sources) +env.NumpyPythonExtension('_iterative', source = sources) Modified: trunk/scipy/sparse/sparsetools/SConscript =================================================================== --- trunk/scipy/sparse/sparsetools/SConscript 2008-07-09 12:05:31 UTC (rev 4534) +++ trunk/scipy/sparse/sparsetools/SConscript 2008-07-09 12:34:18 UTC (rev 4535) @@ -1,12 +1,9 @@ # Last Change: Wed Mar 05 09:00 PM 2008 J # vim:syntax=python -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.AppendUnique(CPPPATH = get_numpy_include_dirs()) - for fmt in ['csr','csc','coo','bsr','dia']: sources = [ fmt + '_wrap.cxx' ] - env.DistutilsPythonExtension('_%s' % fmt, source = sources) + env.NumpyPythonExtension('_%s' % fmt, source = sources) Modified: trunk/scipy/special/SConscript =================================================================== --- trunk/scipy/special/SConscript 2008-07-09 12:05:31 UTC (rev 4534) +++ trunk/scipy/special/SConscript 2008-07-09 12:34:18 UTC (rev 4535) @@ -20,6 +20,7 @@ raise RuntimeError("Could not get C/F77 runtime information") config.Finish() +env.AppendUnique(CPPPATH = env["PYEXTCPPPATH"]) def build_lib(name, ext, libname = None): """ext should be .f or .c""" if not libname: From scipy-svn at scipy.org Wed Jul 9 08:52:02 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 9 Jul 2008 07:52:02 -0500 (CDT) Subject: [Scipy-svn] r4536 - trunk/scipy/cluster/tests Message-ID: <20080709125202.7993939C260@scipy.org> Author: cdavid Date: 2008-07-09 07:51:55 -0500 (Wed, 09 Jul 2008) New Revision: 4536 Modified: trunk/scipy/cluster/tests/test_vq.py Log: Fix useless message in test. Modified: trunk/scipy/cluster/tests/test_vq.py =================================================================== --- trunk/scipy/cluster/tests/test_vq.py 2008-07-09 12:34:18 UTC (rev 4535) +++ trunk/scipy/cluster/tests/test_vq.py 2008-07-09 12:51:55 UTC (rev 4536) @@ -107,7 +107,7 @@ res = kmeans2(data, initk, missing = 'raise') raise AssertionError("Exception not raised ! Should not happen") except ClusterError, e: - print "exception raised as expected: " + str(e) + pass def test_kmeans2_simple(self): """Testing simple call to kmeans2 and its results.""" From scipy-svn at scipy.org Wed Jul 9 23:32:24 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 9 Jul 2008 22:32:24 -0500 (CDT) Subject: [Scipy-svn] r4537 - in trunk/scipy: integrate interpolate lib/lapack odr optimize special stats Message-ID: <20080710033224.68A0939C153@scipy.org> Author: cdavid Date: 2008-07-09 22:32:10 -0500 (Wed, 09 Jul 2008) New Revision: 4537 Modified: trunk/scipy/integrate/SConscript trunk/scipy/interpolate/SConscript trunk/scipy/lib/lapack/SConscript trunk/scipy/odr/SConscript trunk/scipy/optimize/SConscript trunk/scipy/special/SConscript trunk/scipy/stats/SConscript Log: Remove F77 runtime handling: this is automatically handled by numscons now. Modified: trunk/scipy/integrate/SConscript =================================================================== --- trunk/scipy/integrate/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/integrate/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -9,11 +9,8 @@ env.Tool('f2py') # Configuration -config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib, - 'CheckF77BLAS' : CheckF77BLAS}) +config = env.NumpyConfigure(custom_tests = {'CheckF77BLAS' : CheckF77BLAS}) -if not config.CheckF77Clib(): - raise Exception("Could not check F77 runtime, needed for interpolate") if not config.CheckF77BLAS(): raise Exception("Could not find F77 BLAS, needed for integrate package") @@ -56,7 +53,6 @@ odepack = env.DistutilsStaticExtLibrary('odepack', source = src) env.AppendUnique(LIBPATH = '.') -env.AppendUnique(LINKFLAGSEND = env['F77_LDFLAGS']) quadenv = env.Clone() quadenv.Prepend(LIBS = ['quadpack', 'linpack_lite', 'mach']) Modified: trunk/scipy/interpolate/SConscript =================================================================== --- trunk/scipy/interpolate/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/interpolate/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -12,8 +12,6 @@ raise Exception("Could not check F77 runtime, needed for interpolate") config.Finish() -env.AppendUnique(LINKFLAGSEND = env['F77_LDFLAGS']) - # Build fitpack src = [pjoin("fitpack", s) for s in ["bispev.f", "clocur.f", "cocosp.f", "concon.f", "concur.f", "cualde.f", "curev.f", "curfit.f", "dblint.f", Modified: trunk/scipy/lib/lapack/SConscript =================================================================== --- trunk/scipy/lib/lapack/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/lib/lapack/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -32,10 +32,6 @@ #-------------- # 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") @@ -83,8 +79,7 @@ #---------------- calc_src = env.F2py(pjoin('calc_lworkmodule.c'), source = pjoin('calc_lwork.f')) -env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f'], - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('calc_lwork', source = calc_src + ['calc_lwork.f']) #-------------- # Atlas version Modified: trunk/scipy/odr/SConscript =================================================================== --- trunk/scipy/odr/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/odr/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -19,8 +19,7 @@ #======================= # Starting Configuration #======================= -config = env.NumpyConfigure(custom_tests = {'CheckBLAS' : CheckF77BLAS, - 'CheckF77Clib' : CheckF77Clib}) +config = env.NumpyConfigure(custom_tests = {'CheckBLAS' : CheckF77BLAS}) if not config.CheckF77Clib(): raise RuntimeError("Could not check F/C runtime library for %s/%s, " \ @@ -55,5 +54,4 @@ env.PrependUnique(LIBPATH = '.') # odr pyextension -env.NumpyPythonExtension('__odrpack', '__odrpack.c', - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('__odrpack', '__odrpack.c') Modified: trunk/scipy/optimize/SConscript =================================================================== --- trunk/scipy/optimize/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/optimize/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -21,16 +21,11 @@ #======================= # Starting Configuration #======================= -config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK, - 'CheckF77Clib' : CheckF77Clib}) +config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) #----------------- # 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 @@ -61,26 +56,22 @@ env.AppendUnique(LIBPATH = '.') # _minpack pyextension -env.NumpyPythonExtension('_minpack', '_minpackmodule.c', - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('_minpack', '_minpackmodule.c') # _zeros pyextension env.NumpyPythonExtension('_zeros', 'zeros.c') # _lbfgsb pyextension src = [pjoin('lbfgsb', i) for i in ['lbfgsb.pyf', 'routines.f']] -env.NumpyPythonExtension('_lbfgsb', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('_lbfgsb', source = src) # _cobyla pyextension src = [pjoin('cobyla', i) for i in ['cobyla2.f', 'trstlp.f', 'cobyla.pyf']] -env.NumpyPythonExtension('_cobyla', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('_cobyla', source = src) # _minpack2 pyextension src = [pjoin('minpack2', i) for i in ['dcsrch.f', 'dcstep.f', 'minpack2.pyf']] -env.NumpyPythonExtension('minpack2', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('minpack2', source = src) # moduleTNC pyextension env.NumpyPythonExtension('moduleTNC', @@ -89,5 +80,4 @@ # _slsqp pyextension src = [pjoin('slsqp', i) for i in ['slsqp_optmz.f', 'slsqp.pyf']] -env.NumpyPythonExtension('_slsqp', source = src, - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('_slsqp', source = src) Modified: trunk/scipy/special/SConscript =================================================================== --- trunk/scipy/special/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/special/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -50,11 +50,9 @@ env.NumpyPythonExtension('_cephes', source = src, LIBS = ['amos', 'toms', 'c_misc', 'cephes', 'mach',\ - 'cdf', 'specfunlib'], - LINKFLAGSEND = env['F77_LDFLAGS']) + 'cdf', 'specfunlib']) # Specfun extension env.Prepend(LIBS = ['specfunlib']) env.NumpyPythonExtension('specfun', source = 'specfun.pyf', - F2PYOPTIONS = ["--no-wrap-functions"], - LINKFLAGSEND = env['F77_LDFLAGS']) + F2PYOPTIONS = ["--no-wrap-functions"]) Modified: trunk/scipy/stats/SConscript =================================================================== --- trunk/scipy/stats/SConscript 2008-07-09 12:51:55 UTC (rev 4536) +++ trunk/scipy/stats/SConscript 2008-07-10 03:32:10 UTC (rev 4537) @@ -22,14 +22,11 @@ # Statlib extension env.NumpyPythonExtension('statlib', source = 'statlib.pyf', F2PYOPTIONS = ["--no-wrap-functions"], - LIBS = 'statlibimp', - LINKFLAGSEND = env['F77_LDFLAGS']) + LIBS = 'statlibimp') # futil extension futil_src = env.F2py(pjoin('futilmodule.c'), pjoin('futil.f')) -env.NumpyPythonExtension('futil', source = futil_src + ['futil.f'], - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('futil', source = futil_src + ['futil.f']) # mvn extension -env.NumpyPythonExtension('mvn', source = ['mvn.pyf', 'mvndst.f'], - LINKFLAGSEND = env['F77_LDFLAGS']) +env.NumpyPythonExtension('mvn', source = ['mvn.pyf', 'mvndst.f']) From scipy-svn at scipy.org Thu Jul 10 19:29:26 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 10 Jul 2008 18:29:26 -0500 (CDT) Subject: [Scipy-svn] r4538 - in branches: . interpolate2 Message-ID: <20080710232926.8468F39C144@scipy.org> Author: fcady Date: 2008-07-10 18:29:12 -0500 (Thu, 10 Jul 2008) New Revision: 4538 Added: branches/interpolate2/ branches/interpolate2/Interpolate1D.py branches/interpolate2/_interpolate.pyd branches/interpolate2/interpolate_helper.py Log: added rudimentary but working new interpolation module Added: branches/interpolate2/Interpolate1D.py =================================================================== --- branches/interpolate2/Interpolate1D.py 2008-07-10 03:32:10 UTC (rev 4537) +++ branches/interpolate2/Interpolate1D.py 2008-07-10 23:29:12 UTC (rev 4538) @@ -0,0 +1,100 @@ +""" A module for intepolation +""" + +#from enthought.interpolate import DataFit, Linear, Block +from interpolate_helper import block, linear, block, Linear, Block, logarithmic +from numpy import array, arange, empty, float64 + + + + +class Interpolate1D(object): + """ Class for interpolation and extrapolation of functions + from 1D data. + + Parameters + ---------- + x : array_like + x values to interpolate from. Pass in as NumPy array + or Python list. + y : array_like + y values to interpolate from. Pass in as NumPy array + or Python list.x and y must be the same length. + kind : optional + low : optional + high : optional + + + Example + ------- + # fixme: This should also demonstrate extrapolation. + + >>> from numpy import arange, array + >>> a = arange(10.) + >>> b = arange(10.) * 2.0 + >>> new_a = array([1.0, 2.5, 8.0, 1.0, -1, 12]) + >>> interp = Interpolate1D(a, b) + >>> interp(new_a) + array([ 2., 5., 16., 2., 0., 18.]) + + """ + + def __init__(self, x, y, kind='Linear', low='Block', high='Block'): + """ Class constructor + + x : array-like + + """ + + # fixme: Handle checking if they are the correct size. + self._x = array(x) + self._y = array(y) + + self.kind = self._init_interp_method(x, y, kind) + self.low = self._init_interp_method(x, y, low) + self.high = self._init_interp_method(x, y, high) + + def _init_interp_method(self, x, y, kind): + from inspect import isclass, isfunction + + if isinstance(kind, str): + try: + exec('from interpolate_helper import %s; kind = %s' % (kind, kind) ) + except: + raise + + if isclass(kind): + result = kind(x, y) + elif isfunction(kind): + result = kind + else: + print 'WTF??' + raise + return result + + + def __call__(self, x): + low_mask = xself._x[-1] + interp_mask = (~low_mask) & (~high_mask) + + new_interp = self.kind(x[interp_mask]) + new_low = self.low(x[low_mask]) + new_high = self.high(x[high_mask]) + + # fixme: Handle other data types. + result = empty(x.shape, dtype=float64) + result[low_mask] = new_low + result[high_mask] = new_high + result[interp_mask] = new_interp + + return result + +if __name__ == '__main__': + a = arange(10.) + b = 2*a + c = array([-1, 4.5, 19]) + interp = Interpolate1D(a, b, kind=lambda x: linear(a,b,x), \ + low='Block', high=lambda x: block(a,b,x) ) + print 'c equals: ', c + print 'interp(c) equals: ', interp(c) \ No newline at end of file Added: branches/interpolate2/_interpolate.pyd =================================================================== (Binary files differ) Property changes on: branches/interpolate2/_interpolate.pyd ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/interpolate2/interpolate_helper.py =================================================================== --- branches/interpolate2/interpolate_helper.py 2008-07-10 03:32:10 UTC (rev 4537) +++ branches/interpolate2/interpolate_helper.py 2008-07-10 23:29:12 UTC (rev 4538) @@ -0,0 +1,156 @@ +""" helper_funcs.py +""" + +import numpy +import _interpolate +print "this is the module" + +def make_array_safe(ary, typecode): + ary = numpy.atleast_1d(numpy.asarray(ary, typecode)) + if not ary.flags['CONTIGUOUS']: + ary = ary.copy() + return ary + + +class Block(): + """ Used when only one element is available in the log. + """ + def __init__(self, x, y): + self._x = x + self._y = y + + def __call__(self, new_x): + # find index of values in x that preceed values in x + # This code is a little strange -- we really want a routine that + # returns the index of values where x[j] < x[index] + TINY = 1e-10 + indices = numpy.searchsorted(new_x, new_x+TINY)-1 + + # If the value is at the front of the list, it'll have -1. + # In this case, we will use the first (0), element in the array. + # take requires the index array to be an Int + indices = numpy.atleast_1d(numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)) + result = numpy.take(self._y, indices, axis=-1) + return result + +class Linear(): + """ Linearly interpolates values in new_x based on the values in x and y + + Parameters + ---------- + x + 1-D array + y + 1-D or 2-D array + new_x + 1-D array + """ + def __init__(self, x, y): + self._x = make_array_safe(x, numpy.float64) + self._y = make_array_safe(y, numpy.float64) + + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + + def __call__(self, new_x): + new_x = make_array_safe(new_x, numpy.float64) + if len(self._y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.linear_dddd(x, y, new_x, new_y) + return new_y + +def block(x, y, new_x): + """ Used when only one element is available in the log. + """ + + # find index of values in x that preceed values in x + # This code is a little strange -- we really want a routine that + # returns the index of values where x[j] < x[index] + TINY = 1e-10 + indices = numpy.searchsorted(new_x, new_x+TINY)-1 + + # If the value is at the front of the list, it'll have -1. + # In this case, we will use the first (0), element in the array. + # take requires the index array to be an Int + indices = numpy.atleast_1d(numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)) + result = numpy.take(y, indices, axis=-1) + return result + +def linear(x, y, new_x): + """ Linearly interpolates values in new_x based on the values in x and y + + Parameters + ---------- + x + 1-D array + y + 1-D or 2-D array + new_x + 1-D array + """ + x = make_array_safe(x, numpy.float64) + y = make_array_safe(y, numpy.float64) + new_x = make_array_safe(new_x, numpy.float64) + + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.linear_dddd(x, y, new_x, new_y) + + return new_y + +class Logarithmic: + """ For log-linear interpolation + """ + + def __init__(self, x, y): + self._x = make_array_safe(x, numpy.float64) + self._y = make_array_safe(y, numpy.float64) + + def __call__(new_x): + new_x = make_array_safe(new_x, numpy.float64) + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.loginterp_dddd(x, y, new_x, new_y) + + return new_y + +def logarithmic(x, y, new_x): + """ Linearly interpolates values in new_x based in the log space of y. + + Parameters + ---------- + x + 1-D array + y + 1-D or 2-D array + new_x + 1-D array + """ + x = make_array_safe(x, numpy.float64) + y = make_array_safe(y, numpy.float64) + new_x = make_array_safe(new_x, numpy.float64) + + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.loginterp_dddd(x, y, new_x, new_y) + + return new_y + From scipy-svn at scipy.org Fri Jul 11 04:08:29 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 11 Jul 2008 03:08:29 -0500 (CDT) Subject: [Scipy-svn] r4539 - trunk/scipy/odr Message-ID: <20080711080829.EA12339C94C@scipy.org> Author: cdavid Date: 2008-07-11 03:08:24 -0500 (Fri, 11 Jul 2008) New Revision: 4539 Modified: trunk/scipy/odr/SConscript Log: Fix config for scons build of odr. Modified: trunk/scipy/odr/SConscript =================================================================== --- trunk/scipy/odr/SConscript 2008-07-10 23:29:12 UTC (rev 4538) +++ trunk/scipy/odr/SConscript 2008-07-11 08:08:24 UTC (rev 4539) @@ -21,7 +21,7 @@ #======================= config = env.NumpyConfigure(custom_tests = {'CheckBLAS' : CheckF77BLAS}) -if not config.CheckF77Clib(): +if not config.CheckBLAS(): raise RuntimeError("Could not check F/C runtime library for %s/%s, " \ "contact the maintainer" % (env['CC'], env['F77'])) From scipy-svn at scipy.org Sun Jul 13 23:53:30 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 13 Jul 2008 22:53:30 -0500 (CDT) Subject: [Scipy-svn] r4540 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080714035330.BD99B39C654@scipy.org> Author: ilan Date: 2008-07-13 22:53:29 -0500 (Sun, 13 Jul 2008) New Revision: 4540 Added: trunk/scipy/sandbox/mkufunc/examples/mandel-c.py trunk/scipy/sandbox/mkufunc/examples/mandel-py.py Removed: trunk/scipy/sandbox/mkufunc/examples/mandel.py Log: Added example Added: trunk/scipy/sandbox/mkufunc/examples/mandel-c.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel-c.py 2008-07-11 08:08:24 UTC (rev 4539) +++ trunk/scipy/sandbox/mkufunc/examples/mandel-c.py 2008-07-14 03:53:29 UTC (rev 4540) @@ -0,0 +1,88 @@ +#!/usr/bin/env python +""" +>>> mandel(-1, .3) +36 +>>> mandel(0, 0) +-1 +>>> mandel(10, 10) +1 +>>> mandel(array([-1, 0, 10]), array([.3, 0, 10])) +array([36, -1, 1]) +""" +import hashlib + +from numpy import array +from scipy import weave + +support_code = ''' +#define D 1000 + +long iterations(double cr, double ci) +{ + long d = 1; + double zr=cr, zi=ci, zr2, zi2; + for(;;) { + zr2 = zr * zr; + zi2 = zi * zi; + if( zr2+zi2 > 16.0 ) return d; + if( ++d == D ) return -1; + zi = 2.0 * zr * zi + ci; + zr = zr2 - zi2 + cr; + } +} + +static void +PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) +{ + npy_intp i, n; + npy_intp is0 = steps[0]; + npy_intp is1 = steps[1]; + npy_intp os = steps[2]; + char *ip0 = args[0]; + char *ip1 = args[1]; + char *op = args[2]; + n = dimensions[0]; + + for(i = 0; i < n; i++) { + *(long *)op = iterations(*(double *)ip0, + *(double *)ip1); + ip0 += is0; + ip1 += is1; + op += os; + } +} + +static PyUFuncGenericFunction f_functions[] = { + PyUFunc_0, +}; + +static char f_types[] = { + NPY_DOUBLE, NPY_DOUBLE, NPY_LONG, +}; +''' +ufunc_info = weave.base_info.custom_info() +ufunc_info.add_header('"numpy/ufuncobject.h"') + +mandel = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/ +import_ufunc(); + +return_val = PyUFunc_FromFuncAndData( + f_functions, + NULL, + f_types, + 1, /* ntypes */ + 2, /* nin */ + 1, /* nout */ + PyUFunc_None, /* identity */ + "mandel", /* name */ + "returns number of iterations from cr, ci", /* doc */ + 0); + ''', + support_code=support_code, + verbose=0, + customize=ufunc_info) + + +if __name__ == '__main__': + import doctest + doctest.testmod() Property changes on: trunk/scipy/sandbox/mkufunc/examples/mandel-c.py ___________________________________________________________________ Name: svn:executable + * Added: trunk/scipy/sandbox/mkufunc/examples/mandel-py.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel-py.py 2008-07-11 08:08:24 UTC (rev 4539) +++ trunk/scipy/sandbox/mkufunc/examples/mandel-py.py 2008-07-14 03:53:29 UTC (rev 4540) @@ -0,0 +1,37 @@ +#!/usr/bin/env python +""" +>>> mandel(-1, .3) +36 +>>> mandel(0, 0) +-1 +>>> mandel(10, 10) +1 +>>> mandel(array([-1, 0, 10]), array([.3, 0, 10])) +array([36, -1, 1]) +""" +from numpy import array +from mkufunc.api import mkufunc + +D = 1000 + + + at mkufunc([(float, float, int)]) +def mandel(cr, ci): + d = 1 + zr = cr + zi = ci + for d in xrange(1, D): + zr2 = zr * zr + zi2 = zi * zi + if zr2 + zi2 > 16: + return d + zi = 2.0 * zr * zi + ci + zr = zr2 - zi2 + cr + else: + return -1 + + + +if __name__ == '__main__': + import doctest + doctest.testmod() Property changes on: trunk/scipy/sandbox/mkufunc/examples/mandel-py.py ___________________________________________________________________ Name: svn:executable + * Deleted: trunk/scipy/sandbox/mkufunc/examples/mandel.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel.py 2008-07-11 08:08:24 UTC (rev 4539) +++ trunk/scipy/sandbox/mkufunc/examples/mandel.py 2008-07-14 03:53:29 UTC (rev 4540) @@ -1,88 +0,0 @@ -#!/usr/bin/env python -""" ->>> mandel(-1, .3) -36 ->>> mandel(0, 0) --1 ->>> mandel(10, 10) -1 ->>> mandel(array([-1, 0, 10]), array([.3, 0, 10])) -array([36, -1, 1]) -""" -import hashlib - -from numpy import array -from scipy import weave - -support_code = ''' -#define D 1000 - -long iterations(double cr, double ci) -{ - long d = 1; - double zr=cr, zi=ci, zr2, zi2; - for(;;) { - zr2 = zr * zr; - zi2 = zi * zi; - if( zr2+zi2 > 16.0 ) return d; - if( ++d == D ) return -1; - zi = 2.0 * zr * zi + ci; - zr = zr2 - zi2 + cr; - } -} - -static void -PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) -{ - npy_intp i, n; - npy_intp is0 = steps[0]; - npy_intp is1 = steps[1]; - npy_intp os = steps[2]; - char *ip0 = args[0]; - char *ip1 = args[1]; - char *op = args[2]; - n = dimensions[0]; - - for(i = 0; i < n; i++) { - *(long *)op = iterations(*(double *)ip0, - *(double *)ip1); - ip0 += is0; - ip1 += is1; - op += os; - } -} - -static PyUFuncGenericFunction f_functions[] = { - PyUFunc_0, -}; - -static char f_types[] = { - NPY_DOUBLE, NPY_DOUBLE, NPY_LONG, -}; -''' -ufunc_info = weave.base_info.custom_info() -ufunc_info.add_header('"numpy/ufuncobject.h"') - -mandel = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/ -import_ufunc(); - -return_val = PyUFunc_FromFuncAndData( - f_functions, - NULL, - f_types, - 1, /* ntypes */ - 2, /* nin */ - 1, /* nout */ - PyUFunc_None, /* identity */ - "mandel", /* name */ - "returns number of iterations from cr, ci", /* doc */ - 0); - ''', - support_code=support_code, - verbose=0, - customize=ufunc_info) - - -if __name__ == '__main__': - import doctest - doctest.testmod() From scipy-svn at scipy.org Mon Jul 14 00:14:10 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 13 Jul 2008 23:14:10 -0500 (CDT) Subject: [Scipy-svn] r4541 - trunk/scipy/sandbox/mkufunc Message-ID: <20080714041410.B829139C654@scipy.org> Author: ilan Date: 2008-07-13 23:14:10 -0500 (Sun, 13 Jul 2008) New Revision: 4541 Removed: trunk/scipy/sandbox/mkufunc/docs/ Modified: trunk/scipy/sandbox/mkufunc/README.txt trunk/scipy/sandbox/mkufunc/TODO.txt Log: Small changes Modified: trunk/scipy/sandbox/mkufunc/README.txt =================================================================== --- trunk/scipy/sandbox/mkufunc/README.txt 2008-07-14 03:53:29 UTC (rev 4540) +++ trunk/scipy/sandbox/mkufunc/README.txt 2008-07-14 04:14:10 UTC (rev 4541) @@ -15,5 +15,5 @@ You need the pypy path in your PYTHONPATH environment: -$ export PYTHONPATH=/giant/src/pypy-dist +$ export PYTHONPATH=/<...>/pypy-dist Modified: trunk/scipy/sandbox/mkufunc/TODO.txt =================================================================== --- trunk/scipy/sandbox/mkufunc/TODO.txt 2008-07-14 03:53:29 UTC (rev 4540) +++ trunk/scipy/sandbox/mkufunc/TODO.txt 2008-07-14 04:14:10 UTC (rev 4541) @@ -1,6 +1,9 @@ -- add Csrc attribute to ufunc object +- Documentation -- Mandelbrot +- improve caching of pypy compiler output +- think about shipping issues (using weave ext_tools) +- add Csrc attribute to ufunc object + From scipy-svn at scipy.org Mon Jul 14 10:28:52 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 14 Jul 2008 09:28:52 -0500 (CDT) Subject: [Scipy-svn] r4542 - branches/interpolate2 Message-ID: <20080714142852.68E0F39C9BD@scipy.org> Author: fcady Date: 2008-07-14 09:28:50 -0500 (Mon, 14 Jul 2008) New Revision: 4542 Added: branches/interpolate2/journal.txt Modified: branches/interpolate2/Interpolate1D.py branches/interpolate2/interpolate_helper.py Log: commiting so that I can access from office computer Modified: branches/interpolate2/Interpolate1D.py =================================================================== --- branches/interpolate2/Interpolate1D.py 2008-07-14 04:14:10 UTC (rev 4541) +++ branches/interpolate2/Interpolate1D.py 2008-07-14 14:28:50 UTC (rev 4542) @@ -2,7 +2,8 @@ """ #from enthought.interpolate import DataFit, Linear, Block -from interpolate_helper import block, linear, block, Linear, Block, logarithmic +from interpolate_helper import * #block, linear, block, Linear, \ + #Block, logarithmic, Block_Average_Above, Window_Average from numpy import array, arange, empty, float64 @@ -50,25 +51,25 @@ self._x = array(x) self._y = array(y) - self.kind = self._init_interp_method(x, y, kind) - self.low = self._init_interp_method(x, y, low) - self.high = self._init_interp_method(x, y, high) + self.kind = self._init_interp_method(self._x, self._y, kind) + self.low = self._init_interp_method(self._x, self._y, low) + self.high = self._init_interp_method(self._x, self._y, high) def _init_interp_method(self, x, y, kind): from inspect import isclass, isfunction if isinstance(kind, str): try: - exec('from interpolate_helper import %s; kind = %s' % (kind, kind) ) + #fixme: import the object + exec('dummy_var = %s' % kind) except: - raise + raise "Could not import indicated class or function" if isclass(kind): result = kind(x, y) elif isfunction(kind): result = kind else: - print 'WTF??' raise return result @@ -89,12 +90,19 @@ result[interp_mask] = new_interp return result + + def __clone__(self): + # fixme: objects are currently double-referenced. Make them copied over. + clone_x = self._x.clone() + clone_y = self._y.clone() + return Interpolate1D(self._x, self._y, low=self.low, kind=self.kind, high=self.high) if __name__ == '__main__': + print "hey world" a = arange(10.) b = 2*a c = array([-1, 4.5, 19]) - interp = Interpolate1D(a, b, kind=lambda x: linear(a,b,x), \ - low='Block', high=lambda x: block(a,b,x) ) + interp = Interpolate1D(a, b, low = 'Block', \ + kind='Window_Average', high=lambda x: block(a,b,x) ) print 'c equals: ', c print 'interp(c) equals: ', interp(c) \ No newline at end of file Modified: branches/interpolate2/interpolate_helper.py =================================================================== --- branches/interpolate2/interpolate_helper.py 2008-07-14 04:14:10 UTC (rev 4541) +++ branches/interpolate2/interpolate_helper.py 2008-07-14 14:28:50 UTC (rev 4542) @@ -3,7 +3,6 @@ import numpy import _interpolate -print "this is the module" def make_array_safe(ary, typecode): ary = numpy.atleast_1d(numpy.asarray(ary, typecode)) @@ -12,28 +11,7 @@ return ary -class Block(): - """ Used when only one element is available in the log. - """ - def __init__(self, x, y): - self._x = x - self._y = y - - def __call__(self, new_x): - # find index of values in x that preceed values in x - # This code is a little strange -- we really want a routine that - # returns the index of values where x[j] < x[index] - TINY = 1e-10 - indices = numpy.searchsorted(new_x, new_x+TINY)-1 - - # If the value is at the front of the list, it'll have -1. - # In this case, we will use the first (0), element in the array. - # take requires the index array to be an Int - indices = numpy.atleast_1d(numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)) - result = numpy.take(self._y, indices, axis=-1) - return result - -class Linear(): +def linear(x, y, new_x): """ Linearly interpolates values in new_x based on the values in x and y Parameters @@ -45,42 +23,23 @@ new_x 1-D array """ - def __init__(self, x, y): - self._x = make_array_safe(x, numpy.float64) - self._y = make_array_safe(y, numpy.float64) + x = make_array_safe(x, numpy.float64) + y = make_array_safe(y, numpy.float64) + new_x = make_array_safe(new_x, numpy.float64) - assert len(y.shape) < 3, "function only works with 1D or 2D arrays" - - def __call__(self, new_x): - new_x = make_array_safe(new_x, numpy.float64) - if len(self._y.shape) == 2: - new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) - for i in range(len(new_y)): - _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) - else: - new_y = numpy.zeros(len(new_x), numpy.float64) - _interpolate.linear_dddd(x, y, new_x, new_y) - return new_y + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.linear_dddd(x, y, new_x, new_y) -def block(x, y, new_x): - """ Used when only one element is available in the log. - """ + return new_y - # find index of values in x that preceed values in x - # This code is a little strange -- we really want a routine that - # returns the index of values where x[j] < x[index] - TINY = 1e-10 - indices = numpy.searchsorted(new_x, new_x+TINY)-1 - - # If the value is at the front of the list, it'll have -1. - # In this case, we will use the first (0), element in the array. - # take requires the index array to be an Int - indices = numpy.atleast_1d(numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)) - result = numpy.take(y, indices, axis=-1) - return result - -def linear(x, y, new_x): - """ Linearly interpolates values in new_x based on the values in x and y +def logarithmic(x, y, new_x): + """ Linearly interpolates values in new_x based in the log space of y. Parameters ---------- @@ -99,37 +58,16 @@ if len(y.shape) == 2: new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) for i in range(len(new_y)): - _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) + _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) else: new_y = numpy.zeros(len(new_x), numpy.float64) - _interpolate.linear_dddd(x, y, new_x, new_y) + _interpolate.loginterp_dddd(x, y, new_x, new_y) return new_y - -class Logarithmic: - """ For log-linear interpolation - """ - def __init__(self, x, y): - self._x = make_array_safe(x, numpy.float64) - self._y = make_array_safe(y, numpy.float64) - - def __call__(new_x): - new_x = make_array_safe(new_x, numpy.float64) - assert len(y.shape) < 3, "function only works with 1D or 2D arrays" - if len(y.shape) == 2: - new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) - for i in range(len(new_y)): - _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) - else: - new_y = numpy.zeros(len(new_x), numpy.float64) - _interpolate.loginterp_dddd(x, y, new_x, new_y) +def block_average_above(x, y, new_x): + """ Linearly interpolates values in new_x based on the values in x and y - return new_y - -def logarithmic(x, y, new_x): - """ Linearly interpolates values in new_x based in the log space of y. - Parameters ---------- x @@ -139,6 +77,7 @@ new_x 1-D array """ + bad_index = None x = make_array_safe(x, numpy.float64) y = make_array_safe(y, numpy.float64) new_x = make_array_safe(new_x, numpy.float64) @@ -147,10 +86,93 @@ if len(y.shape) == 2: new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) for i in range(len(new_y)): - _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) + bad_index = _interpolate.block_averave_above_dddd(x, y[i], + new_x, new_y[i]) + if bad_index is not None: + break else: new_y = numpy.zeros(len(new_x), numpy.float64) - _interpolate.loginterp_dddd(x, y, new_x, new_y) + bad_index = _interpolate.block_average_above_dddd(x, y, new_x, new_y) + if bad_index is not None: + msg = "block_average_above cannot extrapolate and new_x[%d]=%f "\ + "is out of the x range (%f, %f)" % \ + (bad_index, new_x[bad_index], x[0], x[-1]) + raise ValueError, msg + return new_y + + + + +def test_helper(): + """ use numpy.allclose to test + """ + print "now testing accuracy of interpolation of linear data" + + x = numpy.arange(10.) + y = 2.0*x + c = numpy.array([-1.0, 2.3, 10.5]) + + assert numpy.allclose( linear(x, y, c) , [-2.0, 4.6, 21.0] ), "problem in linear" + assert numpy.allclose( logarithmic(x, y, c) , [0. , 4.51738774 , 21.47836848] ), \ + "problem with logarithmic" + assert numpy.allclose( block_average_above(x, y, c) , [0., 2., 4.] ), \ + "problem with block_average_above" + +def compare_runtimes(): + from scipy import arange, ones + import time + + # basic linear interp + N = 3000. + x = arange(N) + y = arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = linear(x, y, new_x) + t2 = time.clock() + print '1d interp (sec):', t2 - t1 + print new_y[:5] + + # basic block_average_above + N = 3000. + x = arange(N) + y = arange(N) + new_x = arange(N/2)*2 + t1 = time.clock() + new_y = block_average_above(x, y, new_x) + t2 = time.clock() + print '1d block_average_above (sec):', t2 - t1 + print new_y[:5] + + # y linear with y having multiple params + N = 3000. + x = arange(N) + y = ones((100,N)) * arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = linear(x, y, new_x) + t2 = time.clock() + print 'fast interpolate (sec):', t2 - t1 + print new_y[:5,:5] + + # scipy with multiple params + import scipy + N = 3000. + x = arange(N) + y = ones((100, N)) * arange(N) + new_x = arange(N) + t1 = time.clock() + interp = scipy.interpolate.interp1d(x, y) + new_y = interp(new_x) + t2 = time.clock() + print 'scipy interp1d (sec):', t2 - t1 + print new_y[:5,:5] + +if __name__ == '__main__': + compare_runtimes() + test_helper() + +# Below is stuff from scipy.interpolate and fitpack \ No newline at end of file Added: branches/interpolate2/journal.txt =================================================================== --- branches/interpolate2/journal.txt 2008-07-14 04:14:10 UTC (rev 4541) +++ branches/interpolate2/journal.txt 2008-07-14 14:28:50 UTC (rev 4542) @@ -0,0 +1,83 @@ +# Log in making a new Interpolate module + +# The goal +The current interpolation software is wanting. My goal is to create a module to +replace scipy.interpolate. Currently functionality is mostly in scipy.interpolate +and enthought.interpolate. A few other functions are also in NDImage and +signalprocessing. + +First off, I just want to have a good 1D interpolation callable class, along +with a straight-up function. It should have functionality for linear, logarithmic, +block and spline interpolation. There should also be extrapolation high and low. + +# starting off +The core function was derived from the skeleton written by Eric Jones while we +were talking. It was basically a callable class with __init__ and __call__ methods. +__init__ would set x and y, and also decide which method (linear, block, etc) to +use. + +I started off scavenging the enthought.interpolate.py functions. I turned the +functions into other callable classes, and created functions which are wrappers +around the classes. The Interpolate1D.__init__ method should call a subroutine +which will appropriately deal with the interpolation argument. It could be a class, +a function, or a string. The string was difficult, as I included an instruction to +import the named class/function. But this caused a namespace problem, as iPython +wouldn''t re-import it after editing and calling Interpolate1D again. + +# stuff incorporated +Now I've incorporatd the functionality form interpolate.py as callable classes. +I have several directions to go. +1) create tests for all of the functionality incorporated so far. This would be boring + but good practice and really must be done. +2) add handlers for NaN and non-standard data types. This also must be done. + In particular, there's lists, arrays, and naked atomic types (ints, floats, etc). + I think everything should be cast to a numpy array. But should it be a numpy + array of float64? +3) incorporate the functionality of fitting.py. This uses splines and calls + scipy.interpolate. It also uses traits, which is taboo. I should really revamp + the whole thing; it should directly call the fortran subroutines, rather than calling + them through scipy.interpolate. Thus, I should really be scavenging scipy but + putting a good face on it. + +There's a question of whether interpolate_helper should include all of these functions +or should be split into a couple modules. At least preliminarily, I think several modules +is a good thing because it makes testing easier. + +But for the time being, I'll write a test function for the stuff currently in +interpolate_helper. + +# July 12 2:18 PM +the block function is strange; wrong, it appears. The answers depend on other +elements in the argument array. Block doesn't call C code, so it's more suspect. +Perhaps I just don't understand the function +well enough. Linear works erfectly, logarithmic seems good too, though it's zero +for negative values. block_average above looks good. +Window_width has a problem with the C call. So window_width and block need +more thought. + +Block shows same problem in mine and enthought.interpolate, but the non-function +thing of block_avg_above is unique to me. + +Window_Average has a low-level bug. I'm scrapping it for now, since it's rarely used +anyway. Block comes not from interpolate, but from fitting. Thus I've gotten all +interpolate.py functionality included. Yay. + + +# July 12 5 PM +moving on to fitting.py. It has a parent DataFit class whose children call functions in interpolate.py. +That makes for more pure-function stuff, thanks to interpolate.py. This has objects +wrapped around funcs, whereas I have funcs wrapped around objects. Objects around +funcs has less overhead (I think) and is more pure-functional, so I'll redo things to +follow that. + +Redoing it amounts to copying interpolate.py over everything I've done. Damn it. +But the main function 1) needs assert statement, and 2) needlessly defines x +and y a lot (though that makes one per function) + + +# July 14 +Looking at DataFit in fitting.py I'm debating how to replicate it. In +particular, I don't need set_xy and such. However, those functions +allow for more flexibility in future code (setting may be more complicated +for some descendent class) so they're good. However, I'm preliminarily +making that function private; x and y must be initialized. \ No newline at end of file From scipy-svn at scipy.org Mon Jul 14 17:33:04 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 14 Jul 2008 16:33:04 -0500 (CDT) Subject: [Scipy-svn] r4543 - trunk Message-ID: <20080714213304.85F1639C343@scipy.org> Author: rkern Date: 2008-07-14 16:33:03 -0500 (Mon, 14 Jul 2008) New Revision: 4543 Modified: trunk/INSTALL.txt Log: BUG: fix URL. Modified: trunk/INSTALL.txt =================================================================== --- trunk/INSTALL.txt 2008-07-14 14:28:50 UTC (rev 4542) +++ trunk/INSTALL.txt 2008-07-14 21:33:03 UTC (rev 4543) @@ -159,7 +159,7 @@ source directories). More details of how to do this are on the SciPy Wiki, at: - http://new.scipy.org/Wiki/Installing_SciPy/BuildingGeneral + http://www.scipy.org/Installing_SciPy/BuildingGeneral 3) Users of Debian (and derivatives like Ubuntu) can use the following deb packages:: From scipy-svn at scipy.org Tue Jul 15 08:22:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 15 Jul 2008 07:22:41 -0500 (CDT) Subject: [Scipy-svn] r4544 - in trunk/scipy/sparse: . tests Message-ID: <20080715122241.D0E5B39C646@scipy.org> Author: wnbell Date: 2008-07-15 07:22:24 -0500 (Tue, 15 Jul 2008) New Revision: 4544 Added: trunk/scipy/sparse/extract.py trunk/scipy/sparse/tests/test_extract.py Modified: trunk/scipy/sparse/__init__.py trunk/scipy/sparse/base.py trunk/scipy/sparse/construct.py trunk/scipy/sparse/tests/test_base.py trunk/scipy/sparse/tests/test_construct.py Log: added tril and triu to scipy.sparse Modified: trunk/scipy/sparse/__init__.py =================================================================== --- trunk/scipy/sparse/__init__.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -12,6 +12,8 @@ from bsr import * from construct import * +from extract import * + #from spfuncs import * __all__ = filter(lambda s:not s.startswith('_'),dir()) Modified: trunk/scipy/sparse/base.py =================================================================== --- trunk/scipy/sparse/base.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/base.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -485,6 +485,9 @@ # else: # return other.matmat(self.transpose()) + #def __array__(self): + # return self.toarray() + def todense(self): return asmatrix(self.toarray()) Modified: trunk/scipy/sparse/construct.py =================================================================== --- trunk/scipy/sparse/construct.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/construct.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -7,11 +7,10 @@ 'hstack', 'vstack', 'bmat' ] -from itertools import izip from warnings import warn import numpy -from numpy import ones, clip, array, arange, intc, asarray, rank, zeros, \ +from numpy import ones, arange, intc, asarray, rank, zeros, \ cumsum, concatenate, empty from sputils import upcast @@ -49,7 +48,6 @@ Example ------- - >>> data = array([[1,2,3,4],[1,2,3,4],[1,2,3,4]]) >>> diags = array([0,-1,2]) >>> spdiags(data, diags, 4, 4).todense() @@ -62,7 +60,32 @@ return dia_matrix((data, diags), shape=(m,n)).asformat(format) def identity(n, dtype='d', format=None): - """identity(n) returns a sparse (n x n) identity matrix""" + """Identity matrix in sparse format + + Returns an identity matrix with shape (n,n) using a given + sparse format and dtype. + + Parameters + ---------- + n : integer + Shape of the identity matrix. + dtype : + Data type of the matrix + format : string + Sparse format of the result, e.g. format="csr", etc. + + Examples + -------- + >>> identity(3).todense() + matrix([[ 1., 0., 0.], + [ 0., 1., 0.], + [ 0., 0., 1.]]) + >>> identity(3, dtype='int8', format='dia') + <3x3 sparse matrix of type '' + with 3 stored elements (1 diagonals) in DIAgonal format> + + """ + if format in ['csr','csc']: indptr = arange(n+1, dtype=intc) indices = arange(n, dtype=intc) @@ -74,6 +97,10 @@ col = arange(n, dtype=intc) data = ones(n, dtype=dtype) return coo_matrix((data,(row,col)),(n,n)) + elif format == 'dia': + data = ones(n, dtype=dtype) + diags = [0] + return dia_matrix( (data,diags), shape=(n,n) ) else: return identity( n, dtype=dtype, format='csr').asformat(format) @@ -103,7 +130,6 @@ Examples -------- - >>> A = csr_matrix(array([[0,2],[5,0]])) >>> B = csr_matrix(array([[1,2],[3,4]])) >>> kron(A,B).todense() @@ -200,7 +226,7 @@ if B.shape[0] != B.shape[1]: raise ValueError('B is not square') - dtype = upcast(A.dtype,B.dtype) + dtype = upcast(A.dtype, B.dtype) L = kron(identity(B.shape[0],dtype=dtype), A, format=format) R = kron(B, identity(A.shape[0],dtype=dtype), format=format) @@ -213,7 +239,6 @@ Parameters ---------- - blocks sequence of sparse matrices with compatible shapes format : string @@ -223,7 +248,6 @@ Example ------- - >>> from scipy.sparse import coo_matrix, vstack >>> A = coo_matrix([[1,2],[3,4]]) >>> B = coo_matrix([[5],[6]]) @@ -240,7 +264,6 @@ Parameters ---------- - blocks sequence of sparse matrices with compatible shapes format : string @@ -250,7 +273,6 @@ Example ------- - >>> from scipy.sparse import coo_matrix, vstack >>> A = coo_matrix([[1,2],[3,4]]) >>> B = coo_matrix([[5,6]]) @@ -268,7 +290,6 @@ Parameters ---------- - blocks grid of sparse matrices with compatible shapes an entry of None implies an all-zero matrix @@ -278,7 +299,6 @@ Example ------- - >>> from scipy.sparse import coo_matrix, bmat >>> A = coo_matrix([[1,2],[3,4]]) >>> B = coo_matrix([[5],[6]]) @@ -398,8 +418,9 @@ DeprecationWarning) return eye(r,c,k,dtype=dtype,format='lil') +from numpy import clip +from itertools import izip - #TODO remove this function def lil_diags(diags,offsets,(m,n),dtype='d'): """Generate a lil_matrix with the given diagonals. Added: trunk/scipy/sparse/extract.py =================================================================== --- trunk/scipy/sparse/extract.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/extract.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -0,0 +1,143 @@ +"""Functions to extract parts of sparse matrices +""" + +__docformat__ = "restructuredtext en" + +__all__ = ['tril', 'triu'] + + +from coo import coo_matrix + +def tril(A, k=0, format=None): + """Return the lower triangular portion of a matrix in sparse format + + Returns the elements on or below the k-th diagonal of the matrix A. + - k = 0 corresponds to the main diagonal + - k > 0 is above the main diagonal + - k < 0 is below the main diagonal + + Parameters + ---------- + A : dense or sparse matrix + Matrix whose lower trianglar portion is desired. + k : integer : optional + The top-most diagonal of the lower triangle. + format : string + Sparse format of the result, e.g. format="csr", etc. + + Returns + ------- + L : sparse matrix + Lower triangular portion of A in sparse format. + + See Also + -------- + triu : upper triangle in sparse format + + Examples + -------- + >>> from scipy.sparse import csr_matrix + >>> A = csr_matrix( [[1,2,0,0,3],[4,5,0,6,7],[0,0,8,9,0]] ) + >>> A.todense() + matrix([[1, 2, 0, 0, 3], + [4, 5, 0, 6, 7], + [0, 0, 8, 9, 0]]) + >>> tril(A).todense() + matrix([[1, 0, 0, 0, 0], + [4, 5, 0, 0, 0], + [0, 0, 8, 0, 0]]) + >>> tril(A).nnz + 4 + >>> tril(A, k=1).todense() + matrix([[1, 2, 0, 0, 0], + [4, 5, 0, 0, 0], + [0, 0, 8, 9, 0]]) + >>> tril(A, k=-1).todense() + matrix([[0, 0, 0, 0, 0], + [4, 0, 0, 0, 0], + [0, 0, 0, 0, 0]]) + >>> tril(A, format='csc') + <3x5 sparse matrix of type '' + with 4 stored elements in Compressed Sparse Column format> + + """ + + # convert to COOrdinate format where things are easy + A = coo_matrix(A, copy=False) + + mask = A.row + k >= A.col + + row = A.row[mask] + col = A.col[mask] + data = A.data[mask] + + return coo_matrix( (data,(row,col)), shape=A.shape ).asformat(format) + + +def triu(A, k=0, format=None): + """Return the upper triangular portion of a matrix in sparse format + + Returns the elements on or above the k-th diagonal of the matrix A. + - k = 0 corresponds to the main diagonal + - k > 0 is above the main diagonal + - k < 0 is below the main diagonal + + Parameters + ---------- + A : dense or sparse matrix + Matrix whose upper trianglar portion is desired. + k : integer : optional + The bottom-most diagonal of the upper triangle. + format : string + Sparse format of the result, e.g. format="csr", etc. + + Returns + ------- + L : sparse matrix + Upper triangular portion of A in sparse format. + + See Also + -------- + tril : lower triangle in sparse format + + Examples + -------- + >>> from scipy.sparse import csr_matrix + >>> A = csr_matrix( [[1,2,0,0,3],[4,5,0,6,7],[0,0,8,9,0]] ) + >>> A.todense() + matrix([[1, 2, 0, 0, 3], + [4, 5, 0, 6, 7], + [0, 0, 8, 9, 0]]) + >>> triu(A).todense() + matrix([[1, 2, 0, 0, 3], + [0, 5, 0, 6, 7], + [0, 0, 8, 9, 0]]) + >>> triu(A).nnz + 8 + >>> triu(A, k=1).todense() + matrix([[0, 2, 0, 0, 3], + [0, 0, 0, 6, 7], + [0, 0, 0, 9, 0]]) + >>> triu(A, k=-1).todense() + matrix([[1, 2, 0, 0, 3], + [4, 5, 0, 6, 7], + [0, 0, 8, 9, 0]]) + >>> triu(A, format='csc') + <3x5 sparse matrix of type '' + with 8 stored elements in Compressed Sparse Column format> + + """ + + # convert to COOrdinate format where things are easy + A = coo_matrix(A, copy=False) + + mask = A.row + k <= A.col + + row = A.row[mask] + col = A.col[mask] + data = A.data[mask] + + return coo_matrix( (data,(row,col)), shape=A.shape ).asformat(format) + + + Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/tests/test_base.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -149,6 +149,10 @@ A = [[1,0,0],[2,3,4],[0,5,0],[0,0,0]] assert_array_equal(self.spmatrix(A).todense(), A) + #def test_array(self): + # """test array(A) where A is in sparse format""" + # assert_equal( array(self.datsp), self.dat ) + def test_todense(self): chk = self.datsp.todense() assert_array_equal(chk,self.dat) Modified: trunk/scipy/sparse/tests/test_construct.py =================================================================== --- trunk/scipy/sparse/tests/test_construct.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/tests/test_construct.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -9,6 +9,8 @@ from scipy.sparse.construct import * +sparse_formats = ['csr','csc','coo','bsr','dia','lil','dok'] + #TODO check whether format=XXX is respected class TestConstructUtils(TestCase): @@ -61,14 +63,18 @@ def test_identity(self): - a = identity(3) - b = array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype='d') - assert_array_equal(a.toarray(), b) + assert_equal(identity(1).toarray(), [[1]]) + assert_equal(identity(2).toarray(), [[1,0],[0,1]]) - a = identity(1) - b = array([[1]], dtype='d') - assert_array_equal(a.toarray(), b) + I = identity(3, dtype='int8', format='dia') + assert_equal( I.dtype, 'int8' ) + assert_equal( I.format, 'dia' ) + for fmt in sparse_formats: + I = identity( 3, format=fmt ) + assert_equal( I.format, fmt ) + assert_equal( I.toarray(), [[1,0,0],[0,1,0],[0,0,1]]) + def test_eye(self): a = eye(2, 3 ) b = array([[1, 0, 0], [0, 1, 0]], dtype='d') Added: trunk/scipy/sparse/tests/test_extract.py =================================================================== --- trunk/scipy/sparse/tests/test_extract.py 2008-07-14 21:33:03 UTC (rev 4543) +++ trunk/scipy/sparse/tests/test_extract.py 2008-07-15 12:22:24 UTC (rev 4544) @@ -0,0 +1,42 @@ +"""test sparse matrix construction functions""" + +import numpy +from numpy import array, matrix +from scipy.testing import * + +from scipy.sparse import csr_matrix + +import numpy as np +from scipy.sparse.extract import * + + +class TestExtract(TestCase): + def setUp(self): + cases = [] + + cases.append( csr_matrix( [[1,2]] ) ) + cases.append( csr_matrix( [[1,0]] ) ) + cases.append( csr_matrix( [[0,0]] ) ) + cases.append( csr_matrix( [[1],[2]] ) ) + cases.append( csr_matrix( [[1],[0]] ) ) + cases.append( csr_matrix( [[0],[0]] ) ) + cases.append( csr_matrix( [[1,2],[3,4]] ) ) + cases.append( csr_matrix( [[0,1],[0,0]] ) ) + cases.append( csr_matrix( [[0,0],[1,0]] ) ) + cases.append( csr_matrix( [[0,0],[0,0]] ) ) + cases.append( csr_matrix( [[1,2,0,0,3],[4,5,0,6,7],[0,0,8,9,0]] ) ) + cases.append( csr_matrix( [[1,2,0,0,3],[4,5,0,6,7],[0,0,8,9,0]] ).T ) + + self.cases = cases + + def test_tril(self): + for A in self.cases: + B = A.toarray() + for k in [-3,-2,-1,0,1,2,3]: + assert_equal( tril(A,k=k).toarray(), np.tril(B,k=k)) + + def test_triu(self): + for A in self.cases: + B = A.toarray() + for k in [-3,-2,-1,0,1,2,3]: + assert_equal( triu(A,k=k).toarray(), np.triu(B,k=k)) From scipy-svn at scipy.org Tue Jul 15 20:27:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 15 Jul 2008 19:27:53 -0500 (CDT) Subject: [Scipy-svn] r4545 - in trunk/scipy: . cluster cluster/tests fftpack fftpack/benchmarks fftpack/tests integrate integrate/tests interpolate interpolate/tests io io/arff/tests io/matlab/tests io/tests lib lib/blas lib/blas/tests lib/lapack lib/lapack/tests linalg linalg/benchmarks linalg/tests maxentropy maxentropy/tests misc misc/tests ndimage ndimage/tests odr odr/tests optimize optimize/benchmarks optimize/tests sandbox/cdavid sandbox/cdavid/tests sandbox/exmplpackage sandbox/exmplpackage/benchmarks sandbox/exmplpackage/tests sandbox/exmplpackage/yyy sandbox/exmplpackage/yyy/tests sandbox/fdfpack/tests sandbox/montecarlo/tests sandbox/numexpr/tests sandbox/pyloess/tests sandbox/rbf sandbox/rbf/tests sandbox/spline sandbox/spline/tests signal signal/tests sparse sparse/benchmarks sparse/linalg sparse/linalg/dsolve sparse/linalg/dsolve/tests sparse/linalg/dsolve/umfpack sparse/linalg/dsolve/umfpack/tests sparse/linalg/eigen sparse/linalg/eigen/arpack/tests sparse/linalg/eigen/lobpcg sparse/linalg/eigen/lobpcg/tests sparse/linalg/isolve sparse/linalg/isolve/tests sparse/linalg/tests sparse/tests special special/tests stats stats/models stats/models/tests stats/tests weave weave/tests Message-ID: <20080716002753.2349C39C02D@scipy.org> Author: alan.mcintyre Date: 2008-07-15 19:26:23 -0500 (Tue, 15 Jul 2008) New Revision: 4545 Removed: trunk/scipy/testing/ Modified: trunk/scipy/__init__.py trunk/scipy/cluster/__init__.py trunk/scipy/cluster/tests/test_hierarchy.py trunk/scipy/cluster/tests/test_vq.py trunk/scipy/fftpack/__init__.py trunk/scipy/fftpack/benchmarks/bench_basic.py trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py trunk/scipy/fftpack/tests/test_basic.py trunk/scipy/fftpack/tests/test_helper.py trunk/scipy/fftpack/tests/test_pseudo_diffs.py trunk/scipy/integrate/__init__.py trunk/scipy/integrate/tests/test_integrate.py trunk/scipy/integrate/tests/test_quadpack.py trunk/scipy/integrate/tests/test_quadrature.py trunk/scipy/interpolate/__init__.py trunk/scipy/interpolate/tests/test_fitpack.py trunk/scipy/interpolate/tests/test_interpolate.py trunk/scipy/interpolate/tests/test_polyint.py trunk/scipy/io/__init__.py trunk/scipy/io/arff/tests/test_data.py trunk/scipy/io/arff/tests/test_header.py trunk/scipy/io/matlab/tests/test_mio.py trunk/scipy/io/tests/test_array_import.py trunk/scipy/io/tests/test_mmio.py trunk/scipy/io/tests/test_npfile.py trunk/scipy/io/tests/test_recaster.py trunk/scipy/lib/__init__.py trunk/scipy/lib/blas/__init__.py trunk/scipy/lib/blas/tests/test_blas.py trunk/scipy/lib/blas/tests/test_fblas.py trunk/scipy/lib/lapack/__init__.py trunk/scipy/lib/lapack/tests/esv_tests.py trunk/scipy/lib/lapack/tests/gesv_tests.py trunk/scipy/lib/lapack/tests/test_lapack.py trunk/scipy/linalg/__init__.py trunk/scipy/linalg/benchmarks/bench_basic.py trunk/scipy/linalg/benchmarks/bench_decom.py trunk/scipy/linalg/tests/test_atlas_version.py trunk/scipy/linalg/tests/test_basic.py trunk/scipy/linalg/tests/test_blas.py trunk/scipy/linalg/tests/test_decomp.py trunk/scipy/linalg/tests/test_fblas.py trunk/scipy/linalg/tests/test_lapack.py trunk/scipy/linalg/tests/test_matfuncs.py trunk/scipy/maxentropy/__init__.py trunk/scipy/maxentropy/tests/test_maxentropy.py trunk/scipy/misc/__init__.py trunk/scipy/misc/ppimport.py trunk/scipy/misc/tests/test_pilutil.py trunk/scipy/ndimage/__init__.py trunk/scipy/ndimage/tests/test_ndimage.py trunk/scipy/ndimage/tests/test_registration.py trunk/scipy/ndimage/tests/test_segment.py trunk/scipy/odr/__init__.py trunk/scipy/odr/tests/test_odr.py trunk/scipy/optimize/__init__.py trunk/scipy/optimize/benchmarks/bench_zeros.py trunk/scipy/optimize/tests/test_cobyla.py trunk/scipy/optimize/tests/test_nonlin.py trunk/scipy/optimize/tests/test_optimize.py trunk/scipy/optimize/tests/test_slsqp.py trunk/scipy/optimize/tests/test_zeros.py trunk/scipy/sandbox/cdavid/__init__.py trunk/scipy/sandbox/cdavid/tests/test_autocorr.py trunk/scipy/sandbox/cdavid/tests/test_lpc.py trunk/scipy/sandbox/cdavid/tests/test_segmentaxis.py trunk/scipy/sandbox/exmplpackage/__init__.py trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py trunk/scipy/sandbox/exmplpackage/tests/test_foo.py trunk/scipy/sandbox/exmplpackage/yyy/__init__.py trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py trunk/scipy/sandbox/fdfpack/tests/test_fdf.py trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py trunk/scipy/sandbox/numexpr/tests/test_numexpr.py trunk/scipy/sandbox/pyloess/tests/test_mpyloess.py trunk/scipy/sandbox/pyloess/tests/test_pyloess.py trunk/scipy/sandbox/rbf/__init__.py trunk/scipy/sandbox/rbf/tests/test_rbf.py trunk/scipy/sandbox/spline/__init__.py trunk/scipy/sandbox/spline/tests/test_fitpack.py trunk/scipy/sandbox/spline/tests/test_spline.py trunk/scipy/setup.py trunk/scipy/setupscons.py trunk/scipy/signal/__init__.py trunk/scipy/signal/tests/test_signaltools.py trunk/scipy/signal/tests/test_wavelets.py trunk/scipy/sparse/__init__.py trunk/scipy/sparse/benchmarks/bench_sparse.py trunk/scipy/sparse/linalg/__init__.py trunk/scipy/sparse/linalg/dsolve/__init__.py trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py trunk/scipy/sparse/linalg/dsolve/umfpack/__init__.py trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py trunk/scipy/sparse/linalg/eigen/__init__.py trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py trunk/scipy/sparse/linalg/eigen/lobpcg/__init__.py trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py trunk/scipy/sparse/linalg/isolve/__init__.py trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py trunk/scipy/sparse/linalg/tests/test_interface.py trunk/scipy/sparse/tests/test_base.py trunk/scipy/sparse/tests/test_construct.py trunk/scipy/sparse/tests/test_extract.py trunk/scipy/sparse/tests/test_spfuncs.py trunk/scipy/sparse/tests/test_sputils.py trunk/scipy/special/__init__.py trunk/scipy/special/tests/test_basic.py trunk/scipy/special/tests/test_spfun_stats.py trunk/scipy/stats/__init__.py trunk/scipy/stats/models/__init__.py trunk/scipy/stats/models/tests/test_bspline.py trunk/scipy/stats/models/tests/test_formula.py trunk/scipy/stats/models/tests/test_glm.py trunk/scipy/stats/models/tests/test_regression.py trunk/scipy/stats/models/tests/test_rlm.py trunk/scipy/stats/models/tests/test_scale.py trunk/scipy/stats/models/tests/test_utils.py trunk/scipy/stats/morestats.py trunk/scipy/stats/tests/test_distributions.py trunk/scipy/stats/tests/test_mmorestats.py trunk/scipy/stats/tests/test_morestats.py trunk/scipy/stats/tests/test_mstats.py trunk/scipy/stats/tests/test_stats.py trunk/scipy/weave/__init__.py trunk/scipy/weave/tests/test_ast_tools.py trunk/scipy/weave/tests/test_blitz_tools.py trunk/scipy/weave/tests/test_build_tools.py trunk/scipy/weave/tests/test_c_spec.py trunk/scipy/weave/tests/test_catalog.py trunk/scipy/weave/tests/test_ext_tools.py trunk/scipy/weave/tests/test_inline_tools.py trunk/scipy/weave/tests/test_numpy_scalar_spec.py trunk/scipy/weave/tests/test_scxx.py trunk/scipy/weave/tests/test_scxx_dict.py trunk/scipy/weave/tests/test_scxx_object.py trunk/scipy/weave/tests/test_scxx_sequence.py trunk/scipy/weave/tests/test_size_check.py trunk/scipy/weave/tests/test_slice_handler.py trunk/scipy/weave/tests/test_standard_array_spec.py trunk/scipy/weave/tests/test_wx_spec.py Log: Remove the testing package, and switched all test modules to use numpy.test instead. Modified: trunk/scipy/__init__.py =================================================================== --- trunk/scipy/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -67,7 +67,7 @@ # "from scipy import *". This works around a numpy bug present in < 1.2. subpackages = """cluster constants fftpack integrate interpolate io lib linalg linsolve maxentropy misc ndimage odr optimize sandbox signal sparse special -splinalg stats stsci testing weave""".split() +splinalg stats stsci weave""".split() for name in subpackages: try: __all__.remove(name) @@ -83,7 +83,7 @@ """ __doc__ += pkgload.get_pkgdocs() -from testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench __doc__ += """ Modified: trunk/scipy/cluster/__init__.py =================================================================== --- trunk/scipy/cluster/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/cluster/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,5 +7,5 @@ __all__ = ['vq', 'hierarchy', 'distance'] import vq, hierarchy, distance -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -37,7 +37,7 @@ import os.path import numpy -from scipy.testing import * +from numpy.testing import * from scipy.cluster.hierarchy import squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage from scipy.cluster.distance import pdist, matching, jaccard, dice, sokalsneath, rogerstanimoto, russellrao, yule Modified: trunk/scipy/cluster/tests/test_vq.py =================================================================== --- trunk/scipy/cluster/tests/test_vq.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/cluster/tests/test_vq.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -8,7 +8,7 @@ import sys import os.path -from scipy.testing import * +from numpy.testing import * import numpy as N Modified: trunk/scipy/fftpack/__init__.py =================================================================== --- trunk/scipy/fftpack/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/fftpack/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -17,6 +17,6 @@ del k, register_func -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/fftpack/benchmarks/bench_basic.py =================================================================== --- trunk/scipy/fftpack/benchmarks/bench_basic.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/fftpack/benchmarks/bench_basic.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ """ Test functions for fftpack.basic module """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.fftpack import ifft,fft,fftn,ifftn,rfft,irfft from scipy.fftpack import _fftpack as fftpack Modified: trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py =================================================================== --- trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ from numpy import arange, add, array, sin, cos, pi,exp,tanh,sum,sign -from scipy.testing import * +from numpy.testing import * from scipy.fftpack import diff,fft,ifft,tilbert,itilbert,hilbert,ihilbert,rfft from scipy.fftpack import shift from scipy.fftpack import fftfreq Modified: trunk/scipy/fftpack/tests/test_basic.py =================================================================== --- trunk/scipy/fftpack/tests/test_basic.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/fftpack/tests/test_basic.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -11,7 +11,7 @@ python tests/test_basic.py """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.fftpack import ifft,fft,fftn,ifftn,rfft,irfft from scipy.fftpack import _fftpack as fftpack Modified: trunk/scipy/fftpack/tests/test_helper.py =================================================================== --- trunk/scipy/fftpack/tests/test_helper.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/fftpack/tests/test_helper.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -12,7 +12,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.fftpack import fftshift,ifftshift,fftfreq,rfftfreq from numpy import pi Modified: trunk/scipy/fftpack/tests/test_pseudo_diffs.py =================================================================== --- trunk/scipy/fftpack/tests/test_pseudo_diffs.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/fftpack/tests/test_pseudo_diffs.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -11,7 +11,7 @@ python tests/test_pseudo_diffs.py [] """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.fftpack import diff,fft,ifft,tilbert,itilbert,hilbert,ihilbert,rfft from scipy.fftpack import shift from scipy.fftpack import fftfreq Modified: trunk/scipy/integrate/__init__.py =================================================================== --- trunk/scipy/integrate/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/integrate/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -12,5 +12,5 @@ from ode import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/integrate/tests/test_integrate.py =================================================================== --- trunk/scipy/integrate/tests/test_integrate.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/integrate/tests/test_integrate.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -8,7 +8,7 @@ eye, pi, exp, allclose) from scipy.linalg import norm -from scipy.testing import * +from numpy.testing import * from scipy.integrate import odeint, ode #------------------------------------------------------------------------------ Modified: trunk/scipy/integrate/tests/test_quadpack.py =================================================================== --- trunk/scipy/integrate/tests/test_quadpack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/integrate/tests/test_quadpack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ import numpy from numpy import sqrt, cos, sin, arctan, exp, log, pi, Inf -from scipy.testing import * +from numpy.testing import * from scipy.integrate import quad, dblquad, tplquad def assert_quad((value, err), tabledValue, errTol=1.5e-8): Modified: trunk/scipy/integrate/tests/test_quadrature.py =================================================================== --- trunk/scipy/integrate/tests/test_quadrature.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/integrate/tests/test_quadrature.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import numpy from numpy import cos, sin, pi -from scipy.testing import * +from numpy.testing import * from scipy.integrate import quadrature, romberg, romb Modified: trunk/scipy/interpolate/__init__.py =================================================================== --- trunk/scipy/interpolate/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/interpolate/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -15,5 +15,5 @@ from polyint import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/interpolate/tests/test_fitpack.py =================================================================== --- trunk/scipy/interpolate/tests/test_fitpack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/interpolate/tests/test_fitpack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -13,7 +13,7 @@ #import libwadpy import sys -from scipy.testing import * +from numpy.testing import * from numpy import array, diff from scipy.interpolate.fitpack2 import UnivariateSpline,LSQUnivariateSpline,\ InterpolatedUnivariateSpline Modified: trunk/scipy/interpolate/tests/test_interpolate.py =================================================================== --- trunk/scipy/interpolate/tests/test_interpolate.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/interpolate/tests/test_interpolate.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,4 +1,4 @@ -from scipy.testing import * +from numpy.testing import * from numpy import mgrid, pi, sin, ogrid, poly1d import numpy as np Modified: trunk/scipy/interpolate/tests/test_polyint.py =================================================================== --- trunk/scipy/interpolate/tests/test_polyint.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/interpolate/tests/test_polyint.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ -from scipy.testing import * +from numpy.testing import * from scipy.interpolate import KroghInterpolator, krogh_interpolate, \ BarycentricInterpolator, barycentric_interpolate, \ PiecewisePolynomial, piecewise_polynomial_interpolate, \ Modified: trunk/scipy/io/__init__.py =================================================================== --- trunk/scipy/io/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -84,5 +84,5 @@ from mmio import mminfo, mmread, mmwrite __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/io/arff/tests/test_data.py =================================================================== --- trunk/scipy/io/arff/tests/test_data.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/arff/tests/test_data.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ import os import numpy as N -from scipy.testing import * +from numpy.testing import * from scipy.io.arff.arffread import loadarff Modified: trunk/scipy/io/arff/tests/test_header.py =================================================================== --- trunk/scipy/io/arff/tests/test_header.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/arff/tests/test_header.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ """Test for parsing arff headers only.""" import os -from scipy.testing import * +from numpy.testing import * from scipy.io.arff.arffread import read_header, MetaData, parse_type, \ ParseArffError Modified: trunk/scipy/io/matlab/tests/test_mio.py =================================================================== --- trunk/scipy/io/matlab/tests/test_mio.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/matlab/tests/test_mio.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ from glob import glob from cStringIO import StringIO from tempfile import mkstemp, mkdtemp -from scipy.testing import * +from numpy.testing import * from numpy import arange, array, eye, pi, cos, exp, sin, sqrt, ndarray, \ zeros, reshape, transpose, empty import scipy.sparse as SP Modified: trunk/scipy/io/tests/test_array_import.py =================================================================== --- trunk/scipy/io/tests/test_array_import.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/tests/test_array_import.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ # also check out numpyio.fread.__doc__ and other method docstrings. import os -from scipy.testing import * +from numpy.testing import * import scipy.io as io from scipy.io import numpyio from scipy.io import array_import Modified: trunk/scipy/io/tests/test_mmio.py =================================================================== --- trunk/scipy/io/tests/test_mmio.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/tests/test_mmio.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ from tempfile import mktemp from numpy import array,transpose -from scipy.testing import * +from numpy.testing import * import scipy import scipy.sparse Modified: trunk/scipy/io/tests/test_npfile.py =================================================================== --- trunk/scipy/io/tests/test_npfile.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/tests/test_npfile.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import os from StringIO import StringIO from tempfile import mkstemp -from scipy.testing import * +from numpy.testing import * import numpy as N from scipy.io.npfile import npfile, sys_endian_code Modified: trunk/scipy/io/tests/test_recaster.py =================================================================== --- trunk/scipy/io/tests/test_recaster.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/io/tests/test_recaster.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ import numpy as N -from scipy.testing import * +from numpy.testing import * from scipy.io.recaster import sctype_attributes, Recaster, RecastError Modified: trunk/scipy/lib/__init__.py =================================================================== --- trunk/scipy/lib/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ from info import __doc__, __all__ -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/lib/blas/__init__.py =================================================================== --- trunk/scipy/lib/blas/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/blas/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -58,5 +58,5 @@ funcs.append(func) return tuple(funcs) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/lib/blas/tests/test_blas.py =================================================================== --- trunk/scipy/lib/blas/tests/test_blas.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/blas/tests/test_blas.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -16,7 +16,7 @@ import math from numpy import arange, add, array -from scipy.testing import * +from numpy.testing import * from scipy.lib.blas import fblas from scipy.lib.blas import cblas from scipy.lib.blas import get_blas_funcs Modified: trunk/scipy/lib/blas/tests/test_fblas.py =================================================================== --- trunk/scipy/lib/blas/tests/test_fblas.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/blas/tests/test_fblas.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -10,7 +10,7 @@ from numpy import zeros, transpose, newaxis, shape, float32, \ float64, complex64, complex128, arange, array, common_type, \ conjugate -from scipy.testing import * +from numpy.testing import * from scipy.lib.blas import fblas #decimal accuracy to require between Python and LAPACK/BLAS calculations Modified: trunk/scipy/lib/lapack/__init__.py =================================================================== --- trunk/scipy/lib/lapack/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/lapack/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -90,5 +90,5 @@ func_code = %(func_name)s.func_code ''' -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/lib/lapack/tests/esv_tests.py =================================================================== --- trunk/scipy/lib/lapack/tests/esv_tests.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/lapack/tests/esv_tests.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ -from scipy.testing import * +from numpy.testing import * from numpy import dot class _test_ev(object): Modified: trunk/scipy/lib/lapack/tests/gesv_tests.py =================================================================== --- trunk/scipy/lib/lapack/tests/gesv_tests.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/lapack/tests/gesv_tests.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ -from scipy.testing import * +from numpy.testing import * from numpy import dot class _test_gev(object): Modified: trunk/scipy/lib/lapack/tests/test_lapack.py =================================================================== --- trunk/scipy/lib/lapack/tests/test_lapack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/lib/lapack/tests/test_lapack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -16,7 +16,7 @@ import os import sys -from scipy.testing import * +from numpy.testing import * from numpy import dot, ones, zeros from scipy.lib.lapack import flapack, clapack Modified: trunk/scipy/linalg/__init__.py =================================================================== --- trunk/scipy/linalg/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -30,6 +30,6 @@ del k, register_func -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/linalg/benchmarks/bench_basic.py =================================================================== --- trunk/scipy/linalg/benchmarks/bench_basic.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/benchmarks/bench_basic.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ import numpy from numpy import arange, add, array, dot, zeros, identity, conjugate, transpose -from scipy.testing import * +from numpy.testing import * from scipy.linalg import solve,inv,det,lstsq, toeplitz, hankel, tri, triu, \ tril, pinv, pinv2, solve_banded Modified: trunk/scipy/linalg/benchmarks/bench_decom.py =================================================================== --- trunk/scipy/linalg/benchmarks/bench_decom.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/benchmarks/bench_decom.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,7 +7,7 @@ from numpy import linalg from scipy.linalg import eigvals -from scipy.testing import * +from numpy.testing import * def random(size): return rand(*size) Modified: trunk/scipy/linalg/tests/test_atlas_version.py =================================================================== --- trunk/scipy/linalg/tests/test_atlas_version.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_atlas_version.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ # import sys -from scipy.testing import * +from numpy.testing import * import scipy.linalg.atlas_version Modified: trunk/scipy/linalg/tests/test_basic.py =================================================================== --- trunk/scipy/linalg/tests/test_basic.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_basic.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -23,7 +23,7 @@ from numpy import arange, add, array, dot, zeros, identity, conjugate, transpose import sys -from scipy.testing import * +from numpy.testing import * from scipy.linalg import solve,inv,det,lstsq, toeplitz, hankel, tri, triu, \ tril, pinv, pinv2, solve_banded Modified: trunk/scipy/linalg/tests/test_blas.py =================================================================== --- trunk/scipy/linalg/tests/test_blas.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_blas.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -17,7 +17,7 @@ from numpy import arange, add, array -from scipy.testing import * +from numpy.testing import * from scipy.linalg import fblas, cblas Modified: trunk/scipy/linalg/tests/test_decomp.py =================================================================== --- trunk/scipy/linalg/tests/test_decomp.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_decomp.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -15,7 +15,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.linalg import eig,eigvals,lu,svd,svdvals,cholesky,qr, \ schur,rsf2csf, lu_solve,lu_factor,solve,diagsvd,hessenberg,rq, \ Modified: trunk/scipy/linalg/tests/test_fblas.py =================================================================== --- trunk/scipy/linalg/tests/test_fblas.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_fblas.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -13,7 +13,7 @@ common_type, conjugate from scipy.linalg import fblas -from scipy.testing import * +from numpy.testing import * #decimal accuracy to require between Python and LAPACK/BLAS calculations Modified: trunk/scipy/linalg/tests/test_lapack.py =================================================================== --- trunk/scipy/linalg/tests/test_lapack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_lapack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -5,7 +5,7 @@ import sys -from scipy.testing import * +from numpy.testing import * from numpy import ones from scipy.linalg import flapack, clapack Modified: trunk/scipy/linalg/tests/test_matfuncs.py =================================================================== --- trunk/scipy/linalg/tests/test_matfuncs.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/linalg/tests/test_matfuncs.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -11,7 +11,7 @@ import numpy from numpy import array, identity, dot, sqrt -from scipy.testing import * +from numpy.testing import * import scipy.linalg from scipy.linalg import signm,logm,funm, sqrtm, expm, expm2, expm3 Modified: trunk/scipy/maxentropy/__init__.py =================================================================== --- trunk/scipy/maxentropy/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/maxentropy/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -8,5 +8,5 @@ from info import __doc__ from maxentropy import * -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/maxentropy/tests/test_maxentropy.py =================================================================== --- trunk/scipy/maxentropy/tests/test_maxentropy.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/maxentropy/tests/test_maxentropy.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,7 +7,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from numpy import arange, add, array, dot, zeros, identity, log, exp, ones from scipy.maxentropy.maxentropy import * Modified: trunk/scipy/misc/__init__.py =================================================================== --- trunk/scipy/misc/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/misc/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -20,5 +20,5 @@ __all__ += common.__all__ -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/misc/ppimport.py =================================================================== --- trunk/scipy/misc/ppimport.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/misc/ppimport.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -242,7 +242,7 @@ self.__dict__['_ppimport_p_frame'] = p_frame if location != 'sys.path': - from scipy.testing.pkgtester import Tester + from numpy.testing import Tester self.__dict__['test'] = Tester(os,path.dirname(location)).test # install loader @@ -283,7 +283,7 @@ self.__dict__['_ppimport_module'] = module # XXX: Should we check the existence of module.test? Warn? - from scipy.testing.pkgtester import Tester + from numpy.testing import Tester test = Tester(os.path.dirname(module)).test return module Modified: trunk/scipy/misc/tests/test_pilutil.py =================================================================== --- trunk/scipy/misc/tests/test_pilutil.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/misc/tests/test_pilutil.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ import glob import numpy as N -from scipy.testing import * +from numpy.testing import * try: import PIL.Image Modified: trunk/scipy/ndimage/__init__.py =================================================================== --- trunk/scipy/ndimage/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/ndimage/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -38,5 +38,5 @@ from info import __doc__ __version__ = '2.0' -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/ndimage/tests/test_ndimage.py =================================================================== --- trunk/scipy/ndimage/tests/test_ndimage.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/ndimage/tests/test_ndimage.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -31,7 +31,7 @@ import math import numpy from numpy import fft -from scipy.testing import * +from numpy.testing import * import scipy.ndimage as ndimage eps = 1e-12 Modified: trunk/scipy/ndimage/tests/test_registration.py =================================================================== --- trunk/scipy/ndimage/tests/test_registration.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/ndimage/tests/test_registration.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import math import numpy as np import scipy.ndimage._registration as reg -from scipy.testing import * +from numpy.testing import * def load_desc(): # this is for a 256x256x90 volume with 0.9375 x 0.9375 * 1.5 mm voxel sizes Modified: trunk/scipy/ndimage/tests/test_segment.py =================================================================== --- trunk/scipy/ndimage/tests/test_segment.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/ndimage/tests/test_segment.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import math import numpy as NP import scipy.ndimage._segmenter as seg -from scipy.testing import * +from numpy.testing import * def run_sobel(): img = seg.build_test_discs() Modified: trunk/scipy/odr/__init__.py =================================================================== --- trunk/scipy/odr/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/odr/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -21,6 +21,6 @@ __all__ = ['odr', 'odr_error', 'odr_stop', 'Data', 'RealData', 'Model', 'Output', 'ODR', 'odrpack'] -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test #### EOF ####################################################################### Modified: trunk/scipy/odr/tests/test_odr.py =================================================================== --- trunk/scipy/odr/tests/test_odr.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/odr/tests/test_odr.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ # Scipy imports. import numpy as np from numpy import pi -from scipy.testing import * +from numpy.testing import * from scipy.odr import Data, Model, ODR, RealData, odr_stop Modified: trunk/scipy/optimize/__init__.py =================================================================== --- trunk/scipy/optimize/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -16,6 +16,6 @@ from slsqp import fmin_slsqp __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/optimize/benchmarks/bench_zeros.py =================================================================== --- trunk/scipy/optimize/benchmarks/bench_zeros.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/benchmarks/bench_zeros.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ from math import sqrt -from scipy.testing import * +from numpy.testing import * from scipy.optimize import zeros as cc Modified: trunk/scipy/optimize/tests/test_cobyla.py =================================================================== --- trunk/scipy/optimize/tests/test_cobyla.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/tests/test_cobyla.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ import math -from scipy.testing import * +from numpy.testing import * from scipy.optimize import cobyla as co Modified: trunk/scipy/optimize/tests/test_nonlin.py =================================================================== --- trunk/scipy/optimize/tests/test_nonlin.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/tests/test_nonlin.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ May 2007 """ -from scipy.testing import * +from numpy.testing import * from scipy.optimize import nonlin from numpy import matrix, diag Modified: trunk/scipy/optimize/tests/test_optimize.py =================================================================== --- trunk/scipy/optimize/tests/test_optimize.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/tests/test_optimize.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -9,7 +9,7 @@ """ -from scipy.testing import * +from numpy.testing import * from scipy import optimize from scipy.optimize import leastsq Modified: trunk/scipy/optimize/tests/test_slsqp.py =================================================================== --- trunk/scipy/optimize/tests/test_slsqp.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/tests/test_slsqp.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,4 +1,4 @@ -from scipy.testing import * +from numpy.testing import * import numpy as np from scipy.optimize import fmin_slsqp Modified: trunk/scipy/optimize/tests/test_zeros.py =================================================================== --- trunk/scipy/optimize/tests/test_zeros.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/optimize/tests/test_zeros.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ from math import sqrt -from scipy.testing import * +from numpy.testing import * from scipy.optimize import zeros as cc Modified: trunk/scipy/sandbox/cdavid/__init__.py =================================================================== --- trunk/scipy/sandbox/cdavid/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/cdavid/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -5,5 +5,5 @@ from autocorr import autocorr_oneside_nofft, autocorr_fft from segmentaxis import segment_axis -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/sandbox/cdavid/tests/test_autocorr.py =================================================================== --- trunk/scipy/sandbox/cdavid/tests/test_autocorr.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/cdavid/tests/test_autocorr.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ #! /usr/bin/env python # Last Change: Fri Dec 15 10:00 PM 2006 J -from scipy.testing import * +from numpy.testing import * from numpy.random import randn, seed from numpy import correlate, array, concatenate, require, corrcoef from numpy.fft import fft, ifft Modified: trunk/scipy/sandbox/cdavid/tests/test_lpc.py =================================================================== --- trunk/scipy/sandbox/cdavid/tests/test_lpc.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/cdavid/tests/test_lpc.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ #! /usr/bin/env python # Last Change: Tue Nov 28 05:00 PM 2006 J -from scipy.testing import * +from numpy.testing import * from numpy.random import randn, seed from numpy import correlate, array, concatenate, require Modified: trunk/scipy/sandbox/cdavid/tests/test_segmentaxis.py =================================================================== --- trunk/scipy/sandbox/cdavid/tests/test_segmentaxis.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/cdavid/tests/test_segmentaxis.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ #! /usr/bin/env python # Last Change: Fri Dec 15 10:00 PM 2006 J -from scipy.testing import * +from numpy.testing import * import numpy as N Modified: trunk/scipy/sandbox/exmplpackage/__init__.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/exmplpackage/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -6,7 +6,7 @@ from info_exmplpackage import __doc__ # Import testing rig, allowing scipy.examplpackage.test() -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test # Import symbols from sub-module: Modified: trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -8,7 +8,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.exmplpackage.foo import * Modified: trunk/scipy/sandbox/exmplpackage/tests/test_foo.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/tests/test_foo.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/exmplpackage/tests/test_foo.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -16,7 +16,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.exmplpackage.foo import * Modified: trunk/scipy/sandbox/exmplpackage/yyy/__init__.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/yyy/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/exmplpackage/yyy/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -5,7 +5,7 @@ __all__ = ['fun', 'test'] # Import testing rig, allowing scipy.examplpackage.yyy.test() -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test def fun(): Modified: trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py =================================================================== --- trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ -from scipy.testing import * +from numpy.testing import * from yyy import fun Modified: trunk/scipy/sandbox/fdfpack/tests/test_fdf.py =================================================================== --- trunk/scipy/sandbox/fdfpack/tests/test_fdf.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/fdfpack/tests/test_fdf.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.fdfpack import periodic_finite_difference as diff Modified: trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py =================================================================== --- trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -10,7 +10,7 @@ from numpy import arange, add, array, dot, zeros, identity import sys -from scipy.testing import * +from numpy.testing import * from numpy import sum, array, average, sqrt #from scipy.montecarlo import * Modified: trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py =================================================================== --- trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -18,7 +18,7 @@ from numpy import arange, add, array, dot, zeros, identity import sys -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.montecarlo import * from scipy import stats Modified: trunk/scipy/sandbox/numexpr/tests/test_numexpr.py =================================================================== --- trunk/scipy/sandbox/numexpr/tests/test_numexpr.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/numexpr/tests/test_numexpr.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import new from numpy import array, arange, sin, zeros, sum, int32, empty, \ prod, uint16, complex_, float64, rec -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.numexpr import E, numexpr, evaluate, disassemble Modified: trunk/scipy/sandbox/pyloess/tests/test_mpyloess.py =================================================================== --- trunk/scipy/sandbox/pyloess/tests/test_mpyloess.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/pyloess/tests/test_mpyloess.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -22,7 +22,7 @@ marray = maskedarray.masked_array masked_values = maskedarray.masked_values -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.maskedarray.testutils import build_err_msg, \ assert_equal, assert_almost_equal Modified: trunk/scipy/sandbox/pyloess/tests/test_pyloess.py =================================================================== --- trunk/scipy/sandbox/pyloess/tests/test_pyloess.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/pyloess/tests/test_pyloess.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -21,7 +21,7 @@ narray = numpy.array -from scipy.testing import * +from numpy.testing import * from scipy.sandbox.pyloess import lowess, stl, loess, loess_anova Modified: trunk/scipy/sandbox/rbf/__init__.py =================================================================== --- trunk/scipy/sandbox/rbf/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/rbf/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,5 +7,5 @@ from rbf import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/sandbox/rbf/tests/test_rbf.py =================================================================== --- trunk/scipy/sandbox/rbf/tests/test_rbf.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/rbf/tests/test_rbf.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ # Created by John Travers, Robert Hetland, 2007 """ Test functions for rbf module """ -from scipy.testing import * +from numpy.testing import * from numpy import linspace, sin, random, exp Modified: trunk/scipy/sandbox/spline/__init__.py =================================================================== --- trunk/scipy/sandbox/spline/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/spline/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -10,5 +10,5 @@ from spline import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/sandbox/spline/tests/test_fitpack.py =================================================================== --- trunk/scipy/sandbox/spline/tests/test_fitpack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/spline/tests/test_fitpack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -12,7 +12,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from numpy import array, arange, around, pi, sin, ravel, zeros, asarray Modified: trunk/scipy/sandbox/spline/tests/test_spline.py =================================================================== --- trunk/scipy/sandbox/spline/tests/test_spline.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sandbox/spline/tests/test_spline.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -13,7 +13,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from numpy import array, arange, around, pi, sin, cos Modified: trunk/scipy/setup.py =================================================================== --- trunk/scipy/setup.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/setup.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -23,7 +23,6 @@ config.add_subpackage('ndimage') config.add_subpackage('stsci') config.add_subpackage('weave') - config.add_subpackage('testing') config.make_svn_version_py() # installs __svn_version__.py config.make_config_py() return config Modified: trunk/scipy/setupscons.py =================================================================== --- trunk/scipy/setupscons.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/setupscons.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -22,7 +22,6 @@ config.add_subpackage('ndimage') config.add_subpackage('stsci') config.add_subpackage('weave') - config.add_subpackage('testing') config.make_svn_version_py() # installs __svn_version__.py config.scons_make_config_py() # installs __config__.py return config Modified: trunk/scipy/signal/__init__.py =================================================================== --- trunk/scipy/signal/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/signal/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -13,5 +13,5 @@ from wavelets import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/signal/tests/test_signaltools.py =================================================================== --- trunk/scipy/signal/tests/test_signaltools.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/signal/tests/test_signaltools.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ #this program corresponds to special.py -from scipy.testing import * +from numpy.testing import * import scipy.signal as signal Modified: trunk/scipy/signal/tests/test_wavelets.py =================================================================== --- trunk/scipy/signal/tests/test_wavelets.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/signal/tests/test_wavelets.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ import numpy as N -from scipy.testing import * +from numpy.testing import * from scipy.signal import wavelets Modified: trunk/scipy/sparse/__init__.py =================================================================== --- trunk/scipy/sparse/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -17,6 +17,6 @@ #from spfuncs import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/sparse/benchmarks/bench_sparse.py =================================================================== --- trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -5,7 +5,7 @@ import numpy from numpy import ones, array, asarray, empty -from scipy.testing import * +from numpy.testing import * from scipy import sparse from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \ Modified: trunk/scipy/sparse/linalg/__init__.py =================================================================== --- trunk/scipy/sparse/linalg/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -9,6 +9,6 @@ __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/sparse/linalg/dsolve/__init__.py =================================================================== --- trunk/scipy/sparse/linalg/dsolve/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/dsolve/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -9,5 +9,5 @@ from linsolve import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py =================================================================== --- trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import warnings from numpy import array, finfo -from scipy.testing import * +from numpy.testing import * from scipy.linalg import norm, inv from scipy.sparse import spdiags, csc_matrix, SparseEfficiencyWarning Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/__init__.py =================================================================== --- trunk/scipy/sparse/linalg/dsolve/umfpack/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/dsolve/umfpack/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,5 +3,5 @@ from umfpack import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py =================================================================== --- trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -10,7 +10,7 @@ from numpy import transpose, array, arange import random -from scipy.testing import * +from numpy.testing import * from scipy import rand, matrix, diag, eye from scipy.sparse import csc_matrix, dok_matrix, spdiags, SparseEfficiencyWarning Modified: trunk/scipy/sparse/linalg/eigen/__init__.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/eigen/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -6,6 +6,6 @@ from lobpcg import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -5,7 +5,7 @@ """ -from scipy.testing import * +from numpy.testing import * from numpy import array,real,imag,finfo,concatenate,\ column_stack,argsort,dot,round,conj,sort,random Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ #!/usr/bin/env python -from scipy.testing import * +from numpy.testing import * from scipy.sparse.linalg.interface import aslinearoperator from scipy.sparse.linalg.eigen.arpack.speigs import * Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/__init__.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/lobpcg/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/eigen/lobpcg/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,5 +7,5 @@ from lobpcg import * -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ """ import numpy -from scipy.testing import * +from numpy.testing import * from scipy import array, arange, ones, sort, cos, pi, rand, \ set_printoptions, r_, diag, linalg Modified: trunk/scipy/sparse/linalg/isolve/__init__.py =================================================================== --- trunk/scipy/sparse/linalg/isolve/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/isolve/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -5,6 +5,6 @@ from minres import minres __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test bench = Tester().bench Modified: trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py =================================================================== --- trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ """ Test functions for the sparse.linalg.isolve module """ -from scipy.testing import * +from numpy.testing import * from numpy import zeros, dot, diag, ones, arange, array from numpy.random import rand Modified: trunk/scipy/sparse/linalg/tests/test_interface.py =================================================================== --- trunk/scipy/sparse/linalg/tests/test_interface.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/linalg/tests/test_interface.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ """ Test functions for the sparse.linalg.interface module """ -from scipy.testing import * +from numpy.testing import * import numpy from numpy import array, matrix, ones, ravel Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/tests/test_base.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -20,7 +20,7 @@ asarray, vstack, ndarray, transpose, diag import random -from scipy.testing import * +from numpy.testing import * import scipy.sparse as sparse from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \ Modified: trunk/scipy/sparse/tests/test_construct.py =================================================================== --- trunk/scipy/sparse/tests/test_construct.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/tests/test_construct.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ import numpy from numpy import array, matrix -from scipy.testing import * +from numpy.testing import * from scipy.sparse import csr_matrix, coo_matrix Modified: trunk/scipy/sparse/tests/test_extract.py =================================================================== --- trunk/scipy/sparse/tests/test_extract.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/tests/test_extract.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ import numpy from numpy import array, matrix -from scipy.testing import * +from numpy.testing import * from scipy.sparse import csr_matrix Modified: trunk/scipy/sparse/tests/test_spfuncs.py =================================================================== --- trunk/scipy/sparse/tests/test_spfuncs.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/tests/test_spfuncs.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ from numpy import array, kron, matrix, diag -from scipy.testing import * +from numpy.testing import * from scipy.sparse.spfuncs import * from scipy.sparse import csr_matrix, csc_matrix, bsr_matrix Modified: trunk/scipy/sparse/tests/test_sputils.py =================================================================== --- trunk/scipy/sparse/tests/test_sputils.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/sparse/tests/test_sputils.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ """unit tests for sparse utility functions""" import numpy as np -from scipy.testing import * +from numpy.testing import * from scipy.sparse.sputils import * Modified: trunk/scipy/special/__init__.py =================================================================== --- trunk/scipy/special/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/special/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -19,5 +19,5 @@ register_func('i0',i0) del register_func -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/special/tests/test_basic.py =================================================================== --- trunk/scipy/special/tests/test_basic.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/special/tests/test_basic.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -34,7 +34,7 @@ from numpy import dot, array -from scipy.testing import * +from numpy.testing import * from scipy.special import * import scipy.special._cephes as cephes Modified: trunk/scipy/special/tests/test_spfun_stats.py =================================================================== --- trunk/scipy/special/tests/test_spfun_stats.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/special/tests/test_spfun_stats.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ import numpy as N -from scipy.testing import * +from numpy.testing import * from scipy.special import gammaln, multigammaln Modified: trunk/scipy/stats/__init__.py =================================================================== --- trunk/scipy/stats/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -11,5 +11,5 @@ from kde import gaussian_kde __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/stats/models/__init__.py =================================================================== --- trunk/scipy/stats/models/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -16,5 +16,5 @@ __all__ = filter(lambda s:not s.startswith('_'),dir()) -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/stats/models/tests/test_bspline.py =================================================================== --- trunk/scipy/stats/models/tests/test_bspline.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_bspline.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ """ import numpy as N -from scipy.testing import * +from numpy.testing import * import scipy.stats.models as S try: Modified: trunk/scipy/stats/models/tests/test_formula.py =================================================================== --- trunk/scipy/stats/models/tests/test_formula.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_formula.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,7 +7,7 @@ import numpy as N import numpy.random as R import numpy.linalg as L -from scipy.testing import * +from numpy.testing import * from scipy.stats.models import utils, formula, contrast Modified: trunk/scipy/stats/models/tests/test_glm.py =================================================================== --- trunk/scipy/stats/models/tests/test_glm.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_glm.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import numpy as N import numpy.random as R -from scipy.testing import * +from numpy.testing import * import scipy.stats.models as S import scipy.stats.models.glm as models Modified: trunk/scipy/stats/models/tests/test_regression.py =================================================================== --- trunk/scipy/stats/models/tests/test_regression.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_regression.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ """ from numpy.random import standard_normal -from scipy.testing import * +from numpy.testing import * from scipy.stats.models.regression import OLSModel, ARModel Modified: trunk/scipy/stats/models/tests/test_rlm.py =================================================================== --- trunk/scipy/stats/models/tests/test_rlm.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_rlm.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ """ import numpy.random as R -from scipy.testing import * +from numpy.testing import * import scipy.stats.models.rlm as models Modified: trunk/scipy/stats/models/tests/test_scale.py =================================================================== --- trunk/scipy/stats/models/tests/test_scale.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_scale.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -3,7 +3,7 @@ """ import numpy.random as R -from scipy.testing import * +from numpy.testing import * import scipy.stats.models.robust.scale as scale Modified: trunk/scipy/stats/models/tests/test_utils.py =================================================================== --- trunk/scipy/stats/models/tests/test_utils.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/models/tests/test_utils.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import numpy as N import numpy.random as R -from scipy.testing import * +from numpy.testing import * from scipy.stats.models import utils Modified: trunk/scipy/stats/morestats.py =================================================================== --- trunk/scipy/stats/morestats.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/morestats.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -17,7 +17,7 @@ import scipy.special as special import futil import numpy as sb -from scipy.testing.decorators import setastest +from numpy.testing.decorators import setastest __all__ = ['find_repeats', 'bayes_mvs', 'kstat', 'kstatvar', 'probplot', 'ppcc_max', 'ppcc_plot', Modified: trunk/scipy/stats/tests/test_distributions.py =================================================================== --- trunk/scipy/stats/tests/test_distributions.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/tests/test_distributions.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ """ -from scipy.testing import * +from numpy.testing import * import numpy Modified: trunk/scipy/stats/tests/test_mmorestats.py =================================================================== --- trunk/scipy/stats/tests/test_mmorestats.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/tests/test_mmorestats.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -14,7 +14,7 @@ import scipy.stats.mstats as ms import scipy.stats.mmorestats as mms -from scipy.testing import * +from numpy.testing import * class TestMisc(TestCase): Modified: trunk/scipy/stats/tests/test_morestats.py =================================================================== --- trunk/scipy/stats/tests/test_morestats.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/tests/test_morestats.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ # Author: Travis Oliphant, 2002 # -from scipy.testing import * +from numpy.testing import * import scipy.stats as stats Modified: trunk/scipy/stats/tests/test_mstats.py =================================================================== --- trunk/scipy/stats/tests/test_mstats.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/tests/test_mstats.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -9,7 +9,7 @@ from numpy.ma import masked, nomask import scipy.stats.mstats as mstats -from scipy.testing import * +from numpy.testing import * from numpy.ma.testutils import assert_equal, assert_almost_equal, \ assert_array_almost_equal Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/stats/tests/test_stats.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -7,7 +7,7 @@ """ import sys -from scipy.testing import * +from numpy.testing import * from numpy import array, arange, zeros, ravel, float32, float64, power import numpy Modified: trunk/scipy/weave/__init__.py =================================================================== --- trunk/scipy/weave/__init__.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/__init__.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -18,5 +18,5 @@ except: pass -from scipy.testing.pkgtester import Tester +from numpy.testing import Tester test = Tester().test Modified: trunk/scipy/weave/tests/test_ast_tools.py =================================================================== --- trunk/scipy/weave/tests/test_ast_tools.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_ast_tools.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,4 +1,4 @@ -from scipy.testing import * +from numpy.testing import * from scipy.weave import ast_tools Modified: trunk/scipy/weave/tests/test_blitz_tools.py =================================================================== --- trunk/scipy/weave/tests/test_blitz_tools.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_blitz_tools.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ from numpy import dot, float32, float64, complex64, complex128, \ zeros, random, array, sum, abs, allclose -from scipy.testing import * +from numpy.testing import * from scipy.weave import blitz_tools from scipy.weave.ast_tools import harvest_variables Modified: trunk/scipy/weave/tests/test_build_tools.py =================================================================== --- trunk/scipy/weave/tests/test_build_tools.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_build_tools.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import os, sys, tempfile -from scipy.testing import * +from numpy.testing import * from scipy.weave import build_tools Modified: trunk/scipy/weave/tests/test_c_spec.py =================================================================== --- trunk/scipy/weave/tests/test_c_spec.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_c_spec.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -9,7 +9,7 @@ global test_dir test_dir = '' -from scipy.testing import * +from numpy.testing import * from scipy.weave import inline_tools,ext_tools,c_spec from scipy.weave.build_tools import msvc_exists, gcc_exists Modified: trunk/scipy/weave/tests/test_catalog.py =================================================================== --- trunk/scipy/weave/tests/test_catalog.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_catalog.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -2,7 +2,7 @@ import os -from scipy.testing import * +from numpy.testing import * from scipy.weave import catalog Modified: trunk/scipy/weave/tests/test_ext_tools.py =================================================================== --- trunk/scipy/weave/tests/test_ext_tools.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_ext_tools.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ import time -from scipy.testing import * +from numpy.testing import * from scipy.weave import ext_tools, c_spec try: Modified: trunk/scipy/weave/tests/test_inline_tools.py =================================================================== --- trunk/scipy/weave/tests/test_inline_tools.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_inline_tools.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,7 +1,7 @@ from numpy import * -from scipy.testing import * +from numpy.testing import * from scipy.weave import inline_tools Modified: trunk/scipy/weave/tests/test_numpy_scalar_spec.py =================================================================== --- trunk/scipy/weave/tests/test_numpy_scalar_spec.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_numpy_scalar_spec.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -10,7 +10,7 @@ test_dir = '' import numpy -from scipy.testing import * +from numpy.testing import * from scipy.weave import inline_tools,ext_tools from scipy.weave.build_tools import msvc_exists, gcc_exists Modified: trunk/scipy/weave/tests/test_scxx.py =================================================================== --- trunk/scipy/weave/tests/test_scxx.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_scxx.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import time import os,sys -from scipy.testing import * +from numpy.testing import * set_local_path() from test_scxx_object import * from test_scxx_sequence import * Modified: trunk/scipy/weave/tests/test_scxx_dict.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_dict.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_scxx_dict.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import os import sys -from scipy.testing import * +from numpy.testing import * from scipy.weave import inline_tools Modified: trunk/scipy/weave/tests/test_scxx_object.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_object.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_scxx_object.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import os import sys -from scipy.testing import * +from numpy.testing import * from scipy.weave import inline_tools Modified: trunk/scipy/weave/tests/test_scxx_sequence.py =================================================================== --- trunk/scipy/weave/tests/test_scxx_sequence.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_scxx_sequence.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -4,7 +4,7 @@ import time import os,sys -from scipy.testing import * +from numpy.testing import * from scipy.weave import inline_tools Modified: trunk/scipy/weave/tests/test_size_check.py =================================================================== --- trunk/scipy/weave/tests/test_size_check.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_size_check.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ import os from numpy import * -from scipy.testing import * +from numpy.testing import * from scipy.weave import size_check from scipy.weave.ast_tools import * Modified: trunk/scipy/weave/tests/test_slice_handler.py =================================================================== --- trunk/scipy/weave/tests/test_slice_handler.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_slice_handler.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,5 +1,5 @@ -from scipy.testing import * +from numpy.testing import * from scipy.weave import slice_handler from scipy.weave.slice_handler import indexed_array_pattern Modified: trunk/scipy/weave/tests/test_standard_array_spec.py =================================================================== --- trunk/scipy/weave/tests/test_standard_array_spec.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_standard_array_spec.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -1,6 +1,6 @@ from numpy import * -from scipy.testing import * +from numpy.testing import * from scipy.weave import standard_array_spec Modified: trunk/scipy/weave/tests/test_wx_spec.py =================================================================== --- trunk/scipy/weave/tests/test_wx_spec.py 2008-07-15 12:22:24 UTC (rev 4544) +++ trunk/scipy/weave/tests/test_wx_spec.py 2008-07-16 00:26:23 UTC (rev 4545) @@ -8,7 +8,7 @@ then returned as a function return value correctly """ -from scipy.testing import * +from numpy.testing import * e = None DONOTRUN = False From scipy-svn at scipy.org Wed Jul 16 18:08:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 16 Jul 2008 17:08:53 -0500 (CDT) Subject: [Scipy-svn] r4546 - in branches: . Interpolate1D Interpolate1D/build Interpolate1D/build/lib.win32-2.5 Interpolate1D/build/src.win32-2.5 Interpolate1D/build/temp.win32-2.5 Interpolate1D/build/temp.win32-2.5/Release Interpolate1D/build/temp.win32-2.5/Release/build Message-ID: <20080716220853.4B50039C50D@scipy.org> Author: fcady Date: 2008-07-16 17:08:51 -0500 (Wed, 16 Jul 2008) New Revision: 4546 Added: branches/Interpolate1D/ branches/Interpolate1D/build/ branches/Interpolate1D/build/lib.win32-2.5/ branches/Interpolate1D/build/lib.win32-2.5/_interpolate.pyd branches/Interpolate1D/build/src.win32-2.5/ branches/Interpolate1D/build/src.win32-2.5/dfitpack-f2pywrappers.f branches/Interpolate1D/build/src.win32-2.5/dfitpackmodule.c branches/Interpolate1D/build/src.win32-2.5/fitpack.pyf branches/Interpolate1D/build/src.win32-2.5/fortranobject.c branches/Interpolate1D/build/src.win32-2.5/fortranobject.h branches/Interpolate1D/build/temp.win32-2.5/ branches/Interpolate1D/build/temp.win32-2.5/Release/ branches/Interpolate1D/build/temp.win32-2.5/Release/build/ branches/Interpolate1D/build/temp.win32-2.5/Release/build/src.win32-2.5/ branches/Interpolate1D/dfitpack.py branches/Interpolate1D/dfitpack.pyd Removed: branches/interpolate2/ Log: wrapped most functionality of enthought.interpolate in _interpolate.c_module wrapper most functionality of scipy.interpolate in fitpack_module combined functionalities in Interpolate1D module, on which I am currently working. still VERY much a work in progress. But code works for basic purposes, and there is some unit testing included. Added: branches/Interpolate1D/build/lib.win32-2.5/_interpolate.pyd =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/build/lib.win32-2.5/_interpolate.pyd ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/build/src.win32-2.5/dfitpack-f2pywrappers.f =================================================================== --- branches/Interpolate1D/build/src.win32-2.5/dfitpack-f2pywrappers.f 2008-07-16 00:26:23 UTC (rev 4545) +++ branches/Interpolate1D/build/src.win32-2.5/dfitpack-f2pywrappers.f 2008-07-16 22:08:51 UTC (rev 4546) @@ -0,0 +1,39 @@ +C -*- fortran -*- +C This file is autogenerated with f2py (version:2_4422) +C It contains Fortran 77 wrappers to fortran functions. + + subroutine f2pywrapsplint (splintf2pywrap, t, n, c, k, a, b, + & wrk) + external splint + integer n + integer k + real*8 a + real*8 b + real*8 t(n) + real*8 c(n) + real*8 wrk(n) + real*8 splintf2pywrap, splint + splintf2pywrap = splint(t, n, c, k, a, b, wrk) + end + + + subroutine f2pywrapdblint (dblintf2pywrap, tx, nx, ty, ny, c + &, kx, ky, xb, xe, yb, ye, wrk) + external dblint + integer nx + integer ny + integer kx + integer ky + real*8 xb + real*8 xe + real*8 yb + real*8 ye + real*8 tx(nx) + real*8 ty(ny) + real*8 c((nx-kx-1)*(ny-ky-1)) + real*8 wrk(nx+ny-kx-ky-2) + real*8 dblintf2pywrap, dblint + dblintf2pywrap = dblint(tx, nx, ty, ny, c, kx, ky, xb, xe, y + &b, ye, wrk) + end + Added: branches/Interpolate1D/build/src.win32-2.5/dfitpackmodule.c =================================================================== --- branches/Interpolate1D/build/src.win32-2.5/dfitpackmodule.c 2008-07-16 00:26:23 UTC (rev 4545) +++ branches/Interpolate1D/build/src.win32-2.5/dfitpackmodule.c 2008-07-16 22:08:51 UTC (rev 4546) @@ -0,0 +1,4809 @@ +/* File: dfitpackmodule.c + * This file is auto-generated with f2py (version:2_4422). + * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, + * written by Pearu Peterson . + * See http://cens.ioc.ee/projects/f2py2e/ + * Generation date: Tue Jul 15 14:23:30 2008 + * $Revision:$ + * $Date:$ + * Do not edit this file directly unless you know what you are doing!!! + */ +#ifdef __cplusplus +extern "C" { +#endif + +/*********************** See f2py2e/cfuncs.py: includes ***********************/ +#include "Python.h" +#include "fortranobject.h" +#include + +/**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/ +static PyObject *dfitpack_error; +static PyObject *dfitpack_module; + +/*********************** See f2py2e/cfuncs.py: typedefs ***********************/ +/*need_typedefs*/ + +/****************** See f2py2e/cfuncs.py: typedefs_generated ******************/ +/*need_typedefs_generated*/ + +/********************** See f2py2e/cfuncs.py: cppmacros **********************/ +#if defined(PREPEND_FORTRAN) +#if defined(NO_APPEND_FORTRAN) +#if defined(UPPERCASE_FORTRAN) +#define F_FUNC(f,F) _##F +#else +#define F_FUNC(f,F) _##f +#endif +#else +#if defined(UPPERCASE_FORTRAN) +#define F_FUNC(f,F) _##F##_ +#else +#define F_FUNC(f,F) _##f##_ +#endif +#endif +#else +#if defined(NO_APPEND_FORTRAN) +#if defined(UPPERCASE_FORTRAN) +#define F_FUNC(f,F) F +#else +#define F_FUNC(f,F) f +#endif +#else +#if defined(UPPERCASE_FORTRAN) +#define F_FUNC(f,F) F##_ +#else +#define F_FUNC(f,F) f##_ +#endif +#endif +#endif +#if defined(UNDERSCORE_G77) +#define F_FUNC_US(f,F) F_FUNC(f##_,F##_) +#else +#define F_FUNC_US(f,F) F_FUNC(f,F) +#endif + +#define rank(var) var ## _Rank +#define shape(var,dim) var ## _Dims[dim] +#define old_rank(var) (((PyArrayObject *)(capi_ ## var ## _tmp))->nd) +#define old_shape(var,dim) (((PyArrayObject *)(capi_ ## var ## _tmp))->dimensions[dim]) +#define fshape(var,dim) shape(var,rank(var)-dim-1) +#define len(var) shape(var,0) +#define flen(var) fshape(var,0) +#define size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp)) +/* #define index(i) capi_i ## i */ +#define slen(var) capi_ ## var ## _len + +#define CHECKARRAY(check,tcheck,name) \ + if (!(check)) {\ + PyErr_SetString(dfitpack_error,"("tcheck") failed for "name);\ + /*goto capi_fail;*/\ + } else +#ifdef DEBUGCFUNCS +#define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess); +#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \ + PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ + fprintf(stderr,"\n"); +#else +#define CFUNCSMESS(mess) +#define CFUNCSMESSPY(mess,obj) +#endif + +#ifndef MAX +#define MAX(a,b) ((a > b) ? (a) : (b)) +#endif +#ifndef MIN +#define MIN(a,b) ((a < b) ? (a) : (b)) +#endif + +#define CHECKSCALAR(check,tcheck,name,show,var)\ + if (!(check)) {\ + PyErr_SetString(dfitpack_error,"("tcheck") failed for "name);\ + fprintf(stderr,show"\n",var);\ + /*goto capi_fail;*/\ + } else +#if defined(PREPEND_FORTRAN) +#if defined(NO_APPEND_FORTRAN) +#if defined(UPPERCASE_FORTRAN) +#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F +#else +#define F_WRAPPEDFUNC(f,F) _f2pywrap##f +#endif +#else +#if defined(UPPERCASE_FORTRAN) +#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_ +#else +#define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_ +#endif +#endif +#else +#if defined(NO_APPEND_FORTRAN) +#if defined(UPPERCASE_FORTRAN) +#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F +#else +#define F_WRAPPEDFUNC(f,F) f2pywrap##f +#endif +#else +#if defined(UPPERCASE_FORTRAN) +#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_ +#else +#define F_WRAPPEDFUNC(f,F) f2pywrap##f##_ +#endif +#endif +#endif +#if defined(UNDERSCORE_G77) +#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_) +#else +#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F) +#endif + + +/************************ See f2py2e/cfuncs.py: cfuncs ************************/ +static int int_from_pyobj(int* v,PyObject *obj,const char *errmess) { + PyObject* tmp = NULL; + if (PyInt_Check(obj)) { + *v = (int)PyInt_AS_LONG(obj); + return 1; + } + tmp = PyNumber_Int(obj); + if (tmp) { + *v = PyInt_AS_LONG(tmp); + Py_DECREF(tmp); + return 1; + } + if (PyComplex_Check(obj)) + tmp = PyObject_GetAttrString(obj,"real"); + else if (PyString_Check(obj)) + /*pass*/; + else if (PySequence_Check(obj)) + tmp = PySequence_GetItem(obj,0); + if (tmp) { + PyErr_Clear(); + if (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} + Py_DECREF(tmp); + } + { + PyObject* err = PyErr_Occurred(); + if (err==NULL) err = dfitpack_error; + PyErr_SetString(err,errmess); + } + return 0; +} + +static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) { + PyObject* tmp = NULL; + if (PyFloat_Check(obj)) { +#ifdef __sgi + *v = PyFloat_AsDouble(obj); +#else + *v = PyFloat_AS_DOUBLE(obj); +#endif + return 1; + } + tmp = PyNumber_Float(obj); + if (tmp) { +#ifdef __sgi + *v = PyFloat_AsDouble(tmp); +#else + *v = PyFloat_AS_DOUBLE(tmp); +#endif + Py_DECREF(tmp); + return 1; + } + if (PyComplex_Check(obj)) + tmp = PyObject_GetAttrString(obj,"real"); + else if (PyString_Check(obj)) + /*pass*/; + else if (PySequence_Check(obj)) + tmp = PySequence_GetItem(obj,0); + if (tmp) { + PyErr_Clear(); + if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} + Py_DECREF(tmp); + } + { + PyObject* err = PyErr_Occurred(); + if (err==NULL) err = dfitpack_error; + PyErr_SetString(err,errmess); + } + return 0; +} + +static struct { int nd;npy_intp *d;int *i,*i_tr,tr; } forcombcache; +static int initforcomb(npy_intp *dims,int nd,int tr) { + int k; + if (dims==NULL) return 0; + if (nd<0) return 0; + forcombcache.nd = nd; + forcombcache.d = dims; + forcombcache.tr = tr; + if ((forcombcache.i = (int *)malloc(sizeof(int)*nd))==NULL) return 0; + if ((forcombcache.i_tr = (int *)malloc(sizeof(int)*nd))==NULL) return 0; + for (k=1;kval) val = seq[i]; + return val; +} +static double dmin(double* seq,int len) { + double val; + int i; + if (len<1) + return 1e308; + val = seq[0]; + for(i=1;ival1) return val1; + val1 = dmax(tx,nx); + return val2 - (val1-val2)/nx; +} +static double calc_e(double* x,int m,double* tx,int nx) { + double val1 = dmax(x,m); + double val2 = dmax(tx,nx); + if (val2data); + + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 4th argument `x' of dfitpack.splev to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable m */ + m = len(x); + /* Processing variable n */ + n = len(t); + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,Py_None); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `y' of dfitpack.splev to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `c' of dfitpack.splev to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==n,"len(c)==n","2nd argument c") { +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(t,&n,c,&k,x,y,&m,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("N",capi_y_tmp); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*CHECKARRAY(len(c)==n)*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + /* End of cleaning variable n */ + /* End of cleaning variable m */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + /* End of cleaning variable ier */ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************** end of splev ********************************/ + +/*********************************** splder ***********************************/ +static char doc_f2py_rout_dfitpack_splder[] = "\ +Function signature:\n\ + y = splder(t,c,k,x,[nu])\n\ +Required arguments:\n" +" t : input rank-1 array('d') with bounds (n)\n" +" c : input rank-1 array('d') with bounds (n)\n" +" k : input int\n" +" x : input rank-1 array('d') with bounds (m)\n" +"Optional arguments:\n" +" nu := 1 input int\n" +"Return objects:\n" +" y : rank-1 array('d') with bounds (m)"; +/* extern void F_FUNC(splder,SPLDER)(double*,int*,double*,int*,int*,double*,double*,int*,double*,int*); */ +static PyObject *f2py_rout_dfitpack_splder(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(double*,int*,double*,int*,int*,double*,double*,int*,double*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + int n = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + PyObject *c_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + int nu = 0; + PyObject *nu_capi = Py_None; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + int m = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + int ier = 0; + static char *capi_kwlist[] = {"t","c","k","x","nu",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOO|O:dfitpack.splder",\ + capi_kwlist,&t_capi,&c_capi,&k_capi,&x_capi,&nu_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable k */ + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.splder() 3rd argument (k) can't be converted to int"); + if (f2py_success) { + /* Processing variable ier */ + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_IN; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `t' of dfitpack.splder to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 4th argument `x' of dfitpack.splder to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable m */ + m = len(x); + /* Processing variable n */ + n = len(t); + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,Py_None); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `y' of dfitpack.splder to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + /* Processing variable nu */ + if (nu_capi == Py_None) nu = 1; else + f2py_success = int_from_pyobj(&nu,nu_capi,"dfitpack.splder() 1st keyword (nu) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(0<=nu && nu<=k,"0<=nu && nu<=k","1st keyword nu","splder:nu=%d",nu) { + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `c' of dfitpack.splder to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==n,"len(c)==n","2nd argument c") { + /* Processing variable wrk */ + wrk_Dims[0]=n; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.splder to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(t,&n,c,&k,&nu,x,y,&m,wrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("N",capi_y_tmp); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*CHECKARRAY(len(c)==n)*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*CHECKSCALAR(0<=nu && nu<=k)*/ + } /*if (f2py_success) of nu*/ + /* End of cleaning variable nu */ + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + /* End of cleaning variable n */ + /* End of cleaning variable m */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + /* End of cleaning variable ier */ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of splder *******************************/ + +/*********************************** splint ***********************************/ +static char doc_f2py_rout_dfitpack_splint[] = "\ +Function signature:\n\ + splint = splint(t,c,k,a,b)\n\ +Required arguments:\n" +" t : input rank-1 array('d') with bounds (n)\n" +" c : input rank-1 array('d') with bounds (n)\n" +" k : input int\n" +" a : input float\n" +" b : input float\n" +"Return objects:\n" +" splint : float"; +/* extern void F_WRAPPEDFUNC(splint,SPLINT)(double*,double*,int*,double*,int*,double*,double*,double*); */ +static PyObject *f2py_rout_dfitpack_splint(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(double*,double*,int*,double*,int*,double*,double*,double*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + double splint = 0; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + int n = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + PyObject *c_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double a = 0; + PyObject *a_capi = Py_None; + double b = 0; + PyObject *b_capi = Py_None; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + static char *capi_kwlist[] = {"t","c","k","a","b",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOO|:dfitpack.splint",\ + capi_kwlist,&t_capi,&c_capi,&k_capi,&a_capi,&b_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable a */ + f2py_success = double_from_pyobj(&a,a_capi,"dfitpack.splint() 4th argument (a) can't be converted to double"); + if (f2py_success) { + /* Processing variable b */ + f2py_success = double_from_pyobj(&b,b_capi,"dfitpack.splint() 5th argument (b) can't be converted to double"); + if (f2py_success) { + /* Processing variable k */ + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.splint() 3rd argument (k) can't be converted to int"); + if (f2py_success) { + /* Processing variable splint */ + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_IN; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `t' of dfitpack.splint to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable n */ + n = len(t); + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `c' of dfitpack.splint to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==n,"len(c)==n","2nd argument c") { + /* Processing variable wrk */ + wrk_Dims[0]=n; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.splint to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&splint,t,&n,c,&k,&a,&b,wrk); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("d",splint); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*CHECKARRAY(len(c)==n)*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable n */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + /* End of cleaning variable splint */ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + } /*if (f2py_success) of b*/ + /* End of cleaning variable b */ + } /*if (f2py_success) of a*/ + /* End of cleaning variable a */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of splint *******************************/ + +/*********************************** sproot ***********************************/ +static char doc_f2py_rout_dfitpack_sproot[] = "\ +Function signature:\n\ + zero,m,ier = sproot(t,c,[mest])\n\ +Required arguments:\n" +" t : input rank-1 array('d') with bounds (n)\n" +" c : input rank-1 array('d') with bounds (n)\n" +"Optional arguments:\n" +" mest := 3*(n-7) input int\n" +"Return objects:\n" +" zero : rank-1 array('d') with bounds (mest)\n" +" m : int\n" +" ier : int"; +/* extern void F_FUNC(sproot,SPROOT)(double*,int*,double*,double*,int*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_sproot(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(double*,int*,double*,double*,int*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + int n = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + PyObject *c_capi = Py_None; + double *zero = NULL; + npy_intp zero_Dims[1] = {-1}; + const int zero_Rank = 1; + PyArrayObject *capi_zero_tmp = NULL; + int capi_zero_intent = 0; + int mest = 0; + PyObject *mest_capi = Py_None; + int m = 0; + int ier = 0; + static char *capi_kwlist[] = {"t","c","mest",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OO|O:dfitpack.sproot",\ + capi_kwlist,&t_capi,&c_capi,&mest_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_IN; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `t' of dfitpack.sproot to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable ier */ + /* Processing variable m */ + /* Processing variable n */ + n = len(t); + CHECKSCALAR(n>=8,"n>=8","hidden n","sproot:n=%d",n) { + /* Processing variable mest */ + if (mest_capi == Py_None) mest = 3*(n-7); else + f2py_success = int_from_pyobj(&mest,mest_capi,"dfitpack.sproot() 1st keyword (mest) can't be converted to int"); + if (f2py_success) { + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `c' of dfitpack.sproot to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==n,"len(c)==n","2nd argument c") { + /* Processing variable zero */ + zero_Dims[0]=mest; + capi_zero_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_zero_tmp = array_from_pyobj(PyArray_DOUBLE,zero_Dims,zero_Rank,capi_zero_intent,Py_None); + if (capi_zero_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `zero' of dfitpack.sproot to C/Fortran array" ); + } else { + zero = (double *)(capi_zero_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(t,&n,c,zero,&mest,&m,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("Nii",capi_zero_tmp,m,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*if (capi_zero_tmp == NULL) ... else of zero*/ + /* End of cleaning variable zero */ + } /*CHECKARRAY(len(c)==n)*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*if (f2py_success) of mest*/ + /* End of cleaning variable mest */ + } /*CHECKSCALAR(n>=8)*/ + /* End of cleaning variable n */ + /* End of cleaning variable m */ + /* End of cleaning variable ier */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of sproot *******************************/ + +/*********************************** spalde ***********************************/ +static char doc_f2py_rout_dfitpack_spalde[] = "\ +Function signature:\n\ + d,ier = spalde(t,c,k,x)\n\ +Required arguments:\n" +" t : input rank-1 array('d') with bounds (n)\n" +" c : input rank-1 array('d') with bounds (n)\n" +" k : input int\n" +" x : input float\n" +"Return objects:\n" +" d : rank-1 array('d') with bounds (k + 1)\n" +" ier : int"; +/* extern void F_FUNC(spalde,SPALDE)(double*,int*,double*,int*,double*,double*,int*); */ +static PyObject *f2py_rout_dfitpack_spalde(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(double*,int*,double*,int*,double*,double*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + int n = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + PyObject *c_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double x = 0; + PyObject *x_capi = Py_None; + double *d = NULL; + npy_intp d_Dims[1] = {-1}; + const int d_Rank = 1; + PyArrayObject *capi_d_tmp = NULL; + int capi_d_intent = 0; + int ier = 0; + static char *capi_kwlist[] = {"t","c","k","x",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOO|:dfitpack.spalde",\ + capi_kwlist,&t_capi,&c_capi,&k_capi,&x_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_IN; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `t' of dfitpack.spalde to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable x */ + f2py_success = double_from_pyobj(&x,x_capi,"dfitpack.spalde() 4th argument (x) can't be converted to double"); + if (f2py_success) { + /* Processing variable k */ + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.spalde() 3rd argument (k) can't be converted to int"); + if (f2py_success) { + /* Processing variable ier */ + /* Processing variable d */ + d_Dims[0]=k + 1; + capi_d_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_d_tmp = array_from_pyobj(PyArray_DOUBLE,d_Dims,d_Rank,capi_d_intent,Py_None); + if (capi_d_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `d' of dfitpack.spalde to C/Fortran array" ); + } else { + d = (double *)(capi_d_tmp->data); + + /* Processing variable n */ + n = len(t); + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `c' of dfitpack.spalde to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==n,"len(c)==n","2nd argument c") { +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + {int k1=k+1; (*f2py_func)(t,&n,c,&k1,&x,d,&ier); }; + /*(*f2py_func)(t,&n,c,&k,&x,d,&ier);*/ +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("Ni",capi_d_tmp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*CHECKARRAY(len(c)==n)*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable n */ + } /*if (capi_d_tmp == NULL) ... else of d*/ + /* End of cleaning variable d */ + /* End of cleaning variable ier */ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + } /*if (f2py_success) of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of spalde *******************************/ + +/*********************************** curfit ***********************************/ +static char doc_f2py_rout_dfitpack_curfit[] = "\ +Function signature:\n\ + n,c,fp,ier = curfit(iopt,x,y,w,t,wrk,iwrk,[xb,xe,k,s])\n\ +Required arguments:\n" +" iopt : input int\n" +" x : input rank-1 array('d') with bounds (m)\n" +" y : input rank-1 array('d') with bounds (m)\n" +" w : input rank-1 array('d') with bounds (m)\n" +" t : in/output rank-1 array('d') with bounds (nest)\n" +" wrk : in/output rank-1 array('d') with bounds (lwrk)\n" +" iwrk : in/output rank-1 array('i') with bounds (nest)\n" +"Optional arguments:\n" +" xb := x[0] input float\n" +" xe := x[m-1] input float\n" +" k := 3 input int\n" +" s := 0.0 input float\n" +"Return objects:\n" +" n : int\n" +" c : rank-1 array('d') with bounds (n)\n" +" fp : float\n" +" ier : int"; +/* extern void F_FUNC(curfit,CURFIT)(int*,int*,double*,double*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_curfit(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,int*,double*,double*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + PyObject *iopt_capi = Py_None; + int m = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + PyObject *y_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + PyObject *w_capi = Py_None; + double xb = 0; + PyObject *xb_capi = Py_None; + double xe = 0; + PyObject *xe_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double s = 0; + PyObject *s_capi = Py_None; + int nest = 0; + int n = 0; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + double fp = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + PyObject *wrk_capi = Py_None; + int lwrk = 0; + int *iwrk = NULL; + npy_intp iwrk_Dims[1] = {-1}; + const int iwrk_Rank = 1; + PyArrayObject *capi_iwrk_tmp = NULL; + int capi_iwrk_intent = 0; + PyObject *iwrk_capi = Py_None; + int ier = 0; + static char *capi_kwlist[] = {"iopt","x","y","w","t","wrk","iwrk","xb","xe","k","s",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOOOO|OOOO:dfitpack.curfit",\ + capi_kwlist,&iopt_capi,&x_capi,&y_capi,&w_capi,&t_capi,&wrk_capi,&iwrk_capi,&xb_capi,&xe_capi,&k_capi,&s_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + /* Processing variable iopt */ + f2py_success = int_from_pyobj(&iopt,iopt_capi,"dfitpack.curfit() 1st argument (iopt) can't be converted to int"); + if (f2py_success) { + /* Processing variable k */ + if (k_capi == Py_None) k = 3; else + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.curfit() 3rd keyword (k) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=k && k <=5,"1<=k && k <=5","3rd keyword k","curfit:k=%d",k) { + /* Processing variable ier */ + /* Processing variable wrk */ + ; + capi_wrk_intent |= F2PY_INTENT_INOUT; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,wrk_capi); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 6th argument `wrk' of dfitpack.curfit to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + + /* Processing variable s */ + if (s_capi == Py_None) s = 0.0; else + f2py_success = double_from_pyobj(&s,s_capi,"dfitpack.curfit() 4th keyword (s) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(s>=0.0,"s>=0.0","4th keyword s","curfit:s=%g",s) { + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_INOUT; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 5th argument `t' of dfitpack.curfit to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `x' of dfitpack.curfit to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable xb */ + if (xb_capi == Py_None) xb = x[0]; else + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.curfit() 1st keyword (xb) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(xb<=x[0],"xb<=x[0]","1st keyword xb","curfit:xb=%g",xb) { + /* Processing variable nest */ + nest = len(t); + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>k,"m>k","hidden m","curfit:m=%d",m) { + /* Processing variable lwrk */ + lwrk = len(wrk); + /* Processing variable n */ + n = nest; + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 4th argument `w' of dfitpack.curfit to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + CHECKARRAY(len(w)==m,"len(w)==m","4th argument w") { + /* Processing variable iwrk */ + iwrk_Dims[0]=nest; + capi_iwrk_intent |= F2PY_INTENT_INOUT; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,iwrk_capi); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 7th argument `iwrk' of dfitpack.curfit to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `y' of dfitpack.curfit to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","3rd argument y") { + /* Processing variable xe */ + if (xe_capi == Py_None) xe = x[m-1]; else + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.curfit() 2nd keyword (xe) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(xe>=x[m-1],"xe>=x[m-1]","2nd keyword xe","curfit:xe=%g",xe) { + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.curfit to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,&m,x,y,w,&xb,&xe,&k,&s,&nest,&n,t,c,&fp,wrk,&lwrk,iwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("iNdi",n,capi_c_tmp,fp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*CHECKSCALAR(xe>=x[m-1])*/ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*CHECKARRAY(len(y)==m)*/ + if((PyObject *)capi_y_tmp!=y_capi) { + Py_XDECREF(capi_y_tmp); } + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + if((PyObject *)capi_iwrk_tmp!=iwrk_capi) { + Py_XDECREF(capi_iwrk_tmp); } + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + } /*CHECKARRAY(len(w)==m)*/ + if((PyObject *)capi_w_tmp!=w_capi) { + Py_XDECREF(capi_w_tmp); } + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + /* End of cleaning variable n */ + /* End of cleaning variable lwrk */ + } /*CHECKSCALAR(m>k)*/ + /* End of cleaning variable m */ + /* End of cleaning variable nest */ + } /*CHECKSCALAR(xb<=x[0])*/ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + } /*CHECKSCALAR(s>=0.0)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + if((PyObject *)capi_wrk_tmp!=wrk_capi) { + Py_XDECREF(capi_wrk_tmp); } + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + /* End of cleaning variable ier */ + } /*CHECKSCALAR(1<=k && k <=5)*/ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + } /*if (f2py_success) of iopt*/ + /* End of cleaning variable iopt */ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of curfit *******************************/ + +/*********************************** percur ***********************************/ +static char doc_f2py_rout_dfitpack_percur[] = "\ +Function signature:\n\ + n,c,fp,ier = percur(iopt,x,y,w,t,wrk,iwrk,[k,s])\n\ +Required arguments:\n" +" iopt : input int\n" +" x : input rank-1 array('d') with bounds (m)\n" +" y : input rank-1 array('d') with bounds (m)\n" +" w : input rank-1 array('d') with bounds (m)\n" +" t : in/output rank-1 array('d') with bounds (nest)\n" +" wrk : in/output rank-1 array('d') with bounds (lwrk)\n" +" iwrk : in/output rank-1 array('i') with bounds (nest)\n" +"Optional arguments:\n" +" k := 3 input int\n" +" s := 0.0 input float\n" +"Return objects:\n" +" n : int\n" +" c : rank-1 array('d') with bounds (n)\n" +" fp : float\n" +" ier : int"; +/* extern void F_FUNC(percur,PERCUR)(int*,int*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_percur(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,int*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + PyObject *iopt_capi = Py_None; + int m = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + PyObject *y_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + PyObject *w_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double s = 0; + PyObject *s_capi = Py_None; + int nest = 0; + int n = 0; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + double fp = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + PyObject *wrk_capi = Py_None; + int lwrk = 0; + int *iwrk = NULL; + npy_intp iwrk_Dims[1] = {-1}; + const int iwrk_Rank = 1; + PyArrayObject *capi_iwrk_tmp = NULL; + int capi_iwrk_intent = 0; + PyObject *iwrk_capi = Py_None; + int ier = 0; + static char *capi_kwlist[] = {"iopt","x","y","w","t","wrk","iwrk","k","s",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOOOO|OO:dfitpack.percur",\ + capi_kwlist,&iopt_capi,&x_capi,&y_capi,&w_capi,&t_capi,&wrk_capi,&iwrk_capi,&k_capi,&s_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + /* Processing variable iopt */ + f2py_success = int_from_pyobj(&iopt,iopt_capi,"dfitpack.percur() 1st argument (iopt) can't be converted to int"); + if (f2py_success) { + /* Processing variable k */ + if (k_capi == Py_None) k = 3; else + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.percur() 1st keyword (k) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=k && k <=5,"1<=k && k <=5","1st keyword k","percur:k=%d",k) { + /* Processing variable ier */ + /* Processing variable wrk */ + ; + capi_wrk_intent |= F2PY_INTENT_INOUT; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,wrk_capi); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 6th argument `wrk' of dfitpack.percur to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + + /* Processing variable s */ + if (s_capi == Py_None) s = 0.0; else + f2py_success = double_from_pyobj(&s,s_capi,"dfitpack.percur() 2nd keyword (s) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(s>=0.0,"s>=0.0","2nd keyword s","percur:s=%g",s) { + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_INOUT; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 5th argument `t' of dfitpack.percur to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `x' of dfitpack.percur to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable nest */ + nest = len(t); + /* Processing variable iwrk */ + iwrk_Dims[0]=nest; + capi_iwrk_intent |= F2PY_INTENT_INOUT; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,iwrk_capi); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 7th argument `iwrk' of dfitpack.percur to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>k,"m>k","hidden m","percur:m=%d",m) { + /* Processing variable lwrk */ + lwrk = len(wrk); + /* Processing variable n */ + n = nest; + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 4th argument `w' of dfitpack.percur to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + CHECKARRAY(len(w)==m,"len(w)==m","4th argument w") { + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `y' of dfitpack.percur to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","3rd argument y") { + /* Processing variable c */ + c_Dims[0]=n; + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.percur to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,&m,x,y,w,&k,&s,&nest,&n,t,c,&fp,wrk,&lwrk,iwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("iNdi",n,capi_c_tmp,fp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*CHECKARRAY(len(y)==m)*/ + if((PyObject *)capi_y_tmp!=y_capi) { + Py_XDECREF(capi_y_tmp); } + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + } /*CHECKARRAY(len(w)==m)*/ + if((PyObject *)capi_w_tmp!=w_capi) { + Py_XDECREF(capi_w_tmp); } + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + /* End of cleaning variable n */ + /* End of cleaning variable lwrk */ + } /*CHECKSCALAR(m>k)*/ + /* End of cleaning variable m */ + if((PyObject *)capi_iwrk_tmp!=iwrk_capi) { + Py_XDECREF(capi_iwrk_tmp); } + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + /* End of cleaning variable nest */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + } /*CHECKSCALAR(s>=0.0)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + if((PyObject *)capi_wrk_tmp!=wrk_capi) { + Py_XDECREF(capi_wrk_tmp); } + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + /* End of cleaning variable ier */ + } /*CHECKSCALAR(1<=k && k <=5)*/ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + } /*if (f2py_success) of iopt*/ + /* End of cleaning variable iopt */ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of percur *******************************/ + +/*********************************** parcur ***********************************/ +static char doc_f2py_rout_dfitpack_parcur[] = "\ +Function signature:\n\ + n,c,fp,ier = parcur(iopt,ipar,idim,u,x,w,ub,ue,t,wrk,iwrk,[k,s])\n\ +Required arguments:\n" +" iopt : input int\n" +" ipar : input int\n" +" idim : input int\n" +" u : in/output rank-1 array('d') with bounds (m)\n" +" x : input rank-1 array('d') with bounds (mx)\n" +" w : input rank-1 array('d') with bounds (m)\n" +" ub : input float\n" +" ue : input float\n" +" t : in/output rank-1 array('d') with bounds (nest)\n" +" wrk : in/output rank-1 array('d') with bounds (lwrk)\n" +" iwrk : in/output rank-1 array('i') with bounds (nest)\n" +"Optional arguments:\n" +" k := 3.0 input int\n" +" s := 0.0 input float\n" +"Return objects:\n" +" n : int\n" +" c : rank-1 array('d') with bounds (nc)\n" +" fp : float\n" +" ier : int"; +/* extern void F_FUNC(parcur,PARCUR)(int*,int*,int*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,double*,int*,double*,double*,double*,int*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_parcur(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,int*,int*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,double*,int*,double*,double*,double*,int*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + PyObject *iopt_capi = Py_None; + int ipar = 0; + PyObject *ipar_capi = Py_None; + int idim = 0; + PyObject *idim_capi = Py_None; + int m = 0; + double *u = NULL; + npy_intp u_Dims[1] = {-1}; + const int u_Rank = 1; + PyArrayObject *capi_u_tmp = NULL; + int capi_u_intent = 0; + PyObject *u_capi = Py_None; + int mx = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + PyObject *w_capi = Py_None; + double ub = 0; + PyObject *ub_capi = Py_None; + double ue = 0; + PyObject *ue_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double s = 0; + PyObject *s_capi = Py_None; + int nest = 0; + int n = 0; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + PyObject *t_capi = Py_None; + int nc = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + double fp = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + PyObject *wrk_capi = Py_None; + int lwrk = 0; + int *iwrk = NULL; + npy_intp iwrk_Dims[1] = {-1}; + const int iwrk_Rank = 1; + PyArrayObject *capi_iwrk_tmp = NULL; + int capi_iwrk_intent = 0; + PyObject *iwrk_capi = Py_None; + int ier = 0; + static char *capi_kwlist[] = {"iopt","ipar","idim","u","x","w","ub","ue","t","wrk","iwrk","k","s",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOOOOOOOO|OO:dfitpack.parcur",\ + capi_kwlist,&iopt_capi,&ipar_capi,&idim_capi,&u_capi,&x_capi,&w_capi,&ub_capi,&ue_capi,&t_capi,&wrk_capi,&iwrk_capi,&k_capi,&s_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + /* Processing variable ier */ + /* Processing variable iopt */ + f2py_success = int_from_pyobj(&iopt,iopt_capi,"dfitpack.parcur() 1st argument (iopt) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(iopt>=-1 && iopt <= 1,"iopt>=-1 && iopt <= 1","1st argument iopt","parcur:iopt=%d",iopt) { + /* Processing variable c */ + ; + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.parcur to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + /* Processing variable k */ + if (k_capi == Py_None) k = 3.0; else + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.parcur() 1st keyword (k) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=k && k<=5,"1<=k && k<=5","1st keyword k","parcur:k=%d",k) { + /* Processing variable wrk */ + ; + capi_wrk_intent |= F2PY_INTENT_INOUT; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,wrk_capi); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 10th argument `wrk' of dfitpack.parcur to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + + /* Processing variable s */ + if (s_capi == Py_None) s = 0.0; else + f2py_success = double_from_pyobj(&s,s_capi,"dfitpack.parcur() 2nd keyword (s) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(s>=0.0,"s>=0.0","2nd keyword s","parcur:s=%g",s) { + /* Processing variable u */ + ; + capi_u_intent |= F2PY_INTENT_INOUT; + capi_u_tmp = array_from_pyobj(PyArray_DOUBLE,u_Dims,u_Rank,capi_u_intent,u_capi); + if (capi_u_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 4th argument `u' of dfitpack.parcur to C/Fortran array" ); + } else { + u = (double *)(capi_u_tmp->data); + + /* Processing variable idim */ + f2py_success = int_from_pyobj(&idim,idim_capi,"dfitpack.parcur() 3rd argument (idim) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(idim > 0 && idim < 11,"idim > 0 && idim < 11","3rd argument idim","parcur:idim=%d",idim) { + /* Processing variable ipar */ + f2py_success = int_from_pyobj(&ipar,ipar_capi,"dfitpack.parcur() 2nd argument (ipar) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(ipar == 1 || ipar == 0,"ipar == 1 || ipar == 0","2nd argument ipar","parcur:ipar=%d",ipar) { + /* Processing variable ue */ + f2py_success = double_from_pyobj(&ue,ue_capi,"dfitpack.parcur() 8th argument (ue) can't be converted to double"); + if (f2py_success) { + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 5th argument `x' of dfitpack.parcur to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable ub */ + f2py_success = double_from_pyobj(&ub,ub_capi,"dfitpack.parcur() 7th argument (ub) can't be converted to double"); + if (f2py_success) { + /* Processing variable t */ + ; + capi_t_intent |= F2PY_INTENT_INOUT; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 9th argument `t' of dfitpack.parcur to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable nest */ + nest = len(t); + /* Processing variable iwrk */ + iwrk_Dims[0]=nest; + capi_iwrk_intent |= F2PY_INTENT_INOUT; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,iwrk_capi); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 11st argument `iwrk' of dfitpack.parcur to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + + /* Processing variable nc */ + nc = len(c); + CHECKSCALAR(nc>=idim*nest,"nc>=idim*nest","hidden nc","parcur:nc=%d",nc) { + /* Processing variable m */ + m = len(u); + CHECKSCALAR(m>k,"m>k","hidden m","parcur:m=%d",m) { + /* Processing variable lwrk */ + lwrk = len(wrk); + /* Processing variable n */ + n = nest; + /* Processing variable mx */ + mx = len(x); + CHECKSCALAR(mx>=idim*m,"mx>=idim*m","hidden mx","parcur:mx=%d",mx) { + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 6th argument `w' of dfitpack.parcur to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,&ipar,&idim,&m,u,&mx,x,w,&ub,&ue,&k,&s,&nest,&n,t,&nc,c,&fp,wrk,&lwrk,iwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("iNdi",n,capi_c_tmp,fp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + if((PyObject *)capi_w_tmp!=w_capi) { + Py_XDECREF(capi_w_tmp); } + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + } /*CHECKSCALAR(mx>=idim*m)*/ + /* End of cleaning variable mx */ + /* End of cleaning variable n */ + /* End of cleaning variable lwrk */ + } /*CHECKSCALAR(m>k)*/ + /* End of cleaning variable m */ + } /*CHECKSCALAR(nc>=idim*nest)*/ + /* End of cleaning variable nc */ + if((PyObject *)capi_iwrk_tmp!=iwrk_capi) { + Py_XDECREF(capi_iwrk_tmp); } + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + /* End of cleaning variable nest */ + if((PyObject *)capi_t_tmp!=t_capi) { + Py_XDECREF(capi_t_tmp); } + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + } /*if (f2py_success) of ub*/ + /* End of cleaning variable ub */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + } /*if (f2py_success) of ue*/ + /* End of cleaning variable ue */ + } /*CHECKSCALAR(ipar == 1 || ipar == 0)*/ + } /*if (f2py_success) of ipar*/ + /* End of cleaning variable ipar */ + } /*CHECKSCALAR(idim > 0 && idim < 11)*/ + } /*if (f2py_success) of idim*/ + /* End of cleaning variable idim */ + if((PyObject *)capi_u_tmp!=u_capi) { + Py_XDECREF(capi_u_tmp); } + } /*if (capi_u_tmp == NULL) ... else of u*/ + /* End of cleaning variable u */ + } /*CHECKSCALAR(s>=0.0)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + if((PyObject *)capi_wrk_tmp!=wrk_capi) { + Py_XDECREF(capi_wrk_tmp); } + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*CHECKSCALAR(1<=k && k<=5)*/ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*CHECKSCALAR(iopt>=-1 && iopt <= 1)*/ + } /*if (f2py_success) of iopt*/ + /* End of cleaning variable iopt */ + /* End of cleaning variable ier */ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of parcur *******************************/ + +/********************************** fpcurf0 **********************************/ +static char doc_f2py_rout_dfitpack_fpcurf0[] = "\ +Function signature:\n\ + x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = fpcurf0(x,y,k,[w,xb,xe,s,nest])\n\ +Required arguments:\n" +" x : input rank-1 array('d') with bounds (m)\n" +" y : input rank-1 array('d') with bounds (m)\n" +" k : input int\n" +"Optional arguments:\n" +" w := 1.0 input rank-1 array('d') with bounds (m)\n" +" xb := x[0] input float\n" +" xe := x[m-1] input float\n" +" s := m input float\n" +" nest := (s==0.0?m+k+1:MAX(m/2,2*k1)) input int\n" +"Return objects:\n" +" x : rank-1 array('d') with bounds (m)\n" +" y : rank-1 array('d') with bounds (m)\n" +" w : rank-1 array('d') with bounds (m)\n" +" xb : float\n" +" xe : float\n" +" k : int\n" +" s : float\n" +" n : int\n" +" t : rank-1 array('d') with bounds (nest)\n" +" c : rank-1 array('d') with bounds (nest)\n" +" fp : float\n" +" fpint : rank-1 array('d') with bounds (nest)\n" +" nrdata : rank-1 array('i') with bounds (nest)\n" +" ier : int"; +/* extern void F_FUNC(fpcurf,FPCURF)(int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_fpcurf0(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + PyObject *y_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + PyObject *w_capi = Py_None; + int m = 0; + double xb = 0; + PyObject *xb_capi = Py_None; + double xe = 0; + PyObject *xe_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double s = 0; + PyObject *s_capi = Py_None; + int nest = 0; + PyObject *nest_capi = Py_None; + double tol = 0; + int maxit = 0; + int k1 = 0; + int k2 = 0; + int n = 0; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + double fp = 0; + double *fpint = NULL; + npy_intp fpint_Dims[1] = {-1}; + const int fpint_Rank = 1; + PyArrayObject *capi_fpint_tmp = NULL; + int capi_fpint_intent = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + int *nrdata = NULL; + npy_intp nrdata_Dims[1] = {-1}; + const int nrdata_Rank = 1; + PyArrayObject *capi_nrdata_tmp = NULL; + int capi_nrdata_intent = 0; + int ier = 0; + static char *capi_kwlist[] = {"x","y","k","w","xb","xe","s","nest",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOO|OOOOO:dfitpack.fpcurf0",\ + capi_kwlist,&x_capi,&y_capi,&k_capi,&w_capi,&xb_capi,&xe_capi,&s_capi,&nest_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + /* Processing variable maxit */ + maxit = 20; + /* Processing variable k */ + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.fpcurf0() 3rd argument (k) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=k && k<=5,"1<=k && k<=5","3rd argument k","fpcurf0:k=%d",k) { + /* Processing variable ier */ + /* Processing variable n */ + /* Processing variable tol */ + tol = 0.001; + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `x' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable iopt */ + iopt = 0; + /* Processing variable xb */ + if (xb_capi == Py_None) xb = x[0]; else + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.fpcurf0() 2nd keyword (xb) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(xb<=x[0],"xb<=x[0]","2nd keyword xb","fpcurf0:xb=%g",xb) { + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>k,"m>k","hidden m","fpcurf0:m=%d",m) { + /* Processing variable k2 */ + k2 = k+2; + /* Processing variable k1 */ + k1 = k+1; + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `y' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","2nd argument y") { + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL|F2PY_INTENT_OUT; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st keyword `w' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + if (w_capi == Py_None) { + + + int *_i,capi_i=0; + CFUNCSMESS("fpcurf0: Initializing w=1.0\n"); + if (initforcomb(capi_w_tmp->dimensions,capi_w_tmp->nd,1)) { + while ((_i = nextforcomb())) + w[capi_i++] = 1.0; /* fortran way */ + } else { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"Initialization of 1st keyword w failed (initforcomb)."); + f2py_success = 0; + } + } + if (f2py_success) { + CHECKARRAY(len(w)==m,"len(w)==m","1st keyword w") { + /* Processing variable s */ + if (s_capi == Py_None) s = m; else + f2py_success = double_from_pyobj(&s,s_capi,"dfitpack.fpcurf0() 4th keyword (s) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(s>=0.0,"s>=0.0","4th keyword s","fpcurf0:s=%g",s) { + /* Processing variable nest */ + if (nest_capi == Py_None) nest = (s==0.0?m+k+1:MAX(m/2,2*k1)); else + f2py_success = int_from_pyobj(&nest,nest_capi,"dfitpack.fpcurf0() 5th keyword (nest) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(nest>=2*k1,"nest>=2*k1","5th keyword nest","fpcurf0:nest=%d",nest) { + /* Processing variable xe */ + if (xe_capi == Py_None) xe = x[m-1]; else + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.fpcurf0() 3rd keyword (xe) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(xe>=x[m-1],"xe>=x[m-1]","3rd keyword xe","fpcurf0:xe=%g",xe) { + /* Processing variable nrdata */ + nrdata_Dims[0]=nest; + capi_nrdata_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_nrdata_tmp = array_from_pyobj(PyArray_INT,nrdata_Dims,nrdata_Rank,capi_nrdata_intent,Py_None); + if (capi_nrdata_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `nrdata' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + nrdata = (int *)(capi_nrdata_tmp->data); + + /* Processing variable fpint */ + fpint_Dims[0]=nest; + capi_fpint_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_fpint_tmp = array_from_pyobj(PyArray_DOUBLE,fpint_Dims,fpint_Rank,capi_fpint_intent,Py_None); + if (capi_fpint_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `fpint' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + fpint = (double *)(capi_fpint_tmp->data); + + /* Processing variable c */ + c_Dims[0]=nest; + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + /* Processing variable wrk */ + wrk_Dims[0]=nest*3*k2+m*k1; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + + /* Processing variable t */ + t_Dims[0]=nest; + capi_t_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,Py_None); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `t' of dfitpack.fpcurf0 to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier); + /*(*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,nrdata,&ier);*/ +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("NNNddidiNNdNNi",capi_x_tmp,capi_y_tmp,capi_w_tmp,xb,xe,k,s,n,capi_t_tmp,capi_c_tmp,fp,capi_fpint_tmp,capi_nrdata_tmp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*if (capi_fpint_tmp == NULL) ... else of fpint*/ + /* End of cleaning variable fpint */ + } /*if (capi_nrdata_tmp == NULL) ... else of nrdata*/ + /* End of cleaning variable nrdata */ + } /*CHECKSCALAR(xe>=x[m-1])*/ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*CHECKSCALAR(nest>=2*k1)*/ + } /*if (f2py_success) of nest*/ + /* End of cleaning variable nest */ + } /*CHECKSCALAR(s>=0.0)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + } /*CHECKARRAY(len(w)==m)*/ + } /*if (f2py_success) of w init*/ + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + } /*CHECKARRAY(len(y)==m)*/ + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + /* End of cleaning variable k1 */ + /* End of cleaning variable k2 */ + } /*CHECKSCALAR(m>k)*/ + /* End of cleaning variable m */ + } /*CHECKSCALAR(xb<=x[0])*/ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + /* End of cleaning variable iopt */ + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + /* End of cleaning variable tol */ + /* End of cleaning variable n */ + /* End of cleaning variable ier */ + } /*CHECKSCALAR(1<=k && k<=5)*/ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + /* End of cleaning variable maxit */ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of fpcurf0 *******************************/ + +/********************************** fpcurf1 **********************************/ +static char doc_f2py_rout_dfitpack_fpcurf1[] = "\ +Function signature:\n\ + x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = fpcurf1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier,[overwrite_x,overwrite_y,overwrite_w,overwrite_t,overwrite_c,overwrite_fpint,overwrite_nrdata])\n\ +Required arguments:\n" +" x : input rank-1 array('d') with bounds (m)\n" +" y : input rank-1 array('d') with bounds (m)\n" +" w : input rank-1 array('d') with bounds (m)\n" +" xb : input float\n" +" xe : input float\n" +" k : input int\n" +" s : input float\n" +" n : input int\n" +" t : input rank-1 array('d') with bounds (nest)\n" +" c : input rank-1 array('d') with bounds (nest)\n" +" fp : input float\n" +" fpint : input rank-1 array('d') with bounds (nest)\n" +" nrdata : input rank-1 array('i') with bounds (nest)\n" +" ier : input int\n" +"Optional arguments:\n" +" overwrite_x := 1 input int\n" +" overwrite_y := 1 input int\n" +" overwrite_w := 1 input int\n" +" overwrite_t := 1 input int\n" +" overwrite_c := 1 input int\n" +" overwrite_fpint := 1 input int\n" +" overwrite_nrdata := 1 input int\n" +"Return objects:\n" +" x : rank-1 array('d') with bounds (m)\n" +" y : rank-1 array('d') with bounds (m)\n" +" w : rank-1 array('d') with bounds (m)\n" +" xb : float\n" +" xe : float\n" +" k : int\n" +" s : float\n" +" n : int\n" +" t : rank-1 array('d') with bounds (nest)\n" +" c : rank-1 array('d') with bounds (nest)\n" +" fp : float\n" +" fpint : rank-1 array('d') with bounds (nest)\n" +" nrdata : rank-1 array('i') with bounds (nest)\n" +" ier : int"; +/* extern void F_FUNC(fpcurf,FPCURF)(int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_fpcurf1(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + int capi_overwrite_x = 1; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + int capi_overwrite_y = 1; + PyObject *y_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + int capi_overwrite_w = 1; + PyObject *w_capi = Py_None; + int m = 0; + double xb = 0; + PyObject *xb_capi = Py_None; + double xe = 0; + PyObject *xe_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double s = 0; + PyObject *s_capi = Py_None; + int nest = 0; + double tol = 0; + int maxit = 0; + int k1 = 0; + int k2 = 0; + int n = 0; + PyObject *n_capi = Py_None; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + int capi_overwrite_t = 1; + PyObject *t_capi = Py_None; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + int capi_overwrite_c = 1; + PyObject *c_capi = Py_None; + double fp = 0; + PyObject *fp_capi = Py_None; + double *fpint = NULL; + npy_intp fpint_Dims[1] = {-1}; + const int fpint_Rank = 1; + PyArrayObject *capi_fpint_tmp = NULL; + int capi_fpint_intent = 0; + int capi_overwrite_fpint = 1; + PyObject *fpint_capi = Py_None; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + int *nrdata = NULL; + npy_intp nrdata_Dims[1] = {-1}; + const int nrdata_Rank = 1; + PyArrayObject *capi_nrdata_tmp = NULL; + int capi_nrdata_intent = 0; + int capi_overwrite_nrdata = 1; + PyObject *nrdata_capi = Py_None; + int ier = 0; + PyObject *ier_capi = Py_None; + static char *capi_kwlist[] = {"x","y","w","xb","xe","k","s","n","t","c","fp","fpint","nrdata","ier","overwrite_x","overwrite_y","overwrite_w","overwrite_t","overwrite_c","overwrite_fpint","overwrite_nrdata",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOOOOOOOOOOO|iiiiiii:dfitpack.fpcurf1",\ + capi_kwlist,&x_capi,&y_capi,&w_capi,&xb_capi,&xe_capi,&k_capi,&s_capi,&n_capi,&t_capi,&c_capi,&fp_capi,&fpint_capi,&nrdata_capi,&ier_capi,&capi_overwrite_x,&capi_overwrite_y,&capi_overwrite_w,&capi_overwrite_t,&capi_overwrite_c,&capi_overwrite_fpint,&capi_overwrite_nrdata)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + f2py_success = double_from_pyobj(&fp,fp_capi,"dfitpack.fpcurf1() 11st argument (fp) can't be converted to double"); + if (f2py_success) { + /* Processing variable xb */ + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.fpcurf1() 4th argument (xb) can't be converted to double"); + if (f2py_success) { + /* Processing variable s */ + f2py_success = double_from_pyobj(&s,s_capi,"dfitpack.fpcurf1() 7th argument (s) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(s>=0.0,"s>=0.0","7th argument s","fpcurf1:s=%g",s) { + /* Processing variable xe */ + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.fpcurf1() 5th argument (xe) can't be converted to double"); + if (f2py_success) { + /* Processing variable maxit */ + maxit = 20; + /* Processing variable k */ + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.fpcurf1() 6th argument (k) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=k && k<=5,"1<=k && k<=5","6th argument k","fpcurf1:k=%d",k) { + /* Processing variable ier */ + f2py_success = int_from_pyobj(&ier,ier_capi,"dfitpack.fpcurf1() 14th argument (ier) can't be converted to int"); + if (f2py_success) { + /* Processing variable n */ + f2py_success = int_from_pyobj(&n,n_capi,"dfitpack.fpcurf1() 8th argument (n) can't be converted to int"); + if (f2py_success) { + /* Processing variable t */ + capi_t_intent |= (capi_overwrite_t?0:F2PY_INTENT_COPY); + ; + capi_t_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 9th argument `t' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable tol */ + tol = 0.001; + /* Processing variable x */ + capi_x_intent |= (capi_overwrite_x?0:F2PY_INTENT_COPY); + ; + capi_x_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `x' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable iopt */ + iopt = 1; + /* Processing variable nest */ + nest = len(t); + /* Processing variable nrdata */ + capi_nrdata_intent |= (capi_overwrite_nrdata?0:F2PY_INTENT_COPY); + nrdata_Dims[0]=nest; + capi_nrdata_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_nrdata_tmp = array_from_pyobj(PyArray_INT,nrdata_Dims,nrdata_Rank,capi_nrdata_intent,nrdata_capi); + if (capi_nrdata_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 13rd argument `nrdata' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + nrdata = (int *)(capi_nrdata_tmp->data); + + CHECKARRAY(len(nrdata)==nest,"len(nrdata)==nest","13rd argument nrdata") { + /* Processing variable fpint */ + capi_fpint_intent |= (capi_overwrite_fpint?0:F2PY_INTENT_COPY); + fpint_Dims[0]=nest; + capi_fpint_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_fpint_tmp = array_from_pyobj(PyArray_DOUBLE,fpint_Dims,fpint_Rank,capi_fpint_intent,fpint_capi); + if (capi_fpint_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 12nd argument `fpint' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + fpint = (double *)(capi_fpint_tmp->data); + + CHECKARRAY(len(fpint)==nest,"len(fpint)==nest","12nd argument fpint") { + /* Processing variable c */ + capi_c_intent |= (capi_overwrite_c?0:F2PY_INTENT_COPY); + c_Dims[0]=nest; + capi_c_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 10th argument `c' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==nest,"len(c)==nest","10th argument c") { + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>k,"m>k","hidden m","fpcurf1:m=%d",m) { + /* Processing variable k2 */ + k2 = k+2; + /* Processing variable k1 */ + k1 = k+1; + /* Processing variable y */ + capi_y_intent |= (capi_overwrite_y?0:F2PY_INTENT_COPY); + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `y' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","2nd argument y") { + /* Processing variable w */ + capi_w_intent |= (capi_overwrite_w?0:F2PY_INTENT_COPY); + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `w' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + CHECKARRAY(len(w)==m,"len(w)==m","3rd argument w") { + /* Processing variable wrk */ + wrk_Dims[0]=nest*3*k2+m*k1; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.fpcurf1 to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier); + /*(*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,nrdata,&ier);*/ +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("NNNddidiNNdNNi",capi_x_tmp,capi_y_tmp,capi_w_tmp,xb,xe,k,s,n,capi_t_tmp,capi_c_tmp,fp,capi_fpint_tmp,capi_nrdata_tmp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*CHECKARRAY(len(w)==m)*/ + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + } /*CHECKARRAY(len(y)==m)*/ + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + /* End of cleaning variable k1 */ + /* End of cleaning variable k2 */ + } /*CHECKSCALAR(m>k)*/ + /* End of cleaning variable m */ + } /*CHECKARRAY(len(c)==nest)*/ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*CHECKARRAY(len(fpint)==nest)*/ + } /*if (capi_fpint_tmp == NULL) ... else of fpint*/ + /* End of cleaning variable fpint */ + } /*CHECKARRAY(len(nrdata)==nest)*/ + } /*if (capi_nrdata_tmp == NULL) ... else of nrdata*/ + /* End of cleaning variable nrdata */ + /* End of cleaning variable nest */ + /* End of cleaning variable iopt */ + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + /* End of cleaning variable tol */ + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + } /*if (f2py_success) of n*/ + /* End of cleaning variable n */ + } /*if (f2py_success) of ier*/ + /* End of cleaning variable ier */ + } /*CHECKSCALAR(1<=k && k<=5)*/ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + /* End of cleaning variable maxit */ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*CHECKSCALAR(s>=0.0)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + } /*if (f2py_success) of fp*/ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of fpcurf1 *******************************/ + +/********************************** fpcurfm1 **********************************/ +static char doc_f2py_rout_dfitpack_fpcurfm1[] = "\ +Function signature:\n\ + x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = fpcurfm1(x,y,k,t,[w,xb,xe,overwrite_t])\n\ +Required arguments:\n" +" x : input rank-1 array('d') with bounds (m)\n" +" y : input rank-1 array('d') with bounds (m)\n" +" k : input int\n" +" t : input rank-1 array('d') with bounds (n)\n" +"Optional arguments:\n" +" w := 1.0 input rank-1 array('d') with bounds (m)\n" +" xb := x[0] input float\n" +" xe := x[m-1] input float\n" +" overwrite_t := 1 input int\n" +"Return objects:\n" +" x : rank-1 array('d') with bounds (m)\n" +" y : rank-1 array('d') with bounds (m)\n" +" w : rank-1 array('d') with bounds (m)\n" +" xb : float\n" +" xe : float\n" +" k : int\n" +" s : float\n" +" n : int\n" +" t : rank-1 array('d') with bounds (n)\n" +" c : rank-1 array('d') with bounds (nest)\n" +" fp : float\n" +" fpint : rank-1 array('d') with bounds (nest)\n" +" nrdata : rank-1 array('i') with bounds (nest)\n" +" ier : int"; +/* extern void F_FUNC(fpcurf,FPCURF)(int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_fpcurfm1(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + PyObject *y_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + PyObject *w_capi = Py_None; + int m = 0; + double xb = 0; + PyObject *xb_capi = Py_None; + double xe = 0; + PyObject *xe_capi = Py_None; + int k = 0; + PyObject *k_capi = Py_None; + double s = 0; + int nest = 0; + double tol = 0; + int maxit = 0; + int k1 = 0; + int k2 = 0; + int n = 0; + double *t = NULL; + npy_intp t_Dims[1] = {-1}; + const int t_Rank = 1; + PyArrayObject *capi_t_tmp = NULL; + int capi_t_intent = 0; + int capi_overwrite_t = 1; + PyObject *t_capi = Py_None; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + double fp = 0; + double *fpint = NULL; + npy_intp fpint_Dims[1] = {-1}; + const int fpint_Rank = 1; + PyArrayObject *capi_fpint_tmp = NULL; + int capi_fpint_intent = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + int *nrdata = NULL; + npy_intp nrdata_Dims[1] = {-1}; + const int nrdata_Rank = 1; + PyArrayObject *capi_nrdata_tmp = NULL; + int capi_nrdata_intent = 0; + int ier = 0; + static char *capi_kwlist[] = {"x","y","k","t","w","xb","xe","overwrite_t",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOO|OOOi:dfitpack.fpcurfm1",\ + capi_kwlist,&x_capi,&y_capi,&k_capi,&t_capi,&w_capi,&xb_capi,&xe_capi,&capi_overwrite_t)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + /* Processing variable s */ + s = -1; + /* Processing variable maxit */ + maxit = 20; + /* Processing variable k */ + f2py_success = int_from_pyobj(&k,k_capi,"dfitpack.fpcurfm1() 3rd argument (k) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=k && k<=5,"1<=k && k<=5","3rd argument k","fpcurfm1:k=%d",k) { + /* Processing variable ier */ + /* Processing variable t */ + capi_t_intent |= (capi_overwrite_t?0:F2PY_INTENT_COPY); + ; + capi_t_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_t_tmp = array_from_pyobj(PyArray_DOUBLE,t_Dims,t_Rank,capi_t_intent,t_capi); + if (capi_t_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 4th argument `t' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + t = (double *)(capi_t_tmp->data); + + /* Processing variable tol */ + tol = 0.001; + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `x' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable iopt */ + iopt = -1; + /* Processing variable xb */ + if (xb_capi == Py_None) xb = x[0]; else + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.fpcurfm1() 2nd keyword (xb) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(xb<=x[0],"xb<=x[0]","2nd keyword xb","fpcurfm1:xb=%g",xb) { + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>k,"m>k","hidden m","fpcurfm1:m=%d",m) { + /* Processing variable n */ + n = len(t); + /* Processing variable k2 */ + k2 = k+2; + /* Processing variable k1 */ + k1 = k+1; + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `y' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","2nd argument y") { + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL|F2PY_INTENT_OUT; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st keyword `w' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + if (w_capi == Py_None) { + + + int *_i,capi_i=0; + CFUNCSMESS("fpcurfm1: Initializing w=1.0\n"); + if (initforcomb(capi_w_tmp->dimensions,capi_w_tmp->nd,1)) { + while ((_i = nextforcomb())) + w[capi_i++] = 1.0; /* fortran way */ + } else { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"Initialization of 1st keyword w failed (initforcomb)."); + f2py_success = 0; + } + } + if (f2py_success) { + CHECKARRAY(len(w)==m,"len(w)==m","1st keyword w") { + /* Processing variable nest */ + nest = n; + /* Processing variable xe */ + if (xe_capi == Py_None) xe = x[m-1]; else + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.fpcurfm1() 3rd keyword (xe) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(xe>=x[m-1],"xe>=x[m-1]","3rd keyword xe","fpcurfm1:xe=%g",xe) { + /* Processing variable nrdata */ + nrdata_Dims[0]=nest; + capi_nrdata_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_nrdata_tmp = array_from_pyobj(PyArray_INT,nrdata_Dims,nrdata_Rank,capi_nrdata_intent,Py_None); + if (capi_nrdata_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `nrdata' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + nrdata = (int *)(capi_nrdata_tmp->data); + + /* Processing variable fpint */ + fpint_Dims[0]=nest; + capi_fpint_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_fpint_tmp = array_from_pyobj(PyArray_DOUBLE,fpint_Dims,fpint_Rank,capi_fpint_intent,Py_None); + if (capi_fpint_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `fpint' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + fpint = (double *)(capi_fpint_tmp->data); + + /* Processing variable c */ + c_Dims[0]=nest; + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + /* Processing variable wrk */ + wrk_Dims[0]=nest*3*k2+m*k1; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.fpcurfm1 to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier); + /*(*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,nrdata,&ier);*/ +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("NNNddidiNNdNNi",capi_x_tmp,capi_y_tmp,capi_w_tmp,xb,xe,k,s,n,capi_t_tmp,capi_c_tmp,fp,capi_fpint_tmp,capi_nrdata_tmp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + } /*if (capi_fpint_tmp == NULL) ... else of fpint*/ + /* End of cleaning variable fpint */ + } /*if (capi_nrdata_tmp == NULL) ... else of nrdata*/ + /* End of cleaning variable nrdata */ + } /*CHECKSCALAR(xe>=x[m-1])*/ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + /* End of cleaning variable nest */ + } /*CHECKARRAY(len(w)==m)*/ + } /*if (f2py_success) of w init*/ + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + } /*CHECKARRAY(len(y)==m)*/ + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + /* End of cleaning variable k1 */ + /* End of cleaning variable k2 */ + /* End of cleaning variable n */ + } /*CHECKSCALAR(m>k)*/ + /* End of cleaning variable m */ + } /*CHECKSCALAR(xb<=x[0])*/ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + /* End of cleaning variable iopt */ + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + /* End of cleaning variable tol */ + } /*if (capi_t_tmp == NULL) ... else of t*/ + /* End of cleaning variable t */ + /* End of cleaning variable ier */ + } /*CHECKSCALAR(1<=k && k<=5)*/ + } /*if (f2py_success) of k*/ + /* End of cleaning variable k */ + /* End of cleaning variable maxit */ + /* End of cleaning variable s */ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/****************************** end of fpcurfm1 ******************************/ + +/*********************************** bispev ***********************************/ +static char doc_f2py_rout_dfitpack_bispev[] = "\ +Function signature:\n\ + z,ier = bispev(tx,ty,c,kx,ky,x,y)\n\ +Required arguments:\n" +" tx : input rank-1 array('d') with bounds (nx)\n" +" ty : input rank-1 array('d') with bounds (ny)\n" +" c : input rank-1 array('d') with bounds ((nx-kx-1)*(ny-ky-1))\n" +" kx : input int\n" +" ky : input int\n" +" x : input rank-1 array('d') with bounds (mx)\n" +" y : input rank-1 array('d') with bounds (my)\n" +"Return objects:\n" +" z : rank-2 array('d') with bounds (mx,my)\n" +" ier : int"; +/* extern void F_FUNC(bispev,BISPEV)(double*,int*,double*,int*,double*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_bispev(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(double*,int*,double*,int*,double*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + double *tx = NULL; + npy_intp tx_Dims[1] = {-1}; + const int tx_Rank = 1; + PyArrayObject *capi_tx_tmp = NULL; + int capi_tx_intent = 0; + PyObject *tx_capi = Py_None; + int nx = 0; + double *ty = NULL; + npy_intp ty_Dims[1] = {-1}; + const int ty_Rank = 1; + PyArrayObject *capi_ty_tmp = NULL; + int capi_ty_intent = 0; + PyObject *ty_capi = Py_None; + int ny = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + PyObject *c_capi = Py_None; + int kx = 0; + PyObject *kx_capi = Py_None; + int ky = 0; + PyObject *ky_capi = Py_None; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + int mx = 0; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + PyObject *y_capi = Py_None; + int my = 0; + double *z = NULL; + npy_intp z_Dims[2] = {-1, -1}; + const int z_Rank = 2; + PyArrayObject *capi_z_tmp = NULL; + int capi_z_intent = 0; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + int lwrk = 0; + int *iwrk = NULL; + npy_intp iwrk_Dims[1] = {-1}; + const int iwrk_Rank = 1; + PyArrayObject *capi_iwrk_tmp = NULL; + int capi_iwrk_intent = 0; + int kwrk = 0; + int ier = 0; + static char *capi_kwlist[] = {"tx","ty","c","kx","ky","x","y",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOOOO|:dfitpack.bispev",\ + capi_kwlist,&tx_capi,&ty_capi,&c_capi,&kx_capi,&ky_capi,&x_capi,&y_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable kx */ + f2py_success = int_from_pyobj(&kx,kx_capi,"dfitpack.bispev() 4th argument (kx) can't be converted to int"); + if (f2py_success) { + /* Processing variable tx */ + ; + capi_tx_intent |= F2PY_INTENT_IN; + capi_tx_tmp = array_from_pyobj(PyArray_DOUBLE,tx_Dims,tx_Rank,capi_tx_intent,tx_capi); + if (capi_tx_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `tx' of dfitpack.bispev to C/Fortran array" ); + } else { + tx = (double *)(capi_tx_tmp->data); + + /* Processing variable ty */ + ; + capi_ty_intent |= F2PY_INTENT_IN; + capi_ty_tmp = array_from_pyobj(PyArray_DOUBLE,ty_Dims,ty_Rank,capi_ty_intent,ty_capi); + if (capi_ty_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `ty' of dfitpack.bispev to C/Fortran array" ); + } else { + ty = (double *)(capi_ty_tmp->data); + + /* Processing variable ier */ + /* Processing variable y */ + ; + capi_y_intent |= F2PY_INTENT_IN; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 7th argument `y' of dfitpack.bispev to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 6th argument `x' of dfitpack.bispev to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable ky */ + f2py_success = int_from_pyobj(&ky,ky_capi,"dfitpack.bispev() 5th argument (ky) can't be converted to int"); + if (f2py_success) { + /* Processing variable nx */ + nx = len(tx); + /* Processing variable ny */ + ny = len(ty); + /* Processing variable my */ + my = len(y); + /* Processing variable mx */ + mx = len(x); + /* Processing variable kwrk */ + kwrk = mx+my; + /* Processing variable c */ + c_Dims[0]=(nx-kx-1)*(ny-ky-1); + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `c' of dfitpack.bispev to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==(nx-kx-1)*(ny-ky-1),"len(c)==(nx-kx-1)*(ny-ky-1)","3rd argument c") { + /* Processing variable lwrk */ + lwrk = mx*(kx+1)+my*(ky+1); + /* Processing variable z */ + z_Dims[0]=mx,z_Dims[1]=my; + capi_z_intent |= F2PY_INTENT_C|F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_z_tmp = array_from_pyobj(PyArray_DOUBLE,z_Dims,z_Rank,capi_z_intent,Py_None); + if (capi_z_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `z' of dfitpack.bispev to C/Fortran array" ); + } else { + z = (double *)(capi_z_tmp->data); + + /* Processing variable iwrk */ + iwrk_Dims[0]=kwrk; + capi_iwrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,Py_None); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `iwrk' of dfitpack.bispev to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + + /* Processing variable wrk */ + wrk_Dims[0]=lwrk; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.bispev to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(tx,&nx,ty,&ny,c,&kx,&ky,x,&mx,y,&my,z,wrk,&lwrk,iwrk,&kwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("Ni",capi_z_tmp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + Py_XDECREF(capi_iwrk_tmp); + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + } /*if (capi_z_tmp == NULL) ... else of z*/ + /* End of cleaning variable z */ + /* End of cleaning variable lwrk */ + } /*CHECKARRAY(len(c)==(nx-kx-1)*(ny-ky-1))*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable kwrk */ + /* End of cleaning variable mx */ + /* End of cleaning variable my */ + /* End of cleaning variable ny */ + /* End of cleaning variable nx */ + } /*if (f2py_success) of ky*/ + /* End of cleaning variable ky */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_y_tmp!=y_capi) { + Py_XDECREF(capi_y_tmp); } + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + /* End of cleaning variable ier */ + if((PyObject *)capi_ty_tmp!=ty_capi) { + Py_XDECREF(capi_ty_tmp); } + } /*if (capi_ty_tmp == NULL) ... else of ty*/ + /* End of cleaning variable ty */ + if((PyObject *)capi_tx_tmp!=tx_capi) { + Py_XDECREF(capi_tx_tmp); } + } /*if (capi_tx_tmp == NULL) ... else of tx*/ + /* End of cleaning variable tx */ + } /*if (f2py_success) of kx*/ + /* End of cleaning variable kx */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of bispev *******************************/ + +/******************************** surfit_smth ********************************/ +static char doc_f2py_rout_dfitpack_surfit_smth[] = "\ +Function signature:\n\ + nx,tx,ny,ty,c,fp,wrk1,ier = surfit_smth(x,y,z,[w,xb,xe,yb,ye,kx,ky,s,nxest,nyest,eps,lwrk2])\n\ +Required arguments:\n" +" x : input rank-1 array('d') with bounds (m)\n" +" y : input rank-1 array('d') with bounds (m)\n" +" z : input rank-1 array('d') with bounds (m)\n" +"Optional arguments:\n" +" w := 1.0 input rank-1 array('d') with bounds (m)\n" +" xb := dmin(x,m) input float\n" +" xe := dmax(x,m) input float\n" +" yb := dmin(y,m) input float\n" +" ye := dmax(y,m) input float\n" +" kx := 3 input int\n" +" ky := 3 input int\n" +" s := m input float\n" +" nxest := imax(kx+1+sqrt(m/2),2*(kx+1)) input int\n" +" nyest := imax(ky+1+sqrt(m/2),2*(ky+1)) input int\n" +" eps := 1e-016 input float\n" +" lwrk2 := calc_surfit_lwrk2(m,kx,ky,nxest,nyest) input int\n" +"Return objects:\n" +" nx : int\n" +" tx : rank-1 array('d') with bounds (nmax)\n" +" ny : int\n" +" ty : rank-1 array('d') with bounds (nmax)\n" +" c : rank-1 array('d') with bounds ((nxest-kx-1)*(nyest-ky-1))\n" +" fp : float\n" +" wrk1 : rank-1 array('d') with bounds (lwrk1)\n" +" ier : int"; +/* extern void F_FUNC(surfit,SURFIT)(int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,double*,int*,int*,int*,double*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,int*,int*); */ +static PyObject *f2py_rout_dfitpack_surfit_smth(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,double*,int*,int*,int*,double*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,int*,int*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + int iopt = 0; + int m = 0; + double *x = NULL; + npy_intp x_Dims[1] = {-1}; + const int x_Rank = 1; + PyArrayObject *capi_x_tmp = NULL; + int capi_x_intent = 0; + PyObject *x_capi = Py_None; + double *y = NULL; + npy_intp y_Dims[1] = {-1}; + const int y_Rank = 1; + PyArrayObject *capi_y_tmp = NULL; + int capi_y_intent = 0; + PyObject *y_capi = Py_None; + double *z = NULL; + npy_intp z_Dims[1] = {-1}; + const int z_Rank = 1; + PyArrayObject *capi_z_tmp = NULL; + int capi_z_intent = 0; + PyObject *z_capi = Py_None; + double *w = NULL; + npy_intp w_Dims[1] = {-1}; + const int w_Rank = 1; + PyArrayObject *capi_w_tmp = NULL; + int capi_w_intent = 0; + PyObject *w_capi = Py_None; + double xb = 0; + PyObject *xb_capi = Py_None; + double xe = 0; + PyObject *xe_capi = Py_None; + double yb = 0; + PyObject *yb_capi = Py_None; + double ye = 0; + PyObject *ye_capi = Py_None; + int kx = 0; + PyObject *kx_capi = Py_None; + int ky = 0; + PyObject *ky_capi = Py_None; + double s = 0; + PyObject *s_capi = Py_None; + int nxest = 0; + PyObject *nxest_capi = Py_None; + int nyest = 0; + PyObject *nyest_capi = Py_None; + int nmax = 0; + double eps = 0; + PyObject *eps_capi = Py_None; + int nx = 0; + double *tx = NULL; + npy_intp tx_Dims[1] = {-1}; + const int tx_Rank = 1; + PyArrayObject *capi_tx_tmp = NULL; + int capi_tx_intent = 0; + int ny = 0; + double *ty = NULL; + npy_intp ty_Dims[1] = {-1}; + const int ty_Rank = 1; + PyArrayObject *capi_ty_tmp = NULL; + int capi_ty_intent = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + double fp = 0; + double *wrk1 = NULL; + npy_intp wrk1_Dims[1] = {-1}; + const int wrk1_Rank = 1; + PyArrayObject *capi_wrk1_tmp = NULL; + int capi_wrk1_intent = 0; + int lwrk1 = 0; + double *wrk2 = NULL; + npy_intp wrk2_Dims[1] = {-1}; + const int wrk2_Rank = 1; + PyArrayObject *capi_wrk2_tmp = NULL; + int capi_wrk2_intent = 0; + int lwrk2 = 0; + PyObject *lwrk2_capi = Py_None; + int *iwrk = NULL; + npy_intp iwrk_Dims[1] = {-1}; + const int iwrk_Rank = 1; + PyArrayObject *capi_iwrk_tmp = NULL; + int capi_iwrk_intent = 0; + int kwrk = 0; + int ier = 0; + static char *capi_kwlist[] = {"x","y","z","w","xb","xe","yb","ye","kx","ky","s","nxest","nyest","eps","lwrk2",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOO|OOOOOOOOOOOO:dfitpack.surfit_smth",\ + capi_kwlist,&x_capi,&y_capi,&z_capi,&w_capi,&xb_capi,&xe_capi,&yb_capi,&ye_capi,&kx_capi,&ky_capi,&s_capi,&nxest_capi,&nyest_capi,&eps_capi,&lwrk2_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable fp */ + /* Processing variable iopt */ + iopt = 0; + /* Processing variable kx */ + if (kx_capi == Py_None) kx = 3; else + f2py_success = int_from_pyobj(&kx,kx_capi,"dfitpack.surfit_smth() 6th keyword (kx) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=kx && kx<=5,"1<=kx && kx<=5","6th keyword kx","surfit_smth:kx=%d",kx) { + /* Processing variable ier */ + /* Processing variable eps */ + if (eps_capi == Py_None) eps = 1e-016; else + f2py_success = double_from_pyobj(&eps,eps_capi,"dfitpack.surfit_smth() 11st keyword (eps) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(0.0data); + + /* Processing variable ky */ + if (ky_capi == Py_None) ky = 3; else + f2py_success = int_from_pyobj(&ky,ky_capi,"dfitpack.surfit_smth() 7th keyword (ky) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=ky && ky<=5,"1<=ky && ky<=5","7th keyword ky","surfit_smth:ky=%d",ky) { + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>=(kx+1)*(ky+1),"m>=(kx+1)*(ky+1)","hidden m","surfit_smth:m=%d",m) { + /* Processing variable s */ + if (s_capi == Py_None) s = m; else + f2py_success = double_from_pyobj(&s,s_capi,"dfitpack.surfit_smth() 8th keyword (s) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(0.0<=s,"0.0<=s","8th keyword s","surfit_smth:s=%g",s) { + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st keyword `w' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + if (w_capi == Py_None) { + + + int *_i,capi_i=0; + CFUNCSMESS("surfit_smth: Initializing w=1.0\n"); + if (initforcomb(capi_w_tmp->dimensions,capi_w_tmp->nd,1)) { + while ((_i = nextforcomb())) + w[capi_i++] = 1.0; /* fortran way */ + } else { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"Initialization of 1st keyword w failed (initforcomb)."); + f2py_success = 0; + } + } + if (f2py_success) { + CHECKARRAY(len(w)==m,"len(w)==m","1st keyword w") { + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `y' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","2nd argument y") { + /* Processing variable z */ + z_Dims[0]=m; + capi_z_intent |= F2PY_INTENT_IN; + capi_z_tmp = array_from_pyobj(PyArray_DOUBLE,z_Dims,z_Rank,capi_z_intent,z_capi); + if (capi_z_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `z' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + z = (double *)(capi_z_tmp->data); + + CHECKARRAY(len(z)==m,"len(z)==m","3rd argument z") { + /* Processing variable xb */ + if (xb_capi == Py_None) xb = dmin(x,m); else + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.surfit_smth() 2nd keyword (xb) can't be converted to double"); + if (f2py_success) { + /* Processing variable yb */ + if (yb_capi == Py_None) yb = dmin(y,m); else + f2py_success = double_from_pyobj(&yb,yb_capi,"dfitpack.surfit_smth() 4th keyword (yb) can't be converted to double"); + if (f2py_success) { + /* Processing variable ye */ + if (ye_capi == Py_None) ye = dmax(y,m); else + f2py_success = double_from_pyobj(&ye,ye_capi,"dfitpack.surfit_smth() 5th keyword (ye) can't be converted to double"); + if (f2py_success) { + /* Processing variable xe */ + if (xe_capi == Py_None) xe = dmax(x,m); else + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.surfit_smth() 3rd keyword (xe) can't be converted to double"); + if (f2py_success) { + /* Processing variable nxest */ + if (nxest_capi == Py_None) nxest = imax(kx+1+sqrt(m/2),2*(kx+1)); else + f2py_success = int_from_pyobj(&nxest,nxest_capi,"dfitpack.surfit_smth() 9th keyword (nxest) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(nxest>=2*(kx+1),"nxest>=2*(kx+1)","9th keyword nxest","surfit_smth:nxest=%d",nxest) { + /* Processing variable nyest */ + if (nyest_capi == Py_None) nyest = imax(ky+1+sqrt(m/2),2*(ky+1)); else + f2py_success = int_from_pyobj(&nyest,nyest_capi,"dfitpack.surfit_smth() 10th keyword (nyest) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(nyest>=2*(ky+1),"nyest>=2*(ky+1)","10th keyword nyest","surfit_smth:nyest=%d",nyest) { + /* Processing variable nmax */ + nmax = MAX(nxest,nyest); + /* Processing variable lwrk2 */ + if (lwrk2_capi == Py_None) lwrk2 = calc_surfit_lwrk2(m,kx,ky,nxest,nyest); else + f2py_success = int_from_pyobj(&lwrk2,lwrk2_capi,"dfitpack.surfit_smth() 12nd keyword (lwrk2) can't be converted to int"); + if (f2py_success) { + /* Processing variable lwrk1 */ + lwrk1 = calc_surfit_lwrk1(m,kx,ky,nxest,nyest); + /* Processing variable kwrk */ + kwrk = m+(nxest-2*kx-1)*(nyest-2*ky-1); + /* Processing variable c */ + c_Dims[0]=(nxest-kx-1)*(nyest-ky-1); + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + /* Processing variable tx */ + tx_Dims[0]=nmax; + capi_tx_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_tx_tmp = array_from_pyobj(PyArray_DOUBLE,tx_Dims,tx_Rank,capi_tx_intent,Py_None); + if (capi_tx_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `tx' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + tx = (double *)(capi_tx_tmp->data); + + /* Processing variable ty */ + ty_Dims[0]=nmax; + capi_ty_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_ty_tmp = array_from_pyobj(PyArray_DOUBLE,ty_Dims,ty_Rank,capi_ty_intent,Py_None); + if (capi_ty_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `ty' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + ty = (double *)(capi_ty_tmp->data); + + /* Processing variable iwrk */ + iwrk_Dims[0]=kwrk; + capi_iwrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,Py_None); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `iwrk' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + + /* Processing variable wrk2 */ + wrk2_Dims[0]=lwrk2; + capi_wrk2_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk2_tmp = array_from_pyobj(PyArray_DOUBLE,wrk2_Dims,wrk2_Rank,capi_wrk2_intent,Py_None); + if (capi_wrk2_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk2' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + wrk2 = (double *)(capi_wrk2_tmp->data); + + /* Processing variable wrk1 */ + wrk1_Dims[0]=lwrk1; + capi_wrk1_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_wrk1_tmp = array_from_pyobj(PyArray_DOUBLE,wrk1_Dims,wrk1_Rank,capi_wrk1_intent,Py_None); + if (capi_wrk1_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk1' of dfitpack.surfit_smth to C/Fortran array" ); + } else { + wrk1 = (double *)(capi_wrk1_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,&m,x,y,z,w,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nmax,&eps,&nx,tx,&ny,ty,c,&fp,wrk1,&lwrk1,wrk2,&lwrk2,iwrk,&kwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("iNiNNdNi",nx,capi_tx_tmp,ny,capi_ty_tmp,capi_c_tmp,fp,capi_wrk1_tmp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + } /*if (capi_wrk1_tmp == NULL) ... else of wrk1*/ + /* End of cleaning variable wrk1 */ + Py_XDECREF(capi_wrk2_tmp); + } /*if (capi_wrk2_tmp == NULL) ... else of wrk2*/ + /* End of cleaning variable wrk2 */ + Py_XDECREF(capi_iwrk_tmp); + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + } /*if (capi_ty_tmp == NULL) ... else of ty*/ + /* End of cleaning variable ty */ + } /*if (capi_tx_tmp == NULL) ... else of tx*/ + /* End of cleaning variable tx */ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable kwrk */ + /* End of cleaning variable lwrk1 */ + } /*if (f2py_success) of lwrk2*/ + /* End of cleaning variable lwrk2 */ + /* End of cleaning variable nmax */ + } /*CHECKSCALAR(nyest>=2*(ky+1))*/ + } /*if (f2py_success) of nyest*/ + /* End of cleaning variable nyest */ + } /*CHECKSCALAR(nxest>=2*(kx+1))*/ + } /*if (f2py_success) of nxest*/ + /* End of cleaning variable nxest */ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*if (f2py_success) of ye*/ + /* End of cleaning variable ye */ + } /*if (f2py_success) of yb*/ + /* End of cleaning variable yb */ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + } /*CHECKARRAY(len(z)==m)*/ + if((PyObject *)capi_z_tmp!=z_capi) { + Py_XDECREF(capi_z_tmp); } + } /*if (capi_z_tmp == NULL) ... else of z*/ + /* End of cleaning variable z */ + } /*CHECKARRAY(len(y)==m)*/ + if((PyObject *)capi_y_tmp!=y_capi) { + Py_XDECREF(capi_y_tmp); } + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + } /*CHECKARRAY(len(w)==m)*/ + } /*if (f2py_success) of w init*/ + if((PyObject *)capi_w_tmp!=w_capi) { + Py_XDECREF(capi_w_tmp); } + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + } /*CHECKSCALAR(0.0<=s)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + } /*CHECKSCALAR(m>=(kx+1)*(ky+1))*/ + /* End of cleaning variable m */ + } /*CHECKSCALAR(1<=ky && ky<=5)*/ + } /*if (f2py_success) of ky*/ + /* End of cleaning variable ky */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + /* End of cleaning variable ny */ + /* End of cleaning variable nx */ + } /*CHECKSCALAR(0.0data); + + /* Processing variable ty */ + capi_ty_intent |= (capi_overwrite_ty?0:F2PY_INTENT_COPY); + ; + capi_ty_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; + capi_ty_tmp = array_from_pyobj(PyArray_DOUBLE,ty_Dims,ty_Rank,capi_ty_intent,ty_capi); + if (capi_ty_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 5th argument `ty' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + ty = (double *)(capi_ty_tmp->data); + + /* Processing variable ier */ + /* Processing variable eps */ + if (eps_capi == Py_None) eps = 1e-016; else + f2py_success = double_from_pyobj(&eps,eps_capi,"dfitpack.surfit_lsq() 8th keyword (eps) can't be converted to double"); + if (f2py_success) { + CHECKSCALAR(0.0data); + + /* Processing variable ky */ + if (ky_capi == Py_None) ky = 3; else + f2py_success = int_from_pyobj(&ky,ky_capi,"dfitpack.surfit_lsq() 7th keyword (ky) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=ky && ky<=5,"1<=ky && ky<=5","7th keyword ky","surfit_lsq:ky=%d",ky) { + /* Processing variable m */ + m = len(x); + CHECKSCALAR(m>=(kx+1)*(ky+1),"m>=(kx+1)*(ky+1)","hidden m","surfit_lsq:m=%d",m) { + /* Processing variable nx */ + nx = len(tx); + CHECKSCALAR(2*kx+2<=nx,"2*kx+2<=nx","hidden nx","surfit_lsq:nx=%d",nx) { + /* Processing variable ny */ + ny = len(ty); + CHECKSCALAR(2*ky+2<=ny,"2*ky+2<=ny","hidden ny","surfit_lsq:ny=%d",ny) { + /* Processing variable w */ + w_Dims[0]=m; + capi_w_intent |= F2PY_INTENT_IN|F2PY_OPTIONAL; + capi_w_tmp = array_from_pyobj(PyArray_DOUBLE,w_Dims,w_Rank,capi_w_intent,w_capi); + if (capi_w_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st keyword `w' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + w = (double *)(capi_w_tmp->data); + + if (w_capi == Py_None) { + + + int *_i,capi_i=0; + CFUNCSMESS("surfit_lsq: Initializing w=1.0\n"); + if (initforcomb(capi_w_tmp->dimensions,capi_w_tmp->nd,1)) { + while ((_i = nextforcomb())) + w[capi_i++] = 1.0; /* fortran way */ + } else { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"Initialization of 1st keyword w failed (initforcomb)."); + f2py_success = 0; + } + } + if (f2py_success) { + CHECKARRAY(len(w)==m,"len(w)==m","1st keyword w") { + /* Processing variable y */ + y_Dims[0]=m; + capi_y_intent |= F2PY_INTENT_IN; + capi_y_tmp = array_from_pyobj(PyArray_DOUBLE,y_Dims,y_Rank,capi_y_intent,y_capi); + if (capi_y_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `y' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + y = (double *)(capi_y_tmp->data); + + CHECKARRAY(len(y)==m,"len(y)==m","2nd argument y") { + /* Processing variable z */ + z_Dims[0]=m; + capi_z_intent |= F2PY_INTENT_IN; + capi_z_tmp = array_from_pyobj(PyArray_DOUBLE,z_Dims,z_Rank,capi_z_intent,z_capi); + if (capi_z_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `z' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + z = (double *)(capi_z_tmp->data); + + CHECKARRAY(len(z)==m,"len(z)==m","3rd argument z") { + /* Processing variable nmax */ + nmax = MAX(nx,ny); + /* Processing variable xb */ + if (xb_capi == Py_None) xb = calc_b(x,m,tx,nx); else + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.surfit_lsq() 2nd keyword (xb) can't be converted to double"); + if (f2py_success) { + /* Processing variable yb */ + if (yb_capi == Py_None) yb = calc_b(y,m,ty,ny); else + f2py_success = double_from_pyobj(&yb,yb_capi,"dfitpack.surfit_lsq() 4th keyword (yb) can't be converted to double"); + if (f2py_success) { + /* Processing variable ye */ + if (ye_capi == Py_None) ye = calc_e(y,m,ty,ny); else + f2py_success = double_from_pyobj(&ye,ye_capi,"dfitpack.surfit_lsq() 5th keyword (ye) can't be converted to double"); + if (f2py_success) { + /* Processing variable xe */ + if (xe_capi == Py_None) xe = calc_e(x,m,tx,nx); else + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.surfit_lsq() 3rd keyword (xe) can't be converted to double"); + if (f2py_success) { + /* Processing variable nxest */ + nxest = nx; + /* Processing variable kwrk */ + kwrk = m+(nx-2*kx-1)*(ny-2*ky-1); + /* Processing variable c */ + c_Dims[0]=(nx-kx-1)*(ny-ky-1); + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + /* Processing variable nyest */ + nyest = ny; + /* Processing variable iwrk */ + iwrk_Dims[0]=kwrk; + capi_iwrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,Py_None); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `iwrk' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + + /* Processing variable lwrk2 */ + if (lwrk2_capi == Py_None) lwrk2 = calc_surfit_lwrk2(m,kx,ky,nxest,nyest); else + f2py_success = int_from_pyobj(&lwrk2,lwrk2_capi,"dfitpack.surfit_lsq() 9th keyword (lwrk2) can't be converted to int"); + if (f2py_success) { + /* Processing variable lwrk1 */ + lwrk1 = calc_surfit_lwrk1(m,kx,ky,nxest,nyest); + /* Processing variable wrk2 */ + wrk2_Dims[0]=lwrk2; + capi_wrk2_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk2_tmp = array_from_pyobj(PyArray_DOUBLE,wrk2_Dims,wrk2_Rank,capi_wrk2_intent,Py_None); + if (capi_wrk2_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk2' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + wrk2 = (double *)(capi_wrk2_tmp->data); + + /* Processing variable wrk1 */ + wrk1_Dims[0]=lwrk1; + capi_wrk1_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk1_tmp = array_from_pyobj(PyArray_DOUBLE,wrk1_Dims,wrk1_Rank,capi_wrk1_intent,Py_None); + if (capi_wrk1_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk1' of dfitpack.surfit_lsq to C/Fortran array" ); + } else { + wrk1 = (double *)(capi_wrk1_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,&m,x,y,z,w,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nmax,&eps,&nx,tx,&ny,ty,c,&fp,wrk1,&lwrk1,wrk2,&lwrk2,iwrk,&kwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("NNNdi",capi_tx_tmp,capi_ty_tmp,capi_c_tmp,fp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk1_tmp); + } /*if (capi_wrk1_tmp == NULL) ... else of wrk1*/ + /* End of cleaning variable wrk1 */ + Py_XDECREF(capi_wrk2_tmp); + } /*if (capi_wrk2_tmp == NULL) ... else of wrk2*/ + /* End of cleaning variable wrk2 */ + /* End of cleaning variable lwrk1 */ + } /*if (f2py_success) of lwrk2*/ + /* End of cleaning variable lwrk2 */ + Py_XDECREF(capi_iwrk_tmp); + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + /* End of cleaning variable nyest */ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable kwrk */ + /* End of cleaning variable nxest */ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*if (f2py_success) of ye*/ + /* End of cleaning variable ye */ + } /*if (f2py_success) of yb*/ + /* End of cleaning variable yb */ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + /* End of cleaning variable nmax */ + } /*CHECKARRAY(len(z)==m)*/ + if((PyObject *)capi_z_tmp!=z_capi) { + Py_XDECREF(capi_z_tmp); } + } /*if (capi_z_tmp == NULL) ... else of z*/ + /* End of cleaning variable z */ + } /*CHECKARRAY(len(y)==m)*/ + if((PyObject *)capi_y_tmp!=y_capi) { + Py_XDECREF(capi_y_tmp); } + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + } /*CHECKARRAY(len(w)==m)*/ + } /*if (f2py_success) of w init*/ + if((PyObject *)capi_w_tmp!=w_capi) { + Py_XDECREF(capi_w_tmp); } + } /*if (capi_w_tmp == NULL) ... else of w*/ + /* End of cleaning variable w */ + } /*CHECKSCALAR(2*ky+2<=ny)*/ + /* End of cleaning variable ny */ + } /*CHECKSCALAR(2*kx+2<=nx)*/ + /* End of cleaning variable nx */ + } /*CHECKSCALAR(m>=(kx+1)*(ky+1))*/ + /* End of cleaning variable m */ + } /*CHECKSCALAR(1<=ky && ky<=5)*/ + } /*if (f2py_success) of ky*/ + /* End of cleaning variable ky */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + /* End of cleaning variable s */ + } /*CHECKSCALAR(0.0data); + + /* Processing variable x */ + ; + capi_x_intent |= F2PY_INTENT_IN; + capi_x_tmp = array_from_pyobj(PyArray_DOUBLE,x_Dims,x_Rank,capi_x_intent,x_capi); + if (capi_x_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `x' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + x = (double *)(capi_x_tmp->data); + + /* Processing variable ky */ + if (ky_capi == Py_None) ky = 3; else + f2py_success = int_from_pyobj(&ky,ky_capi,"dfitpack.regrid_smth() 6th keyword (ky) can't be converted to int"); + if (f2py_success) { + CHECKSCALAR(1<=ky && ky<=5,"1<=ky && ky<=5","6th keyword ky","regrid_smth:ky=%d",ky) { + /* Processing variable my */ + my = len(y); + CHECKSCALAR(my>ky,"my>ky","hidden my","regrid_smth:my=%d",my) { + /* Processing variable mx */ + mx = len(x); + CHECKSCALAR(mx>kx,"mx>kx","hidden mx","regrid_smth:mx=%d",mx) { + /* Processing variable xb */ + if (xb_capi == Py_None) xb = dmin(x,mx); else + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.regrid_smth() 1st keyword (xb) can't be converted to double"); + if (f2py_success) { + /* Processing variable yb */ + if (yb_capi == Py_None) yb = dmin(y,my); else + f2py_success = double_from_pyobj(&yb,yb_capi,"dfitpack.regrid_smth() 3rd keyword (yb) can't be converted to double"); + if (f2py_success) { + /* Processing variable ye */ + if (ye_capi == Py_None) ye = dmax(y,my); else + f2py_success = double_from_pyobj(&ye,ye_capi,"dfitpack.regrid_smth() 4th keyword (ye) can't be converted to double"); + if (f2py_success) { + /* Processing variable xe */ + if (xe_capi == Py_None) xe = dmax(x,mx); else + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.regrid_smth() 2nd keyword (xe) can't be converted to double"); + if (f2py_success) { + /* Processing variable nxest */ + nxest = mx+kx+1; + CHECKSCALAR(nxest>=2*(kx+1),"nxest>=2*(kx+1)","hidden nxest","regrid_smth:nxest=%d",nxest) { + /* Processing variable nyest */ + nyest = my+ky+1; + CHECKSCALAR(nyest>=2*(ky+1),"nyest>=2*(ky+1)","hidden nyest","regrid_smth:nyest=%d",nyest) { + /* Processing variable tx */ + tx_Dims[0]=nxest; + capi_tx_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_tx_tmp = array_from_pyobj(PyArray_DOUBLE,tx_Dims,tx_Rank,capi_tx_intent,Py_None); + if (capi_tx_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `tx' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + tx = (double *)(capi_tx_tmp->data); + + /* Processing variable ty */ + ty_Dims[0]=nyest; + capi_ty_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_ty_tmp = array_from_pyobj(PyArray_DOUBLE,ty_Dims,ty_Rank,capi_ty_intent,Py_None); + if (capi_ty_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `ty' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + ty = (double *)(capi_ty_tmp->data); + + /* Processing variable lwrk */ + lwrk = calc_regrid_lwrk(mx,my,kx,ky,nxest,nyest); + /* Processing variable z */ + z_Dims[0]=mx*my; + capi_z_intent |= F2PY_INTENT_IN; + capi_z_tmp = array_from_pyobj(PyArray_DOUBLE,z_Dims,z_Rank,capi_z_intent,z_capi); + if (capi_z_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `z' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + z = (double *)(capi_z_tmp->data); + + CHECKARRAY(len(z)==mx*my,"len(z)==mx*my","3rd argument z") { + /* Processing variable kwrk */ + kwrk = 3+mx+my+nxest+nyest; + /* Processing variable c */ + c_Dims[0]=(nxest-kx-1)*(nyest-ky-1); + capi_c_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,Py_None); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `c' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + /* Processing variable wrk */ + wrk_Dims[0]=lwrk; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + + /* Processing variable iwrk */ + iwrk_Dims[0]=kwrk; + capi_iwrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_iwrk_tmp = array_from_pyobj(PyArray_INT,iwrk_Dims,iwrk_Rank,capi_iwrk_intent,Py_None); + if (capi_iwrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `iwrk' of dfitpack.regrid_smth to C/Fortran array" ); + } else { + iwrk = (int *)(capi_iwrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&iopt,&mx,x,&my,y,z,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nx,tx,&ny,ty,c,&fp,wrk,&lwrk,iwrk,&kwrk,&ier); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("iNiNNdi",nx,capi_tx_tmp,ny,capi_ty_tmp,capi_c_tmp,fp,ier); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_iwrk_tmp); + } /*if (capi_iwrk_tmp == NULL) ... else of iwrk*/ + /* End of cleaning variable iwrk */ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable kwrk */ + } /*CHECKARRAY(len(z)==mx*my)*/ + if((PyObject *)capi_z_tmp!=z_capi) { + Py_XDECREF(capi_z_tmp); } + } /*if (capi_z_tmp == NULL) ... else of z*/ + /* End of cleaning variable z */ + /* End of cleaning variable lwrk */ + } /*if (capi_ty_tmp == NULL) ... else of ty*/ + /* End of cleaning variable ty */ + } /*if (capi_tx_tmp == NULL) ... else of tx*/ + /* End of cleaning variable tx */ + } /*CHECKSCALAR(nyest>=2*(ky+1))*/ + /* End of cleaning variable nyest */ + } /*CHECKSCALAR(nxest>=2*(kx+1))*/ + /* End of cleaning variable nxest */ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*if (f2py_success) of ye*/ + /* End of cleaning variable ye */ + } /*if (f2py_success) of yb*/ + /* End of cleaning variable yb */ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + } /*CHECKSCALAR(mx>kx)*/ + /* End of cleaning variable mx */ + } /*CHECKSCALAR(my>ky)*/ + /* End of cleaning variable my */ + } /*CHECKSCALAR(1<=ky && ky<=5)*/ + } /*if (f2py_success) of ky*/ + /* End of cleaning variable ky */ + if((PyObject *)capi_x_tmp!=x_capi) { + Py_XDECREF(capi_x_tmp); } + } /*if (capi_x_tmp == NULL) ... else of x*/ + /* End of cleaning variable x */ + if((PyObject *)capi_y_tmp!=y_capi) { + Py_XDECREF(capi_y_tmp); } + } /*if (capi_y_tmp == NULL) ... else of y*/ + /* End of cleaning variable y */ + } /*CHECKSCALAR(0.0<=s)*/ + } /*if (f2py_success) of s*/ + /* End of cleaning variable s */ + /* End of cleaning variable ny */ + /* End of cleaning variable nx */ + /* End of cleaning variable ier */ + } /*CHECKSCALAR(1<=kx && kx<=5)*/ + } /*if (f2py_success) of kx*/ + /* End of cleaning variable kx */ + /* End of cleaning variable iopt */ + /* End of cleaning variable fp */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/***************************** end of regrid_smth *****************************/ + +/*********************************** dblint ***********************************/ +static char doc_f2py_rout_dfitpack_dblint[] = "\ +Function signature:\n\ + dblint = dblint(tx,ty,c,kx,ky,xb,xe,yb,ye)\n\ +Required arguments:\n" +" tx : input rank-1 array('d') with bounds (nx)\n" +" ty : input rank-1 array('d') with bounds (ny)\n" +" c : input rank-1 array('d') with bounds ((nx-kx-1)*(ny-ky-1))\n" +" kx : input int\n" +" ky : input int\n" +" xb : input float\n" +" xe : input float\n" +" yb : input float\n" +" ye : input float\n" +"Return objects:\n" +" dblint : float"; +/* extern void F_WRAPPEDFUNC(dblint,DBLINT)(double*,double*,int*,double*,int*,double*,int*,int*,double*,double*,double*,double*,double*); */ +static PyObject *f2py_rout_dfitpack_dblint(const PyObject *capi_self, + PyObject *capi_args, + PyObject *capi_keywds, + void (*f2py_func)(double*,double*,int*,double*,int*,double*,int*,int*,double*,double*,double*,double*,double*)) { + PyObject * volatile capi_buildvalue = NULL; + volatile int f2py_success = 1; +/*decl*/ + + double dblint = 0; + double *tx = NULL; + npy_intp tx_Dims[1] = {-1}; + const int tx_Rank = 1; + PyArrayObject *capi_tx_tmp = NULL; + int capi_tx_intent = 0; + PyObject *tx_capi = Py_None; + int nx = 0; + double *ty = NULL; + npy_intp ty_Dims[1] = {-1}; + const int ty_Rank = 1; + PyArrayObject *capi_ty_tmp = NULL; + int capi_ty_intent = 0; + PyObject *ty_capi = Py_None; + int ny = 0; + double *c = NULL; + npy_intp c_Dims[1] = {-1}; + const int c_Rank = 1; + PyArrayObject *capi_c_tmp = NULL; + int capi_c_intent = 0; + PyObject *c_capi = Py_None; + int kx = 0; + PyObject *kx_capi = Py_None; + int ky = 0; + PyObject *ky_capi = Py_None; + double xb = 0; + PyObject *xb_capi = Py_None; + double xe = 0; + PyObject *xe_capi = Py_None; + double yb = 0; + PyObject *yb_capi = Py_None; + double ye = 0; + PyObject *ye_capi = Py_None; + double *wrk = NULL; + npy_intp wrk_Dims[1] = {-1}; + const int wrk_Rank = 1; + PyArrayObject *capi_wrk_tmp = NULL; + int capi_wrk_intent = 0; + static char *capi_kwlist[] = {"tx","ty","c","kx","ky","xb","xe","yb","ye",NULL}; + +/*routdebugenter*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_clock(); +#endif + if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ + "OOOOOOOOO|:dfitpack.dblint",\ + capi_kwlist,&tx_capi,&ty_capi,&c_capi,&kx_capi,&ky_capi,&xb_capi,&xe_capi,&yb_capi,&ye_capi)) + return NULL; +/*frompyobj*/ + /* Processing variable kx */ + f2py_success = int_from_pyobj(&kx,kx_capi,"dfitpack.dblint() 4th argument (kx) can't be converted to int"); + if (f2py_success) { + /* Processing variable tx */ + ; + capi_tx_intent |= F2PY_INTENT_IN; + capi_tx_tmp = array_from_pyobj(PyArray_DOUBLE,tx_Dims,tx_Rank,capi_tx_intent,tx_capi); + if (capi_tx_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 1st argument `tx' of dfitpack.dblint to C/Fortran array" ); + } else { + tx = (double *)(capi_tx_tmp->data); + + /* Processing variable ty */ + ; + capi_ty_intent |= F2PY_INTENT_IN; + capi_ty_tmp = array_from_pyobj(PyArray_DOUBLE,ty_Dims,ty_Rank,capi_ty_intent,ty_capi); + if (capi_ty_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 2nd argument `ty' of dfitpack.dblint to C/Fortran array" ); + } else { + ty = (double *)(capi_ty_tmp->data); + + /* Processing variable xb */ + f2py_success = double_from_pyobj(&xb,xb_capi,"dfitpack.dblint() 6th argument (xb) can't be converted to double"); + if (f2py_success) { + /* Processing variable yb */ + f2py_success = double_from_pyobj(&yb,yb_capi,"dfitpack.dblint() 8th argument (yb) can't be converted to double"); + if (f2py_success) { + /* Processing variable ye */ + f2py_success = double_from_pyobj(&ye,ye_capi,"dfitpack.dblint() 9th argument (ye) can't be converted to double"); + if (f2py_success) { + /* Processing variable xe */ + f2py_success = double_from_pyobj(&xe,xe_capi,"dfitpack.dblint() 7th argument (xe) can't be converted to double"); + if (f2py_success) { + /* Processing variable ky */ + f2py_success = int_from_pyobj(&ky,ky_capi,"dfitpack.dblint() 5th argument (ky) can't be converted to int"); + if (f2py_success) { + /* Processing variable dblint */ + /* Processing variable nx */ + nx = len(tx); + /* Processing variable ny */ + ny = len(ty); + /* Processing variable c */ + c_Dims[0]=(nx-kx-1)*(ny-ky-1); + capi_c_intent |= F2PY_INTENT_IN; + capi_c_tmp = array_from_pyobj(PyArray_DOUBLE,c_Dims,c_Rank,capi_c_intent,c_capi); + if (capi_c_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting 3rd argument `c' of dfitpack.dblint to C/Fortran array" ); + } else { + c = (double *)(capi_c_tmp->data); + + CHECKARRAY(len(c)==(nx-kx-1)*(ny-ky-1),"len(c)==(nx-kx-1)*(ny-ky-1)","3rd argument c") { + /* Processing variable wrk */ + wrk_Dims[0]=nx+ny-kx-ky-2; + capi_wrk_intent |= F2PY_INTENT_CACHE|F2PY_INTENT_HIDE; + capi_wrk_tmp = array_from_pyobj(PyArray_DOUBLE,wrk_Dims,wrk_Rank,capi_wrk_intent,Py_None); + if (capi_wrk_tmp == NULL) { + if (!PyErr_Occurred()) + PyErr_SetString(dfitpack_error,"failed in converting hidden `wrk' of dfitpack.dblint to C/Fortran array" ); + } else { + wrk = (double *)(capi_wrk_tmp->data); + +/*end of frompyobj*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_start_call_clock(); +#endif +/*callfortranroutine*/ + (*f2py_func)(&dblint,tx,&nx,ty,&ny,c,&kx,&ky,&xb,&xe,&yb,&ye,wrk); +if (PyErr_Occurred()) + f2py_success = 0; +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_call_clock(); +#endif +/*end of callfortranroutine*/ + if (f2py_success) { +/*pyobjfrom*/ +/*end of pyobjfrom*/ + CFUNCSMESS("Building return value.\n"); + capi_buildvalue = Py_BuildValue("d",dblint); +/*closepyobjfrom*/ +/*end of closepyobjfrom*/ + } /*if (f2py_success) after callfortranroutine*/ +/*cleanupfrompyobj*/ + Py_XDECREF(capi_wrk_tmp); + } /*if (capi_wrk_tmp == NULL) ... else of wrk*/ + /* End of cleaning variable wrk */ + } /*CHECKARRAY(len(c)==(nx-kx-1)*(ny-ky-1))*/ + if((PyObject *)capi_c_tmp!=c_capi) { + Py_XDECREF(capi_c_tmp); } + } /*if (capi_c_tmp == NULL) ... else of c*/ + /* End of cleaning variable c */ + /* End of cleaning variable ny */ + /* End of cleaning variable nx */ + /* End of cleaning variable dblint */ + } /*if (f2py_success) of ky*/ + /* End of cleaning variable ky */ + } /*if (f2py_success) of xe*/ + /* End of cleaning variable xe */ + } /*if (f2py_success) of ye*/ + /* End of cleaning variable ye */ + } /*if (f2py_success) of yb*/ + /* End of cleaning variable yb */ + } /*if (f2py_success) of xb*/ + /* End of cleaning variable xb */ + if((PyObject *)capi_ty_tmp!=ty_capi) { + Py_XDECREF(capi_ty_tmp); } + } /*if (capi_ty_tmp == NULL) ... else of ty*/ + /* End of cleaning variable ty */ + if((PyObject *)capi_tx_tmp!=tx_capi) { + Py_XDECREF(capi_tx_tmp); } + } /*if (capi_tx_tmp == NULL) ... else of tx*/ + /* End of cleaning variable tx */ + } /*if (f2py_success) of kx*/ + /* End of cleaning variable kx */ +/*end of cleanupfrompyobj*/ + if (capi_buildvalue == NULL) { +/*routdebugfailure*/ + } else { +/*routdebugleave*/ + } + CFUNCSMESS("Freeing memory.\n"); +/*freemem*/ +#ifdef F2PY_REPORT_ATEXIT +f2py_stop_clock(); +#endif + return capi_buildvalue; +} +/******************************* end of dblint *******************************/ +/*eof body*/ + +/******************* See f2py2e/f90mod_rules.py: buildhooks *******************/ +/*need_f90modhooks*/ + +/************** See f2py2e/rules.py: module_rules['modulebody'] **************/ + +/******************* See f2py2e/common_rules.py: buildhooks *******************/ + +/*need_commonhooks*/ + +/**************************** See f2py2e/rules.py ****************************/ + +static FortranDataDef f2py_routine_defs[] = { + {"splev",-1,{{-1}},0,(char *)F_FUNC(splev,SPLEV),(f2py_init_func)f2py_rout_dfitpack_splev,doc_f2py_rout_dfitpack_splev}, + {"splder",-1,{{-1}},0,(char *)F_FUNC(splder,SPLDER),(f2py_init_func)f2py_rout_dfitpack_splder,doc_f2py_rout_dfitpack_splder}, + {"splint",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(splint,SPLINT),(f2py_init_func)f2py_rout_dfitpack_splint,doc_f2py_rout_dfitpack_splint}, + {"sproot",-1,{{-1}},0,(char *)F_FUNC(sproot,SPROOT),(f2py_init_func)f2py_rout_dfitpack_sproot,doc_f2py_rout_dfitpack_sproot}, + {"spalde",-1,{{-1}},0,(char *)F_FUNC(spalde,SPALDE),(f2py_init_func)f2py_rout_dfitpack_spalde,doc_f2py_rout_dfitpack_spalde}, + {"curfit",-1,{{-1}},0,(char *)F_FUNC(curfit,CURFIT),(f2py_init_func)f2py_rout_dfitpack_curfit,doc_f2py_rout_dfitpack_curfit}, + {"percur",-1,{{-1}},0,(char *)F_FUNC(percur,PERCUR),(f2py_init_func)f2py_rout_dfitpack_percur,doc_f2py_rout_dfitpack_percur}, + {"parcur",-1,{{-1}},0,(char *)F_FUNC(parcur,PARCUR),(f2py_init_func)f2py_rout_dfitpack_parcur,doc_f2py_rout_dfitpack_parcur}, + {"fpcurf0",-1,{{-1}},0,(char *)F_FUNC(fpcurf,FPCURF),(f2py_init_func)f2py_rout_dfitpack_fpcurf0,doc_f2py_rout_dfitpack_fpcurf0}, + {"fpcurf1",-1,{{-1}},0,(char *)F_FUNC(fpcurf,FPCURF),(f2py_init_func)f2py_rout_dfitpack_fpcurf1,doc_f2py_rout_dfitpack_fpcurf1}, + {"fpcurfm1",-1,{{-1}},0,(char *)F_FUNC(fpcurf,FPCURF),(f2py_init_func)f2py_rout_dfitpack_fpcurfm1,doc_f2py_rout_dfitpack_fpcurfm1}, + {"bispev",-1,{{-1}},0,(char *)F_FUNC(bispev,BISPEV),(f2py_init_func)f2py_rout_dfitpack_bispev,doc_f2py_rout_dfitpack_bispev}, + {"surfit_smth",-1,{{-1}},0,(char *)F_FUNC(surfit,SURFIT),(f2py_init_func)f2py_rout_dfitpack_surfit_smth,doc_f2py_rout_dfitpack_surfit_smth}, + {"surfit_lsq",-1,{{-1}},0,(char *)F_FUNC(surfit,SURFIT),(f2py_init_func)f2py_rout_dfitpack_surfit_lsq,doc_f2py_rout_dfitpack_surfit_lsq}, + {"regrid_smth",-1,{{-1}},0,(char *)F_FUNC(regrid,REGRID),(f2py_init_func)f2py_rout_dfitpack_regrid_smth,doc_f2py_rout_dfitpack_regrid_smth}, + {"dblint",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(dblint,DBLINT),(f2py_init_func)f2py_rout_dfitpack_dblint,doc_f2py_rout_dfitpack_dblint}, + +/*eof routine_defs*/ + {NULL} +}; + +static PyMethodDef f2py_module_methods[] = { + + {NULL,NULL} +}; + +PyMODINIT_FUNC initdfitpack(void) { + int i; + PyObject *m,*d, *s; + m = dfitpack_module = Py_InitModule("dfitpack", f2py_module_methods); + PyFortran_Type.ob_type = &PyType_Type; + import_array(); + if (PyErr_Occurred()) + {PyErr_SetString(PyExc_ImportError, "can't initialize module dfitpack (failed to import numpy)"); return;} + d = PyModule_GetDict(m); + s = PyString_FromString("$Revision: $"); + PyDict_SetItemString(d, "__version__", s); + s = PyString_FromString("This module 'dfitpack' is auto-generated with f2py (version:2_4422).\nFunctions:\n" +" y = splev(t,c,k,x)\n" +" y = splder(t,c,k,x,nu=1)\n" +" splint = splint(t,c,k,a,b)\n" +" zero,m,ier = sproot(t,c,mest=3*(n-7))\n" +" d,ier = spalde(t,c,k,x)\n" +" n,c,fp,ier = curfit(iopt,x,y,w,t,wrk,iwrk,xb=x[0],xe=x[m-1],k=3,s=0.0)\n" +" n,c,fp,ier = percur(iopt,x,y,w,t,wrk,iwrk,k=3,s=0.0)\n" +" n,c,fp,ier = parcur(iopt,ipar,idim,u,x,w,ub,ue,t,wrk,iwrk,k=3.0,s=0.0)\n" +" x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = fpcurf0(x,y,k,w=1.0,xb=x[0],xe=x[m-1],s=m,nest=(s==0.0?m+k+1:MAX(m/2,2*k1)))\n" +" x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = fpcurf1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier,overwrite_x=1,overwrite_y=1,overwrite_w=1,overwrite_t=1,overwrite_c=1,overwrite_fpint=1,overwrite_nrdata=1)\n" +" x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = fpcurfm1(x,y,k,t,w=1.0,xb=x[0],xe=x[m-1],overwrite_t=1)\n" +" z,ier = bispev(tx,ty,c,kx,ky,x,y)\n" +" nx,tx,ny,ty,c,fp,wrk1,ier = surfit_smth(x,y,z,w=1.0,xb=dmin(x,m),xe=dmax(x,m),yb=dmin(y,m),ye=dmax(y,m),kx=3,ky=3,s=m,nxest=imax(kx+1+sqrt(m/2),2*(kx+1)),nyest=imax(ky+1+sqrt(m/2),2*(ky+1)),eps=1e-016,lwrk2=calc_surfit_lwrk2(m,kx,ky,nxest,nyest))\n" +" tx,ty,c,fp,ier = surfit_lsq(x,y,z,tx,ty,w=1.0,xb=calc_b(x,m,tx,nx),xe=calc_e(x,m,tx,nx),yb=calc_b(y,m,ty,ny),ye=calc_e(y,m,ty,ny),kx=3,ky=3,eps=1e-016,lwrk2=calc_surfit_lwrk2(m,kx,ky,nxest,nyest),overwrite_tx=1,overwrite_ty=1)\n" +" nx,tx,ny,ty,c,fp,ier = regrid_smth(x,y,z,xb=dmin(x,mx),xe=dmax(x,mx),yb=dmin(y,my),ye=dmax(y,my),kx=3,ky=3,s=0.0)\n" +" dblint = dblint(tx,ty,c,kx,ky,xb,xe,yb,ye)\n" +"."); + PyDict_SetItemString(d, "__doc__", s); + dfitpack_error = PyErr_NewException ("dfitpack.error", NULL, NULL); + Py_DECREF(s); + for(i=0;f2py_routine_defs[i].name!=NULL;i++) + PyDict_SetItemString(d, f2py_routine_defs[i].name,PyFortranObject_NewAsAttr(&f2py_routine_defs[i])); + + + + { + extern double F_FUNC(splint,SPLINT)(void); + PyObject* o = PyDict_GetItemString(d,"splint"); + PyObject_SetAttrString(o,"_cpointer", PyCObject_FromVoidPtr((void*)F_FUNC(splint,SPLINT),NULL)); + } + + + + + + + + + + + + + + + { + extern double F_FUNC(dblint,DBLINT)(void); + PyObject* o = PyDict_GetItemString(d,"dblint"); + PyObject_SetAttrString(o,"_cpointer", PyCObject_FromVoidPtr((void*)F_FUNC(dblint,DBLINT),NULL)); + } + +/*eof initf2pywraphooks*/ +/*eof initf90modhooks*/ + +/*eof initcommonhooks*/ + + +#ifdef F2PY_REPORT_ATEXIT + if (! PyErr_Occurred()) + on_exit(f2py_report_on_exit,(void*)"dfitpack"); +#endif + +} +#ifdef __cplusplus +} +#endif Added: branches/Interpolate1D/build/src.win32-2.5/fitpack.pyf =================================================================== --- branches/Interpolate1D/build/src.win32-2.5/fitpack.pyf 2008-07-16 00:26:23 UTC (rev 4545) +++ branches/Interpolate1D/build/src.win32-2.5/fitpack.pyf 2008-07-16 22:08:51 UTC (rev 4546) @@ -0,0 +1,479 @@ +! -*- f90 -*- +! Author: Pearu Peterson +! +python module dfitpack ! in + + usercode ''' + +static double dmax(double* seq,int len) { + double val; + int i; + if (len<1) + return -1e308; + val = seq[0]; + for(i=1;ival) val = seq[i]; + return val; +} +static double dmin(double* seq,int len) { + double val; + int i; + if (len<1) + return 1e308; + val = seq[0]; + for(i=1;ival1) return val1; + val1 = dmax(tx,nx); + return val2 - (val1-val2)/nx; +} +static double calc_e(double* x,int m,double* tx,int nx) { + double val1 = dmax(x,m); + double val2 = dmax(tx,nx); + if (val2=8) :: n=len(t) + real*8 dimension(n),depend(n),check(len(c)==n) :: c + real*8 dimension(mest),intent(out),depend(mest) :: zero + integer optional,intent(in),depend(n) :: mest=3*(n-7) + integer intent(out) :: m + integer intent(out) :: ier + end subroutine sproot + + subroutine spalde(t,n,c,k,x,d,ier) + ! d,ier = spalde(t,c,k,x) + + callprotoargument double*,int*,double*,int*,double*,double*,int* + callstatement {int k1=k+1; (*f2py_func)(t,&n,c,&k1,&x,d,&ier); } + + real*8 dimension(n) :: t + integer intent(hide),depend(t) :: n=len(t) + real*8 dimension(n),depend(n),check(len(c)==n) :: c + integer intent(in) :: k + real*8 intent(in) :: x + real*8 dimension(k+1),intent(out),depend(k) :: d + integer intent(out) :: ier + end subroutine spalde + + subroutine curfit(iopt,m,x,y,w,xb,xe,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! in curfit.f + integer :: iopt + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(w)==m) :: w + real*8 optional,depend(x),check(xb<=x[0]) :: xb = x[0] + real*8 optional,depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] + integer optional,check(1<=k && k <=5),intent(in) :: k=3 + real*8 optional,check(s>=0.0) :: s = 0.0 + integer intent(hide),depend(t) :: nest=len(t) + integer intent(out), depend(nest) :: n=nest + real*8 dimension(nest),intent(inout) :: t + real*8 dimension(n),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(inout) :: wrk + integer intent(hide),depend(wrk) :: lwrk=len(wrk) + integer dimension(nest),intent(inout) :: iwrk + integer intent(out) :: ier + end subroutine curfit + + subroutine percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! in percur.f + integer :: iopt + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(w)==m) :: w + integer optional,check(1<=k && k <=5),intent(in) :: k=3 + real*8 optional,check(s>=0.0) :: s = 0.0 + integer intent(hide),depend(t) :: nest=len(t) + integer intent(out), depend(nest) :: n=nest + real*8 dimension(nest),intent(inout) :: t + real*8 dimension(n),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(inout) :: wrk + integer intent(hide),depend(wrk) :: lwrk=len(wrk) + integer dimension(nest),intent(inout) :: iwrk + integer intent(out) :: ier + end subroutine percur + + + subroutine parcur(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,c,fp,wrk,lwrk,iwrk,ier) + ! in parcur.f + integer check(iopt>=-1 && iopt <= 1):: iopt + integer check(ipar == 1 || ipar == 0) :: ipar + integer check(idim > 0 && idim < 11) :: idim + integer intent(hide),depend(u,k),check(m>k) :: m=len(u) + real*8 dimension(m), intent(inout) :: u + integer intent(hide),depend(x,idim,m),check(mx>=idim*m) :: mx=len(x) + real*8 dimension(mx) :: x + real*8 dimension(m) :: w + real*8 :: ub + real*8 :: ue + integer optional, check(1<=k && k<=5) :: k=3.0 + real*8 optional, check(s>=0.0) :: s = 0.0 + integer intent(hide), depend(t) :: nest=len(t) + integer intent(out), depend(nest) :: n=nest + real*8 dimension(nest), intent(inout) :: t + integer intent(hide), depend(c,nest,idim), check(nc>=idim*nest) :: nc=len(c) + real*8 dimension(nc), intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk), intent(inout) :: wrk + integer intent(hide),depend(wrk) :: lwrk=len(wrk) + integer dimension(nest), intent(inout) :: iwrk + integer intent(out) :: ier + end subroutine parcur + + + subroutine fpcurf0(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ + ! fpcurf0(x,y,k,[w,xb,xe,s,nest]) + + fortranname fpcurf + callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* + callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) + + integer intent(hide) :: iopt = 0 + real*8 dimension(m),intent(in,out) :: x + real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y + real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out) :: w = 1.0 + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 intent(in,out),depend(x),check(xb<=x[0]) :: xb = x[0] + real*8 intent(in,out),depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] + integer check(1<=k && k<=5),intent(in,out) :: k + real*8 check(s>=0.0),depend(m),intent(in,out) :: s = m + integer intent(in),depend(m,s,k,k1),check(nest>=2*k1) :: nest = (s==0.0?m+k+1:MAX(m/2,2*k1)) + real*8 intent(hide) :: tol = 0.001 + integer intent(hide) :: maxit = 20 + integer intent(hide),depend(k) :: k1=k+1 + integer intent(hide),depend(k) :: k2=k+2 + integer intent(out) :: n + real*8 dimension(nest),intent(out),depend(nest) :: t + real*8 dimension(nest),depend(nest),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(nest),depend(nest),intent(out,cache) :: fpint + real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk + integer dimension(nest),depend(nest),intent(out,cache) :: nrdata + integer intent(out) :: ier + end subroutine fpcurf0 + + subroutine fpcurf1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ + ! fpcurf1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier) + + fortranname fpcurf + callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* + callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) + + integer intent(hide) :: iopt = 1 + real*8 dimension(m),intent(in,out,overwrite) :: x + real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out,overwrite) :: y + real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out,overwrite) :: w + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 intent(in,out) :: xb + real*8 intent(in,out) :: xe + integer check(1<=k && k<=5),intent(in,out) :: k + real*8 check(s>=0.0),intent(in,out) :: s + integer intent(hide),depend(t) :: nest = len(t) + real*8 intent(hide) :: tol = 0.001 + integer intent(hide) :: maxit = 20 + integer intent(hide),depend(k) :: k1=k+1 + integer intent(hide),depend(k) :: k2=k+2 + integer intent(in,out) :: n + real*8 dimension(nest),intent(in,out,overwrite) :: t + real*8 dimension(nest),depend(nest),check(len(c)==nest),intent(in,out,overwrite) :: c + real*8 intent(in,out) :: fp + real*8 dimension(nest),depend(nest),check(len(fpint)==nest),intent(in,out,cache,overwrite) :: fpint + real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk + integer dimension(nest),depend(nest),check(len(nrdata)==nest),intent(in,out,cache,overwrite) :: nrdata + integer intent(in,out) :: ier + end subroutine fpcurf1 + + subroutine fpcurfm1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ + ! fpcurfm1(x,y,k,t,[w,xb,xe]) + + fortranname fpcurf + callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* + callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) + + integer intent(hide) :: iopt = -1 + real*8 dimension(m),intent(in,out) :: x + real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y + real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out) :: w = 1.0 + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 intent(in,out),depend(x),check(xb<=x[0]) :: xb = x[0] + real*8 intent(in,out),depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] + integer check(1<=k && k<=5),intent(in,out) :: k + real*8 intent(out) :: s = -1 + integer intent(hide),depend(n) :: nest = n + real*8 intent(hide) :: tol = 0.001 + integer intent(hide) :: maxit = 20 + integer intent(hide),depend(k) :: k1=k+1 + integer intent(hide),depend(k) :: k2=k+2 + integer intent(out),depend(t) :: n = len(t) + real*8 dimension(n),intent(in,out,overwrite) :: t + real*8 dimension(nest),depend(nest),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(nest),depend(nest),intent(out,cache) :: fpint + real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk + integer dimension(nest),depend(nest),intent(out,cache) :: nrdata + integer intent(out) :: ier + end subroutine fpcurfm1 + + !!!!!!!!!! Bivariate spline !!!!!!!!!!! + + subroutine bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk,iwrk,kwrk,ier) + ! z,ier = bispev(tx,ty,c,kx,ky,x,y) + real*8 dimension(nx),intent(in) :: tx + integer intent(hide),depend(tx) :: nx=len(tx) + real*8 dimension(ny),intent(in) :: ty + integer intent(hide),depend(ty) :: ny=len(ty) + real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& + check(len(c)==(nx-kx-1)*(ny-ky-1)):: c + integer :: kx + integer :: ky + real*8 intent(in),dimension(mx) :: x + integer intent(hide),depend(x) :: mx=len(x) + real*8 intent(in),dimension(my) :: y + integer intent(hide),depend(y) :: my=len(y) + real*8 dimension(mx,my),depend(mx,my),intent(out,c) :: z + real*8 dimension(lwrk),depend(lwrk),intent(hide,cache) :: wrk + integer intent(hide),depend(mx,kx,my,ky) :: lwrk=mx*(kx+1)+my*(ky+1) + integer dimension(kwrk),depend(kwrk),intent(hide,cache) :: iwrk + integer intent(hide),depend(mx,my) :: kwrk=mx+my + integer intent(out) :: ier + end subroutine bispev + + subroutine surfit_smth(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest,& + nmax,eps,nx,tx,ny,ty,c,fp,wrk1,lwrk1,wrk2,lwrk2,& + iwrk,kwrk,ier) + ! nx,tx,ny,ty,c,fp,ier = surfit_smth(x,y,z,[w,xb,xe,yb,ye,kx,ky,s,eps,lwrk2]) + + fortranname surfit + + integer intent(hide) :: iopt=0 + integer intent(hide),depend(x,kx,ky),check(m>=(kx+1)*(ky+1)) & + :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(z)==m) :: z + real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 + real*8 optional,depend(x,m) :: xb=dmin(x,m) + real*8 optional,depend(x,m) :: xe=dmax(x,m) + real*8 optional,depend(y,m) :: yb=dmin(y,m) + real*8 optional,depend(y,m) :: ye=dmax(y,m) + integer check(1<=kx && kx<=5) :: kx = 3 + integer check(1<=ky && ky<=5) :: ky = 3 + real*8 optional,check(0.0<=s) :: s = m + integer optional,depend(kx,m),check(nxest>=2*(kx+1)) & + :: nxest = imax(kx+1+sqrt(m/2),2*(kx+1)) + integer optional,depend(ky,m),check(nyest>=2*(ky+1)) & + :: nyest = imax(ky+1+sqrt(m/2),2*(ky+1)) + integer intent(hide),depend(nxest,nyest) :: nmax=MAX(nxest,nyest) + real*8 optional,check(0.0=(kx+1)*(ky+1)) & + :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(z)==m) :: z + real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 + real*8 optional,depend(x,tx,m,nx) :: xb=calc_b(x,m,tx,nx) + real*8 optional,depend(x,tx,m,nx) :: xe=calc_e(x,m,tx,nx) + real*8 optional,depend(y,ty,m,ny) :: yb=calc_b(y,m,ty,ny) + real*8 optional,depend(y,ty,m,ny) :: ye=calc_e(y,m,ty,ny) + integer check(1<=kx && kx<=5) :: kx = 3 + integer check(1<=ky && ky<=5) :: ky = 3 + real*8 intent(hide) :: s = 0.0 + integer intent(hide),depend(nx) :: nxest = nx + integer intent(hide),depend(ny) :: nyest = ny + integer intent(hide),depend(nx,ny) :: nmax=MAX(nx,ny) + real*8 optional,check(0.0kx) :: mx=len(x) + real*8 dimension(mx) :: x + integer intent(hide),depend(y,ky),check(my>ky) :: my=len(y) + real*8 dimension(my) :: y + real*8 dimension(mx*my),depend(mx,my),check(len(z)==mx*my) :: z + real*8 optional,depend(x,mx) :: xb=dmin(x,mx) + real*8 optional,depend(x,mx) :: xe=dmax(x,mx) + real*8 optional,depend(y,my) :: yb=dmin(y,my) + real*8 optional,depend(y,my) :: ye=dmax(y,my) + integer optional,check(1<=kx && kx<=5) :: kx = 3 + integer optional,check(1<=ky && ky<=5) :: ky = 3 + real*8 optional,check(0.0<=s) :: s = 0.0 + integer intent(hide),depend(kx,mx),check(nxest>=2*(kx+1)) & + :: nxest = mx+kx+1 + integer intent(hide),depend(ky,my),check(nyest>=2*(ky+1)) & + :: nyest = my+ky+1 + integer intent(out) :: nx + real*8 dimension(nxest),intent(out),depend(nxest) :: tx + integer intent(out) :: ny + real*8 dimension(nyest),intent(out),depend(nyest) :: ty + real*8 dimension((nxest-kx-1)*(nyest-ky-1)), & + depend(kx,ky,nxest,nyest),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(cache,hide),depend(lwrk) :: wrk + integer intent(hide),depend(mx,my,kx,ky,nxest,nyest) & + :: lwrk=calc_regrid_lwrk(mx,my,kx,ky,nxest,nyest) + integer dimension(kwrk),depend(kwrk),intent(cache,hide) :: iwrk + integer intent(hide),depend(mx,my,nxest,nyest) & + :: kwrk=3+mx+my+nxest+nyest + integer intent(out) :: ier + end subroutine regrid_smth + + function dblint(tx,nx,ty,ny,c,kx,ky,xb,xe,yb,ye,wrk) + ! iy = dblint(tx,ty,c,kx,ky,xb,xe,yb,ye) + real*8 dimension(nx),intent(in) :: tx + integer intent(hide),depend(tx) :: nx=len(tx) + real*8 dimension(ny),intent(in) :: ty + integer intent(hide),depend(ty) :: ny=len(ty) + real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& + check(len(c)==(nx-kx-1)*(ny-ky-1)):: c + integer :: kx + integer :: ky + real*8 intent(in) :: xb + real*8 intent(in) :: xe + real*8 intent(in) :: yb + real*8 intent(in) :: ye + real*8 dimension(nx+ny-kx-ky-2),depend(nx,ny,kx,ky),intent(cache,hide) :: wrk + real*8 :: dblint + end function dblint + end interface +end python module dfitpack + Added: branches/Interpolate1D/build/src.win32-2.5/fortranobject.c =================================================================== --- branches/Interpolate1D/build/src.win32-2.5/fortranobject.c 2008-07-16 00:26:23 UTC (rev 4545) +++ branches/Interpolate1D/build/src.win32-2.5/fortranobject.c 2008-07-16 22:08:51 UTC (rev 4546) @@ -0,0 +1,816 @@ +#define FORTRANOBJECT_C +#include "fortranobject.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + This file implements: FortranObject, array_from_pyobj, copy_ND_array + + Author: Pearu Peterson + $Revision: 1.52 $ + $Date: 2005/07/11 07:44:20 $ +*/ + +int +F2PyDict_SetItemString(PyObject *dict, char *name, PyObject *obj) +{ + if (obj==NULL) { + fprintf(stderr, "Error loading %s\n", name); + if (PyErr_Occurred()) { + PyErr_Print(); + PyErr_Clear(); + } + return -1; + } + return PyDict_SetItemString(dict, name, obj); +} + +/************************* FortranObject *******************************/ + +typedef PyObject *(*fortranfunc)(PyObject *,PyObject *,PyObject *,void *); + +PyObject * +PyFortranObject_New(FortranDataDef* defs, f2py_void_func init) { + int i; + PyFortranObject *fp = NULL; + PyObject *v = NULL; + if (init!=NULL) /* Initialize F90 module objects */ + (*(init))(); + if ((fp = PyObject_New(PyFortranObject, &PyFortran_Type))==NULL) return NULL; + if ((fp->dict = PyDict_New())==NULL) return NULL; + fp->len = 0; + while (defs[fp->len].name != NULL) fp->len++; + if (fp->len == 0) goto fail; + fp->defs = defs; + for (i=0;ilen;i++) + if (fp->defs[i].rank == -1) { /* Is Fortran routine */ + v = PyFortranObject_NewAsAttr(&(fp->defs[i])); + if (v==NULL) return NULL; + PyDict_SetItemString(fp->dict,fp->defs[i].name,v); + } else + if ((fp->defs[i].data)!=NULL) { /* Is Fortran variable or array (not allocatable) */ + if (fp->defs[i].type == PyArray_STRING) { + int n = fp->defs[i].rank-1; + v = PyArray_New(&PyArray_Type, n, fp->defs[i].dims.d, + PyArray_STRING, NULL, fp->defs[i].data, fp->defs[i].dims.d[n], + NPY_FARRAY, NULL); + } + else { + v = PyArray_New(&PyArray_Type, fp->defs[i].rank, fp->defs[i].dims.d, + fp->defs[i].type, NULL, fp->defs[i].data, 0, NPY_FARRAY, + NULL); + } + if (v==NULL) return NULL; + PyDict_SetItemString(fp->dict,fp->defs[i].name,v); + } + Py_XDECREF(v); + return (PyObject *)fp; + fail: + Py_XDECREF(v); + return NULL; +} + +PyObject * +PyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module routines */ + PyFortranObject *fp = NULL; + fp = PyObject_New(PyFortranObject, &PyFortran_Type); + if (fp == NULL) return NULL; + if ((fp->dict = PyDict_New())==NULL) return NULL; + fp->len = 1; + fp->defs = defs; + return (PyObject *)fp; +} + +/* Fortran methods */ + +static void +fortran_dealloc(PyFortranObject *fp) { + Py_XDECREF(fp->dict); + PyMem_Del(fp); +} + + +static PyMethodDef fortran_methods[] = { + {NULL, NULL} /* sentinel */ +}; + + +static PyObject * +fortran_doc (FortranDataDef def) { + char *p; + PyObject *s = NULL; + int i; + unsigned size=100; + if (def.doc!=NULL) + size += strlen(def.doc); + p = (char*)malloc (size); + if (sprintf(p,"%s - ",def.name)==0) goto fail; + if (def.rank==-1) { + if (def.doc==NULL) { + if (sprintf(p,"%sno docs available",p)==0) + goto fail; + } else { + if (sprintf(p,"%s%s",p,def.doc)==0) + goto fail; + } + } else { + PyArray_Descr *d = PyArray_DescrFromType(def.type); + if (sprintf(p,"%s'%c'-",p,d->type)==0) {Py_DECREF(d); goto fail;} + Py_DECREF(d); + if (def.data==NULL) { + if (sprintf(p,"%sarray(%" NPY_INTP_FMT,p,def.dims.d[0])==0) goto fail; + for(i=1;i0) { + if (sprintf(p,"%sarray(%"NPY_INTP_FMT,p,def.dims.d[0])==0) goto fail; + for(i=1;isize) { + fprintf(stderr,"fortranobject.c:fortran_doc:len(p)=%zd>%d(size): too long doc string required, increase size\n",strlen(p),size); + goto fail; + } + s = PyString_FromString(p); + fail: + free(p); + return s; +} + +static FortranDataDef *save_def; /* save pointer of an allocatable array */ +static void set_data(char *d,npy_intp *f) { /* callback from Fortran */ + if (*f) /* In fortran f=allocated(d) */ + save_def->data = d; + else + save_def->data = NULL; + /* printf("set_data: d=%p,f=%d\n",d,*f); */ +} + +static PyObject * +fortran_getattr(PyFortranObject *fp, char *name) { + int i,j,k,flag; + if (fp->dict != NULL) { + PyObject *v = PyDict_GetItemString(fp->dict, name); + if (v != NULL) { + Py_INCREF(v); + return v; + } + } + for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++); + if (j==0) + if (fp->defs[i].rank!=-1) { /* F90 allocatable array */ + if (fp->defs[i].func==NULL) return NULL; + for(k=0;kdefs[i].rank;++k) + fp->defs[i].dims.d[k]=-1; + save_def = &fp->defs[i]; + (*(fp->defs[i].func))(&fp->defs[i].rank,fp->defs[i].dims.d,set_data,&flag); + if (flag==2) + k = fp->defs[i].rank + 1; + else + k = fp->defs[i].rank; + if (fp->defs[i].data !=NULL) { /* array is allocated */ + PyObject *v = PyArray_New(&PyArray_Type, k, fp->defs[i].dims.d, + fp->defs[i].type, NULL, fp->defs[i].data, 0, NPY_FARRAY, + NULL); + if (v==NULL) return NULL; + /* Py_INCREF(v); */ + return v; + } else { /* array is not allocated */ + Py_INCREF(Py_None); + return Py_None; + } + } + if (strcmp(name,"__dict__")==0) { + Py_INCREF(fp->dict); + return fp->dict; + } + if (strcmp(name,"__doc__")==0) { + PyObject *s = PyString_FromString(""); + for (i=0;ilen;i++) + PyString_ConcatAndDel(&s,fortran_doc(fp->defs[i])); + if (PyDict_SetItemString(fp->dict, name, s)) + return NULL; + return s; + } + if ((strcmp(name,"_cpointer")==0) && (fp->len==1)) { + PyObject *cobj = PyCObject_FromVoidPtr((void *)(fp->defs[0].data),NULL); + if (PyDict_SetItemString(fp->dict, name, cobj)) + return NULL; + return cobj; + } + return Py_FindMethod(fortran_methods, (PyObject *)fp, name); +} + +static int +fortran_setattr(PyFortranObject *fp, char *name, PyObject *v) { + int i,j,flag; + PyArrayObject *arr = NULL; + for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++); + if (j==0) { + if (fp->defs[i].rank==-1) { + PyErr_SetString(PyExc_AttributeError,"over-writing fortran routine"); + return -1; + } + if (fp->defs[i].func!=NULL) { /* is allocatable array */ + npy_intp dims[F2PY_MAX_DIMS]; + int k; + save_def = &fp->defs[i]; + if (v!=Py_None) { /* set new value (reallocate if needed -- + see f2py generated code for more + details ) */ + for(k=0;kdefs[i].rank;k++) dims[k]=-1; + if ((arr = array_from_pyobj(fp->defs[i].type,dims,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL) + return -1; + (*(fp->defs[i].func))(&fp->defs[i].rank,arr->dimensions,set_data,&flag); + } else { /* deallocate */ + for(k=0;kdefs[i].rank;k++) dims[k]=0; + (*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag); + for(k=0;kdefs[i].rank;k++) dims[k]=-1; + } + memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(npy_intp)); + } else { /* not allocatable array */ + if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL) + return -1; + } + if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */ + npy_intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd); + if (s==-1) + s = PyArray_MultiplyList(arr->dimensions,arr->nd); + if (s<0 || + (memcpy(fp->defs[i].data,arr->data,s*PyArray_ITEMSIZE(arr)))==NULL) { + if ((PyObject*)arr!=v) { + Py_DECREF(arr); + } + return -1; + } + if ((PyObject*)arr!=v) { + Py_DECREF(arr); + } + } else return (fp->defs[i].func==NULL?-1:0); + return 0; /* succesful */ + } + if (fp->dict == NULL) { + fp->dict = PyDict_New(); + if (fp->dict == NULL) + return -1; + } + if (v == NULL) { + int rv = PyDict_DelItemString(fp->dict, name); + if (rv < 0) + PyErr_SetString(PyExc_AttributeError,"delete non-existing fortran attribute"); + return rv; + } + else + return PyDict_SetItemString(fp->dict, name, v); +} + +static PyObject* +fortran_call(PyFortranObject *fp, PyObject *arg, PyObject *kw) { + int i = 0; + /* printf("fortran call + name=%s,func=%p,data=%p,%p\n",fp->defs[i].name, + fp->defs[i].func,fp->defs[i].data,&fp->defs[i].data); */ + if (fp->defs[i].rank==-1) {/* is Fortran routine */ + if ((fp->defs[i].func==NULL)) { + PyErr_Format(PyExc_RuntimeError, "no function to call"); + return NULL; + } + else if (fp->defs[i].data==NULL) + /* dummy routine */ + return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,NULL); + else + return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw, + (void *)fp->defs[i].data); + } + PyErr_Format(PyExc_TypeError, "this fortran object is not callable"); + return NULL; +} + + +PyTypeObject PyFortran_Type = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "fortran", /*tp_name*/ + sizeof(PyFortranObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)fortran_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + (getattrfunc)fortran_getattr, /*tp_getattr*/ + (setattrfunc)fortran_setattr, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + (ternaryfunc)fortran_call, /*tp_call*/ +}; + +/************************* f2py_report_atexit *******************************/ + +#ifdef F2PY_REPORT_ATEXIT +static int passed_time = 0; +static int passed_counter = 0; +static int passed_call_time = 0; +static struct timeb start_time; +static struct timeb stop_time; +static struct timeb start_call_time; +static struct timeb stop_call_time; +static int cb_passed_time = 0; +static int cb_passed_counter = 0; +static int cb_passed_call_time = 0; +static struct timeb cb_start_time; +static struct timeb cb_stop_time; +static struct timeb cb_start_call_time; +static struct timeb cb_stop_call_time; + +extern void f2py_start_clock(void) { ftime(&start_time); } +extern +void f2py_start_call_clock(void) { + f2py_stop_clock(); + ftime(&start_call_time); +} +extern +void f2py_stop_clock(void) { + ftime(&stop_time); + passed_time += 1000*(stop_time.time - start_time.time); + passed_time += stop_time.millitm - start_time.millitm; +} +extern +void f2py_stop_call_clock(void) { + ftime(&stop_call_time); + passed_call_time += 1000*(stop_call_time.time - start_call_time.time); + passed_call_time += stop_call_time.millitm - start_call_time.millitm; + passed_counter += 1; + f2py_start_clock(); +} + +extern void f2py_cb_start_clock(void) { ftime(&cb_start_time); } +extern +void f2py_cb_start_call_clock(void) { + f2py_cb_stop_clock(); + ftime(&cb_start_call_time); +} +extern +void f2py_cb_stop_clock(void) { + ftime(&cb_stop_time); + cb_passed_time += 1000*(cb_stop_time.time - cb_start_time.time); + cb_passed_time += cb_stop_time.millitm - cb_start_time.millitm; +} +extern +void f2py_cb_stop_call_clock(void) { + ftime(&cb_stop_call_time); + cb_passed_call_time += 1000*(cb_stop_call_time.time - cb_start_call_time.time); + cb_passed_call_time += cb_stop_call_time.millitm - cb_start_call_time.millitm; + cb_passed_counter += 1; + f2py_cb_start_clock(); +} + +static int f2py_report_on_exit_been_here = 0; +extern +void f2py_report_on_exit(int exit_flag,void *name) { + if (f2py_report_on_exit_been_here) { + fprintf(stderr," %s\n",(char*)name); + return; + } + f2py_report_on_exit_been_here = 1; + fprintf(stderr," /-----------------------\\\n"); + fprintf(stderr," < F2PY performance report >\n"); + fprintf(stderr," \\-----------------------/\n"); + fprintf(stderr,"Overall time spent in ...\n"); + fprintf(stderr,"(a) wrapped (Fortran/C) functions : %8d msec\n", + passed_call_time); + fprintf(stderr,"(b) f2py interface, %6d calls : %8d msec\n", + passed_counter,passed_time); + fprintf(stderr,"(c) call-back (Python) functions : %8d msec\n", + cb_passed_call_time); + fprintf(stderr,"(d) f2py call-back interface, %6d calls : %8d msec\n", + cb_passed_counter,cb_passed_time); + + fprintf(stderr,"(e) wrapped (Fortran/C) functions (acctual) : %8d msec\n\n", + passed_call_time-cb_passed_call_time-cb_passed_time); + fprintf(stderr,"Use -DF2PY_REPORT_ATEXIT_DISABLE to disable this message.\n"); + fprintf(stderr,"Exit status: %d\n",exit_flag); + fprintf(stderr,"Modules : %s\n",(char*)name); +} +#endif + +/********************** report on array copy ****************************/ + +#ifdef F2PY_REPORT_ON_ARRAY_COPY +static void f2py_report_on_array_copy(PyArrayObject* arr) { + const long arr_size = PyArray_Size((PyObject *)arr); + if (arr_size>F2PY_REPORT_ON_ARRAY_COPY) { + fprintf(stderr,"copied an array: size=%ld, elsize=%d\n", + arr_size, PyArray_ITEMSIZE(arr)); + } +} +static void f2py_report_on_array_copy_fromany(void) { + fprintf(stderr,"created an array from object\n"); +} + +#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR f2py_report_on_array_copy((PyArrayObject *)arr) +#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY f2py_report_on_array_copy_fromany() +#else +#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR +#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY +#endif + + +/************************* array_from_obj *******************************/ + +/* + * File: array_from_pyobj.c + * + * Description: + * ------------ + * Provides array_from_pyobj function that returns a contigious array + * object with the given dimensions and required storage order, either + * in row-major (C) or column-major (Fortran) order. The function + * array_from_pyobj is very flexible about its Python object argument + * that can be any number, list, tuple, or array. + * + * array_from_pyobj is used in f2py generated Python extension + * modules. + * + * Author: Pearu Peterson + * Created: 13-16 January 2002 + * $Id: fortranobject.c,v 1.52 2005/07/11 07:44:20 pearu Exp $ + */ + +static int +count_nonpos(const int rank, + const npy_intp *dims) { + int i=0,r=0; + while (ind; + npy_intp size = PyArray_Size((PyObject *)arr); + printf("\trank = %d, flags = %d, size = %" NPY_INTP_FMT "\n", + rank,arr->flags,size); + printf("\tstrides = "); + dump_dims(rank,arr->strides); + printf("\tdimensions = "); + dump_dims(rank,arr->dimensions); +} +#endif + +#define SWAPTYPE(a,b,t) {t c; c = (a); (a) = (b); (b) = c; } + +static int swap_arrays(PyArrayObject* arr1, PyArrayObject* arr2) { + SWAPTYPE(arr1->data,arr2->data,char*); + SWAPTYPE(arr1->nd,arr2->nd,int); + SWAPTYPE(arr1->dimensions,arr2->dimensions,npy_intp*); + SWAPTYPE(arr1->strides,arr2->strides,npy_intp*); + SWAPTYPE(arr1->base,arr2->base,PyObject*); + SWAPTYPE(arr1->descr,arr2->descr,PyArray_Descr*); + SWAPTYPE(arr1->flags,arr2->flags,int); + /* SWAPTYPE(arr1->weakreflist,arr2->weakreflist,PyObject*); */ + return 0; +} + +#define ARRAY_ISCOMPATIBLE(arr,type_num) \ + ( (PyArray_ISINTEGER(arr) && PyTypeNum_ISINTEGER(type_num)) \ + ||(PyArray_ISFLOAT(arr) && PyTypeNum_ISFLOAT(type_num)) \ + ||(PyArray_ISCOMPLEX(arr) && PyTypeNum_ISCOMPLEX(type_num)) \ + ) + +extern +PyArrayObject* array_from_pyobj(const int type_num, + npy_intp *dims, + const int rank, + const int intent, + PyObject *obj) { + /* Note about reference counting + ----------------------------- + If the caller returns the array to Python, it must be done with + Py_BuildValue("N",arr). + Otherwise, if obj!=arr then the caller must call Py_DECREF(arr). + + Note on intent(cache,out,..) + --------------------- + Don't expect correct data when returning intent(cache) array. + + */ + char mess[200]; + PyArrayObject *arr = NULL; + PyArray_Descr *descr; + char typechar; + int elsize; + + if ((intent & F2PY_INTENT_HIDE) + || ((intent & F2PY_INTENT_CACHE) && (obj==Py_None)) + || ((intent & F2PY_OPTIONAL) && (obj==Py_None)) + ) { + /* intent(cache), optional, intent(hide) */ + if (count_nonpos(rank,dims)) { + int i; + sprintf(mess,"failed to create intent(cache|hide)|optional array" + "-- must have defined dimensions but got ("); + for(i=0;ielsize; + typechar = descr->type; + Py_DECREF(descr); + if (PyArray_Check(obj)) { + arr = (PyArrayObject *)obj; + + if (intent & F2PY_INTENT_CACHE) { + /* intent(cache) */ + if (PyArray_ISONESEGMENT(obj) + && PyArray_ITEMSIZE((PyArrayObject *)obj)>=elsize) { + if (check_and_fix_dimensions((PyArrayObject *)obj,rank,dims)) { + return NULL; /*XXX: set exception */ + } + if (intent & F2PY_INTENT_OUT) + Py_INCREF(obj); + return (PyArrayObject *)obj; + } + sprintf(mess,"failed to initialize intent(cache) array"); + if (!PyArray_ISONESEGMENT(obj)) + sprintf(mess+strlen(mess)," -- input must be in one segment"); + if (PyArray_ITEMSIZE(arr)descr->type,typechar); + PyErr_SetString(PyExc_ValueError,mess); + return NULL; + } + + /* here we have always intent(in) or intent(inplace) */ + + { + PyArrayObject *retarr = (PyArrayObject *) \ + PyArray_New(&PyArray_Type, arr->nd, arr->dimensions, type_num, + NULL,NULL,0, + !(intent&F2PY_INTENT_C), + NULL); + if (retarr==NULL) + return NULL; + F2PY_REPORT_ON_ARRAY_COPY_FROMARR; + if (PyArray_CopyInto(retarr, arr)) { + Py_DECREF(retarr); + return NULL; + } + if (intent & F2PY_INTENT_INPLACE) { + if (swap_arrays(arr,retarr)) + return NULL; /* XXX: set exception */ + Py_XDECREF(retarr); + if (intent & F2PY_INTENT_OUT) + Py_INCREF(arr); + } else { + arr = retarr; + } + } + return arr; + } + + if ((intent & F2PY_INTENT_INOUT) + || (intent & F2PY_INTENT_INPLACE) + || (intent & F2PY_INTENT_CACHE)) { + sprintf(mess,"failed to initialize intent(inout|inplace|cache) array" + " -- input must be array but got %s", + PyString_AsString(PyObject_Str(PyObject_Type(obj))) + ); + PyErr_SetString(PyExc_TypeError,mess); + return NULL; + } + + { + F2PY_REPORT_ON_ARRAY_COPY_FROMANY; + arr = (PyArrayObject *) \ + PyArray_FromAny(obj,PyArray_DescrFromType(type_num), 0,0, + ((intent & F2PY_INTENT_C)?NPY_CARRAY:NPY_FARRAY) \ + | NPY_FORCECAST, NULL); + if (arr==NULL) + return NULL; + if (check_and_fix_dimensions(arr,rank,dims)) + return NULL; /*XXX: set exception */ + return arr; + } + +} + +/*****************************************/ +/* Helper functions for array_from_pyobj */ +/*****************************************/ + +static +int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,npy_intp *dims) { + /* + This function fills in blanks (that are -1\'s) in dims list using + the dimensions from arr. It also checks that non-blank dims will + match with the corresponding values in arr dimensions. + */ + const npy_intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1; +#ifdef DEBUG_COPY_ND_ARRAY + dump_attrs(arr); + printf("check_and_fix_dimensions:init: dims="); + dump_dims(rank,dims); +#endif + if (rank > arr->nd) { /* [1,2] -> [[1],[2]]; 1 -> [[1]] */ + npy_intp new_size = 1; + int free_axe = -1; + int i; + /* Fill dims where -1 or 0; check dimensions; calc new_size; */ + for(i=0;ind;++i) { + if (dims[i] >= 0) { + if (dims[i]!=arr->dimensions[i]) { + fprintf(stderr,"%d-th dimension must be fixed to %" NPY_INTP_FMT + " but got %" NPY_INTP_FMT "\n", + i,dims[i], arr->dimensions[i]); + return 1; + } + if (!dims[i]) dims[i] = 1; + } else { + dims[i] = arr->dimensions[i] ? arr->dimensions[i] : 1; + } + new_size *= dims[i]; + } + for(i=arr->nd;i1) { + fprintf(stderr,"%d-th dimension must be %" NPY_INTP_FMT + " but got 0 (not defined).\n", + i,dims[i]); + return 1; + } else if (free_axe<0) + free_axe = i; + else + dims[i] = 1; + if (free_axe>=0) { + dims[free_axe] = arr_size/new_size; + new_size *= dims[free_axe]; + } + if (new_size != arr_size) { + fprintf(stderr,"confused: new_size=%" NPY_INTP_FMT + ", arr_size=%" NPY_INTP_FMT " (maybe too many free" + " indices)\n", new_size,arr_size); + return 1; + } + } else if (rank==arr->nd) { + int i; + npy_intp d; + for (i=0; idimensions[i]; + if (dims[i]>=0) { + if (d > 1 && d!=dims[i]) { + fprintf(stderr,"%d-th dimension must be fixed to %" NPY_INTP_FMT + " but got %" NPY_INTP_FMT "\n", + i,dims[i],d); + return 1; + } + if (!dims[i]) dims[i] = 1; + } else dims[i] = d; + } + } else { /* [[1,2]] -> [[1],[2]] */ + int i,j; + npy_intp d; + int effrank; + npy_intp size; + for (i=0,effrank=0;ind;++i) + if (arr->dimensions[i]>1) ++effrank; + if (dims[rank-1]>=0) + if (effrank>rank) { + fprintf(stderr,"too many axes: %d (effrank=%d), expected rank=%d\n", + arr->nd,effrank,rank); + return 1; + } + + for (i=0,j=0;ind && arr->dimensions[j]<2) ++j; + if (j>=arr->nd) d = 1; + else d = arr->dimensions[j++]; + if (dims[i]>=0) { + if (d>1 && d!=dims[i]) { + fprintf(stderr,"%d-th dimension must be fixed to %" NPY_INTP_FMT + " but got %" NPY_INTP_FMT " (real index=%d)\n", + i,dims[i],d,j-1); + return 1; + } + if (!dims[i]) dims[i] = 1; + } else + dims[i] = d; + } + + for (i=rank;ind;++i) { /* [[1,2],[3,4]] -> [1,2,3,4] */ + while (jnd && arr->dimensions[j]<2) ++j; + if (j>=arr->nd) d = 1; + else d = arr->dimensions[j++]; + dims[rank-1] *= d; + } + for (i=0,size=1;ind); + for (i=0;ind;++i) fprintf(stderr," %" NPY_INTP_FMT,arr->dimensions[i]); + fprintf(stderr," ]\n"); + return 1; + } + } +#ifdef DEBUG_COPY_ND_ARRAY + printf("check_and_fix_dimensions:end: dims="); + dump_dims(rank,dims); +#endif + return 0; +} + +/* End of file: array_from_pyobj.c */ + +/************************* copy_ND_array *******************************/ + +extern +int copy_ND_array(const PyArrayObject *arr, PyArrayObject *out) +{ + F2PY_REPORT_ON_ARRAY_COPY_FROMARR; + return PyArray_CopyInto(out, (PyArrayObject *)arr); +} + +#ifdef __cplusplus +} +#endif +/************************* EOF fortranobject.c *******************************/ Added: branches/Interpolate1D/build/src.win32-2.5/fortranobject.h =================================================================== --- branches/Interpolate1D/build/src.win32-2.5/fortranobject.h 2008-07-16 00:26:23 UTC (rev 4545) +++ branches/Interpolate1D/build/src.win32-2.5/fortranobject.h 2008-07-16 22:08:51 UTC (rev 4546) @@ -0,0 +1,124 @@ +#ifndef Py_FORTRANOBJECT_H +#define Py_FORTRANOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "Python.h" + +#ifdef FORTRANOBJECT_C +#define NO_IMPORT_ARRAY +#endif +#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API +#include "numpy/arrayobject.h" + + /* +#ifdef F2PY_REPORT_ATEXIT_DISABLE +#undef F2PY_REPORT_ATEXIT +#else + +#ifndef __FreeBSD__ +#ifndef __WIN32__ +#ifndef __APPLE__ +#define F2PY_REPORT_ATEXIT +#endif +#endif +#endif + +#endif + */ + +#ifdef F2PY_REPORT_ATEXIT +#include + extern void f2py_start_clock(void); + extern void f2py_stop_clock(void); + extern void f2py_start_call_clock(void); + extern void f2py_stop_call_clock(void); + extern void f2py_cb_start_clock(void); + extern void f2py_cb_stop_clock(void); + extern void f2py_cb_start_call_clock(void); + extern void f2py_cb_stop_call_clock(void); + extern void f2py_report_on_exit(int,void*); +#endif + +#ifdef DMALLOC +#include "dmalloc.h" +#endif + +/* Fortran object interface */ + +/* +123456789-123456789-123456789-123456789-123456789-123456789-123456789-12 + +PyFortranObject represents various Fortran objects: +Fortran (module) routines, COMMON blocks, module data. + +Author: Pearu Peterson +*/ + +#define F2PY_MAX_DIMS 40 + +typedef void (*f2py_set_data_func)(char*,npy_intp*); +typedef void (*f2py_void_func)(void); +typedef void (*f2py_init_func)(int*,npy_intp*,f2py_set_data_func,int*); + + /*typedef void* (*f2py_c_func)(void*,...);*/ + +typedef void *(*f2pycfunc)(void); + +typedef struct { + char *name; /* attribute (array||routine) name */ + int rank; /* array rank, 0 for scalar, max is F2PY_MAX_DIMS, + || rank=-1 for Fortran routine */ + struct {npy_intp d[F2PY_MAX_DIMS];} dims; /* dimensions of the array, || not used */ + int type; /* PyArray_ || not used */ + char *data; /* pointer to array || Fortran routine */ + f2py_init_func func; /* initialization function for + allocatable arrays: + func(&rank,dims,set_ptr_func,name,len(name)) + || C/API wrapper for Fortran routine */ + char *doc; /* documentation string; only recommended + for routines. */ +} FortranDataDef; + +typedef struct { + PyObject_HEAD + int len; /* Number of attributes */ + FortranDataDef *defs; /* An array of FortranDataDef's */ + PyObject *dict; /* Fortran object attribute dictionary */ +} PyFortranObject; + +#define PyFortran_Check(op) ((op)->ob_type == &PyFortran_Type) +#define PyFortran_Check1(op) (0==strcmp((op)->ob_type->tp_name,"fortran")) + + extern PyTypeObject PyFortran_Type; + extern int F2PyDict_SetItemString(PyObject* dict, char *name, PyObject *obj); + extern PyObject * PyFortranObject_New(FortranDataDef* defs, f2py_void_func init); + extern PyObject * PyFortranObject_NewAsAttr(FortranDataDef* defs); + +#define ISCONTIGUOUS(m) ((m)->flags & NPY_CONTIGUOUS) +#define F2PY_INTENT_IN 1 +#define F2PY_INTENT_INOUT 2 +#define F2PY_INTENT_OUT 4 +#define F2PY_INTENT_HIDE 8 +#define F2PY_INTENT_CACHE 16 +#define F2PY_INTENT_COPY 32 +#define F2PY_INTENT_C 64 +#define F2PY_OPTIONAL 128 +#define F2PY_INTENT_INPLACE 256 + + extern PyArrayObject* array_from_pyobj(const int type_num, + npy_intp *dims, + const int rank, + const int intent, + PyObject *obj); + extern int copy_ND_array(const PyArrayObject *in, PyArrayObject *out); + +#ifdef DEBUG_COPY_ND_ARRAY + extern void dump_attrs(const PyArrayObject* arr); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FORTRANOBJECT_H */ Added: branches/Interpolate1D/dfitpack.py =================================================================== --- branches/Interpolate1D/dfitpack.py 2008-07-16 00:26:23 UTC (rev 4545) +++ branches/Interpolate1D/dfitpack.py 2008-07-16 22:08:51 UTC (rev 4546) @@ -0,0 +1,7 @@ +def __bootstrap__(): + global __bootstrap__, __loader__, __file__ + import sys, pkg_resources, imp + __file__ = pkg_resources.resource_filename(__name__,'dfitpack.pyd') + del __bootstrap__, __loader__ + imp.load_dynamic(__name__,__file__) +__bootstrap__() Added: branches/Interpolate1D/dfitpack.pyd =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/dfitpack.pyd ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From scipy-svn at scipy.org Wed Jul 16 18:10:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 16 Jul 2008 17:10:41 -0500 (CDT) Subject: [Scipy-svn] r4547 - branches/Interpolate1D Message-ID: <20080716221041.282EB39C50D@scipy.org> Author: fcady Date: 2008-07-16 17:10:40 -0500 (Wed, 16 Jul 2008) New Revision: 4547 Added: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/Interpolate1D.pyc branches/Interpolate1D/__init__.py branches/Interpolate1D/__init__fit.py branches/Interpolate1D/_interpolate.cpp branches/Interpolate1D/_interpolate.pyd branches/Interpolate1D/fitpack.pyf branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/fitpack_wrapper.pyc branches/Interpolate1D/info_fit.py branches/Interpolate1D/interpolate.h branches/Interpolate1D/interpolate_wrapper.py branches/Interpolate1D/interpolate_wrapper.pyc branches/Interpolate1D/setup.py Log: a few files were not added last time Added: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,130 @@ +""" A module for intepolation +""" + +# fixme: information strings giving mathematical descriptions of the actions +# of the functions. + +from interpolate_wrapper import linear, logarithmic, block, block_average_above +from fitpack_wrapper import Spline +import numpy as np +from numpy import array, arange, empty, float64, NaN + +# fixme: use this to ensure proper type of all inputs and outputs in Interpolate1D +def make_array_safe(ary, typecode=np.float64): + ary = np.atleast_1d(np.asarray(ary, typecode)) + if not ary.flags['CONTIGUOUS']: + ary = ary.copy() + return ary + + +class Interpolate1D(object): + # see enthought.interpolate + + # fixme: Handle other data types. + + def __init__(self, x, y, k=1, kind='linear', low=None, high=None): + + # fixme: Handle checking if they are the correct size. + self._x = make_array_safe(x).copy() + self._y = make_array_safe(y).copy() + self._xdtype = type(self._x[0]) + self._ydtype = type(self._y[0]) + + assert( len(x) == len(y) , "x and y must be of the same length" ) + assert( x.ndim == 1 , "x must be one-dimensional" ) + assert( y.ndim == 1 , "y must be one-dimensional" ) + # fixme: let y be 2-dimensional. Involves reworking of Interpolate1D.__call__ + # because Spline enumerates y along the last, rather then first, axis, + # while concatenate works along first axis + + self.kind = self._init_interp_method(self._x, self._y, k, kind) + self.low = self._init_interp_method(self._x, self._y, k, low) + self.high = self._init_interp_method(self._x, self._y, k, high) + + def _init_interp_method(self, x, y, k, interp_arg): + from inspect import isclass, isfunction + + if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: + func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ + 'block_average_above':block_average_above}[interp_arg] + result = lambda new_x : func(self._x, self._y, new_x) + elif interp_arg in ['Spline', Spline, 'spline']: + result = Spline(self._x, self._y, k=k) + elif isfunction(interp_arg): + result = interp_arg + elif isclass(interp_arg): + result = interp_arg(x, y) + else: + print "warning: defaulting on extrapolation" + result = np.vectorize(lambda new_x : interp_arg) + return result + + def __call__(self, x): + + x = make_array_safe(x) + low_mask = xself._x[-1] + interp_mask = (~low_mask) & (~high_mask) + + # hack, since getting an error when self.low or self.high gets 0-length array + # and they return None or NaN + if len(x[low_mask]) == 0: new_low=np.array([]) + else: new_low = self.low(x[low_mask]) + if len(x[interp_mask])==0: new_interp=np.array([]) + else: new_interp = self.kind(x[interp_mask]) + if len(x[high_mask]) == 0: new_high = np.array([]) + else: new_high = self.high(x[high_mask]) + + result = np.concatenate((new_low, new_interp, new_high)) + + return result + +# unit testing +import unittest, time +class Test(unittest.TestCase): + + def assertAllclose(self, x, y): + self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) + + # fixme: run the test contained in the wrapper modules + + def test_Interp_linearSpl(self): + #return + print "\n\nTESTING LINEAR (1st ORDER) SPLINE" + N = 7 + x = np.arange(N) + y = np.arange(N) + T1 = time.clock() + interp_func = Interpolate1D(x, y, k=1, kind='Spline', low=None, high=None) + T2 = time.clock() + print 'time to create linear interp function: ', T2 - T1 + new_x = np.arange(N)-0.5 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print '1d interp (sec):', t2 - t1 + + print "new_y: ", new_y + self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) + self.assert_(new_y[0] == None) + + def test_linear(self): + print "\n\nTESTING LINEAR INTERPOLATION" + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + T1 = time.clock() + interp_func = Interpolate1D(x, y, kind='linear', low=None, high=None) + T2 = time.clock() + print 'time to create linear interp function: ', T2 - T1 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print '1d interp (sec):', t2 - t1 + + self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) + self.assert_(new_y[0] == None) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file Added: branches/Interpolate1D/Interpolate1D.pyc =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/Interpolate1D.pyc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/__init__.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,3 @@ +from interpolate_wrapper import linear, logarithmicm, block_average_above + +from Interpolate1D import Interpolate1D \ No newline at end of file Added: branches/Interpolate1D/__init__fit.py =================================================================== --- branches/Interpolate1D/__init__fit.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/__init__fit.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,15 @@ +# +# interpolate - Interpolation Tools +# + +from info import __doc__ + +#from interpolate import * +#from fitpack import * + +# New interface to fitpack library: +from fitpack2 import * + +__all__ = filter(lambda s:not s.startswith('_'),dir()) +from numpy.testing import NumpyTest +test = NumpyTest().test Added: branches/Interpolate1D/_interpolate.cpp =================================================================== --- branches/Interpolate1D/_interpolate.cpp 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/_interpolate.cpp 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,236 @@ +#include "Python.h" +#include + +#include "interpolate.h" +#include "numpy/arrayobject.h" + +using namespace std; + +extern "C" { + +static PyObject* linear_method(PyObject*self, PyObject* args, PyObject* kywds) +{ + static char *kwlist[] = {"x","y","new_x","new_y", NULL}; + PyObject *py_x, *py_y, *py_new_x, *py_new_y; + py_x = py_y = py_new_x = py_new_y = NULL; + PyObject *arr_x, *arr_y, *arr_new_x, *arr_new_y; + arr_x = arr_y = arr_new_x = arr_new_y = NULL; + + if(!PyArg_ParseTupleAndKeywords(args,kywds,"OOOO:linear_dddd",kwlist,&py_x, &py_y, &py_new_x, &py_new_y)) + return NULL; + arr_x = PyArray_FROMANY(py_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_x) { + PyErr_SetString(PyExc_ValueError, "x must be a 1-D array of floats"); + goto fail; + } + arr_y = PyArray_FROMANY(py_y, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_y) { + PyErr_SetString(PyExc_ValueError, "y must be a 1-D array of floats"); + goto fail; + } + arr_new_x = PyArray_FROMANY(py_new_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_new_x) { + PyErr_SetString(PyExc_ValueError, "new_x must be a 1-D array of floats"); + goto fail; + } + arr_new_y = PyArray_FROMANY(py_new_y, PyArray_DOUBLE, 1, 1, NPY_INOUT_ARRAY); + if (!arr_new_y) { + PyErr_SetString(PyExc_ValueError, "new_y must be a 1-D array of floats"); + goto fail; + } + + linear((double*)PyArray_DATA(arr_x), (double*)PyArray_DATA(arr_y), + PyArray_DIM(arr_x,0), (double*)PyArray_DATA(arr_new_x), + (double*)PyArray_DATA(arr_new_y), PyArray_DIM(arr_new_x,0)); + + Py_DECREF(arr_x); + Py_DECREF(arr_y); + Py_DECREF(arr_new_x); + Py_DECREF(arr_new_y); + + Py_RETURN_NONE; + +fail: + Py_XDECREF(arr_x); + Py_XDECREF(arr_y); + Py_XDECREF(arr_new_x); + Py_XDECREF(arr_new_y); + return NULL; +} + +static PyObject* loginterp_method(PyObject*self, PyObject* args, PyObject* kywds) +{ + static char *kwlist[] = {"x","y","new_x","new_y", NULL}; + PyObject *py_x, *py_y, *py_new_x, *py_new_y; + py_x = py_y = py_new_x = py_new_y = NULL; + PyObject *arr_x, *arr_y, *arr_new_x, *arr_new_y; + arr_x = arr_y = arr_new_x = arr_new_y = NULL; + + if(!PyArg_ParseTupleAndKeywords(args,kywds,"OOOO:loginterp_dddd",kwlist,&py_x, &py_y, &py_new_x, &py_new_y)) + return NULL; + arr_x = PyArray_FROMANY(py_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_x) { + PyErr_SetString(PyExc_ValueError, "x must be a 1-D array of floats"); + goto fail; + } + arr_y = PyArray_FROMANY(py_y, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_y) { + PyErr_SetString(PyExc_ValueError, "y must be a 1-D array of floats"); + goto fail; + } + arr_new_x = PyArray_FROMANY(py_new_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_new_x) { + PyErr_SetString(PyExc_ValueError, "new_x must be a 1-D array of floats"); + goto fail; + } + arr_new_y = PyArray_FROMANY(py_new_y, PyArray_DOUBLE, 1, 1, NPY_INOUT_ARRAY); + if (!arr_new_y) { + PyErr_SetString(PyExc_ValueError, "new_y must be a 1-D array of floats"); + goto fail; + } + + loginterp((double*)PyArray_DATA(arr_x), (double*)PyArray_DATA(arr_y), + PyArray_DIM(arr_x,0), (double*)PyArray_DATA(arr_new_x), + (double*)PyArray_DATA(arr_new_y), PyArray_DIM(arr_new_x,0)); + + Py_DECREF(arr_x); + Py_DECREF(arr_y); + Py_DECREF(arr_new_x); + Py_DECREF(arr_new_y); + + Py_RETURN_NONE; + +fail: + Py_XDECREF(arr_x); + Py_XDECREF(arr_y); + Py_XDECREF(arr_new_x); + Py_XDECREF(arr_new_y); + return NULL; +} + +static PyObject* window_average_method(PyObject*self, PyObject* args, PyObject* kywds) +{ + static char *kwlist[] = {"x","y","new_x","new_y", NULL}; + PyObject *py_x, *py_y, *py_new_x, *py_new_y; + py_x = py_y = py_new_x = py_new_y = NULL; + PyObject *arr_x, *arr_y, *arr_new_x, *arr_new_y; + arr_x = arr_y = arr_new_x = arr_new_y = NULL; + double width; + + if(!PyArg_ParseTupleAndKeywords(args,kywds,"OOOOd:loginterp_dddd",kwlist,&py_x, &py_y, &py_new_x, &py_new_y, &width)) + return NULL; + arr_x = PyArray_FROMANY(py_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_x) { + PyErr_SetString(PyExc_ValueError, "x must be a 1-D array of floats"); + goto fail; + } + arr_y = PyArray_FROMANY(py_y, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_y) { + PyErr_SetString(PyExc_ValueError, "y must be a 1-D array of floats"); + goto fail; + } + arr_new_x = PyArray_FROMANY(py_new_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_new_x) { + PyErr_SetString(PyExc_ValueError, "new_x must be a 1-D array of floats"); + goto fail; + } + arr_new_y = PyArray_FROMANY(py_new_y, PyArray_DOUBLE, 1, 1, NPY_INOUT_ARRAY); + if (!arr_new_y) { + PyErr_SetString(PyExc_ValueError, "new_y must be a 1-D array of floats"); + goto fail; + } + + window_average((double*)PyArray_DATA(arr_x), (double*)PyArray_DATA(arr_y), + PyArray_DIM(arr_x,0), (double*)PyArray_DATA(arr_new_x), + (double*)PyArray_DATA(arr_new_y), PyArray_DIM(arr_new_x,0), width); + + Py_DECREF(arr_x); + Py_DECREF(arr_y); + Py_DECREF(arr_new_x); + Py_DECREF(arr_new_y); + + Py_RETURN_NONE; + +fail: + Py_XDECREF(arr_x); + Py_XDECREF(arr_y); + Py_XDECREF(arr_new_x); + Py_XDECREF(arr_new_y); + return NULL; +} + +static PyObject* block_average_above_method(PyObject*self, PyObject* args, PyObject* kywds) +{ + static char *kwlist[] = {"x","y","new_x","new_y", NULL}; + PyObject *py_x, *py_y, *py_new_x, *py_new_y; + py_x = py_y = py_new_x = py_new_y = NULL; + PyObject *arr_x, *arr_y, *arr_new_x, *arr_new_y; + arr_x = arr_y = arr_new_x = arr_new_y = NULL; + + if(!PyArg_ParseTupleAndKeywords(args,kywds,"OOOO:loginterp_dddd",kwlist,&py_x, &py_y, &py_new_x, &py_new_y)) + return NULL; + arr_x = PyArray_FROMANY(py_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_x) { + PyErr_SetString(PyExc_ValueError, "x must be a 1-D array of floats"); + goto fail; + } + arr_y = PyArray_FROMANY(py_y, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_y) { + PyErr_SetString(PyExc_ValueError, "y must be a 1-D array of floats"); + goto fail; + } + arr_new_x = PyArray_FROMANY(py_new_x, PyArray_DOUBLE, 1, 1, NPY_IN_ARRAY); + if (!arr_new_x) { + PyErr_SetString(PyExc_ValueError, "new_x must be a 1-D array of floats"); + goto fail; + } + arr_new_y = PyArray_FROMANY(py_new_y, PyArray_DOUBLE, 1, 1, NPY_INOUT_ARRAY); + if (!arr_new_y) { + PyErr_SetString(PyExc_ValueError, "new_y must be a 1-D array of floats"); + goto fail; + } + + block_average_above((double*)PyArray_DATA(arr_x), (double*)PyArray_DATA(arr_y), + PyArray_DIM(arr_x,0), (double*)PyArray_DATA(arr_new_x), + (double*)PyArray_DATA(arr_new_y), PyArray_DIM(arr_new_x,0)); + + Py_DECREF(arr_x); + Py_DECREF(arr_y); + Py_DECREF(arr_new_x); + Py_DECREF(arr_new_y); + + Py_RETURN_NONE; + +fail: + Py_XDECREF(arr_x); + Py_XDECREF(arr_y); + Py_XDECREF(arr_new_x); + Py_XDECREF(arr_new_y); + return NULL; +} + +static PyMethodDef interpolate_methods[] = { + {"linear_dddd", (PyCFunction)linear_method, METH_VARARGS|METH_KEYWORDS, + ""}, + {"loginterp_dddd", (PyCFunction)loginterp_method, METH_VARARGS|METH_KEYWORDS, + ""}, + {"window_average_ddddd", (PyCFunction)window_average_method, METH_VARARGS|METH_KEYWORDS, + ""}, + {"block_average_above_dddd", (PyCFunction)block_average_above_method, METH_VARARGS|METH_KEYWORDS, + ""}, + {NULL, NULL, 0, NULL} +}; + + +PyMODINIT_FUNC init_interpolate(void) +{ + PyObject* m; + m = Py_InitModule3("_interpolate", interpolate_methods, + "A few interpolation routines.\n" + ); + if (m == NULL) + return; + import_array(); +} + +} // extern "C" Added: branches/Interpolate1D/_interpolate.pyd =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/_interpolate.pyd ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/fitpack.pyf =================================================================== --- branches/Interpolate1D/fitpack.pyf 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/fitpack.pyf 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,479 @@ +! -*- f90 -*- +! Author: Pearu Peterson +! +python module dfitpack ! in + + usercode ''' + +static double dmax(double* seq,int len) { + double val; + int i; + if (len<1) + return -1e308; + val = seq[0]; + for(i=1;ival) val = seq[i]; + return val; +} +static double dmin(double* seq,int len) { + double val; + int i; + if (len<1) + return 1e308; + val = seq[0]; + for(i=1;ival1) return val1; + val1 = dmax(tx,nx); + return val2 - (val1-val2)/nx; +} +static double calc_e(double* x,int m,double* tx,int nx) { + double val1 = dmax(x,m); + double val2 = dmax(tx,nx); + if (val2=8) :: n=len(t) + real*8 dimension(n),depend(n),check(len(c)==n) :: c + real*8 dimension(mest),intent(out),depend(mest) :: zero + integer optional,intent(in),depend(n) :: mest=3*(n-7) + integer intent(out) :: m + integer intent(out) :: ier + end subroutine sproot + + subroutine spalde(t,n,c,k,x,d,ier) + ! d,ier = spalde(t,c,k,x) + + callprotoargument double*,int*,double*,int*,double*,double*,int* + callstatement {int k1=k+1; (*f2py_func)(t,&n,c,&k1,&x,d,&ier); } + + real*8 dimension(n) :: t + integer intent(hide),depend(t) :: n=len(t) + real*8 dimension(n),depend(n),check(len(c)==n) :: c + integer intent(in) :: k + real*8 intent(in) :: x + real*8 dimension(k+1),intent(out),depend(k) :: d + integer intent(out) :: ier + end subroutine spalde + + subroutine curfit(iopt,m,x,y,w,xb,xe,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! in curfit.f + integer :: iopt + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(w)==m) :: w + real*8 optional,depend(x),check(xb<=x[0]) :: xb = x[0] + real*8 optional,depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] + integer optional,check(1<=k && k <=5),intent(in) :: k=3 + real*8 optional,check(s>=0.0) :: s = 0.0 + integer intent(hide),depend(t) :: nest=len(t) + integer intent(out), depend(nest) :: n=nest + real*8 dimension(nest),intent(inout) :: t + real*8 dimension(n),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(inout) :: wrk + integer intent(hide),depend(wrk) :: lwrk=len(wrk) + integer dimension(nest),intent(inout) :: iwrk + integer intent(out) :: ier + end subroutine curfit + + subroutine percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! in percur.f + integer :: iopt + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(w)==m) :: w + integer optional,check(1<=k && k <=5),intent(in) :: k=3 + real*8 optional,check(s>=0.0) :: s = 0.0 + integer intent(hide),depend(t) :: nest=len(t) + integer intent(out), depend(nest) :: n=nest + real*8 dimension(nest),intent(inout) :: t + real*8 dimension(n),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(inout) :: wrk + integer intent(hide),depend(wrk) :: lwrk=len(wrk) + integer dimension(nest),intent(inout) :: iwrk + integer intent(out) :: ier + end subroutine percur + + + subroutine parcur(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,c,fp,wrk,lwrk,iwrk,ier) + ! in parcur.f + integer check(iopt>=-1 && iopt <= 1):: iopt + integer check(ipar == 1 || ipar == 0) :: ipar + integer check(idim > 0 && idim < 11) :: idim + integer intent(hide),depend(u,k),check(m>k) :: m=len(u) + real*8 dimension(m), intent(inout) :: u + integer intent(hide),depend(x,idim,m),check(mx>=idim*m) :: mx=len(x) + real*8 dimension(mx) :: x + real*8 dimension(m) :: w + real*8 :: ub + real*8 :: ue + integer optional, check(1<=k && k<=5) :: k=3.0 + real*8 optional, check(s>=0.0) :: s = 0.0 + integer intent(hide), depend(t) :: nest=len(t) + integer intent(out), depend(nest) :: n=nest + real*8 dimension(nest), intent(inout) :: t + integer intent(hide), depend(c,nest,idim), check(nc>=idim*nest) :: nc=len(c) + real*8 dimension(nc), intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk), intent(inout) :: wrk + integer intent(hide),depend(wrk) :: lwrk=len(wrk) + integer dimension(nest), intent(inout) :: iwrk + integer intent(out) :: ier + end subroutine parcur + + + subroutine fpcurf0(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ + ! fpcurf0(x,y,k,[w,xb,xe,s,nest]) + + fortranname fpcurf + callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* + callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) + + integer intent(hide) :: iopt = 0 + real*8 dimension(m),intent(in,out) :: x + real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y + real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out) :: w = 1.0 + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 intent(in,out),depend(x),check(xb<=x[0]) :: xb = x[0] + real*8 intent(in,out),depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] + integer check(1<=k && k<=5),intent(in,out) :: k + real*8 check(s>=0.0),depend(m),intent(in,out) :: s = m + integer intent(in),depend(m,s,k,k1),check(nest>=2*k1) :: nest = (s==0.0?m+k+1:MAX(m/2,2*k1)) + real*8 intent(hide) :: tol = 0.001 + integer intent(hide) :: maxit = 20 + integer intent(hide),depend(k) :: k1=k+1 + integer intent(hide),depend(k) :: k2=k+2 + integer intent(out) :: n + real*8 dimension(nest),intent(out),depend(nest) :: t + real*8 dimension(nest),depend(nest),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(nest),depend(nest),intent(out,cache) :: fpint + real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk + integer dimension(nest),depend(nest),intent(out,cache) :: nrdata + integer intent(out) :: ier + end subroutine fpcurf0 + + subroutine fpcurf1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ + ! fpcurf1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier) + + fortranname fpcurf + callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* + callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) + + integer intent(hide) :: iopt = 1 + real*8 dimension(m),intent(in,out,overwrite) :: x + real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out,overwrite) :: y + real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out,overwrite) :: w + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 intent(in,out) :: xb + real*8 intent(in,out) :: xe + integer check(1<=k && k<=5),intent(in,out) :: k + real*8 check(s>=0.0),intent(in,out) :: s + integer intent(hide),depend(t) :: nest = len(t) + real*8 intent(hide) :: tol = 0.001 + integer intent(hide) :: maxit = 20 + integer intent(hide),depend(k) :: k1=k+1 + integer intent(hide),depend(k) :: k2=k+2 + integer intent(in,out) :: n + real*8 dimension(nest),intent(in,out,overwrite) :: t + real*8 dimension(nest),depend(nest),check(len(c)==nest),intent(in,out,overwrite) :: c + real*8 intent(in,out) :: fp + real*8 dimension(nest),depend(nest),check(len(fpint)==nest),intent(in,out,cache,overwrite) :: fpint + real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk + integer dimension(nest),depend(nest),check(len(nrdata)==nest),intent(in,out,cache,overwrite) :: nrdata + integer intent(in,out) :: ier + end subroutine fpcurf1 + + subroutine fpcurfm1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ + ! fpcurfm1(x,y,k,t,[w,xb,xe]) + + fortranname fpcurf + callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* + callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) + + integer intent(hide) :: iopt = -1 + real*8 dimension(m),intent(in,out) :: x + real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y + real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out) :: w = 1.0 + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 intent(in,out),depend(x),check(xb<=x[0]) :: xb = x[0] + real*8 intent(in,out),depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] + integer check(1<=k && k<=5),intent(in,out) :: k + real*8 intent(out) :: s = -1 + integer intent(hide),depend(n) :: nest = n + real*8 intent(hide) :: tol = 0.001 + integer intent(hide) :: maxit = 20 + integer intent(hide),depend(k) :: k1=k+1 + integer intent(hide),depend(k) :: k2=k+2 + integer intent(out),depend(t) :: n = len(t) + real*8 dimension(n),intent(in,out,overwrite) :: t + real*8 dimension(nest),depend(nest),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(nest),depend(nest),intent(out,cache) :: fpint + real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk + integer dimension(nest),depend(nest),intent(out,cache) :: nrdata + integer intent(out) :: ier + end subroutine fpcurfm1 + + !!!!!!!!!! Bivariate spline !!!!!!!!!!! + + subroutine bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk,iwrk,kwrk,ier) + ! z,ier = bispev(tx,ty,c,kx,ky,x,y) + real*8 dimension(nx),intent(in) :: tx + integer intent(hide),depend(tx) :: nx=len(tx) + real*8 dimension(ny),intent(in) :: ty + integer intent(hide),depend(ty) :: ny=len(ty) + real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& + check(len(c)==(nx-kx-1)*(ny-ky-1)):: c + integer :: kx + integer :: ky + real*8 intent(in),dimension(mx) :: x + integer intent(hide),depend(x) :: mx=len(x) + real*8 intent(in),dimension(my) :: y + integer intent(hide),depend(y) :: my=len(y) + real*8 dimension(mx,my),depend(mx,my),intent(out,c) :: z + real*8 dimension(lwrk),depend(lwrk),intent(hide,cache) :: wrk + integer intent(hide),depend(mx,kx,my,ky) :: lwrk=mx*(kx+1)+my*(ky+1) + integer dimension(kwrk),depend(kwrk),intent(hide,cache) :: iwrk + integer intent(hide),depend(mx,my) :: kwrk=mx+my + integer intent(out) :: ier + end subroutine bispev + + subroutine surfit_smth(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest,& + nmax,eps,nx,tx,ny,ty,c,fp,wrk1,lwrk1,wrk2,lwrk2,& + iwrk,kwrk,ier) + ! nx,tx,ny,ty,c,fp,ier = surfit_smth(x,y,z,[w,xb,xe,yb,ye,kx,ky,s,eps,lwrk2]) + + fortranname surfit + + integer intent(hide) :: iopt=0 + integer intent(hide),depend(x,kx,ky),check(m>=(kx+1)*(ky+1)) & + :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(z)==m) :: z + real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 + real*8 optional,depend(x,m) :: xb=dmin(x,m) + real*8 optional,depend(x,m) :: xe=dmax(x,m) + real*8 optional,depend(y,m) :: yb=dmin(y,m) + real*8 optional,depend(y,m) :: ye=dmax(y,m) + integer check(1<=kx && kx<=5) :: kx = 3 + integer check(1<=ky && ky<=5) :: ky = 3 + real*8 optional,check(0.0<=s) :: s = m + integer optional,depend(kx,m),check(nxest>=2*(kx+1)) & + :: nxest = imax(kx+1+sqrt(m/2),2*(kx+1)) + integer optional,depend(ky,m),check(nyest>=2*(ky+1)) & + :: nyest = imax(ky+1+sqrt(m/2),2*(ky+1)) + integer intent(hide),depend(nxest,nyest) :: nmax=MAX(nxest,nyest) + real*8 optional,check(0.0=(kx+1)*(ky+1)) & + :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(z)==m) :: z + real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 + real*8 optional,depend(x,tx,m,nx) :: xb=calc_b(x,m,tx,nx) + real*8 optional,depend(x,tx,m,nx) :: xe=calc_e(x,m,tx,nx) + real*8 optional,depend(y,ty,m,ny) :: yb=calc_b(y,m,ty,ny) + real*8 optional,depend(y,ty,m,ny) :: ye=calc_e(y,m,ty,ny) + integer check(1<=kx && kx<=5) :: kx = 3 + integer check(1<=ky && ky<=5) :: ky = 3 + real*8 intent(hide) :: s = 0.0 + integer intent(hide),depend(nx) :: nxest = nx + integer intent(hide),depend(ny) :: nyest = ny + integer intent(hide),depend(nx,ny) :: nmax=MAX(nx,ny) + real*8 optional,check(0.0kx) :: mx=len(x) + real*8 dimension(mx) :: x + integer intent(hide),depend(y,ky),check(my>ky) :: my=len(y) + real*8 dimension(my) :: y + real*8 dimension(mx*my),depend(mx,my),check(len(z)==mx*my) :: z + real*8 optional,depend(x,mx) :: xb=dmin(x,mx) + real*8 optional,depend(x,mx) :: xe=dmax(x,mx) + real*8 optional,depend(y,my) :: yb=dmin(y,my) + real*8 optional,depend(y,my) :: ye=dmax(y,my) + integer optional,check(1<=kx && kx<=5) :: kx = 3 + integer optional,check(1<=ky && ky<=5) :: ky = 3 + real*8 optional,check(0.0<=s) :: s = 0.0 + integer intent(hide),depend(kx,mx),check(nxest>=2*(kx+1)) & + :: nxest = mx+kx+1 + integer intent(hide),depend(ky,my),check(nyest>=2*(ky+1)) & + :: nyest = my+ky+1 + integer intent(out) :: nx + real*8 dimension(nxest),intent(out),depend(nxest) :: tx + integer intent(out) :: ny + real*8 dimension(nyest),intent(out),depend(nyest) :: ty + real*8 dimension((nxest-kx-1)*(nyest-ky-1)), & + depend(kx,ky,nxest,nyest),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(cache,hide),depend(lwrk) :: wrk + integer intent(hide),depend(mx,my,kx,ky,nxest,nyest) & + :: lwrk=calc_regrid_lwrk(mx,my,kx,ky,nxest,nyest) + integer dimension(kwrk),depend(kwrk),intent(cache,hide) :: iwrk + integer intent(hide),depend(mx,my,nxest,nyest) & + :: kwrk=3+mx+my+nxest+nyest + integer intent(out) :: ier + end subroutine regrid_smth + + function dblint(tx,nx,ty,ny,c,kx,ky,xb,xe,yb,ye,wrk) + ! iy = dblint(tx,ty,c,kx,ky,xb,xe,yb,ye) + real*8 dimension(nx),intent(in) :: tx + integer intent(hide),depend(tx) :: nx=len(tx) + real*8 dimension(ny),intent(in) :: ty + integer intent(hide),depend(ty) :: ny=len(ty) + real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& + check(len(c)==(nx-kx-1)*(ny-ky-1)):: c + integer :: kx + integer :: ky + real*8 intent(in) :: xb + real*8 intent(in) :: xe + real*8 intent(in) :: yb + real*8 intent(in) :: ye + real*8 dimension(nx+ny-kx-ky-2),depend(nx,ny,kx,ky),intent(cache,hide) :: wrk + real*8 :: dblint + end function dblint + end interface +end python module dfitpack + Added: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,204 @@ +""" fit_helper.py + +mimics the functionality of enthought.interpolate that is +contained in the module fitting.py + +""" + +import numpy as np + +import dfitpack #fixme: rename module fitpack_wrapper + + +class Spline(object): + """ Univariate spline s(x) of degree k on the interval + [xb,xe] calculated from a given set of data points + (x,y). + + Can include least-squares fitting. + + See also: + + splrep, splev, sproot, spint, spalde - an older wrapping of FITPACK + BivariateSpline - a similar class for bivariate spline interpolation + """ + + def __init__(self, x, y, w=None, bbox = [None]*2, k=3, s=None): + """ + Input: + x,y - 1-d sequences of data points (x must be + in strictly ascending order) + + Optional input: + w - positive 1-d sequence of weights + bbox - 2-sequence specifying the boundary of + the approximation interval. + By default, bbox=[x[0],x[-1]] + k=3 - degree of the univariate spline. + s - positive smoothing factor defined for + estimation condition: + sum((w[i]*(y[i]-s(x[i])))**2,axis=0) <= s + Default s=len(w) which should be a good value + if 1/w[i] is an estimate of the standard + deviation of y[i]. + """ + #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier + data = dfitpack.fpcurf0(x,y,k,w=w, + xb=bbox[0],xe=bbox[1],s=s) + if data[-1]==1: + # nest too small, setting to maximum bound + data = self._reset_nest(data) + self._data = data + self._reset_class() + + def _reset_class(self): + data = self._data + n,t,c,k,ier = data[7],data[8],data[9],data[5],data[-1] + self._eval_args = t[:n],c[:n],k + if ier==0: + # the spline returned has a residual sum of squares fp + # such that abs(fp-s)/s <= tol with tol a relative + # tolerance set to 0.001 by the program + pass + elif ier==-1: + # the spline returned is an interpolating spline + #self.__class__ = InterpolatedUnivariateSpline + pass + elif ier==-2: + # the spline returned is the weighted least-squares + # polynomial of degree k. In this extreme case fp gives + # the upper bound fp0 for the smoothing factor s. + #self.__class__ = LSQUnivariateSpline + pass + else: + # error + #if ier==1: + # self.__class__ = LSQUnivariateSpline + #message = _curfit_messages.get(ier,'ier=%s' % (ier)) + #warnings.warn(message) + pass + + def _reset_nest(self, data, nest=None): + n = data[10] + if nest is None: + k,m = data[5],len(data[0]) + nest = m+k+1 # this is the maximum bound for nest + else: + assert n<=nest,"nest can only be increased" + t,c,fpint,nrdata = data[8].copy(),data[9].copy(),\ + data[11].copy(),data[12].copy() + t.resize(nest) + c.resize(nest) + fpint.resize(nest) + nrdata.resize(nest) + args = data[:8] + (t,c,n,fpint,nrdata,data[13]) + data = dfitpack.fpcurf1(*args) + return data + + def set_smoothing_factor(self, s): + """ Continue spline computation with the given smoothing + factor s and with the knots found at the last call. + + """ + data = self._data + if data[6]==-1: + warnings.warn('smoothing factor unchanged for' + 'LSQ spline with fixed knots') + return + args = data[:6] + (s,) + data[7:] + data = dfitpack.fpcurf1(*args) + if data[-1]==1: + # nest too small, setting to maximum bound + data = self._reset_nest(data) + self._data = data + self._reset_class() + + def __call__(self, x, nu=None): + """ Evaluate spline (or its nu-th derivative) at positions x. + Note: x can be unordered but the evaluation is more efficient + if x is (partially) ordered. + + """ + print 'length of x: ', len(x) + if len(x) == 0: return np.array([]) #hack to cope with shape (0,) + if nu is None: + return dfitpack.splev(*(self._eval_args+(x,))) + return dfitpack.splder(nu=nu,*(self._eval_args+(x,))) + + def get_knots(self): + """ Return the positions of (boundary and interior) + knots of the spline. + """ + data = self._data + k,n = data[5],data[7] + return data[8][k:n-k] + + def get_coeffs(self): + """Return spline coefficients.""" + data = self._data + k,n = data[5],data[7] + return data[9][:n-k-1] + + def get_residual(self): + """Return weighted sum of squared residuals of the spline + approximation: sum ((w[i]*(y[i]-s(x[i])))**2,axis=0) + + """ + return self._data[10] + + def integral(self, a, b): + """ Return definite integral of the spline between two + given points. + """ + return dfitpack.splint(*(self._eval_args+(a,b))) + + def derivatives(self, x): + """ Return all derivatives of the spline at the point x.""" + d,ier = dfitpack.spalde(*(self._eval_args+(x,))) + assert ier==0,`ier` + return d + + def roots(self): + """ Return the zeros of the spline. + + Restriction: only cubic splines are supported by fitpack. + """ + k = self._data[5] + if k==3: + z,m,ier = dfitpack.sproot(*self._eval_args[:2]) + assert ier==0,`ier` + return z[:m] + raise NotImplementedError,\ + 'finding roots unsupported for non-cubic splines' + + + +# testing +import unittest +import time +from numpy import arange, allclose, ones + +class Test(unittest.TestCase): + + def assertAllclose(self, x, y): + self.assert_(np.allclose(x, y)) + + def test_linearSpl(self): + N = 3000. + x = np.arange(N) + y = np.arange(N) + T1 = time.clock() + interp_func = Spline(x, y, k=1) + T2 = time.clock() + print 'time to create linear interp function: ', T2 - T1 + new_x = np.arange(N)+0.5 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print '1d interp (sec):', t2 - t1 + self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) + +if __name__ == '__main__': + unittest.main() + + \ No newline at end of file Added: branches/Interpolate1D/fitpack_wrapper.pyc =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/fitpack_wrapper.pyc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/info_fit.py =================================================================== --- branches/Interpolate1D/info_fit.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/info_fit.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,12 @@ +""" +Interpolation Tools +=================== + +Primary interpolation agent: + + Interpolate1D -- callable class, initialized with x and y to interpolate + from and indicator of how to deal with + extrapolation +""" + +postpone_import = 1 Added: branches/Interpolate1D/interpolate.h =================================================================== --- branches/Interpolate1D/interpolate.h 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/interpolate.h 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,206 @@ +#include +#include +#include +#include + +template +void linear(T* x_vec, T* y_vec, int len, + T* new_x_vec, T* new_y_vec, int new_len) +{ + for (int i=0;i=x_vec[len-1]) + index = len-2; + else + { + T* which = std::lower_bound(x_vec, x_vec+len, new_x); + index = which - x_vec-1; + } + + if(new_x == x_vec[index]) + { + // exact value + new_y_vec[i] = y_vec[index]; + } + else + { + //interpolate + double x_lo = x_vec[index]; + double x_hi = x_vec[index+1]; + double y_lo = y_vec[index]; + double y_hi = y_vec[index+1]; + double slope = (y_hi-y_lo)/(x_hi-x_lo); + new_y_vec[i] = slope * (new_x-x_lo) + y_lo; + } + } +} + +template +void loginterp(T* x_vec, T* y_vec, int len, + T* new_x_vec, T* new_y_vec, int new_len) +{ + for (int i=0;i=x_vec[len-1]) + index = len-2; + else + { + T* which = std::lower_bound(x_vec, x_vec+len, new_x); + index = which - x_vec-1; + } + + if(new_x == x_vec[index]) + { + // exact value + new_y_vec[i] = y_vec[index]; + } + else + { + //interpolate + double x_lo = x_vec[index]; + double x_hi = x_vec[index+1]; + double y_lo = log10(y_vec[index]); + double y_hi = log10(y_vec[index+1]); + double slope = (y_hi-y_lo)/(x_hi-x_lo); + new_y_vec[i] = pow(10.0, (slope * (new_x-x_lo) + y_lo)); + } + } +} + +template +int block_average_above(T* x_vec, T* y_vec, int len, + T* new_x_vec, T* new_y_vec, int new_len) +{ + int bad_index = -1; + int start_index = 0; + T last_y = 0.0; + T thickness = 0.0; + + for(int i=0;i x_vec[len-1])) + { + bad_index = i; + break; + } + else if (new_x == x_vec[0]) + { + // for the first sample, just return the cooresponding y value + new_y_vec[i] = y_vec[0]; + } + else + { + T* which = std::lower_bound(x_vec, x_vec+len, new_x); + int index = which - x_vec-1; + + // calculate weighted average + + // Start off with "residue" from last interval in case last x + // was between to samples. + T weighted_y_sum = last_y * thickness; + T thickness_sum = thickness; + for(int j=start_index; j<=index; j++) + { + T next_x; + if (x_vec[j+1] < new_x) + thickness = x_vec[j+1] - x_vec[j]; + else + thickness = new_x -x_vec[j]; + weighted_y_sum += y_vec[j] * thickness; + thickness_sum += thickness; + } + new_y_vec[i] = weighted_y_sum/thickness_sum; + + // Store the thickness between the x value and the next sample + // to add to the next weighted average. + last_y = y_vec[index]; + thickness = x_vec[index+1] - new_x; + + // start next weighted average at next sample + start_index =index+1; + } + } + return bad_index; +} + +template +int window_average(T* x_vec, T* y_vec, int len, + T* new_x_vec, T* new_y_vec, int new_len, + T width) +{ + for(int i=0;i= len) + { + //top = x_vec[len-1]; + top_index = len-1; + } + //std::cout << std::endl; + //std::cout << bottom_index << " " << top_index << std::endl; + //std::cout << bottom << " " << top << std::endl; + // calculate weighted average + T thickness =0.0; + T thickness_sum =0.0; + T weighted_y_sum =0.0; + for(int j=bottom_index; j < top_index; j++) + { + thickness = x_vec[j+1] - bottom; + weighted_y_sum += y_vec[j] * thickness; + thickness_sum += thickness; + bottom = x_vec[j+1]; + /* + std::cout << "iter: " << j - bottom_index << " " << + "index: " << j << " " << + "bottom: " << bottom << " " << + "x+1: " << x_vec[j+1] << " " << + "x: " << x_vec[j] << " " << + "y: " << y_vec[j] << " " << + "weighted_sum: " << weighted_y_sum << + "thickness: " << thickness << " " << + "thickness_sum: " << thickness_sum << std::endl; + */ + //std::cout << x_vec[j] << " "; + //std::cout << thickness << " "; + } + + // last element + thickness = top - bottom; + weighted_y_sum += y_vec[top_index] * thickness; + thickness_sum += thickness; + /* + std::cout << "iter: last" << " " << + "index: " << top_index << " " << + "x: " << x_vec[top_index] << " " << + "y: " << y_vec[top_index] << " " << + "weighted_sum: " << weighted_y_sum << + "thickness: " << thickness << " " << + "thickness_sum: " << thickness_sum << std::endl; + */ + //std::cout << x_vec[top_index] << " " << thickness_sum << std::endl; + new_y_vec[i] = weighted_y_sum/thickness_sum; + } + return -1; +} Added: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,259 @@ +""" helper_funcs.py +""" + +import numpy +import sys; sys.path.append('C:\home\python\branches\interpolate2\entinterp') +import _interpolate + +def make_array_safe(ary, typecode = numpy.float64): + ary = numpy.atleast_1d(numpy.asarray(ary, typecode)) + if not ary.flags['CONTIGUOUS']: + ary = ary.copy() + return ary + + +def linear(x, y, new_x): + """ Linearly interpolates values in new_x based on the values in x and y + + Parameters + ---------- + x + 1-D array + y + 1-D or 2-D array + new_x + 1-D array + """ + x = make_array_safe(x, numpy.float64) + y = make_array_safe(y, numpy.float64) + new_x = make_array_safe(new_x, numpy.float64) + + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.linear_dddd(x, y, new_x, new_y) + + return new_y + +def logarithmic(x, y, new_x): + """ Linearly interpolates values in new_x based in the log space of y. + + Parameters + ---------- + x + 1-D array + y + 1-D or 2-D array + new_x + 1-D array + """ + x = make_array_safe(x, numpy.float64) + y = make_array_safe(y, numpy.float64) + new_x = make_array_safe(new_x, numpy.float64) + + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + _interpolate.loginterp_dddd(x, y, new_x, new_y) + + return new_y + +def block_average_above(x, y, new_x): + """ Linearly interpolates values in new_x based on the values in x and y + + Parameters + ---------- + x + 1-D array + y + 1-D or 2-D array + new_x + 1-D array + """ + bad_index = None + x = make_array_safe(x, numpy.float64) + y = make_array_safe(y, numpy.float64) + new_x = make_array_safe(new_x, numpy.float64) + + assert len(y.shape) < 3, "function only works with 1D or 2D arrays" + if len(y.shape) == 2: + new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + for i in range(len(new_y)): + bad_index = _interpolate.block_averave_above_dddd(x, y[i], + new_x, new_y[i]) + if bad_index is not None: + break + else: + new_y = numpy.zeros(len(new_x), numpy.float64) + bad_index = _interpolate.block_average_above_dddd(x, y, new_x, new_y) + + if bad_index is not None: + msg = "block_average_above cannot extrapolate and new_x[%d]=%f "\ + "is out of the x range (%f, %f)" % \ + (bad_index, new_x[bad_index], x[0], x[-1]) + raise ValueError, msg + + return new_y + +def block(x, y, new_x): + """ Used when only one element is available in the log. + """ + + # find index of values in x that preceed values in x + # This code is a little strange -- we really want a routine that + # returns the index of values where x[j] < x[index] + TINY = 1e-10 + indices = numpy.searchsorted(x, new_x+TINY)-1 + + # If the value is at the front of the list, it'll have -1. + # In this case, we will use the first (0), element in the array. + # take requires the index array to be an Int + indices = numpy.atleast_1d(numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)) + new_y = numpy.take(y, indices, axis=-1) + return new_y +def test_helper(): + """ use numpy.allclose to test + """ + + print "now testing accuracy of interpolation of linear data" + + x = numpy.arange(10.) + y = 2.0*x + c = numpy.array([-1.0, 2.3, 10.5]) + + assert numpy.allclose( linear(x, y, c) , [-2.0, 4.6, 21.0] ), "problem in linear" + assert numpy.allclose( logarithmic(x, y, c) , [0. , 4.51738774 , 21.47836848] ), \ + "problem with logarithmic" + assert numpy.allclose( block_average_above(x, y, c) , [0., 2., 4.] ), \ + "problem with block_average_above" + +def compare_runtimes(): + from scipy import arange, ones + import time + + # basic linear interp + N = 3000. + x = arange(N) + y = arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = linear(x, y, new_x) + t2 = time.clock() + print '1d interp (sec):', t2 - t1 + print new_y[:5] + + # basic block_average_above + N = 3000. + x = arange(N) + y = arange(N) + new_x = arange(N/2)*2 + t1 = time.clock() + new_y = block_average_above(x, y, new_x) + t2 = time.clock() + print '1d block_average_above (sec):', t2 - t1 + print new_y[:5] + + # y linear with y having multiple params + N = 3000. + x = arange(N) + y = ones((100,N)) * arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = linear(x, y, new_x) + t2 = time.clock() + print 'fast interpolate (sec):', t2 - t1 + print new_y[:5,:5] + + # scipy with multiple params + import scipy + N = 3000. + x = arange(N) + y = ones((100, N)) * arange(N) + new_x = arange(N) + t1 = time.clock() + interp = scipy.interpolate.interp1d(x, y) + new_y = interp(new_x) + t2 = time.clock() + print 'scipy interp1d (sec):', t2 - t1 + print new_y[:5,:5] + + +# Below is stuff from scipy.interpolate and fitpack + +# Unit Test +import unittest +import time +from numpy import arange, allclose, ones, NaN, isnan +class Test(unittest.TestCase): + + #def assertAllclose(self, x, y, rtol = 1.0e-5): + # self.assert_(numpy.allclose(x, y, rtol = rtol)) + + def assertAllclose(self, x, y, rtol=1.0e-5): + for i, xi in enumerate(x): + self.assert_(allclose(xi, y[i], rtol) or (isnan(xi) and isnan(y[i]))) + + def test_linear(self): + N = 3000. + x = arange(N) + y = arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = linear(x, y, new_x) + t2 = time.clock() + print '1d interp (sec):', t2 - t1 + + self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) + + def test_block_average_above(self): + N = 3000. + x = arange(N) + y = arange(N) + + new_x = arange(N/2)*2 + t1 = time.clock() + new_y = block_average_above(x, y, new_x) + t2 = time.clock() + print '1d block_average_above (sec):', t2 - t1 + self.assertAllclose(new_y[:5], [0.0, 0.5, 2.5, 4.5, 6.5]) + + def test_linear2(self): + N = 3000. + x = arange(N) + y = ones((100,N)) * arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = linear(x, y, new_x) + t2 = time.clock() + print 'fast interpolate (sec):', t2 - t1 + self.assertAllclose(new_y[:5,:5], + [[ 0.5, 1.5, 2.5, 3.5, 4.5], + [ 0.5, 1.5, 2.5, 3.5, 4.5], + [ 0.5, 1.5, 2.5, 3.5, 4.5], + [ 0.5, 1.5, 2.5, 3.5, 4.5], + [ 0.5, 1.5, 2.5, 3.5, 4.5]]) + + def test_logarithmic(self): + N = 3000. + x = arange(N) + y = arange(N) + new_x = arange(N)+0.5 + t1 = time.clock() + new_y = logarithmic(x, y, new_x) + t2 = time.clock() + print 'logarithmic interp (sec):', t2 - t1 + correct_y = [numpy.NaN, 1.41421356, 2.44948974, 3.46410162, 4.47213595] + self.assertAllclose(new_y[:5], correct_y) + print "logo" + +if __name__ == '__main__': + unittest.main() + \ No newline at end of file Added: branches/Interpolate1D/interpolate_wrapper.pyc =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/interpolate_wrapper.pyc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-16 22:08:51 UTC (rev 4546) +++ branches/Interpolate1D/setup.py 2008-07-16 22:10:40 UTC (rev 4547) @@ -0,0 +1,24 @@ +#!/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('', parent_package, top_path) + + config.add_extension('_interpolate', + ['_interpolate.cpp'], + include_dirs = ['.'], + depends = ['interpolate.h']) + + config.add_extension('dfitpack', + sources=['fitpack.pyf'], + libraries=['fitpack'], + ) + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration(top_path='').todict() ) \ No newline at end of file From scipy-svn at scipy.org Thu Jul 17 08:50:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 17 Jul 2008 07:50:18 -0500 (CDT) Subject: [Scipy-svn] r4548 - trunk/scipy/ndimage Message-ID: <20080717125018.1C61E39C6AA@scipy.org> Author: stefan Date: 2008-07-17 07:50:08 -0500 (Thu, 17 Jul 2008) New Revision: 4548 Modified: trunk/scipy/ndimage/filters.py Log: Fix typo in filters.py [spotted by Michael Fitzgerald]. Modified: trunk/scipy/ndimage/filters.py =================================================================== --- trunk/scipy/ndimage/filters.py 2008-07-16 22:10:40 UTC (rev 4547) +++ trunk/scipy/ndimage/filters.py 2008-07-17 12:50:08 UTC (rev 4548) @@ -63,7 +63,7 @@ if numpy.iscomplexobj(input): raise TypeError, 'Complex type not supported' output, return_value = _ni_support._get_output(output, input) - weights = numpy.asarray(weights, dtype = numpy.float64) + weights = numpy.asarray(weights, dtype=numpy.float64) if weights.ndim != 1 or weights.shape[0] < 1: raise RuntimeError, 'no filter weights given' if not weights.flags.contiguous: @@ -332,7 +332,7 @@ if numpy.iscomplexobj(int): raise TypeError, 'Complex type not supported' origins = _ni_support._normalize_sequence(origin, input.ndim) - weights = numpy.asarray(weights, dtype = numpy.float64) + weights = numpy.asarray(weights, dtype=numpy.float64) wshape = [ii for ii in weights.shape if ii > 0] if len(wshape) != input.ndim: raise RuntimeError, 'filter weights array has incorrect shape.' @@ -492,7 +492,7 @@ else: separable = False else: - structure = numpy.asarray(structure, dtype = numpy.float64) + structure = numpy.asarray(structure, dtype=numpy.float64) separable = False if footprint is None: footprint = numpy.ones(structure.shape, bool) @@ -573,9 +573,9 @@ 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) + footprint = numpy.ones(sizes, dtype=bool) else: - footprint = numpy.asarray(footprint, dtype = bool) + footprint = numpy.asarray(footprint, dtype=bool) fshape = [ii for ii in footprint.shape if ii > 0] if len(fshape) != input.ndim: raise RuntimeError, 'filter footprint array has incorrect shape.' @@ -709,7 +709,7 @@ 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) + footprint = numpy.ones(sizes, dtype=bool) else: footprint = numpy.asarray(footprint) footprint = footprint.astype(bool) From scipy-svn at scipy.org Fri Jul 18 09:20:25 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 18 Jul 2008 08:20:25 -0500 (CDT) Subject: [Scipy-svn] r4549 - in trunk/scipy/sparse: . benchmarks linalg/dsolve sparsetools tests Message-ID: <20080718132025.1D96439C23D@scipy.org> Author: wnbell Date: 2008-07-18 08:19:37 -0500 (Fri, 18 Jul 2008) New Revision: 4549 Added: trunk/scipy/sparse/sparsetools/dense.h Modified: trunk/scipy/sparse/benchmarks/bench_sparse.py trunk/scipy/sparse/bsr.py trunk/scipy/sparse/compressed.py trunk/scipy/sparse/coo.py trunk/scipy/sparse/dia.py trunk/scipy/sparse/linalg/dsolve/linsolve.py trunk/scipy/sparse/sparsetools/bsr.h trunk/scipy/sparse/sparsetools/bsr.i trunk/scipy/sparse/sparsetools/bsr.py trunk/scipy/sparse/sparsetools/bsr_wrap.cxx trunk/scipy/sparse/sparsetools/csc.h trunk/scipy/sparse/sparsetools/csc.i trunk/scipy/sparse/sparsetools/csc.py trunk/scipy/sparse/sparsetools/csc_wrap.cxx trunk/scipy/sparse/sparsetools/csr.h trunk/scipy/sparse/sparsetools/csr.i trunk/scipy/sparse/sparsetools/csr.py trunk/scipy/sparse/sparsetools/csr_wrap.cxx trunk/scipy/sparse/tests/test_base.py Log: added several block matrix vector products Modified: trunk/scipy/sparse/benchmarks/bench_sparse.py =================================================================== --- trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -48,8 +48,8 @@ def bench_arithmetic(self): matrices = [] #matrices.append( ('A','Identity', sparse.identity(500**2,format='csr')) ) - matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr')) ) - matrices.append( ('B','Poisson5pt^2', poisson2d(500,format='csr')**2) ) + matrices.append( ('A','Poisson5pt', poisson2d(250,format='csr')) ) + matrices.append( ('B','Poisson5pt^2', poisson2d(250,format='csr')**2) ) print print ' Sparse Matrix Arithmetic' @@ -82,7 +82,7 @@ start = time.clock() iter = 0 - while iter < 5 or time.clock() < start + 1: + while iter < 3 or time.clock() < start + 0.5: fn(y) iter += 1 end = time.clock() @@ -133,6 +133,7 @@ matrices.append(('Poisson5pt', poisson2d(300,format='dia'))) matrices.append(('Poisson5pt', poisson2d(300,format='coo'))) matrices.append(('Poisson5pt', poisson2d(300,format='csr'))) + matrices.append(('Poisson5pt', poisson2d(300,format='csc'))) matrices.append(('Poisson5pt', poisson2d(300,format='bsr'))) A = sparse.kron(poisson2d(150),ones((2,2))).tobsr(blocksize=(2,2)) @@ -159,11 +160,6 @@ iter = 0 while iter < 5 or time.clock() < start + 1: y = A*x - #try: - # #avoid creating y if possible - # A.matvec(x,y) - #except: - # y = A*x iter += 1 end = time.clock() @@ -175,6 +171,46 @@ print fmt % (A.format,name,shape,A.nnz,MFLOPs) + def bench_matvecs(self): + matrices = [] + matrices.append(('Poisson5pt', poisson2d(300,format='dia'))) + matrices.append(('Poisson5pt', poisson2d(300,format='coo'))) + matrices.append(('Poisson5pt', poisson2d(300,format='csr'))) + matrices.append(('Poisson5pt', poisson2d(300,format='csc'))) + matrices.append(('Poisson5pt', poisson2d(300,format='bsr'))) + + + n_vecs = 10 + + print + print ' Sparse Matrix (Block) Vector Product' + print ' Blocksize = %d' % (n_vecs,) + print '==================================================================' + print ' type | name | shape | nnz | MFLOPs ' + print '------------------------------------------------------------------' + fmt = ' %3s | %12s | %20s | %8d | %6.1f ' + + for name,A in matrices: + x = ones((A.shape[1],10),dtype=A.dtype) + + y = A*x #warmup + + start = time.clock() + iter = 0 + while iter < 5 or time.clock() < start + 1: + y = A*x + iter += 1 + end = time.clock() + + del y + + name = name.center(12) + shape = ("%s" % (A.shape,)).center(20) + MFLOPs = (2*n_vecs*A.nnz*iter/(end-start))/float(1e6) + + print fmt % (A.format,name,shape,A.nnz,MFLOPs) + + def bench_construction(self): """build matrices by inserting single values""" matrices = [] @@ -213,13 +249,13 @@ def bench_conversion(self): A = poisson2d(100) - formats = ['csr','csc','coo','lil','dok'] + formats = ['csr','csc','coo','dia','lil','dok'] print - print ' Sparse Matrix Conversion' - print '==========================================================' - print ' format | tocsr() | tocsc() | tocoo() | tolil() | todok() ' - print '----------------------------------------------------------' + print ' Sparse Matrix Conversion' + print '====================================================================' + print ' format | tocsr() | tocsc() | tocoo() | todia() | tolil() | todok() ' + print '--------------------------------------------------------------------' for fromfmt in formats: base = getattr(A,'to' + fromfmt)() Modified: trunk/scipy/sparse/bsr.py =================================================================== --- trunk/scipy/sparse/bsr.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/bsr.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -15,7 +15,7 @@ from sputils import isshape, getdtype, to_native, isscalarlike, isdense, \ upcast import sparsetools -from sparsetools import bsr_matvec, csr_matmat_pass1, csr_matmat_pass2, \ +from sparsetools import bsr_matvec, bsr_matvecs, csr_matmat_pass1, csr_matmat_pass2, \ bsr_matmat_pass2, bsr_transpose, bsr_sort_indices class bsr_matrix(_cs_matrix): @@ -296,16 +296,30 @@ result = zeros( self.shape[0], dtype=upcast(self.dtype, other.dtype) ) bsr_matvec(M/R, N/C, R, C, \ - self.indptr, self.indices, ravel(self.data), other, result) + self.indptr, self.indices, self.data.ravel(), + other, result) return result + + def _mul_dense_matrix(self,other): + R,C = self.blocksize + M,N = self.shape + n_vecs = other.shape[1] #number of column vectors - def _mul_dense_matrix(self, other): - # TODO make sparse * dense matrix multiplication more efficient - # matvec each column of other - result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) - return result + result = zeros( (M,n_vecs), dtype=upcast(self.dtype,other.dtype) ) + bsr_matvecs(M/R, N/C, n_vecs, R, C, \ + self.indptr, self.indices, self.data.ravel(), \ + other.ravel(), result.ravel()) + + return result + + #def _mul_dense_matrix(self, other): + # # TODO make sparse * dense matrix multiplication more efficient + # # matvec each column of other + # result = hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) + # return result + def _mul_sparse_matrix(self, other): M, K1 = self.shape K2, N = other.shape Modified: trunk/scipy/sparse/compressed.py =================================================================== --- trunk/scipy/sparse/compressed.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/compressed.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -276,7 +276,7 @@ #output array result = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) - # csrmux, cscmux + # csr_matvec or csc_matvec fn = getattr(sparsetools,self.format + '_matvec') fn(M, N, self.indptr, self.indices, self.data, other, result) @@ -284,10 +284,17 @@ def _mul_dense_matrix(self,other): - # TODO make sparse * dense matrix multiplication more efficient - # matvec each column of other - return hstack( [ self * col.reshape(-1,1) for col in asarray(other).T ] ) + M,N = self.shape + n_vecs = other.shape[1] #number of column vectors + result = zeros( (M,n_vecs), dtype=upcast(self.dtype,other.dtype) ) + + # csr_matvecs or csc_matvecs + fn = getattr(sparsetools,self.format + '_matvecs') + fn(M, N, n_vecs, self.indptr, self.indices, self.data, other.ravel(), result.ravel()) + + return result + def _mul_sparse_matrix(self, other): M, K1 = self.shape Modified: trunk/scipy/sparse/coo.py =================================================================== --- trunk/scipy/sparse/coo.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/coo.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -8,7 +8,7 @@ from warnings import warn from numpy import array, asarray, empty, intc, zeros, \ - unique, searchsorted, atleast_2d, rank, deprecate + unique, searchsorted, atleast_2d, rank, deprecate, hstack from sparsetools import coo_tocsr, coo_tocsc, coo_todense, coo_matvec from base import isspmatrix @@ -338,6 +338,9 @@ result = zeros( self.shape[0], dtype=upcast(self.dtype,other.dtype) ) coo_matvec(self.nnz, self.row, self.col, self.data, other, result) return result + + def _mul_dense_matrix(self, other): + return hstack( [ self._mul_vector(col).reshape(-1,1) for col in other.T ] ) from sputils import _isinstance Modified: trunk/scipy/sparse/dia.py =================================================================== --- trunk/scipy/sparse/dia.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/dia.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -6,7 +6,7 @@ from numpy import asarray, asmatrix, matrix, zeros, arange, array, \ empty_like, intc, atleast_1d, atleast_2d, add, multiply, \ - unique + unique, hstack from base import isspmatrix, _formats from data import _data_matrix @@ -155,6 +155,8 @@ return y + def _mul_dense_matrix(self, other): + return hstack( [ self._mul_vector(col).reshape(-1,1) for col in other.T ] ) def todia(self,copy=False): if copy: @@ -180,21 +182,22 @@ for i,k in enumerate(self.diags): row[i,:] -= k + row,col,data = row.ravel(),col.ravel(),self.data.ravel() + mask = (row >= 0) mask &= (row < self.shape[0]) mask &= (col < self.shape[1]) - mask &= self.data != 0 - row,col,data = row[mask],col[mask],self.data[mask] - row,col,data = row.reshape(-1),col.reshape(-1),data.reshape(-1) + mask &= data != 0 + row,col,data = row[mask],col[mask],data[mask] + #row,col,data = row.reshape(-1),col.reshape(-1),data.reshape(-1) from coo import coo_matrix return coo_matrix((data,(row,col)),shape=self.shape) # needed by _data_matrix - def _with_data(self,data,copy=True): + def _with_data(self, data, copy=True): """Returns a matrix with the same sparsity structure as self, - but with different data. By default the structure arrays - (i.e. .indptr and .indices) are copied. + but with different data. By default the structure arrays are copied. """ if copy: return dia_matrix( (data,self.diags.copy()), shape=self.shape) Modified: trunk/scipy/sparse/linalg/dsolve/linsolve.py =================================================================== --- trunk/scipy/sparse/linalg/dsolve/linsolve.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/linalg/dsolve/linsolve.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -22,6 +22,8 @@ useUmfpack = True +__all__ = [ 'use_solver', 'spsolve', 'splu', 'factorized' ] + #convert numpy char to superLU char superLU_transtabl = {'f':'s', 'd':'d', 'F':'c', 'D':'z'} Modified: trunk/scipy/sparse/sparsetools/bsr.h =================================================================== --- trunk/scipy/sparse/sparsetools/bsr.h 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/bsr.h 2008-07-18 13:19:37 UTC (rev 4549) @@ -6,7 +6,7 @@ #include #include "csr.h" -#include "fixed_size.h" +#include "dense.h" template @@ -19,10 +19,10 @@ const T Ax[], T Yx[]) { - const I N = std::min(R*n_brow, C*n_bcol); + const I D = std::min(R*n_brow, C*n_bcol); const I RC = R*C; - for(I i = 0; i < N; i++){ + for(I i = 0; i < D; i++){ Yx[i] = 0; } @@ -45,7 +45,7 @@ else { //This could be made faster - const I end = (N/R) + (N % R == 0 ? 0 : 1); + const I end = (D/R) + (D % R == 0 ? 0 : 1); for(I i = 0; i < end; i++){ for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ const I base_row = R*i; @@ -54,7 +54,7 @@ for(I bi = 0; bi < R; bi++){ const I row = base_row + bi; - if (row >= N) break; + if (row >= D) break; for(I bj = 0; bj < C; bj++){ const I col = base_col + bj; @@ -87,16 +87,15 @@ const T Xx[]) { const I RC = R*C; + for(I i = 0; i < n_brow; i++){ + const T * row_scales = Xx + R*i; + for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ - for(I bi = 0; bi < R; bi++){ - const T s = Xx[R*i + bi]; - T * block_row = Ax + RC*jj + C*bi; - - for(I bj = 0; bj < C; bj++){ - block_row[bj] *= s; - } + T * block = Ax + RC*jj; + for(I bi = 0; bi < R; bi++){ + scal(C, row_scales[bi], block + C*bi); } } } @@ -167,7 +166,7 @@ const I RC = R*C; const I nnz = RC*nblks; - //compute permutation of blocks using tranpose(CSR) + //compute permutation of blocks using CSR std::vector perm(nblks); for(I i = 0; i < nblks; i++) @@ -249,70 +248,7 @@ } -template -void bsr_matmat_pass2_fixed(const I n_brow, const I n_bcol, - const I Ap[], const I Aj[], const T Ax[], - const I Bp[], const I Bj[], const T Bx[], - I Cp[], I Cj[], T Cx[]) -{ - const I RC = R*C; - const I RN = R*N; - const I NC = N*C; - const I SIZE = RC*Cp[n_brow]; - for(I i = 0; i < SIZE; i++){ - Cx[i] = 0; - } - - std::vector next(n_bcol,-1); - std::vector mats(n_bcol); - - - I nnz = 0; - - Cp[0] = 0; - - for(I i = 0; i < n_brow; i++){ - I head = -2; - I length = 0; - - I jj_start = Ap[i]; - I jj_end = Ap[i+1]; - for(I jj = jj_start; jj < jj_end; jj++){ - I j = Aj[jj]; - - I kk_start = Bp[j]; - I kk_end = Bp[j+1]; - for(I kk = kk_start; kk < kk_end; kk++){ - I k = Bj[kk]; - - if(next[k] == -1){ - next[k] = head; - head = k; - Cj[nnz] = k; - mats[k] = Cx + RC*nnz; - nnz++; - length++; - } - - const T * A = Ax + jj*RN; - const T * B = Bx + kk*NC; - T * result = mats[k]; - matmat(A,B,result); - } - } - - for(I jj = 0; jj < length; jj++){ - I temp = head; - head = next[head]; - next[temp] = -1; //clear arrays - } - - } - -} - - template void bsr_matmat_pass2(const I n_brow, const I n_bcol, const I R, const I C, const I N, @@ -322,44 +258,8 @@ { assert(R > 0 && C > 0 && N > 0); -#ifdef SPARSETOOLS_TESTING -#define F(X,Y,Z) bsr_matmat_pass2_fixed - - void (*dispatch[4][4][4])(I,I,const I*,const I*,const T*, - const I*,const I*,const T*, - I*, I*, T*) = \ - { - { { F(1,1,1), F(1,1,2), F(1,1,3), F(1,1,4) }, - { F(1,2,1), F(1,2,2), F(1,2,3), F(1,2,4) }, - { F(1,3,1), F(1,3,2), F(1,3,3), F(1,3,4) }, - { F(1,4,1), F(1,4,2), F(1,4,3), F(1,4,4) }, - }, - { { F(2,1,1), F(2,1,2), F(2,1,3), F(2,1,4) }, - { F(2,2,1), F(2,2,2), F(2,2,3), F(2,2,4) }, - { F(2,3,1), F(2,3,2), F(2,3,3), F(2,3,4) }, - { F(2,4,1), F(2,4,2), F(2,4,3), F(2,4,4) }, - }, - { { F(3,1,1), F(3,1,2), F(3,1,3), F(3,1,4) }, - { F(3,2,1), F(3,2,2), F(3,2,3), F(3,2,4) }, - { F(3,3,1), F(3,3,2), F(3,3,3), F(3,3,4) }, - { F(3,4,1), F(3,4,2), F(3,4,3), F(3,4,4) }, - }, - { { F(4,1,1), F(4,1,2), F(4,1,3), F(4,1,4) }, - { F(4,2,1), F(4,2,2), F(4,2,3), F(4,2,4) }, - { F(4,3,1), F(4,3,2), F(4,3,3), F(4,3,4) }, - { F(4,4,1), F(4,4,2), F(4,4,3), F(4,4,4) }, - } - }; - - if (R <= 4 && C <= 4 && N <= 4){ - dispatch[R-1][N-1][C-1](n_brow,n_bcol,Ap,Aj,Ax,Bp,Bj,Bx,Cp,Cj,Cx); - return; - } - -#undef F -#endif - if( R == 1 && N == 1 && C == 1 ){ + // Use CSR for 1x1 blocksize csr_matmat_pass2(n_brow, n_bcol, Ap, Aj, Ax, Bp, Bj, Bx, Cp, Cj, Cx); return; } @@ -367,12 +267,8 @@ const I RC = R*C; const I RN = R*N; const I NC = N*C; - const I SIZE = RC*Cp[n_brow]; - - for(I i = 0; i < SIZE; i++){ - Cx[i] = 0; - } + std::fill( Cx, Cx + RC * Cp[n_brow], 0 ); //clear output array std::vector next(n_bcol,-1); std::vector mats(n_bcol); @@ -405,15 +301,8 @@ const T * A = Ax + jj*RN; const T * B = Bx + kk*NC; - T * result = mats[k]; - for(I r = 0; r < R; r++){ - for(I c = 0; c < C; c++){ - for(I n = 0; n < N; n++){ - result[C*r + c] += A[N*r + n] * B[C*n + c]; - } - } - } + gemm(R, C, N, A, B, mats[k]); } } @@ -609,38 +498,7 @@ // } //} -template -void bsr_matvec_fixed(const I n_brow, - const I n_bcol, - const I Ap[], - const I Aj[], - const T Ax[], - const T Xx[], - T Yx[]) -{ - const int RC = R*C; - for(I i = 0; i < n_brow; i++) { - for(I jj = Ap[i]; jj < Ap[i+1]; jj++) { - I j = Aj[jj]; - matvec(Ax + jj*RC, Xx + j*C, Yx + i*R); - } - } -} -/* - * Generate the table below with: - * out = '' - * N = 8 - * for i in range(N): - * out += '{' - * for j in range(N-1): - * out += ' F(%d,%d),' % (i+1,j+1) - * out += ' F(%d,%d) },\n' % (i+1,j+2) - * out = out[:-2] - * - */ - - template void bsr_matvec(const I n_brow, const I n_bcol, @@ -655,50 +513,72 @@ assert(R > 0 && C > 0); if( R == 1 && C == 1 ){ - csr_matvec(n_brow, n_bcol, Ap, Aj, Ax, Xx, Yx); //use CSR for 1x1 blocksize + //use CSR for 1x1 blocksize + csr_matvec(n_brow, n_bcol, Ap, Aj, Ax, Xx, Yx); return; } -#ifdef SPARSETOOLS_TESTING -#define F(X,Y) bsr_matvec_fixed + const I RC = R*C; + for(I i = 0; i < n_brow; i++){ + T * y = Yx + R * i; + for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ + const I j = Aj[jj]; + const T * A = Ax + RC * jj; + const T * x = Xx + C * j; + gemv(R, C, A, x, y); // y += A*x + } + } +} +/* + * Compute Y += A*X for BSR matrix A and dense block vectors X,Y + * + * + * Input Arguments: + * I n_brow - number of row blocks in A + * I n_bcol - number of column blocks in A + * I n_vecs - number of column vectors in X and Y + * I R - rows per block + * I C - columns per block + * I Ap[n_brow+1] - row pointer + * I Aj[nblks(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * T Xx[C*n_bcol,n_vecs] - input vector + * + * Output Arguments: + * T Yx[R*n_brow,n_vecs] - output vector + * + */ +template +void bsr_matvecs(const I n_brow, + const I n_bcol, + const I n_vecs, + const I R, + const I C, + const I Ap[], + const I Aj[], + const T Ax[], + const T Xx[], + T Yx[]) +{ + assert(R > 0 && C > 0); - void (*dispatch[8][8])(I,I,const I*,const I*,const T*,const T*,T*) = \ - { - { F(1,1), F(1,2), F(1,3), F(1,4), F(1,5), F(1,6), F(1,7), F(1,8) }, - { F(2,1), F(2,2), F(2,3), F(2,4), F(2,5), F(2,6), F(2,7), F(2,8) }, - { F(3,1), F(3,2), F(3,3), F(3,4), F(3,5), F(3,6), F(3,7), F(3,8) }, - { F(4,1), F(4,2), F(4,3), F(4,4), F(4,5), F(4,6), F(4,7), F(4,8) }, - { F(5,1), F(5,2), F(5,3), F(5,4), F(5,5), F(5,6), F(5,7), F(5,8) }, - { F(6,1), F(6,2), F(6,3), F(6,4), F(6,5), F(6,6), F(6,7), F(6,8) }, - { F(7,1), F(7,2), F(7,3), F(7,4), F(7,5), F(7,6), F(7,7), F(7,8) }, - { F(8,1), F(8,2), F(8,3), F(8,4), F(8,5), F(8,6), F(8,7), F(8,8) } - }; - - if (R <= 8 && C <= 8){ - dispatch[R-1][C-1](n_brow,n_bcol,Ap,Aj,Ax,Xx,Yx); + if( R == 1 && C == 1 ){ + //use CSR for 1x1 blocksize + csr_matvecs(n_brow, n_bcol, n_vecs, Ap, Aj, Ax, Xx, Yx); return; } -#undef F -#endif + const I A_bs = R*C; //Ax blocksize + const I Y_bs = n_vecs*R; //Yx blocksize + const I X_bs = C*n_vecs; //Xx blocksize - //otherwise use general method for(I i = 0; i < n_brow; i++){ - const T * A = Ax + R * C * Ap[i]; - T * y = Yx + R * i; + T * y = Yx + Y_bs * i; for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ - const T * x = Xx + C*Aj[jj]; - - //TODO replace this with a proper matvec - for( I r = 0; r < R; r++ ){ - T sum = 0; - for( I c = 0; c < C; c++ ){ - sum += (*A) * x[c]; - A++; - } - y[r] += sum; - } - + const I j = Aj[jj]; + const T * A = Ax + A_bs * jj; + const T * x = Xx + X_bs * j; + gemm(R, n_vecs, C, A, x, y); // y += A*x } } } Modified: trunk/scipy/sparse/sparsetools/bsr.i =================================================================== --- trunk/scipy/sparse/sparsetools/bsr.i 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/bsr.i 2008-07-18 13:19:37 UTC (rev 4549) @@ -15,6 +15,7 @@ INSTANTIATE_ALL(bsr_transpose) INSTANTIATE_ALL(bsr_matmat_pass2) INSTANTIATE_ALL(bsr_matvec) +INSTANTIATE_ALL(bsr_matvecs) INSTANTIATE_ALL(bsr_elmul_bsr) INSTANTIATE_ALL(bsr_eldiv_bsr) INSTANTIATE_ALL(bsr_plus_bsr) Modified: trunk/scipy/sparse/sparsetools/bsr.py =================================================================== --- trunk/scipy/sparse/sparsetools/bsr.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/bsr.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -269,6 +269,48 @@ """ return _bsr.bsr_matvec(*args) +def bsr_matvecs(*args): + """ + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, signed char Ax, signed char Xx, + signed char Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, unsigned char Ax, unsigned char Xx, + unsigned char Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, short Ax, short Xx, short Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, unsigned short Ax, unsigned short Xx, + unsigned short Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, int Ax, int Xx, int Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, unsigned int Ax, unsigned int Xx, + unsigned int Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, long long Ax, long long Xx, long long Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, unsigned long long Ax, unsigned long long Xx, + unsigned long long Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, float Ax, float Xx, float Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, double Ax, double Xx, double Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, long double Ax, long double Xx, + long double Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, + int Aj, npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) + """ + return _bsr.bsr_matvecs(*args) + def bsr_elmul_bsr(*args): """ bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, Modified: trunk/scipy/sparse/sparsetools/bsr_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/bsr_wrap.cxx 2008-07-18 13:19:37 UTC (rev 4549) @@ -20630,6 +20630,3118 @@ } +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + signed char *arg8 ; + signed char *arg9 ; + signed char *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_BYTE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (signed char*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_BYTE, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (signed char*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_BYTE); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (signed char*) array_data(temp10); + } + bsr_matvecs< int,signed char >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(signed char const (*))arg8,(signed char const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + unsigned char *arg8 ; + unsigned char *arg9 ; + unsigned char *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_UBYTE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (unsigned char*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_UBYTE, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (unsigned char*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_UBYTE); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (unsigned char*) array_data(temp10); + } + bsr_matvecs< int,unsigned char >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned char const (*))arg8,(unsigned char const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + short *arg8 ; + short *arg9 ; + short *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_SHORT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (short*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_SHORT, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (short*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_SHORT); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (short*) array_data(temp10); + } + bsr_matvecs< int,short >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(short const (*))arg8,(short const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + unsigned short *arg8 ; + unsigned short *arg9 ; + unsigned short *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_USHORT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (unsigned short*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_USHORT, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (unsigned short*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_USHORT); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (unsigned short*) array_data(temp10); + } + bsr_matvecs< int,unsigned short >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned short const (*))arg8,(unsigned short const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + int *arg8 ; + int *arg9 ; + int *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (int*) array8->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (int*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_INT); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (int*) array_data(temp10); + } + bsr_matvecs< int,int >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,(int const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + unsigned int *arg8 ; + unsigned int *arg9 ; + unsigned int *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_UINT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (unsigned int*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_UINT, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (unsigned int*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_UINT); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (unsigned int*) array_data(temp10); + } + bsr_matvecs< int,unsigned int >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned int const (*))arg8,(unsigned int const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + long long *arg8 ; + long long *arg9 ; + long long *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGLONG, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (long long*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_LONGLONG, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (long long*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_LONGLONG); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (long long*) array_data(temp10); + } + bsr_matvecs< int,long long >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(long long const (*))arg8,(long long const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + unsigned long long *arg8 ; + unsigned long long *arg9 ; + unsigned long long *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_ULONGLONG, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (unsigned long long*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_ULONGLONG, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (unsigned long long*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_ULONGLONG); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (unsigned long long*) array_data(temp10); + } + bsr_matvecs< int,unsigned long long >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(unsigned long long const (*))arg8,(unsigned long long const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_9(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + float *arg9 ; + float *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (float*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_FLOAT, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (float*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_FLOAT); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (float*) array_data(temp10); + } + bsr_matvecs< int,float >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,(float const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_10(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + double *arg9 ; + double *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (double*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_DOUBLE, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (double*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_DOUBLE); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (double*) array_data(temp10); + } + bsr_matvecs< int,double >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,(double const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_11(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + long double *arg9 ; + long double *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (long double*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_LONGDOUBLE, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (long double*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_LONGDOUBLE); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (long double*) array_data(temp10); + } + bsr_matvecs< int,long double >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,(long double const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_12(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat_wrapper *arg8 ; + npy_cfloat_wrapper *arg9 ; + npy_cfloat_wrapper *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (npy_cfloat_wrapper*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_CFLOAT, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (npy_cfloat_wrapper*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_CFLOAT); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (npy_cfloat_wrapper*) array_data(temp10); + } + bsr_matvecs< int,npy_cfloat_wrapper >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat_wrapper const (*))arg8,(npy_cfloat_wrapper const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_13(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble_wrapper *arg8 ; + npy_cdouble_wrapper *arg9 ; + npy_cdouble_wrapper *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (npy_cdouble_wrapper*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_CDOUBLE, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (npy_cdouble_wrapper*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_CDOUBLE); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (npy_cdouble_wrapper*) array_data(temp10); + } + bsr_matvecs< int,npy_cdouble_wrapper >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble_wrapper const (*))arg8,(npy_cdouble_wrapper const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs__SWIG_14(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble_wrapper *arg8 ; + npy_clongdouble_wrapper *arg9 ; + npy_clongdouble_wrapper *arg10 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + PyArrayObject *array9 = NULL ; + int is_new_object9 ; + PyArrayObject *temp10 = NULL ; + 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 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:bsr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bsr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bsr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bsr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "bsr_matvecs" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bsr_matvecs" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + npy_intp size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1) + || !require_contiguous(array8) || !require_native(array8)) SWIG_fail; + + arg8 = (npy_clongdouble_wrapper*) array8->data; + } + { + npy_intp size[1] = { + -1 + }; + array9 = obj_to_array_contiguous_allow_conversion(obj8, PyArray_CLONGDOUBLE, &is_new_object9); + if (!array9 || !require_dimensions(array9,1) || !require_size(array9,size,1) + || !require_contiguous(array9) || !require_native(array9)) SWIG_fail; + + arg9 = (npy_clongdouble_wrapper*) array9->data; + } + { + temp10 = obj_to_array_no_conversion(obj9,PyArray_CLONGDOUBLE); + if (!temp10 || !require_contiguous(temp10) || !require_native(temp10)) SWIG_fail; + arg10 = (npy_clongdouble_wrapper*) array_data(temp10); + } + bsr_matvecs< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,arg4,arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble_wrapper const (*))arg8,(npy_clongdouble_wrapper const (*))arg9,arg10); + resultobj = SWIG_Py_Void(); + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return resultobj; +fail: + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + { + if (is_new_object8 && array8) { + Py_DECREF(array8); + } + } + { + if (is_new_object9 && array9) { + Py_DECREF(array9); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bsr_matvecs(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[11]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = (int)PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 10); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_7(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_8(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_9(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_10(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_11(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_12(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_13(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[8]) && PyArray_CanCastSafely(PyArray_TYPE(argv[8]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[9]) && PyArray_CanCastSafely(PyArray_TYPE(argv[9]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_bsr_matvecs__SWIG_14(self, args); + } + } + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_matvecs'.\n" + " Possible C/C++ prototypes are:\n" + " bsr_matvecs< int,signed char >(int const,int const,int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n" + " bsr_matvecs< int,unsigned char >(int const,int const,int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n" + " bsr_matvecs< int,short >(int const,int const,int const,int const,int const,int const [],int const [],short const [],short const [],short [])\n" + " bsr_matvecs< int,unsigned short >(int const,int const,int const,int const,int const,int const [],int const [],unsigned short const [],unsigned short const [],unsigned short [])\n" + " bsr_matvecs< int,int >(int const,int const,int const,int const,int const,int const [],int const [],int const [],int const [],int [])\n" + " bsr_matvecs< int,unsigned int >(int const,int const,int const,int const,int const,int const [],int const [],unsigned int const [],unsigned int const [],unsigned int [])\n" + " bsr_matvecs< int,long long >(int const,int const,int const,int const,int const,int const [],int const [],long long const [],long long const [],long long [])\n" + " bsr_matvecs< int,unsigned long long >(int const,int const,int const,int const,int const,int const [],int const [],unsigned long long const [],unsigned long long const [],unsigned long long [])\n" + " bsr_matvecs< int,float >(int const,int const,int const,int const,int const,int const [],int const [],float const [],float const [],float [])\n" + " bsr_matvecs< int,double >(int const,int const,int const,int const,int const,int const [],int const [],double const [],double const [],double [])\n" + " bsr_matvecs< int,long double >(int const,int const,int const,int const,int const,int const [],int const [],long double const [],long double const [],long double [])\n" + " bsr_matvecs< int,npy_cfloat_wrapper >(int const,int const,int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n" + " bsr_matvecs< int,npy_cdouble_wrapper >(int const,int const,int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n" + " bsr_matvecs< int,npy_clongdouble_wrapper >(int const,int const,int const,int const,int const,int const [],int const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper [])\n"); + return NULL; +} + + SWIGINTERN PyObject *_wrap_bsr_elmul_bsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -38786,6 +41898,45 @@ " npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, \n" " npy_clongdouble_wrapper Yx)\n" ""}, + { (char *)"bsr_matvecs", _wrap_bsr_matvecs, METH_VARARGS, (char *)"\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, signed char Ax, signed char Xx, \n" + " signed char Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, unsigned char Ax, unsigned char Xx, \n" + " unsigned char Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, short Ax, short Xx, short Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, unsigned short Ax, unsigned short Xx, \n" + " unsigned short Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, int Ax, int Xx, int Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, unsigned int Ax, unsigned int Xx, \n" + " unsigned int Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, long long Ax, long long Xx, long long Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, unsigned long long Ax, unsigned long long Xx, \n" + " unsigned long long Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, float Ax, float Xx, float Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, double Ax, double Xx, double Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, long double Ax, long double Xx, \n" + " long double Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, npy_cfloat_wrapper Ax, npy_cfloat_wrapper Xx, \n" + " npy_cfloat_wrapper Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, npy_cdouble_wrapper Ax, npy_cdouble_wrapper Xx, \n" + " npy_cdouble_wrapper Yx)\n" + "bsr_matvecs(int n_brow, int n_bcol, int n_vecs, int R, int C, int Ap, \n" + " int Aj, npy_clongdouble_wrapper Ax, npy_clongdouble_wrapper Xx, \n" + " npy_clongdouble_wrapper Yx)\n" + ""}, { (char *)"bsr_elmul_bsr", _wrap_bsr_elmul_bsr, METH_VARARGS, (char *)"\n" "bsr_elmul_bsr(int n_row, int n_col, int R, int C, int Ap, int Aj, \n" " signed char Ax, int Bp, int Bj, signed char Bx, \n" Modified: trunk/scipy/sparse/sparsetools/csc.h =================================================================== --- trunk/scipy/sparse/sparsetools/csc.h 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csc.h 2008-07-18 13:19:37 UTC (rev 4549) @@ -40,14 +40,55 @@ I col_end = Ap[j+1]; for(I ii = col_start; ii < col_end; ii++){ - I row = Ai[ii]; - Yx[row] += Ax[ii] * Xx[j]; + I i = Ai[ii]; + Yx[i] += Ax[ii] * Xx[j]; } } } /* + * Compute Y += A*X for CSC matrix A and dense block vectors X,Y + * + * + * Input Arguments: + * I n_row - number of rows in A + * I n_col - number of columns in A + * I n_vecs - number of column vectors in X and Y + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * T Xx[n_col,n_vecs] - input vector + * + * Output Arguments: + * T Yx[n_row,n_vecs] - output vector + * + * Note: + * Output array Yx must be preallocated + * + */ +template +void csc_matvecs(const I n_row, + const I n_col, + const I n_vecs, + const I Ap[], + const I Ai[], + const T Ax[], + const T Xx[], + T Yx[]) +{ + for(I j = 0; j < n_col; j++){ + for(I ii = Ap[j]; ii < Ap[j+1]; ii++){ + const I i = Ai[ii]; + axpy(n_vecs, Ax[ii], Xx + n_vecs * j, Yx + n_vecs * i); + } + } +} + + + + +/* * Derived methods */ template Modified: trunk/scipy/sparse/sparsetools/csc.i =================================================================== --- trunk/scipy/sparse/sparsetools/csc.i 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csc.i 2008-07-18 13:19:37 UTC (rev 4549) @@ -14,6 +14,7 @@ INSTANTIATE_ALL(csc_tocsr) INSTANTIATE_ALL(csc_matmat_pass2) INSTANTIATE_ALL(csc_matvec) +INSTANTIATE_ALL(csc_matvecs) INSTANTIATE_ALL(csc_elmul_csc) INSTANTIATE_ALL(csc_eldiv_csc) INSTANTIATE_ALL(csc_plus_csc) Modified: trunk/scipy/sparse/sparsetools/csc.py =================================================================== --- trunk/scipy/sparse/sparsetools/csc.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csc.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -195,6 +195,43 @@ """ return _csc.csc_matvec(*args) +def csc_matvecs(*args): + """ + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, signed char Ax, + signed char Xx, signed char Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned char Ax, + unsigned char Xx, unsigned char Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, short Ax, + short Xx, short Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned short Ax, + unsigned short Xx, unsigned short Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, int Ax, + int Xx, int Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned int Ax, + unsigned int Xx, unsigned int Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, long long Ax, + long long Xx, long long Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned long long Ax, + unsigned long long Xx, + unsigned long long Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, float Ax, + float Xx, float Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, double Ax, + double Xx, double Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, long double Ax, + long double Xx, long double Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) + """ + return _csc.csc_matvecs(*args) + def csc_elmul_csc(*args): """ csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, Modified: trunk/scipy/sparse/sparsetools/csc_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/csc_wrap.cxx 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csc_wrap.cxx 2008-07-18 13:19:37 UTC (rev 4549) @@ -13882,6 +13882,2698 @@ } +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + signed char *arg6 ; + signed char *arg7 ; + signed char *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_BYTE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (signed char*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_BYTE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (signed char*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_BYTE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (signed char*) array_data(temp8); + } + csc_matvecs< int,signed char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(signed char const (*))arg6,(signed char const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned char *arg6 ; + unsigned char *arg7 ; + unsigned char *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_UBYTE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned char*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_UBYTE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned char*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_UBYTE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned char*) array_data(temp8); + } + csc_matvecs< int,unsigned char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned char const (*))arg6,(unsigned char const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + short *arg6 ; + short *arg7 ; + short *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_SHORT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (short*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_SHORT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (short*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_SHORT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (short*) array_data(temp8); + } + csc_matvecs< int,short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(short const (*))arg6,(short const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned short *arg6 ; + unsigned short *arg7 ; + unsigned short *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_USHORT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned short*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_USHORT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned short*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_USHORT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned short*) array_data(temp8); + } + csc_matvecs< int,unsigned short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned short const (*))arg6,(unsigned short const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + int *arg6 ; + int *arg7 ; + int *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_INT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (int*) array_data(temp8); + } + csc_matvecs< int,int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned int *arg6 ; + unsigned int *arg7 ; + unsigned int *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_UINT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned int*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_UINT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned int*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_UINT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned int*) array_data(temp8); + } + csc_matvecs< int,unsigned int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned int const (*))arg6,(unsigned int const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + long long *arg6 ; + long long *arg7 ; + long long *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGLONG, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (long long*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_LONGLONG, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (long long*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_LONGLONG); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (long long*) array_data(temp8); + } + csc_matvecs< int,long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long long const (*))arg6,(long long const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned long long *arg6 ; + unsigned long long *arg7 ; + unsigned long long *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_ULONGLONG, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned long long*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_ULONGLONG, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned long long*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_ULONGLONG); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned long long*) array_data(temp8); + } + csc_matvecs< int,unsigned long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned long long const (*))arg6,(unsigned long long const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_9(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + float *arg6 ; + float *arg7 ; + float *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + 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; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (float*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_FLOAT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (float*) array_data(temp8); + } + csc_matvecs< int,float >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,(float const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_10(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + double *arg6 ; + double *arg7 ; + double *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + 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; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (double*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_DOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (double*) array_data(temp8); + } + csc_matvecs< int,double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,(double const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_11(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + long double *arg6 ; + long double *arg7 ; + long double *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (long double*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_LONGDOUBLE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (long double*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_LONGDOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (long double*) array_data(temp8); + } + csc_matvecs< int,long double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,(long double const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_12(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cfloat_wrapper *arg6 ; + npy_cfloat_wrapper *arg7 ; + npy_cfloat_wrapper *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (npy_cfloat_wrapper*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_CFLOAT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (npy_cfloat_wrapper*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_CFLOAT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (npy_cfloat_wrapper*) array_data(temp8); + } + csc_matvecs< int,npy_cfloat_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat_wrapper const (*))arg6,(npy_cfloat_wrapper const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_13(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cdouble_wrapper *arg6 ; + npy_cdouble_wrapper *arg7 ; + npy_cdouble_wrapper *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (npy_cdouble_wrapper*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_CDOUBLE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (npy_cdouble_wrapper*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_CDOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (npy_cdouble_wrapper*) array_data(temp8); + } + csc_matvecs< int,npy_cdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble_wrapper const (*))arg6,(npy_cdouble_wrapper const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs__SWIG_14(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_clongdouble_wrapper *arg6 ; + npy_clongdouble_wrapper *arg7 ; + npy_clongdouble_wrapper *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csc_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csc_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csc_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csc_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (npy_clongdouble_wrapper*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_CLONGDOUBLE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (npy_clongdouble_wrapper*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_CLONGDOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (npy_clongdouble_wrapper*) array_data(temp8); + } + csc_matvecs< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csc_matvecs(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = (int)PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_7(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_8(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 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) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_9(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 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) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_10(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_11(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_12(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_13(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csc_matvecs__SWIG_14(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_matvecs'.\n" + " Possible C/C++ prototypes are:\n" + " csc_matvecs< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n" + " csc_matvecs< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n" + " csc_matvecs< int,short >(int const,int const,int const,int const [],int const [],short const [],short const [],short [])\n" + " csc_matvecs< int,unsigned short >(int const,int const,int const,int const [],int const [],unsigned short const [],unsigned short const [],unsigned short [])\n" + " csc_matvecs< int,int >(int const,int const,int const,int const [],int const [],int const [],int const [],int [])\n" + " csc_matvecs< int,unsigned int >(int const,int const,int const,int const [],int const [],unsigned int const [],unsigned int const [],unsigned int [])\n" + " csc_matvecs< int,long long >(int const,int const,int const,int const [],int const [],long long const [],long long const [],long long [])\n" + " csc_matvecs< int,unsigned long long >(int const,int const,int const,int const [],int const [],unsigned long long const [],unsigned long long const [],unsigned long long [])\n" + " csc_matvecs< int,float >(int const,int const,int const,int const [],int const [],float const [],float const [],float [])\n" + " csc_matvecs< int,double >(int const,int const,int const,int const [],int const [],double const [],double const [],double [])\n" + " csc_matvecs< int,long double >(int const,int const,int const,int const [],int const [],long double const [],long double const [],long double [])\n" + " csc_matvecs< int,npy_cfloat_wrapper >(int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n" + " csc_matvecs< int,npy_cdouble_wrapper >(int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n" + " csc_matvecs< int,npy_clongdouble_wrapper >(int const,int const,int const,int const [],int const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper [])\n"); + return NULL; +} + + SWIGINTERN PyObject *_wrap_csc_elmul_csc__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -28645,6 +31337,40 @@ "csc_matvec(int n_row, int n_col, int Ap, int Ai, npy_clongdouble_wrapper Ax, \n" " npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx)\n" ""}, + { (char *)"csc_matvecs", _wrap_csc_matvecs, METH_VARARGS, (char *)"\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, signed char Ax, \n" + " signed char Xx, signed char Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned char Ax, \n" + " unsigned char Xx, unsigned char Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, short Ax, \n" + " short Xx, short Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned short Ax, \n" + " unsigned short Xx, unsigned short Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, int Ax, \n" + " int Xx, int Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned int Ax, \n" + " unsigned int Xx, unsigned int Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, long long Ax, \n" + " long long Xx, long long Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, unsigned long long Ax, \n" + " unsigned long long Xx, \n" + " unsigned long long Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, float Ax, \n" + " float Xx, float Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, double Ax, \n" + " double Xx, double Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, long double Ax, \n" + " long double Xx, long double Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, npy_cfloat_wrapper Ax, \n" + " npy_cfloat_wrapper Xx, \n" + " npy_cfloat_wrapper Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, npy_cdouble_wrapper Ax, \n" + " npy_cdouble_wrapper Xx, \n" + " npy_cdouble_wrapper Yx)\n" + "csc_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Ai, npy_clongdouble_wrapper Ax, \n" + " npy_clongdouble_wrapper Xx, \n" + " npy_clongdouble_wrapper Yx)\n" + ""}, { (char *)"csc_elmul_csc", _wrap_csc_elmul_csc, METH_VARARGS, (char *)"\n" "csc_elmul_csc(int n_row, int n_col, int Ap, int Ai, signed char Ax, \n" " int Bp, int Bi, signed char Bx, int Cp, int Ci, \n" Modified: trunk/scipy/sparse/sparsetools/csr.h =================================================================== --- trunk/scipy/sparse/sparsetools/csr.h 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csr.h 2008-07-18 13:19:37 UTC (rev 4549) @@ -5,6 +5,8 @@ #include #include +#include "dense.h" + /* * Extract main diagonal of CSR matrix A * @@ -854,6 +856,47 @@ } +/* + * Compute Y += A*X for CSR matrix A and dense block vectors X,Y + * + * + * Input Arguments: + * I n_row - number of rows in A + * I n_col - number of columns in A + * I n_vecs - number of column vectors in X and Y + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * T Xx[n_col,n_vecs] - input vector + * + * Output Arguments: + * T Yx[n_row,n_vecs] - output vector + * + */ +template +void csr_matvecs(const I n_row, + const I n_col, + const I n_vecs, + const I Ap[], + const I Aj[], + const T Ax[], + const T Xx[], + T Yx[]) +{ + for(I i = 0; i < n_row; i++){ + T * y = Yx + n_vecs * i; + for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ + const I j = Aj[jj]; + const T a = Ax[jj]; + const T * x = Xx + n_vecs * j; + axpy(n_vecs, a, x, y); + } + } +} + + + + template void get_csr_submatrix(const I n_row, const I n_col, Modified: trunk/scipy/sparse/sparsetools/csr.i =================================================================== --- trunk/scipy/sparse/sparsetools/csr.i 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csr.i 2008-07-18 13:19:37 UTC (rev 4549) @@ -22,6 +22,7 @@ INSTANTIATE_ALL(csr_tobsr) INSTANTIATE_ALL(csr_matmat_pass2) INSTANTIATE_ALL(csr_matvec) +INSTANTIATE_ALL(csr_matvecs) INSTANTIATE_ALL(csr_elmul_csr) INSTANTIATE_ALL(csr_eldiv_csr) INSTANTIATE_ALL(csr_plus_csr) Modified: trunk/scipy/sparse/sparsetools/csr.py =================================================================== --- trunk/scipy/sparse/sparsetools/csr.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csr.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -299,6 +299,43 @@ """ return _csr.csr_matvec(*args) +def csr_matvecs(*args): + """ + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, signed char Ax, + signed char Xx, signed char Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned char Ax, + unsigned char Xx, unsigned char Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, short Ax, + short Xx, short Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned short Ax, + unsigned short Xx, unsigned short Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, int Ax, + int Xx, int Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned int Ax, + unsigned int Xx, unsigned int Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, long long Ax, + long long Xx, long long Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned long long Ax, + unsigned long long Xx, + unsigned long long Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, float Ax, + float Xx, float Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, double Ax, + double Xx, double Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, long double Ax, + long double Xx, long double Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, npy_cfloat_wrapper Ax, + npy_cfloat_wrapper Xx, + npy_cfloat_wrapper Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, npy_cdouble_wrapper Ax, + npy_cdouble_wrapper Xx, + npy_cdouble_wrapper Yx) + csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, npy_clongdouble_wrapper Ax, + npy_clongdouble_wrapper Xx, + npy_clongdouble_wrapper Yx) + """ + return _csr.csr_matvecs(*args) + def csr_elmul_csr(*args): """ csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, Modified: trunk/scipy/sparse/sparsetools/csr_wrap.cxx =================================================================== --- trunk/scipy/sparse/sparsetools/csr_wrap.cxx 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/csr_wrap.cxx 2008-07-18 13:19:37 UTC (rev 4549) @@ -21145,6 +21145,2698 @@ } +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + signed char *arg6 ; + signed char *arg7 ; + signed char *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_BYTE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (signed char*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_BYTE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (signed char*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_BYTE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (signed char*) array_data(temp8); + } + csr_matvecs< int,signed char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(signed char const (*))arg6,(signed char const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned char *arg6 ; + unsigned char *arg7 ; + unsigned char *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_UBYTE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned char*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_UBYTE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned char*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_UBYTE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned char*) array_data(temp8); + } + csr_matvecs< int,unsigned char >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned char const (*))arg6,(unsigned char const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + short *arg6 ; + short *arg7 ; + short *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_SHORT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (short*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_SHORT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (short*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_SHORT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (short*) array_data(temp8); + } + csr_matvecs< int,short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(short const (*))arg6,(short const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned short *arg6 ; + unsigned short *arg7 ; + unsigned short *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_USHORT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned short*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_USHORT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned short*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_USHORT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned short*) array_data(temp8); + } + csr_matvecs< int,unsigned short >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned short const (*))arg6,(unsigned short const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + int *arg6 ; + int *arg7 ; + int *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (int*) array6->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (int*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_INT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (int*) array_data(temp8); + } + csr_matvecs< int,int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned int *arg6 ; + unsigned int *arg7 ; + unsigned int *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_UINT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned int*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_UINT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned int*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_UINT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned int*) array_data(temp8); + } + csr_matvecs< int,unsigned int >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned int const (*))arg6,(unsigned int const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + long long *arg6 ; + long long *arg7 ; + long long *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGLONG, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (long long*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_LONGLONG, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (long long*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_LONGLONG); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (long long*) array_data(temp8); + } + csr_matvecs< int,long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long long const (*))arg6,(long long const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + unsigned long long *arg6 ; + unsigned long long *arg7 ; + unsigned long long *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_ULONGLONG, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (unsigned long long*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_ULONGLONG, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (unsigned long long*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_ULONGLONG); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (unsigned long long*) array_data(temp8); + } + csr_matvecs< int,unsigned long long >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(unsigned long long const (*))arg6,(unsigned long long const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_9(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + float *arg6 ; + float *arg7 ; + float *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + 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; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (float*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_FLOAT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (float*) array_data(temp8); + } + csr_matvecs< int,float >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,(float const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_10(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + double *arg6 ; + double *arg7 ; + double *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + 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; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (double*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_DOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (double*) array_data(temp8); + } + csr_matvecs< int,double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,(double const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_11(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + long double *arg6 ; + long double *arg7 ; + long double *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (long double*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_LONGDOUBLE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (long double*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_LONGDOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (long double*) array_data(temp8); + } + csr_matvecs< int,long double >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,(long double const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_12(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cfloat_wrapper *arg6 ; + npy_cfloat_wrapper *arg7 ; + npy_cfloat_wrapper *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (npy_cfloat_wrapper*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_CFLOAT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (npy_cfloat_wrapper*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_CFLOAT); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (npy_cfloat_wrapper*) array_data(temp8); + } + csr_matvecs< int,npy_cfloat_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat_wrapper const (*))arg6,(npy_cfloat_wrapper const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_13(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cdouble_wrapper *arg6 ; + npy_cdouble_wrapper *arg7 ; + npy_cdouble_wrapper *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (npy_cdouble_wrapper*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_CDOUBLE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (npy_cdouble_wrapper*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_CDOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (npy_cdouble_wrapper*) array_data(temp8); + } + csr_matvecs< int,npy_cdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble_wrapper const (*))arg6,(npy_cdouble_wrapper const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs__SWIG_14(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_clongdouble_wrapper *arg6 ; + npy_clongdouble_wrapper *arg7 ; + npy_clongdouble_wrapper *arg8 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *temp8 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csr_matvecs",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csr_matvecs" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csr_matvecs" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "csr_matvecs" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + { + npy_intp size[1] = { + -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) + || !require_contiguous(array4) || !require_native(array4)) SWIG_fail; + + arg4 = (int*) array4->data; + } + { + npy_intp size[1] = { + -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) + || !require_contiguous(array5) || !require_native(array5)) SWIG_fail; + + arg5 = (int*) array5->data; + } + { + npy_intp size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1) + || !require_contiguous(array6) || !require_native(array6)) SWIG_fail; + + arg6 = (npy_clongdouble_wrapper*) array6->data; + } + { + npy_intp size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_CLONGDOUBLE, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1) + || !require_contiguous(array7) || !require_native(array7)) SWIG_fail; + + arg7 = (npy_clongdouble_wrapper*) array7->data; + } + { + temp8 = obj_to_array_no_conversion(obj7,PyArray_CLONGDOUBLE); + if (!temp8 || !require_contiguous(temp8) || !require_native(temp8)) SWIG_fail; + arg8 = (npy_clongdouble_wrapper*) array_data(temp8); + } + csr_matvecs< int,npy_clongdouble_wrapper >(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble_wrapper const (*))arg6,(npy_clongdouble_wrapper const (*))arg7,arg8); + resultobj = SWIG_Py_Void(); + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return resultobj; +fail: + { + if (is_new_object4 && array4) { + Py_DECREF(array4); + } + } + { + if (is_new_object5 && array5) { + Py_DECREF(array5); + } + } + { + if (is_new_object6 && array6) { + Py_DECREF(array6); + } + } + { + if (is_new_object7 && array7) { + Py_DECREF(array7); + } + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csr_matvecs(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = (int)PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_BYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_UBYTE)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_SHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_USHORT)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_UINT)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_7(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_ULONGLONG)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_8(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 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) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_9(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 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) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_10(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_11(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_12(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_13(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csr_matvecs__SWIG_14(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_matvecs'.\n" + " Possible C/C++ prototypes are:\n" + " csr_matvecs< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n" + " csr_matvecs< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n" + " csr_matvecs< int,short >(int const,int const,int const,int const [],int const [],short const [],short const [],short [])\n" + " csr_matvecs< int,unsigned short >(int const,int const,int const,int const [],int const [],unsigned short const [],unsigned short const [],unsigned short [])\n" + " csr_matvecs< int,int >(int const,int const,int const,int const [],int const [],int const [],int const [],int [])\n" + " csr_matvecs< int,unsigned int >(int const,int const,int const,int const [],int const [],unsigned int const [],unsigned int const [],unsigned int [])\n" + " csr_matvecs< int,long long >(int const,int const,int const,int const [],int const [],long long const [],long long const [],long long [])\n" + " csr_matvecs< int,unsigned long long >(int const,int const,int const,int const [],int const [],unsigned long long const [],unsigned long long const [],unsigned long long [])\n" + " csr_matvecs< int,float >(int const,int const,int const,int const [],int const [],float const [],float const [],float [])\n" + " csr_matvecs< int,double >(int const,int const,int const,int const [],int const [],double const [],double const [],double [])\n" + " csr_matvecs< int,long double >(int const,int const,int const,int const [],int const [],long double const [],long double const [],long double [])\n" + " csr_matvecs< int,npy_cfloat_wrapper >(int const,int const,int const,int const [],int const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper const [],npy_cfloat_wrapper [])\n" + " csr_matvecs< int,npy_cdouble_wrapper >(int const,int const,int const,int const [],int const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper const [],npy_cdouble_wrapper [])\n" + " csr_matvecs< int,npy_clongdouble_wrapper >(int const,int const,int const,int const [],int const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper const [],npy_clongdouble_wrapper [])\n"); + return NULL; +} + + SWIGINTERN PyObject *_wrap_csr_elmul_csr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -42954,6 +45646,40 @@ "csr_matvec(int n_row, int n_col, int Ap, int Aj, npy_clongdouble_wrapper Ax, \n" " npy_clongdouble_wrapper Xx, npy_clongdouble_wrapper Yx)\n" ""}, + { (char *)"csr_matvecs", _wrap_csr_matvecs, METH_VARARGS, (char *)"\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, signed char Ax, \n" + " signed char Xx, signed char Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned char Ax, \n" + " unsigned char Xx, unsigned char Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, short Ax, \n" + " short Xx, short Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned short Ax, \n" + " unsigned short Xx, unsigned short Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, int Ax, \n" + " int Xx, int Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned int Ax, \n" + " unsigned int Xx, unsigned int Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, long long Ax, \n" + " long long Xx, long long Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, unsigned long long Ax, \n" + " unsigned long long Xx, \n" + " unsigned long long Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, float Ax, \n" + " float Xx, float Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, double Ax, \n" + " double Xx, double Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, long double Ax, \n" + " long double Xx, long double Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, npy_cfloat_wrapper Ax, \n" + " npy_cfloat_wrapper Xx, \n" + " npy_cfloat_wrapper Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, npy_cdouble_wrapper Ax, \n" + " npy_cdouble_wrapper Xx, \n" + " npy_cdouble_wrapper Yx)\n" + "csr_matvecs(int n_row, int n_col, int n_vecs, int Ap, int Aj, npy_clongdouble_wrapper Ax, \n" + " npy_clongdouble_wrapper Xx, \n" + " npy_clongdouble_wrapper Yx)\n" + ""}, { (char *)"csr_elmul_csr", _wrap_csr_elmul_csr, METH_VARARGS, (char *)"\n" "csr_elmul_csr(int n_row, int n_col, int Ap, int Aj, signed char Ax, \n" " int Bp, int Bj, signed char Bx, int Cp, int Cj, \n" Added: trunk/scipy/sparse/sparsetools/dense.h =================================================================== --- trunk/scipy/sparse/sparsetools/dense.h 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/sparsetools/dense.h 2008-07-18 13:19:37 UTC (rev 4549) @@ -0,0 +1,83 @@ +#ifndef __DENSE_H__ +#define __DENSE_H__ + +// Simplified BLAS routines and other dense linear algebra functions + +/* + * Level 1 + */ + +// y += a*x +template +void axpy(const I n, const T a, const T * x, T * y){ + for(I i = 0; i < n; i++){ + y[i] += a * x[i]; + } +} + +// scale a vector in-place +template +void scal(const I n, const T a, T * x){ + for(I i = 0; i < n; i++){ + x[i] *= a; + } +} + + +// dot product +template +void dot(const I n, const T * x, const T * y){ + T dp = 0; + for(I i = 0; i < n; i++){ + dp += x[i] * y[i]; + } + return dp; +} + + +// vectorize a binary operation +template +void vector_binop(const I n, const T * x, const T * y, T * z, + const binary_operator& op) +{ + for(I i = 0; i < n; i++){ + z[i] = op(x[i],y[i]); + } +} + +//template +//void vector_multiply(const I n, const T * x, const T * y, T * z){ +//{ +// vector_binop(n,x,y,z, std::multiplies() ); +//} + + + +// Level 2 +template +void gemv(const I m, const I n, const T * A, const T * x, T * y){ + for(I i = 0; i < m; i++){ + T dot = y[i]; + for(I j = 0; j < n; j++){ + dot += A[n * i + j] * x[j]; + } + y[i] = dot; + } +} + +// Level 3 +template +void gemm(const I m, const I n, const I k, const T * A, const T * B, T * C){ + for(I i = 0; i < m; i++){ + for(I j = 0; j < n; j++){ + T dot = C[n * i + j]; + for(I _d = 0; _d < k; _d++){ + dot += A[k * i + _d] * B[n * _d + j]; + } + C[n * i + j] = dot; + } + } +} + + +#endif Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-07-17 12:50:08 UTC (rev 4548) +++ trunk/scipy/sparse/tests/test_base.py 2008-07-18 13:19:37 UTC (rev 4549) @@ -400,7 +400,7 @@ assert_equal( result, dot(a,b) ) def test_sparse_format_conversions(self): - A = sparse.kron([[1,0,1],[0,1,1],[1,0,0]], [[1,1],[0,1]] ) + A = sparse.kron( [[1,0,2],[0,3,4],[5,0,0]], [[1,2],[0,3]] ) D = A.todense() A = self.spmatrix(A) @@ -441,7 +441,7 @@ def test_add_dense(self): - """ Check whether adding a dense matrix to a sparse matrix works + """ adding a dense matrix to a sparse matrix """ sum1 = self.dat + self.datsp assert_array_equal(sum1, 2*self.dat) @@ -449,7 +449,7 @@ assert_array_equal(sum2, 2*self.dat) def test_sub_dense(self): - """ Check whether adding a dense matrix to a sparse matrix works + """ subtracting a dense matrix to/from a sparse matrix """ sum1 = 3*self.dat - self.datsp assert_array_equal(sum1, 2*self.dat) @@ -1406,6 +1406,16 @@ assert_array_equal(asp.nnz, 3*4) assert_array_equal(asp.todense(),bsp.todense()) + def test_bsr_matvec(self): + A = bsr_matrix( arange(2*3*4*5).reshape(2*4,3*5), blocksize=(4,5) ) + x = arange(A.shape[1]).reshape(-1,1) + assert_equal(A*x, A.todense()*x) + def test_bsr_matvecs(self): + A = bsr_matrix( arange(2*3*4*5).reshape(2*4,3*5), blocksize=(4,5) ) + x = arange(A.shape[1]*6).reshape(-1,6) + assert_equal(A*x, A.todense()*x) + + if __name__ == "__main__": nose.run(argv=['', __file__]) From scipy-svn at scipy.org Fri Jul 18 15:44:23 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 18 Jul 2008 14:44:23 -0500 (CDT) Subject: [Scipy-svn] r4550 - in branches/Interpolate1D: . fitpack Message-ID: <20080718194423.7DB3639C59E@scipy.org> Author: fcady Date: 2008-07-18 14:44:12 -0500 (Fri, 18 Jul 2008) New Revision: 4550 Added: branches/Interpolate1D/fitpack/ branches/Interpolate1D/fitpack/Makefile branches/Interpolate1D/fitpack/README branches/Interpolate1D/fitpack/bispev.f branches/Interpolate1D/fitpack/clocur.f branches/Interpolate1D/fitpack/cocosp.f branches/Interpolate1D/fitpack/concon.f branches/Interpolate1D/fitpack/concur.f branches/Interpolate1D/fitpack/cualde.f branches/Interpolate1D/fitpack/curev.f branches/Interpolate1D/fitpack/curfit.f branches/Interpolate1D/fitpack/dblint.f branches/Interpolate1D/fitpack/evapol.f branches/Interpolate1D/fitpack/fourco.f branches/Interpolate1D/fitpack/fpader.f branches/Interpolate1D/fitpack/fpadno.f branches/Interpolate1D/fitpack/fpadpo.f branches/Interpolate1D/fitpack/fpback.f branches/Interpolate1D/fitpack/fpbacp.f branches/Interpolate1D/fitpack/fpbfout.f branches/Interpolate1D/fitpack/fpbisp.f branches/Interpolate1D/fitpack/fpbspl.f branches/Interpolate1D/fitpack/fpchec.f branches/Interpolate1D/fitpack/fpched.f branches/Interpolate1D/fitpack/fpchep.f branches/Interpolate1D/fitpack/fpclos.f branches/Interpolate1D/fitpack/fpcoco.f branches/Interpolate1D/fitpack/fpcons.f branches/Interpolate1D/fitpack/fpcosp.f branches/Interpolate1D/fitpack/fpcsin.f branches/Interpolate1D/fitpack/fpcurf.f branches/Interpolate1D/fitpack/fpcuro.f branches/Interpolate1D/fitpack/fpcyt1.f branches/Interpolate1D/fitpack/fpcyt2.f branches/Interpolate1D/fitpack/fpdeno.f branches/Interpolate1D/fitpack/fpdisc.f branches/Interpolate1D/fitpack/fpfrno.f branches/Interpolate1D/fitpack/fpgivs.f branches/Interpolate1D/fitpack/fpgrdi.f branches/Interpolate1D/fitpack/fpgrpa.f branches/Interpolate1D/fitpack/fpgrre.f branches/Interpolate1D/fitpack/fpgrsp.f branches/Interpolate1D/fitpack/fpinst.f branches/Interpolate1D/fitpack/fpintb.f branches/Interpolate1D/fitpack/fpknot.f branches/Interpolate1D/fitpack/fpopdi.f branches/Interpolate1D/fitpack/fpopsp.f branches/Interpolate1D/fitpack/fporde.f branches/Interpolate1D/fitpack/fppara.f branches/Interpolate1D/fitpack/fppasu.f branches/Interpolate1D/fitpack/fpperi.f branches/Interpolate1D/fitpack/fppocu.f branches/Interpolate1D/fitpack/fppogr.f branches/Interpolate1D/fitpack/fppola.f branches/Interpolate1D/fitpack/fprank.f branches/Interpolate1D/fitpack/fprati.f branches/Interpolate1D/fitpack/fpregr.f branches/Interpolate1D/fitpack/fprota.f branches/Interpolate1D/fitpack/fprppo.f branches/Interpolate1D/fitpack/fprpsp.f branches/Interpolate1D/fitpack/fpseno.f branches/Interpolate1D/fitpack/fpspgr.f branches/Interpolate1D/fitpack/fpsphe.f branches/Interpolate1D/fitpack/fpsuev.f branches/Interpolate1D/fitpack/fpsurf.f branches/Interpolate1D/fitpack/fpsysy.f branches/Interpolate1D/fitpack/fptrnp.f branches/Interpolate1D/fitpack/fptrpe.f branches/Interpolate1D/fitpack/insert.f branches/Interpolate1D/fitpack/parcur.f branches/Interpolate1D/fitpack/parder.f branches/Interpolate1D/fitpack/parsur.f branches/Interpolate1D/fitpack/percur.f branches/Interpolate1D/fitpack/pogrid.f branches/Interpolate1D/fitpack/polar.f branches/Interpolate1D/fitpack/profil.f branches/Interpolate1D/fitpack/regrid.f branches/Interpolate1D/fitpack/spalde.f branches/Interpolate1D/fitpack/spgrid.f branches/Interpolate1D/fitpack/sphere.f branches/Interpolate1D/fitpack/splder.f branches/Interpolate1D/fitpack/splev.f branches/Interpolate1D/fitpack/splint.f branches/Interpolate1D/fitpack/sproot.f branches/Interpolate1D/fitpack/surev.f branches/Interpolate1D/fitpack/surfit.f branches/Interpolate1D/multipack.h Removed: branches/Interpolate1D/Interpolate1D.pyc branches/Interpolate1D/__init__fit.py branches/Interpolate1D/_interpolate.pyd branches/Interpolate1D/build/ branches/Interpolate1D/dfitpack.py branches/Interpolate1D/dfitpack.pyd branches/Interpolate1D/fitpack_wrapper.pyc branches/Interpolate1D/info_fit.py branches/Interpolate1D/interpolate_wrapper.pyc Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/__init__.py branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate_wrapper.py branches/Interpolate1D/setup.py Log: Interpolate1D builds correctly, unnecessary files removed, other improvements. Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -11,6 +11,7 @@ # fixme: use this to ensure proper type of all inputs and outputs in Interpolate1D def make_array_safe(ary, typecode=np.float64): + # fixme: could pick correct typecode ary = np.atleast_1d(np.asarray(ary, typecode)) if not ary.flags['CONTIGUOUS']: ary = ary.copy() @@ -18,44 +19,98 @@ class Interpolate1D(object): - # see enthought.interpolate - # fixme: Handle other data types. - def __init__(self, x, y, k=1, kind='linear', low=None, high=None): - + def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, missing_data=[None, np.NaN]): + """ + Object for interpolation of 1D data. + + REQUIRED ARGUMENTS: + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. + + OPTIONAL ARGUMENTS: + + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + If nothing else, assumes the argument is intended as a value + to be returned for all arguments. Defaults to linear interpolation. + + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. + + + + """ # fixme: Handle checking if they are the correct size. self._x = make_array_safe(x).copy() self._y = make_array_safe(y).copy() - self._xdtype = type(self._x[0]) - self._ydtype = type(self._y[0]) - - assert( len(x) == len(y) , "x and y must be of the same length" ) - assert( x.ndim == 1 , "x must be one-dimensional" ) - assert( y.ndim == 1 , "y must be one-dimensional" ) + + assert len(x) == len(y) , "x and y must be of the same length" + assert x.ndim == 1 , "x must be one-dimensional" + assert y.ndim == 1 , "y must be one-dimensional" # fixme: let y be 2-dimensional. Involves reworking of Interpolate1D.__call__ # because Spline enumerates y along the last, rather then first, axis, # while concatenate works along first axis - self.kind = self._init_interp_method(self._x, self._y, k, kind) - self.low = self._init_interp_method(self._x, self._y, k, low) - self.high = self._init_interp_method(self._x, self._y, k, high) + self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) + self.low = self._init_interp_method(self._x, self._y, low, lowkw) + self.high = self._init_interp_method(self._x, self._y, high, highkw) - def _init_interp_method(self, x, y, k, interp_arg): + def _format_array(x, y, missing_data=[None, np.NaN]): + # fixme: don't allow copying multiple times. + + assert len(x) > 0 and len(y) > 0 , "interpolation does not support\ + array of length 0" + assert len(x) == len(y) , "x and y must be of the same length" + mask = [((xi not in missing_data) and (y[i] not in missing_data)) \ + for i, xi in enumerate(x) ] + if isinstance(x, list): + x = [x[i] for (i, good_data) in enumerate(mask) if good_data] + else: + x = x[mask] + if isinstance(y, list): + y = [y[i] for (i, good_data) in enumerate(mask) if good_data] + else: + y = y[mask] + self._xdtype = type(x[0]) + self._x = make_array_safe(x, _xdtype).copy() + self._ydtype = type(y[0]) + self._y = make_array_safe(y, _ydtype).copy() + + assert self._x.ndim == 1 , "x must be one-dimensional" + assert self._y.ndim == 1 , "y must be one-dimensional" + + def _init_interp_method(self, x, y, interp_arg, kw): from inspect import isclass, isfunction if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x) + result = lambda new_x : func(self._x, self._y, new_x, **kw) elif interp_arg in ['Spline', Spline, 'spline']: - result = Spline(self._x, self._y, k=k) + result = Spline(self._x, self._y, **kw) elif isfunction(interp_arg): - result = interp_arg + result = lambda new_x : interp_arg(new_x, **kw) elif isclass(interp_arg): - result = interp_arg(x, y) + result = interp_arg(x, y, **kw) else: - print "warning: defaulting on extrapolation" result = np.vectorize(lambda new_x : interp_arg) return result @@ -65,10 +120,9 @@ low_mask = xself._x[-1] interp_mask = (~low_mask) & (~high_mask) - - # hack, since getting an error when self.low or self.high gets 0-length array - # and they return None or NaN - if len(x[low_mask]) == 0: new_low=np.array([]) + + if len(x[low_mask]) == 0: new_low=np.array([]) # hack, since vectorize is failing + # work on lists/arrays of length 0 else: new_low = self.low(x[low_mask]) if len(x[interp_mask])==0: new_interp=np.array([]) else: new_interp = self.kind(x[interp_mask]) @@ -86,45 +140,89 @@ def assertAllclose(self, x, y): self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - # fixme: run the test contained in the wrapper modules + def test__interpolate_wrapper(self): + print "\n\nTESTING _interpolate_wrapper MODULE" + from interpolate_wrapper import Test + T = Test() + T.runTest() - def test_Interp_linearSpl(self): - #return + def test__fitpack_wrapper(self): + print "\n\nTESTING _fitpack_wrapper MODULE" + from fitpack_wrapper import Test + T = Test() + T.runTest() + + def test_spline1_defaultExt(self): + # make sure : spline order 1 (linear) interpolation works correctly + # make sure : default extrapolation works print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 + N = 7 # must be > 5 x = np.arange(N) y = np.arange(N) + interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + + self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) + self.assert_(new_y[0] == None) + self.assert_(new_y[-1] == 599.73) + + def test_spline2(self): + print "\n\nTESTING 2nd ORDER SPLINE" + # make sure : order-2 splines work on linear data + N = 7 #must be > 5 + x = np.arange(N) + y = np.arange(N) T1 = time.clock() - interp_func = Interpolate1D(x, y, k=1, kind='Spline', low=None, high=None) + interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') T2 = time.clock() - print 'time to create linear interp function: ', T2 - T1 - new_x = np.arange(N)-0.5 + print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 + new_x = np.arange(N+1)-0.5 t1 = time.clock() new_y = interp_func(new_x) t2 = time.clock() - print '1d interp (sec):', t2 - t1 + print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 + self.assertAllclose(new_x, new_y) - print "new_y: ", new_y - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) + # make sure for non-linear data + N = 7 + x = np.arange(N) + y = x**2 + interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_x**2, new_y) + def test_linear(self): + # make sure : linear interpolation works + # make sure : linear extrapolation works print "\n\nTESTING LINEAR INTERPOLATION" N = 7 x = arange(N) y = arange(N) new_x = arange(N+1)-0.5 T1 = time.clock() - interp_func = Interpolate1D(x, y, kind='linear', low=None, high=None) + interp_func = Interpolate1D(x, y, kind='linear', low='linear', high='linear') T2 = time.clock() - print 'time to create linear interp function: ', T2 - T1 + print "time to create linear interp function with N = %i: " % N, T2 - T1 t1 = time.clock() new_y = interp_func(new_x) t2 = time.clock() - print '1d interp (sec):', t2 - t1 + print "time to create linear interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) + self.assertAllclose(new_x, new_y) + def test_noLow(self): + # make sure : having the out-of-range elements in new_x is fine + # there was a bug with this + N = 5 + x = arange(N) + y = arange(N) + new_x = arange(1,N-1)+.2 + interp_func = Interpolate1D(x, y, kind='linear', low='linear', high=np.NaN) + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + if __name__ == '__main__': unittest.main() \ No newline at end of file Deleted: branches/Interpolate1D/Interpolate1D.pyc =================================================================== (Binary files differ) Modified: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/__init__.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,3 +1,5 @@ -from interpolate_wrapper import linear, logarithmicm, block_average_above + +from interpolate_wrapper import linear, logarithmic, block, block_average_above +from fitpack_wrapper import Spline from Interpolate1D import Interpolate1D \ No newline at end of file Deleted: branches/Interpolate1D/__init__fit.py =================================================================== --- branches/Interpolate1D/__init__fit.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/__init__fit.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,15 +0,0 @@ -# -# interpolate - Interpolation Tools -# - -from info import __doc__ - -#from interpolate import * -#from fitpack import * - -# New interface to fitpack library: -from fitpack2 import * - -__all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import NumpyTest -test = NumpyTest().test Deleted: branches/Interpolate1D/_interpolate.pyd =================================================================== (Binary files differ) Deleted: branches/Interpolate1D/dfitpack.py =================================================================== --- branches/Interpolate1D/dfitpack.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/dfitpack.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,7 +0,0 @@ -def __bootstrap__(): - global __bootstrap__, __loader__, __file__ - import sys, pkg_resources, imp - __file__ = pkg_resources.resource_filename(__name__,'dfitpack.pyd') - del __bootstrap__, __loader__ - imp.load_dynamic(__name__,__file__) -__bootstrap__() Deleted: branches/Interpolate1D/dfitpack.pyd =================================================================== (Binary files differ) Added: branches/Interpolate1D/fitpack/Makefile =================================================================== --- branches/Interpolate1D/fitpack/Makefile 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/Makefile 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,19 @@ +# Makefile that builts a library lib$(LIB).a from all +# of the Fortran files found in the current directory. +# Usage: make LIB= +# Pearu + +OBJ=$(patsubst %.f,%.o,$(shell ls *.f)) +all: lib$(LIB).a +$(OBJ): + $(FC) -c $(FFLAGS) $(FSHARED) $(patsubst %.o,%.f,$(@F)) -o $@ +lib$(LIB).a: $(OBJ) + $(AR) rus lib$(LIB).a $? +clean: + rm *.o + + + + + + Added: branches/Interpolate1D/fitpack/README =================================================================== --- branches/Interpolate1D/fitpack/README 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/README 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,3 @@ +- ddierckx is a 'real*8' version of dierckx + generated by Pearu Peterson . +- dierckx (in netlib) is fitpack by P. Dierckx Added: branches/Interpolate1D/fitpack/bispev.f =================================================================== --- branches/Interpolate1D/fitpack/bispev.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/bispev.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,103 @@ + subroutine bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk, + * iwrk,kwrk,ier) +c subroutine bispev evaluates on a grid (x(i),y(j)),i=1,...,mx; j=1,... +c ,my a bivariate spline s(x,y) of degrees kx and ky, given in the +c b-spline representation. +c +c calling sequence: +c call bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk, +c * iwrk,kwrk,ier) +c +c input parameters: +c tx : real array, length nx, which contains the position of the +c knots in the x-direction. +c nx : integer, giving the total number of knots in the x-direction +c ty : real array, length ny, which contains the position of the +c knots in the y-direction. +c ny : integer, giving the total number of knots in the y-direction +c c : real array, length (nx-kx-1)*(ny-ky-1), which contains the +c b-spline coefficients. +c kx,ky : integer values, giving the degrees of the spline. +c x : real array of dimension (mx). +c before entry x(i) must be set to the x co-ordinate of the +c i-th grid point along the x-axis. +c tx(kx+1)<=x(i-1)<=x(i)<=tx(nx-kx), i=2,...,mx. +c mx : on entry mx must specify the number of grid points along +c the x-axis. mx >=1. +c y : real array of dimension (my). +c before entry y(j) must be set to the y co-ordinate of the +c j-th grid point along the y-axis. +c ty(ky+1)<=y(j-1)<=y(j)<=ty(ny-ky), j=2,...,my. +c my : on entry my must specify the number of grid points along +c the y-axis. my >=1. +c wrk : real array of dimension lwrk. used as workspace. +c lwrk : integer, specifying the dimension of wrk. +c lwrk >= mx*(kx+1)+my*(ky+1) +c iwrk : integer array of dimension kwrk. used as workspace. +c kwrk : integer, specifying the dimension of iwrk. kwrk >= mx+my. +c +c output parameters: +c z : real array of dimension (mx*my). +c on succesful exit z(my*(i-1)+j) contains the value of s(x,y) +c at the point (x(i),y(j)),i=1,...,mx;j=1,...,my. +c ier : integer error flag +c ier=0 : normal return +c ier=10: invalid input data (see restrictions) +c +c restrictions: +c mx >=1, my >=1, lwrk>=mx*(kx+1)+my*(ky+1), kwrk>=mx+my +c tx(kx+1) <= x(i-1) <= x(i) <= tx(nx-kx), i=2,...,mx +c ty(ky+1) <= y(j-1) <= y(j) <= ty(ny-ky), j=2,...,my +c +c other subroutines required: +c fpbisp,fpbspl +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer nx,ny,kx,ky,mx,my,lwrk,kwrk,ier +c ..array arguments.. + integer iwrk(kwrk) + real*8 tx(nx),ty(ny),c((nx-kx-1)*(ny-ky-1)),x(mx),y(my),z(mx*my), + * wrk(lwrk) +c ..local scalars.. + integer i,iw,lwest +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + lwest = (kx+1)*mx+(ky+1)*my + if(lwrk.lt.lwest) go to 100 + if(kwrk.lt.(mx+my)) go to 100 + if (mx.lt.1) go to 100 + if (mx.eq.1) go to 30 + go to 10 + 10 do 20 i=2,mx + if(x(i).lt.x(i-1)) go to 100 + 20 continue + 30 if (my.lt.1) go to 100 + if (my.eq.1) go to 60 + go to 40 + 40 do 50 i=2,my + if(y(i).lt.y(i-1)) go to 100 + 50 continue + 60 ier = 0 + iw = mx*(kx+1)+1 + call fpbisp(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk(1),wrk(iw), + * iwrk(1),iwrk(mx+1)) + 100 return + end Added: branches/Interpolate1D/fitpack/clocur.f =================================================================== --- branches/Interpolate1D/fitpack/clocur.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/clocur.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,352 @@ + subroutine clocur(iopt,ipar,idim,m,u,mx,x,w,k,s,nest,n,t,nc,c,fp, + * wrk,lwrk,iwrk,ier) +c given the ordered set of m points x(i) in the idim-dimensional space +c with x(1)=x(m), and given also a corresponding set of strictly in- +c creasing values u(i) and the set of positive numbers w(i),i=1,2,...,m +c subroutine clocur determines a smooth approximating closed spline +c curve s(u), i.e. +c x1 = s1(u) +c x2 = s2(u) u(1) <= u <= u(m) +c ......... +c xidim = sidim(u) +c with sj(u),j=1,2,...,idim periodic spline functions of degree k with +c common knots t(j),j=1,2,...,n. +c if ipar=1 the values u(i),i=1,2,...,m must be supplied by the user. +c if ipar=0 these values are chosen automatically by clocur as +c v(1) = 0 +c v(i) = v(i-1) + dist(x(i),x(i-1)) ,i=2,3,...,m +c u(i) = v(i)/v(m) ,i=1,2,...,m +c if iopt=-1 clocur calculates the weighted least-squares closed spline +c curve according to a given set of knots. +c if iopt>=0 the number of knots of the splines sj(u) and the position +c t(j),j=1,2,...,n is chosen automatically by the routine. the smooth- +c ness of s(u) is then achieved by minimalizing the discontinuity +c jumps of the k-th derivative of s(u) at the knots t(j),j=k+2,k+3,..., +c n-k-1. the amount of smoothness is determined by the condition that +c f(p)=sum((w(i)*dist(x(i),s(u(i))))**2) be <= s, with s a given non- +c negative constant, called the smoothing factor. +c the fit s(u) is given in the b-spline representation and can be +c evaluated by means of subroutine curev. +c +c calling sequence: +c call clocur(iopt,ipar,idim,m,u,mx,x,w,k,s,nest,n,t,nc,c, +c * fp,wrk,lwrk,iwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares closed spline curve (iopt=-1) or a smoothing +c closed spline curve (iopt=0 or 1) must be determined. if +c iopt=0 the routine will start with an initial set of knots +c t(i)=u(1)+(u(m)-u(1))*(i-k-1),i=1,2,...,2*k+2. if iopt=1 the +c routine will continue with the knots found at the last call. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c ipar : integer flag. on entry ipar must specify whether (ipar=1) +c the user will supply the parameter values u(i),or whether +c (ipar=0) these values are to be calculated by clocur. +c unchanged on exit. +c idim : integer. on entry idim must specify the dimension of the +c curve. 0 < idim < 11. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m > 1. unchanged on exit. +c u : real array of dimension at least (m). in case ipar=1,before +c entry, u(i) must be set to the i-th value of the parameter +c variable u for i=1,2,...,m. these values must then be +c supplied in strictly ascending order and will be unchanged +c on exit. in case ipar=0, on exit,the array will contain the +c values u(i) as determined by clocur. +c mx : integer. on entry mx must specify the actual dimension of +c the array x as declared in the calling (sub)program. mx must +c not be too small (see x). unchanged on exit. +c x : real array of dimension at least idim*m. +c before entry, x(idim*(i-1)+j) must contain the j-th coord- +c inate of the i-th data point for i=1,2,...,m and j=1,2,..., +c idim. since first and last data point must coincide it +c means that x(j)=x(idim*(m-1)+j),j=1,2,...,idim. +c unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. w(m) is not used. +c unchanged on exit. see also further comments. +c k : integer. on entry k must specify the degree of the splines. +c 1<=k<=5. it is recommended to use cubic splines (k=3). +c the user is strongly dissuaded from choosing k even,together +c with a small s-value. unchanged on exit. +c s : real.on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments. +c nest : integer. on entry nest must contain an over-estimate of the +c total number of knots of the splines returned, to indicate +c the storage space available to the routine. nest >=2*k+2. +c in most practical situation nest=m/2 will be sufficient. +c always large enough is nest=m+2*k, the number of knots +c needed for interpolation (s=0). unchanged on exit. +c n : integer. +c unless ier = 10 (in case iopt >=0), n will contain the +c total number of knots of the smoothing spline curve returned +c if the computation mode iopt=1 is used this value of n +c should be left unchanged between subsequent calls. +c in case iopt=-1, the value of n must be specified on entry. +c t : real array of dimension at least (nest). +c on succesful exit, this array will contain the knots of the +c spline curve,i.e. the position of the interior knots t(k+2), +c t(k+3),..,t(n-k-1) as well as the position of the additional +c t(1),t(2),..,t(k+1)=u(1) and u(m)=t(n-k),...,t(n) needed for +c the b-spline representation. +c if the computation mode iopt=1 is used, the values of t(1), +c t(2),...,t(n) should be left unchanged between subsequent +c calls. if the computation mode iopt=-1 is used, the values +c t(k+2),...,t(n-k-1) must be supplied by the user, before +c entry. see also the restrictions (ier=10). +c nc : integer. on entry nc must specify the actual dimension of +c the array c as declared in the calling (sub)program. nc +c must not be too small (see c). unchanged on exit. +c c : real array of dimension at least (nest*idim). +c on succesful exit, this array will contain the coefficients +c in the b-spline representation of the spline curve s(u),i.e. +c the b-spline coefficients of the spline sj(u) will be given +c in c(n*(j-1)+i),i=1,2,...,n-k-1 for j=1,2,...,idim. +c fp : real. unless ier = 10, fp contains the weighted sum of +c squared residuals of the spline curve returned. +c wrk : real array of dimension at least m*(k+1)+nest*(7+idim+5*k). +c used as working space. if the computation mode iopt=1 is +c used, the values wrk(1),...,wrk(n) should be left unchanged +c between subsequent calls. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (nest). +c used as working space. if the computation mode iopt=1 is +c used,the values iwrk(1),...,iwrk(n) should be left unchanged +c between subsequent calls. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the close curve returned has a residual +c sum of squares fp such that abs(fp-s)/s <= tol with tol a +c relative tolerance set to 0.001 by the program. +c ier=-1 : normal return. the curve returned is an interpolating +c spline curve (fp=0). +c ier=-2 : normal return. the curve returned is the weighted least- +c squares point,i.e. each spline sj(u) is a constant. in +c this extreme case fp gives the upper bound fp0 for the +c smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameter nest. +c probably causes : nest too small. if nest is already +c large (say nest > m/2), it may also indicate that s is +c too small +c the approximation returned is the least-squares closed +c curve according to the knots t(1),t(2),...,t(n). (n=nest) +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing curve with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing curve +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 1<=k<=5, m>1, nest>2*k+2, w(i)>0,i=1,2,...,m +c 0<=ipar<=1, 0=(k+1)*m+nest*(7+idim+5*k), +c nc>=nest*idim, x(j)=x(idim*(m-1)+j), j=1,2,...,idim +c if ipar=0: sum j=1,idim (x(i*idim+j)-x((i-1)*idim+j))**2>0 +c i=1,2,...,m-1. +c if ipar=1: u(1)=0: s>=0 +c if s=0 : nest >= m+2*k +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the curve will be too smooth and signal will be +c lost ; if s is too small the curve will pick up too much noise. in +c the extreme cases the program will return an interpolating curve if +c s=0 and the weighted least-squares point if s is very large. +c between these extremes, a properly chosen s will result in a good +c compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c x(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in x(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the weighted +c least-squares point and the upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximating curve shows more detail) to obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if clocur is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c curve underlying the data. but, if the computation mode iopt=1 is +c used, the knots returned may also depend on the s-values at previous +c calls (if these were smaller). therefore, if after a number of +c trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c clocur once more with the selected value for s but now with iopt=0. +c indeed, clocur may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c +c the form of the approximating curve can strongly be affected by +c the choice of the parameter values u(i). if there is no physical +c reason for choosing a particular parameter u, often good results +c will be obtained with the choice of clocur(in case ipar=0), i.e. +c v(1)=0, v(i)=v(i-1)+q(i), i=2,...,m, u(i)=v(i)/v(m), i=1,..,m +c where +c q(i)= sqrt(sum j=1,idim (xj(i)-xj(i-1))**2 ) +c other possibilities for q(i) are +c q(i)= sum j=1,idim (xj(i)-xj(i-1))**2 +c q(i)= sum j=1,idim abs(xj(i)-xj(i-1)) +c q(i)= max j=1,idim abs(xj(i)-xj(i-1)) +c q(i)= 1 +c +c +c other subroutines required: +c fpbacp,fpbspl,fpchep,fpclos,fpdisc,fpgivs,fpknot,fprati,fprota +c +c references: +c dierckx p. : algorithms for smoothing data with periodic and +c parametric splines, computer graphics and image +c processing 20 (1982) 171-184. +c dierckx p. : algorithms for smoothing data with periodic and param- +c etric splines, report tw55, dept. computer science, +c k.u.leuven, 1981. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + real*8 s,fp + integer iopt,ipar,idim,m,mx,k,nest,n,nc,lwrk,ier +c ..array arguments.. + real*8 u(m),x(mx),w(m),t(nest),c(nc),wrk(lwrk) + integer iwrk(nest) +c ..local scalars.. + real*8 per,tol,dist + integer i,ia1,ia2,ib,ifp,ig1,ig2,iq,iz,i1,i2,j1,j2,k1,k2,lwest, + * maxit,m1,nmin,ncc,j +c ..function references.. + real*8 sqrt +c we set up the parameters tol and maxit + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 90 + if(ipar.lt.0 .or. ipar.gt.1) go to 90 + if(idim.le.0 .or. idim.gt.10) go to 90 + if(k.le.0 .or. k.gt.5) go to 90 + k1 = k+1 + k2 = k1+1 + nmin = 2*k1 + if(m.lt.2 .or. nest.lt.nmin) go to 90 + ncc = nest*idim + if(mx.lt.m*idim .or. nc.lt.ncc) go to 90 + lwest = m*k1+nest*(7+idim+5*k) + if(lwrk.lt.lwest) go to 90 + i1 = idim + i2 = m*idim + do 5 j=1,idim + if(x(i1).ne.x(i2)) go to 90 + i1 = i1-1 + i2 = i2-1 + 5 continue + if(ipar.ne.0 .or. iopt.gt.0) go to 40 + i1 = 0 + i2 = idim + u(1) = 0. + do 20 i=2,m + dist = 0. + do 10 j1=1,idim + i1 = i1+1 + i2 = i2+1 + dist = dist+(x(i2)-x(i1))**2 + 10 continue + u(i) = u(i-1)+sqrt(dist) + 20 continue + if(u(m).le.0.) go to 90 + do 30 i=2,m + u(i) = u(i)/u(m) + 30 continue + u(m) = 0.1e+01 + 40 if(w(1).le.0.) go to 90 + m1 = m-1 + do 50 i=1,m1 + if(u(i).ge.u(i+1) .or. w(i).le.0.) go to 90 + 50 continue + if(iopt.ge.0) go to 70 + if(n.le.nmin .or. n.gt.nest) go to 90 + per = u(m)-u(1) + j1 = k1 + t(j1) = u(1) + i1 = n-k + t(i1) = u(m) + j2 = j1 + i2 = i1 + do 60 i=1,k + i1 = i1+1 + i2 = i2-1 + j1 = j1+1 + j2 = j2-1 + t(j2) = t(i2)-per + t(i1) = t(j1)+per + 60 continue + call fpchep(u,m,t,n,k,ier) + if (ier.eq.0) go to 80 + go to 90 + 70 if(s.lt.0.) go to 90 + if(s.eq.0. .and. nest.lt.(m+2*k)) go to 90 + ier = 0 +c we partition the working space and determine the spline approximation. + 80 ifp = 1 + iz = ifp+nest + ia1 = iz+ncc + ia2 = ia1+nest*k1 + ib = ia2+nest*k + ig1 = ib+nest*k2 + ig2 = ig1+nest*k2 + iq = ig2+nest*k1 + call fpclos(iopt,idim,m,u,mx,x,w,k,s,nest,tol,maxit,k1,k2,n,t, + * ncc,c,fp,wrk(ifp),wrk(iz),wrk(ia1),wrk(ia2),wrk(ib),wrk(ig1), + * wrk(ig2),wrk(iq),iwrk,ier) + 90 return + end Added: branches/Interpolate1D/fitpack/cocosp.f =================================================================== --- branches/Interpolate1D/fitpack/cocosp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/cocosp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,180 @@ + subroutine cocosp(m,x,y,w,n,t,e,maxtr,maxbin,c,sq,sx,bind,wrk, + * lwrk,iwrk,kwrk,ier) +c given the set of data points (x(i),y(i)) and the set of positive +c numbers w(i),i=1,2,...,m, subroutine cocosp determines the weighted +c least-squares cubic spline s(x) with given knots t(j),j=1,2,...,n +c which satisfies the following concavity/convexity conditions +c s''(t(j+3))*e(j) <= 0, j=1,2,...n-6 +c the fit is given in the b-spline representation( b-spline coef- +c ficients c(j),j=1,2,...n-4) and can be evaluated by means of +c subroutine splev. +c +c calling sequence: +c call cocosp(m,x,y,w,n,t,e,maxtr,maxbin,c,sq,sx,bind,wrk, +c * lwrk,iwrk,kwrk,ier) +c +c parameters: +c m : integer. on entry m must specify the number of data points. +c m > 3. unchanged on exit. +c x : real array of dimension at least (m). before entry, x(i) +c must be set to the i-th value of the independent variable x, +c for i=1,2,...,m. these values must be supplied in strictly +c ascending order. unchanged on exit. +c y : real array of dimension at least (m). before entry, y(i) +c must be set to the i-th value of the dependent variable y, +c for i=1,2,...,m. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. unchanged on exit. +c n : integer. on entry n must contain the total number of knots +c of the cubic spline. m+4>=n>=8. unchanged on exit. +c t : real array of dimension at least (n). before entry, this +c array must contain the knots of the spline, i.e. the position +c of the interior knots t(5),t(6),...,t(n-4) as well as the +c position of the boundary knots t(1),t(2),t(3),t(4) and t(n-3) +c t(n-2),t(n-1),t(n) needed for the b-spline representation. +c unchanged on exit. see also the restrictions (ier=10). +c e : real array of dimension at least (n). before entry, e(j) +c must be set to 1 if s(x) must be locally concave at t(j+3), +c to (-1) if s(x) must be locally convex at t(j+3) and to 0 +c if no convexity constraint is imposed at t(j+3),j=1,2,..,n-6. +c e(n-5),...,e(n) are not used. unchanged on exit. +c maxtr : integer. on entry maxtr must contain an over-estimate of the +c total number of records in the used tree structure, to indic- +c ate the storage space available to the routine. maxtr >=1 +c in most practical situation maxtr=100 will be sufficient. +c always large enough is +c n-5 n-6 +c maxtr = ( ) + ( ) with l the greatest +c l l+1 +c integer <= (n-6)/2 . unchanged on exit. +c maxbin: integer. on entry maxbin must contain an over-estimate of the +c number of knots where s(x) will have a zero second derivative +c maxbin >=1. in most practical situation maxbin = 10 will be +c sufficient. always large enough is maxbin=n-6. +c unchanged on exit. +c c : real array of dimension at least (n). +c on succesful exit, this array will contain the coefficients +c c(1),c(2),..,c(n-4) in the b-spline representation of s(x) +c sq : real. on succesful exit, sq contains the weighted sum of +c squared residuals of the spline approximation returned. +c sx : real array of dimension at least m. on succesful exit +c this array will contain the spline values s(x(i)),i=1,...,m +c bind : logical array of dimension at least (n). on succesful exit +c this array will indicate the knots where s''(x)=0, i.e. +c s''(t(j+3)) .eq. 0 if bind(j) = .true. +c s''(t(j+3)) .ne. 0 if bind(j) = .false., j=1,2,...,n-6 +c wrk : real array of dimension at least m*4+n*7+maxbin*(maxbin+n+1) +c used as working space. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program.lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (maxtr*4+2*(maxbin+1)) +c used as working space. +c kwrk : integer. on entry,kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. kwrk +c must not be too small (see iwrk). unchanged on exit. +c ier : integer. error flag +c ier=0 : succesful exit. +c ier>0 : abnormal termination: no approximation is returned +c ier=1 : the number of knots where s''(x)=0 exceeds maxbin. +c probably causes : maxbin too small. +c ier=2 : the number of records in the tree structure exceeds +c maxtr. +c probably causes : maxtr too small. +c ier=3 : the algoritm finds no solution to the posed quadratic +c programming problem. +c probably causes : rounding errors. +c ier=10 : on entry, the input data are controlled on validity. +c the following restrictions must be satisfied +c m>3, maxtr>=1, maxbin>=1, 8<=n<=m+4,w(i) > 0, +c x(1)=maxtr*4+2*(maxbin+1), +c lwrk>=m*4+n*7+maxbin*(maxbin+n+1), +c the schoenberg-whitney conditions, i.e. there must +c be a subset of data points xx(j) such that +c t(j) < xx(j) < t(j+4), j=1,2,...,n-4 +c if one of these restrictions is found to be violated +c control is immediately repassed to the calling program +c +c +c other subroutines required: +c fpcosp,fpbspl,fpadno,fpdeno,fpseno,fpfrno,fpchec +c +c references: +c dierckx p. : an algorithm for cubic spline fitting with convexity +c constraints, computing 24 (1980) 349-371. +c dierckx p. : an algorithm for least-squares cubic spline fitting +c with convexity and concavity constraints, report tw39, +c dept. computer science, k.u.leuven, 1978. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p. dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : march 1978 +c latest update : march 1987. +c +c .. +c ..scalar arguments.. + real*8 sq + integer m,n,maxtr,maxbin,lwrk,kwrk,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),t(n),e(n),c(n),sx(m),wrk(lwrk) + integer iwrk(kwrk) + logical bind(n) +c ..local scalars.. + integer i,ia,ib,ic,iq,iu,iz,izz,ji,jib,jjb,jl,jr,ju,kwest, + * lwest,mb,nm,n6 + real*8 one +c .. +c set constant + one = 0.1e+01 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(m.lt.4 .or. n.lt.8) go to 40 + if(maxtr.lt.1 .or. maxbin.lt.1) go to 40 + lwest = 7*n+m*4+maxbin*(1+n+maxbin) + kwest = 4*maxtr+2*(maxbin+1) + if(lwrk.lt.lwest .or. kwrk.lt.kwest) go to 40 + if(w(1).le.0.) go to 40 + do 10 i=2,m + if(x(i-1).ge.x(i) .or. w(i).le.0.) go to 40 + 10 continue + call fpchec(x,m,t,n,3,ier) + if (ier.eq.0) go to 20 + go to 40 +c set numbers e(i) + 20 n6 = n-6 + do 30 i=1,n6 + if(e(i).gt.0.) e(i) = one + if(e(i).lt.0.) e(i) = -one + 30 continue +c we partition the working space and determine the spline approximation + nm = n+maxbin + mb = maxbin+1 + ia = 1 + ib = ia+4*n + ic = ib+nm*maxbin + iz = ic+n + izz = iz+n + iu = izz+n + iq = iu+maxbin + ji = 1 + ju = ji+maxtr + jl = ju+maxtr + jr = jl+maxtr + jjb = jr+maxtr + jib = jjb+mb + call fpcosp(m,x,y,w,n,t,e,maxtr,maxbin,c,sq,sx,bind,nm,mb,wrk(ia), + * + * wrk(ib),wrk(ic),wrk(iz),wrk(izz),wrk(iu),wrk(iq),iwrk(ji), + * iwrk(ju),iwrk(jl),iwrk(jr),iwrk(jjb),iwrk(jib),ier) + 40 return + end Added: branches/Interpolate1D/fitpack/concon.f =================================================================== --- branches/Interpolate1D/fitpack/concon.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/concon.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,233 @@ + subroutine concon(iopt,m,x,y,w,v,s,nest,maxtr,maxbin,n,t,c,sq, + * sx,bind,wrk,lwrk,iwrk,kwrk,ier) +c given the set of data points (x(i),y(i)) and the set of positive +c numbers w(i), i=1,2,...,m,subroutine concon determines a cubic spline +c approximation s(x) which satisfies the following local convexity +c constraints s''(x(i))*v(i) <= 0, i=1,2,...,m. +c the number of knots n and the position t(j),j=1,2,...n is chosen +c automatically by the routine in a way that +c sq = sum((w(i)*(y(i)-s(x(i))))**2) be <= s. +c the fit is given in the b-spline representation (b-spline coef- +c ficients c(j),j=1,2,...n-4) and can be evaluated by means of +c subroutine splev. +c +c calling sequence: +c +c call concon(iopt,m,x,y,w,v,s,nest,maxtr,maxbin,n,t,c,sq, +c * sx,bind,wrk,lwrk,iwrk,kwrk,ier) +c +c parameters: +c iopt: integer flag. +c if iopt=0, the routine will start with the minimal number of +c knots to guarantee that the convexity conditions will be +c satisfied. if iopt=1, the routine will continue with the set +c of knots found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m > 3. unchanged on exit. +c x : real array of dimension at least (m). before entry, x(i) +c must be set to the i-th value of the independent variable x, +c for i=1,2,...,m. these values must be supplied in strictly +c ascending order. unchanged on exit. +c y : real array of dimension at least (m). before entry, y(i) +c must be set to the i-th value of the dependent variable y, +c for i=1,2,...,m. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. unchanged on exit. +c v : real array of dimension at least (m). before entry, v(i) +c must be set to 1 if s(x) must be locally concave at x(i), +c to (-1) if s(x) must be locally convex at x(i) and to 0 +c if no convexity constraint is imposed at x(i). +c s : real. on entry s must specify an over-estimate for the +c the weighted sum of squared residuals sq of the requested +c spline. s >=0. unchanged on exit. +c nest : integer. on entry nest must contain an over-estimate of the +c total number of knots of the spline returned, to indicate +c the storage space available to the routine. nest >=8. +c in most practical situation nest=m/2 will be sufficient. +c always large enough is nest=m+4. unchanged on exit. +c maxtr : integer. on entry maxtr must contain an over-estimate of the +c total number of records in the used tree structure, to indic- +c ate the storage space available to the routine. maxtr >=1 +c in most practical situation maxtr=100 will be sufficient. +c always large enough is +c nest-5 nest-6 +c maxtr = ( ) + ( ) with l the greatest +c l l+1 +c integer <= (nest-6)/2 . unchanged on exit. +c maxbin: integer. on entry maxbin must contain an over-estimate of the +c number of knots where s(x) will have a zero second derivative +c maxbin >=1. in most practical situation maxbin = 10 will be +c sufficient. always large enough is maxbin=nest-6. +c unchanged on exit. +c n : integer. +c on exit with ier <=0, n will contain the total number of +c knots of the spline approximation returned. if the comput- +c ation mode iopt=1 is used this value of n should be left +c unchanged between subsequent calls. +c t : real array of dimension at least (nest). +c on exit with ier<=0, this array will contain the knots of the +c spline,i.e. the position of the interior knots t(5),t(6),..., +c t(n-4) as well as the position of the additional knots +c t(1)=t(2)=t(3)=t(4)=x(1) and t(n-3)=t(n-2)=t(n-1)=t(n)=x(m) +c needed for the the b-spline representation. +c if the computation mode iopt=1 is used, the values of t(1), +c t(2),...,t(n) should be left unchanged between subsequent +c calls. +c c : real array of dimension at least (nest). +c on succesful exit, this array will contain the coefficients +c c(1),c(2),..,c(n-4) in the b-spline representation of s(x) +c sq : real. unless ier>0 , sq contains the weighted sum of +c squared residuals of the spline approximation returned. +c sx : real array of dimension at least m. on exit with ier<=0 +c this array will contain the spline values s(x(i)),i=1,...,m +c if the computation mode iopt=1 is used, the values of sx(1), +c sx(2),...,sx(m) should be left unchanged between subsequent +c calls. +c bind: logical array of dimension at least nest. on exit with ier<=0 +c this array will indicate the knots where s''(x)=0, i.e. +c s''(t(j+3)) .eq. 0 if bind(j) = .true. +c s''(t(j+3)) .ne. 0 if bind(j) = .false., j=1,2,...,n-6 +c if the computation mode iopt=1 is used, the values of bind(1) +c ,...,bind(n-6) should be left unchanged between subsequent +c calls. +c wrk : real array of dimension at least (m*4+nest*8+maxbin*(maxbin+ +c nest+1)). used as working space. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program.lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (maxtr*4+2*(maxbin+1)) +c used as working space. +c kwrk : integer. on entry,kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. kwrk +c must not be too small (see iwrk). unchanged on exit. +c ier : integer. error flag +c ier=0 : normal return, s(x) satisfies the concavity/convexity +c constraints and sq <= s. +c ier<0 : abnormal termination: s(x) satisfies the concavity/ +c convexity constraints but sq > s. +c ier=-3 : the requested storage space exceeds the available +c storage space as specified by the parameter nest. +c probably causes: nest too small. if nest is already +c large (say nest > m/2), it may also indicate that s +c is too small. +c the approximation returned is the least-squares cubic +c spline according to the knots t(1),...,t(n) (n=nest) +c which satisfies the convexity constraints. +c ier=-2 : the maximal number of knots n=m+4 has been reached. +c probably causes: s too small. +c ier=-1 : the number of knots n is less than the maximal number +c m+4 but concon finds that adding one or more knots +c will not further reduce the value of sq. +c probably causes : s too small. +c ier>0 : abnormal termination: no approximation is returned +c ier=1 : the number of knots where s''(x)=0 exceeds maxbin. +c probably causes : maxbin too small. +c ier=2 : the number of records in the tree structure exceeds +c maxtr. +c probably causes : maxtr too small. +c ier=3 : the algoritm finds no solution to the posed quadratic +c programming problem. +c probably causes : rounding errors. +c ier=4 : the minimum number of knots (given by n) to guarantee +c that the concavity/convexity conditions will be +c satisfied is greater than nest. +c probably causes: nest too small. +c ier=5 : the minimum number of knots (given by n) to guarantee +c that the concavity/convexity conditions will be +c satisfied is greater than m+4. +c probably causes: strongly alternating convexity and +c concavity conditions. normally the situation can be +c coped with by adding n-m-4 extra data points (found +c by linear interpolation e.g.) with a small weight w(i) +c and a v(i) number equal to zero. +c ier=10 : on entry, the input data are controlled on validity. +c the following restrictions must be satisfied +c 0<=iopt<=1, m>3, nest>=8, s>=0, maxtr>=1, maxbin>=1, +c kwrk>=maxtr*4+2*(maxbin+1), w(i)>0, x(i) < x(i+1), +c lwrk>=m*4+nest*8+maxbin*(maxbin+nest+1) +c if one of these restrictions is found to be violated +c control is immediately repassed to the calling program +c +c further comments: +c as an example of the use of the computation mode iopt=1, the +c following program segment will cause concon to return control +c each time a spline with a new set of knots has been computed. +c ............. +c iopt = 0 +c s = 0.1e+60 (s very large) +c do 10 i=1,m +c call concon(iopt,m,x,y,w,v,s,nest,maxtr,maxbin,n,t,c,sq,sx, +c * bind,wrk,lwrk,iwrk,kwrk,ier) +c ...... +c s = sq +c iopt=1 +c 10 continue +c ............. +c +c other subroutines required: +c fpcoco,fpcosp,fpbspl,fpadno,fpdeno,fpseno,fpfrno +c +c references: +c dierckx p. : an algorithm for cubic spline fitting with convexity +c constraints, computing 24 (1980) 349-371. +c dierckx p. : an algorithm for least-squares cubic spline fitting +c with convexity and concavity constraints, report tw39, +c dept. computer science, k.u.leuven, 1978. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p. dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : march 1978 +c latest update : march 1987. +c +c .. +c ..scalar arguments.. + real*8 s,sq + integer iopt,m,nest,maxtr,maxbin,n,lwrk,kwrk,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),v(m),t(nest),c(nest),sx(m),wrk(lwrk) + integer iwrk(kwrk) + logical bind(nest) +c ..local scalars.. + integer i,lwest,kwest,ie,iw,lww + real*8 one +c .. +c set constant + one = 0.1e+01 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt.lt.0 .or. iopt.gt.1) go to 30 + if(m.lt.4 .or. nest.lt.8) go to 30 + if(s.lt.0.) go to 30 + if(maxtr.lt.1 .or. maxbin.lt.1) go to 30 + lwest = 8*nest+m*4+maxbin*(1+nest+maxbin) + kwest = 4*maxtr+2*(maxbin+1) + if(lwrk.lt.lwest .or. kwrk.lt.kwest) go to 30 + if(iopt.gt.0) go to 20 + if(w(1).le.0.) go to 30 + if(v(1).gt.0.) v(1) = one + if(v(1).lt.0.) v(1) = -one + do 10 i=2,m + if(x(i-1).ge.x(i) .or. w(i).le.0.) go to 30 + if(v(i).gt.0.) v(i) = one + if(v(i).lt.0.) v(i) = -one + 10 continue + 20 ier = 0 +c we partition the working space and determine the spline approximation + ie = 1 + iw = ie+nest + lww = lwrk-nest + call fpcoco(iopt,m,x,y,w,v,s,nest,maxtr,maxbin,n,t,c,sq,sx, + * bind,wrk(ie),wrk(iw),lww,iwrk,kwrk,ier) + 30 return + end Added: branches/Interpolate1D/fitpack/concur.f =================================================================== --- branches/Interpolate1D/fitpack/concur.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/concur.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,370 @@ + subroutine concur(iopt,idim,m,u,mx,x,xx,w,ib,db,nb,ie,de,ne,k,s, + * nest,n,t,nc,c,np,cp,fp,wrk,lwrk,iwrk,ier) +c given the ordered set of m points x(i) in the idim-dimensional space +c and given also a corresponding set of strictly increasing values u(i) +c and the set of positive numbers w(i),i=1,2,...,m, subroutine concur +c determines a smooth approximating spline curve s(u), i.e. +c x1 = s1(u) +c x2 = s2(u) ub = u(1) <= u <= u(m) = ue +c ......... +c xidim = sidim(u) +c with sj(u),j=1,2,...,idim spline functions of odd degree k with +c common knots t(j),j=1,2,...,n. +c in addition these splines will satisfy the following boundary +c constraints (l) +c if ib > 0 : sj (u(1)) = db(idim*l+j) ,l=0,1,...,ib-1 +c and (l) +c if ie > 0 : sj (u(m)) = de(idim*l+j) ,l=0,1,...,ie-1. +c if iopt=-1 concur calculates the weighted least-squares spline curve +c according to a given set of knots. +c if iopt>=0 the number of knots of the splines sj(u) and the position +c t(j),j=1,2,...,n is chosen automatically by the routine. the smooth- +c ness of s(u) is then achieved by minimalizing the discontinuity +c jumps of the k-th derivative of s(u) at the knots t(j),j=k+2,k+3,..., +c n-k-1. the amount of smoothness is determined by the condition that +c f(p)=sum((w(i)*dist(x(i),s(u(i))))**2) be <= s, with s a given non- +c negative constant, called the smoothing factor. +c the fit s(u) is given in the b-spline representation and can be +c evaluated by means of subroutine curev. +c +c calling sequence: +c call concur(iopt,idim,m,u,mx,x,xx,w,ib,db,nb,ie,de,ne,k,s,nest,n, +c * t,nc,c,np,cp,fp,wrk,lwrk,iwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares spline curve (iopt=-1) or a smoothing spline +c curve (iopt=0 or 1) must be determined.if iopt=0 the routine +c will start with an initial set of knots t(i)=ub,t(i+k+1)=ue, +c i=1,2,...,k+1. if iopt=1 the routine will continue with the +c knots found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c idim : integer. on entry idim must specify the dimension of the +c curve. 0 < idim < 11. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m > k-max(ib-1,0)-max(ie-1,0). unchanged on exit. +c u : real array of dimension at least (m). before entry, +c u(i) must be set to the i-th value of the parameter variable +c u for i=1,2,...,m. these values must be supplied in +c strictly ascending order and will be unchanged on exit. +c mx : integer. on entry mx must specify the actual dimension of +c the arrays x and xx as declared in the calling (sub)program +c mx must not be too small (see x). unchanged on exit. +c x : real array of dimension at least idim*m. +c before entry, x(idim*(i-1)+j) must contain the j-th coord- +c inate of the i-th data point for i=1,2,...,m and j=1,2,..., +c idim. unchanged on exit. +c xx : real array of dimension at least idim*m. +c used as working space. on exit xx contains the coordinates +c of the data points to which a spline curve with zero deriv- +c ative constraints has been determined. +c if the computation mode iopt =1 is used xx should be left +c unchanged between calls. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. unchanged on exit. +c see also further comments. +c ib : integer. on entry ib must specify the number of derivative +c constraints for the curve at the begin point. 0<=ib<=(k+1)/2 +c unchanged on exit. +c db : real array of dimension nb. before entry db(idim*l+j) must +c contain the l-th order derivative of sj(u) at u=u(1) for +c j=1,2,...,idim and l=0,1,...,ib-1 (if ib>0). +c unchanged on exit. +c nb : integer, specifying the dimension of db. nb>=max(1,idim*ib) +c unchanged on exit. +c ie : integer. on entry ie must specify the number of derivative +c constraints for the curve at the end point. 0<=ie<=(k+1)/2 +c unchanged on exit. +c de : real array of dimension ne. before entry de(idim*l+j) must +c contain the l-th order derivative of sj(u) at u=u(m) for +c j=1,2,...,idim and l=0,1,...,ie-1 (if ie>0). +c unchanged on exit. +c ne : integer, specifying the dimension of de. ne>=max(1,idim*ie) +c unchanged on exit. +c k : integer. on entry k must specify the degree of the splines. +c k=1,3 or 5. +c unchanged on exit. +c s : real.on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments. +c nest : integer. on entry nest must contain an over-estimate of the +c total number of knots of the splines returned, to indicate +c the storage space available to the routine. nest >=2*k+2. +c in most practical situation nest=m/2 will be sufficient. +c always large enough is nest=m+k+1+max(0,ib-1)+max(0,ie-1), +c the number of knots needed for interpolation (s=0). +c unchanged on exit. +c n : integer. +c unless ier = 10 (in case iopt >=0), n will contain the +c total number of knots of the smoothing spline curve returned +c if the computation mode iopt=1 is used this value of n +c should be left unchanged between subsequent calls. +c in case iopt=-1, the value of n must be specified on entry. +c t : real array of dimension at least (nest). +c on succesful exit, this array will contain the knots of the +c spline curve,i.e. the position of the interior knots t(k+2), +c t(k+3),..,t(n-k-1) as well as the position of the additional +c t(1)=t(2)=...=t(k+1)=ub and t(n-k)=...=t(n)=ue needed for +c the b-spline representation. +c if the computation mode iopt=1 is used, the values of t(1), +c t(2),...,t(n) should be left unchanged between subsequent +c calls. if the computation mode iopt=-1 is used, the values +c t(k+2),...,t(n-k-1) must be supplied by the user, before +c entry. see also the restrictions (ier=10). +c nc : integer. on entry nc must specify the actual dimension of +c the array c as declared in the calling (sub)program. nc +c must not be too small (see c). unchanged on exit. +c c : real array of dimension at least (nest*idim). +c on succesful exit, this array will contain the coefficients +c in the b-spline representation of the spline curve s(u),i.e. +c the b-spline coefficients of the spline sj(u) will be given +c in c(n*(j-1)+i),i=1,2,...,n-k-1 for j=1,2,...,idim. +c cp : real array of dimension at least 2*(k+1)*idim. +c on exit cp will contain the b-spline coefficients of a +c polynomial curve which satisfies the boundary constraints. +c if the computation mode iopt =1 is used cp should be left +c unchanged between calls. +c np : integer. on entry np must specify the actual dimension of +c the array cp as declared in the calling (sub)program. np +c must not be too small (see cp). unchanged on exit. +c fp : real. unless ier = 10, fp contains the weighted sum of +c squared residuals of the spline curve returned. +c wrk : real array of dimension at least m*(k+1)+nest*(6+idim+3*k). +c used as working space. if the computation mode iopt=1 is +c used, the values wrk(1),...,wrk(n) should be left unchanged +c between subsequent calls. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (nest). +c used as working space. if the computation mode iopt=1 is +c used,the values iwrk(1),...,iwrk(n) should be left unchanged +c between subsequent calls. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the curve returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the curve returned is an interpolating +c spline curve, satisfying the constraints (fp=0). +c ier=-2 : normal return. the curve returned is the weighted least- +c squares polynomial curve of degree k, satisfying the +c constraints. in this extreme case fp gives the upper +c bound fp0 for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameter nest. +c probably causes : nest too small. if nest is already +c large (say nest > m/2), it may also indicate that s is +c too small +c the approximation returned is the least-squares spline +c curve according to the knots t(1),t(2),...,t(n). (n=nest) +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline curve +c with fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing curve +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, k = 1,3 or 5, m>k-max(0,ib-1)-max(0,ie-1), +c nest>=2k+2, 0=(k+1)*m+nest*(6+idim+3*k), +c nc >=nest*idim ,u(1)0 i=1,2,...,m, +c mx>=idim*m,0<=ib<=(k+1)/2,0<=ie<=(k+1)/2,nb>=1,ne>=1, +c nb>=ib*idim,ne>=ib*idim,np>=2*(k+1)*idim, +c if iopt=-1:2*k+2<=n<=min(nest,mmax) with mmax = m+k+1+ +c max(0,ib-1)+max(0,ie-1) +c u(1)=0: s>=0 +c if s=0 : nest >=mmax (see above) +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the curve will be too smooth and signal will be +c lost ; if s is too small the curve will pick up too much noise. in +c the extreme cases the program will return an interpolating curve if +c s=0 and the least-squares polynomial curve of degree k if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c x(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in x(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c polynomial curve and the upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximating curve shows more detail) to obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if concur is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c curve underlying the data. but, if the computation mode iopt=1 is +c used, the knots returned may also depend on the s-values at previous +c calls (if these were smaller). therefore, if after a number of +c trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c concur once more with the selected value for s but now with iopt=0. +c indeed, concur may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c +c the form of the approximating curve can strongly be affected by +c the choice of the parameter values u(i). if there is no physical +c reason for choosing a particular parameter u, often good results +c will be obtained with the choice +c v(1)=0, v(i)=v(i-1)+q(i), i=2,...,m, u(i)=v(i)/v(m), i=1,..,m +c where +c q(i)= sqrt(sum j=1,idim (xj(i)-xj(i-1))**2 ) +c other possibilities for q(i) are +c q(i)= sum j=1,idim (xj(i)-xj(i-1))**2 +c q(i)= sum j=1,idim abs(xj(i)-xj(i-1)) +c q(i)= max j=1,idim abs(xj(i)-xj(i-1)) +c q(i)= 1 +c +c other subroutines required: +c fpback,fpbspl,fpched,fpcons,fpdisc,fpgivs,fpknot,fprati,fprota +c curev,fppocu,fpadpo,fpinst +c +c references: +c dierckx p. : algorithms for smoothing data with periodic and +c parametric splines, computer graphics and image +c processing 20 (1982) 171-184. +c dierckx p. : algorithms for smoothing data with periodic and param- +c etric splines, report tw55, dept. computer science, +c k.u.leuven, 1981. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + real*8 s,fp + integer iopt,idim,m,mx,ib,nb,ie,ne,k,nest,n,nc,np,lwrk,ier +c ..array arguments.. + real*8 u(m),x(mx),xx(mx),db(nb),de(ne),w(m),t(nest),c(nc),wrk(lwrk + *) + real*8 cp(np) + integer iwrk(nest) +c ..local scalars.. + real*8 tol,dist + integer i,ib1,ie1,ja,jb,jfp,jg,jq,jz,j,k1,k2,lwest,maxit,nmin, + * ncc,kk,mmin,nmax,mxx +c ..function references + integer max0 +c .. +c we set up the parameters tol and maxit + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 90 + if(idim.le.0 .or. idim.gt.10) go to 90 + if(k.le.0 .or. k.gt.5) go to 90 + k1 = k+1 + kk = k1/2 + if(kk*2.ne.k1) go to 90 + k2 = k1+1 + if(ib.lt.0 .or. ib.gt.kk) go to 90 + if(ie.lt.0 .or. ie.gt.kk) go to 90 + nmin = 2*k1 + ib1 = max0(0,ib-1) + ie1 = max0(0,ie-1) + mmin = k1-ib1-ie1 + if(m.lt.mmin .or. nest.lt.nmin) go to 90 + if(nb.lt.(idim*ib) .or. ne.lt.(idim*ie)) go to 90 + if(np.lt.(2*k1*idim)) go to 90 + mxx = m*idim + ncc = nest*idim + if(mx.lt.mxx .or. nc.lt.ncc) go to 90 + lwest = m*k1+nest*(6+idim+3*k) + if(lwrk.lt.lwest) go to 90 + if(w(1).le.0.) go to 90 + do 10 i=2,m + if(u(i-1).ge.u(i) .or. w(i).le.0.) go to 90 + 10 continue + if(iopt.ge.0) go to 30 + if(n.lt.nmin .or. n.gt.nest) go to 90 + j = n + do 20 i=1,k1 + t(i) = u(1) + t(j) = u(m) + j = j-1 + 20 continue + call fpched(u,m,t,n,k,ib,ie,ier) + if (ier.eq.0) go to 40 + go to 90 + 30 if(s.lt.0.) go to 90 + nmax = m+k1+ib1+ie1 + if(s.eq.0. .and. nest.lt.nmax) go to 90 + ier = 0 + if(iopt.gt.0) go to 70 +c we determine a polynomial curve satisfying the boundary constraints. + 40 call fppocu(idim,k,u(1),u(m),ib,db,nb,ie,de,ne,cp,np) +c we generate new data points which will be approximated by a spline +c with zero derivative constraints. + j = nmin + do 50 i=1,k1 + wrk(i) = u(1) + wrk(j) = u(m) + j = j-1 + 50 continue +c evaluate the polynomial curve + call curev(idim,wrk,nmin,cp,np,k,u,m,xx,mxx,ier) +c substract from the old data, the values of the polynomial curve + do 60 i=1,mxx + xx(i) = x(i)-xx(i) + 60 continue +c we partition the working space and determine the spline curve. + 70 jfp = 1 + jz = jfp+nest + ja = jz+ncc + jb = ja+nest*k1 + jg = jb+nest*k2 + jq = jg+nest*k2 + call fpcons(iopt,idim,m,u,mxx,xx,w,ib,ie,k,s,nest,tol,maxit,k1, + * k2,n,t,ncc,c,fp,wrk(jfp),wrk(jz),wrk(ja),wrk(jb),wrk(jg),wrk(jq), + * + * iwrk,ier) +c add the polynomial curve to the calculated spline. + call fpadpo(idim,t,n,c,ncc,k,cp,np,wrk(jz),wrk(ja),wrk(jb)) + 90 return + end Added: branches/Interpolate1D/fitpack/cualde.f =================================================================== --- branches/Interpolate1D/fitpack/cualde.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/cualde.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,91 @@ + subroutine cualde(idim,t,n,c,nc,k1,u,d,nd,ier) +c subroutine cualde evaluates at the point u all the derivatives +c (l) +c d(idim*l+j) = sj (u) ,l=0,1,...,k, j=1,2,...,idim +c of a spline curve s(u) of order k1 (degree k=k1-1) and dimension idim +c given in its b-spline representation. +c +c calling sequence: +c call cualde(idim,t,n,c,nc,k1,u,d,nd,ier) +c +c input parameters: +c idim : integer, giving the dimension of the spline curve. +c t : array,length n, which contains the position of the knots. +c n : integer, giving the total number of knots of s(u). +c c : array,length nc, which contains the b-spline coefficients. +c nc : integer, giving the total number of coefficients of s(u). +c k1 : integer, giving the order of s(u) (order=degree+1). +c u : real, which contains the point where the derivatives must +c be evaluated. +c nd : integer, giving the dimension of the array d. nd >= k1*idim +c +c output parameters: +c d : array,length nd,giving the different curve derivatives. +c d(idim*l+j) will contain the j-th coordinate of the l-th +c derivative of the curve at the point u. +c ier : error flag +c ier = 0 : normal return +c ier =10 : invalid input data (see restrictions) +c +c restrictions: +c nd >= k1*idim +c t(k1) <= u <= t(n-k1+1) +c +c further comments: +c if u coincides with a knot, right derivatives are computed +c ( left derivatives if u = t(n-k1+1) ). +c +c other subroutines required: fpader. +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer idim,n,nc,k1,nd,ier + real*8 u +c ..array arguments.. + real*8 t(n),c(nc),d(nd) +c ..local scalars.. + integer i,j,kk,l,m,nk1 +c ..local array.. + real*8 h(6) +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + if(nd.lt.(k1*idim)) go to 500 + nk1 = n-k1 + if(u.lt.t(k1) .or. u.gt.t(nk1+1)) go to 500 +c search for knot interval t(l) <= u < t(l+1) + l = k1 + 100 if(u.lt.t(l+1) .or. l.eq.nk1) go to 200 + l = l+1 + go to 100 + 200 if(t(l).ge.t(l+1)) go to 500 + ier = 0 +c calculate the derivatives. + j = 1 + do 400 i=1,idim + call fpader(t,n,c(j),k1,u,l,h) + m = i + do 300 kk=1,k1 + d(m) = h(kk) + m = m+idim + 300 continue + j = j+n + 400 continue + 500 return + end Added: branches/Interpolate1D/fitpack/curev.f =================================================================== --- branches/Interpolate1D/fitpack/curev.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/curev.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,110 @@ + subroutine curev(idim,t,n,c,nc,k,u,m,x,mx,ier) +c subroutine curev evaluates in a number of points u(i),i=1,2,...,m +c a spline curve s(u) of degree k and dimension idim, given in its +c b-spline representation. +c +c calling sequence: +c call curev(idim,t,n,c,nc,k,u,m,x,mx,ier) +c +c input parameters: +c idim : integer, giving the dimension of the spline curve. +c t : array,length n, which contains the position of the knots. +c n : integer, giving the total number of knots of s(u). +c c : array,length nc, which contains the b-spline coefficients. +c nc : integer, giving the total number of coefficients of s(u). +c k : integer, giving the degree of s(u). +c u : array,length m, which contains the points where s(u) must +c be evaluated. +c m : integer, giving the number of points where s(u) must be +c evaluated. +c mx : integer, giving the dimension of the array x. mx >= m*idim +c +c output parameters: +c x : array,length mx,giving the value of s(u) at the different +c points. x(idim*(i-1)+j) will contain the j-th coordinate +c of the i-th point on the curve. +c ier : error flag +c ier = 0 : normal return +c ier =10 : invalid input data (see restrictions) +c +c restrictions: +c m >= 1 +c mx >= m*idim +c t(k+1) <= u(i) <= u(i+1) <= t(n-k) , i=1,2,...,m-1. +c +c other subroutines required: fpbspl. +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer idim,n,nc,k,m,mx,ier +c ..array arguments.. + real*8 t(n),c(nc),u(m),x(mx) +c ..local scalars.. + integer i,j,jj,j1,k1,l,ll,l1,mm,nk1 + real*8 arg,sp,tb,te +c ..local array.. + real*8 h(6) +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + if (m.lt.1) go to 100 + if (m.eq.1) go to 30 + go to 10 + 10 do 20 i=2,m + if(u(i).lt.u(i-1)) go to 100 + 20 continue + 30 if(mx.lt.(m*idim)) go to 100 + ier = 0 +c fetch tb and te, the boundaries of the approximation interval. + k1 = k+1 + nk1 = n-k1 + tb = t(k1) + te = t(nk1+1) + l = k1 + l1 = l+1 +c main loop for the different points. + mm = 0 + do 80 i=1,m +c fetch a new u-value arg. + arg = u(i) + if(arg.lt.tb) arg = tb + if(arg.gt.te) arg = te +c search for knot interval t(l) <= arg < t(l+1) + 40 if(arg.lt.t(l1) .or. l.eq.nk1) go to 50 + l = l1 + l1 = l+1 + go to 40 +c evaluate the non-zero b-splines at arg. + 50 call fpbspl(t,n,k,arg,l,h) +c find the value of s(u) at u=arg. + ll = l-k1 + do 70 j1=1,idim + jj = ll + sp = 0. + do 60 j=1,k1 + jj = jj+1 + sp = sp+c(jj)*h(j) + 60 continue + mm = mm+1 + x(mm) = sp + ll = ll+n + 70 continue + 80 continue + 100 return + end Added: branches/Interpolate1D/fitpack/curfit.f =================================================================== --- branches/Interpolate1D/fitpack/curfit.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/curfit.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,261 @@ + subroutine curfit(iopt,m,x,y,w,xb,xe,k,s,nest,n,t,c,fp, + * wrk,lwrk,iwrk,ier) +c given the set of data points (x(i),y(i)) and the set of positive +c numbers w(i),i=1,2,...,m,subroutine curfit determines a smooth spline +c approximation of degree k on the interval xb <= x <= xe. +c if iopt=-1 curfit calculates the weighted least-squares spline +c according to a given set of knots. +c if iopt>=0 the number of knots of the spline s(x) and the position +c t(j),j=1,2,...,n is chosen automatically by the routine. the smooth- +c ness of s(x) is then achieved by minimalizing the discontinuity +c jumps of the k-th derivative of s(x) at the knots t(j),j=k+2,k+3,..., +c n-k-1. the amount of smoothness is determined by the condition that +c f(p)=sum((w(i)*(y(i)-s(x(i))))**2) be <= s, with s a given non- +c negative constant, called the smoothing factor. +c the fit s(x) is given in the b-spline representation (b-spline coef- +c ficients c(j),j=1,2,...,n-k-1) and can be evaluated by means of +c subroutine splev. +c +c calling sequence: +c call curfit(iopt,m,x,y,w,xb,xe,k,s,nest,n,t,c,fp,wrk, +c * lwrk,iwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares spline (iopt=-1) or a smoothing spline (iopt= +c 0 or 1) must be determined. if iopt=0 the routine will start +c with an initial set of knots t(i)=xb, t(i+k+1)=xe, i=1,2,... +c k+1. if iopt=1 the routine will continue with the knots +c found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m > k. unchanged on exit. +c x : real array of dimension at least (m). before entry, x(i) +c must be set to the i-th value of the independent variable x, +c for i=1,2,...,m. these values must be supplied in strictly +c ascending order. unchanged on exit. +c y : real array of dimension at least (m). before entry, y(i) +c must be set to the i-th value of the dependent variable y, +c for i=1,2,...,m. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. unchanged on exit. +c see also further comments. +c xb,xe : real values. on entry xb and xe must specify the boundaries +c of the approximation interval. xb<=x(1), xe>=x(m). +c unchanged on exit. +c k : integer. on entry k must specify the degree of the spline. +c 1<=k<=5. it is recommended to use cubic splines (k=3). +c the user is strongly dissuaded from choosing k even,together +c with a small s-value. unchanged on exit. +c s : real.on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments. +c nest : integer. on entry nest must contain an over-estimate of the +c total number of knots of the spline returned, to indicate +c the storage space available to the routine. nest >=2*k+2. +c in most practical situation nest=m/2 will be sufficient. +c always large enough is nest=m+k+1, the number of knots +c needed for interpolation (s=0). unchanged on exit. +c n : integer. +c unless ier =10 (in case iopt >=0), n will contain the +c total number of knots of the spline approximation returned. +c if the computation mode iopt=1 is used this value of n +c should be left unchanged between subsequent calls. +c in case iopt=-1, the value of n must be specified on entry. +c t : real array of dimension at least (nest). +c on succesful exit, this array will contain the knots of the +c spline,i.e. the position of the interior knots t(k+2),t(k+3) +c ...,t(n-k-1) as well as the position of the additional knots +c t(1)=t(2)=...=t(k+1)=xb and t(n-k)=...=t(n)=xe needed for +c the b-spline representation. +c if the computation mode iopt=1 is used, the values of t(1), +c t(2),...,t(n) should be left unchanged between subsequent +c calls. if the computation mode iopt=-1 is used, the values +c t(k+2),...,t(n-k-1) must be supplied by the user, before +c entry. see also the restrictions (ier=10). +c c : real array of dimension at least (nest). +c on succesful exit, this array will contain the coefficients +c c(1),c(2),..,c(n-k-1) in the b-spline representation of s(x) +c fp : real. unless ier=10, fp contains the weighted sum of +c squared residuals of the spline approximation returned. +c wrk : real array of dimension at least (m*(k+1)+nest*(7+3*k)). +c used as working space. if the computation mode iopt=1 is +c used, the values wrk(1),...,wrk(n) should be left unchanged +c between subsequent calls. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program.lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (nest). +c used as working space. if the computation mode iopt=1 is +c used,the values iwrk(1),...,iwrk(n) should be left unchanged +c between subsequent calls. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c spline (fp=0). +c ier=-2 : normal return. the spline returned is the weighted least- +c squares polynomial of degree k. in this extreme case fp +c gives the upper bound fp0 for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameter nest. +c probably causes : nest too small. if nest is already +c large (say nest > m/2), it may also indicate that s is +c too small +c the approximation returned is the weighted least-squares +c spline according to the knots t(1),t(2),...,t(n). (n=nest) +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 1<=k<=5, m>k, nest>2*k+2, w(i)>0,i=1,2,...,m +c xb<=x(1)=(k+1)*m+nest*(7+3*k) +c if iopt=-1: 2*k+2<=n<=min(nest,m+k+1) +c xb=0: s>=0 +c if s=0 : nest >= m+k+1 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the weighted least-squares polynomial of degree k if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c y(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in y(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c polynomial and the corresponding upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximation shows more detail) to obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if curfit is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. but, if the computation mode iopt=1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c curfit once more with the selected value for s but now with iopt=0. +c indeed, curfit may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c +c other subroutines required: +c fpback,fpbspl,fpchec,fpcurf,fpdisc,fpgivs,fpknot,fprati,fprota +c +c references: +c dierckx p. : an algorithm for smoothing, differentiation and integ- +c ration of experimental data using spline functions, +c j.comp.appl.maths 1 (1975) 165-184. +c dierckx p. : a fast algorithm for smoothing data on a rectangular +c grid while using spline functions, siam j.numer.anal. +c 19 (1982) 1286-1304. +c dierckx p. : an improved algorithm for curve fitting with spline +c functions, report tw54, dept. computer science,k.u. +c leuven, 1981. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + real*8 xb,xe,s,fp + integer iopt,m,k,nest,n,lwrk,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),t(nest),c(nest),wrk(lwrk) + integer iwrk(nest) +c ..local scalars.. + real*8 tol + integer i,ia,ib,ifp,ig,iq,iz,j,k1,k2,lwest,maxit,nmin +c .. +c we set up the parameters tol and maxit + maxit = 20 + tol = 0.1d-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(k.le.0 .or. k.gt.5) go to 50 + k1 = k+1 + k2 = k1+1 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 50 + nmin = 2*k1 + if(m.lt.k1 .or. nest.lt.nmin) go to 50 + lwest = m*k1+nest*(7+3*k) + if(lwrk.lt.lwest) go to 50 + if(xb.gt.x(1) .or. xe.lt.x(m) .or. w(1).le.0.) go to 50 + do 10 i=2,m + if(x(i-1).ge.x(i) .or. w(i).le.0.) go to 50 + 10 continue + if(iopt.ge.0) go to 30 + if(n.lt.nmin .or. n.gt.nest) go to 50 + j = n + do 20 i=1,k1 + t(i) = xb + t(j) = xe + j = j-1 + 20 continue + call fpchec(x,m,t,n,k,ier) + if (ier.eq.0) go to 40 + go to 50 + 30 if(s.lt.0.) go to 50 + if(s.eq.0. .and. nest.lt.(m+k1)) go to 50 + ier = 0 +c we partition the working space and determine the spline approximation. + 40 ifp = 1 + iz = ifp+nest + ia = iz+nest + ib = ia+nest*k1 + ig = ib+nest*k2 + iq = ig+nest*k2 + call fpcurf(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp, + * wrk(ifp),wrk(iz),wrk(ia),wrk(ib),wrk(ig),wrk(iq),iwrk,ier) + 50 return + end Added: branches/Interpolate1D/fitpack/dblint.f =================================================================== --- branches/Interpolate1D/fitpack/dblint.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/dblint.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,88 @@ + real*8 function dblint(tx,nx,ty,ny,c,kx,ky,xb,xe,yb,ye,wrk) +c function dblint calculates the double integral +c / xe / ye +c | | s(x,y) dx dy +c xb / yb / +c with s(x,y) a bivariate spline of degrees kx and ky, given in the +c b-spline representation. +c +c calling sequence: +c aint = dblint(tx,nx,ty,ny,c,kx,ky,xb,xe,yb,ye,wrk) +c +c input parameters: +c tx : real array, length nx, which contains the position of the +c knots in the x-direction. +c nx : integer, giving the total number of knots in the x-direction +c ty : real array, length ny, which contains the position of the +c knots in the y-direction. +c ny : integer, giving the total number of knots in the y-direction +c c : real array, length (nx-kx-1)*(ny-ky-1), which contains the +c b-spline coefficients. +c kx,ky : integer values, giving the degrees of the spline. +c xb,xe : real values, containing the boundaries of the integration +c yb,ye domain. s(x,y) is considered to be identically zero out- +c side the rectangle (tx(kx+1),tx(nx-kx))*(ty(ky+1),ty(ny-ky)) +c +c output parameters: +c aint : real , containing the double integral of s(x,y). +c wrk : real array of dimension at least (nx+ny-kx-ky-2). +c used as working space. +c on exit, wrk(i) will contain the integral +c / xe +c | ni,kx+1(x) dx , i=1,2,...,nx-kx-1 +c xb / +c with ni,kx+1(x) the normalized b-spline defined on +c the knots tx(i),...,tx(i+kx+1) +c wrk(j+nx-kx-1) will contain the integral +c / ye +c | nj,ky+1(y) dy , j=1,2,...,ny-ky-1 +c yb / +c with nj,ky+1(y) the normalized b-spline defined on +c the knots ty(j),...,ty(j+ky+1) +c +c other subroutines required: fpintb +c +c references : +c gaffney p.w. : the calculation of indefinite integrals of b-splines +c j. inst. maths applics 17 (1976) 37-41. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1989 +c +c ..scalar arguments.. + integer nx,ny,kx,ky + real*8 xb,xe,yb,ye +c ..array arguments.. + real*8 tx(nx),ty(ny),c((nx-kx-1)*(ny-ky-1)),wrk(nx+ny-kx-ky-2) +c ..local scalars.. + integer i,j,l,m,nkx1,nky1 + real*8 res +c .. + nkx1 = nx-kx-1 + nky1 = ny-ky-1 +c we calculate the integrals of the normalized b-splines ni,kx+1(x) + call fpintb(tx,nx,wrk,nkx1,xb,xe) +c we calculate the integrals of the normalized b-splines nj,ky+1(y) + call fpintb(ty,ny,wrk(nkx1+1),nky1,yb,ye) +c calculate the integral of s(x,y) + dblint = 0. + do 200 i=1,nkx1 + res = wrk(i) + if(res.eq.0.) go to 200 + m = (i-1)*nky1 + l = nkx1 + do 100 j=1,nky1 + m = m+1 + l = l+1 + dblint = dblint+res*wrk(l)*c(m) + 100 continue + 200 continue + return + end Added: branches/Interpolate1D/fitpack/evapol.f =================================================================== --- branches/Interpolate1D/fitpack/evapol.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/evapol.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,82 @@ + real*8 function evapol(tu,nu,tv,nv,c,rad,x,y) +c function program evacir evaluates the function f(x,y) = s(u,v), +c defined through the transformation +c x = u*rad(v)*cos(v) y = u*rad(v)*sin(v) +c and where s(u,v) is a bicubic spline ( 0<=u<=1 , -pi<=v<=pi ), given +c in its standard b-spline representation. +c +c calling sequence: +c f = evapol(tu,nu,tv,nv,c,rad,x,y) +c +c input parameters: +c tu : real array, length nu, which contains the position of the +c knots in the u-direction. +c nu : integer, giving the total number of knots in the u-direction +c tv : real array, length nv, which contains the position of the +c knots in the v-direction. +c nv : integer, giving the total number of knots in the v-direction +c c : real array, length (nu-4)*(nv-4), which contains the +c b-spline coefficients. +c rad : real function subprogram, defining the boundary of the +c approximation domain. must be declared external in the +c calling (sub)-program +c x,y : real values. +c before entry x and y must be set to the co-ordinates of +c the point where f(x,y) must be evaluated. +c +c output parameter: +c f : real +c on exit f contains the value of f(x,y) +c +c other subroutines required: +c bispev,fpbisp,fpbspl +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1989 +c +c ..scalar arguments.. + integer nu,nv + real*8 x,y +c ..array arguments.. + real*8 tu(nu),tv(nv),c((nu-4)*(nv-4)) +c ..user specified function + real*8 rad +c ..local scalars.. + integer ier + real*8 u,v,r,f,one,dist +c ..local arrays + real*8 wrk(8) + integer iwrk(2) +c ..function references + real*8 atan2,sqrt +c .. +c calculate the (u,v)-coordinates of the given point. + one = 1 + u = 0. + v = 0. + dist = x**2+y**2 + if(dist.le.0.) go to 10 + v = atan2(y,x) + r = rad(v) + if(r.le.0.) go to 10 + u = sqrt(dist)/r + if(u.gt.one) u = one +c evaluate s(u,v) + 10 call bispev(tu,nu,tv,nv,c,3,3,u,1,v,1,f,wrk,8,iwrk,2,ier) + evapol = f + return + end + Added: branches/Interpolate1D/fitpack/fourco.f =================================================================== --- branches/Interpolate1D/fitpack/fourco.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fourco.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,96 @@ + subroutine fourco(t,n,c,alfa,m,ress,resc,wrk1,wrk2,ier) +c subroutine fourco calculates the integrals +c /t(n-3) +c ress(i) = ! s(x)*sin(alfa(i)*x) dx and +c t(4)/ +c /t(n-3) +c resc(i) = ! s(x)*cos(alfa(i)*x) dx, i=1,...,m, +c t(4)/ +c where s(x) denotes a cubic spline which is given in its +c b-spline representation. +c +c calling sequence: +c call fourco(t,n,c,alfa,m,ress,resc,wrk1,wrk2,ier) +c +c input parameters: +c t : real array,length n, containing the knots of s(x). +c n : integer, containing the total number of knots. n>=10. +c c : real array,length n, containing the b-spline coefficients. +c alfa : real array,length m, containing the parameters alfa(i). +c m : integer, specifying the number of integrals to be computed. +c wrk1 : real array,length n. used as working space +c wrk2 : real array,length n. used as working space +c +c output parameters: +c ress : real array,length m, containing the integrals ress(i). +c resc : real array,length m, containing the integrals resc(i). +c ier : error flag: +c ier=0 : normal return. +c ier=10: invalid input data (see restrictions). +c +c restrictions: +c n >= 10 +c t(4) < t(5) < ... < t(n-4) < t(n-3). +c t(1) <= t(2) <= t(3) <= t(4). +c t(n-3) <= t(n-2) <= t(n-1) <= t(n). +c +c other subroutines required: fpbfou,fpcsin +c +c references : +c dierckx p. : calculation of fouriercoefficients of discrete +c functions using cubic splines. j. computational +c and applied mathematics 3 (1977) 207-209. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer n,m,ier +c ..array arguments.. + real*8 t(n),c(n),wrk1(n),wrk2(n),alfa(m),ress(m),resc(m) +c ..local scalars.. + integer i,j,n4 + real*8 rs,rc +c .. + n4 = n-4 +c before starting computations a data check is made. in the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(n.lt.10) go to 50 + j = n + do 10 i=1,3 + if(t(i).gt.t(i+1)) go to 50 + if(t(j).lt.t(j-1)) go to 50 + j = j-1 + 10 continue + do 20 i=4,n4 + if(t(i).ge.t(i+1)) go to 50 + 20 continue + ier = 0 +c main loop for the different alfa(i). + do 40 i=1,m +c calculate the integrals +c wrk1(j) = integral(nj,4(x)*sin(alfa*x)) and +c wrk2(j) = integral(nj,4(x)*cos(alfa*x)), j=1,2,...,n-4, +c where nj,4(x) denotes the normalised cubic b-spline defined on the +c knots t(j),t(j+1),...,t(j+4). + call fpbfou(t,n,alfa(i),wrk1,wrk2) +c calculate the integrals ress(i) and resc(i). + rs = 0. + rc = 0. + do 30 j=1,n4 + rs = rs+c(j)*wrk1(j) + rc = rc+c(j)*wrk2(j) + 30 continue + ress(i) = rs + resc(i) = rc + 40 continue + 50 return + end Added: branches/Interpolate1D/fitpack/fpader.f =================================================================== --- branches/Interpolate1D/fitpack/fpader.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpader.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,57 @@ + subroutine fpader(t,n,c,k1,x,l,d) +c subroutine fpader calculates the derivatives +c (j-1) +c d(j) = s (x) , j=1,2,...,k1 +c of a spline of order k1 at the point t(l)<=x= 10, t(4) < t(5) < ... < t(n-4) < t(n-3). +c .. +c ..scalar arguments.. + integer n + real*8 par +c ..array arguments.. + real*8 t(n),ress(n),resc(n) +c ..local scalars.. + integer i,ic,ipj,is,j,jj,jp1,jp4,k,li,lj,ll,nmj,nm3,nm7 + real*8 ak,beta,con1,con2,c1,c2,delta,eps,fac,f1,f2,f3,one,quart, + * sign,six,s1,s2,term +c ..local arrays.. + real*8 co(5),si(5),hs(5),hc(5),rs(3),rc(3) +c ..function references.. + real*8 cos,sin,abs +c .. +c initialization. + one = 0.1e+01 + six = 0.6e+01 + eps = 0.1e-07 + quart = 0.25e0 + con1 = 0.5e-01 + con2 = 0.12e+03 + nm3 = n-3 + nm7 = n-7 + if(par.ne.0.) term = six/par + beta = par*t(4) + co(1) = cos(beta) + si(1) = sin(beta) +c calculate the integrals ress(j) and resc(j), j=1,2,3 by setting up +c a divided difference table. + do 30 j=1,3 + jp1 = j+1 + jp4 = j+4 + beta = par*t(jp4) + co(jp1) = cos(beta) + si(jp1) = sin(beta) + call fpcsin(t(4),t(jp4),par,si(1),co(1),si(jp1),co(jp1), + * rs(j),rc(j)) + i = 5-j + hs(i) = 0. + hc(i) = 0. + do 10 jj=1,j + ipj = i+jj + hs(ipj) = rs(jj) + hc(ipj) = rc(jj) + 10 continue + do 20 jj=1,3 + if(i.lt.jj) i = jj + k = 5 + li = jp4 + do 20 ll=i,4 + lj = li-jj + fac = t(li)-t(lj) + hs(k) = (hs(k)-hs(k-1))/fac + hc(k) = (hc(k)-hc(k-1))/fac + k = k-1 + li = li-1 + 20 continue + ress(j) = hs(5)-hs(4) + resc(j) = hc(5)-hc(4) + 30 continue + if(nm7.lt.4) go to 160 +c calculate the integrals ress(j) and resc(j),j=4,5,...,n-7. + do 150 j=4,nm7 + jp4 = j+4 + beta = par*t(jp4) + co(5) = cos(beta) + si(5) = sin(beta) + delta = t(jp4)-t(j) +c the way of computing ress(j) and resc(j) depends on the value of +c beta = par*(t(j+4)-t(j)). + beta = delta*par + if(abs(beta).le.one) go to 60 +c if !beta! > 1 the integrals are calculated by setting up a divided +c difference table. + do 40 k=1,5 + hs(k) = si(k) + hc(k) = co(k) + 40 continue + do 50 jj=1,3 + k = 5 + li = jp4 + do 50 ll=jj,4 + lj = li-jj + fac = par*(t(li)-t(lj)) + hs(k) = (hs(k)-hs(k-1))/fac + hc(k) = (hc(k)-hc(k-1))/fac + k = k-1 + li = li-1 + 50 continue + s2 = (hs(5)-hs(4))*term + c2 = (hc(5)-hc(4))*term + go to 130 +c if !beta! <= 1 the integrals are calculated by evaluating a series +c expansion. + 60 f3 = 0. + do 70 i=1,4 + ipj = i+j + hs(i) = par*(t(ipj)-t(j)) + hc(i) = hs(i) + f3 = f3+hs(i) + 70 continue + f3 = f3*con1 + c1 = quart + s1 = f3 + if(abs(f3).le.eps) go to 120 + sign = one + fac = con2 + k = 5 + is = 0 + do 110 ic=1,20 + k = k+1 + ak = k + fac = fac*ak + f1 = 0. + f3 = 0. + do 80 i=1,4 + f1 = f1+hc(i) + f2 = f1*hs(i) + hc(i) = f2 + f3 = f3+f2 + 80 continue + f3 = f3*six/fac + if(is.eq.0) go to 90 + is = 0 + s1 = s1+f3*sign + go to 100 + 90 sign = -sign + is = 1 + c1 = c1+f3*sign + 100 if(abs(f3).le.eps) go to 120 + 110 continue + 120 s2 = delta*(co(1)*s1+si(1)*c1) + c2 = delta*(co(1)*c1-si(1)*s1) + 130 ress(j) = s2 + resc(j) = c2 + do 140 i=1,4 + co(i) = co(i+1) + si(i) = si(i+1) + 140 continue + 150 continue +c calculate the integrals ress(j) and resc(j),j=n-6,n-5,n-4 by setting +c up a divided difference table. + 160 do 190 j=1,3 + nmj = nm3-j + i = 5-j + call fpcsin(t(nm3),t(nmj),par,si(4),co(4),si(i-1),co(i-1), + * rs(j),rc(j)) + hs(i) = 0. + hc(i) = 0. + do 170 jj=1,j + ipj = i+jj + hc(ipj) = rc(jj) + hs(ipj) = rs(jj) + 170 continue + do 180 jj=1,3 + if(i.lt.jj) i = jj + k = 5 + li = nmj + do 180 ll=i,4 + lj = li+jj + fac = t(lj)-t(li) + hs(k) = (hs(k-1)-hs(k))/fac + hc(k) = (hc(k-1)-hc(k))/fac + k = k-1 + li = li+1 + 180 continue + ress(nmj) = hs(4)-hs(5) + resc(nmj) = hc(4)-hc(5) + 190 continue + return + end Added: branches/Interpolate1D/fitpack/fpbisp.f =================================================================== --- branches/Interpolate1D/fitpack/fpbisp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpbisp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,79 @@ + subroutine fpbisp(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wx,wy,lx,ly) +c ..scalar arguments.. + integer nx,ny,kx,ky,mx,my +c ..array arguments.. + integer lx(mx),ly(my) + real*8 tx(nx),ty(ny),c((nx-kx-1)*(ny-ky-1)),x(mx),y(my),z(mx*my), + * wx(mx,kx+1),wy(my,ky+1) +c ..local scalars.. + integer kx1,ky1,l,l1,l2,m,nkx1,nky1 + real*8 arg,sp,tb,te +c ..local arrays.. + real*8 h(6) +c ..subroutine references.. +c fpbspl +c .. + kx1 = kx+1 + nkx1 = nx-kx1 + tb = tx(kx1) + te = tx(nkx1+1) + l = kx1 + l1 = l+1 + do 40 i=1,mx + arg = x(i) + if(arg.lt.tb) arg = tb + if(arg.gt.te) arg = te + 10 if(arg.lt.tx(l1) .or. l.eq.nkx1) go to 20 + l = l1 + l1 = l+1 + go to 10 + 20 call fpbspl(tx,nx,kx,arg,l,h) + lx(i) = l-kx1 + do 30 j=1,kx1 + wx(i,j) = h(j) + 30 continue + 40 continue + ky1 = ky+1 + nky1 = ny-ky1 + tb = ty(ky1) + te = ty(nky1+1) + l = ky1 + l1 = l+1 + do 80 i=1,my + arg = y(i) + if(arg.lt.tb) arg = tb + if(arg.gt.te) arg = te + 50 if(arg.lt.ty(l1) .or. l.eq.nky1) go to 60 + l = l1 + l1 = l+1 + go to 50 + 60 call fpbspl(ty,ny,ky,arg,l,h) + ly(i) = l-ky1 + do 70 j=1,ky1 + wy(i,j) = h(j) + 70 continue + 80 continue + m = 0 + do 130 i=1,mx + l = lx(i)*nky1 + do 90 i1=1,kx1 + h(i1) = wx(i,i1) + 90 continue + do 120 j=1,my + l1 = l+ly(j) + sp = 0. + do 110 i1=1,kx1 + l2 = l1 + do 100 j1=1,ky1 + l2 = l2+1 + sp = sp+c(l2)*h(i1)*wy(j,j1) + 100 continue + l1 = l1+nky1 + 110 continue + m = m+1 + z(m) = sp + 120 continue + 130 continue + return + end + Added: branches/Interpolate1D/fitpack/fpbspl.f =================================================================== --- branches/Interpolate1D/fitpack/fpbspl.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpbspl.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,42 @@ + subroutine fpbspl(t,n,k,x,l,h) +c subroutine fpbspl evaluates the (k+1) non-zero b-splines of +c degree k at t(l) <= x < t(l+1) using the stable recurrence +c relation of de boor and cox. +c Travis Oliphant 2007 +c changed so that weighting of 0 is used when knots with +c multiplicity are present. +c Also, notice that l+k <= n and 1 <= l+1-k +c or else the routine will be accessing memory outside t +c Thus it is imperative that that k <= l <= n-k but this +c is not checked. +c .. +c ..scalar arguments.. + real*8 x + integer n,k,l +c ..array arguments.. + real*8 t(n),h(20) +c ..local scalars.. + real*8 f,one + integer i,j,li,lj +c ..local arrays.. + real*8 hh(19) +c .. + one = 0.1d+01 + h(1) = one + do 20 j=1,k + do 10 i=1,j + hh(i) = h(i) + 10 continue + h(1) = 0.0d0 + do 20 i=1,j + li = l+i + lj = li-j + if (t(li).ne.t(lj)) goto 15 + h(i+1) = 0.0d0 + goto 20 + 15 f = hh(i)/(t(li)-t(lj)) + h(i) = h(i)+f*(t(li)-x) + h(i+1) = f*(x-t(lj)) + 20 continue + return + end Added: branches/Interpolate1D/fitpack/fpchec.f =================================================================== --- branches/Interpolate1D/fitpack/fpchec.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpchec.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,62 @@ + subroutine fpchec(x,m,t,n,k,ier) +c subroutine fpchec verifies the number and the position of the knots +c t(j),j=1,2,...,n of a spline of degree k, in relation to the number +c and the position of the data points x(i),i=1,2,...,m. if all of the +c following conditions are fulfilled, the error parameter ier is set +c to zero. if one of the conditions is violated ier is set to ten. +c 1) k+1 <= n-k-1 <= m +c 2) t(1) <= t(2) <= ... <= t(k+1) +c t(n-k) <= t(n-k+1) <= ... <= t(n) +c 3) t(k+1) < t(k+2) < ... < t(n-k) +c 4) t(k+1) <= x(i) <= t(n-k) +c 5) the conditions specified by schoenberg and whitney must hold +c for at least one subset of data points, i.e. there must be a +c subset of data points y(j) such that +c t(j) < y(j) < t(j+k+1), j=1,2,...,n-k-1 +c .. +c ..scalar arguments.. + integer m,n,k,ier +c ..array arguments.. + real*8 x(m),t(n) +c ..local scalars.. + integer i,j,k1,k2,l,nk1,nk2,nk3 + real*8 tj,tl +c .. + k1 = k+1 + k2 = k1+1 + nk1 = n-k1 + nk2 = nk1+1 + ier = 10 +c check condition no 1 + if(nk1.lt.k1 .or. nk1.gt.m) go to 80 +c check condition no 2 + j = n + do 20 i=1,k + if(t(i).gt.t(i+1)) go to 80 + if(t(j).lt.t(j-1)) go to 80 + j = j-1 + 20 continue +c check condition no 3 + do 30 i=k2,nk2 + if(t(i).le.t(i-1)) go to 80 + 30 continue +c check condition no 4 + if(x(1).lt.t(k1) .or. x(m).gt.t(nk2)) go to 80 +c check condition no 5 + if(x(1).ge.t(k2) .or. x(m).le.t(nk1)) go to 80 + i = 1 + l = k2 + nk3 = nk1-1 + if(nk3.lt.2) go to 70 + do 60 j=2,nk3 + tj = t(j) + l = l+1 + tl = t(l) + 40 i = i+1 + if(i.ge.m) go to 80 + if(x(i).le.tj) go to 40 + if(x(i).ge.tl) go to 80 + 60 continue + 70 ier = 0 + 80 return + end Added: branches/Interpolate1D/fitpack/fpched.f =================================================================== --- branches/Interpolate1D/fitpack/fpched.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpched.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,69 @@ + subroutine fpched(x,m,t,n,k,ib,ie,ier) +c subroutine fpched verifies the number and the position of the knots +c t(j),j=1,2,...,n of a spline of degree k,with ib derative constraints +c at x(1) and ie constraints at x(m), in relation to the number and +c the position of the data points x(i),i=1,2,...,m. if all of the +c following conditions are fulfilled, the error parameter ier is set +c to zero. if one of the conditions is violated ier is set to ten. +c 1) k+1 <= n-k-1 <= m + max(0,ib-1) + max(0,ie-1) +c 2) t(1) <= t(2) <= ... <= t(k+1) +c t(n-k) <= t(n-k+1) <= ... <= t(n) +c 3) t(k+1) < t(k+2) < ... < t(n-k) +c 4) t(k+1) <= x(i) <= t(n-k) +c 5) the conditions specified by schoenberg and whitney must hold +c for at least one subset of data points, i.e. there must be a +c subset of data points y(j) such that +c t(j) < y(j) < t(j+k+1), j=1+ib1,2+ib1,...,n-k-1-ie1 +c with ib1 = max(0,ib-1), ie1 = max(0,ie-1) +c .. +c ..scalar arguments.. + integer m,n,k,ib,ie,ier +c ..array arguments.. + real*8 x(m),t(n) +c ..local scalars.. + integer i,ib1,ie1,j,jj,k1,k2,l,nk1,nk2,nk3 + real*8 tj,tl +c .. + k1 = k+1 + k2 = k1+1 + nk1 = n-k1 + nk2 = nk1+1 + ib1 = ib-1 + if(ib1.lt.0) ib1 = 0 + ie1 = ie-1 + if(ie1.lt.0) ie1 = 0 + ier = 10 +c check condition no 1 + if(nk1.lt.k1 .or. nk1.gt.(m+ib1+ie1)) go to 80 +c check condition no 2 + j = n + do 20 i=1,k + if(t(i).gt.t(i+1)) go to 80 + if(t(j).lt.t(j-1)) go to 80 + j = j-1 + 20 continue +c check condition no 3 + do 30 i=k2,nk2 + if(t(i).le.t(i-1)) go to 80 + 30 continue +c check condition no 4 + if(x(1).lt.t(k1) .or. x(m).gt.t(nk2)) go to 80 +c check condition no 5 + if(x(1).ge.t(k2) .or. x(m).le.t(nk1)) go to 80 + i = 1 + jj = 2+ib1 + l = jj+k + nk3 = nk1-1-ie1 + if(nk3.lt.jj) go to 70 + do 60 j=jj,nk3 + tj = t(j) + l = l+1 + tl = t(l) + 40 i = i+1 + if(i.ge.m) go to 80 + if(x(i).le.tj) go to 40 + if(x(i).ge.tl) go to 80 + 60 continue + 70 ier = 0 + 80 return + end Added: branches/Interpolate1D/fitpack/fpchep.f =================================================================== --- branches/Interpolate1D/fitpack/fpchep.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpchep.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,81 @@ + subroutine fpchep(x,m,t,n,k,ier) +c subroutine fpchep verifies the number and the position of the knots +c t(j),j=1,2,...,n of a periodic spline of degree k, in relation to +c the number and the position of the data points x(i),i=1,2,...,m. +c if all of the following conditions are fulfilled, ier is set +c to zero. if one of the conditions is violated ier is set to ten. +c 1) k+1 <= n-k-1 <= m+k-1 +c 2) t(1) <= t(2) <= ... <= t(k+1) +c t(n-k) <= t(n-k+1) <= ... <= t(n) +c 3) t(k+1) < t(k+2) < ... < t(n-k) +c 4) t(k+1) <= x(i) <= t(n-k) +c 5) the conditions specified by schoenberg and whitney must hold +c for at least one subset of data points, i.e. there must be a +c subset of data points y(j) such that +c t(j) < y(j) < t(j+k+1), j=k+1,...,n-k-1 +c .. +c ..scalar arguments.. + integer m,n,k,ier +c ..array arguments.. + real*8 x(m),t(n) +c ..local scalars.. + integer i,i1,i2,j,j1,k1,k2,l,l1,l2,mm,m1,nk1,nk2 + real*8 per,tj,tl,xi +c .. + k1 = k+1 + k2 = k1+1 + nk1 = n-k1 + nk2 = nk1+1 + m1 = m-1 + ier = 10 +c check condition no 1 + if(nk1.lt.k1 .or. n.gt.m+2*k) go to 130 +c check condition no 2 + j = n + do 20 i=1,k + if(t(i).gt.t(i+1)) go to 130 + if(t(j).lt.t(j-1)) go to 130 + j = j-1 + 20 continue +c check condition no 3 + do 30 i=k2,nk2 + if(t(i).le.t(i-1)) go to 130 + 30 continue +c check condition no 4 + if(x(1).lt.t(k1) .or. x(m).gt.t(nk2)) go to 130 +c check condition no 5 + l1 = k1 + l2 = 1 + do 50 l=1,m + xi = x(l) + 40 if(xi.lt.t(l1+1) .or. l.eq.nk1) go to 50 + l1 = l1+1 + l2 = l2+1 + if(l2.gt.k1) go to 60 + go to 40 + 50 continue + l = m + 60 per = t(nk2)-t(k1) + do 120 i1=2,l + i = i1-1 + mm = i+m1 + do 110 j=k1,nk1 + tj = t(j) + j1 = j+k1 + tl = t(j1) + 70 i = i+1 + if(i.gt.mm) go to 120 + i2 = i-m1 + if (i2.le.0) go to 80 + go to 90 + 80 xi = x(i) + go to 100 + 90 xi = x(i2)+per + 100 if(xi.le.tj) go to 70 + if(xi.ge.tl) go to 120 + 110 continue + ier = 0 + go to 130 + 120 continue + 130 return + end Added: branches/Interpolate1D/fitpack/fpclos.f =================================================================== --- branches/Interpolate1D/fitpack/fpclos.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpclos.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,714 @@ + subroutine fpclos(iopt,idim,m,u,mx,x,w,k,s,nest,tol,maxit,k1,k2, + * n,t,nc,c,fp,fpint,z,a1,a2,b,g1,g2,q,nrdata,ier) +c .. +c ..scalar arguments.. + real*8 s,tol,fp + integer iopt,idim,m,mx,k,nest,maxit,k1,k2,n,nc,ier +c ..array arguments.. + real*8 u(m),x(mx),w(m),t(nest),c(nc),fpint(nest),z(nc),a1(nest,k1) + *, + * a2(nest,k),b(nest,k2),g1(nest,k2),g2(nest,k1),q(m,k1) + integer nrdata(nest) +c ..local scalars.. + real*8 acc,cos,d1,fac,fpart,fpms,fpold,fp0,f1,f2,f3,p,per,pinv,piv + *, + * p1,p2,p3,sin,store,term,ui,wi,rn,one,con1,con4,con9,half + integer i,ich1,ich3,ij,ik,it,iter,i1,i2,i3,j,jj,jk,jper,j1,j2,kk, + * kk1,k3,l,l0,l1,l5,mm,m1,new,nk1,nk2,nmax,nmin,nplus,npl1, + * nrint,n10,n11,n7,n8 +c ..local arrays.. + real*8 h(6),h1(7),h2(6),xi(10) +c ..function references.. + real*8 abs,fprati + integer max0,min0 +c ..subroutine references.. +c fpbacp,fpbspl,fpgivs,fpdisc,fpknot,fprota +c .. +c set constants + one = 0.1e+01 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 + half = 0.5e0 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position c +c ************************************************************** c +c given a set of knots we compute the least-squares closed curve c +c sinf(u). if the sum f(p=inf) <= s we accept the choice of knots. c +c if iopt=-1 sinf(u) is the requested curve c +c if iopt=0 or iopt=1 we check whether we can accept the knots: c +c if fp <=s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares curve until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmax = m+2*k. c +c if s > 0 and c +c iopt=0 we first compute the least-squares polynomial curve of c +c degree k; n = nmin = 2*k+2. since s(u) must be periodic we c +c find that s(u) reduces to a fixed point. c +c iopt=1 we start with the set of knots found at the last c +c call of the routine, except for the case that s > fp0; then c +c we compute directly the least-squares polynomial curve. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc + m1 = m-1 + kk = k + kk1 = k1 + k3 = 3*k+1 + nmin = 2*k1 +c determine the length of the period of the splines. + per = u(m)-u(1) + if(iopt.lt.0) go to 50 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s +c determine nmax, the number of knots for periodic spline interpolation + nmax = m+2*k + if(s.gt.0. .or. nmax.eq.nmin) go to 30 +c if s=0, s(u) is an interpolating curve. + n = nmax +c test whether the required storage space exceeds the available one. + if(n.gt.nest) go to 620 +c find the position of the interior knots in case of interpolation. + 5 if((k/2)*2 .eq.k) go to 20 + do 10 i=2,m1 + j = i+k + t(j) = u(i) + 10 continue + if(s.gt.0.) go to 50 + kk = k-1 + kk1 = k + if(kk.gt.0) go to 50 + t(1) = t(m)-per + t(2) = u(1) + t(m+1) = u(m) + t(m+2) = t(3)+per + jj = 0 + do 15 i=1,m1 + j = i + do 12 j1=1,idim + jj = jj+1 + c(j) = x(jj) + j = j+n + 12 continue + 15 continue + jj = 1 + j = m + do 17 j1=1,idim + c(j) = c(jj) + j = j+n + jj = jj+n + 17 continue + fp = 0. + fpint(n) = fp0 + fpint(n-1) = 0. + nrdata(n) = 0 + go to 630 + 20 do 25 i=2,m1 + j = i+k + t(j) = (u(i)+u(i-1))*half + 25 continue + go to 50 +c if s > 0 our initial choice depends on the value of iopt. +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c polynomial curve. (i.e. a constant point). +c if iopt=1 and fp0>s we start computing the least-squares closed +c curve according the set of knots found at the last call of the +c routine. + 30 if(iopt.eq.0) go to 35 + if(n.eq.nmin) go to 35 + fp0 = fpint(n) + fpold = fpint(n-1) + nplus = nrdata(n) + if(fp0.gt.s) go to 50 +c the case that s(u) is a fixed point is treated separetely. +c fp0 denotes the corresponding sum of squared residuals. + 35 fp0 = 0. + d1 = 0. + do 37 j=1,idim + z(j) = 0. + 37 continue + jj = 0 + do 45 it=1,m1 + wi = w(it) + call fpgivs(wi,d1,cos,sin) + do 40 j=1,idim + jj = jj+1 + fac = wi*x(jj) + call fprota(cos,sin,fac,z(j)) + fp0 = fp0+fac**2 + 40 continue + 45 continue + do 47 j=1,idim + z(j) = z(j)/d1 + 47 continue +c test whether that fixed point is a solution of our problem. + fpms = fp0-s + if(fpms.lt.acc .or. nmax.eq.nmin) go to 640 + fpold = fp0 +c test whether the required storage space exceeds the available one. + if(n.ge.nest) go to 620 +c start computing the least-squares closed curve with one +c interior knot. + nplus = 1 + n = nmin+1 + mm = (m+1)/2 + t(k2) = u(mm) + nrdata(1) = mm-2 + nrdata(2) = m1-mm +c main loop for the different sets of knots. m is a save upper +c bound for the number of trials. + 50 do 340 iter=1,m +c find nrint, the number of knot intervals. + nrint = n-nmin+1 +c find the position of the additional knots which are needed for +c the b-spline representation of s(u). if we take +c t(k+1) = u(1), t(n-k) = u(m) +c t(k+1-j) = t(n-k-j) - per, j=1,2,...k +c t(n-k+j) = t(k+1+j) + per, j=1,2,...k +c then s(u) will be a smooth closed curve if the b-spline +c coefficients satisfy the following conditions +c c((i-1)*n+n7+j) = c((i-1)*n+j), j=1,...k,i=1,2,...,idim (**) +c with n7=n-2*k-1. + t(k1) = u(1) + nk1 = n-k1 + nk2 = nk1+1 + t(nk2) = u(m) + do 60 j=1,k + i1 = nk2+j + i2 = nk2-j + j1 = k1+j + j2 = k1-j + t(i1) = t(j1)+per + t(j2) = t(i2)-per + 60 continue +c compute the b-spline coefficients of the least-squares closed curve +c sinf(u). the observation matrix a is built up row by row while +c taking into account condition (**) and is reduced to triangular +c form by givens transformations . +c at the same time fp=f(p=inf) is computed. +c the n7 x n7 triangularised upper matrix a has the form +c ! a1 ' ! +c a = ! ' a2 ! +c ! 0 ' ! +c with a2 a n7 x k matrix and a1 a n10 x n10 upper triangular +c matrix of bandwith k+1 ( n10 = n7-k). +c initialization. + do 65 i=1,nc + z(i) = 0. + 65 continue + do 70 i=1,nk1 + do 70 j=1,kk1 + a1(i,j) = 0. + 70 continue + n7 = nk1-k + n10 = n7-kk + jper = 0 + fp = 0. + l = k1 + jj = 0 + do 290 it=1,m1 +c fetch the current data point u(it),x(it) + ui = u(it) + wi = w(it) + do 75 j=1,idim + jj = jj+1 + xi(j) = x(jj)*wi + 75 continue +c search for knot interval t(l) <= ui < t(l+1). + 80 if(ui.lt.t(l+1)) go to 85 + l = l+1 + go to 80 +c evaluate the (k+1) non-zero b-splines at ui and store them in q. + 85 call fpbspl(t,n,k,ui,l,h) + do 90 i=1,k1 + q(it,i) = h(i) + h(i) = h(i)*wi + 90 continue + l5 = l-k1 +c test whether the b-splines nj,k+1(u),j=1+n7,...nk1 are all zero at ui + if(l5.lt.n10) go to 285 + if(jper.ne.0) go to 160 +c initialize the matrix a2. + do 95 i=1,n7 + do 95 j=1,kk + a2(i,j) = 0. + 95 continue + jk = n10+1 + do 110 i=1,kk + ik = jk + do 100 j=1,kk1 + if(ik.le.0) go to 105 + a2(ik,i) = a1(ik,j) + ik = ik-1 + 100 continue + 105 jk = jk+1 + 110 continue + jper = 1 +c if one of the b-splines nj,k+1(u),j=n7+1,...nk1 is not zero at ui +c we take account of condition (**) for setting up the new row +c of the observation matrix a. this row is stored in the arrays h1 +c (the part with respect to a1) and h2 (the part with +c respect to a2). + 160 do 170 i=1,kk + h1(i) = 0. + h2(i) = 0. + 170 continue + h1(kk1) = 0. + j = l5-n10 + do 210 i=1,kk1 + j = j+1 + l0 = j + 180 l1 = l0-kk + if(l1.le.0) go to 200 + if(l1.le.n10) go to 190 + l0 = l1-n10 + go to 180 + 190 h1(l1) = h(i) + go to 210 + 200 h2(l0) = h2(l0)+h(i) + 210 continue +c rotate the new row of the observation matrix into triangle +c by givens transformations. + if(n10.le.0) go to 250 +c rotation with the rows 1,2,...n10 of matrix a. + do 240 j=1,n10 + piv = h1(1) + if(piv.ne.0.) go to 214 + do 212 i=1,kk + h1(i) = h1(i+1) + 212 continue + h1(kk1) = 0. + go to 240 +c calculate the parameters of the givens transformation. + 214 call fpgivs(piv,a1(j,1),cos,sin) +c transformation to the right hand side. + j1 = j + do 217 j2=1,idim + call fprota(cos,sin,xi(j2),z(j1)) + j1 = j1+n + 217 continue +c transformations to the left hand side with respect to a2. + do 220 i=1,kk + call fprota(cos,sin,h2(i),a2(j,i)) + 220 continue + if(j.eq.n10) go to 250 + i2 = min0(n10-j,kk) +c transformations to the left hand side with respect to a1. + do 230 i=1,i2 + i1 = i+1 + call fprota(cos,sin,h1(i1),a1(j,i1)) + h1(i) = h1(i1) + 230 continue + h1(i1) = 0. + 240 continue +c rotation with the rows n10+1,...n7 of matrix a. + 250 do 270 j=1,kk + ij = n10+j + if(ij.le.0) go to 270 + piv = h2(j) + if(piv.eq.0.) go to 270 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a2(ij,j),cos,sin) +c transformations to right hand side. + j1 = ij + do 255 j2=1,idim + call fprota(cos,sin,xi(j2),z(j1)) + j1 = j1+n + 255 continue + if(j.eq.kk) go to 280 + j1 = j+1 +c transformations to left hand side. + do 260 i=j1,kk + call fprota(cos,sin,h2(i),a2(ij,i)) + 260 continue + 270 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 280 do 282 j2=1,idim + fp = fp+xi(j2)**2 + 282 continue + go to 290 +c rotation of the new row of the observation matrix into +c triangle in case the b-splines nj,k+1(u),j=n7+1,...n-k-1 are all zero +c at ui. + 285 j = l5 + do 140 i=1,kk1 + j = j+1 + piv = h(i) + if(piv.eq.0.) go to 140 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a1(j,1),cos,sin) +c transformations to right hand side. + j1 = j + do 125 j2=1,idim + call fprota(cos,sin,xi(j2),z(j1)) + j1 = j1+n + 125 continue + if(i.eq.kk1) go to 150 + i2 = 1 + i3 = i+1 +c transformations to left hand side. + do 130 i1=i3,kk1 + i2 = i2+1 + call fprota(cos,sin,h(i1),a1(j,i2)) + 130 continue + 140 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 150 do 155 j2=1,idim + fp = fp+xi(j2)**2 + 155 continue + 290 continue + fpint(n) = fp0 + fpint(n-1) = fpold + nrdata(n) = nplus +c backward substitution to obtain the b-spline coefficients . + j1 = 1 + do 292 j2=1,idim + call fpbacp(a1,a2,z(j1),n7,kk,c(j1),kk1,nest) + j1 = j1+n + 292 continue +c calculate from condition (**) the remaining coefficients. + do 297 i=1,k + j1 = i + do 295 j=1,idim + j2 = j1+n7 + c(j2) = c(j1) + j1 = j1+n + 295 continue + 297 continue + if(iopt.lt.0) go to 660 +c test whether the approximation sinf(u) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 660 +c if f(p=inf) < s accept the choice of knots. + if(fpms.lt.0.) go to 350 +c if n=nmax, sinf(u) is an interpolating curve. + if(n.eq.nmax) go to 630 +c increase the number of knots. +c if n=nest we cannot increase the number of knots because of the +c storage capacity limitation. + if(n.eq.nest) go to 620 +c determine the number of knots nplus we are going to add. + npl1 = nplus*2 + rn = nplus + if(fpold-fp.gt.acc) npl1 = rn*fpms/(fpold-fp) + nplus = min0(nplus*2,max0(npl1,nplus/2,1)) + fpold = fp +c compute the sum of squared residuals for each knot interval +c t(j+k) <= ui <= t(j+k+1) and store it in fpint(j),j=1,2,...nrint. + fpart = 0. + i = 1 + l = k1 + jj = 0 + do 320 it=1,m1 + if(u(it).lt.t(l)) go to 300 + new = 1 + l = l+1 + 300 term = 0. + l0 = l-k2 + do 310 j2=1,idim + fac = 0. + j1 = l0 + do 305 j=1,k1 + j1 = j1+1 + fac = fac+c(j1)*q(it,j) + 305 continue + jj = jj+1 + term = term+(w(it)*(fac-x(jj)))**2 + l0 = l0+n + 310 continue + fpart = fpart+term + if(new.eq.0) go to 320 + if(l.gt.k2) go to 315 + fpint(nrint) = term + new = 0 + go to 320 + 315 store = term*half + fpint(i) = fpart-store + i = i+1 + fpart = store + new = 0 + 320 continue + fpint(nrint) = fpint(nrint)+fpart + do 330 l=1,nplus +c add a new knot + call fpknot(u,m,t,n,fpint,nrdata,nrint,nest,1) +c if n=nmax we locate the knots as for interpolation + if(n.eq.nmax) go to 5 +c test whether we cannot further increase the number of knots. + if(n.eq.nest) go to 340 + 330 continue +c restart the computations with the new set of knots. + 340 continue +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing closed curve sp(u). c +c ********************************************************** c +c we have determined the number of knots and their position. c +c we now compute the b-spline coefficients of the smoothing curve c +c sp(u). the observation matrix a is extended by the rows of matrix c +c b expressing that the kth derivative discontinuities of sp(u) at c +c the interior knots t(k+2),...t(n-k-1) must be zero. the corres- c +c ponding weights of these additional rows are set to 1/p. c +c iteratively we then have to determine the value of p such that f(p),c +c the sum of squared residuals be = s. we already know that the least-c +c squares polynomial curve corresponds to p=0, and that the least- c +c squares periodic spline curve corresponds to p=infinity. the c +c iteration process which is proposed here, makes use of rational c +c interpolation. since f(p) is a convex and strictly decreasing c +c function of p, it can be approximated by a rational function c +c r(p) = (u*p+v)/(p+w). three values of p(p1,p2,p3) with correspond- c +c ing values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used c +c to calculate the new value of p such that r(p)=s. convergence is c +c guaranteed by taking f1>0 and f3<0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jump of the kth derivative of the +c b-splines at the knots t(l),l=k+2,...n-k-1 and store in b. + 350 call fpdisc(t,n,k2,b,nest) +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + n11 = n10-1 + n8 = n7-1 + p = 0. + l = n7 + do 352 i=1,k + j = k+1-i + p = p+a2(l,j) + l = l-1 + if(l.eq.0) go to 356 + 352 continue + do 354 i=1,n10 + p = p+a1(i,1) + 354 continue + 356 rn = n7 + p = rn/p + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p) = s. + do 595 iter=1,maxit +c form the matrix g as the matrix a extended by the rows of matrix b. +c the rows of matrix b with weight 1/p are rotated into +c the triangularised observation matrix a. +c after triangularisation our n7 x n7 matrix g takes the form +c ! g1 ' ! +c g = ! ' g2 ! +c ! 0 ' ! +c with g2 a n7 x (k+1) matrix and g1 a n11 x n11 upper triangular +c matrix of bandwidth k+2. ( n11 = n7-k-1) + pinv = one/p +c store matrix a into g + do 358 i=1,nc + c(i) = z(i) + 358 continue + do 360 i=1,n7 + g1(i,k1) = a1(i,k1) + g1(i,k2) = 0. + g2(i,1) = 0. + do 360 j=1,k + g1(i,j) = a1(i,j) + g2(i,j+1) = a2(i,j) + 360 continue + l = n10 + do 370 j=1,k1 + if(l.le.0) go to 375 + g2(l,1) = a1(l,j) + l = l-1 + 370 continue + 375 do 540 it=1,n8 +c fetch a new row of matrix b and store it in the arrays h1 (the part +c with respect to g1) and h2 (the part with respect to g2). + do 380 j=1,idim + xi(j) = 0. + 380 continue + do 385 i=1,k1 + h1(i) = 0. + h2(i) = 0. + 385 continue + h1(k2) = 0. + if(it.gt.n11) go to 420 + l = it + l0 = it + do 390 j=1,k2 + if(l0.eq.n10) go to 400 + h1(j) = b(it,j)*pinv + l0 = l0+1 + 390 continue + go to 470 + 400 l0 = 1 + do 410 l1=j,k2 + h2(l0) = b(it,l1)*pinv + l0 = l0+1 + 410 continue + go to 470 + 420 l = 1 + i = it-n10 + do 460 j=1,k2 + i = i+1 + l0 = i + 430 l1 = l0-k1 + if(l1.le.0) go to 450 + if(l1.le.n11) go to 440 + l0 = l1-n11 + go to 430 + 440 h1(l1) = b(it,j)*pinv + go to 460 + 450 h2(l0) = h2(l0)+b(it,j)*pinv + 460 continue + if(n11.le.0) go to 510 +c rotate this row into triangle by givens transformations +c rotation with the rows l,l+1,...n11. + 470 do 500 j=l,n11 + piv = h1(1) +c calculate the parameters of the givens transformation. + call fpgivs(piv,g1(j,1),cos,sin) +c transformation to right hand side. + j1 = j + do 475 j2=1,idim + call fprota(cos,sin,xi(j2),c(j1)) + j1 = j1+n + 475 continue +c transformation to the left hand side with respect to g2. + do 480 i=1,k1 + call fprota(cos,sin,h2(i),g2(j,i)) + 480 continue + if(j.eq.n11) go to 510 + i2 = min0(n11-j,k1) +c transformation to the left hand side with respect to g1. + do 490 i=1,i2 + i1 = i+1 + call fprota(cos,sin,h1(i1),g1(j,i1)) + h1(i) = h1(i1) + 490 continue + h1(i1) = 0. + 500 continue +c rotation with the rows n11+1,...n7 + 510 do 530 j=1,k1 + ij = n11+j + if(ij.le.0) go to 530 + piv = h2(j) +c calculate the parameters of the givens transformation + call fpgivs(piv,g2(ij,j),cos,sin) +c transformation to the right hand side. + j1 = ij + do 515 j2=1,idim + call fprota(cos,sin,xi(j2),c(j1)) + j1 = j1+n + 515 continue + if(j.eq.k1) go to 540 + j1 = j+1 +c transformation to the left hand side. + do 520 i=j1,k1 + call fprota(cos,sin,h2(i),g2(ij,i)) + 520 continue + 530 continue + 540 continue +c backward substitution to obtain the b-spline coefficients + j1 = 1 + do 542 j2=1,idim + call fpbacp(g1,g2,c(j1),n7,k1,c(j1),k2,nest) + j1 = j1+n + 542 continue +c calculate from condition (**) the remaining b-spline coefficients. + do 547 i=1,k + j1 = i + do 545 j=1,idim + j2 = j1+n7 + c(j2) = c(j1) + j1 = j1+n + 545 continue + 547 continue +c computation of f(p). + fp = 0. + l = k1 + jj = 0 + do 570 it=1,m1 + if(u(it).lt.t(l)) go to 550 + l = l+1 + 550 l0 = l-k2 + term = 0. + do 565 j2=1,idim + fac = 0. + j1 = l0 + do 560 j=1,k1 + j1 = j1+1 + fac = fac+c(j1)*q(it,j) + 560 continue + jj = jj+1 + term = term+(fac-x(jj))**2 + l0 = l0+n + 565 continue + fp = fp+term*w(it)**2 + 570 continue +c test whether the approximation sp(u) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 660 +c test whether the maximal number of iterations is reached. + if(iter.eq.maxit) go to 600 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 580 + if((f2-f3) .gt. acc) go to 575 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 +p2*con1 + go to 595 + 575 if(f2.lt.0.) ich3 = 1 + 580 if(ich1.ne.0) go to 590 + if((f1-f2) .gt. acc) go to 585 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 595 + if(p.ge.p3) p = p2*con1 +p3*con9 + go to 595 + 585 if(f2.gt.0.) ich1 = 1 +c test whether the iteration process proceeds as theoretically +c expected. + 590 if(f2.ge.f1 .or. f2.le.f3) go to 610 +c find the new value for p. + p = fprati(p1,f1,p2,f2,p3,f3) + 595 continue +c error codes and messages. + 600 ier = 3 + go to 660 + 610 ier = 2 + go to 660 + 620 ier = 1 + go to 660 + 630 ier = -1 + go to 660 + 640 ier = -2 +c the point (z(1),z(2),...,z(idim)) is a solution of our problem. +c a constant function is a spline of degree k with all b-spline +c coefficients equal to that constant. + do 650 i=1,k1 + rn = k1-i + t(i) = u(1)-rn*per + j = i+k1 + rn = i-1 + t(j) = u(m)+rn*per + 650 continue + n = nmin + j1 = 0 + do 658 j=1,idim + fac = z(j) + j2 = j1 + do 654 i=1,k1 + j2 = j2+1 + c(j2) = fac + 654 continue + j1 = j1+n + 658 continue + fp = fp0 + fpint(n) = fp0 + fpint(n-1) = 0. + nrdata(n) = 0 + 660 return + end Added: branches/Interpolate1D/fitpack/fpcoco.f =================================================================== --- branches/Interpolate1D/fitpack/fpcoco.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcoco.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,168 @@ + subroutine fpcoco(iopt,m,x,y,w,v,s,nest,maxtr,maxbin,n,t,c,sq,sx, + * bind,e,wrk,lwrk,iwrk,kwrk,ier) +c ..scalar arguments.. + real*8 s,sq + integer iopt,m,nest,maxtr,maxbin,n,lwrk,kwrk,ier +c ..array arguments.. + integer iwrk(kwrk) + real*8 x(m),y(m),w(m),v(m),t(nest),c(nest),sx(m),e(nest),wrk(lwrk) + * + logical bind(nest) +c ..local scalars.. + integer i,ia,ib,ic,iq,iu,iz,izz,i1,j,k,l,l1,m1,nmax,nr,n4,n6,n8, + * ji,jib,jjb,jl,jr,ju,mb,nm + real*8 sql,sqmax,term,tj,xi,half +c ..subroutine references.. +c fpcosp,fpbspl,fpadno,fpdeno,fpseno,fpfrno +c .. +c set constant + half = 0.5e0 +c determine the maximal admissible number of knots. + nmax = m+4 +c the initial choice of knots depends on the value of iopt. +c if iopt=0 the program starts with the minimal number of knots +c so that can be guarantied that the concavity/convexity constraints +c will be satisfied. +c if iopt = 1 the program will continue from the point on where she +c left at the foregoing call. + if(iopt.gt.0) go to 80 +c find the minimal number of knots. +c a knot is located at the data point x(i), i=2,3,...m-1 if +c 1) v(i) ^= 0 and +c 2) v(i)*v(i-1) <= 0 or v(i)*v(i+1) <= 0. + m1 = m-1 + n = 4 + do 20 i=2,m1 + if(v(i).eq.0. .or. (v(i)*v(i-1).gt.0. .and. + * v(i)*v(i+1).gt.0.)) go to 20 + n = n+1 +c test whether the required storage space exceeds the available one. + if(n+4.gt.nest) go to 200 + t(n) = x(i) + 20 continue +c find the position of the knots t(1),...t(4) and t(n-3),...t(n) which +c are needed for the b-spline representation of s(x). + do 30 i=1,4 + t(i) = x(1) + n = n+1 + t(n) = x(m) + 30 continue +c test whether the minimum number of knots exceeds the maximum number. + if(n.gt.nmax) go to 210 +c main loop for the different sets of knots. +c find corresponding values e(j) to the knots t(j+3),j=1,2,...n-6 +c e(j) will take the value -1,1, or 0 according to the requirement +c that s(x) must be locally convex or concave at t(j+3) or that the +c sign of s''(x) is unrestricted at that point. + 40 i= 1 + xi = x(1) + j = 4 + tj = t(4) + n6 = n-6 + do 70 l=1,n6 + 50 if(xi.eq.tj) go to 60 + i = i+1 + xi = x(i) + go to 50 + 60 e(l) = v(i) + j = j+1 + tj = t(j) + 70 continue +c we partition the working space + nm = n+maxbin + mb = maxbin+1 + ia = 1 + ib = ia+4*n + ic = ib+nm*maxbin + iz = ic+n + izz = iz+n + iu = izz+n + iq = iu+maxbin + ji = 1 + ju = ji+maxtr + jl = ju+maxtr + jr = jl+maxtr + jjb = jr+maxtr + jib = jjb+mb +c given the set of knots t(j),j=1,2,...n, find the least-squares cubic +c spline which satisfies the imposed concavity/convexity constraints. + call fpcosp(m,x,y,w,n,t,e,maxtr,maxbin,c,sq,sx,bind,nm,mb,wrk(ia), + * + * wrk(ib),wrk(ic),wrk(iz),wrk(izz),wrk(iu),wrk(iq),iwrk(ji), + * iwrk(ju),iwrk(jl),iwrk(jr),iwrk(jjb),iwrk(jib),ier) +c if sq <= s or in case of abnormal exit from fpcosp, control is +c repassed to the driver program. + if(sq.le.s .or. ier.gt.0) go to 300 +c calculate for each knot interval t(l-1) <= xi <= t(l) the +c sum((wi*(yi-s(xi)))**2). +c find the interval t(k-1) <= x <= t(k) for which this sum is maximal +c on the condition that this interval contains at least one interior +c data point x(nr) and that s(x) is not given there by a straight line. + 80 sqmax = 0. + sql = 0. + l = 5 + nr = 0 + i1 = 1 + n4 = n-4 + do 110 i=1,m + term = (w(i)*(sx(i)-y(i)))**2 + if(x(i).lt.t(l) .or. l.gt.n4) go to 100 + term = term*half + sql = sql+term + if(i-i1.le.1 .or. (bind(l-4).and.bind(l-3))) go to 90 + if(sql.le.sqmax) go to 90 + k = l + sqmax = sql + nr = i1+(i-i1)/2 + 90 l = l+1 + i1 = i + sql = 0. + 100 sql = sql+term + 110 continue + if(m-i1.le.1 .or. (bind(l-4).and.bind(l-3))) go to 120 + if(sql.le.sqmax) go to 120 + k = l + nr = i1+(m-i1)/2 +c if no such interval is found, control is repassed to the driver +c program (ier = -1). + 120 if(nr.eq.0) go to 190 +c if s(x) is given by the same straight line in two succeeding knot +c intervals t(l-1) <= x <= t(l) and t(l) <= x <= t(l+1),delete t(l) + n8 = n-8 + l1 = 0 + if(n8.le.0) go to 150 + do 140 i=1,n8 + if(.not. (bind(i).and.bind(i+1).and.bind(i+2))) go to 140 + l = i+4-l1 + if(k.gt.l) k = k-1 + n = n-1 + l1 = l1+1 + do 130 j=l,n + t(j) = t(j+1) + 130 continue + 140 continue +c test whether we cannot further increase the number of knots. + 150 if(n.eq.nmax) go to 180 + if(n.eq.nest) go to 170 +c locate an additional knot at the point x(nr). + j = n + do 160 i=k,n + t(j+1) = t(j) + j = j-1 + 160 continue + t(k) = x(nr) + n = n+1 +c restart the computations with the new set of knots. + go to 40 +c error codes and messages. + 170 ier = -3 + go to 300 + 180 ier = -2 + go to 300 + 190 ier = -1 + go to 300 + 200 ier = 4 + go to 300 + 210 ier = 5 + 300 return + end Added: branches/Interpolate1D/fitpack/fpcons.f =================================================================== --- branches/Interpolate1D/fitpack/fpcons.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcons.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,442 @@ + subroutine fpcons(iopt,idim,m,u,mx,x,w,ib,ie,k,s,nest,tol,maxit, + * k1,k2,n,t,nc,c,fp,fpint,z,a,b,g,q,nrdata,ier) +c .. +c ..scalar arguments.. + real*8 s,tol,fp + integer iopt,idim,m,mx,ib,ie,k,nest,maxit,k1,k2,n,nc,ier +c ..array arguments.. + real*8 u(m),x(mx),w(m),t(nest),c(nc),fpint(nest), + * z(nc),a(nest,k1),b(nest,k2),g(nest,k2),q(m,k1) + integer nrdata(nest) +c ..local scalars.. + real*8 acc,con1,con4,con9,cos,fac,fpart,fpms,fpold,fp0,f1,f2,f3, + * half,one,p,pinv,piv,p1,p2,p3,rn,sin,store,term,ui,wi + integer i,ich1,ich3,it,iter,i1,i2,i3,j,jb,je,jj,j1,j2,j3,kbe, + * l,li,lj,l0,mb,me,mm,new,nk1,nmax,nmin,nn,nplus,npl1,nrint,n8 +c ..local arrays.. + real*8 h(7),xi(10) +c ..function references + real*8 abs,fprati + integer max0,min0 +c ..subroutine references.. +c fpbacp,fpbspl,fpgivs,fpdisc,fpknot,fprota +c .. +c set constants + one = 0.1e+01 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 + half = 0.5e0 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position c +c ************************************************************** c +c given a set of knots we compute the least-squares curve sinf(u), c +c and the corresponding sum of squared residuals fp=f(p=inf). c +c if iopt=-1 sinf(u) is the requested curve. c +c if iopt=0 or iopt=1 we check whether we can accept the knots: c +c if fp <=s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares curve until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmax = m+k+1-max(0,ib-1)-max(0,ie-1) c +c if s > 0 and c +c iopt=0 we first compute the least-squares polynomial curve of c +c degree k; n = nmin = 2*k+2 c +c iopt=1 we start with the set of knots found at the last c +c call of the routine, except for the case that s > fp0; then c +c we compute directly the polynomial curve of degree k. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c determine nmin, the number of knots for polynomial approximation. + nmin = 2*k1 +c find which data points are to be concidered. + mb = 2 + jb = ib + if(ib.gt.0) go to 10 + mb = 1 + jb = 1 + 10 me = m-1 + je = ie + if(ie.gt.0) go to 20 + me = m + je = 1 + 20 if(iopt.lt.0) go to 60 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s +c determine nmax, the number of knots for spline interpolation. + kbe = k1-jb-je + mmin = kbe+2 + mm = m-mmin + nmax = nmin+mm + if(s.gt.0.) go to 40 +c if s=0, s(u) is an interpolating curve. +c test whether the required storage space exceeds the available one. + n = nmax + if(nmax.gt.nest) go to 420 +c find the position of the interior knots in case of interpolation. + if(mm.eq.0) go to 60 + 25 i = k2 + j = 3-jb+k/2 + do 30 l=1,mm + t(i) = u(j) + i = i+1 + j = j+1 + 30 continue + go to 60 +c if s>0 our initial choice of knots depends on the value of iopt. +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c polynomial curve which is a spline curve without interior knots. +c if iopt=1 and fp0>s we start computing the least squares spline curve +c according to the set of knots found at the last call of the routine. + 40 if(iopt.eq.0) go to 50 + if(n.eq.nmin) go to 50 + fp0 = fpint(n) + fpold = fpint(n-1) + nplus = nrdata(n) + if(fp0.gt.s) go to 60 + 50 n = nmin + fpold = 0. + nplus = 0 + nrdata(1) = m-2 +c main loop for the different sets of knots. m is a save upper bound +c for the number of trials. + 60 do 200 iter = 1,m + if(n.eq.nmin) ier = -2 +c find nrint, tne number of knot intervals. + nrint = n-nmin+1 +c find the position of the additional knots which are needed for +c the b-spline representation of s(u). + nk1 = n-k1 + i = n + do 70 j=1,k1 + t(j) = u(1) + t(i) = u(m) + i = i-1 + 70 continue +c compute the b-spline coefficients of the least-squares spline curve +c sinf(u). the observation matrix a is built up row by row and +c reduced to upper triangular form by givens transformations. +c at the same time fp=f(p=inf) is computed. + fp = 0. +c nn denotes the dimension of the splines + nn = nk1-ib-ie +c initialize the b-spline coefficients and the observation matrix a. + do 75 i=1,nc + z(i) = 0. + c(i) = 0. + 75 continue + if(me.lt.mb) go to 134 + if(nn.eq.0) go to 82 + do 80 i=1,nn + do 80 j=1,k1 + a(i,j) = 0. + 80 continue + 82 l = k1 + jj = (mb-1)*idim + do 130 it=mb,me +c fetch the current data point u(it),x(it). + ui = u(it) + wi = w(it) + do 84 j=1,idim + jj = jj+1 + xi(j) = x(jj)*wi + 84 continue +c search for knot interval t(l) <= ui < t(l+1). + 86 if(ui.lt.t(l+1) .or. l.eq.nk1) go to 90 + l = l+1 + go to 86 +c evaluate the (k+1) non-zero b-splines at ui and store them in q. + 90 call fpbspl(t,n,k,ui,l,h) + do 92 i=1,k1 + q(it,i) = h(i) + h(i) = h(i)*wi + 92 continue +c take into account that certain b-spline coefficients must be zero. + lj = k1 + j = nk1-l-ie + if(j.ge.0) go to 94 + lj = lj+j + 94 li = 1 + j = l-k1-ib + if(j.ge.0) go to 96 + li = li-j + j = 0 + 96 if(li.gt.lj) go to 120 +c rotate the new row of the observation matrix into triangle. + do 110 i=li,lj + j = j+1 + piv = h(i) + if(piv.eq.0.) go to 110 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(j,1),cos,sin) +c transformations to right hand side. + j1 = j + do 98 j2 =1,idim + call fprota(cos,sin,xi(j2),z(j1)) + j1 = j1+n + 98 continue + if(i.eq.lj) go to 120 + i2 = 1 + i3 = i+1 + do 100 i1 = i3,lj + i2 = i2+1 +c transformations to left hand side. + call fprota(cos,sin,h(i1),a(j,i2)) + 100 continue + 110 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 120 do 125 j2=1,idim + fp = fp+xi(j2)**2 + 125 continue + 130 continue + if(ier.eq.(-2)) fp0 = fp + fpint(n) = fp0 + fpint(n-1) = fpold + nrdata(n) = nplus +c backward substitution to obtain the b-spline coefficients. + if(nn.eq.0) go to 134 + j1 = 1 + do 132 j2=1,idim + j3 = j1+ib + call fpback(a,z(j1),nn,k1,c(j3),nest) + j1 = j1+n + 132 continue +c test whether the approximation sinf(u) is an acceptable solution. + 134 if(iopt.lt.0) go to 440 + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c if f(p=inf) < s accept the choice of knots. + if(fpms.lt.0.) go to 250 +c if n = nmax, sinf(u) is an interpolating spline curve. + if(n.eq.nmax) go to 430 +c increase the number of knots. +c if n=nest we cannot increase the number of knots because of +c the storage capacity limitation. + if(n.eq.nest) go to 420 +c determine the number of knots nplus we are going to add. + if(ier.eq.0) go to 140 + nplus = 1 + ier = 0 + go to 150 + 140 npl1 = nplus*2 + rn = nplus + if(fpold-fp.gt.acc) npl1 = rn*fpms/(fpold-fp) + nplus = min0(nplus*2,max0(npl1,nplus/2,1)) + 150 fpold = fp +c compute the sum of squared residuals for each knot interval +c t(j+k) <= u(i) <= t(j+k+1) and store it in fpint(j),j=1,2,...nrint. + fpart = 0. + i = 1 + l = k2 + new = 0 + jj = (mb-1)*idim + do 180 it=mb,me + if(u(it).lt.t(l) .or. l.gt.nk1) go to 160 + new = 1 + l = l+1 + 160 term = 0. + l0 = l-k2 + do 175 j2=1,idim + fac = 0. + j1 = l0 + do 170 j=1,k1 + j1 = j1+1 + fac = fac+c(j1)*q(it,j) + 170 continue + jj = jj+1 + term = term+(w(it)*(fac-x(jj)))**2 + l0 = l0+n + 175 continue + fpart = fpart+term + if(new.eq.0) go to 180 + store = term*half + fpint(i) = fpart-store + i = i+1 + fpart = store + new = 0 + 180 continue + fpint(nrint) = fpart + do 190 l=1,nplus +c add a new knot. + call fpknot(u,m,t,n,fpint,nrdata,nrint,nest,1) +c if n=nmax we locate the knots as for interpolation + if(n.eq.nmax) go to 25 +c test whether we cannot further increase the number of knots. + if(n.eq.nest) go to 200 + 190 continue +c restart the computations with the new set of knots. + 200 continue +c test whether the least-squares kth degree polynomial curve is a +c solution of our approximation problem. + 250 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline curve sp(u). c +c ********************************************************** c +c we have determined the number of knots and their position. c +c we now compute the b-spline coefficients of the smoothing curve c +c sp(u). the observation matrix a is extended by the rows of matrix c +c b expressing that the kth derivative discontinuities of sp(u) at c +c the interior knots t(k+2),...t(n-k-1) must be zero. the corres- c +c ponding weights of these additional rows are set to 1/p. c +c iteratively we then have to determine the value of p such that f(p),c +c the sum of squared residuals be = s. we already know that the least c +c squares kth degree polynomial curve corresponds to p=0, and that c +c the least-squares spline curve corresponds to p=infinity. the c +c iteration process which is proposed here, makes use of rational c +c interpolation. since f(p) is a convex and strictly decreasing c +c function of p, it can be approximated by a rational function c +c r(p) = (u*p+v)/(p+w). three values of p(p1,p2,p3) with correspond- c +c ing values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used c +c to calculate the new value of p such that r(p)=s. convergence is c +c guaranteed by taking f1>0 and f3<0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jump of the kth derivative of the +c b-splines at the knots t(l),l=k+2,...n-k-1 and store in b. + call fpdisc(t,n,k2,b,nest) +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = 0. + do 252 i=1,nn + p = p+a(i,1) + 252 continue + rn = nn + p = rn/p + ich1 = 0 + ich3 = 0 + n8 = n-nmin +c iteration process to find the root of f(p) = s. + do 360 iter=1,maxit +c the rows of matrix b with weight 1/p are rotated into the +c triangularised observation matrix a which is stored in g. + pinv = one/p + do 255 i=1,nc + c(i) = z(i) + 255 continue + do 260 i=1,nn + g(i,k2) = 0. + do 260 j=1,k1 + g(i,j) = a(i,j) + 260 continue + do 300 it=1,n8 +c the row of matrix b is rotated into triangle by givens transformation + do 264 i=1,k2 + h(i) = b(it,i)*pinv + 264 continue + do 268 j=1,idim + xi(j) = 0. + 268 continue +c take into account that certain b-spline coefficients must be zero. + if(it.gt.ib) go to 274 + j1 = ib-it+2 + j2 = 1 + do 270 i=j1,k2 + h(j2) = h(i) + j2 = j2+1 + 270 continue + do 272 i=j2,k2 + h(i) = 0. + 272 continue + 274 jj = max0(1,it-ib) + do 290 j=jj,nn + piv = h(1) +c calculate the parameters of the givens transformation. + call fpgivs(piv,g(j,1),cos,sin) +c transformations to right hand side. + j1 = j + do 277 j2=1,idim + call fprota(cos,sin,xi(j2),c(j1)) + j1 = j1+n + 277 continue + if(j.eq.nn) go to 300 + i2 = min0(nn-j,k1) + do 280 i=1,i2 +c transformations to left hand side. + i1 = i+1 + call fprota(cos,sin,h(i1),g(j,i1)) + h(i) = h(i1) + 280 continue + h(i2+1) = 0. + 290 continue + 300 continue +c backward substitution to obtain the b-spline coefficients. + j1 = 1 + do 308 j2=1,idim + j3 = j1+ib + call fpback(g,c(j1),nn,k2,c(j3),nest) + if(ib.eq.0) go to 306 + j3 = j1 + do 304 i=1,ib + c(j3) = 0. + j3 = j3+1 + 304 continue + 306 j1 =j1+n + 308 continue +c computation of f(p). + fp = 0. + l = k2 + jj = (mb-1)*idim + do 330 it=mb,me + if(u(it).lt.t(l) .or. l.gt.nk1) go to 310 + l = l+1 + 310 l0 = l-k2 + term = 0. + do 325 j2=1,idim + fac = 0. + j1 = l0 + do 320 j=1,k1 + j1 = j1+1 + fac = fac+c(j1)*q(it,j) + 320 continue + jj = jj+1 + term = term+(fac-x(jj))**2 + l0 = l0+n + 325 continue + fp = fp+term*w(it)**2 + 330 continue +c test whether the approximation sp(u) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximal number of iterations is reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 340 + if((f2-f3).gt.acc) go to 335 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p=p1*con9 + p2*con1 + go to 360 + 335 if(f2.lt.0.) ich3=1 + 340 if(ich1.ne.0) go to 350 + if((f1-f2).gt.acc) go to 345 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 360 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 360 + 345 if(f2.gt.0.) ich1=1 +c test whether the iteration process proceeds as theoretically +c expected. + 350 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value for p. + p = fprati(p1,f1,p2,f2,p3,f3) + 360 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + 440 return + end Added: branches/Interpolate1D/fitpack/fpcosp.f =================================================================== --- branches/Interpolate1D/fitpack/fpcosp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcosp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,362 @@ + subroutine fpcosp(m,x,y,w,n,t,e,maxtr,maxbin,c,sq,sx,bind,nm,mb,a, + * + * b,const,z,zz,u,q,info,up,left,right,jbind,ibind,ier) +c .. +c ..scalar arguments.. + real*8 sq + integer m,n,maxtr,maxbin,nm,mb,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),t(n),e(n),c(n),sx(m),a(n,4),b(nm,maxbin), + * const(n),z(n),zz(n),u(maxbin),q(m,4) + integer info(maxtr),up(maxtr),left(maxtr),right(maxtr),jbind(mb), + * ibind(mb) + logical bind(n) +c ..local scalars.. + integer count,i,i1,j,j1,j2,j3,k,kdim,k1,k2,k3,k4,k5,k6, + * l,lp1,l1,l2,l3,merk,nbind,number,n1,n4,n6 + real*8 f,wi,xi +c ..local array.. + real*8 h(4) +c ..subroutine references.. +c fpbspl,fpadno,fpdeno,fpfrno,fpseno +c .. +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c if we use the b-spline representation of s(x) our approximation c +c problem results in a quadratic programming problem: c +c find the b-spline coefficients c(j),j=1,2,...n-4 such that c +c (1) sumi((wi*(yi-sumj(cj*nj(xi))))**2),i=1,2,...m is minimal c +c (2) sumj(cj*n''j(t(l+3)))*e(l) <= 0, l=1,2,...n-6. c +c to solve this problem we use the theil-van de panne procedure. c +c if the inequality constraints (2) are numbered from 1 to n-6, c +c this algorithm finds a subset of constraints ibind(1)..ibind(nbind) c +c such that the solution of the minimization problem (1) with these c +c constraints in equality form, satisfies all constraints. such a c +c feasible solution is optimal if the lagrange parameters associated c +c with that problem with equality constraints, are all positive. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c determine n6, the number of inequality constraints. + n6 = n-6 +c fix the parameters which determine these constraints. + do 10 i=1,n6 + const(i) = e(i)*(t(i+4)-t(i+1))/(t(i+5)-t(i+2)) + 10 continue +c initialize the triply linked tree which is used to find the subset +c of constraints ibind(1),...ibind(nbind). + count = 1 + info(1) = 0 + left(1) = 0 + right(1) = 0 + up(1) = 1 + merk = 1 +c set up the normal equations n'nc=n'y where n denotes the m x (n-4) +c observation matrix with elements ni,j = wi*nj(xi) and y is the +c column vector with elements yi*wi. +c from the properties of the b-splines nj(x),j=1,2,...n-4, it follows +c that n'n is a (n-4) x (n-4) positive definit bandmatrix of +c bandwidth 7. the matrices n'n and n'y are built up in a and z. + n4 = n-4 +c initialization + do 20 i=1,n4 + z(i) = 0. + do 20 j=1,4 + a(i,j) = 0. + 20 continue + l = 4 + lp1 = l+1 + do 70 i=1,m +c fetch the current row of the observation matrix. + xi = x(i) + wi = w(i)**2 +c search for knot interval t(l) <= xi < t(l+1) + 30 if(xi.lt.t(lp1) .or. l.eq.n4) go to 40 + l = lp1 + lp1 = l+1 + go to 30 +c evaluate the four non-zero cubic b-splines nj(xi),j=l-3,...l. + 40 call fpbspl(t,n,3,xi,l,h) +c store in q these values h(1),h(2),...h(4). + do 50 j=1,4 + q(i,j) = h(j) + 50 continue +c add the contribution of the current row of the observation matrix +c n to the normal equations. + l3 = l-3 + k1 = 0 + do 60 j1 = l3,l + k1 = k1+1 + f = h(k1) + z(j1) = z(j1)+f*wi*y(i) + k2 = k1 + j2 = 4 + do 60 j3 = j1,l + a(j3,j2) = a(j3,j2)+f*wi*h(k2) + k2 = k2+1 + j2 = j2-1 + 60 continue + 70 continue +c since n'n is a symmetric matrix it can be factorized as +c (3) n'n = (r1)'(d1)(r1) +c with d1 a diagonal matrix and r1 an (n-4) x (n-4) unit upper +c triangular matrix of bandwidth 4. the matrices r1 and d1 are built +c up in a. at the same time we solve the systems of equations +c (4) (r1)'(z2) = n'y +c (5) (d1) (z1) = (z2) +c the vectors z2 and z1 are kept in zz and z. + do 140 i=1,n4 + k1 = 1 + if(i.lt.4) k1 = 5-i + k2 = i-4+k1 + k3 = k2 + do 100 j=k1,4 + k4 = j-1 + k5 = 4-j+k1 + f = a(i,j) + if(k1.gt.k4) go to 90 + k6 = k2 + do 80 k=k1,k4 + f = f-a(i,k)*a(k3,k5)*a(k6,4) + k5 = k5+1 + k6 = k6+1 + 80 continue + 90 if(j.eq.4) go to 110 + a(i,j) = f/a(k3,4) + k3 = k3+1 + 100 continue + 110 a(i,4) = f + f = z(i) + if(i.eq.1) go to 130 + k4 = i + do 120 j=k1,3 + k = k1+3-j + k4 = k4-1 + f = f-a(i,k)*z(k4)*a(k4,4) + 120 continue + 130 z(i) = f/a(i,4) + zz(i) = f + 140 continue +c start computing the least-squares cubic spline without taking account +c of any constraint. + nbind = 0 + n1 = 1 + ibind(1) = 0 +c main loop for the least-squares problems with different subsets of +c the constraints (2) in equality form. the resulting b-spline coeff. +c c and lagrange parameters u are the solution of the system +c ! n'n b' ! ! c ! ! n'y ! +c (6) ! ! ! ! = ! ! +c ! b 0 ! ! u ! ! 0 ! +c z1 is stored into array c. + 150 do 160 i=1,n4 + c(i) = z(i) + 160 continue +c if there are no equality constraints, compute the coeff. c directly. + if(nbind.eq.0) go to 370 +c initialization + kdim = n4+nbind + do 170 i=1,nbind + do 170 j=1,kdim + b(j,i) = 0. + 170 continue +c matrix b is built up,expressing that the constraints nrs ibind(1),... +c ibind(nbind) must be satisfied in equality form. + do 180 i=1,nbind + l = ibind(i) + b(l,i) = e(l) + b(l+1,i) = -(e(l)+const(l)) + b(l+2,i) = const(l) + 180 continue +c find the matrix (b1) as the solution of the system of equations +c (7) (r1)'(d1)(b1) = b' +c (b1) is built up in the upper part of the array b(rows 1,...n-4). + do 220 k1=1,nbind + l = ibind(k1) + do 210 i=l,n4 + f = b(i,k1) + if(i.eq.1) go to 200 + k2 = 3 + if(i.lt.4) k2 = i-1 + do 190 k3=1,k2 + l1 = i-k3 + l2 = 4-k3 + f = f-b(l1,k1)*a(i,l2)*a(l1,4) + 190 continue + 200 b(i,k1) = f/a(i,4) + 210 continue + 220 continue +c factorization of the symmetric matrix -(b1)'(d1)(b1) +c (8) -(b1)'(d1)(b1) = (r2)'(d2)(r2) +c with (d2) a diagonal matrix and (r2) an nbind x nbind unit upper +c triangular matrix. the matrices r2 and d2 are built up in the lower +c part of the array b (rows n-3,n-2,...n-4+nbind). + do 270 i=1,nbind + i1 = i-1 + do 260 j=i,nbind + f = 0. + do 230 k=1,n4 + f = f+b(k,i)*b(k,j)*a(k,4) + 230 continue + k1 = n4+1 + if(i1.eq.0) go to 250 + do 240 k=1,i1 + f = f+b(k1,i)*b(k1,j)*b(k1,k) + k1 = k1+1 + 240 continue + 250 b(k1,j) = -f + if(j.eq.i) go to 260 + b(k1,j) = b(k1,j)/b(k1,i) + 260 continue + 270 continue +c according to (3),(7) and (8) the system of equations (6) becomes +c ! (r1)' 0 ! ! (d1) 0 ! ! (r1) (b1) ! ! c ! ! n'y ! +c (9) ! ! ! ! ! ! ! ! = ! ! +c ! (b1)' (r2)'! ! 0 (d2) ! ! 0 (r2) ! ! u ! ! 0 ! +c backward substitution to obtain the b-spline coefficients c(j),j=1,.. +c n-4 and the lagrange parameters u(j),j=1,2,...nbind. +c first step of the backward substitution: solve the system +c ! (r1)'(d1) 0 ! ! (c1) ! ! n'y ! +c (10) ! ! ! ! = ! ! +c ! (b1)'(d1) (r2)'(d2) ! ! (u1) ! ! 0 ! +c from (4) and (5) we know that this is equivalent to +c (11) (c1) = (z1) +c (12) (r2)'(d2)(u1) = -(b1)'(z2) + do 310 i=1,nbind + f = 0. + do 280 j=1,n4 + f = f+b(j,i)*zz(j) + 280 continue + i1 = i-1 + k1 = n4+1 + if(i1.eq.0) go to 300 + do 290 j=1,i1 + f = f+u(j)*b(k1,i)*b(k1,j) + k1 = k1+1 + 290 continue + 300 u(i) = -f/b(k1,i) + 310 continue +c second step of the backward substitution: solve the system +c ! (r1) (b1) ! ! c ! ! c1 ! +c (13) ! ! ! ! = ! ! +c ! 0 (r2) ! ! u ! ! u1 ! + k1 = nbind + k2 = kdim +c find the lagrange parameters u. + do 340 i=1,nbind + f = u(k1) + if(i.eq.1) go to 330 + k3 = k1+1 + do 320 j=k3,nbind + f = f-u(j)*b(k2,j) + 320 continue + 330 u(k1) = f + k1 = k1-1 + k2 = k2-1 + 340 continue +c find the b-spline coefficients c. + do 360 i=1,n4 + f = c(i) + do 350 j=1,nbind + f = f-u(j)*b(i,j) + 350 continue + c(i) = f + 360 continue + 370 k1 = n4 + do 390 i=2,n4 + k1 = k1-1 + f = c(k1) + k2 = 1 + if(i.lt.5) k2 = 5-i + k3 = k1 + l = 3 + do 380 j=k2,3 + k3 = k3+1 + f = f-a(k3,l)*c(k3) + l = l-1 + 380 continue + c(k1) = f + 390 continue +c test whether the solution of the least-squares problem with the +c constraints ibind(1),...ibind(nbind) in equality form, satisfies +c all of the constraints (2). + k = 1 +c number counts the number of violated inequality constraints. + number = 0 + do 440 j=1,n6 + l = ibind(k) + k = k+1 + if(j.eq.l) go to 440 + k = k-1 +c test whether constraint j is satisfied + f = e(j)*(c(j)-c(j+1))+const(j)*(c(j+2)-c(j+1)) + if(f.le.0.) go to 440 +c if constraint j is not satisfied, add a branch of length nbind+1 +c to the tree. the nodes of this branch contain in their information +c field the number of the constraints ibind(1),...ibind(nbind) and j, +c arranged in increasing order. + number = number+1 + k1 = k-1 + if(k1.eq.0) go to 410 + do 400 i=1,k1 + jbind(i) = ibind(i) + 400 continue + 410 jbind(k) = j + if(l.eq.0) go to 430 + do 420 i=k,nbind + jbind(i+1) = ibind(i) + 420 continue + 430 call fpadno(maxtr,up,left,right,info,count,merk,jbind,n1,ier) +c test whether the storage space which is required for the tree,exceeds +c the available storage space. + if(ier.ne.0) go to 560 + 440 continue +c test whether the solution of the least-squares problem with equality +c constraints is a feasible solution. + if(number.eq.0) go to 470 +c test whether there are still cases with nbind constraints in +c equality form to be considered. + 450 if(merk.gt.1) go to 460 + nbind = n1 +c test whether the number of knots where s''(x)=0 exceeds maxbin. + if(nbind.gt.maxbin) go to 550 + n1 = n1+1 + ibind(n1) = 0 +c search which cases with nbind constraints in equality form +c are going to be considered. + call fpdeno(maxtr,up,left,right,nbind,merk) +c test whether the quadratic programming problem has a solution. + if(merk.eq.1) go to 570 +c find a new case with nbind constraints in equality form. + 460 call fpseno(maxtr,up,left,right,info,merk,ibind,nbind) + go to 150 +c test whether the feasible solution is optimal. + 470 ier = 0 + do 480 i=1,n6 + bind(i) = .false. + 480 continue + if(nbind.eq.0) go to 500 + do 490 i=1,nbind + if(u(i).le.0.) go to 450 + j = ibind(i) + bind(j) = .true. + 490 continue +c evaluate s(x) at the data points x(i) and calculate the weighted +c sum of squared residual right hand sides sq. + 500 sq = 0. + l = 4 + lp1 = 5 + do 530 i=1,m + 510 if(x(i).lt.t(lp1) .or. l.eq.n4) go to 520 + l = lp1 + lp1 = l+1 + go to 510 + 520 sx(i) = c(l-3)*q(i,1)+c(l-2)*q(i,2)+c(l-1)*q(i,3)+c(l)*q(i,4) + sq = sq+(w(i)*(y(i)-sx(i)))**2 + 530 continue + go to 600 +c error codes and messages. + 550 ier = 1 + go to 600 + 560 ier = 2 + go to 600 + 570 ier = 3 + 600 return + end Added: branches/Interpolate1D/fitpack/fpcsin.f =================================================================== --- branches/Interpolate1D/fitpack/fpcsin.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcsin.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,56 @@ + subroutine fpcsin(a,b,par,sia,coa,sib,cob,ress,resc) +c fpcsin calculates the integrals ress=integral((b-x)**3*sin(par*x)) +c and resc=integral((b-x)**3*cos(par*x)) over the interval (a,b), +c given sia=sin(par*a),coa=cos(par*a),sib=sin(par*b) and cob=cos(par*b) +c .. +c ..scalar arguments.. + real*8 a,b,par,sia,coa,sib,cob,ress,resc +c ..local scalars.. + integer i,j + real*8 ab,ab4,ai,alfa,beta,b2,b4,eps,fac,f1,f2,one,quart,six, + * three,two +c ..function references.. + real*8 abs +c .. + one = 0.1e+01 + two = 0.2e+01 + three = 0.3e+01 + six = 0.6e+01 + quart = 0.25e+0 + eps = 0.1e-09 + ab = b-a + ab4 = ab**4 + alfa = ab*par +c the way of calculating the integrals ress and resc depends on +c the value of alfa = (b-a)*par. + if(abs(alfa).le.one) go to 100 +c integration by parts. + beta = one/alfa + b2 = beta**2 + b4 = six*b2**2 + f1 = three*b2*(one-two*b2) + f2 = beta*(one-six*b2) + ress = ab4*(coa*f2+sia*f1+sib*b4) + resc = ab4*(coa*f1-sia*f2+cob*b4) + go to 400 +c ress and resc are found by evaluating a series expansion. + 100 fac = quart + f1 = fac + f2 = 0. + i = 4 + do 200 j=1,5 + i = i+1 + ai = i + fac = fac*alfa/ai + f2 = f2+fac + if(abs(fac).le.eps) go to 300 + i = i+1 + ai = i + fac = -fac*alfa/ai + f1 = f1+fac + if(abs(fac).le.eps) go to 300 + 200 continue + 300 ress = ab4*(coa*f2+sia*f1) + resc = ab4*(coa*f1-sia*f2) + 400 return + end Added: branches/Interpolate1D/fitpack/fpcurf.f =================================================================== --- branches/Interpolate1D/fitpack/fpcurf.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcurf.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,359 @@ + subroutine fpcurf(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2, + * n,t,c,fp,fpint,z,a,b,g,q,nrdata,ier) +c .. +c ..scalar arguments.. + real*8 xb,xe,s,tol,fp + integer iopt,m,k,nest,maxit,k1,k2,n,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),t(nest),c(nest),fpint(nest), + * z(nest),a(nest,k1),b(nest,k2),g(nest,k2),q(m,k1) + integer nrdata(nest) +c ..local scalars.. + real*8 acc,con1,con4,con9,cos,half,fpart,fpms,fpold,fp0,f1,f2,f3, + * one,p,pinv,piv,p1,p2,p3,rn,sin,store,term,wi,xi,yi + integer i,ich1,ich3,it,iter,i1,i2,i3,j,k3,l,l0, + * mk1,new,nk1,nmax,nmin,nplus,npl1,nrint,n8 +c ..local arrays.. + real*8 h(7) +c ..function references + real*8 abs,fprati + integer max0,min0 +c ..subroutine references.. +c fpback,fpbspl,fpgivs,fpdisc,fpknot,fprota +c .. +c set constants + one = 0.1d+01 + con1 = 0.1d0 + con9 = 0.9d0 + con4 = 0.4d-01 + half = 0.5d0 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position c +c ************************************************************** c +c given a set of knots we compute the least-squares spline sinf(x), c +c and the corresponding sum of squared residuals fp=f(p=inf). c +c if iopt=-1 sinf(x) is the requested approximation. c +c if iopt=0 or iopt=1 we check whether we can accept the knots: c +c if fp <=s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares spline until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmax = m+k+1. c +c if s > 0 and c +c iopt=0 we first compute the least-squares polynomial of c +c degree k; n = nmin = 2*k+2 c +c iopt=1 we start with the set of knots found at the last c +c call of the routine, except for the case that s > fp0; then c +c we compute directly the least-squares polynomial of degree k. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c determine nmin, the number of knots for polynomial approximation. + nmin = 2*k1 + if(iopt.lt.0) go to 60 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s +c determine nmax, the number of knots for spline interpolation. + nmax = m+k1 + if(s.gt.0.0d0) go to 45 +c if s=0, s(x) is an interpolating spline. +c test whether the required storage space exceeds the available one. + n = nmax + if(nmax.gt.nest) go to 420 +c find the position of the interior knots in case of interpolation. + 10 mk1 = m-k1 + if(mk1.eq.0) go to 60 + k3 = k/2 + i = k2 + j = k3+2 + if(k3*2.eq.k) go to 30 + do 20 l=1,mk1 + t(i) = x(j) + i = i+1 + j = j+1 + 20 continue + go to 60 + 30 do 40 l=1,mk1 + t(i) = (x(j)+x(j-1))*half + i = i+1 + j = j+1 + 40 continue + go to 60 +c if s>0 our initial choice of knots depends on the value of iopt. +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c polynomial of degree k which is a spline without interior knots. +c if iopt=1 and fp0>s we start computing the least squares spline +c according to the set of knots found at the last call of the routine. + 45 if(iopt.eq.0) go to 50 + if(n.eq.nmin) go to 50 + fp0 = fpint(n) + fpold = fpint(n-1) + nplus = nrdata(n) + if(fp0.gt.s) go to 60 + 50 n = nmin + fpold = 0.0d0 + nplus = 0 + nrdata(1) = m-2 +c main loop for the different sets of knots. m is a save upper bound +c for the number of trials. + 60 do 200 iter = 1,m + if(n.eq.nmin) ier = -2 +c find nrint, tne number of knot intervals. + nrint = n-nmin+1 +c find the position of the additional knots which are needed for +c the b-spline representation of s(x). + nk1 = n-k1 + i = n + do 70 j=1,k1 + t(j) = xb + t(i) = xe + i = i-1 + 70 continue +c compute the b-spline coefficients of the least-squares spline +c sinf(x). the observation matrix a is built up row by row and +c reduced to upper triangular form by givens transformations. +c at the same time fp=f(p=inf) is computed. + fp = 0.0d0 +c initialize the observation matrix a. + do 80 i=1,nk1 + z(i) = 0.0d0 + do 80 j=1,k1 + a(i,j) = 0.0d0 + 80 continue + l = k1 + do 130 it=1,m +c fetch the current data point x(it),y(it). + xi = x(it) + wi = w(it) + yi = y(it)*wi +c search for knot interval t(l) <= xi < t(l+1). + 85 if(xi.lt.t(l+1) .or. l.eq.nk1) go to 90 + l = l+1 + go to 85 +c evaluate the (k+1) non-zero b-splines at xi and store them in q. + 90 call fpbspl(t,n,k,xi,l,h) + do 95 i=1,k1 + q(it,i) = h(i) + h(i) = h(i)*wi + 95 continue +c rotate the new row of the observation matrix into triangle. + j = l-k1 + do 110 i=1,k1 + j = j+1 + piv = h(i) + if(piv.eq.0.0d0) go to 110 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(j,1),cos,sin) +c transformations to right hand side. + call fprota(cos,sin,yi,z(j)) + if(i.eq.k1) go to 120 + i2 = 1 + i3 = i+1 + do 100 i1 = i3,k1 + i2 = i2+1 +c transformations to left hand side. + call fprota(cos,sin,h(i1),a(j,i2)) + 100 continue + 110 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 120 fp = fp+yi*yi + 130 continue + if(ier.eq.(-2)) fp0 = fp + fpint(n) = fp0 + fpint(n-1) = fpold + nrdata(n) = nplus +c backward substitution to obtain the b-spline coefficients. + call fpback(a,z,nk1,k1,c,nest) +c test whether the approximation sinf(x) is an acceptable solution. + if(iopt.lt.0) go to 440 + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c if f(p=inf) < s accept the choice of knots. + if(fpms.lt.0.0d0) go to 250 +c if n = nmax, sinf(x) is an interpolating spline. + if(n.eq.nmax) go to 430 +c increase the number of knots. +c if n=nest we cannot increase the number of knots because of +c the storage capacity limitation. + if(n.eq.nest) go to 420 +c determine the number of knots nplus we are going to add. + if(ier.eq.0) go to 140 + nplus = 1 + ier = 0 + go to 150 + 140 npl1 = nplus*2 + rn = nplus + if(fpold-fp.gt.acc) npl1 = rn*fpms/(fpold-fp) + nplus = min0(nplus*2,max0(npl1,nplus/2,1)) + 150 fpold = fp +c compute the sum((w(i)*(y(i)-s(x(i))))**2) for each knot interval +c t(j+k) <= x(i) <= t(j+k+1) and store it in fpint(j),j=1,2,...nrint. + fpart = 0.0d0 + i = 1 + l = k2 + new = 0 + do 180 it=1,m + if(x(it).lt.t(l) .or. l.gt.nk1) go to 160 + new = 1 + l = l+1 + 160 term = 0.0d0 + l0 = l-k2 + do 170 j=1,k1 + l0 = l0+1 + term = term+c(l0)*q(it,j) + 170 continue + term = (w(it)*(term-y(it)))**2 + fpart = fpart+term + if(new.eq.0) go to 180 + store = term*half + fpint(i) = fpart-store + i = i+1 + fpart = store + new = 0 + 180 continue + fpint(nrint) = fpart + do 190 l=1,nplus +c add a new knot. + call fpknot(x,m,t,n,fpint,nrdata,nrint,nest,1) +c if n=nmax we locate the knots as for interpolation. + if(n.eq.nmax) go to 10 +c test whether we cannot further increase the number of knots. + if(n.eq.nest) go to 200 + 190 continue +c restart the computations with the new set of knots. + 200 continue +c test whether the least-squares kth degree polynomial is a solution +c of our approximation problem. + 250 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline sp(x). c +c *************************************************** c +c we have determined the number of knots and their position. c +c we now compute the b-spline coefficients of the smoothing spline c +c sp(x). the observation matrix a is extended by the rows of matrix c +c b expressing that the kth derivative discontinuities of sp(x) at c +c the interior knots t(k+2),...t(n-k-1) must be zero. the corres- c +c ponding weights of these additional rows are set to 1/p. c +c iteratively we then have to determine the value of p such that c +c f(p)=sum((w(i)*(y(i)-sp(x(i))))**2) be = s. we already know that c +c the least-squares kth degree polynomial corresponds to p=0, and c +c that the least-squares spline corresponds to p=infinity. the c +c iteration process which is proposed here, makes use of rational c +c interpolation. since f(p) is a convex and strictly decreasing c +c function of p, it can be approximated by a rational function c +c r(p) = (u*p+v)/(p+w). three values of p(p1,p2,p3) with correspond- c +c ing values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used c +c to calculate the new value of p such that r(p)=s. convergence is c +c guaranteed by taking f1>0 and f3<0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jump of the kth derivative of the +c b-splines at the knots t(l),l=k+2,...n-k-1 and store in b. + call fpdisc(t,n,k2,b,nest) +c initial value for p. + p1 = 0.0d0 + f1 = fp0-s + p3 = -one + f3 = fpms + p = 0. + do 255 i=1,nk1 + p = p+a(i,1) + 255 continue + rn = nk1 + p = rn/p + ich1 = 0 + ich3 = 0 + n8 = n-nmin +c iteration process to find the root of f(p) = s. + do 360 iter=1,maxit +c the rows of matrix b with weight 1/p are rotated into the +c triangularised observation matrix a which is stored in g. + pinv = one/p + do 260 i=1,nk1 + c(i) = z(i) + g(i,k2) = 0.0d0 + do 260 j=1,k1 + g(i,j) = a(i,j) + 260 continue + do 300 it=1,n8 +c the row of matrix b is rotated into triangle by givens transformation + do 270 i=1,k2 + h(i) = b(it,i)*pinv + 270 continue + yi = 0.0d0 + do 290 j=it,nk1 + piv = h(1) +c calculate the parameters of the givens transformation. + call fpgivs(piv,g(j,1),cos,sin) +c transformations to right hand side. + call fprota(cos,sin,yi,c(j)) + if(j.eq.nk1) go to 300 + i2 = k1 + if(j.gt.n8) i2 = nk1-j + do 280 i=1,i2 +c transformations to left hand side. + i1 = i+1 + call fprota(cos,sin,h(i1),g(j,i1)) + h(i) = h(i1) + 280 continue + h(i2+1) = 0.0d0 + 290 continue + 300 continue +c backward substitution to obtain the b-spline coefficients. + call fpback(g,c,nk1,k2,c,nest) +c computation of f(p). + fp = 0.0d0 + l = k2 + do 330 it=1,m + if(x(it).lt.t(l) .or. l.gt.nk1) go to 310 + l = l+1 + 310 l0 = l-k2 + term = 0.0d0 + do 320 j=1,k1 + l0 = l0+1 + term = term+c(l0)*q(it,j) + 320 continue + fp = fp+(w(it)*(term-y(it)))**2 + 330 continue +c test whether the approximation sp(x) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximal number of iterations is reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 340 + if((f2-f3).gt.acc) go to 335 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p=p1*con9 + p2*con1 + go to 360 + 335 if(f2.lt.0.0d0) ich3=1 + 340 if(ich1.ne.0) go to 350 + if((f1-f2).gt.acc) go to 345 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 360 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 360 + 345 if(f2.gt.0.0d0) ich1=1 +c test whether the iteration process proceeds as theoretically +c expected. + 350 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value for p. + p = fprati(p1,f1,p2,f2,p3,f3) + 360 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + 440 return + end Added: branches/Interpolate1D/fitpack/fpcuro.f =================================================================== --- branches/Interpolate1D/fitpack/fpcuro.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcuro.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,94 @@ + subroutine fpcuro(a,b,c,d,x,n) +c subroutine fpcuro finds the real zeros of a cubic polynomial +c p(x) = a*x**3+b*x**2+c*x+d. +c +c calling sequence: +c call fpcuro(a,b,c,d,x,n) +c +c input parameters: +c a,b,c,d: real values, containing the coefficients of p(x). +c +c output parameters: +c x : real array,length 3, which contains the real zeros of p(x) +c n : integer, giving the number of real zeros of p(x). +c .. +c ..scalar arguments.. + real*8 a,b,c,d + integer n +c ..array argument.. + real*8 x(3) +c ..local scalars.. + integer i + real*8 a1,b1,c1,df,disc,d1,e3,f,four,half,ovfl,pi3,p3,q,r, + * step,tent,three,two,u,u1,u2,y +c ..function references.. + real*8 abs,max,datan,atan2,cos,sign,sqrt +c set constants + two = 0.2d+01 + three = 0.3d+01 + four = 0.4d+01 + ovfl =0.1d+05 + half = 0.5d+0 + tent = 0.1d+0 + e3 = tent/0.3d0 + pi3 = datan(0.1d+01)/0.75d0 + a1 = abs(a) + b1 = abs(b) + c1 = abs(c) + d1 = abs(d) +c test whether p(x) is a third degree polynomial. + if(max(b1,c1,d1).lt.a1*ovfl) go to 300 +c test whether p(x) is a second degree polynomial. + if(max(c1,d1).lt.b1*ovfl) go to 200 +c test whether p(x) is a first degree polynomial. + if(d1.lt.c1*ovfl) go to 100 +c p(x) is a constant function. + n = 0 + go to 800 +c p(x) is a first degree polynomial. + 100 n = 1 + x(1) = -d/c + go to 500 +c p(x) is a second degree polynomial. + 200 disc = c*c-four*b*d + n = 0 + if(disc.lt.0.) go to 800 + n = 2 + u = sqrt(disc) + b1 = b+b + x(1) = (-c+u)/b1 + x(2) = (-c-u)/b1 + go to 500 +c p(x) is a third degree polynomial. + 300 b1 = b/a*e3 + c1 = c/a + d1 = d/a + q = c1*e3-b1*b1 + r = b1*b1*b1+(d1-b1*c1)*half + disc = q*q*q+r*r + if(disc.gt.0.) go to 400 + u = sqrt(abs(q)) + if(r.lt.0.) u = -u + p3 = atan2(sqrt(-disc),abs(r))*e3 + u2 = u+u + n = 3 + x(1) = -u2*cos(p3)-b1 + x(2) = u2*cos(pi3-p3)-b1 + x(3) = u2*cos(pi3+p3)-b1 + go to 500 + 400 u = sqrt(disc) + u1 = -r+u + u2 = -r-u + n = 1 + x(1) = sign(abs(u1)**e3,u1)+sign(abs(u2)**e3,u2)-b1 +c apply a newton iteration to improve the accuracy of the roots. + 500 do 700 i=1,n + y = x(i) + f = ((a*y+b)*y+c)*y+d + df = (three*a*y+two*b)*y+c + step = 0. + if(abs(f).lt.abs(df)*tent) step = f/df + x(i) = y-step + 700 continue + 800 return + end Added: branches/Interpolate1D/fitpack/fpcyt1.f =================================================================== --- branches/Interpolate1D/fitpack/fpcyt1.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcyt1.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,53 @@ + subroutine fpcyt1(a,n,nn) +c (l u)-decomposition of a cyclic tridiagonal matrix with the non-zero +c elements stored as follows +c +c | a(1,2) a(1,3) a(1,1) | +c | a(2,1) a(2,2) a(2,3) | +c | a(3,1) a(3,2) a(3,3) | +c | ............... | +c | a(n-1,1) a(n-1,2) a(n-1,3) | +c | a(n,3) a(n,1) a(n,2) | +c +c .. +c ..scalar arguments.. + integer n,nn +c ..array arguments.. + real*8 a(nn,6) +c ..local scalars.. + real*8 aa,beta,gamma,sum,teta,v,one + integer i,n1,n2 +c .. +c set constant + one = 1 + n2 = n-2 + beta = one/a(1,2) + gamma = a(n,3) + teta = a(1,1)*beta + a(1,4) = beta + a(1,5) = gamma + a(1,6) = teta + sum = gamma*teta + do 10 i=2,n2 + v = a(i-1,3)*beta + aa = a(i,1) + beta = one/(a(i,2)-aa*v) + gamma = -gamma*v + teta = -teta*aa*beta + a(i,4) = beta + a(i,5) = gamma + a(i,6) = teta + sum = sum+gamma*teta + 10 continue + n1 = n-1 + v = a(n2,3)*beta + aa = a(n1,1) + beta = one/(a(n1,2)-aa*v) + gamma = a(n,1)-gamma*v + teta = (a(n1,3)-teta*aa)*beta + a(n1,4) = beta + a(n1,5) = gamma + a(n1,6) = teta + a(n,4) = one/(a(n,2)-(sum+gamma*teta)) + return + end Added: branches/Interpolate1D/fitpack/fpcyt2.f =================================================================== --- branches/Interpolate1D/fitpack/fpcyt2.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpcyt2.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,32 @@ + subroutine fpcyt2(a,n,b,c,nn) +c subroutine fpcyt2 solves a linear n x n system +c a * c = b +c where matrix a is a cyclic tridiagonal matrix, decomposed +c using subroutine fpsyt1. +c .. +c ..scalar arguments.. + integer n,nn +c ..array arguments.. + real*8 a(nn,6),b(n),c(n) +c ..local scalars.. + real*8 cc,sum + integer i,j,j1,n1 +c .. + c(1) = b(1)*a(1,4) + sum = c(1)*a(1,5) + n1 = n-1 + do 10 i=2,n1 + c(i) = (b(i)-a(i,1)*c(i-1))*a(i,4) + sum = sum+c(i)*a(i,5) + 10 continue + cc = (b(n)-sum)*a(n,4) + c(n) = cc + c(n1) = c(n1)-cc*a(n1,6) + j = n1 + do 20 i=3,n + j1 = j-1 + c(j1) = c(j1)-c(j)*a(j1,3)*a(j1,4)-cc*a(j1,6) + j = j1 + 20 continue + return + end Added: branches/Interpolate1D/fitpack/fpdeno.f =================================================================== --- branches/Interpolate1D/fitpack/fpdeno.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpdeno.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,55 @@ + subroutine fpdeno(maxtr,up,left,right,nbind,merk) +c subroutine fpdeno frees the nodes of all branches of a triply linked +c tree with length < nbind by putting to zero their up field. +c on exit the parameter merk points to the terminal node of the +c most left branch of length nbind or takes the value 1 if there +c is no such branch. +c .. +c ..scalar arguments.. + integer maxtr,nbind,merk +c ..array arguments.. + integer up(maxtr),left(maxtr),right(maxtr) +c ..local scalars .. + integer i,j,k,l,niveau,point +c .. + i = 1 + niveau = 0 + 10 point = i + i = left(point) + if(i.eq.0) go to 20 + niveau = niveau+1 + go to 10 + 20 if(niveau.eq.nbind) go to 70 + 30 i = right(point) + j = up(point) + up(point) = 0 + k = left(j) + if(point.ne.k) go to 50 + if(i.ne.0) go to 40 + niveau = niveau-1 + if(niveau.eq.0) go to 80 + point = j + go to 30 + 40 left(j) = i + go to 10 + 50 l = right(k) + if(point.eq.l) go to 60 + k = l + go to 50 + 60 right(k) = i + point = k + 70 i = right(point) + if(i.ne.0) go to 10 + i = up(point) + niveau = niveau-1 + if(niveau.eq.0) go to 80 + point = i + go to 70 + 80 k = 1 + l = left(k) + if(up(l).eq.0) return + 90 merk = k + k = left(k) + if(k.ne.0) go to 90 + return + end Added: branches/Interpolate1D/fitpack/fpdisc.f =================================================================== --- branches/Interpolate1D/fitpack/fpdisc.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpdisc.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,43 @@ + subroutine fpdisc(t,n,k2,b,nest) +c subroutine fpdisc calculates the discontinuity jumps of the kth +c derivative of the b-splines of degree k at the knots t(k+2)..t(n-k-1) +c ..scalar arguments.. + integer n,k2,nest +c ..array arguments.. + real*8 t(n),b(nest,k2) +c ..local scalars.. + real*8 an,fac,prod + integer i,ik,j,jk,k,k1,l,lj,lk,lmk,lp,nk1,nrint +c ..local array.. + real*8 h(12) +c .. + k1 = k2-1 + k = k1-1 + nk1 = n-k1 + nrint = nk1-k + an = nrint + fac = an/(t(nk1+1)-t(k1)) + do 40 l=k2,nk1 + lmk = l-k1 + do 10 j=1,k1 + ik = j+k1 + lj = l+j + lk = lj-k2 + h(j) = t(l)-t(lk) + h(ik) = t(l)-t(lj) + 10 continue + lp = lmk + do 30 j=1,k2 + jk = j + prod = h(j) + do 20 i=1,k + jk = jk+1 + prod = prod*h(jk)*fac + 20 continue + lk = lp+k1 + b(lmk,j) = (t(lk)-t(lp))/prod + lp = lp+1 + 30 continue + 40 continue + return + end Added: branches/Interpolate1D/fitpack/fpfrno.f =================================================================== --- branches/Interpolate1D/fitpack/fpfrno.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpfrno.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,69 @@ + subroutine fpfrno(maxtr,up,left,right,info,point,merk,n1, + * count,ier) +c subroutine fpfrno collects the free nodes (up field zero) of the +c triply linked tree the information of which is kept in the arrays +c up,left,right and info. the maximal length of the branches of the +c tree is given by n1. if no free nodes are found, the error flag +c ier is set to 1. +c .. +c ..scalar arguments.. + integer maxtr,point,merk,n1,count,ier +c ..array arguments.. + integer up(maxtr),left(maxtr),right(maxtr),info(maxtr) +c ..local scalars + integer i,j,k,l,n,niveau +c .. + ier = 1 + if(n1.eq.2) go to 140 + niveau = 1 + count = 2 + 10 j = 0 + i = 1 + 20 if(j.eq.niveau) go to 30 + k = 0 + l = left(i) + if(l.eq.0) go to 110 + i = l + j = j+1 + go to 20 + 30 if (i.lt.count) go to 110 + if (i.eq.count) go to 100 + go to 40 + 40 if(up(count).eq.0) go to 50 + count = count+1 + go to 30 + 50 up(count) = up(i) + left(count) = left(i) + right(count) = right(i) + info(count) = info(i) + if(merk.eq.i) merk = count + if(point.eq.i) point = count + if(k.eq.0) go to 60 + right(k) = count + go to 70 + 60 n = up(i) + left(n) = count + 70 l = left(i) + 80 if(l.eq.0) go to 90 + up(l) = count + l = right(l) + go to 80 + 90 up(i) = 0 + i = count + 100 count = count+1 + 110 l = right(i) + k = i + if(l.eq.0) go to 120 + i = l + go to 20 + 120 l = up(i) + j = j-1 + if(j.eq.0) go to 130 + i = l + go to 110 + 130 niveau = niveau+1 + if(niveau.le.n1) go to 10 + if(count.gt.maxtr) go to 140 + ier = 0 + 140 return + end Added: branches/Interpolate1D/fitpack/fpgivs.f =================================================================== --- branches/Interpolate1D/fitpack/fpgivs.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpgivs.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,20 @@ + subroutine fpgivs(piv,ww,cos,sin) +c subroutine fpgivs calculates the parameters of a givens +c transformation . +c .. +c ..scalar arguments.. + real*8 piv,ww,cos,sin +c ..local scalars.. + real*8 dd,one,store +c ..function references.. + real*8 abs,sqrt +c .. + one = 0.1e+01 + store = abs(piv) + if(store.ge.ww) dd = store*sqrt(one+(ww/piv)**2) + if(store.lt.ww) dd = ww*sqrt(one+(piv/ww)**2) + cos = ww/dd + sin = piv/dd + ww = dd + return + end Added: branches/Interpolate1D/fitpack/fpgrdi.f =================================================================== --- branches/Interpolate1D/fitpack/fpgrdi.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpgrdi.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,600 @@ + subroutine fpgrdi(ifsu,ifsv,ifbu,ifbv,iback,u,mu,v,mv,z,mz,dz, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sq,fp,fpu,fpv,mm,mvnu,spu,spv, + * right,q,au,av1,av2,bu,bv,aa,bb,cc,cosi,nru,nrv) +c .. +c ..scalar arguments.. + real*8 p,sq,fp + integer ifsu,ifsv,ifbu,ifbv,iback,mu,mv,mz,iop0,iop1,nu,nv,nc, + * mm,mvnu +c ..array arguments.. + real*8 u(mu),v(mv),z(mz),dz(3),tu(nu),tv(nv),c(nc),fpu(nu),fpv(nv) + *, + * spu(mu,4),spv(mv,4),right(mm),q(mvnu),au(nu,5),av1(nv,6), + * av2(nv,4),aa(2,mv),bb(2,nv),cc(nv),cosi(2,nv),bu(nu,5),bv(nv,5) + integer nru(mu),nrv(mv) +c ..local scalars.. + real*8 arg,co,dz1,dz2,dz3,fac,fac0,pinv,piv,si,term,one,three,half + * + integer i,ic,ii,ij,ik,iq,irot,it,iz,i0,i1,i2,i3,j,jj,jk,jper, + * j0,j1,k,k1,k2,l,l0,l1,l2,mvv,ncof,nrold,nroldu,nroldv,number, + * numu,numu1,numv,numv1,nuu,nu4,nu7,nu8,nu9,nv11,nv4,nv7,nv8,n1 +c ..local arrays.. + real*8 h(5),h1(5),h2(4) +c ..function references.. + integer min0 + real*8 cos,sin +c ..subroutine references.. +c fpback,fpbspl,fpgivs,fpcyt1,fpcyt2,fpdisc,fpbacp,fprota +c .. +c let +c | (spu) | | (spv) | +c (au) = | ---------- | (av) = | ---------- | +c | (1/p) (bu) | | (1/p) (bv) | +c +c | z ' 0 | +c q = | ------ | +c | 0 ' 0 | +c +c with c : the (nu-4) x (nv-4) matrix which contains the b-spline +c coefficients. +c z : the mu x mv matrix which contains the function values. +c spu,spv: the mu x (nu-4), resp. mv x (nv-4) observation matrices +c according to the least-squares problems in the u-,resp. +c v-direction. +c bu,bv : the (nu-7) x (nu-4),resp. (nv-7) x (nv-4) matrices +c containing the discontinuity jumps of the derivatives +c of the b-splines in the u-,resp.v-variable at the knots +c the b-spline coefficients of the smoothing spline are then calculated +c as the least-squares solution of the following over-determined linear +c system of equations +c +c (1) (av) c (au)' = q +c +c subject to the constraints +c +c (2) c(i,nv-3+j) = c(i,j), j=1,2,3 ; i=1,2,...,nu-4 +c +c (3) if iop0 = 0 c(1,j) = dz(1) +c iop0 = 1 c(1,j) = dz(1) +c c(2,j) = dz(1)+(dz(2)*cosi(1,j)+dz(3)*cosi(2,j))* +c tu(5)/3. = cc(j) , j=1,2,...nv-4 +c +c (4) if iop1 = 1 c(nu-4,j) = 0, j=1,2,...,nv-4. +c +c set constants + one = 1 + three = 3 + half = 0.5 +c initialization + nu4 = nu-4 + nu7 = nu-7 + nu8 = nu-8 + nu9 = nu-9 + nv4 = nv-4 + nv7 = nv-7 + nv8 = nv-8 + nv11 = nv-11 + nuu = nu4-iop0-iop1-1 + if(p.gt.0.) pinv = one/p +c it depends on the value of the flags ifsu,ifsv,ifbu,ifbv and iop0 and +c on the value of p whether the matrices (spu), (spv), (bu), (bv) and +c (cosi) still must be determined. + if(ifsu.ne.0) go to 30 +c calculate the non-zero elements of the matrix (spu) which is the ob- +c servation matrix according to the least-squares spline approximation +c problem in the u-direction. + l = 4 + l1 = 5 + number = 0 + do 25 it=1,mu + arg = u(it) + 10 if(arg.lt.tu(l1) .or. l.eq.nu4) go to 15 + l = l1 + l1 = l+1 + number = number+1 + go to 10 + 15 call fpbspl(tu,nu,3,arg,l,h) + do 20 i=1,4 + spu(it,i) = h(i) + 20 continue + nru(it) = number + 25 continue + ifsu = 1 +c calculate the non-zero elements of the matrix (spv) which is the ob- +c servation matrix according to the least-squares spline approximation +c problem in the v-direction. + 30 if(ifsv.ne.0) go to 85 + l = 4 + l1 = 5 + number = 0 + do 50 it=1,mv + arg = v(it) + 35 if(arg.lt.tv(l1) .or. l.eq.nv4) go to 40 + l = l1 + l1 = l+1 + number = number+1 + go to 35 + 40 call fpbspl(tv,nv,3,arg,l,h) + do 45 i=1,4 + spv(it,i) = h(i) + 45 continue + nrv(it) = number + 50 continue + ifsv = 1 + if(iop0.eq.0) go to 85 +c calculate the coefficients of the interpolating splines for cos(v) +c and sin(v). + do 55 i=1,nv4 + cosi(1,i) = 0. + cosi(2,i) = 0. + 55 continue + if(nv7.lt.4) go to 85 + do 65 i=1,nv7 + l = i+3 + arg = tv(l) + call fpbspl(tv,nv,3,arg,l,h) + do 60 j=1,3 + av1(i,j) = h(j) + 60 continue + cosi(1,i) = cos(arg) + cosi(2,i) = sin(arg) + 65 continue + call fpcyt1(av1,nv7,nv) + do 80 j=1,2 + do 70 i=1,nv7 + right(i) = cosi(j,i) + 70 continue + call fpcyt2(av1,nv7,right,right,nv) + do 75 i=1,nv7 + cosi(j,i+1) = right(i) + 75 continue + cosi(j,1) = cosi(j,nv7+1) + cosi(j,nv7+2) = cosi(j,2) + cosi(j,nv4) = cosi(j,3) + 80 continue + 85 if(p.le.0.) go to 150 +c calculate the non-zero elements of the matrix (bu). + if(ifbu.ne.0 .or. nu8.eq.0) go to 90 + call fpdisc(tu,nu,5,bu,nu) + ifbu = 1 +c calculate the non-zero elements of the matrix (bv). + 90 if(ifbv.ne.0 .or. nv8.eq.0) go to 150 + call fpdisc(tv,nv,5,bv,nv) + ifbv = 1 +c substituting (2),(3) and (4) into (1), we obtain the overdetermined +c system +c (5) (avv) (cr) (auu)' = (qq) +c from which the nuu*nv7 remaining coefficients +c c(i,j) , i=2+iop0,3+iop0,...,nu-4-iop1 ; j=1,2,...,nv-7 , +c the elements of (cr), are then determined in the least-squares sense. +c simultaneously, we compute the resulting sum of squared residuals sq. + 150 dz1 = dz(1) + do 155 i=1,mv + aa(1,i) = dz1 + 155 continue + if(nv8.eq.0 .or. p.le.0.) go to 165 + do 160 i=1,nv8 + bb(1,i) = 0. + 160 continue + 165 mvv = mv + if(iop0.eq.0) go to 220 + fac = tu(5)/three + dz2 = dz(2)*fac + dz3 = dz(3)*fac + do 170 i=1,nv4 + cc(i) = dz1+dz2*cosi(1,i)+dz3*cosi(2,i) + 170 continue + do 190 i=1,mv + number = nrv(i) + fac = 0. + do 180 j=1,4 + number = number+1 + fac = fac+cc(number)*spv(i,j) + 180 continue + aa(2,i) = fac + 190 continue + if(nv8.eq.0 .or. p.le.0.) go to 220 + do 210 i=1,nv8 + number = i + fac = 0. + do 200 j=1,5 + fac = fac+cc(number)*bv(i,j) + number = number+1 + 200 continue + bb(2,i) = fac*pinv + 210 continue + mvv = mvv+nv8 +c we first determine the matrices (auu) and (qq). then we reduce the +c matrix (auu) to upper triangular form (ru) using givens rotations. +c we apply the same transformations to the rows of matrix qq to obtain +c the (mv+nv8) x nuu matrix g. +c we store matrix (ru) into au and g into q. + 220 l = mvv*nuu +c initialization. + sq = 0. + do 230 i=1,l + q(i) = 0. + 230 continue + do 240 i=1,nuu + do 240 j=1,5 + au(i,j) = 0. + 240 continue + l = 0 + nrold = 0 + n1 = nrold+1 + do 420 it=1,mu + number = nru(it) +c find the appropriate column of q. + 250 do 260 j=1,mvv + right(j) = 0. + 260 continue + if(nrold.eq.number) go to 280 + if(p.le.0.) go to 410 +c fetch a new row of matrix (bu). + do 270 j=1,5 + h(j) = bu(n1,j)*pinv + 270 continue + i0 = 1 + i1 = 5 + go to 310 +c fetch a new row of matrix (spu). + 280 do 290 j=1,4 + h(j) = spu(it,j) + 290 continue +c find the appropriate column of q. + do 300 j=1,mv + l = l+1 + right(j) = z(l) + 300 continue + i0 = 1 + i1 = 4 + 310 if(nu7-number .eq. iop1) i1 = i1-1 + j0 = n1 +c take into account that we eliminate the constraints (3) + 320 if(j0-1.gt.iop0) go to 360 + fac0 = h(i0) + do 330 j=1,mv + right(j) = right(j)-fac0*aa(j0,j) + 330 continue + if(mv.eq.mvv) go to 350 + j = mv + do 340 jj=1,nv8 + j = j+1 + right(j) = right(j)-fac0*bb(j0,jj) + 340 continue + 350 j0 = j0+1 + i0 = i0+1 + go to 320 + 360 irot = nrold-iop0-1 + if(irot.lt.0) irot = 0 +c rotate the new row of matrix (auu) into triangle. + do 390 i=i0,i1 + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 390 +c calculate the parameters of the givens transformation. + call fpgivs(piv,au(irot,1),co,si) +c apply that transformation to the rows of matrix (qq). + iq = (irot-1)*mvv + do 370 j=1,mvv + iq = iq+1 + call fprota(co,si,right(j),q(iq)) + 370 continue +c apply that transformation to the columns of (auu). + if(i.eq.i1) go to 390 + i2 = 1 + i3 = i+1 + do 380 j=i3,i1 + i2 = i2+1 + call fprota(co,si,h(j),au(irot,i2)) + 380 continue + 390 continue +c we update the sum of squared residuals + do 395 j=1,mvv + sq = sq+right(j)**2 + 395 continue + 400 if(nrold.eq.number) go to 420 + 410 nrold = n1 + n1 = n1+1 + go to 250 + 420 continue +c we determine the matrix (avv) and then we reduce her to +c upper triangular form (rv) using givens rotations. +c we apply the same transformations to the columns of matrix +c g to obtain the (nv-7) x (nu-5-iop0-iop1) matrix h. +c we store matrix (rv) into av1 and av2, h into c. +c the nv7 x nv7 upper triangular matrix (rv) has the form +c | av1 ' | +c (rv) = | ' av2 | +c | 0 ' | +c with (av2) a nv7 x 4 matrix and (av1) a nv11 x nv11 upper +c triangular matrix of bandwidth 5. + ncof = nuu*nv7 +c initialization. + do 430 i=1,ncof + c(i) = 0. + 430 continue + do 440 i=1,nv4 + av1(i,5) = 0. + do 440 j=1,4 + av1(i,j) = 0. + av2(i,j) = 0. + 440 continue + jper = 0 + nrold = 0 + do 770 it=1,mv + number = nrv(it) + 450 if(nrold.eq.number) go to 480 + if(p.le.0.) go to 760 +c fetch a new row of matrix (bv). + n1 = nrold+1 + do 460 j=1,5 + h(j) = bv(n1,j)*pinv + 460 continue +c find the appropiate row of g. + do 465 j=1,nuu + right(j) = 0. + 465 continue + if(mv.eq.mvv) go to 510 + l = mv+n1 + do 470 j=1,nuu + right(j) = q(l) + l = l+mvv + 470 continue + go to 510 +c fetch a new row of matrix (spv) + 480 h(5) = 0. + do 490 j=1,4 + h(j) = spv(it,j) + 490 continue +c find the appropiate row of g. + l = it + do 500 j=1,nuu + right(j) = q(l) + l = l+mvv + 500 continue +c test whether there are non-zero values in the new row of (avv) +c corresponding to the b-splines n(j,v),j=nv7+1,...,nv4. + 510 if(nrold.lt.nv11) go to 710 + if(jper.ne.0) go to 550 +c initialize the matrix (av2). + jk = nv11+1 + do 540 i=1,4 + ik = jk + do 520 j=1,5 + if(ik.le.0) go to 530 + av2(ik,i) = av1(ik,j) + ik = ik-1 + 520 continue + 530 jk = jk+1 + 540 continue + jper = 1 +c if one of the non-zero elements of the new row corresponds to one of +c the b-splines n(j;v),j=nv7+1,...,nv4, we take account of condition +c (2) for setting up this row of (avv). the row is stored in h1( the +c part with respect to av1) and h2 (the part with respect to av2). + 550 do 560 i=1,4 + h1(i) = 0. + h2(i) = 0. + 560 continue + h1(5) = 0. + j = nrold-nv11 + do 600 i=1,5 + j = j+1 + l0 = j + 570 l1 = l0-4 + if(l1.le.0) go to 590 + if(l1.le.nv11) go to 580 + l0 = l1-nv11 + go to 570 + 580 h1(l1) = h(i) + go to 600 + 590 h2(l0) = h2(l0) + h(i) + 600 continue +c rotate the new row of (avv) into triangle. + if(nv11.le.0) go to 670 +c rotations with the rows 1,2,...,nv11 of (avv). + do 660 j=1,nv11 + piv = h1(1) + i2 = min0(nv11-j,4) + if(piv.eq.0.) go to 640 +c calculate the parameters of the givens transformation. + call fpgivs(piv,av1(j,1),co,si) +c apply that transformation to the columns of matrix g. + ic = j + do 610 i=1,nuu + call fprota(co,si,right(i),c(ic)) + ic = ic+nv7 + 610 continue +c apply that transformation to the rows of (avv) with respect to av2. + do 620 i=1,4 + call fprota(co,si,h2(i),av2(j,i)) + 620 continue +c apply that transformation to the rows of (avv) with respect to av1. + if(i2.eq.0) go to 670 + do 630 i=1,i2 + i1 = i+1 + call fprota(co,si,h1(i1),av1(j,i1)) + 630 continue + 640 do 650 i=1,i2 + h1(i) = h1(i+1) + 650 continue + h1(i2+1) = 0. + 660 continue +c rotations with the rows nv11+1,...,nv7 of avv. + 670 do 700 j=1,4 + ij = nv11+j + if(ij.le.0) go to 700 + piv = h2(j) + if(piv.eq.0.) go to 700 +c calculate the parameters of the givens transformation. + call fpgivs(piv,av2(ij,j),co,si) +c apply that transformation to the columns of matrix g. + ic = ij + do 680 i=1,nuu + call fprota(co,si,right(i),c(ic)) + ic = ic+nv7 + 680 continue + if(j.eq.4) go to 700 +c apply that transformation to the rows of (avv) with respect to av2. + j1 = j+1 + do 690 i=j1,4 + call fprota(co,si,h2(i),av2(ij,i)) + 690 continue + 700 continue +c we update the sum of squared residuals + do 705 i=1,nuu + sq = sq+right(i)**2 + 705 continue + go to 750 +c rotation into triangle of the new row of (avv), in case the elements +c corresponding to the b-splines n(j;v),j=nv7+1,...,nv4 are all zero. + 710 irot =nrold + do 740 i=1,5 + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 740 +c calculate the parameters of the givens transformation. + call fpgivs(piv,av1(irot,1),co,si) +c apply that transformation to the columns of matrix g. + ic = irot + do 720 j=1,nuu + call fprota(co,si,right(j),c(ic)) + ic = ic+nv7 + 720 continue +c apply that transformation to the rows of (avv). + if(i.eq.5) go to 740 + i2 = 1 + i3 = i+1 + do 730 j=i3,5 + i2 = i2+1 + call fprota(co,si,h(j),av1(irot,i2)) + 730 continue + 740 continue +c we update the sum of squared residuals + do 745 i=1,nuu + sq = sq+right(i)**2 + 745 continue + 750 if(nrold.eq.number) go to 770 + 760 nrold = nrold+1 + go to 450 + 770 continue +c test whether the b-spline coefficients must be determined. + if(iback.ne.0) return +c backward substitution to obtain the b-spline coefficients as the +c solution of the linear system (rv) (cr) (ru)' = h. +c first step: solve the system (rv) (c1) = h. + k = 1 + do 780 i=1,nuu + call fpbacp(av1,av2,c(k),nv7,4,c(k),5,nv) + k = k+nv7 + 780 continue +c second step: solve the system (cr) (ru)' = (c1). + k = 0 + do 800 j=1,nv7 + k = k+1 + l = k + do 790 i=1,nuu + right(i) = c(l) + l = l+nv7 + 790 continue + call fpback(au,right,nuu,5,right,nu) + l = k + do 795 i=1,nuu + c(l) = right(i) + l = l+nv7 + 795 continue + 800 continue +c calculate from the conditions (2)-(3)-(4), the remaining b-spline +c coefficients. + ncof = nu4*nv4 + i = nv4 + j = 0 + do 805 l=1,nv4 + q(l) = dz1 + 805 continue + if(iop0.eq.0) go to 815 + do 810 l=1,nv4 + i = i+1 + q(i) = cc(l) + 810 continue + 815 if(nuu.eq.0) go to 850 + do 840 l=1,nuu + ii = i + do 820 k=1,nv7 + i = i+1 + j = j+1 + q(i) = c(j) + 820 continue + do 830 k=1,3 + ii = ii+1 + i = i+1 + q(i) = q(ii) + 830 continue + 840 continue + 850 if(iop1.eq.0) go to 870 + do 860 l=1,nv4 + i = i+1 + q(i) = 0. + 860 continue + 870 do 880 i=1,ncof + c(i) = q(i) + 880 continue +c calculate the quantities +c res(i,j) = (z(i,j) - s(u(i),v(j)))**2 , i=1,2,..,mu;j=1,2,..,mv +c fp = sumi=1,mu(sumj=1,mv(res(i,j))) +c fpu(r) = sum''i(sumj=1,mv(res(i,j))) , r=1,2,...,nu-7 +c tu(r+3) <= u(i) <= tu(r+4) +c fpv(r) = sumi=1,mu(sum''j(res(i,j))) , r=1,2,...,nv-7 +c tv(r+3) <= v(j) <= tv(r+4) + fp = 0. + do 890 i=1,nu + fpu(i) = 0. + 890 continue + do 900 i=1,nv + fpv(i) = 0. + 900 continue + iz = 0 + nroldu = 0 +c main loop for the different grid points. + do 950 i1=1,mu + numu = nru(i1) + numu1 = numu+1 + nroldv = 0 + do 940 i2=1,mv + numv = nrv(i2) + numv1 = numv+1 + iz = iz+1 +c evaluate s(u,v) at the current grid point by making the sum of the +c cross products of the non-zero b-splines at (u,v), multiplied with +c the appropiate b-spline coefficients. + term = 0. + k1 = numu*nv4+numv + do 920 l1=1,4 + k2 = k1 + fac = spu(i1,l1) + do 910 l2=1,4 + k2 = k2+1 + term = term+fac*spv(i2,l2)*c(k2) + 910 continue + k1 = k1+nv4 + 920 continue +c calculate the squared residual at the current grid point. + term = (z(iz)-term)**2 +c adjust the different parameters. + fp = fp+term + fpu(numu1) = fpu(numu1)+term + fpv(numv1) = fpv(numv1)+term + fac = term*half + if(numv.eq.nroldv) go to 930 + fpv(numv1) = fpv(numv1)-fac + fpv(numv) = fpv(numv)+fac + 930 nroldv = numv + if(numu.eq.nroldu) go to 940 + fpu(numu1) = fpu(numu1)-fac + fpu(numu) = fpu(numu)+fac + 940 continue + nroldu = numu + 950 continue + return + end Added: branches/Interpolate1D/fitpack/fpgrpa.f =================================================================== --- branches/Interpolate1D/fitpack/fpgrpa.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpgrpa.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,313 @@ + subroutine fpgrpa(ifsu,ifsv,ifbu,ifbv,idim,ipar,u,mu,v,mv,z,mz, + * tu,nu,tv,nv,p,c,nc,fp,fpu,fpv,mm,mvnu,spu,spv,right,q,au,au1, + * av,av1,bu,bv,nru,nrv) +c .. +c ..scalar arguments.. + real*8 p,fp + integer ifsu,ifsv,ifbu,ifbv,idim,mu,mv,mz,nu,nv,nc,mm,mvnu +c ..array arguments.. + real*8 u(mu),v(mv),z(mz*idim),tu(nu),tv(nv),c(nc*idim),fpu(nu), + * fpv(nv),spu(mu,4),spv(mv,4),right(mm*idim),q(mvnu),au(nu,5), + * au1(nu,4),av(nv,5),av1(nv,4),bu(nu,5),bv(nv,5) + integer ipar(2),nru(mu),nrv(mv) +c ..local scalars.. + real*8 arg,fac,term,one,half,value + integer i,id,ii,it,iz,i1,i2,j,jz,k,k1,k2,l,l1,l2,mvv,k0,muu, + * ncof,nroldu,nroldv,number,nmd,numu,numu1,numv,numv1,nuu,nvv, + * nu4,nu7,nu8,nv4,nv7,nv8 +c ..local arrays.. + real*8 h(5) +c ..subroutine references.. +c fpback,fpbspl,fpdisc,fpbacp,fptrnp,fptrpe +c .. +c let +c | (spu) | | (spv) | +c (au) = | ---------- | (av) = | ---------- | +c | (1/p) (bu) | | (1/p) (bv) | +c +c | z ' 0 | +c q = | ------ | +c | 0 ' 0 | +c +c with c : the (nu-4) x (nv-4) matrix which contains the b-spline +c coefficients. +c z : the mu x mv matrix which contains the function values. +c spu,spv: the mu x (nu-4), resp. mv x (nv-4) observation matrices +c according to the least-squares problems in the u-,resp. +c v-direction. +c bu,bv : the (nu-7) x (nu-4),resp. (nv-7) x (nv-4) matrices +c containing the discontinuity jumps of the derivatives +c of the b-splines in the u-,resp.v-variable at the knots +c the b-spline coefficients of the smoothing spline are then calculated +c as the least-squares solution of the following over-determined linear +c system of equations +c +c (1) (av) c (au)' = q +c +c subject to the constraints +c +c (2) c(nu-3+i,j) = c(i,j), i=1,2,3 ; j=1,2,...,nv-4 +c if(ipar(1).ne.0) +c +c (3) c(i,nv-3+j) = c(i,j), j=1,2,3 ; i=1,2,...,nu-4 +c if(ipar(2).ne.0) +c +c set constants + one = 1 + half = 0.5 +c initialization + nu4 = nu-4 + nu7 = nu-7 + nu8 = nu-8 + nv4 = nv-4 + nv7 = nv-7 + nv8 = nv-8 + muu = mu + if(ipar(1).ne.0) muu = mu-1 + mvv = mv + if(ipar(2).ne.0) mvv = mv-1 +c it depends on the value of the flags ifsu,ifsv,ifbu and ibvand +c on the value of p whether the matrices (spu), (spv), (bu) and (bv) +c still must be determined. + if(ifsu.ne.0) go to 50 +c calculate the non-zero elements of the matrix (spu) which is the ob- +c servation matrix according to the least-squares spline approximation +c problem in the u-direction. + l = 4 + l1 = 5 + number = 0 + do 40 it=1,muu + arg = u(it) + 10 if(arg.lt.tu(l1) .or. l.eq.nu4) go to 20 + l = l1 + l1 = l+1 + number = number+1 + go to 10 + 20 call fpbspl(tu,nu,3,arg,l,h) + do 30 i=1,4 + spu(it,i) = h(i) + 30 continue + nru(it) = number + 40 continue + ifsu = 1 +c calculate the non-zero elements of the matrix (spv) which is the ob- +c servation matrix according to the least-squares spline approximation +c problem in the v-direction. + 50 if(ifsv.ne.0) go to 100 + l = 4 + l1 = 5 + number = 0 + do 90 it=1,mvv + arg = v(it) + 60 if(arg.lt.tv(l1) .or. l.eq.nv4) go to 70 + l = l1 + l1 = l+1 + number = number+1 + go to 60 + 70 call fpbspl(tv,nv,3,arg,l,h) + do 80 i=1,4 + spv(it,i) = h(i) + 80 continue + nrv(it) = number + 90 continue + ifsv = 1 + 100 if(p.le.0.) go to 150 +c calculate the non-zero elements of the matrix (bu). + if(ifbu.ne.0 .or. nu8.eq.0) go to 110 + call fpdisc(tu,nu,5,bu,nu) + ifbu = 1 +c calculate the non-zero elements of the matrix (bv). + 110 if(ifbv.ne.0 .or. nv8.eq.0) go to 150 + call fpdisc(tv,nv,5,bv,nv) + ifbv = 1 +c substituting (2) and (3) into (1), we obtain the overdetermined +c system +c (4) (avv) (cr) (auu)' = (qq) +c from which the nuu*nvv remaining coefficients +c c(i,j) , i=1,...,nu-4-3*ipar(1) ; j=1,...,nv-4-3*ipar(2) , +c the elements of (cr), are then determined in the least-squares sense. +c we first determine the matrices (auu) and (qq). then we reduce the +c matrix (auu) to upper triangular form (ru) using givens rotations. +c we apply the same transformations to the rows of matrix qq to obtain +c the (mv) x nuu matrix g. +c we store matrix (ru) into au (and au1 if ipar(1)=1) and g into q. + 150 if(ipar(1).ne.0) go to 160 + nuu = nu4 + call fptrnp(mu,mv,idim,nu,nru,spu,p,bu,z,au,q,right) + go to 180 + 160 nuu = nu7 + call fptrpe(mu,mv,idim,nu,nru,spu,p,bu,z,au,au1,q,right) +c we determine the matrix (avv) and then we reduce this matrix to +c upper triangular form (rv) using givens rotations. +c we apply the same transformations to the columns of matrix +c g to obtain the (nvv) x (nuu) matrix h. +c we store matrix (rv) into av (and av1 if ipar(2)=1) and h into c. + 180 if(ipar(2).ne.0) go to 190 + nvv = nv4 + call fptrnp(mv,nuu,idim,nv,nrv,spv,p,bv,q,av,c,right) + go to 200 + 190 nvv = nv7 + call fptrpe(mv,nuu,idim,nv,nrv,spv,p,bv,q,av,av1,c,right) +c backward substitution to obtain the b-spline coefficients as the +c solution of the linear system (rv) (cr) (ru)' = h. +c first step: solve the system (rv) (c1) = h. + 200 ncof = nuu*nvv + k = 1 + if(ipar(2).ne.0) go to 240 + do 220 ii=1,idim + do 220 i=1,nuu + call fpback(av,c(k),nvv,5,c(k),nv) + k = k+nvv + 220 continue + go to 300 + 240 do 260 ii=1,idim + do 260 i=1,nuu + call fpbacp(av,av1,c(k),nvv,4,c(k),5,nv) + k = k+nvv + 260 continue +c second step: solve the system (cr) (ru)' = (c1). + 300 if(ipar(1).ne.0) go to 400 + do 360 ii=1,idim + k = (ii-1)*ncof + do 360 j=1,nvv + k = k+1 + l = k + do 320 i=1,nuu + right(i) = c(l) + l = l+nvv + 320 continue + call fpback(au,right,nuu,5,right,nu) + l = k + do 340 i=1,nuu + c(l) = right(i) + l = l+nvv + 340 continue + 360 continue + go to 500 + 400 do 460 ii=1,idim + k = (ii-1)*ncof + do 460 j=1,nvv + k = k+1 + l = k + do 420 i=1,nuu + right(i) = c(l) + l = l+nvv + 420 continue + call fpbacp(au,au1,right,nuu,4,right,5,nu) + l = k + do 440 i=1,nuu + c(l) = right(i) + l = l+nvv + 440 continue + 460 continue +c calculate from the conditions (2)-(3), the remaining b-spline +c coefficients. + 500 if(ipar(2).eq.0) go to 600 + i = 0 + j = 0 + do 560 id=1,idim + do 560 l=1,nuu + ii = i + do 520 k=1,nvv + i = i+1 + j = j+1 + q(i) = c(j) + 520 continue + do 540 k=1,3 + ii = ii+1 + i = i+1 + q(i) = q(ii) + 540 continue + 560 continue + ncof = nv4*nuu + nmd = ncof*idim + do 580 i=1,nmd + c(i) = q(i) + 580 continue + 600 if(ipar(1).eq.0) go to 700 + i = 0 + j = 0 + n33 = 3*nv4 + do 660 id=1,idim + ii = i + do 620 k=1,ncof + i = i+1 + j = j+1 + q(i) = c(j) + 620 continue + do 640 k=1,n33 + ii = ii+1 + i = i+1 + q(i) = q(ii) + 640 continue + 660 continue + ncof = nv4*nu4 + nmd = ncof*idim + do 680 i=1,nmd + c(i) = q(i) + 680 continue +c calculate the quantities +c res(i,j) = (z(i,j) - s(u(i),v(j)))**2 , i=1,2,..,mu;j=1,2,..,mv +c fp = sumi=1,mu(sumj=1,mv(res(i,j))) +c fpu(r) = sum''i(sumj=1,mv(res(i,j))) , r=1,2,...,nu-7 +c tu(r+3) <= u(i) <= tu(r+4) +c fpv(r) = sumi=1,mu(sum''j(res(i,j))) , r=1,2,...,nv-7 +c tv(r+3) <= v(j) <= tv(r+4) + 700 fp = 0. + do 720 i=1,nu + fpu(i) = 0. + 720 continue + do 740 i=1,nv + fpv(i) = 0. + 740 continue + nroldu = 0 +c main loop for the different grid points. + do 860 i1=1,muu + numu = nru(i1) + numu1 = numu+1 + nroldv = 0 + iz = (i1-1)*mv + do 840 i2=1,mvv + numv = nrv(i2) + numv1 = numv+1 + iz = iz+1 +c evaluate s(u,v) at the current grid point by making the sum of the +c cross products of the non-zero b-splines at (u,v), multiplied with +c the appropiate b-spline coefficients. + term = 0. + k0 = numu*nv4+numv + jz = iz + do 800 id=1,idim + k1 = k0 + value = 0. + do 780 l1=1,4 + k2 = k1 + fac = spu(i1,l1) + do 760 l2=1,4 + k2 = k2+1 + value = value+fac*spv(i2,l2)*c(k2) + 760 continue + k1 = k1+nv4 + 780 continue +c calculate the squared residual at the current grid point. + term = term+(z(jz)-value)**2 + jz = jz+mz + k0 = k0+ncof + 800 continue +c adjust the different parameters. + fp = fp+term + fpu(numu1) = fpu(numu1)+term + fpv(numv1) = fpv(numv1)+term + fac = term*half + if(numv.eq.nroldv) go to 820 + fpv(numv1) = fpv(numv1)-fac + fpv(numv) = fpv(numv)+fac + 820 nroldv = numv + if(numu.eq.nroldu) go to 840 + fpu(numu1) = fpu(numu1)-fac + fpu(numu) = fpu(numu)+fac + 840 continue + nroldu = numu + 860 continue + return + end Added: branches/Interpolate1D/fitpack/fpgrre.f =================================================================== --- branches/Interpolate1D/fitpack/fpgrre.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpgrre.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,328 @@ + subroutine fpgrre(ifsx,ifsy,ifbx,ifby,x,mx,y,my,z,mz,kx,ky,tx,nx, + * ty,ny,p,c,nc,fp,fpx,fpy,mm,mynx,kx1,kx2,ky1,ky2,spx,spy,right,q, + * ax,ay,bx,by,nrx,nry) +c .. +c ..scalar arguments.. + real*8 p,fp + integer ifsx,ifsy,ifbx,ifby,mx,my,mz,kx,ky,nx,ny,nc,mm,mynx, + * kx1,kx2,ky1,ky2 +c ..array arguments.. + real*8 x(mx),y(my),z(mz),tx(nx),ty(ny),c(nc),spx(mx,kx1),spy(my,ky + *1) + * ,right(mm),q(mynx),ax(nx,kx2),bx(nx,kx2),ay(ny,ky2),by(ny,ky2), + * fpx(nx),fpy(ny) + integer nrx(mx),nry(my) +c ..local scalars.. + real*8 arg,cos,fac,pinv,piv,sin,term,one,half + integer i,ibandx,ibandy,ic,iq,irot,it,iz,i1,i2,i3,j,k,k1,k2,l, + * l1,l2,ncof,nk1x,nk1y,nrold,nroldx,nroldy,number,numx,numx1, + * numy,numy1,n1 +c ..local arrays.. + real*8 h(7) +c ..subroutine references.. +c fpback,fpbspl,fpgivs,fpdisc,fprota +c .. +c the b-spline coefficients of the smoothing spline are calculated as +c the least-squares solution of the over-determined linear system of +c equations (ay) c (ax)' = q where +c +c | (spx) | | (spy) | +c (ax) = | ---------- | (ay) = | ---------- | +c | (1/p) (bx) | | (1/p) (by) | +c +c | z ' 0 | +c q = | ------ | +c | 0 ' 0 | +c +c with c : the (ny-ky-1) x (nx-kx-1) matrix which contains the +c b-spline coefficients. +c z : the my x mx matrix which contains the function values. +c spx,spy: the mx x (nx-kx-1) and my x (ny-ky-1) observation +c matrices according to the least-squares problems in +c the x- and y-direction. +c bx,by : the (nx-2*kx-1) x (nx-kx-1) and (ny-2*ky-1) x (ny-ky-1) +c matrices which contain the discontinuity jumps of the +c derivatives of the b-splines in the x- and y-direction. + one = 1 + half = 0.5 + nk1x = nx-kx1 + nk1y = ny-ky1 + if(p.gt.0.) pinv = one/p +c it depends on the value of the flags ifsx,ifsy,ifbx and ifby and on +c the value of p whether the matrices (spx),(spy),(bx) and (by) still +c must be determined. + if(ifsx.ne.0) go to 50 +c calculate the non-zero elements of the matrix (spx) which is the +c observation matrix according to the least-squares spline approximat- +c ion problem in the x-direction. + l = kx1 + l1 = kx2 + number = 0 + do 40 it=1,mx + arg = x(it) + 10 if(arg.lt.tx(l1) .or. l.eq.nk1x) go to 20 + l = l1 + l1 = l+1 + number = number+1 + go to 10 + 20 call fpbspl(tx,nx,kx,arg,l,h) + do 30 i=1,kx1 + spx(it,i) = h(i) + 30 continue + nrx(it) = number + 40 continue + ifsx = 1 + 50 if(ifsy.ne.0) go to 100 +c calculate the non-zero elements of the matrix (spy) which is the +c observation matrix according to the least-squares spline approximat- +c ion problem in the y-direction. + l = ky1 + l1 = ky2 + number = 0 + do 90 it=1,my + arg = y(it) + 60 if(arg.lt.ty(l1) .or. l.eq.nk1y) go to 70 + l = l1 + l1 = l+1 + number = number+1 + go to 60 + 70 call fpbspl(ty,ny,ky,arg,l,h) + do 80 i=1,ky1 + spy(it,i) = h(i) + 80 continue + nry(it) = number + 90 continue + ifsy = 1 + 100 if(p.le.0.) go to 120 +c calculate the non-zero elements of the matrix (bx). + if(ifbx.ne.0 .or. nx.eq.2*kx1) go to 110 + call fpdisc(tx,nx,kx2,bx,nx) + ifbx = 1 +c calculate the non-zero elements of the matrix (by). + 110 if(ifby.ne.0 .or. ny.eq.2*ky1) go to 120 + call fpdisc(ty,ny,ky2,by,ny) + ifby = 1 +c reduce the matrix (ax) to upper triangular form (rx) using givens +c rotations. apply the same transformations to the rows of matrix q +c to obtain the my x (nx-kx-1) matrix g. +c store matrix (rx) into (ax) and g into q. + 120 l = my*nk1x +c initialization. + do 130 i=1,l + q(i) = 0. + 130 continue + do 140 i=1,nk1x + do 140 j=1,kx2 + ax(i,j) = 0. + 140 continue + l = 0 + nrold = 0 +c ibandx denotes the bandwidth of the matrices (ax) and (rx). + ibandx = kx1 + do 270 it=1,mx + number = nrx(it) + 150 if(nrold.eq.number) go to 180 + if(p.le.0.) go to 260 + ibandx = kx2 +c fetch a new row of matrix (bx). + n1 = nrold+1 + do 160 j=1,kx2 + h(j) = bx(n1,j)*pinv + 160 continue +c find the appropriate column of q. + do 170 j=1,my + right(j) = 0. + 170 continue + irot = nrold + go to 210 +c fetch a new row of matrix (spx). + 180 h(ibandx) = 0. + do 190 j=1,kx1 + h(j) = spx(it,j) + 190 continue +c find the appropriate column of q. + do 200 j=1,my + l = l+1 + right(j) = z(l) + 200 continue + irot = number +c rotate the new row of matrix (ax) into triangle. + 210 do 240 i=1,ibandx + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 240 +c calculate the parameters of the givens transformation. + call fpgivs(piv,ax(irot,1),cos,sin) +c apply that transformation to the rows of matrix q. + iq = (irot-1)*my + do 220 j=1,my + iq = iq+1 + call fprota(cos,sin,right(j),q(iq)) + 220 continue +c apply that transformation to the columns of (ax). + if(i.eq.ibandx) go to 250 + i2 = 1 + i3 = i+1 + do 230 j=i3,ibandx + i2 = i2+1 + call fprota(cos,sin,h(j),ax(irot,i2)) + 230 continue + 240 continue + 250 if(nrold.eq.number) go to 270 + 260 nrold = nrold+1 + go to 150 + 270 continue +c reduce the matrix (ay) to upper triangular form (ry) using givens +c rotations. apply the same transformations to the columns of matrix g +c to obtain the (ny-ky-1) x (nx-kx-1) matrix h. +c store matrix (ry) into (ay) and h into c. + ncof = nk1x*nk1y +c initialization. + do 280 i=1,ncof + c(i) = 0. + 280 continue + do 290 i=1,nk1y + do 290 j=1,ky2 + ay(i,j) = 0. + 290 continue + nrold = 0 +c ibandy denotes the bandwidth of the matrices (ay) and (ry). + ibandy = ky1 + do 420 it=1,my + number = nry(it) + 300 if(nrold.eq.number) go to 330 + if(p.le.0.) go to 410 + ibandy = ky2 +c fetch a new row of matrix (by). + n1 = nrold+1 + do 310 j=1,ky2 + h(j) = by(n1,j)*pinv + 310 continue +c find the appropiate row of g. + do 320 j=1,nk1x + right(j) = 0. + 320 continue + irot = nrold + go to 360 +c fetch a new row of matrix (spy) + 330 h(ibandy) = 0. + do 340 j=1,ky1 + h(j) = spy(it,j) + 340 continue +c find the appropiate row of g. + l = it + do 350 j=1,nk1x + right(j) = q(l) + l = l+my + 350 continue + irot = number +c rotate the new row of matrix (ay) into triangle. + 360 do 390 i=1,ibandy + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 390 +c calculate the parameters of the givens transformation. + call fpgivs(piv,ay(irot,1),cos,sin) +c apply that transformation to the colums of matrix g. + ic = irot + do 370 j=1,nk1x + call fprota(cos,sin,right(j),c(ic)) + ic = ic+nk1y + 370 continue +c apply that transformation to the columns of matrix (ay). + if(i.eq.ibandy) go to 400 + i2 = 1 + i3 = i+1 + do 380 j=i3,ibandy + i2 = i2+1 + call fprota(cos,sin,h(j),ay(irot,i2)) + 380 continue + 390 continue + 400 if(nrold.eq.number) go to 420 + 410 nrold = nrold+1 + go to 300 + 420 continue +c backward substitution to obtain the b-spline coefficients as the +c solution of the linear system (ry) c (rx)' = h. +c first step: solve the system (ry) (c1) = h. + k = 1 + do 450 i=1,nk1x + call fpback(ay,c(k),nk1y,ibandy,c(k),ny) + k = k+nk1y + 450 continue +c second step: solve the system c (rx)' = (c1). + k = 0 + do 480 j=1,nk1y + k = k+1 + l = k + do 460 i=1,nk1x + right(i) = c(l) + l = l+nk1y + 460 continue + call fpback(ax,right,nk1x,ibandx,right,nx) + l = k + do 470 i=1,nk1x + c(l) = right(i) + l = l+nk1y + 470 continue + 480 continue +c calculate the quantities +c res(i,j) = (z(i,j) - s(x(i),y(j)))**2 , i=1,2,..,mx;j=1,2,..,my +c fp = sumi=1,mx(sumj=1,my(res(i,j))) +c fpx(r) = sum''i(sumj=1,my(res(i,j))) , r=1,2,...,nx-2*kx-1 +c tx(r+kx) <= x(i) <= tx(r+kx+1) +c fpy(r) = sumi=1,mx(sum''j(res(i,j))) , r=1,2,...,ny-2*ky-1 +c ty(r+ky) <= y(j) <= ty(r+ky+1) + fp = 0. + do 490 i=1,nx + fpx(i) = 0. + 490 continue + do 500 i=1,ny + fpy(i) = 0. + 500 continue + nk1y = ny-ky1 + iz = 0 + nroldx = 0 +c main loop for the different grid points. + do 550 i1=1,mx + numx = nrx(i1) + numx1 = numx+1 + nroldy = 0 + do 540 i2=1,my + numy = nry(i2) + numy1 = numy+1 + iz = iz+1 +c evaluate s(x,y) at the current grid point by making the sum of the +c cross products of the non-zero b-splines at (x,y), multiplied with +c the appropiate b-spline coefficients. + term = 0. + k1 = numx*nk1y+numy + do 520 l1=1,kx1 + k2 = k1 + fac = spx(i1,l1) + do 510 l2=1,ky1 + k2 = k2+1 + term = term+fac*spy(i2,l2)*c(k2) + 510 continue + k1 = k1+nk1y + 520 continue +c calculate the squared residual at the current grid point. + term = (z(iz)-term)**2 +c adjust the different parameters. + fp = fp+term + fpx(numx1) = fpx(numx1)+term + fpy(numy1) = fpy(numy1)+term + fac = term*half + if(numy.eq.nroldy) go to 530 + fpy(numy1) = fpy(numy1)-fac + fpy(numy) = fpy(numy)+fac + 530 nroldy = numy + if(numx.eq.nroldx) go to 540 + fpx(numx1) = fpx(numx1)-fac + fpx(numx) = fpx(numx)+fac + 540 continue + nroldx = numx + 550 continue + return + end + Added: branches/Interpolate1D/fitpack/fpgrsp.f =================================================================== --- branches/Interpolate1D/fitpack/fpgrsp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpgrsp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,656 @@ + subroutine fpgrsp(ifsu,ifsv,ifbu,ifbv,iback,u,mu,v,mv,r,mr,dr, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sq,fp,fpu,fpv,mm,mvnu,spu,spv, + * right,q,au,av1,av2,bu,bv,a0,a1,b0,b1,c0,c1,cosi,nru,nrv) +c .. +c ..scalar arguments.. + real*8 p,sq,fp + integer ifsu,ifsv,ifbu,ifbv,iback,mu,mv,mr,iop0,iop1,nu,nv,nc, + * mm,mvnu +c ..array arguments.. + real*8 u(mu),v(mv),r(mr),dr(6),tu(nu),tv(nv),c(nc),fpu(nu),fpv(nv) + *, + * spu(mu,4),spv(mv,4),right(mm),q(mvnu),au(nu,5),av1(nv,6),c0(nv), + * av2(nv,4),a0(2,mv),b0(2,nv),cosi(2,nv),bu(nu,5),bv(nv,5),c1(nv), + * a1(2,mv),b1(2,nv) + integer nru(mu),nrv(mv) +c ..local scalars.. + real*8 arg,co,dr01,dr02,dr03,dr11,dr12,dr13,fac,fac0,fac1,pinv,piv + *, + * si,term,one,three,half + integer i,ic,ii,ij,ik,iq,irot,it,ir,i0,i1,i2,i3,j,jj,jk,jper, + * j0,j1,k,k1,k2,l,l0,l1,l2,mvv,ncof,nrold,nroldu,nroldv,number, + * numu,numu1,numv,numv1,nuu,nu4,nu7,nu8,nu9,nv11,nv4,nv7,nv8,n1 +c ..local arrays.. + real*8 h(5),h1(5),h2(4) +c ..function references.. + integer min0 + real*8 cos,sin +c ..subroutine references.. +c fpback,fpbspl,fpgivs,fpcyt1,fpcyt2,fpdisc,fpbacp,fprota +c .. +c let +c | (spu) | | (spv) | +c (au) = | -------------- | (av) = | -------------- | +c | sqrt(1/p) (bu) | | sqrt(1/p) (bv) | +c +c | r ' 0 | +c q = | ------ | +c | 0 ' 0 | +c +c with c : the (nu-4) x (nv-4) matrix which contains the b-spline +c coefficients. +c r : the mu x mv matrix which contains the function values. +c spu,spv: the mu x (nu-4), resp. mv x (nv-4) observation matrices +c according to the least-squares problems in the u-,resp. +c v-direction. +c bu,bv : the (nu-7) x (nu-4),resp. (nv-7) x (nv-4) matrices +c containing the discontinuity jumps of the derivatives +c of the b-splines in the u-,resp.v-variable at the knots +c the b-spline coefficients of the smoothing spline are then calculated +c as the least-squares solution of the following over-determined linear +c system of equations +c +c (1) (av) c (au)' = q +c +c subject to the constraints +c +c (2) c(i,nv-3+j) = c(i,j), j=1,2,3 ; i=1,2,...,nu-4 +c +c (3) if iop0 = 0 c(1,j) = dr(1) +c iop0 = 1 c(1,j) = dr(1) +c c(2,j) = dr(1)+(dr(2)*cosi(1,j)+dr(3)*cosi(2,j))* +c tu(5)/3. = c0(j) , j=1,2,...nv-4 +c +c (4) if iop1 = 0 c(nu-4,j) = dr(4) +c iop1 = 1 c(nu-4,j) = dr(4) +c c(nu-5,j) = dr(4)+(dr(5)*cosi(1,j)+dr(6)*cosi(2,j)) +c *(tu(nu-4)-tu(nu-3))/3. = c1(j) +c +c set constants + one = 1 + three = 3 + half = 0.5 +c initialization + nu4 = nu-4 + nu7 = nu-7 + nu8 = nu-8 + nu9 = nu-9 + nv4 = nv-4 + nv7 = nv-7 + nv8 = nv-8 + nv11 = nv-11 + nuu = nu4-iop0-iop1-2 + if(p.gt.0.) pinv = one/p +c it depends on the value of the flags ifsu,ifsv,ifbu,ifbv,iop0,iop1 +c and on the value of p whether the matrices (spu), (spv), (bu), (bv), +c (cosi) still must be determined. + if(ifsu.ne.0) go to 30 +c calculate the non-zero elements of the matrix (spu) which is the ob- +c servation matrix according to the least-squares spline approximation +c problem in the u-direction. + l = 4 + l1 = 5 + number = 0 + do 25 it=1,mu + arg = u(it) + 10 if(arg.lt.tu(l1) .or. l.eq.nu4) go to 15 + l = l1 + l1 = l+1 + number = number+1 + go to 10 + 15 call fpbspl(tu,nu,3,arg,l,h) + do 20 i=1,4 + spu(it,i) = h(i) + 20 continue + nru(it) = number + 25 continue + ifsu = 1 +c calculate the non-zero elements of the matrix (spv) which is the ob- +c servation matrix according to the least-squares spline approximation +c problem in the v-direction. + 30 if(ifsv.ne.0) go to 85 + l = 4 + l1 = 5 + number = 0 + do 50 it=1,mv + arg = v(it) + 35 if(arg.lt.tv(l1) .or. l.eq.nv4) go to 40 + l = l1 + l1 = l+1 + number = number+1 + go to 35 + 40 call fpbspl(tv,nv,3,arg,l,h) + do 45 i=1,4 + spv(it,i) = h(i) + 45 continue + nrv(it) = number + 50 continue + ifsv = 1 + if(iop0.eq.0 .and. iop1.eq.0) go to 85 +c calculate the coefficients of the interpolating splines for cos(v) +c and sin(v). + do 55 i=1,nv4 + cosi(1,i) = 0. + cosi(2,i) = 0. + 55 continue + if(nv7.lt.4) go to 85 + do 65 i=1,nv7 + l = i+3 + arg = tv(l) + call fpbspl(tv,nv,3,arg,l,h) + do 60 j=1,3 + av1(i,j) = h(j) + 60 continue + cosi(1,i) = cos(arg) + cosi(2,i) = sin(arg) + 65 continue + call fpcyt1(av1,nv7,nv) + do 80 j=1,2 + do 70 i=1,nv7 + right(i) = cosi(j,i) + 70 continue + call fpcyt2(av1,nv7,right,right,nv) + do 75 i=1,nv7 + cosi(j,i+1) = right(i) + 75 continue + cosi(j,1) = cosi(j,nv7+1) + cosi(j,nv7+2) = cosi(j,2) + cosi(j,nv4) = cosi(j,3) + 80 continue + 85 if(p.le.0.) go to 150 +c calculate the non-zero elements of the matrix (bu). + if(ifbu.ne.0 .or. nu8.eq.0) go to 90 + call fpdisc(tu,nu,5,bu,nu) + ifbu = 1 +c calculate the non-zero elements of the matrix (bv). + 90 if(ifbv.ne.0 .or. nv8.eq.0) go to 150 + call fpdisc(tv,nv,5,bv,nv) + ifbv = 1 +c substituting (2),(3) and (4) into (1), we obtain the overdetermined +c system +c (5) (avv) (cc) (auu)' = (qq) +c from which the nuu*nv7 remaining coefficients +c c(i,j) , i=2+iop0,3+iop0,...,nu-5-iop1,j=1,2,...,nv-7. +c the elements of (cc), are then determined in the least-squares sense. +c simultaneously, we compute the resulting sum of squared residuals sq. + 150 dr01 = dr(1) + dr11 = dr(4) + do 155 i=1,mv + a0(1,i) = dr01 + a1(1,i) = dr11 + 155 continue + if(nv8.eq.0 .or. p.le.0.) go to 165 + do 160 i=1,nv8 + b0(1,i) = 0. + b1(1,i) = 0. + 160 continue + 165 mvv = mv + if(iop0.eq.0) go to 195 + fac = (tu(5)-tu(4))/three + dr02 = dr(2)*fac + dr03 = dr(3)*fac + do 170 i=1,nv4 + c0(i) = dr01+dr02*cosi(1,i)+dr03*cosi(2,i) + 170 continue + do 180 i=1,mv + number = nrv(i) + fac = 0. + do 175 j=1,4 + number = number+1 + fac = fac+c0(number)*spv(i,j) + 175 continue + a0(2,i) = fac + 180 continue + if(nv8.eq.0 .or. p.le.0.) go to 195 + do 190 i=1,nv8 + number = i + fac = 0. + do 185 j=1,5 + fac = fac+c0(number)*bv(i,j) + number = number+1 + 185 continue + b0(2,i) = fac*pinv + 190 continue + mvv = mv+nv8 + 195 if(iop1.eq.0) go to 225 + fac = (tu(nu4)-tu(nu4+1))/three + dr12 = dr(5)*fac + dr13 = dr(6)*fac + do 200 i=1,nv4 + c1(i) = dr11+dr12*cosi(1,i)+dr13*cosi(2,i) + 200 continue + do 210 i=1,mv + number = nrv(i) + fac = 0. + do 205 j=1,4 + number = number+1 + fac = fac+c1(number)*spv(i,j) + 205 continue + a1(2,i) = fac + 210 continue + if(nv8.eq.0 .or. p.le.0.) go to 225 + do 220 i=1,nv8 + number = i + fac = 0. + do 215 j=1,5 + fac = fac+c1(number)*bv(i,j) + number = number+1 + 215 continue + b1(2,i) = fac*pinv + 220 continue + mvv = mv+nv8 +c we first determine the matrices (auu) and (qq). then we reduce the +c matrix (auu) to an unit upper triangular form (ru) using givens +c rotations without square roots. we apply the same transformations to +c the rows of matrix qq to obtain the mv x nuu matrix g. +c we store matrix (ru) into au and g into q. + 225 l = mvv*nuu +c initialization. + sq = 0. + if(l.eq.0) go to 245 + do 230 i=1,l + q(i) = 0. + 230 continue + do 240 i=1,nuu + do 240 j=1,5 + au(i,j) = 0. + 240 continue + l = 0 + 245 nrold = 0 + n1 = nrold+1 + do 420 it=1,mu + number = nru(it) +c find the appropriate column of q. + 250 do 260 j=1,mvv + right(j) = 0. + 260 continue + if(nrold.eq.number) go to 280 + if(p.le.0.) go to 410 +c fetch a new row of matrix (bu). + do 270 j=1,5 + h(j) = bu(n1,j)*pinv + 270 continue + i0 = 1 + i1 = 5 + go to 310 +c fetch a new row of matrix (spu). + 280 do 290 j=1,4 + h(j) = spu(it,j) + 290 continue +c find the appropriate column of q. + do 300 j=1,mv + l = l+1 + right(j) = r(l) + 300 continue + i0 = 1 + i1 = 4 + 310 j0 = n1 + j1 = nu7-number +c take into account that we eliminate the constraints (3) + 315 if(j0-1.gt.iop0) go to 335 + fac0 = h(i0) + do 320 j=1,mv + right(j) = right(j)-fac0*a0(j0,j) + 320 continue + if(mv.eq.mvv) go to 330 + j = mv + do 325 jj=1,nv8 + j = j+1 + right(j) = right(j)-fac0*b0(j0,jj) + 325 continue + 330 j0 = j0+1 + i0 = i0+1 + go to 315 +c take into account that we eliminate the constraints (4) + 335 if(j1-1.gt.iop1) go to 360 + fac1 = h(i1) + do 340 j=1,mv + right(j) = right(j)-fac1*a1(j1,j) + 340 continue + if(mv.eq.mvv) go to 350 + j = mv + do 345 jj=1,nv8 + j = j+1 + right(j) = right(j)-fac1*b1(j1,jj) + 345 continue + 350 j1 = j1+1 + i1 = i1-1 + go to 335 + 360 irot = nrold-iop0-1 + if(irot.lt.0) irot = 0 +c rotate the new row of matrix (auu) into triangle. + if(i0.gt.i1) go to 390 + do 385 i=i0,i1 + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 385 +c calculate the parameters of the givens transformation. + call fpgivs(piv,au(irot,1),co,si) +c apply that transformation to the rows of matrix (qq). + iq = (irot-1)*mvv + do 370 j=1,mvv + iq = iq+1 + call fprota(co,si,right(j),q(iq)) + 370 continue +c apply that transformation to the columns of (auu). + if(i.eq.i1) go to 385 + i2 = 1 + i3 = i+1 + do 380 j=i3,i1 + i2 = i2+1 + call fprota(co,si,h(j),au(irot,i2)) + 380 continue + 385 continue +c we update the sum of squared residuals. + 390 do 395 j=1,mvv + sq = sq+right(j)**2 + 395 continue + 400 if(nrold.eq.number) go to 420 + 410 nrold = n1 + n1 = n1+1 + go to 250 + 420 continue + if(nuu.eq.0) go to 800 +c we determine the matrix (avv) and then we reduce her to an unit +c upper triangular form (rv) using givens rotations without square +c roots. we apply the same transformations to the columns of matrix +c g to obtain the (nv-7) x (nu-6-iop0-iop1) matrix h. +c we store matrix (rv) into av1 and av2, h into c. +c the nv7 x nv7 triangular unit upper matrix (rv) has the form +c | av1 ' | +c (rv) = | ' av2 | +c | 0 ' | +c with (av2) a nv7 x 4 matrix and (av1) a nv11 x nv11 unit upper +c triangular matrix of bandwidth 5. + ncof = nuu*nv7 +c initialization. + do 430 i=1,ncof + c(i) = 0. + 430 continue + do 440 i=1,nv4 + av1(i,5) = 0. + do 440 j=1,4 + av1(i,j) = 0. + av2(i,j) = 0. + 440 continue + jper = 0 + nrold = 0 + do 770 it=1,mv + number = nrv(it) + 450 if(nrold.eq.number) go to 480 + if(p.le.0.) go to 760 +c fetch a new row of matrix (bv). + n1 = nrold+1 + do 460 j=1,5 + h(j) = bv(n1,j)*pinv + 460 continue +c find the appropiate row of g. + do 465 j=1,nuu + right(j) = 0. + 465 continue + if(mv.eq.mvv) go to 510 + l = mv+n1 + do 470 j=1,nuu + right(j) = q(l) + l = l+mvv + 470 continue + go to 510 +c fetch a new row of matrix (spv) + 480 h(5) = 0. + do 490 j=1,4 + h(j) = spv(it,j) + 490 continue +c find the appropiate row of g. + l = it + do 500 j=1,nuu + right(j) = q(l) + l = l+mvv + 500 continue +c test whether there are non-zero values in the new row of (avv) +c corresponding to the b-splines n(j;v),j=nv7+1,...,nv4. + 510 if(nrold.lt.nv11) go to 710 + if(jper.ne.0) go to 550 +c initialize the matrix (av2). + jk = nv11+1 + do 540 i=1,4 + ik = jk + do 520 j=1,5 + if(ik.le.0) go to 530 + av2(ik,i) = av1(ik,j) + ik = ik-1 + 520 continue + 530 jk = jk+1 + 540 continue + jper = 1 +c if one of the non-zero elements of the new row corresponds to one of +c the b-splines n(j;v),j=nv7+1,...,nv4, we take account of condition +c (2) for setting up this row of (avv). the row is stored in h1( the +c part with respect to av1) and h2 (the part with respect to av2). + 550 do 560 i=1,4 + h1(i) = 0. + h2(i) = 0. + 560 continue + h1(5) = 0. + j = nrold-nv11 + do 600 i=1,5 + j = j+1 + l0 = j + 570 l1 = l0-4 + if(l1.le.0) go to 590 + if(l1.le.nv11) go to 580 + l0 = l1-nv11 + go to 570 + 580 h1(l1) = h(i) + go to 600 + 590 h2(l0) = h2(l0) + h(i) + 600 continue +c rotate the new row of (avv) into triangle. + if(nv11.le.0) go to 670 +c rotations with the rows 1,2,...,nv11 of (avv). + do 660 j=1,nv11 + piv = h1(1) + i2 = min0(nv11-j,4) + if(piv.eq.0.) go to 640 +c calculate the parameters of the givens transformation. + call fpgivs(piv,av1(j,1),co,si) +c apply that transformation to the columns of matrix g. + ic = j + do 610 i=1,nuu + call fprota(co,si,right(i),c(ic)) + ic = ic+nv7 + 610 continue +c apply that transformation to the rows of (avv) with respect to av2. + do 620 i=1,4 + call fprota(co,si,h2(i),av2(j,i)) + 620 continue +c apply that transformation to the rows of (avv) with respect to av1. + if(i2.eq.0) go to 670 + do 630 i=1,i2 + i1 = i+1 + call fprota(co,si,h1(i1),av1(j,i1)) + 630 continue + 640 do 650 i=1,i2 + h1(i) = h1(i+1) + 650 continue + h1(i2+1) = 0. + 660 continue +c rotations with the rows nv11+1,...,nv7 of avv. + 670 do 700 j=1,4 + ij = nv11+j + if(ij.le.0) go to 700 + piv = h2(j) + if(piv.eq.0.) go to 700 +c calculate the parameters of the givens transformation. + call fpgivs(piv,av2(ij,j),co,si) +c apply that transformation to the columns of matrix g. + ic = ij + do 680 i=1,nuu + call fprota(co,si,right(i),c(ic)) + ic = ic+nv7 + 680 continue + if(j.eq.4) go to 700 +c apply that transformation to the rows of (avv) with respect to av2. + j1 = j+1 + do 690 i=j1,4 + call fprota(co,si,h2(i),av2(ij,i)) + 690 continue + 700 continue +c we update the sum of squared residuals. + do 705 i=1,nuu + sq = sq+right(i)**2 + 705 continue + go to 750 +c rotation into triangle of the new row of (avv), in case the elements +c corresponding to the b-splines n(j;v),j=nv7+1,...,nv4 are all zero. + 710 irot =nrold + do 740 i=1,5 + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 740 +c calculate the parameters of the givens transformation. + call fpgivs(piv,av1(irot,1),co,si) +c apply that transformation to the columns of matrix g. + ic = irot + do 720 j=1,nuu + call fprota(co,si,right(j),c(ic)) + ic = ic+nv7 + 720 continue +c apply that transformation to the rows of (avv). + if(i.eq.5) go to 740 + i2 = 1 + i3 = i+1 + do 730 j=i3,5 + i2 = i2+1 + call fprota(co,si,h(j),av1(irot,i2)) + 730 continue + 740 continue +c we update the sum of squared residuals. + do 745 i=1,nuu + sq = sq+right(i)**2 + 745 continue + 750 if(nrold.eq.number) go to 770 + 760 nrold = nrold+1 + go to 450 + 770 continue +c test whether the b-spline coefficients must be determined. + if(iback.ne.0) return +c backward substitution to obtain the b-spline coefficients as the +c solution of the linear system (rv) (cr) (ru)' = h. +c first step: solve the system (rv) (c1) = h. + k = 1 + do 780 i=1,nuu + call fpbacp(av1,av2,c(k),nv7,4,c(k),5,nv) + k = k+nv7 + 780 continue +c second step: solve the system (cr) (ru)' = (c1). + k = 0 + do 795 j=1,nv7 + k = k+1 + l = k + do 785 i=1,nuu + right(i) = c(l) + l = l+nv7 + 785 continue + call fpback(au,right,nuu,5,right,nu) + l = k + do 790 i=1,nuu + c(l) = right(i) + l = l+nv7 + 790 continue + 795 continue +c calculate from the conditions (2)-(3)-(4), the remaining b-spline +c coefficients. + 800 ncof = nu4*nv4 + j = ncof + do 805 l=1,nv4 + q(l) = dr01 + q(j) = dr11 + j = j-1 + 805 continue + i = nv4 + j = 0 + if(iop0.eq.0) go to 815 + do 810 l=1,nv4 + i = i+1 + q(i) = c0(l) + 810 continue + 815 if(nuu.eq.0) go to 835 + do 830 l=1,nuu + ii = i + do 820 k=1,nv7 + i = i+1 + j = j+1 + q(i) = c(j) + 820 continue + do 825 k=1,3 + ii = ii+1 + i = i+1 + q(i) = q(ii) + 825 continue + 830 continue + 835 if(iop1.eq.0) go to 845 + do 840 l=1,nv4 + i = i+1 + q(i) = c1(l) + 840 continue + 845 do 850 i=1,ncof + c(i) = q(i) + 850 continue +c calculate the quantities +c res(i,j) = (r(i,j) - s(u(i),v(j)))**2 , i=1,2,..,mu;j=1,2,..,mv +c fp = sumi=1,mu(sumj=1,mv(res(i,j))) +c fpu(r) = sum''i(sumj=1,mv(res(i,j))) , r=1,2,...,nu-7 +c tu(r+3) <= u(i) <= tu(r+4) +c fpv(r) = sumi=1,mu(sum''j(res(i,j))) , r=1,2,...,nv-7 +c tv(r+3) <= v(j) <= tv(r+4) + fp = 0. + do 890 i=1,nu + fpu(i) = 0. + 890 continue + do 900 i=1,nv + fpv(i) = 0. + 900 continue + ir = 0 + nroldu = 0 +c main loop for the different grid points. + do 950 i1=1,mu + numu = nru(i1) + numu1 = numu+1 + nroldv = 0 + do 940 i2=1,mv + numv = nrv(i2) + numv1 = numv+1 + ir = ir+1 +c evaluate s(u,v) at the current grid point by making the sum of the +c cross products of the non-zero b-splines at (u,v), multiplied with +c the appropiate b-spline coefficients. + term = 0. + k1 = numu*nv4+numv + do 920 l1=1,4 + k2 = k1 + fac = spu(i1,l1) + do 910 l2=1,4 + k2 = k2+1 + term = term+fac*spv(i2,l2)*c(k2) + 910 continue + k1 = k1+nv4 + 920 continue +c calculate the squared residual at the current grid point. + term = (r(ir)-term)**2 +c adjust the different parameters. + fp = fp+term + fpu(numu1) = fpu(numu1)+term + fpv(numv1) = fpv(numv1)+term + fac = term*half + if(numv.eq.nroldv) go to 930 + fpv(numv1) = fpv(numv1)-fac + fpv(numv) = fpv(numv)+fac + 930 nroldv = numv + if(numu.eq.nroldu) go to 940 + fpu(numu1) = fpu(numu1)-fac + fpu(numu) = fpu(numu)+fac + 940 continue + nroldu = numu + 950 continue + return + end Added: branches/Interpolate1D/fitpack/fpinst.f =================================================================== --- branches/Interpolate1D/fitpack/fpinst.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpinst.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,77 @@ + subroutine fpinst(iopt,t,n,c,k,x,l,tt,nn,cc,nest) +c given the b-spline representation (knots t(j),j=1,2,...,n, b-spline +c coefficients c(j),j=1,2,...,n-k-1) of a spline of degree k, fpinst +c calculates the b-spline representation (knots tt(j),j=1,2,...,nn, +c b-spline coefficients cc(j),j=1,2,...,nn-k-1) of the same spline if +c an additional knot is inserted at the point x situated in the inter- +c val t(l)<=x2*k or l0) in such a way that +c - if p tends to infinity, sp(u,v) becomes the least-squares spline +c with given knots, satisfying the constraints. +c - if p tends to zero, sp(u,v) becomes the least-squares polynomial, +c satisfying the constraints. +c - the function f(p)=sumi=1,mu(sumj=1,mv((z(i,j)-sp(u(i),v(j)))**2) +c is continuous and strictly decreasing for p>0. +c +c ..scalar arguments.. + integer ifsu,ifsv,ifbu,ifbv,mu,mv,mz,nu,nv,nuest,nvest, + * nc,lwrk + real*8 z0,p,step,fp +c ..array arguments.. + integer ider(2),nru(mu),nrv(mv),iopt(3) + real*8 u(mu),v(mv),z(mz),dz(3),tu(nu),tv(nv),c(nc),fpu(nu),fpv(nv) + *, + * wrk(lwrk) +c ..local scalars.. + real*8 res,sq,sqq,step1,step2,three + integer i,id0,iop0,iop1,i1,j,l,laa,lau,lav1,lav2,lbb,lbu,lbv, + * lcc,lcs,lq,lri,lsu,lsv,l1,l2,mm,mvnu,number +c ..local arrays.. + integer nr(3) + real*8 delta(3),dzz(3),sum(3),a(6,6),g(6) +c ..function references.. + integer max0 +c ..subroutine references.. +c fpgrdi,fpsysy +c .. +c set constant + three = 3 +c we partition the working space + lsu = 1 + lsv = lsu+4*mu + lri = lsv+4*mv + mm = max0(nuest,mv+nvest) + lq = lri+mm + mvnu = nuest*(mv+nvest-8) + lau = lq+mvnu + lav1 = lau+5*nuest + lav2 = lav1+6*nvest + lbu = lav2+4*nvest + lbv = lbu+5*nuest + laa = lbv+5*nvest + lbb = laa+2*mv + lcc = lbb+2*nvest + lcs = lcc+nvest +c we calculate the smoothing spline sp(u,v) according to the input +c values dz(i),i=1,2,3. + iop0 = iopt(2) + iop1 = iopt(3) + call fpgrdi(ifsu,ifsv,ifbu,ifbv,0,u,mu,v,mv,z,mz,dz, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(laa),wrk(lbb), + * wrk(lcc),wrk(lcs),nru,nrv) + id0 = ider(1) + if(id0.ne.0) go to 5 + res = (z0-dz(1))**2 + fp = fp+res + sq = sq+res +c in case all derivative values dz(i) are given (step<=0) or in case +c we have spline interpolation, we accept this spline as a solution. + 5 if(step.le.0. .or. sq.le.0.) return + dzz(1) = dz(1) + dzz(2) = dz(2) + dzz(3) = dz(3) +c number denotes the number of derivative values dz(i) that still must +c be optimized. let us denote these parameters by g(j),j=1,...,number. + number = 0 + if(id0.gt.0) go to 10 + number = 1 + nr(1) = 1 + delta(1) = step + 10 if(iop0.eq.0) go to 20 + if(ider(2).ne.0) go to 20 + step2 = step*three/tu(5) + nr(number+1) = 2 + nr(number+2) = 3 + delta(number+1) = step2 + delta(number+2) = step2 + number = number+2 + 20 if(number.eq.0) return +c the sum of squared residuals sq is a quadratic polynomial in the +c parameters g(j). we determine the unknown coefficients of this +c polymomial by calculating (number+1)*(number+2)/2 different splines +c according to specific values for g(j). + do 30 i=1,number + l = nr(i) + step1 = delta(i) + dzz(l) = dz(l)+step1 + call fpgrdi(ifsu,ifsv,ifbu,ifbv,1,u,mu,v,mv,z,mz,dzz, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sum(i),fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(laa),wrk(lbb), + * wrk(lcc),wrk(lcs),nru,nrv) + if(id0.eq.0) sum(i) = sum(i)+(z0-dzz(1))**2 + dzz(l) = dz(l)-step1 + call fpgrdi(ifsu,ifsv,ifbu,ifbv,1,u,mu,v,mv,z,mz,dzz, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sqq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(laa),wrk(lbb), + * wrk(lcc),wrk(lcs),nru,nrv) + if(id0.eq.0) sqq = sqq+(z0-dzz(1))**2 + a(i,i) = (sum(i)+sqq-sq-sq)/step1**2 + if(a(i,i).le.0.) go to 80 + g(i) = (sqq-sum(i))/(step1+step1) + dzz(l) = dz(l) + 30 continue + if(number.eq.1) go to 60 + do 50 i=2,number + l1 = nr(i) + step1 = delta(i) + dzz(l1) = dz(l1)+step1 + i1 = i-1 + do 40 j=1,i1 + l2 = nr(j) + step2 = delta(j) + dzz(l2) = dz(l2)+step2 + call fpgrdi(ifsu,ifsv,ifbu,ifbv,1,u,mu,v,mv,z,mz,dzz, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sqq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(laa),wrk(lbb), + * wrk(lcc),wrk(lcs),nru,nrv) + if(id0.eq.0) sqq = sqq+(z0-dzz(1))**2 + a(i,j) = (sq+sqq-sum(i)-sum(j))/(step1*step2) + dzz(l2) = dz(l2) + 40 continue + dzz(l1) = dz(l1) + 50 continue +c the optimal values g(j) are found as the solution of the system +c d (sq) / d (g(j)) = 0 , j=1,...,number. + 60 call fpsysy(a,number,g) + do 70 i=1,number + l = nr(i) + dz(l) = dz(l)+g(i) + 70 continue +c we determine the spline sp(u,v) according to the optimal values g(j). + 80 call fpgrdi(ifsu,ifsv,ifbu,ifbv,0,u,mu,v,mv,z,mz,dz, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(laa),wrk(lbb), + * wrk(lcc),wrk(lcs),nru,nrv) + if(id0.eq.0) fp = fp+(z0-dz(1))**2 + return + end Added: branches/Interpolate1D/fitpack/fpopsp.f =================================================================== --- branches/Interpolate1D/fitpack/fpopsp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpopsp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,211 @@ + subroutine fpopsp(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,r,mr,r0,r1,dr, + * iopt,ider,tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpu,fpv, + * nru,nrv,wrk,lwrk) +c given the set of function values r(i,j) defined on the rectangular +c grid (u(i),v(j)),i=1,2,...,mu;j=1,2,...,mv, fpopsp determines a +c smooth bicubic spline approximation with given knots tu(i),i=1,..,nu +c in the u-direction and tv(j),j=1,2,...,nv in the v-direction. this +c spline sp(u,v) will be periodic in the variable v and will satisfy +c the following constraints +c +c s(tu(1),v) = dr(1) , tv(4) <=v<= tv(nv-3) +c +c s(tu(nu),v) = dr(4) , tv(4) <=v<= tv(nv-3) +c +c and (if iopt(2) = 1) +c +c d s(tu(1),v) +c ------------ = dr(2)*cos(v)+dr(3)*sin(v) , tv(4) <=v<= tv(nv-3) +c d u +c +c and (if iopt(3) = 1) +c +c d s(tu(nu),v) +c ------------- = dr(5)*cos(v)+dr(6)*sin(v) , tv(4) <=v<= tv(nv-3) +c d u +c +c where the parameters dr(i) correspond to the derivative values at the +c poles as defined in subroutine spgrid. +c +c the b-spline coefficients of sp(u,v) are determined as the least- +c squares solution of an overdetermined linear system which depends +c on the value of p and on the values dr(i),i=1,...,6. the correspond- +c ing sum of squared residuals sq is a simple quadratic function in +c the variables dr(i). these may or may not be provided. the values +c dr(i) which are not given will be determined so as to minimize the +c resulting sum of squared residuals sq. in that case the user must +c provide some initial guess dr(i) and some estimate (dr(i)-step, +c dr(i)+step) of the range of possible values for these latter. +c +c sp(u,v) also depends on the parameter p (p>0) in such a way that +c - if p tends to infinity, sp(u,v) becomes the least-squares spline +c with given knots, satisfying the constraints. +c - if p tends to zero, sp(u,v) becomes the least-squares polynomial, +c satisfying the constraints. +c - the function f(p)=sumi=1,mu(sumj=1,mv((r(i,j)-sp(u(i),v(j)))**2) +c is continuous and strictly decreasing for p>0. +c +c ..scalar arguments.. + integer ifsu,ifsv,ifbu,ifbv,mu,mv,mr,nu,nv,nuest,nvest, + * nc,lwrk + real*8 r0,r1,p,fp +c ..array arguments.. + integer ider(4),nru(mu),nrv(mv),iopt(3) + real*8 u(mu),v(mv),r(mr),dr(6),tu(nu),tv(nv),c(nc),fpu(nu),fpv(nv) + *, + * wrk(lwrk),step(2) +c ..local scalars.. + real*8 res,sq,sqq,sq0,sq1,step1,step2,three + integer i,id0,iop0,iop1,i1,j,l,lau,lav1,lav2,la0,la1,lbu,lbv,lb0, + * lb1,lc0,lc1,lcs,lq,lri,lsu,lsv,l1,l2,mm,mvnu,number +c ..local arrays.. + integer nr(6) + real*8 delta(6),drr(6),sum(6),a(6,6),g(6) +c ..function references.. + integer max0 +c ..subroutine references.. +c fpgrsp,fpsysy +c .. +c set constant + three = 3 +c we partition the working space + lsu = 1 + lsv = lsu+4*mu + lri = lsv+4*mv + mm = max0(nuest,mv+nvest) + lq = lri+mm + mvnu = nuest*(mv+nvest-8) + lau = lq+mvnu + lav1 = lau+5*nuest + lav2 = lav1+6*nvest + lbu = lav2+4*nvest + lbv = lbu+5*nuest + la0 = lbv+5*nvest + la1 = la0+2*mv + lb0 = la1+2*mv + lb1 = lb0+2*nvest + lc0 = lb1+2*nvest + lc1 = lc0+nvest + lcs = lc1+nvest +c we calculate the smoothing spline sp(u,v) according to the input +c values dr(i),i=1,...,6. + iop0 = iopt(2) + iop1 = iopt(3) + id0 = ider(1) + id1 = ider(3) + call fpgrsp(ifsu,ifsv,ifbu,ifbv,0,u,mu,v,mv,r,mr,dr, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(la0),wrk(la1),wrk(lb0), + * wrk(lb1),wrk(lc0),wrk(lc1),wrk(lcs),nru,nrv) + sq0 = 0. + sq1 = 0. + if(id0.eq.0) sq0 = (r0-dr(1))**2 + if(id1.eq.0) sq1 = (r1-dr(4))**2 + sq = sq+sq0+sq1 +c in case all derivative values dr(i) are given (step<=0) or in case +c we have spline interpolation, we accept this spline as a solution. + if(sq.le.0.) return + if(step(1).le.0. .and. step(2).le.0.) return + do 10 i=1,6 + drr(i) = dr(i) + 10 continue +c number denotes the number of derivative values dr(i) that still must +c be optimized. let us denote these parameters by g(j),j=1,...,number. + number = 0 + if(id0.gt.0) go to 20 + number = 1 + nr(1) = 1 + delta(1) = step(1) + 20 if(iop0.eq.0) go to 30 + if(ider(2).ne.0) go to 30 + step2 = step(1)*three/(tu(5)-tu(4)) + nr(number+1) = 2 + nr(number+2) = 3 + delta(number+1) = step2 + delta(number+2) = step2 + number = number+2 + 30 if(id1.gt.0) go to 40 + number = number+1 + nr(number) = 4 + delta(number) = step(2) + 40 if(iop1.eq.0) go to 50 + if(ider(4).ne.0) go to 50 + step2 = step(2)*three/(tu(nu)-tu(nu-4)) + nr(number+1) = 5 + nr(number+2) = 6 + delta(number+1) = step2 + delta(number+2) = step2 + number = number+2 + 50 if(number.eq.0) return +c the sum of squared residulas sq is a quadratic polynomial in the +c parameters g(j). we determine the unknown coefficients of this +c polymomial by calculating (number+1)*(number+2)/2 different splines +c according to specific values for g(j). + do 60 i=1,number + l = nr(i) + step1 = delta(i) + drr(l) = dr(l)+step1 + call fpgrsp(ifsu,ifsv,ifbu,ifbv,1,u,mu,v,mv,r,mr,drr, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sum(i),fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(la0),wrk(la1),wrk(lb0), + * wrk(lb1),wrk(lc0),wrk(lc1),wrk(lcs),nru,nrv) + if(id0.eq.0) sq0 = (r0-drr(1))**2 + if(id1.eq.0) sq1 = (r1-drr(4))**2 + sum(i) = sum(i)+sq0+sq1 + drr(l) = dr(l)-step1 + call fpgrsp(ifsu,ifsv,ifbu,ifbv,1,u,mu,v,mv,r,mr,drr, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sqq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(la0),wrk(la1),wrk(lb0), + * wrk(lb1),wrk(lc0),wrk(lc1),wrk(lcs),nru,nrv) + if(id0.eq.0) sq0 = (r0-drr(1))**2 + if(id1.eq.0) sq1 = (r1-drr(4))**2 + sqq = sqq+sq0+sq1 + drr(l) = dr(l) + a(i,i) = (sum(i)+sqq-sq-sq)/step1**2 + if(a(i,i).le.0.) go to 110 + g(i) = (sqq-sum(i))/(step1+step1) + 60 continue + if(number.eq.1) go to 90 + do 80 i=2,number + l1 = nr(i) + step1 = delta(i) + drr(l1) = dr(l1)+step1 + i1 = i-1 + do 70 j=1,i1 + l2 = nr(j) + step2 = delta(j) + drr(l2) = dr(l2)+step2 + call fpgrsp(ifsu,ifsv,ifbu,ifbv,1,u,mu,v,mv,r,mr,drr, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sqq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(la0),wrk(la1),wrk(lb0), + * wrk(lb1),wrk(lc0),wrk(lc1),wrk(lcs),nru,nrv) + if(id0.eq.0) sq0 = (r0-drr(1))**2 + if(id1.eq.0) sq1 = (r1-drr(4))**2 + sqq = sqq+sq0+sq1 + a(i,j) = (sq+sqq-sum(i)-sum(j))/(step1*step2) + drr(l2) = dr(l2) + 70 continue + drr(l1) = dr(l1) + 80 continue +c the optimal values g(j) are found as the solution of the system +c d (sq) / d (g(j)) = 0 , j=1,...,number. + 90 call fpsysy(a,number,g) + do 100 i=1,number + l = nr(i) + dr(l) = dr(l)+g(i) + 100 continue +c we determine the spline sp(u,v) according to the optimal values g(j). + 110 call fpgrsp(ifsu,ifsv,ifbu,ifbv,0,u,mu,v,mv,r,mr,dr, + * iop0,iop1,tu,nu,tv,nv,p,c,nc,sq,fp,fpu,fpv,mm,mvnu, + * wrk(lsu),wrk(lsv),wrk(lri),wrk(lq),wrk(lau),wrk(lav1), + * wrk(lav2),wrk(lbu),wrk(lbv),wrk(la0),wrk(la1),wrk(lb0), + * wrk(lb1),wrk(lc0),wrk(lc1),wrk(lcs),nru,nrv) + if(id0.eq.0) sq0 = (r0-dr(1))**2 + if(id1.eq.0) sq1 = (r1-dr(4))**2 + sq = sq+sq0+sq1 + return + end Added: branches/Interpolate1D/fitpack/fporde.f =================================================================== --- branches/Interpolate1D/fitpack/fporde.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fporde.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,47 @@ + subroutine fporde(x,y,m,kx,ky,tx,nx,ty,ny,nummer,index,nreg) +c subroutine fporde sorts the data points (x(i),y(i)),i=1,2,...,m +c according to the panel tx(l)<=x s we will increase the number of knots and compute the c +c corresponding least-squares curve until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmax = m+k+1. c +c if s > 0 and c +c iopt=0 we first compute the least-squares polynomial curve of c +c degree k; n = nmin = 2*k+2 c +c iopt=1 we start with the set of knots found at the last c +c call of the routine, except for the case that s > fp0; then c +c we compute directly the polynomial curve of degree k. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c determine nmin, the number of knots for polynomial approximation. + nmin = 2*k1 + if(iopt.lt.0) go to 60 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s +c determine nmax, the number of knots for spline interpolation. + nmax = m+k1 + if(s.gt.0.) go to 45 +c if s=0, s(u) is an interpolating curve. +c test whether the required storage space exceeds the available one. + n = nmax + if(nmax.gt.nest) go to 420 +c find the position of the interior knots in case of interpolation. + 10 mk1 = m-k1 + if(mk1.eq.0) go to 60 + k3 = k/2 + i = k2 + j = k3+2 + if(k3*2.eq.k) go to 30 + do 20 l=1,mk1 + t(i) = u(j) + i = i+1 + j = j+1 + 20 continue + go to 60 + 30 do 40 l=1,mk1 + t(i) = (u(j)+u(j-1))*half + i = i+1 + j = j+1 + 40 continue + go to 60 +c if s>0 our initial choice of knots depends on the value of iopt. +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c polynomial curve which is a spline curve without interior knots. +c if iopt=1 and fp0>s we start computing the least squares spline curve +c according to the set of knots found at the last call of the routine. + 45 if(iopt.eq.0) go to 50 + if(n.eq.nmin) go to 50 + fp0 = fpint(n) + fpold = fpint(n-1) + nplus = nrdata(n) + if(fp0.gt.s) go to 60 + 50 n = nmin + fpold = 0. + nplus = 0 + nrdata(1) = m-2 +c main loop for the different sets of knots. m is a save upper bound +c for the number of trials. + 60 do 200 iter = 1,m + if(n.eq.nmin) ier = -2 +c find nrint, tne number of knot intervals. + nrint = n-nmin+1 +c find the position of the additional knots which are needed for +c the b-spline representation of s(u). + nk1 = n-k1 + i = n + do 70 j=1,k1 + t(j) = ub + t(i) = ue + i = i-1 + 70 continue +c compute the b-spline coefficients of the least-squares spline curve +c sinf(u). the observation matrix a is built up row by row and +c reduced to upper triangular form by givens transformations. +c at the same time fp=f(p=inf) is computed. + fp = 0. +c initialize the b-spline coefficients and the observation matrix a. + do 75 i=1,nc + z(i) = 0. + 75 continue + do 80 i=1,nk1 + do 80 j=1,k1 + a(i,j) = 0. + 80 continue + l = k1 + jj = 0 + do 130 it=1,m +c fetch the current data point u(it),x(it). + ui = u(it) + wi = w(it) + do 83 j=1,idim + jj = jj+1 + xi(j) = x(jj)*wi + 83 continue +c search for knot interval t(l) <= ui < t(l+1). + 85 if(ui.lt.t(l+1) .or. l.eq.nk1) go to 90 + l = l+1 + go to 85 +c evaluate the (k+1) non-zero b-splines at ui and store them in q. + 90 call fpbspl(t,n,k,ui,l,h) + do 95 i=1,k1 + q(it,i) = h(i) + h(i) = h(i)*wi + 95 continue +c rotate the new row of the observation matrix into triangle. + j = l-k1 + do 110 i=1,k1 + j = j+1 + piv = h(i) + if(piv.eq.0.) go to 110 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(j,1),cos,sin) +c transformations to right hand side. + j1 = j + do 97 j2 =1,idim + call fprota(cos,sin,xi(j2),z(j1)) + j1 = j1+n + 97 continue + if(i.eq.k1) go to 120 + i2 = 1 + i3 = i+1 + do 100 i1 = i3,k1 + i2 = i2+1 +c transformations to left hand side. + call fprota(cos,sin,h(i1),a(j,i2)) + 100 continue + 110 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 120 do 125 j2=1,idim + fp = fp+xi(j2)**2 + 125 continue + 130 continue + if(ier.eq.(-2)) fp0 = fp + fpint(n) = fp0 + fpint(n-1) = fpold + nrdata(n) = nplus +c backward substitution to obtain the b-spline coefficients. + j1 = 1 + do 135 j2=1,idim + call fpback(a,z(j1),nk1,k1,c(j1),nest) + j1 = j1+n + 135 continue +c test whether the approximation sinf(u) is an acceptable solution. + if(iopt.lt.0) go to 440 + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c if f(p=inf) < s accept the choice of knots. + if(fpms.lt.0.) go to 250 +c if n = nmax, sinf(u) is an interpolating spline curve. + if(n.eq.nmax) go to 430 +c increase the number of knots. +c if n=nest we cannot increase the number of knots because of +c the storage capacity limitation. + if(n.eq.nest) go to 420 +c determine the number of knots nplus we are going to add. + if(ier.eq.0) go to 140 + nplus = 1 + ier = 0 + go to 150 + 140 npl1 = nplus*2 + rn = nplus + if(fpold-fp.gt.acc) npl1 = rn*fpms/(fpold-fp) + nplus = min0(nplus*2,max0(npl1,nplus/2,1)) + 150 fpold = fp +c compute the sum of squared residuals for each knot interval +c t(j+k) <= u(i) <= t(j+k+1) and store it in fpint(j),j=1,2,...nrint. + fpart = 0. + i = 1 + l = k2 + new = 0 + jj = 0 + do 180 it=1,m + if(u(it).lt.t(l) .or. l.gt.nk1) go to 160 + new = 1 + l = l+1 + 160 term = 0. + l0 = l-k2 + do 175 j2=1,idim + fac = 0. + j1 = l0 + do 170 j=1,k1 + j1 = j1+1 + fac = fac+c(j1)*q(it,j) + 170 continue + jj = jj+1 + term = term+(w(it)*(fac-x(jj)))**2 + l0 = l0+n + 175 continue + fpart = fpart+term + if(new.eq.0) go to 180 + store = term*half + fpint(i) = fpart-store + i = i+1 + fpart = store + new = 0 + 180 continue + fpint(nrint) = fpart + do 190 l=1,nplus +c add a new knot. + call fpknot(u,m,t,n,fpint,nrdata,nrint,nest,1) +c if n=nmax we locate the knots as for interpolation + if(n.eq.nmax) go to 10 +c test whether we cannot further increase the number of knots. + if(n.eq.nest) go to 200 + 190 continue +c restart the computations with the new set of knots. + 200 continue +c test whether the least-squares kth degree polynomial curve is a +c solution of our approximation problem. + 250 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline curve sp(u). c +c ********************************************************** c +c we have determined the number of knots and their position. c +c we now compute the b-spline coefficients of the smoothing curve c +c sp(u). the observation matrix a is extended by the rows of matrix c +c b expressing that the kth derivative discontinuities of sp(u) at c +c the interior knots t(k+2),...t(n-k-1) must be zero. the corres- c +c ponding weights of these additional rows are set to 1/p. c +c iteratively we then have to determine the value of p such that f(p),c +c the sum of squared residuals be = s. we already know that the least c +c squares kth degree polynomial curve corresponds to p=0, and that c +c the least-squares spline curve corresponds to p=infinity. the c +c iteration process which is proposed here, makes use of rational c +c interpolation. since f(p) is a convex and strictly decreasing c +c function of p, it can be approximated by a rational function c +c r(p) = (u*p+v)/(p+w). three values of p(p1,p2,p3) with correspond- c +c ing values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used c +c to calculate the new value of p such that r(p)=s. convergence is c +c guaranteed by taking f1>0 and f3<0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jump of the kth derivative of the +c b-splines at the knots t(l),l=k+2,...n-k-1 and store in b. + call fpdisc(t,n,k2,b,nest) +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = 0. + do 252 i=1,nk1 + p = p+a(i,1) + 252 continue + rn = nk1 + p = rn/p + ich1 = 0 + ich3 = 0 + n8 = n-nmin +c iteration process to find the root of f(p) = s. + do 360 iter=1,maxit +c the rows of matrix b with weight 1/p are rotated into the +c triangularised observation matrix a which is stored in g. + pinv = one/p + do 255 i=1,nc + c(i) = z(i) + 255 continue + do 260 i=1,nk1 + g(i,k2) = 0. + do 260 j=1,k1 + g(i,j) = a(i,j) + 260 continue + do 300 it=1,n8 +c the row of matrix b is rotated into triangle by givens transformation + do 270 i=1,k2 + h(i) = b(it,i)*pinv + 270 continue + do 275 j=1,idim + xi(j) = 0. + 275 continue + do 290 j=it,nk1 + piv = h(1) +c calculate the parameters of the givens transformation. + call fpgivs(piv,g(j,1),cos,sin) +c transformations to right hand side. + j1 = j + do 277 j2=1,idim + call fprota(cos,sin,xi(j2),c(j1)) + j1 = j1+n + 277 continue + if(j.eq.nk1) go to 300 + i2 = k1 + if(j.gt.n8) i2 = nk1-j + do 280 i=1,i2 +c transformations to left hand side. + i1 = i+1 + call fprota(cos,sin,h(i1),g(j,i1)) + h(i) = h(i1) + 280 continue + h(i2+1) = 0. + 290 continue + 300 continue +c backward substitution to obtain the b-spline coefficients. + j1 = 1 + do 305 j2=1,idim + call fpback(g,c(j1),nk1,k2,c(j1),nest) + j1 =j1+n + 305 continue +c computation of f(p). + fp = 0. + l = k2 + jj = 0 + do 330 it=1,m + if(u(it).lt.t(l) .or. l.gt.nk1) go to 310 + l = l+1 + 310 l0 = l-k2 + term = 0. + do 325 j2=1,idim + fac = 0. + j1 = l0 + do 320 j=1,k1 + j1 = j1+1 + fac = fac+c(j1)*q(it,j) + 320 continue + jj = jj+1 + term = term+(fac-x(jj))**2 + l0 = l0+n + 325 continue + fp = fp+term*w(it)**2 + 330 continue +c test whether the approximation sp(u) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximal number of iterations is reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 340 + if((f2-f3).gt.acc) go to 335 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p=p1*con9 + p2*con1 + go to 360 + 335 if(f2.lt.0.) ich3=1 + 340 if(ich1.ne.0) go to 350 + if((f1-f2).gt.acc) go to 345 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 360 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 360 + 345 if(f2.gt.0.) ich1=1 +c test whether the iteration process proceeds as theoretically +c expected. + 350 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value for p. + p = fprati(p1,f1,p2,f2,p3,f3) + 360 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + 440 return + end Added: branches/Interpolate1D/fitpack/fppasu.f =================================================================== --- branches/Interpolate1D/fitpack/fppasu.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fppasu.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,392 @@ + subroutine fppasu(iopt,ipar,idim,u,mu,v,mv,z,mz,s,nuest,nvest, + * tol,maxit,nc,nu,tu,nv,tv,c,fp,fp0,fpold,reducu,reducv,fpintu, + * fpintv,lastdi,nplusu,nplusv,nru,nrv,nrdatu,nrdatv,wrk,lwrk,ier) +c .. +c ..scalar arguments.. + real*8 s,tol,fp,fp0,fpold,reducu,reducv + integer iopt,idim,mu,mv,mz,nuest,nvest,maxit,nc,nu,nv,lastdi, + * nplusu,nplusv,lwrk,ier +c ..array arguments.. + real*8 u(mu),v(mv),z(mz*idim),tu(nuest),tv(nvest),c(nc*idim), + * fpintu(nuest),fpintv(nvest),wrk(lwrk) + integer ipar(2),nrdatu(nuest),nrdatv(nvest),nru(mu),nrv(mv) +c ..local scalars + real*8 acc,fpms,f1,f2,f3,p,p1,p2,p3,rn,one,con1,con9,con4, + * peru,perv,ub,ue,vb,ve + integer i,ich1,ich3,ifbu,ifbv,ifsu,ifsv,iter,j,lau1,lav1,laa, + * l,lau,lav,lbu,lbv,lq,lri,lsu,lsv,l1,l2,l3,l4,mm,mpm,mvnu,ncof, + * nk1u,nk1v,nmaxu,nmaxv,nminu,nminv,nplu,nplv,npl1,nrintu, + * nrintv,nue,nuk,nve,nuu,nvv +c ..function references.. + real*8 abs,fprati + integer max0,min0 +c ..subroutine references.. +c fpgrpa,fpknot +c .. +c set constants + one = 1 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 +c set boundaries of the approximation domain + ub = u(1) + ue = u(mu) + vb = v(1) + ve = v(mv) +c we partition the working space. + lsu = 1 + lsv = lsu+mu*4 + lri = lsv+mv*4 + mm = max0(nuest,mv) + lq = lri+mm*idim + mvnu = nuest*mv*idim + lau = lq+mvnu + nuk = nuest*5 + lbu = lau+nuk + lav = lbu+nuk + nuk = nvest*5 + lbv = lav+nuk + laa = lbv+nuk + lau1 = lau + if(ipar(1).eq.0) go to 10 + peru = ue-ub + lau1 = laa + laa = laa+4*nuest + 10 lav1 = lav + if(ipar(2).eq.0) go to 20 + perv = ve-vb + lav1 = laa +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position. c +c **************************************************************** c +c given a set of knots we compute the least-squares spline sinf(u,v), c +c and the corresponding sum of squared residuals fp=f(p=inf). c +c if iopt=-1 sinf(u,v) is the requested approximation. c +c if iopt=0 or iopt=1 we check whether we can accept the knots: c +c if fp <=s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares spline until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmaxu = mu+4+2*ipar(1) and nmaxv = mv+4+2*ipar(2) c +c if s>0 and c +c *iopt=0 we first compute the least-squares polynomial c +c nu=nminu=8 and nv=nminv=8 c +c *iopt=1 we start with the knots found at the last call of the c +c routine, except for the case that s > fp0; then we can compute c +c the least-squares polynomial directly. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c determine the number of knots for polynomial approximation. + 20 nminu = 8 + nminv = 8 + if(iopt.lt.0) go to 100 +c acc denotes the absolute tolerance for the root of f(p)=s. + acc = tol*s +c find nmaxu and nmaxv which denote the number of knots in u- and v- +c direction in case of spline interpolation. + nmaxu = mu+4+2*ipar(1) + nmaxv = mv+4+2*ipar(2) +c find nue and nve which denote the maximum number of knots +c allowed in each direction + nue = min0(nmaxu,nuest) + nve = min0(nmaxv,nvest) + if(s.gt.0.) go to 60 +c if s = 0, s(u,v) is an interpolating spline. + nu = nmaxu + nv = nmaxv +c test whether the required storage space exceeds the available one. + if(nv.gt.nvest .or. nu.gt.nuest) go to 420 +c find the position of the interior knots in case of interpolation. +c the knots in the u-direction. + nuu = nu-8 + if(nuu.eq.0) go to 40 + i = 5 + j = 3-ipar(1) + do 30 l=1,nuu + tu(i) = u(j) + i = i+1 + j = j+1 + 30 continue +c the knots in the v-direction. + 40 nvv = nv-8 + if(nvv.eq.0) go to 60 + i = 5 + j = 3-ipar(2) + do 50 l=1,nvv + tv(i) = v(j) + i = i+1 + j = j+1 + 50 continue + go to 100 +c if s > 0 our initial choice of knots depends on the value of iopt. + 60 if(iopt.eq.0) go to 90 + if(fp0.le.s) go to 90 +c if iopt=1 and fp0 > s we start computing the least- squares spline +c according to the set of knots found at the last call of the routine. +c we determine the number of grid coordinates u(i) inside each knot +c interval (tu(l),tu(l+1)). + l = 5 + j = 1 + nrdatu(1) = 0 + mpm = mu-1 + do 70 i=2,mpm + nrdatu(j) = nrdatu(j)+1 + if(u(i).lt.tu(l)) go to 70 + nrdatu(j) = nrdatu(j)-1 + l = l+1 + j = j+1 + nrdatu(j) = 0 + 70 continue +c we determine the number of grid coordinates v(i) inside each knot +c interval (tv(l),tv(l+1)). + l = 5 + j = 1 + nrdatv(1) = 0 + mpm = mv-1 + do 80 i=2,mpm + nrdatv(j) = nrdatv(j)+1 + if(v(i).lt.tv(l)) go to 80 + nrdatv(j) = nrdatv(j)-1 + l = l+1 + j = j+1 + nrdatv(j) = 0 + 80 continue + go to 100 +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c polynomial (which is a spline without interior knots). + 90 nu = nminu + nv = nminv + nrdatu(1) = mu-2 + nrdatv(1) = mv-2 + lastdi = 0 + nplusu = 0 + nplusv = 0 + fp0 = 0. + fpold = 0. + reducu = 0. + reducv = 0. + 100 mpm = mu+mv + ifsu = 0 + ifsv = 0 + ifbu = 0 + ifbv = 0 + p = -one +c main loop for the different sets of knots.mpm=mu+mv is a save upper +c bound for the number of trials. + do 250 iter=1,mpm + if(nu.eq.nminu .and. nv.eq.nminv) ier = -2 +c find nrintu (nrintv) which is the number of knot intervals in the +c u-direction (v-direction). + nrintu = nu-nminu+1 + nrintv = nv-nminv+1 +c find ncof, the number of b-spline coefficients for the current set +c of knots. + nk1u = nu-4 + nk1v = nv-4 + ncof = nk1u*nk1v +c find the position of the additional knots which are needed for the +c b-spline representation of s(u,v). + if(ipar(1).ne.0) go to 110 + i = nu + do 105 j=1,4 + tu(j) = ub + tu(i) = ue + i = i-1 + 105 continue + go to 120 + 110 l1 = 4 + l2 = l1 + l3 = nu-3 + l4 = l3 + tu(l2) = ub + tu(l3) = ue + do 115 j=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tu(l2) = tu(l4)-peru + tu(l3) = tu(l1)+peru + 115 continue + 120 if(ipar(2).ne.0) go to 130 + i = nv + do 125 j=1,4 + tv(j) = vb + tv(i) = ve + i = i-1 + 125 continue + go to 140 + 130 l1 = 4 + l2 = l1 + l3 = nv-3 + l4 = l3 + tv(l2) = vb + tv(l3) = ve + do 135 j=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tv(l2) = tv(l4)-perv + tv(l3) = tv(l1)+perv + 135 continue +c find the least-squares spline sinf(u,v) and calculate for each knot +c interval tu(j+3)<=u<=tu(j+4) (tv(j+3)<=v<=tv(j+4)) the sum +c of squared residuals fpintu(j),j=1,2,...,nu-7 (fpintv(j),j=1,2,... +c ,nv-7) for the data points having their absciss (ordinate)-value +c belonging to that interval. +c fp gives the total sum of squared residuals. + 140 call fpgrpa(ifsu,ifsv,ifbu,ifbv,idim,ipar,u,mu,v,mv,z,mz,tu, + * nu,tv,nv,p,c,nc,fp,fpintu,fpintv,mm,mvnu,wrk(lsu),wrk(lsv), + * wrk(lri),wrk(lq),wrk(lau),wrk(lau1),wrk(lav),wrk(lav1), + * wrk(lbu),wrk(lbv),nru,nrv) + if(ier.eq.(-2)) fp0 = fp +c test whether the least-squares spline is an acceptable solution. + if(iopt.lt.0) go to 440 + fpms = fp-s + if(abs(fpms) .lt. acc) go to 440 +c if f(p=inf) < s, we accept the choice of knots. + if(fpms.lt.0.) go to 300 +c if nu=nmaxu and nv=nmaxv, sinf(u,v) is an interpolating spline. + if(nu.eq.nmaxu .and. nv.eq.nmaxv) go to 430 +c increase the number of knots. +c if nu=nue and nv=nve we cannot further increase the number of knots +c because of the storage capacity limitation. + if(nu.eq.nue .and. nv.eq.nve) go to 420 + ier = 0 +c adjust the parameter reducu or reducv according to the direction +c in which the last added knots were located. + if (lastdi.lt.0) go to 150 + if (lastdi.eq.0) go to 170 + go to 160 + 150 reducu = fpold-fp + go to 170 + 160 reducv = fpold-fp +c store the sum of squared residuals for the current set of knots. + 170 fpold = fp +c find nplu, the number of knots we should add in the u-direction. + nplu = 1 + if(nu.eq.nminu) go to 180 + npl1 = nplusu*2 + rn = nplusu + if(reducu.gt.acc) npl1 = rn*fpms/reducu + nplu = min0(nplusu*2,max0(npl1,nplusu/2,1)) +c find nplv, the number of knots we should add in the v-direction. + 180 nplv = 1 + if(nv.eq.nminv) go to 190 + npl1 = nplusv*2 + rn = nplusv + if(reducv.gt.acc) npl1 = rn*fpms/reducv + nplv = min0(nplusv*2,max0(npl1,nplusv/2,1)) + 190 if (nplu.lt.nplv) go to 210 + if (nplu.eq.nplv) go to 200 + go to 230 + 200 if(lastdi.lt.0) go to 230 + 210 if(nu.eq.nue) go to 230 +c addition in the u-direction. + lastdi = -1 + nplusu = nplu + ifsu = 0 + do 220 l=1,nplusu +c add a new knot in the u-direction + call fpknot(u,mu,tu,nu,fpintu,nrdatu,nrintu,nuest,1) +c test whether we cannot further increase the number of knots in the +c u-direction. + if(nu.eq.nue) go to 250 + 220 continue + go to 250 + 230 if(nv.eq.nve) go to 210 +c addition in the v-direction. + lastdi = 1 + nplusv = nplv + ifsv = 0 + do 240 l=1,nplusv +c add a new knot in the v-direction. + call fpknot(v,mv,tv,nv,fpintv,nrdatv,nrintv,nvest,1) +c test whether we cannot further increase the number of knots in the +c v-direction. + if(nv.eq.nve) go to 250 + 240 continue +c restart the computations with the new set of knots. + 250 continue +c test whether the least-squares polynomial is a solution of our +c approximation problem. + 300 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline sp(u,v) c +c ***************************************************** c +c we have determined the number of knots and their position. we now c +c compute the b-spline coefficients of the smoothing spline sp(u,v). c +c this smoothing spline varies with the parameter p in such a way thatc +c f(p)=suml=1,idim(sumi=1,mu(sumj=1,mv((z(i,j,l)-sp(u(i),v(j),l))**2) c +c is a continuous, strictly decreasing function of p. moreover the c +c least-squares polynomial corresponds to p=0 and the least-squares c +c spline to p=infinity. iteratively we then have to determine the c +c positive value of p such that f(p)=s. the process which is proposed c +c here makes use of rational interpolation. f(p) is approximated by a c +c rational function r(p)=(u*p+v)/(p+w); three values of p (p1,p2,p3) c +c with corresponding values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s)c +c are used to calculate the new value of p such that r(p)=s. c +c convergence is guaranteed by taking f1 > 0 and f3 < 0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = one + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p)=s. + do 350 iter = 1,maxit +c find the smoothing spline sp(u,v) and the corresponding sum of +c squared residuals fp. + call fpgrpa(ifsu,ifsv,ifbu,ifbv,idim,ipar,u,mu,v,mv,z,mz,tu, + * nu,tv,nv,p,c,nc,fp,fpintu,fpintv,mm,mvnu,wrk(lsu),wrk(lsv), + * wrk(lri),wrk(lq),wrk(lau),wrk(lau1),wrk(lav),wrk(lav1), + * wrk(lbu),wrk(lbv),nru,nrv) +c test whether the approximation sp(u,v) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 320 + if((f2-f3).gt.acc) go to 310 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 350 + 310 if(f2.lt.0.) ich3 = 1 + 320 if(ich1.ne.0) go to 340 + if((f1-f2).gt.acc) go to 330 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 350 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 350 +c test whether the iteration process proceeds as theoretically +c expected. + 330 if(f2.gt.0.) ich1 = 1 + 340 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 350 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + fp = 0. + 440 return + end Added: branches/Interpolate1D/fitpack/fpperi.f =================================================================== --- branches/Interpolate1D/fitpack/fpperi.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpperi.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,616 @@ + subroutine fpperi(iopt,x,y,w,m,k,s,nest,tol,maxit,k1,k2,n,t,c, + * fp,fpint,z,a1,a2,b,g1,g2,q,nrdata,ier) +c .. +c ..scalar arguments.. + real*8 s,tol,fp + integer iopt,m,k,nest,maxit,k1,k2,n,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),t(nest),c(nest),fpint(nest),z(nest), + * a1(nest,k1),a2(nest,k),b(nest,k2),g1(nest,k2),g2(nest,k1), + * q(m,k1) + integer nrdata(nest) +c ..local scalars.. + real*8 acc,cos,c1,d1,fpart,fpms,fpold,fp0,f1,f2,f3,p,per,pinv,piv, + * + * p1,p2,p3,sin,store,term,wi,xi,yi,rn,one,con1,con4,con9,half + integer i,ich1,ich3,ij,ik,it,iter,i1,i2,i3,j,jk,jper,j1,j2,kk, + * kk1,k3,l,l0,l1,l5,mm,m1,new,nk1,nk2,nmax,nmin,nplus,npl1, + * nrint,n10,n11,n7,n8 +c ..local arrays.. + real*8 h(6),h1(7),h2(6) +c ..function references.. + real*8 abs,fprati + integer max0,min0 +c ..subroutine references.. +c fpbacp,fpbspl,fpgivs,fpdisc,fpknot,fprota +c .. +c set constants + one = 0.1e+01 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 + half = 0.5e0 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position c +c ************************************************************** c +c given a set of knots we compute the least-squares periodic spline c +c sinf(x). if the sum f(p=inf) <= s we accept the choice of knots. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmax = m+2*k. c +c if s > 0 and c +c iopt=0 we first compute the least-squares polynomial of c +c degree k; n = nmin = 2*k+2. since s(x) must be periodic we c +c find that s(x) is a constant function. c +c iopt=1 we start with the set of knots found at the last c +c call of the routine, except for the case that s > fp0; then c +c we compute directly the least-squares periodic polynomial. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc + m1 = m-1 + kk = k + kk1 = k1 + k3 = 3*k+1 + nmin = 2*k1 +c determine the length of the period of s(x). + per = x(m)-x(1) + if(iopt.lt.0) go to 50 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s +c determine nmax, the number of knots for periodic spline interpolation + nmax = m+2*k + if(s.gt.0. .or. nmax.eq.nmin) go to 30 +c if s=0, s(x) is an interpolating spline. + n = nmax +c test whether the required storage space exceeds the available one. + if(n.gt.nest) go to 620 +c find the position of the interior knots in case of interpolation. + 5 if((k/2)*2 .eq. k) go to 20 + do 10 i=2,m1 + j = i+k + t(j) = x(i) + 10 continue + if(s.gt.0.) go to 50 + kk = k-1 + kk1 = k + if(kk.gt.0) go to 50 + t(1) = t(m)-per + t(2) = x(1) + t(m+1) = x(m) + t(m+2) = t(3)+per + do 15 i=1,m1 + c(i) = y(i) + 15 continue + c(m) = c(1) + fp = 0. + fpint(n) = fp0 + fpint(n-1) = 0. + nrdata(n) = 0 + go to 630 + 20 do 25 i=2,m1 + j = i+k + t(j) = (x(i)+x(i-1))*half + 25 continue + go to 50 +c if s > 0 our initial choice depends on the value of iopt. +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c periodic polynomial. (i.e. a constant function). +c if iopt=1 and fp0>s we start computing the least-squares periodic +c spline according the set of knots found at the last call of the +c routine. + 30 if(iopt.eq.0) go to 35 + if(n.eq.nmin) go to 35 + fp0 = fpint(n) + fpold = fpint(n-1) + nplus = nrdata(n) + if(fp0.gt.s) go to 50 +c the case that s(x) is a constant function is treated separetely. +c find the least-squares constant c1 and compute fp0 at the same time. + 35 fp0 = 0. + d1 = 0. + c1 = 0. + do 40 it=1,m1 + wi = w(it) + yi = y(it)*wi + call fpgivs(wi,d1,cos,sin) + call fprota(cos,sin,yi,c1) + fp0 = fp0+yi**2 + 40 continue + c1 = c1/d1 +c test whether that constant function is a solution of our problem. + fpms = fp0-s + if(fpms.lt.acc .or. nmax.eq.nmin) go to 640 + fpold = fp0 +c test whether the required storage space exceeds the available one. + if(nmin.ge.nest) go to 620 +c start computing the least-squares periodic spline with one +c interior knot. + nplus = 1 + n = nmin+1 + mm = (m+1)/2 + t(k2) = x(mm) + nrdata(1) = mm-2 + nrdata(2) = m1-mm +c main loop for the different sets of knots. m is a save upper +c bound for the number of trials. + 50 do 340 iter=1,m +c find nrint, the number of knot intervals. + nrint = n-nmin+1 +c find the position of the additional knots which are needed for +c the b-spline representation of s(x). if we take +c t(k+1) = x(1), t(n-k) = x(m) +c t(k+1-j) = t(n-k-j) - per, j=1,2,...k +c t(n-k+j) = t(k+1+j) + per, j=1,2,...k +c then s(x) is a periodic spline with period per if the b-spline +c coefficients satisfy the following conditions +c c(n7+j) = c(j), j=1,...k (**) with n7=n-2*k-1. + t(k1) = x(1) + nk1 = n-k1 + nk2 = nk1+1 + t(nk2) = x(m) + do 60 j=1,k + i1 = nk2+j + i2 = nk2-j + j1 = k1+j + j2 = k1-j + t(i1) = t(j1)+per + t(j2) = t(i2)-per + 60 continue +c compute the b-spline coefficients c(j),j=1,...n7 of the least-squares +c periodic spline sinf(x). the observation matrix a is built up row +c by row while taking into account condition (**) and is reduced to +c triangular form by givens transformations . +c at the same time fp=f(p=inf) is computed. +c the n7 x n7 triangularised upper matrix a has the form +c ! a1 ' ! +c a = ! ' a2 ! +c ! 0 ' ! +c with a2 a n7 x k matrix and a1 a n10 x n10 upper triangular +c matrix of bandwith k+1 ( n10 = n7-k). +c initialization. + do 70 i=1,nk1 + z(i) = 0. + do 70 j=1,kk1 + a1(i,j) = 0. + 70 continue + n7 = nk1-k + n10 = n7-kk + jper = 0 + fp = 0. + l = k1 + do 290 it=1,m1 +c fetch the current data point x(it),y(it) + xi = x(it) + wi = w(it) + yi = y(it)*wi +c search for knot interval t(l) <= xi < t(l+1). + 80 if(xi.lt.t(l+1)) go to 85 + l = l+1 + go to 80 +c evaluate the (k+1) non-zero b-splines at xi and store them in q. + 85 call fpbspl(t,n,k,xi,l,h) + do 90 i=1,k1 + q(it,i) = h(i) + h(i) = h(i)*wi + 90 continue + l5 = l-k1 +c test whether the b-splines nj,k+1(x),j=1+n7,...nk1 are all zero at xi + if(l5.lt.n10) go to 285 + if(jper.ne.0) go to 160 +c initialize the matrix a2. + do 95 i=1,n7 + do 95 j=1,kk + a2(i,j) = 0. + 95 continue + jk = n10+1 + do 110 i=1,kk + ik = jk + do 100 j=1,kk1 + if(ik.le.0) go to 105 + a2(ik,i) = a1(ik,j) + ik = ik-1 + 100 continue + 105 jk = jk+1 + 110 continue + jper = 1 +c if one of the b-splines nj,k+1(x),j=n7+1,...nk1 is not zero at xi +c we take account of condition (**) for setting up the new row +c of the observation matrix a. this row is stored in the arrays h1 +c (the part with respect to a1) and h2 (the part with +c respect to a2). + 160 do 170 i=1,kk + h1(i) = 0. + h2(i) = 0. + 170 continue + h1(kk1) = 0. + j = l5-n10 + do 210 i=1,kk1 + j = j+1 + l0 = j + 180 l1 = l0-kk + if(l1.le.0) go to 200 + if(l1.le.n10) go to 190 + l0 = l1-n10 + go to 180 + 190 h1(l1) = h(i) + go to 210 + 200 h2(l0) = h2(l0)+h(i) + 210 continue +c rotate the new row of the observation matrix into triangle +c by givens transformations. + if(n10.le.0) go to 250 +c rotation with the rows 1,2,...n10 of matrix a. + do 240 j=1,n10 + piv = h1(1) + if(piv.ne.0.) go to 214 + do 212 i=1,kk + h1(i) = h1(i+1) + 212 continue + h1(kk1) = 0. + go to 240 +c calculate the parameters of the givens transformation. + 214 call fpgivs(piv,a1(j,1),cos,sin) +c transformation to the right hand side. + call fprota(cos,sin,yi,z(j)) +c transformations to the left hand side with respect to a2. + do 220 i=1,kk + call fprota(cos,sin,h2(i),a2(j,i)) + 220 continue + if(j.eq.n10) go to 250 + i2 = min0(n10-j,kk) +c transformations to the left hand side with respect to a1. + do 230 i=1,i2 + i1 = i+1 + call fprota(cos,sin,h1(i1),a1(j,i1)) + h1(i) = h1(i1) + 230 continue + h1(i1) = 0. + 240 continue +c rotation with the rows n10+1,...n7 of matrix a. + 250 do 270 j=1,kk + ij = n10+j + if(ij.le.0) go to 270 + piv = h2(j) + if(piv.eq.0.) go to 270 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a2(ij,j),cos,sin) +c transformations to right hand side. + call fprota(cos,sin,yi,z(ij)) + if(j.eq.kk) go to 280 + j1 = j+1 +c transformations to left hand side. + do 260 i=j1,kk + call fprota(cos,sin,h2(i),a2(ij,i)) + 260 continue + 270 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 280 fp = fp+yi**2 + go to 290 +c rotation of the new row of the observation matrix into +c triangle in case the b-splines nj,k+1(x),j=n7+1,...n-k-1 are all zero +c at xi. + 285 j = l5 + do 140 i=1,kk1 + j = j+1 + piv = h(i) + if(piv.eq.0.) go to 140 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a1(j,1),cos,sin) +c transformations to right hand side. + call fprota(cos,sin,yi,z(j)) + if(i.eq.kk1) go to 150 + i2 = 1 + i3 = i+1 +c transformations to left hand side. + do 130 i1=i3,kk1 + i2 = i2+1 + call fprota(cos,sin,h(i1),a1(j,i2)) + 130 continue + 140 continue +c add contribution of this row to the sum of squares of residual +c right hand sides. + 150 fp = fp+yi**2 + 290 continue + fpint(n) = fp0 + fpint(n-1) = fpold + nrdata(n) = nplus +c backward substitution to obtain the b-spline coefficients c(j),j=1,.n + call fpbacp(a1,a2,z,n7,kk,c,kk1,nest) +c calculate from condition (**) the coefficients c(j+n7),j=1,2,...k. + do 295 i=1,k + j = i+n7 + c(j) = c(i) + 295 continue + if(iopt.lt.0) go to 660 +c test whether the approximation sinf(x) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 660 +c if f(p=inf) < s accept the choice of knots. + if(fpms.lt.0.) go to 350 +c if n=nmax, sinf(x) is an interpolating spline. + if(n.eq.nmax) go to 630 +c increase the number of knots. +c if n=nest we cannot increase the number of knots because of the +c storage capacity limitation. + if(n.eq.nest) go to 620 +c determine the number of knots nplus we are going to add. + npl1 = nplus*2 + rn = nplus + if(fpold-fp.gt.acc) npl1 = rn*fpms/(fpold-fp) + nplus = min0(nplus*2,max0(npl1,nplus/2,1)) + fpold = fp +c compute the sum(wi*(yi-s(xi))**2) for each knot interval +c t(j+k) <= xi <= t(j+k+1) and store it in fpint(j),j=1,2,...nrint. + fpart = 0. + i = 1 + l = k1 + do 320 it=1,m1 + if(x(it).lt.t(l)) go to 300 + new = 1 + l = l+1 + 300 term = 0. + l0 = l-k2 + do 310 j=1,k1 + l0 = l0+1 + term = term+c(l0)*q(it,j) + 310 continue + term = (w(it)*(term-y(it)))**2 + fpart = fpart+term + if(new.eq.0) go to 320 + if(l.gt.k2) go to 315 + fpint(nrint) = term + new = 0 + go to 320 + 315 store = term*half + fpint(i) = fpart-store + i = i+1 + fpart = store + new = 0 + 320 continue + fpint(nrint) = fpint(nrint)+fpart + do 330 l=1,nplus +c add a new knot + call fpknot(x,m,t,n,fpint,nrdata,nrint,nest,1) +c if n=nmax we locate the knots as for interpolation. + if(n.eq.nmax) go to 5 +c test whether we cannot further increase the number of knots. + if(n.eq.nest) go to 340 + 330 continue +c restart the computations with the new set of knots. + 340 continue +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing periodic spline sp(x). c +c ************************************************************* c +c we have determined the number of knots and their position. c +c we now compute the b-spline coefficients of the smoothing spline c +c sp(x). the observation matrix a is extended by the rows of matrix c +c b expressing that the kth derivative discontinuities of sp(x) at c +c the interior knots t(k+2),...t(n-k-1) must be zero. the corres- c +c ponding weights of these additional rows are set to 1/sqrt(p). c +c iteratively we then have to determine the value of p such that c +c f(p)=sum(w(i)*(y(i)-sp(x(i)))**2) be = s. we already know that c +c the least-squares constant function corresponds to p=0, and that c +c the least-squares periodic spline corresponds to p=infinity. the c +c iteration process which is proposed here, makes use of rational c +c interpolation. since f(p) is a convex and strictly decreasing c +c function of p, it can be approximated by a rational function c +c r(p) = (u*p+v)/(p+w). three values of p(p1,p2,p3) with correspond- c +c ing values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used c +c to calculate the new value of p such that r(p)=s. convergence is c +c guaranteed by taking f1>0 and f3<0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jump of the kth derivative of the +c b-splines at the knots t(l),l=k+2,...n-k-1 and store in b. + 350 call fpdisc(t,n,k2,b,nest) +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + n11 = n10-1 + n8 = n7-1 + p = 0. + l = n7 + do 352 i=1,k + j = k+1-i + p = p+a2(l,j) + l = l-1 + if(l.eq.0) go to 356 + 352 continue + do 354 i=1,n10 + p = p+a1(i,1) + 354 continue + 356 rn = n7 + p = rn/p + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p) = s. + do 595 iter=1,maxit +c form the matrix g as the matrix a extended by the rows of matrix b. +c the rows of matrix b with weight 1/p are rotated into +c the triangularised observation matrix a. +c after triangularisation our n7 x n7 matrix g takes the form +c ! g1 ' ! +c g = ! ' g2 ! +c ! 0 ' ! +c with g2 a n7 x (k+1) matrix and g1 a n11 x n11 upper triangular +c matrix of bandwidth k+2. ( n11 = n7-k-1) + pinv = one/p +c store matrix a into g + do 360 i=1,n7 + c(i) = z(i) + g1(i,k1) = a1(i,k1) + g1(i,k2) = 0. + g2(i,1) = 0. + do 360 j=1,k + g1(i,j) = a1(i,j) + g2(i,j+1) = a2(i,j) + 360 continue + l = n10 + do 370 j=1,k1 + if(l.le.0) go to 375 + g2(l,1) = a1(l,j) + l = l-1 + 370 continue + 375 do 540 it=1,n8 +c fetch a new row of matrix b and store it in the arrays h1 (the part +c with respect to g1) and h2 (the part with respect to g2). + yi = 0. + do 380 i=1,k1 + h1(i) = 0. + h2(i) = 0. + 380 continue + h1(k2) = 0. + if(it.gt.n11) go to 420 + l = it + l0 = it + do 390 j=1,k2 + if(l0.eq.n10) go to 400 + h1(j) = b(it,j)*pinv + l0 = l0+1 + 390 continue + go to 470 + 400 l0 = 1 + do 410 l1=j,k2 + h2(l0) = b(it,l1)*pinv + l0 = l0+1 + 410 continue + go to 470 + 420 l = 1 + i = it-n10 + do 460 j=1,k2 + i = i+1 + l0 = i + 430 l1 = l0-k1 + if(l1.le.0) go to 450 + if(l1.le.n11) go to 440 + l0 = l1-n11 + go to 430 + 440 h1(l1) = b(it,j)*pinv + go to 460 + 450 h2(l0) = h2(l0)+b(it,j)*pinv + 460 continue + if(n11.le.0) go to 510 +c rotate this row into triangle by givens transformations without +c square roots. +c rotation with the rows l,l+1,...n11. + 470 do 500 j=l,n11 + piv = h1(1) +c calculate the parameters of the givens transformation. + call fpgivs(piv,g1(j,1),cos,sin) +c transformation to right hand side. + call fprota(cos,sin,yi,c(j)) +c transformation to the left hand side with respect to g2. + do 480 i=1,k1 + call fprota(cos,sin,h2(i),g2(j,i)) + 480 continue + if(j.eq.n11) go to 510 + i2 = min0(n11-j,k1) +c transformation to the left hand side with respect to g1. + do 490 i=1,i2 + i1 = i+1 + call fprota(cos,sin,h1(i1),g1(j,i1)) + h1(i) = h1(i1) + 490 continue + h1(i1) = 0. + 500 continue +c rotation with the rows n11+1,...n7 + 510 do 530 j=1,k1 + ij = n11+j + if(ij.le.0) go to 530 + piv = h2(j) +c calculate the parameters of the givens transformation + call fpgivs(piv,g2(ij,j),cos,sin) +c transformation to the right hand side. + call fprota(cos,sin,yi,c(ij)) + if(j.eq.k1) go to 540 + j1 = j+1 +c transformation to the left hand side. + do 520 i=j1,k1 + call fprota(cos,sin,h2(i),g2(ij,i)) + 520 continue + 530 continue + 540 continue +c backward substitution to obtain the b-spline coefficients +c c(j),j=1,2,...n7 of sp(x). + call fpbacp(g1,g2,c,n7,k1,c,k2,nest) +c calculate from condition (**) the b-spline coefficients c(n7+j),j=1,. + do 545 i=1,k + j = i+n7 + c(j) = c(i) + 545 continue +c computation of f(p). + fp = 0. + l = k1 + do 570 it=1,m1 + if(x(it).lt.t(l)) go to 550 + l = l+1 + 550 l0 = l-k2 + term = 0. + do 560 j=1,k1 + l0 = l0+1 + term = term+c(l0)*q(it,j) + 560 continue + fp = fp+(w(it)*(term-y(it)))**2 + 570 continue +c test whether the approximation sp(x) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 660 +c test whether the maximal number of iterations is reached. + if(iter.eq.maxit) go to 600 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 580 + if((f2-f3) .gt. acc) go to 575 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 +p2*con1 + go to 595 + 575 if(f2.lt.0.) ich3 = 1 + 580 if(ich1.ne.0) go to 590 + if((f1-f2) .gt. acc) go to 585 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 595 + if(p.ge.p3) p = p2*con1 +p3*con9 + go to 595 + 585 if(f2.gt.0.) ich1 = 1 +c test whether the iteration process proceeds as theoretically +c expected. + 590 if(f2.ge.f1 .or. f2.le.f3) go to 610 +c find the new value for p. + p = fprati(p1,f1,p2,f2,p3,f3) + 595 continue +c error codes and messages. + 600 ier = 3 + go to 660 + 610 ier = 2 + go to 660 + 620 ier = 1 + go to 660 + 630 ier = -1 + go to 660 + 640 ier = -2 +c the least-squares constant function c1 is a solution of our problem. +c a constant function is a spline of degree k with all b-spline +c coefficients equal to that constant c1. + do 650 i=1,k1 + rn = k1-i + t(i) = x(1)-rn*per + c(i) = c1 + j = i+k1 + rn = i-1 + t(j) = x(m)+rn*per + 650 continue + n = nmin + fp = fp0 + fpint(n) = fp0 + fpint(n-1) = 0. + nrdata(n) = 0 + 660 return + end Added: branches/Interpolate1D/fitpack/fppocu.f =================================================================== --- branches/Interpolate1D/fitpack/fppocu.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fppocu.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,72 @@ + subroutine fppocu(idim,k,a,b,ib,db,nb,ie,de,ne,cp,np) +c subroutine fppocu finds a idim-dimensional polynomial curve p(u) = +c (p1(u),p2(u),...,pidim(u)) of degree k, satisfying certain derivative +c constraints at the end points a and b, i.e. +c (l) +c if ib > 0 : pj (a) = db(idim*l+j), l=0,1,...,ib-1 +c (l) +c if ie > 0 : pj (b) = de(idim*l+j), l=0,1,...,ie-1 +c +c the polynomial curve is returned in its b-spline representation +c ( coefficients cp(j), j=1,2,...,np ) +c .. +c ..scalar arguments.. + integer idim,k,ib,nb,ie,ne,np + real*8 a,b +c ..array arguments.. + real*8 db(nb),de(ne),cp(np) +c ..local scalars.. + real*8 ab,aki + integer i,id,j,jj,l,ll,k1,k2 +c ..local array.. + real*8 work(6,6) +c .. + k1 = k+1 + k2 = 2*k1 + ab = b-a + do 110 id=1,idim + do 10 j=1,k1 + work(j,1) = 0. + 10 continue + if(ib.eq.0) go to 50 + l = id + do 20 i=1,ib + work(1,i) = db(l) + l = l+idim + 20 continue + if(ib.eq.1) go to 50 + ll = ib + do 40 j=2,ib + ll = ll-1 + do 30 i=1,ll + aki = k1-i + work(j,i) = ab*work(j-1,i+1)/aki + work(j-1,i) + 30 continue + 40 continue + 50 if(ie.eq.0) go to 90 + l = id + j = k1 + do 60 i=1,ie + work(j,i) = de(l) + l = l+idim + j = j-1 + 60 continue + if(ie.eq.1) go to 90 + ll = ie + do 80 jj=2,ie + ll = ll-1 + j = k1+1-jj + do 70 i=1,ll + aki = k1-i + work(j,i) = work(j+1,i) - ab*work(j,i+1)/aki + j = j-1 + 70 continue + 80 continue + 90 l = (id-1)*k2 + do 100 j=1,k1 + l = l+1 + cp(l) = work(j,1) + 100 continue + 110 continue + return + end Added: branches/Interpolate1D/fitpack/fppogr.f =================================================================== --- branches/Interpolate1D/fitpack/fppogr.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fppogr.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,410 @@ + subroutine fppogr(iopt,ider,u,mu,v,mv,z,mz,z0,r,s,nuest,nvest, + * tol,maxit,nc,nu,tu,nv,tv,c,fp,fp0,fpold,reducu,reducv,fpintu, + * fpintv,dz,step,lastdi,nplusu,nplusv,lasttu,nru,nrv,nrdatu, + * nrdatv,wrk,lwrk,ier) +c .. +c ..scalar arguments.. + integer mu,mv,mz,nuest,nvest,maxit,nc,nu,nv,lastdi,nplusu,nplusv, + * lasttu,lwrk,ier + real*8 z0,r,s,tol,fp,fp0,fpold,reducu,reducv,step +c ..array arguments.. + integer iopt(3),ider(2),nrdatu(nuest),nrdatv(nvest),nru(mu), + * nrv(mv) + real*8 u(mu),v(mv),z(mz),tu(nuest),tv(nvest),c(nc),fpintu(nuest), + * fpintv(nvest),dz(3),wrk(lwrk) +c ..local scalars.. + real*8 acc,fpms,f1,f2,f3,p,per,pi,p1,p2,p3,vb,ve,zmax,zmin,rn,one, + * + * con1,con4,con9 + integer i,ich1,ich3,ifbu,ifbv,ifsu,ifsv,istart,iter,i1,i2,j,ju, + * ktu,l,l1,l2,l3,l4,mpm,mumin,mu0,mu1,nn,nplu,nplv,npl1,nrintu, + * nrintv,nue,numax,nve,nvmax +c ..local arrays.. + integer idd(2) + real*8 dzz(3) +c ..function references.. + real*8 abs,datan2,fprati + integer max0,min0 +c ..subroutine references.. +c fpknot,fpopdi +c .. +c set constants + one = 1d0 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 +c initialization + ifsu = 0 + ifsv = 0 + ifbu = 0 + ifbv = 0 + p = -one + mumin = 4-iopt(3) + if(ider(1).ge.0) mumin = mumin-1 + if(iopt(2).eq.1 .and. ider(2).eq.1) mumin = mumin-1 + pi = datan2(0d0,-one) + per = pi+pi + vb = v(1) + ve = vb+per +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position. c +c **************************************************************** c +c given a set of knots we compute the least-squares spline sinf(u,v) c +c and the corresponding sum of squared residuals fp = f(p=inf). c +c if iopt(1)=-1 sinf(u,v) is the requested approximation. c +c if iopt(1)>=0 we check whether we can accept the knots: c +c if fp <= s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares spline until finally fp <= s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots in the u-direction equals nu=numax=mu+5+iopt(2)+iopt(3) c +c and in the v-direction nv=nvmax=mv+7. c +c if s>0 and c +c iopt(1)=0 we first compute the least-squares polynomial,i.e. a c +c spline without interior knots : nu=8 ; nv=8. c +c iopt(1)=1 we start with the set of knots found at the last call c +c of the routine, except for the case that s > fp0; then we c +c compute the least-squares polynomial directly. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc + if(iopt(1).lt.0) go to 120 +c acc denotes the absolute tolerance for the root of f(p)=s. + acc = tol*s +c numax and nvmax denote the number of knots needed for interpolation. + numax = mu+5+iopt(2)+iopt(3) + nvmax = mv+7 + nue = min0(numax,nuest) + nve = min0(nvmax,nvest) + if(s.gt.0.) go to 100 +c if s = 0, s(u,v) is an interpolating spline. + nu = numax + nv = nvmax +c test whether the required storage space exceeds the available one. + if(nu.gt.nuest .or. nv.gt.nvest) go to 420 +c find the position of the knots in the v-direction. + do 10 l=1,mv + tv(l+3) = v(l) + 10 continue + tv(mv+4) = ve + l1 = mv-2 + l2 = mv+5 + do 20 i=1,3 + tv(i) = v(l1)-per + tv(l2) = v(i+1)+per + l1 = l1+1 + l2 = l2+1 + 20 continue +c if not all the derivative values g(i,j) are given, we will first +c estimate these values by computing a least-squares spline + idd(1) = ider(1) + if(idd(1).eq.0) idd(1) = 1 + if(idd(1).gt.0) dz(1) = z0 + idd(2) = ider(2) + if(ider(1).lt.0) go to 30 + if(iopt(2).eq.0 .or. ider(2).ne.0) go to 70 +c we set up the knots in the u-direction for computing the least-squares +c spline. + 30 i1 = 3 + i2 = mu-2 + nu = 4 + do 40 i=1,mu + if(i1.gt.i2) go to 50 + nu = nu+1 + tu(nu) = u(i1) + i1 = i1+2 + 40 continue + 50 do 60 i=1,4 + tu(i) = 0. + nu = nu+1 + tu(nu) = r + 60 continue +c we compute the least-squares spline for estimating the derivatives. + call fpopdi(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,z,mz,z0,dz,iopt,idd, + * tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru,nrv, + * wrk,lwrk) + ifsu = 0 +c if all the derivatives at the origin are known, we compute the +c interpolating spline. +c we set up the knots in the u-direction, needed for interpolation. + 70 nn = numax-8 + if(nn.eq.0) go to 95 + ju = 2-iopt(2) + do 80 l=1,nn + tu(l+4) = u(ju) + ju = ju+1 + 80 continue + nu = numax + l = nu + do 90 i=1,4 + tu(i) = 0. + tu(l) = r + l = l-1 + 90 continue +c we compute the interpolating spline. + 95 call fpopdi(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,z,mz,z0,dz,iopt,idd, + * tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru,nrv, + * wrk,lwrk) + go to 430 +c if s>0 our initial choice of knots depends on the value of iopt(1). + 100 ier = 0 + if(iopt(1).eq.0) go to 115 + step = -step + if(fp0.le.s) go to 115 +c if iopt(1)=1 and fp0 > s we start computing the least-squares spline +c according to the set of knots found at the last call of the routine. +c we determine the number of grid coordinates u(i) inside each knot +c interval (tu(l),tu(l+1)). + l = 5 + j = 1 + nrdatu(1) = 0 + mu0 = 2-iopt(2) + mu1 = mu-2+iopt(3) + do 105 i=mu0,mu1 + nrdatu(j) = nrdatu(j)+1 + if(u(i).lt.tu(l)) go to 105 + nrdatu(j) = nrdatu(j)-1 + l = l+1 + j = j+1 + nrdatu(j) = 0 + 105 continue +c we determine the number of grid coordinates v(i) inside each knot +c interval (tv(l),tv(l+1)). + l = 5 + j = 1 + nrdatv(1) = 0 + do 110 i=2,mv + nrdatv(j) = nrdatv(j)+1 + if(v(i).lt.tv(l)) go to 110 + nrdatv(j) = nrdatv(j)-1 + l = l+1 + j = j+1 + nrdatv(j) = 0 + 110 continue + idd(1) = ider(1) + idd(2) = ider(2) + go to 120 +c if iopt(1)=0 or iopt(1)=1 and s >= fp0,we start computing the least- +c squares polynomial (which is a spline without interior knots). + 115 ier = -2 + idd(1) = ider(1) + idd(2) = 1 + nu = 8 + nv = 8 + nrdatu(1) = mu-3+iopt(2)+iopt(3) + nrdatv(1) = mv-1 + lastdi = 0 + nplusu = 0 + nplusv = 0 + fp0 = 0. + fpold = 0. + reducu = 0. + reducv = 0. +c main loop for the different sets of knots.mpm=mu+mv is a save upper +c bound for the number of trials. + 120 mpm = mu+mv + do 270 iter=1,mpm +c find nrintu (nrintv) which is the number of knot intervals in the +c u-direction (v-direction). + nrintu = nu-7 + nrintv = nv-7 +c find the position of the additional knots which are needed for the +c b-spline representation of s(u,v). + i = nu + do 130 j=1,4 + tu(j) = 0. + tu(i) = r + i = i-1 + 130 continue + l1 = 4 + l2 = l1 + l3 = nv-3 + l4 = l3 + tv(l2) = vb + tv(l3) = ve + do 140 j=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tv(l2) = tv(l4)-per + tv(l3) = tv(l1)+per + 140 continue +c find an estimate of the range of possible values for the optimal +c derivatives at the origin. + ktu = nrdatu(1)+2-iopt(2) + if(nrintu.eq.1) ktu = mu + if(ktu.lt.mumin) ktu = mumin + if(ktu.eq.lasttu) go to 150 + zmin = z0 + zmax = z0 + l = mv*ktu + do 145 i=1,l + if(z(i).lt.zmin) zmin = z(i) + if(z(i).gt.zmax) zmax = z(i) + 145 continue + step = zmax-zmin + lasttu = ktu +c find the least-squares spline sinf(u,v). + 150 call fpopdi(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,z,mz,z0,dz,iopt,idd, + * tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru,nrv, + * wrk,lwrk) + if(step.lt.0.) step = -step + if(ier.eq.(-2)) fp0 = fp +c test whether the least-squares spline is an acceptable solution. + if(iopt(1).lt.0) go to 440 + fpms = fp-s + if(abs(fpms) .lt. acc) go to 440 +c if f(p=inf) < s, we accept the choice of knots. + if(fpms.lt.0.) go to 300 +c if nu=numax and nv=nvmax, sinf(u,v) is an interpolating spline + if(nu.eq.numax .and. nv.eq.nvmax) go to 430 +c increase the number of knots. +c if nu=nue and nv=nve we cannot further increase the number of knots +c because of the storage capacity limitation. + if(nu.eq.nue .and. nv.eq.nve) go to 420 + if(ider(1).eq.0) fpintu(1) = fpintu(1)+(z0-c(1))**2 + ier = 0 +c adjust the parameter reducu or reducv according to the direction +c in which the last added knots were located. + if (lastdi.lt.0) go to 160 + if (lastdi.eq.0) go to 155 + go to 170 + 155 nplv = 3 + idd(2) = ider(2) + fpold = fp + go to 230 + 160 reducu = fpold-fp + go to 175 + 170 reducv = fpold-fp +c store the sum of squared residuals for the current set of knots. + 175 fpold = fp +c find nplu, the number of knots we should add in the u-direction. + nplu = 1 + if(nu.eq.8) go to 180 + npl1 = nplusu*2 + rn = nplusu + if(reducu.gt.acc) npl1 = rn*fpms/reducu + nplu = min0(nplusu*2,max0(npl1,nplusu/2,1)) +c find nplv, the number of knots we should add in the v-direction. + 180 nplv = 3 + if(nv.eq.8) go to 190 + npl1 = nplusv*2 + rn = nplusv + if(reducv.gt.acc) npl1 = rn*fpms/reducv + nplv = min0(nplusv*2,max0(npl1,nplusv/2,1)) +c test whether we are going to add knots in the u- or v-direction. + 190 if (nplu.lt.nplv) go to 210 + if (nplu.eq.nplv) go to 200 + go to 230 + 200 if(lastdi.lt.0) go to 230 + 210 if(nu.eq.nue) go to 230 +c addition in the u-direction. + lastdi = -1 + nplusu = nplu + ifsu = 0 + istart = 0 + if(iopt(2).eq.0) istart = 1 + do 220 l=1,nplusu +c add a new knot in the u-direction + call fpknot(u,mu,tu,nu,fpintu,nrdatu,nrintu,nuest,istart) +c test whether we cannot further increase the number of knots in the +c u-direction. + if(nu.eq.nue) go to 270 + 220 continue + go to 270 + 230 if(nv.eq.nve) go to 210 +c addition in the v-direction. + lastdi = 1 + nplusv = nplv + ifsv = 0 + do 240 l=1,nplusv +c add a new knot in the v-direction. + call fpknot(v,mv,tv,nv,fpintv,nrdatv,nrintv,nvest,1) +c test whether we cannot further increase the number of knots in the +c v-direction. + if(nv.eq.nve) go to 270 + 240 continue +c restart the computations with the new set of knots. + 270 continue +c test whether the least-squares polynomial is a solution of our +c approximation problem. + 300 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline sp(u,v) c +c ***************************************************** c +c we have determined the number of knots and their position. we now c +c compute the b-spline coefficients of the smoothing spline sp(u,v). c +c this smoothing spline depends on the parameter p in such a way that c +c f(p) = sumi=1,mu(sumj=1,mv((z(i,j)-sp(u(i),v(j)))**2) c +c is a continuous, strictly decreasing function of p. moreover the c +c least-squares polynomial corresponds to p=0 and the least-squares c +c spline to p=infinity. then iteratively we have to determine the c +c positive value of p such that f(p)=s. the process which is proposed c +c here makes use of rational interpolation. f(p) is approximated by a c +c rational function r(p)=(u*p+v)/(p+w); three values of p (p1,p2,p3) c +c with corresponding values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s)c +c are used to calculate the new value of p such that r(p)=s. c +c convergence is guaranteed by taking f1 > 0 and f3 < 0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = one + dzz(1) = dz(1) + dzz(2) = dz(2) + dzz(3) = dz(3) + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p)=s. + do 350 iter = 1,maxit +c find the smoothing spline sp(u,v) and the corresponding sum f(p). + call fpopdi(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,z,mz,z0,dzz,iopt,idd, + * tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru,nrv, + * wrk,lwrk) +c test whether the approximation sp(u,v) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 320 + if((f2-f3).gt.acc) go to 310 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 350 + 310 if(f2.lt.0.) ich3 = 1 + 320 if(ich1.ne.0) go to 340 + if((f1-f2).gt.acc) go to 330 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 350 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 350 +c test whether the iteration process proceeds as theoretically +c expected. + 330 if(f2.gt.0.) ich1 = 1 + 340 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 350 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + fp = 0. + 440 return + end Added: branches/Interpolate1D/fitpack/fppola.f =================================================================== --- branches/Interpolate1D/fitpack/fppola.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fppola.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,840 @@ + subroutine fppola(iopt1,iopt2,iopt3,m,u,v,z,w,rad,s,nuest,nvest, + * eta,tol,maxit,ib1,ib3,nc,ncc,intest,nrest,nu,tu,nv,tv,c,fp,sup, + * fpint,coord,f,ff,row,cs,cosi,a,q,bu,bv,spu,spv,h,index,nummer, + * wrk,lwrk,ier) +c ..scalar arguments.. + integer iopt1,iopt2,iopt3,m,nuest,nvest,maxit,ib1,ib3,nc,ncc, + * intest,nrest,nu,nv,lwrk,ier + real*8 s,eta,tol,fp,sup +c ..array arguments.. + integer index(nrest),nummer(m) + real*8 u(m),v(m),z(m),w(m),tu(nuest),tv(nvest),c(nc),fpint(intest) + *, + * coord(intest),f(ncc),ff(nc),row(nvest),cs(nvest),cosi(5,nvest), + * a(ncc,ib1),q(ncc,ib3),bu(nuest,5),bv(nvest,5),spu(m,4),spv(m,4), + * h(ib3),wrk(lwrk) +c ..user supplied function.. + real*8 rad +c ..local scalars.. + real*8 acc,arg,co,c1,c2,c3,c4,dmax,eps,fac,fac1,fac2,fpmax,fpms, + * f1,f2,f3,hui,huj,p,pi,pinv,piv,pi2,p1,p2,p3,r,ratio,si,sigma, + * sq,store,uu,u2,u3,wi,zi,rn,one,two,three,con1,con4,con9,half,ten + integer i,iband,iband3,iband4,ich1,ich3,ii,il,in,ipar,ipar1,irot, + * iter,i1,i2,i3,j,jl,jrot,j1,j2,k,l,la,lf,lh,ll,lu,lv,lwest,l1,l2, + * l3,l4,ncof,ncoff,nvv,nv4,nreg,nrint,nrr,nr1,nuu,nu4,num,num1, + * numin,nvmin,rank,iband1 +c ..local arrays.. + real*8 hu(4),hv(4) +c ..function references.. + real*8 abs,atan,cos,fprati,sin,sqrt + integer min0 +c ..subroutine references.. +c fporde,fpbspl,fpback,fpgivs,fprota,fprank,fpdisc,fprppo +c .. +c set constants + one = 1 + two = 2 + three = 3 + ten = 10 + half = 0.5e0 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 + pi = atan(one)*4 + pi2 = pi+pi + ipar = iopt2*(iopt2+3)/2 + ipar1 = ipar+1 + eps = sqrt(eta) + if(iopt1.lt.0) go to 90 + numin = 9 + nvmin = 9+iopt2*(iopt2+1) +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s + if(iopt1.eq.0) go to 10 + if(s.lt.sup) then + if (nv.lt.nvmin) go to 70 + go to 90 + endif +c if iopt1 = 0 we begin by computing the weighted least-squares +c polymomial of the form +c s(u,v) = f(1)*(1-u**3)+f(2)*u**3+f(3)*(u**2-u**3)+f(4)*(u-u**3) +c where f(4) = 0 if iopt2> 0 , f(3) = 0 if iopt2 > 1 and +c f(2) = 0 if iopt3> 0. +c the corresponding weighted sum of squared residuals gives the upper +c bound sup for the smoothing factor s. + 10 sup = 0. + do 20 i=1,4 + f(i) = 0. + do 20 j=1,4 + a(i,j) = 0. + 20 continue + do 50 i=1,m + wi = w(i) + zi = z(i)*wi + uu = u(i) + u2 = uu*uu + u3 = uu*u2 + h(1) = (one-u3)*wi + h(2) = u3*wi + h(3) = u2*(one-uu)*wi + h(4) = uu*(one-u2)*wi + if(iopt3.ne.0) h(2) = 0. + if(iopt2.gt.1) h(3) = 0. + if(iopt2.gt.0) h(4) = 0. + do 40 j=1,4 + piv = h(j) + if(piv.eq.0.) go to 40 + call fpgivs(piv,a(j,1),co,si) + call fprota(co,si,zi,f(j)) + if(j.eq.4) go to 40 + j1 = j+1 + j2 = 1 + do 30 l=j1,4 + j2 = j2+1 + call fprota(co,si,h(l),a(j,j2)) + 30 continue + 40 continue + sup = sup+zi*zi + 50 continue + if(a(4,1).ne.0.) f(4) = f(4)/a(4,1) + if(a(3,1).ne.0.) f(3) = (f(3)-a(3,2)*f(4))/a(3,1) + if(a(2,1).ne.0.) f(2) = (f(2)-a(2,2)*f(3)-a(2,3)*f(4))/a(2,1) + if(a(1,1).ne.0.) + * f(1) = (f(1)-a(1,2)*f(2)-a(1,3)*f(3)-a(1,4)*f(4))/a(1,1) +c find the b-spline representation of this least-squares polynomial + c1 = f(1) + c4 = f(2) + c2 = f(4)/three+c1 + c3 = (f(3)+two*f(4))/three+c1 + nu = 8 + nv = 8 + do 60 i=1,4 + c(i) = c1 + c(i+4) = c2 + c(i+8) = c3 + c(i+12) = c4 + tu(i) = 0. + tu(i+4) = one + rn = 2*i-9 + tv(i) = rn*pi + rn = 2*i-1 + tv(i+4) = rn*pi + 60 continue + fp = sup +c test whether the least-squares polynomial is an acceptable solution + fpms = sup-s + if(fpms.lt.acc) go to 960 +c test whether we cannot further increase the number of knots. + 70 if(nuest.lt.numin .or. nvest.lt.nvmin) go to 950 +c find the initial set of interior knots of the spline in case iopt1=0. + nu = numin + nv = nvmin + tu(5) = half + nvv = nv-8 + rn = nvv+1 + fac = pi2/rn + do 80 i=1,nvv + rn = i + tv(i+4) = rn*fac-pi + 80 continue +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1 : computation of least-squares bicubic splines. c +c ****************************************************** c +c if iopt1<0 we compute the least-squares bicubic spline according c +c to the given set of knots. c +c if iopt1>=0 we compute least-squares bicubic splines with in- c +c creasing numbers of knots until the corresponding sum f(p=inf)<=s. c +c the initial set of knots then depends on the value of iopt1 c +c if iopt1=0 we start with one interior knot in the u-direction c +c (0.5) and 1+iopt2*(iopt2+1) in the v-direction. c +c if iopt1>0 we start with the set of knots found at the last c +c call of the routine. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c main loop for the different sets of knots. m is a save upper bound +c for the number of trials. + 90 do 570 iter=1,m +c find the position of the additional knots which are needed for the +c b-spline representation of s(u,v). + l1 = 4 + l2 = l1 + l3 = nv-3 + l4 = l3 + tv(l2) = -pi + tv(l3) = pi + do 120 i=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tv(l2) = tv(l4)-pi2 + tv(l3) = tv(l1)+pi2 + 120 continue + l = nu + do 130 i=1,4 + tu(i) = 0. + tu(l) = one + l = l-1 + 130 continue +c find nrint, the total number of knot intervals and nreg, the number +c of panels in which the approximation domain is subdivided by the +c intersection of knots. + nuu = nu-7 + nvv = nv-7 + nrr = nvv/2 + nr1 = nrr+1 + nrint = nuu+nvv + nreg = nuu*nvv +c arrange the data points according to the panel they belong to. + call fporde(u,v,m,3,3,tu,nu,tv,nv,nummer,index,nreg) + if(iopt2.eq.0) go to 195 +c find the b-spline coefficients cosi of the cubic spline +c approximations for cr(v)=rad(v)*cos(v) and sr(v) = rad(v)*sin(v) +c if iopt2=1, and additionally also for cr(v)**2,sr(v)**2 and +c 2*cr(v)*sr(v) if iopt2=2 + do 140 i=1,nvv + do 135 j=1,ipar + cosi(j,i) = 0. + 135 continue + do 140 j=1,nvv + a(i,j) = 0. + 140 continue +c the coefficients cosi are obtained from interpolation conditions +c at the knots tv(i),i=4,5,...nv-4. + do 175 i=1,nvv + l2 = i+3 + arg = tv(l2) + call fpbspl(tv,nv,3,arg,l2,hv) + do 145 j=1,nvv + row(j) = 0. + 145 continue + ll = i + do 150 j=1,3 + if(ll.gt.nvv) ll= 1 + row(ll) = row(ll)+hv(j) + ll = ll+1 + 150 continue + co = cos(arg) + si = sin(arg) + r = rad(arg) + cs(1) = co*r + cs(2) = si*r + if(iopt2.eq.1) go to 155 + cs(3) = cs(1)*cs(1) + cs(4) = cs(2)*cs(2) + cs(5) = cs(1)*cs(2) + 155 do 170 j=1,nvv + piv = row(j) + if(piv.eq.0.) go to 170 + call fpgivs(piv,a(j,1),co,si) + do 160 l=1,ipar + call fprota(co,si,cs(l),cosi(l,j)) + 160 continue + if(j.eq.nvv) go to 175 + j1 = j+1 + j2 = 1 + do 165 l=j1,nvv + j2 = j2+1 + call fprota(co,si,row(l),a(j,j2)) + 165 continue + 170 continue + 175 continue + do 190 l=1,ipar + do 180 j=1,nvv + cs(j) = cosi(l,j) + 180 continue + call fpback(a,cs,nvv,nvv,cs,ncc) + do 185 j=1,nvv + cosi(l,j) = cs(j) + 185 continue + 190 continue +c find ncof, the dimension of the spline and ncoff, the number +c of coefficients in the standard b-spline representation. + 195 nu4 = nu-4 + nv4 = nv-4 + ncoff = nu4*nv4 + ncof = ipar1+nvv*(nu4-1-iopt2-iopt3) +c find the bandwidth of the observation matrix a. + iband = 4*nvv + if(nuu-iopt2-iopt3.le.1) iband = ncof + iband1 = iband-1 +c initialize the observation matrix a. + do 200 i=1,ncof + f(i) = 0. + do 200 j=1,iband + a(i,j) = 0. + 200 continue +c initialize the sum of squared residuals. + fp = 0. + ratio = one+tu(6)/tu(5) +c fetch the data points in the new order. main loop for the +c different panels. + do 380 num=1,nreg +c fix certain constants for the current panel; jrot records the column +c number of the first non-zero element in a row of the observation +c matrix according to a data point of the panel. + num1 = num-1 + lu = num1/nvv + l1 = lu+4 + lv = num1-lu*nvv+1 + l2 = lv+3 + jrot = 0 + if(lu.gt.iopt2) jrot = ipar1+(lu-iopt2-1)*nvv + lu = lu+1 +c test whether there are still data points in the current panel. + in = index(num) + 210 if(in.eq.0) go to 380 +c fetch a new data point. + wi = w(in) + zi = z(in)*wi +c evaluate for the u-direction, the 4 non-zero b-splines at u(in) + call fpbspl(tu,nu,3,u(in),l1,hu) +c evaluate for the v-direction, the 4 non-zero b-splines at v(in) + call fpbspl(tv,nv,3,v(in),l2,hv) +c store the value of these b-splines in spu and spv resp. + do 220 i=1,4 + spu(in,i) = hu(i) + spv(in,i) = hv(i) + 220 continue +c initialize the new row of observation matrix. + do 240 i=1,iband + h(i) = 0. + 240 continue +c calculate the non-zero elements of the new row by making the cross +c products of the non-zero b-splines in u- and v-direction and +c by taking into account the conditions of the splines. + do 250 i=1,nvv + row(i) = 0. + 250 continue +c take into account the periodicity condition of the bicubic splines. + ll = lv + do 260 i=1,4 + if(ll.gt.nvv) ll=1 + row(ll) = row(ll)+hv(i) + ll = ll+1 + 260 continue +c take into account the other conditions of the splines. + if(iopt2.eq.0 .or. lu.gt.iopt2+1) go to 280 + do 270 l=1,ipar + cs(l) = 0. + do 270 i=1,nvv + cs(l) = cs(l)+row(i)*cosi(l,i) + 270 continue +c fill in the non-zero elements of the new row. + 280 j1 = 0 + do 330 j =1,4 + jlu = j+lu + huj = hu(j) + if(jlu.gt.iopt2+2) go to 320 + go to (290,290,300,310),jlu + 290 h(1) = huj + j1 = 1 + go to 330 + 300 h(1) = h(1)+huj + h(2) = huj*cs(1) + h(3) = huj*cs(2) + j1 = 3 + go to 330 + 310 h(1) = h(1)+huj + h(2) = h(2)+huj*ratio*cs(1) + h(3) = h(3)+huj*ratio*cs(2) + h(4) = huj*cs(3) + h(5) = huj*cs(4) + h(6) = huj*cs(5) + j1 = 6 + go to 330 + 320 if(jlu.gt.nu4 .and. iopt3.ne.0) go to 330 + do 325 i=1,nvv + j1 = j1+1 + h(j1) = row(i)*huj + 325 continue + 330 continue + do 335 i=1,iband + h(i) = h(i)*wi + 335 continue +c rotate the row into triangle by givens transformations. + irot = jrot + do 350 i=1,iband + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 350 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(irot,1),co,si) +c apply that transformation to the right hand side. + call fprota(co,si,zi,f(irot)) + if(i.eq.iband) go to 360 +c apply that transformation to the left hand side. + i2 = 1 + i3 = i+1 + do 340 j=i3,iband + i2 = i2+1 + call fprota(co,si,h(j),a(irot,i2)) + 340 continue + 350 continue +c add the contribution of the row to the sum of squares of residual +c right hand sides. + 360 fp = fp+zi**2 +c find the number of the next data point in the panel. + 370 in = nummer(in) + go to 210 + 380 continue +c find dmax, the maximum value for the diagonal elements in the reduced +c triangle. + dmax = 0. + do 390 i=1,ncof + if(a(i,1).le.dmax) go to 390 + dmax = a(i,1) + 390 continue +c check whether the observation matrix is rank deficient. + sigma = eps*dmax + do 400 i=1,ncof + if(a(i,1).le.sigma) go to 410 + 400 continue +c backward substitution in case of full rank. + call fpback(a,f,ncof,iband,c,ncc) + rank = ncof + do 405 i=1,ncof + q(i,1) = a(i,1)/dmax + 405 continue + go to 430 +c in case of rank deficiency, find the minimum norm solution. + 410 lwest = ncof*iband+ncof+iband + if(lwrk.lt.lwest) go to 925 + lf = 1 + lh = lf+ncof + la = lh+iband + do 420 i=1,ncof + ff(i) = f(i) + do 420 j=1,iband + q(i,j) = a(i,j) + 420 continue + call fprank(q,ff,ncof,iband,ncc,sigma,c,sq,rank,wrk(la), + * wrk(lf),wrk(lh)) + do 425 i=1,ncof + q(i,1) = q(i,1)/dmax + 425 continue +c add to the sum of squared residuals, the contribution of reducing +c the rank. + fp = fp+sq +c find the coefficients in the standard b-spline representation of +c the spline. + 430 call fprppo(nu,nv,iopt2,iopt3,cosi,ratio,c,ff,ncoff) +c test whether the least-squares spline is an acceptable solution. + if(iopt1.lt.0) then + if (fp.le.0) go to 970 + go to 980 + endif + fpms = fp-s + if(abs(fpms).le.acc) then + if (fp.le.0) go to 970 + go to 980 + endif +c if f(p=inf) < s, accept the choice of knots. + if(fpms.lt.0.) go to 580 +c test whether we cannot further increase the number of knots + if(m.lt.ncof) go to 935 +c search where to add a new knot. +c find for each interval the sum of squared residuals fpint for the +c data points having the coordinate belonging to that knot interval. +c calculate also coord which is the same sum, weighted by the position +c of the data points considered. + 440 do 450 i=1,nrint + fpint(i) = 0. + coord(i) = 0. + 450 continue + do 490 num=1,nreg + num1 = num-1 + lu = num1/nvv + l1 = lu+1 + lv = num1-lu*nvv + l2 = lv+1+nuu + jrot = lu*nv4+lv + in = index(num) + 460 if(in.eq.0) go to 490 + store = 0. + i1 = jrot + do 480 i=1,4 + hui = spu(in,i) + j1 = i1 + do 470 j=1,4 + j1 = j1+1 + store = store+hui*spv(in,j)*c(j1) + 470 continue + i1 = i1+nv4 + 480 continue + store = (w(in)*(z(in)-store))**2 + fpint(l1) = fpint(l1)+store + coord(l1) = coord(l1)+store*u(in) + fpint(l2) = fpint(l2)+store + coord(l2) = coord(l2)+store*v(in) + in = nummer(in) + go to 460 + 490 continue +c bring together the information concerning knot panels which are +c symmetric with respect to the origin. + do 495 i=1,nrr + l1 = nuu+i + l2 = l1+nrr + fpint(l1) = fpint(l1)+fpint(l2) + coord(l1) = coord(l1)+coord(l2)-pi*fpint(l2) + 495 continue +c find the interval for which fpint is maximal on the condition that +c there still can be added a knot. + l1 = 1 + l2 = nuu+nrr + if(nuest.lt.nu+1) l1=nuu+1 + if(nvest.lt.nv+2) l2=nuu +c test whether we cannot further increase the number of knots. + if(l1.gt.l2) go to 950 + 500 fpmax = 0. + l = 0 + do 510 i=l1,l2 + if(fpmax.ge.fpint(i)) go to 510 + l = i + fpmax = fpint(i) + 510 continue + if(l.eq.0) go to 930 +c calculate the position of the new knot. + arg = coord(l)/fpint(l) +c test in what direction the new knot is going to be added. + if(l.gt.nuu) go to 530 +c addition in the u-direction + l4 = l+4 + fpint(l) = 0. + fac1 = tu(l4)-arg + fac2 = arg-tu(l4-1) + if(fac1.gt.(ten*fac2) .or. fac2.gt.(ten*fac1)) go to 500 + j = nu + do 520 i=l4,nu + tu(j+1) = tu(j) + j = j-1 + 520 continue + tu(l4) = arg + nu = nu+1 + go to 570 +c addition in the v-direction + 530 l4 = l+4-nuu + fpint(l) = 0. + fac1 = tv(l4)-arg + fac2 = arg-tv(l4-1) + if(fac1.gt.(ten*fac2) .or. fac2.gt.(ten*fac1)) go to 500 + ll = nrr+4 + j = ll + do 550 i=l4,ll + tv(j+1) = tv(j) + j = j-1 + 550 continue + tv(l4) = arg + nv = nv+2 + nrr = nrr+1 + do 560 i=5,ll + j = i+nrr + tv(j) = tv(i)+pi + 560 continue +c restart the computations with the new set of knots. + 570 continue +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing bicubic spline. c +c ****************************************************** c +c we have determined the number of knots and their position. we now c +c compute the coefficients of the smoothing spline sp(u,v). c +c the observation matrix a is extended by the rows of a matrix, expres-c +c sing that sp(u,v) must be a constant function in the variable c +c v and a cubic polynomial in the variable u. the corresponding c +c weights of these additional rows are set to 1/(p). iteratively c +c we than have to determine the value of p such that f(p) = sum((w(i)* c +c (z(i)-sp(u(i),v(i))))**2) be = s. c +c we already know that the least-squares polynomial corresponds to p=0,c +c and that the least-squares bicubic spline corresponds to p=infin. c +c the iteration process makes use of rational interpolation. since f(p)c +c is a convex and strictly decreasing function of p, it can be approx- c +c imated by a rational function of the form r(p) = (u*p+v)/(p+w). c +c three values of p (p1,p2,p3) with corresponding values of f(p) (f1= c +c f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used to calculate the new value c +c of p such that r(p)=s. convergence is guaranteed by taking f1>0,f3<0.c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jumps of the 3-th order derivative of +c the b-splines at the knots tu(l),l=5,...,nu-4. + 580 call fpdisc(tu,nu,5,bu,nuest) +c evaluate the discontinuity jumps of the 3-th order derivative of +c the b-splines at the knots tv(l),l=5,...,nv-4. + call fpdisc(tv,nv,5,bv,nvest) +c initial value for p. + p1 = 0. + f1 = sup-s + p3 = -one + f3 = fpms + p = 0. + do 590 i=1,ncof + p = p+a(i,1) + 590 continue + rn = ncof + p = rn/p +c find the bandwidth of the extended observation matrix. + iband4 = iband+ipar1 + if(iband4.gt.ncof) iband4 = ncof + iband3 = iband4 -1 + ich1 = 0 + ich3 = 0 + nuu = nu4-iopt3-1 +c iteration process to find the root of f(p)=s. + do 920 iter=1,maxit + pinv = one/p +c store the triangularized observation matrix into q. + do 630 i=1,ncof + ff(i) = f(i) + do 620 j=1,iband4 + q(i,j) = 0. + 620 continue + do 630 j=1,iband + q(i,j) = a(i,j) + 630 continue +c extend the observation matrix with the rows of a matrix, expressing +c that for u=constant sp(u,v) must be a constant function. + do 720 i=5,nv4 + ii = i-4 + do 635 l=1,nvv + row(l) = 0. + 635 continue + ll = ii + do 640 l=1,5 + if(ll.gt.nvv) ll=1 + row(ll) = row(ll)+bv(ii,l) + ll = ll+1 + 640 continue + do 720 j=1,nuu +c initialize the new row. + do 645 l=1,iband + h(l) = 0. + 645 continue +c fill in the non-zero elements of the row. jrot records the column +c number of the first non-zero element in the row. + if(j.gt.iopt2) go to 665 + if(j.eq.2) go to 655 + do 650 k=1,2 + cs(k) = 0. + do 650 l=1,nvv + cs(k) = cs(k)+cosi(k,l)*row(l) + 650 continue + h(1) = cs(1) + h(2) = cs(2) + jrot = 2 + go to 675 + 655 do 660 k=3,5 + cs(k) = 0. + do 660 l=1,nvv + cs(k) = cs(k)+cosi(k,l)*row(l) + 660 continue + h(1) = cs(1)*ratio + h(2) = cs(2)*ratio + h(3) = cs(3) + h(4) = cs(4) + h(5) = cs(5) + jrot = 2 + go to 675 + 665 do 670 l=1,nvv + h(l) = row(l) + 670 continue + jrot = ipar1+1+(j-iopt2-1)*nvv + 675 do 677 l=1,iband + h(l) = h(l)*pinv + 677 continue + zi = 0. +c rotate the new row into triangle by givens transformations. + do 710 irot=jrot,ncof + piv = h(1) + i2 = min0(iband1,ncof-irot) + if(piv.eq.0.) then + if (i2.le.0) go to 720 + go to 690 + endif +c calculate the parameters of the givens transformation. + call fpgivs(piv,q(irot,1),co,si) +c apply that givens transformation to the right hand side. + call fprota(co,si,zi,ff(irot)) + if(i2.eq.0) go to 720 +c apply that givens transformation to the left hand side. + do 680 l=1,i2 + l1 = l+1 + call fprota(co,si,h(l1),q(irot,l1)) + 680 continue + 690 do 700 l=1,i2 + h(l) = h(l+1) + 700 continue + h(i2+1) = 0. + 710 continue + 720 continue +c extend the observation matrix with the rows of a matrix expressing +c that for v=constant. sp(u,v) must be a cubic polynomial. + do 810 i=5,nu4 + ii = i-4 + do 810 j=1,nvv +c initialize the new row + do 730 l=1,iband4 + h(l) = 0. + 730 continue +c fill in the non-zero elements of the row. jrot records the column +c number of the first non-zero element in the row. + j1 = 1 + do 760 l=1,5 + il = ii+l-1 + if(il.eq.nu4 .and. iopt3.ne.0) go to 760 + if(il.gt.iopt2+1) go to 750 + go to (735,740,745),il + 735 h(1) = bu(ii,l) + j1 = j+1 + go to 760 + 740 h(1) = h(1)+bu(ii,l) + h(2) = bu(ii,l)*cosi(1,j) + h(3) = bu(ii,l)*cosi(2,j) + j1 = j+3 + go to 760 + 745 h(1) = h(1)+bu(ii,l) + h(2) = bu(ii,l)*cosi(1,j)*ratio + h(3) = bu(ii,l)*cosi(2,j)*ratio + h(4) = bu(ii,l)*cosi(3,j) + h(5) = bu(ii,l)*cosi(4,j) + h(6) = bu(ii,l)*cosi(5,j) + j1 = j+6 + go to 760 + 750 h(j1) = bu(ii,l) + j1 = j1+nvv + 760 continue + do 765 l=1,iband4 + h(l) = h(l)*pinv + 765 continue + zi = 0. + jrot = 1 + if(ii.gt.iopt2+1) jrot = ipar1+(ii-iopt2-2)*nvv+j +c rotate the new row into triangle by givens transformations. + do 800 irot=jrot,ncof + piv = h(1) + i2 = min0(iband3,ncof-irot) + if(piv.eq.0.) then + if (i2.le.0) go to 810 + go to 780 + endif +c calculate the parameters of the givens transformation. + call fpgivs(piv,q(irot,1),co,si) +c apply that givens transformation to the right hand side. + call fprota(co,si,zi,ff(irot)) + if(i2.eq.0) go to 810 +c apply that givens transformation to the left hand side. + do 770 l=1,i2 + l1 = l+1 + call fprota(co,si,h(l1),q(irot,l1)) + 770 continue + 780 do 790 l=1,i2 + h(l) = h(l+1) + 790 continue + h(i2+1) = 0. + 800 continue + 810 continue +c find dmax, the maximum value for the diagonal elements in the +c reduced triangle. + dmax = 0. + do 820 i=1,ncof + if(q(i,1).le.dmax) go to 820 + dmax = q(i,1) + 820 continue +c check whether the matrix is rank deficient. + sigma = eps*dmax + do 830 i=1,ncof + if(q(i,1).le.sigma) go to 840 + 830 continue +c backward substitution in case of full rank. + call fpback(q,ff,ncof,iband4,c,ncc) + rank = ncof + go to 845 +c in case of rank deficiency, find the minimum norm solution. + 840 lwest = ncof*iband4+ncof+iband4 + if(lwrk.lt.lwest) go to 925 + lf = 1 + lh = lf+ncof + la = lh+iband4 + call fprank(q,ff,ncof,iband4,ncc,sigma,c,sq,rank,wrk(la), + * wrk(lf),wrk(lh)) + 845 do 850 i=1,ncof + q(i,1) = q(i,1)/dmax + 850 continue +c find the coefficients in the standard b-spline representation of +c the polar spline. + call fprppo(nu,nv,iopt2,iopt3,cosi,ratio,c,ff,ncoff) +c compute f(p). + fp = 0. + do 890 num = 1,nreg + num1 = num-1 + lu = num1/nvv + lv = num1-lu*nvv + jrot = lu*nv4+lv + in = index(num) + 860 if(in.eq.0) go to 890 + store = 0. + i1 = jrot + do 880 i=1,4 + hui = spu(in,i) + j1 = i1 + do 870 j=1,4 + j1 = j1+1 + store = store+hui*spv(in,j)*c(j1) + 870 continue + i1 = i1+nv4 + 880 continue + fp = fp+(w(in)*(z(in)-store))**2 + in = nummer(in) + go to 860 + 890 continue +c test whether the approximation sp(u,v) is an acceptable solution + fpms = fp-s + if(abs(fpms).le.acc) go to 980 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 940 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 900 + if((f2-f3).gt.acc) go to 895 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 920 + 895 if(f2.lt.0.) ich3 = 1 + 900 if(ich1.ne.0) go to 910 + if((f1-f2).gt.acc) go to 905 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 920 + if(p.ge.p3) p = p2*con1 +p3*con9 + go to 920 + 905 if(f2.gt.0.) ich1 = 1 +c test whether the iteration process proceeds as theoretically +c expected. + 910 if(f2.ge.f1 .or. f2.le.f3) go to 945 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 920 continue +c error codes and messages. + 925 ier = lwest + go to 990 + 930 ier = 5 + go to 990 + 935 ier = 4 + go to 990 + 940 ier = 3 + go to 990 + 945 ier = 2 + go to 990 + 950 ier = 1 + go to 990 + 960 ier = -2 + go to 990 + 970 ier = -1 + fp = 0. + 980 if(ncof.ne.rank) ier = -rank + 990 return + end + Added: branches/Interpolate1D/fitpack/fprank.f =================================================================== --- branches/Interpolate1D/fitpack/fprank.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fprank.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,236 @@ + subroutine fprank(a,f,n,m,na,tol,c,sq,rank,aa,ff,h) +c subroutine fprank finds the minimum norm solution of a least- +c squares problem in case of rank deficiency. +c +c input parameters: +c a : array, which contains the non-zero elements of the observation +c matrix after triangularization by givens transformations. +c f : array, which contains the transformed right hand side. +c n : integer,wich contains the dimension of a. +c m : integer, which denotes the bandwidth of a. +c tol : real value, giving a threshold to determine the rank of a. +c +c output parameters: +c c : array, which contains the minimum norm solution. +c sq : real value, giving the contribution of reducing the rank +c to the sum of squared residuals. +c rank : integer, which contains the rank of matrix a. +c +c ..scalar arguments.. + integer n,m,na,rank + real*8 tol,sq +c ..array arguments.. + real*8 a(na,m),f(n),c(n),aa(n,m),ff(n),h(m) +c ..local scalars.. + integer i,ii,ij,i1,i2,j,jj,j1,j2,j3,k,kk,m1,nl + real*8 cos,fac,piv,sin,yi + double precision store,stor1,stor2,stor3 +c ..function references.. + integer min0 +c ..subroutine references.. +c fpgivs,fprota +c .. + m1 = m-1 +c the rank deficiency nl is considered to be the number of sufficient +c small diagonal elements of a. + nl = 0 + sq = 0. + do 90 i=1,n + if(a(i,1).gt.tol) go to 90 +c if a sufficient small diagonal element is found, we put it to +c zero. the remainder of the row corresponding to that zero diagonal +c element is then rotated into triangle by givens rotations . +c the rank deficiency is increased by one. + nl = nl+1 + if(i.eq.n) go to 90 + yi = f(i) + do 10 j=1,m1 + h(j) = a(i,j+1) + 10 continue + h(m) = 0. + i1 = i+1 + do 60 ii=i1,n + i2 = min0(n-ii,m1) + piv = h(1) + if(piv.eq.0.) go to 30 + call fpgivs(piv,a(ii,1),cos,sin) + call fprota(cos,sin,yi,f(ii)) + if(i2.eq.0) go to 70 + do 20 j=1,i2 + j1 = j+1 + call fprota(cos,sin,h(j1),a(ii,j1)) + h(j) = h(j1) + 20 continue + go to 50 + 30 if(i2.eq.0) go to 70 + do 40 j=1,i2 + h(j) = h(j+1) + 40 continue + 50 h(i2+1) = 0. + 60 continue +c add to the sum of squared residuals the contribution of deleting +c the row with small diagonal element. + 70 sq = sq+yi**2 + 90 continue +c rank denotes the rank of a. + rank = n-nl +c let b denote the (rank*n) upper trapezoidal matrix which can be +c obtained from the (n*n) upper triangular matrix a by deleting +c the rows and interchanging the columns corresponding to a zero +c diagonal element. if this matrix is factorized using givens +c transformations as b = (r) (u) where +c r is a (rank*rank) upper triangular matrix, +c u is a (rank*n) orthonormal matrix +c then the minimal least-squares solution c is given by c = b' v, +c where v is the solution of the system (r) (r)' v = g and +c g denotes the vector obtained from the old right hand side f, by +c removing the elements corresponding to a zero diagonal element of a. +c initialization. + do 100 i=1,rank + do 100 j=1,m + aa(i,j) = 0. + 100 continue +c form in aa the upper triangular matrix obtained from a by +c removing rows and columns with zero diagonal elements. form in ff +c the new right hand side by removing the elements of the old right +c hand side corresponding to a deleted row. + ii = 0 + do 120 i=1,n + if(a(i,1).le.tol) go to 120 + ii = ii+1 + ff(ii) = f(i) + aa(ii,1) = a(i,1) + jj = ii + kk = 1 + j = i + j1 = min0(j-1,m1) + if(j1.eq.0) go to 120 + do 110 k=1,j1 + j = j-1 + if(a(j,1).le.tol) go to 110 + kk = kk+1 + jj = jj-1 + aa(jj,kk) = a(j,k+1) + 110 continue + 120 continue +c form successively in h the columns of a with a zero diagonal element. + ii = 0 + do 200 i=1,n + ii = ii+1 + if(a(i,1).gt.tol) go to 200 + ii = ii-1 + if(ii.eq.0) go to 200 + jj = 1 + j = i + j1 = min0(j-1,m1) + do 130 k=1,j1 + j = j-1 + if(a(j,1).le.tol) go to 130 + h(jj) = a(j,k+1) + jj = jj+1 + 130 continue + do 140 kk=jj,m + h(kk) = 0. + 140 continue +c rotate this column into aa by givens transformations. + jj = ii + do 190 i1=1,ii + j1 = min0(jj-1,m1) + piv = h(1) + if(piv.ne.0.) go to 160 + if(j1.eq.0) go to 200 + do 150 j2=1,j1 + j3 = j2+1 + h(j2) = h(j3) + 150 continue + go to 180 + 160 call fpgivs(piv,aa(jj,1),cos,sin) + if(j1.eq.0) go to 200 + kk = jj + do 170 j2=1,j1 + j3 = j2+1 + kk = kk-1 + call fprota(cos,sin,h(j3),aa(kk,j3)) + h(j2) = h(j3) + 170 continue + 180 jj = jj-1 + h(j3) = 0. + 190 continue + 200 continue +c solve the system (aa) (f1) = ff + ff(rank) = ff(rank)/aa(rank,1) + i = rank-1 + if(i.eq.0) go to 230 + do 220 j=2,rank + store = ff(i) + i1 = min0(j-1,m1) + k = i + do 210 ii=1,i1 + k = k+1 + stor1 = ff(k) + stor2 = aa(i,ii+1) + store = store-stor1*stor2 + 210 continue + stor1 = aa(i,1) + ff(i) = store/stor1 + i = i-1 + 220 continue +c solve the system (aa)' (f2) = f1 + 230 ff(1) = ff(1)/aa(1,1) + if(rank.eq.1) go to 260 + do 250 j=2,rank + store = ff(j) + i1 = min0(j-1,m1) + k = j + do 240 ii=1,i1 + k = k-1 + stor1 = ff(k) + stor2 = aa(k,ii+1) + store = store-stor1*stor2 + 240 continue + stor1 = aa(j,1) + ff(j) = store/stor1 + 250 continue +c premultiply f2 by the transpoze of a. + 260 k = 0 + do 280 i=1,n + store = 0. + if(a(i,1).gt.tol) k = k+1 + j1 = min0(i,m) + kk = k + ij = i+1 + do 270 j=1,j1 + ij = ij-1 + if(a(ij,1).le.tol) go to 270 + stor1 = a(ij,j) + stor2 = ff(kk) + store = store+stor1*stor2 + kk = kk-1 + 270 continue + c(i) = store + 280 continue +c add to the sum of squared residuals the contribution of putting +c to zero the small diagonal elements of matrix (a). + stor3 = 0. + do 310 i=1,n + if(a(i,1).gt.tol) go to 310 + store = f(i) + i1 = min0(n-i,m1) + if(i1.eq.0) go to 300 + do 290 j=1,i1 + ij = i+j + stor1 = c(ij) + stor2 = a(i,j+1) + store = store-stor1*stor2 + 290 continue + 300 fac = a(i,1)*c(i) + stor1 = a(i,1) + stor2 = c(i) + stor1 = stor1*stor2 + stor3 = stor3+stor1*(stor1-store-store) + 310 continue + fac = stor3 + sq = sq+fac + return + end + Added: branches/Interpolate1D/fitpack/fprati.f =================================================================== --- branches/Interpolate1D/fitpack/fprati.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fprati.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,29 @@ + real*8 function fprati(p1,f1,p2,f2,p3,f3) +c given three points (p1,f1),(p2,f2) and (p3,f3), function fprati +c gives the value of p such that the rational interpolating function +c of the form r(p) = (u*p+v)/(p+w) equals zero at p. +c .. +c ..scalar arguments.. + real*8 p1,f1,p2,f2,p3,f3 +c ..local scalars.. + real*8 h1,h2,h3,p +c .. + if(p3.gt.0.) go to 10 +c value of p in case p3 = infinity. + p = (p1*(f1-f3)*f2-p2*(f2-f3)*f1)/((f1-f2)*f3) + go to 20 +c value of p in case p3 ^= infinity. + 10 h1 = f1*(f2-f3) + h2 = f2*(f3-f1) + h3 = f3*(f1-f2) + p = -(p1*p2*h3+p2*p3*h1+p3*p1*h2)/(p1*h1+p2*h2+p3*h3) +c adjust the value of p1,f1,p3 and f3 such that f1 > 0 and f3 < 0. + 20 if(f2.lt.0.) go to 30 + p1 = p2 + f1 = f2 + go to 40 + 30 p3 = p2 + f3 = f2 + 40 fprati = p + return + end Added: branches/Interpolate1D/fitpack/fpregr.f =================================================================== --- branches/Interpolate1D/fitpack/fpregr.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpregr.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,367 @@ + subroutine fpregr(iopt,x,mx,y,my,z,mz,xb,xe,yb,ye,kx,ky,s, + * nxest,nyest,tol,maxit,nc,nx,tx,ny,ty,c,fp,fp0,fpold,reducx, + * reducy,fpintx,fpinty,lastdi,nplusx,nplusy,nrx,nry,nrdatx,nrdaty, + * wrk,lwrk,ier) +c .. +c ..scalar arguments.. + real*8 xb,xe,yb,ye,s,tol,fp,fp0,fpold,reducx,reducy + integer iopt,mx,my,mz,kx,ky,nxest,nyest,maxit,nc,nx,ny,lastdi, + * nplusx,nplusy,lwrk,ier +c ..array arguments.. + real*8 x(mx),y(my),z(mz),tx(nxest),ty(nyest),c(nc),fpintx(nxest), + * fpinty(nyest),wrk(lwrk) + integer nrdatx(nxest),nrdaty(nyest),nrx(mx),nry(my) +c ..local scalars + real*8 acc,fpms,f1,f2,f3,p,p1,p2,p3,rn,one,half,con1,con9,con4 + integer i,ich1,ich3,ifbx,ifby,ifsx,ifsy,iter,j,kx1,kx2,ky1,ky2, + * k3,l,lax,lay,lbx,lby,lq,lri,lsx,lsy,mk1,mm,mpm,mynx,ncof, + * nk1x,nk1y,nmaxx,nmaxy,nminx,nminy,nplx,nply,npl1,nrintx, + * nrinty,nxe,nxk,nye +c ..function references.. + real*8 abs,fprati + integer max0,min0 +c ..subroutine references.. +c fpgrre,fpknot +c .. +c set constants + one = 1 + half = 0.5e0 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 +c we partition the working space. + kx1 = kx+1 + ky1 = ky+1 + kx2 = kx1+1 + ky2 = ky1+1 + lsx = 1 + lsy = lsx+mx*kx1 + lri = lsy+my*ky1 + mm = max0(nxest,my) + lq = lri+mm + mynx = nxest*my + lax = lq+mynx + nxk = nxest*kx2 + lbx = lax+nxk + lay = lbx+nxk + lby = lay+nyest*ky2 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position. c +c **************************************************************** c +c given a set of knots we compute the least-squares spline sinf(x,y), c +c and the corresponding sum of squared residuals fp=f(p=inf). c +c if iopt=-1 sinf(x,y) is the requested approximation. c +c if iopt=0 or iopt=1 we check whether we can accept the knots: c +c if fp <=s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares spline until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots equals nmaxx = mx+kx+1 and nmaxy = my+ky+1. c +c if s>0 and c +c *iopt=0 we first compute the least-squares polynomial of degree c +c kx in x and ky in y; nx=nminx=2*kx+2 and ny=nymin=2*ky+2. c +c *iopt=1 we start with the knots found at the last call of the c +c routine, except for the case that s > fp0; then we can compute c +c the least-squares polynomial directly. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c determine the number of knots for polynomial approximation. + nminx = 2*kx1 + nminy = 2*ky1 + if(iopt.lt.0) go to 120 +c acc denotes the absolute tolerance for the root of f(p)=s. + acc = tol*s +c find nmaxx and nmaxy which denote the number of knots in x- and y- +c direction in case of spline interpolation. + nmaxx = mx+kx1 + nmaxy = my+ky1 +c find nxe and nye which denote the maximum number of knots +c allowed in each direction + nxe = min0(nmaxx,nxest) + nye = min0(nmaxy,nyest) + if(s.gt.0.) go to 100 +c if s = 0, s(x,y) is an interpolating spline. + nx = nmaxx + ny = nmaxy +c test whether the required storage space exceeds the available one. + if(ny.gt.nyest .or. nx.gt.nxest) go to 420 +c find the position of the interior knots in case of interpolation. +c the knots in the x-direction. + mk1 = mx-kx1 + if(mk1.eq.0) go to 60 + k3 = kx/2 + i = kx1+1 + j = k3+2 + if(k3*2.eq.kx) go to 40 + do 30 l=1,mk1 + tx(i) = x(j) + i = i+1 + j = j+1 + 30 continue + go to 60 + 40 do 50 l=1,mk1 + tx(i) = (x(j)+x(j-1))*half + i = i+1 + j = j+1 + 50 continue +c the knots in the y-direction. + 60 mk1 = my-ky1 + if(mk1.eq.0) go to 120 + k3 = ky/2 + i = ky1+1 + j = k3+2 + if(k3*2.eq.ky) go to 80 + do 70 l=1,mk1 + ty(i) = y(j) + i = i+1 + j = j+1 + 70 continue + go to 120 + 80 do 90 l=1,mk1 + ty(i) = (y(j)+y(j-1))*half + i = i+1 + j = j+1 + 90 continue + go to 120 +c if s > 0 our initial choice of knots depends on the value of iopt. + 100 if(iopt.eq.0) go to 115 + if(fp0.le.s) go to 115 +c if iopt=1 and fp0 > s we start computing the least- squares spline +c according to the set of knots found at the last call of the routine. +c we determine the number of grid coordinates x(i) inside each knot +c interval (tx(l),tx(l+1)). + l = kx2 + j = 1 + nrdatx(1) = 0 + mpm = mx-1 + do 105 i=2,mpm + nrdatx(j) = nrdatx(j)+1 + if(x(i).lt.tx(l)) go to 105 + nrdatx(j) = nrdatx(j)-1 + l = l+1 + j = j+1 + nrdatx(j) = 0 + 105 continue +c we determine the number of grid coordinates y(i) inside each knot +c interval (ty(l),ty(l+1)). + l = ky2 + j = 1 + nrdaty(1) = 0 + mpm = my-1 + do 110 i=2,mpm + nrdaty(j) = nrdaty(j)+1 + if(y(i).lt.ty(l)) go to 110 + nrdaty(j) = nrdaty(j)-1 + l = l+1 + j = j+1 + nrdaty(j) = 0 + 110 continue + go to 120 +c if iopt=0 or iopt=1 and s>=fp0, we start computing the least-squares +c polynomial of degree kx in x and ky in y (which is a spline without +c interior knots). + 115 nx = nminx + ny = nminy + nrdatx(1) = mx-2 + nrdaty(1) = my-2 + lastdi = 0 + nplusx = 0 + nplusy = 0 + fp0 = 0. + fpold = 0. + reducx = 0. + reducy = 0. + 120 mpm = mx+my + ifsx = 0 + ifsy = 0 + ifbx = 0 + ifby = 0 + p = -one +c main loop for the different sets of knots.mpm=mx+my is a save upper +c bound for the number of trials. + do 250 iter=1,mpm + if(nx.eq.nminx .and. ny.eq.nminy) ier = -2 +c find nrintx (nrinty) which is the number of knot intervals in the +c x-direction (y-direction). + nrintx = nx-nminx+1 + nrinty = ny-nminy+1 +c find ncof, the number of b-spline coefficients for the current set +c of knots. + nk1x = nx-kx1 + nk1y = ny-ky1 + ncof = nk1x*nk1y +c find the position of the additional knots which are needed for the +c b-spline representation of s(x,y). + i = nx + do 130 j=1,kx1 + tx(j) = xb + tx(i) = xe + i = i-1 + 130 continue + i = ny + do 140 j=1,ky1 + ty(j) = yb + ty(i) = ye + i = i-1 + 140 continue +c find the least-squares spline sinf(x,y) and calculate for each knot +c interval tx(j+kx)<=x<=tx(j+kx+1) (ty(j+ky)<=y<=ty(j+ky+1)) the sum +c of squared residuals fpintx(j),j=1,2,...,nx-2*kx-1 (fpinty(j),j=1,2, +c ...,ny-2*ky-1) for the data points having their absciss (ordinate)- +c value belonging to that interval. +c fp gives the total sum of squared residuals. + call fpgrre(ifsx,ifsy,ifbx,ifby,x,mx,y,my,z,mz,kx,ky,tx,nx,ty, + * ny,p,c,nc,fp,fpintx,fpinty,mm,mynx,kx1,kx2,ky1,ky2,wrk(lsx), + * wrk(lsy),wrk(lri),wrk(lq),wrk(lax),wrk(lay),wrk(lbx),wrk(lby), + * nrx,nry) + if(ier.eq.(-2)) fp0 = fp +c test whether the least-squares spline is an acceptable solution. + if(iopt.lt.0) go to 440 + fpms = fp-s + if(abs(fpms) .lt. acc) go to 440 +c if f(p=inf) < s, we accept the choice of knots. + if(fpms.lt.0.) go to 300 +c if nx=nmaxx and ny=nmaxy, sinf(x,y) is an interpolating spline. + if(nx.eq.nmaxx .and. ny.eq.nmaxy) go to 430 +c increase the number of knots. +c if nx=nxe and ny=nye we cannot further increase the number of knots +c because of the storage capacity limitation. + if(nx.eq.nxe .and. ny.eq.nye) go to 420 + ier = 0 +c adjust the parameter reducx or reducy according to the direction +c in which the last added knots were located. + if (lastdi.lt.0) go to 150 + if (lastdi.eq.0) go to 170 + go to 160 + 150 reducx = fpold-fp + go to 170 + 160 reducy = fpold-fp +c store the sum of squared residuals for the current set of knots. + 170 fpold = fp +c find nplx, the number of knots we should add in the x-direction. + nplx = 1 + if(nx.eq.nminx) go to 180 + npl1 = nplusx*2 + rn = nplusx + if(reducx.gt.acc) npl1 = rn*fpms/reducx + nplx = min0(nplusx*2,max0(npl1,nplusx/2,1)) +c find nply, the number of knots we should add in the y-direction. + 180 nply = 1 + if(ny.eq.nminy) go to 190 + npl1 = nplusy*2 + rn = nplusy + if(reducy.gt.acc) npl1 = rn*fpms/reducy + nply = min0(nplusy*2,max0(npl1,nplusy/2,1)) + 190 if (nplx.lt.nply) go to 210 + if (nplx.eq.nply) go to 200 + go to 230 + 200 if(lastdi.lt.0) go to 230 + 210 if(nx.eq.nxe) go to 230 +c addition in the x-direction. + lastdi = -1 + nplusx = nplx + ifsx = 0 + do 220 l=1,nplusx +c add a new knot in the x-direction + call fpknot(x,mx,tx,nx,fpintx,nrdatx,nrintx,nxest,1) +c test whether we cannot further increase the number of knots in the +c x-direction. + if(nx.eq.nxe) go to 250 + 220 continue + go to 250 + 230 if(ny.eq.nye) go to 210 +c addition in the y-direction. + lastdi = 1 + nplusy = nply + ifsy = 0 + do 240 l=1,nplusy +c add a new knot in the y-direction. + call fpknot(y,my,ty,ny,fpinty,nrdaty,nrinty,nyest,1) +c test whether we cannot further increase the number of knots in the +c y-direction. + if(ny.eq.nye) go to 250 + 240 continue +c restart the computations with the new set of knots. + 250 continue +c test whether the least-squares polynomial is a solution of our +c approximation problem. + 300 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline sp(x,y) c +c ***************************************************** c +c we have determined the number of knots and their position. we now c +c compute the b-spline coefficients of the smoothing spline sp(x,y). c +c this smoothing spline varies with the parameter p in such a way thatc +c f(p) = sumi=1,mx(sumj=1,my((z(i,j)-sp(x(i),y(j)))**2) c +c is a continuous, strictly decreasing function of p. moreover the c +c least-squares polynomial corresponds to p=0 and the least-squares c +c spline to p=infinity. iteratively we then have to determine the c +c positive value of p such that f(p)=s. the process which is proposed c +c here makes use of rational interpolation. f(p) is approximated by a c +c rational function r(p)=(u*p+v)/(p+w); three values of p (p1,p2,p3) c +c with corresponding values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s)c +c are used to calculate the new value of p such that r(p)=s. c +c convergence is guaranteed by taking f1 > 0 and f3 < 0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = one + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p)=s. + do 350 iter = 1,maxit +c find the smoothing spline sp(x,y) and the corresponding sum of +c squared residuals fp. + call fpgrre(ifsx,ifsy,ifbx,ifby,x,mx,y,my,z,mz,kx,ky,tx,nx,ty, + * ny,p,c,nc,fp,fpintx,fpinty,mm,mynx,kx1,kx2,ky1,ky2,wrk(lsx), + * wrk(lsy),wrk(lri),wrk(lq),wrk(lax),wrk(lay),wrk(lbx),wrk(lby), + * nrx,nry) +c test whether the approximation sp(x,y) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 320 + if((f2-f3).gt.acc) go to 310 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 350 + 310 if(f2.lt.0.) ich3 = 1 + 320 if(ich1.ne.0) go to 340 + if((f1-f2).gt.acc) go to 330 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 350 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 350 +c test whether the iteration process proceeds as theoretically +c expected. + 330 if(f2.gt.0.) ich1 = 1 + 340 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 350 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + fp = 0. + 440 return + end + Added: branches/Interpolate1D/fitpack/fprota.f =================================================================== --- branches/Interpolate1D/fitpack/fprota.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fprota.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,14 @@ + subroutine fprota(cos,sin,a,b) +c subroutine fprota applies a givens rotation to a and b. +c .. +c ..scalar arguments.. + real*8 cos,sin,a,b +c ..local scalars.. + real*8 stor1,stor2 +c .. + stor1 = a + stor2 = b + b = cos*stor2+sin*stor1 + a = cos*stor1-sin*stor2 + return + end Added: branches/Interpolate1D/fitpack/fprppo.f =================================================================== --- branches/Interpolate1D/fitpack/fprppo.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fprppo.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,61 @@ + subroutine fprppo(nu,nv,if1,if2,cosi,ratio,c,f,ncoff) +c given the coefficients of a constrained bicubic spline, as determined +c in subroutine fppola, subroutine fprppo calculates the coefficients +c in the standard b-spline representation of bicubic splines. +c .. +c ..scalar arguments.. + real*8 ratio + integer nu,nv,if1,if2,ncoff +c ..array arguments + real*8 c(ncoff),f(ncoff),cosi(5,nv) +c ..local scalars.. + integer i,iopt,ii,j,k,l,nu4,nvv +c .. + nu4 = nu-4 + nvv = nv-7 + iopt = if1+1 + do 10 i=1,ncoff + f(i) = 0. + 10 continue + i = 0 + do 120 l=1,nu4 + ii = i + if(l.gt.iopt) go to 80 + go to (20,40,60),l + 20 do 30 k=1,nvv + i = i+1 + f(i) = c(1) + 30 continue + j = 1 + go to 100 + 40 do 50 k=1,nvv + i = i+1 + f(i) = c(1)+c(2)*cosi(1,k)+c(3)*cosi(2,k) + 50 continue + j = 3 + go to 100 + 60 do 70 k=1,nvv + i = i+1 + f(i) = c(1)+ratio*(c(2)*cosi(1,k)+c(3)*cosi(2,k))+ + * c(4)*cosi(3,k)+c(5)*cosi(4,k)+c(6)*cosi(5,k) + 70 continue + j = 6 + go to 100 + 80 if(l.eq.nu4 .and. if2.ne.0) go to 120 + do 90 k=1,nvv + i = i+1 + j = j+1 + f(i) = c(j) + 90 continue + 100 do 110 k=1,3 + ii = ii+1 + i = i+1 + f(i) = f(ii) + 110 continue + 120 continue + do 130 i=1,ncoff + c(i) = f(i) + 130 continue + return + end + Added: branches/Interpolate1D/fitpack/fprpsp.f =================================================================== --- branches/Interpolate1D/fitpack/fprpsp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fprpsp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,55 @@ + subroutine fprpsp(nt,np,co,si,c,f,ncoff) +c given the coefficients of a spherical spline function, subroutine +c fprpsp calculates the coefficients in the standard b-spline re- +c presentation of this bicubic spline. +c .. +c ..scalar arguments + integer nt,np,ncoff +c ..array arguments + real*8 co(np),si(np),c(ncoff),f(ncoff) +c ..local scalars + real*8 cn,c1,c2,c3 + integer i,ii,j,k,l,ncof,npp,np4,nt4 +c .. + nt4 = nt-4 + np4 = np-4 + npp = np4-3 + ncof = 6+npp*(nt4-4) + c1 = c(1) + cn = c(ncof) + j = ncoff + do 10 i=1,np4 + f(i) = c1 + f(j) = cn + j = j-1 + 10 continue + i = np4 + j=1 + do 70 l=3,nt4 + ii = i + if(l.eq.3 .or. l.eq.nt4) go to 30 + do 20 k=1,npp + i = i+1 + j = j+1 + f(i) = c(j) + 20 continue + go to 50 + 30 if(l.eq.nt4) c1 = cn + c2 = c(j+1) + c3 = c(j+2) + j = j+2 + do 40 k=1,npp + i = i+1 + f(i) = c1+c2*co(k)+c3*si(k) + 40 continue + 50 do 60 k=1,3 + ii = ii+1 + i = i+1 + f(i) = f(ii) + 60 continue + 70 continue + do 80 i=1,ncoff + c(i) = f(i) + 80 continue + return + end Added: branches/Interpolate1D/fitpack/fpseno.f =================================================================== --- branches/Interpolate1D/fitpack/fpseno.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpseno.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,34 @@ + subroutine fpseno(maxtr,up,left,right,info,merk,ibind,nbind) +c subroutine fpseno fetches a branch of a triply linked tree the +c information of which is kept in the arrays up,left,right and info. +c the branch has a specified length nbind and is determined by the +c parameter merk which points to its terminal node. the information +c field of the nodes of this branch is stored in the array ibind. on +c exit merk points to a new branch of length nbind or takes the value +c 1 if no such branch was found. +c .. +c ..scalar arguments.. + integer maxtr,merk,nbind +c ..array arguments.. + integer up(maxtr),left(maxtr),right(maxtr),info(maxtr), + * ibind(nbind) +c ..scalar arguments.. + integer i,j,k +c .. + k = merk + j = nbind + do 10 i=1,nbind + ibind(j) = info(k) + k = up(k) + j = j-1 + 10 continue + 20 k = right(merk) + if(k.ne.0) go to 30 + merk = up(merk) + if (merk.le.1) go to 40 + go to 20 + 30 merk = k + k = left(merk) + if(k.ne.0) go to 30 + 40 return + end Added: branches/Interpolate1D/fitpack/fpspgr.f =================================================================== --- branches/Interpolate1D/fitpack/fpspgr.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpspgr.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,439 @@ + subroutine fpspgr(iopt,ider,u,mu,v,mv,r,mr,r0,r1,s,nuest,nvest, + * tol,maxit,nc,nu,tu,nv,tv,c,fp,fp0,fpold,reducu,reducv,fpintu, + * fpintv,dr,step,lastdi,nplusu,nplusv,lastu0,lastu1,nru,nrv, + * nrdatu,nrdatv,wrk,lwrk,ier) +c .. +c ..scalar arguments.. + integer mu,mv,mr,nuest,nvest,maxit,nc,nu,nv,lastdi,nplusu,nplusv, + * lastu0,lastu1,lwrk,ier + real*8 r0,r1,s,tol,fp,fp0,fpold,reducu,reducv +c ..array arguments.. + integer iopt(3),ider(4),nrdatu(nuest),nrdatv(nvest),nru(mu), + * nrv(mv) + real*8 u(mu),v(mv),r(mr),tu(nuest),tv(nvest),c(nc),fpintu(nuest), + * fpintv(nvest),dr(6),wrk(lwrk),step(2) +c ..local scalars.. + real*8 acc,fpms,f1,f2,f3,p,per,pi,p1,p2,p3,vb,ve,rmax,rmin,rn,one, + * + * con1,con4,con9 + integer i,ich1,ich3,ifbu,ifbv,ifsu,ifsv,istart,iter,i1,i2,j,ju, + * ktu,l,l1,l2,l3,l4,mpm,mumin,mu0,mu1,nn,nplu,nplv,npl1,nrintu, + * nrintv,nue,numax,nve,nvmax +c ..local arrays.. + integer idd(4) + real*8 drr(6) +c ..function references.. + real*8 abs,datan2,fprati + integer max0,min0 +c ..subroutine references.. +c fpknot,fpopsp +c .. +c set constants + one = 1d0 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 +c initialization + ifsu = 0 + ifsv = 0 + ifbu = 0 + ifbv = 0 + p = -one + mumin = 4 + if(ider(1).ge.0) mumin = mumin-1 + if(iopt(2).eq.1 .and. ider(2).eq.1) mumin = mumin-1 + if(ider(3).ge.0) mumin = mumin-1 + if(iopt(3).eq.1 .and. ider(4).eq.1) mumin = mumin-1 + if(mumin.eq.0) mumin = 1 + pi = datan2(0d0,-one) + per = pi+pi + vb = v(1) + ve = vb+per +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position. c +c **************************************************************** c +c given a set of knots we compute the least-squares spline sinf(u,v) c +c and the corresponding sum of squared residuals fp = f(p=inf). c +c if iopt(1)=-1 sinf(u,v) is the requested approximation. c +c if iopt(1)>=0 we check whether we can accept the knots: c +c if fp <= s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares spline until finally fp <= s. c +c the initial choice of knots depends on the value of s and iopt. c +c if s=0 we have spline interpolation; in that case the number of c +c knots in the u-direction equals nu=numax=mu+6+iopt(2)+iopt(3) c +c and in the v-direction nv=nvmax=mv+7. c +c if s>0 and c +c iopt(1)=0 we first compute the least-squares polynomial,i.e. a c +c spline without interior knots : nu=8 ; nv=8. c +c iopt(1)=1 we start with the set of knots found at the last call c +c of the routine, except for the case that s > fp0; then we c +c compute the least-squares polynomial directly. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc + if(iopt(1).lt.0) go to 120 +c acc denotes the absolute tolerance for the root of f(p)=s. + acc = tol*s +c numax and nvmax denote the number of knots needed for interpolation. + numax = mu+6+iopt(2)+iopt(3) + nvmax = mv+7 + nue = min0(numax,nuest) + nve = min0(nvmax,nvest) + if(s.gt.0.) go to 100 +c if s = 0, s(u,v) is an interpolating spline. + nu = numax + nv = nvmax +c test whether the required storage space exceeds the available one. + if(nu.gt.nuest .or. nv.gt.nvest) go to 420 +c find the position of the knots in the v-direction. + do 10 l=1,mv + tv(l+3) = v(l) + 10 continue + tv(mv+4) = ve + l1 = mv-2 + l2 = mv+5 + do 20 i=1,3 + tv(i) = v(l1)-per + tv(l2) = v(i+1)+per + l1 = l1+1 + l2 = l2+1 + 20 continue +c if not all the derivative values g(i,j) are given, we will first +c estimate these values by computing a least-squares spline + idd(1) = ider(1) + if(idd(1).eq.0) idd(1) = 1 + if(idd(1).gt.0) dr(1) = r0 + idd(2) = ider(2) + idd(3) = ider(3) + if(idd(3).eq.0) idd(3) = 1 + if(idd(3).gt.0) dr(4) = r1 + idd(4) = ider(4) + if(ider(1).lt.0 .or. ider(3).lt.0) go to 30 + if(iopt(2).ne.0 .and. ider(2).eq.0) go to 30 + if(iopt(3).eq.0 .or. ider(4).ne.0) go to 70 +c we set up the knots in the u-direction for computing the least-squares +c spline. + 30 i1 = 3 + i2 = mu-2 + nu = 4 + do 40 i=1,mu + if(i1.gt.i2) go to 50 + nu = nu+1 + tu(nu) = u(i1) + i1 = i1+2 + 40 continue + 50 do 60 i=1,4 + tu(i) = 0. + nu = nu+1 + tu(nu) = pi + 60 continue +c we compute the least-squares spline for estimating the derivatives. + call fpopsp(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,r,mr,r0,r1,dr,iopt,idd, + * tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru,nrv, + * wrk,lwrk) + ifsu = 0 +c if all the derivatives at the origin are known, we compute the +c interpolating spline. +c we set up the knots in the u-direction, needed for interpolation. + 70 nn = numax-8 + if(nn.eq.0) go to 95 + ju = 2-iopt(2) + do 80 l=1,nn + tu(l+4) = u(ju) + ju = ju+1 + 80 continue + nu = numax + l = nu + do 90 i=1,4 + tu(i) = 0. + tu(l) = pi + l = l-1 + 90 continue +c we compute the interpolating spline. + 95 call fpopsp(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,r,mr,r0,r1,dr,iopt,idd, + * tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru,nrv, + * wrk,lwrk) + go to 430 +c if s>0 our initial choice of knots depends on the value of iopt(1). + 100 ier = 0 + if(iopt(1).eq.0) go to 115 + step(1) = -step(1) + step(2) = -step(2) + if(fp0.le.s) go to 115 +c if iopt(1)=1 and fp0 > s we start computing the least-squares spline +c according to the set of knots found at the last call of the routine. +c we determine the number of grid coordinates u(i) inside each knot +c interval (tu(l),tu(l+1)). + l = 5 + j = 1 + nrdatu(1) = 0 + mu0 = 2-iopt(2) + mu1 = mu-1+iopt(3) + do 105 i=mu0,mu1 + nrdatu(j) = nrdatu(j)+1 + if(u(i).lt.tu(l)) go to 105 + nrdatu(j) = nrdatu(j)-1 + l = l+1 + j = j+1 + nrdatu(j) = 0 + 105 continue +c we determine the number of grid coordinates v(i) inside each knot +c interval (tv(l),tv(l+1)). + l = 5 + j = 1 + nrdatv(1) = 0 + do 110 i=2,mv + nrdatv(j) = nrdatv(j)+1 + if(v(i).lt.tv(l)) go to 110 + nrdatv(j) = nrdatv(j)-1 + l = l+1 + j = j+1 + nrdatv(j) = 0 + 110 continue + idd(1) = ider(1) + idd(2) = ider(2) + idd(3) = ider(3) + idd(4) = ider(4) + go to 120 +c if iopt(1)=0 or iopt(1)=1 and s >= fp0,we start computing the least- +c squares polynomial (which is a spline without interior knots). + 115 ier = -2 + idd(1) = ider(1) + idd(2) = 1 + idd(3) = ider(3) + idd(4) = 1 + nu = 8 + nv = 8 + nrdatu(1) = mu-2+iopt(2)+iopt(3) + nrdatv(1) = mv-1 + lastdi = 0 + nplusu = 0 + nplusv = 0 + fp0 = 0. + fpold = 0. + reducu = 0. + reducv = 0. +c main loop for the different sets of knots.mpm=mu+mv is a save upper +c bound for the number of trials. + 120 mpm = mu+mv + do 270 iter=1,mpm +c find nrintu (nrintv) which is the number of knot intervals in the +c u-direction (v-direction). + nrintu = nu-7 + nrintv = nv-7 +c find the position of the additional knots which are needed for the +c b-spline representation of s(u,v). + i = nu + do 125 j=1,4 + tu(j) = 0. + tu(i) = pi + i = i-1 + 125 continue + l1 = 4 + l2 = l1 + l3 = nv-3 + l4 = l3 + tv(l2) = vb + tv(l3) = ve + do 130 j=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tv(l2) = tv(l4)-per + tv(l3) = tv(l1)+per + 130 continue +c find an estimate of the range of possible values for the optimal +c derivatives at the origin. + ktu = nrdatu(1)+2-iopt(2) + if(ktu.lt.mumin) ktu = mumin + if(ktu.eq.lastu0) go to 140 + rmin = r0 + rmax = r0 + l = mv*ktu + do 135 i=1,l + if(r(i).lt.rmin) rmin = r(i) + if(r(i).gt.rmax) rmax = r(i) + 135 continue + step(1) = rmax-rmin + lastu0 = ktu + 140 ktu = nrdatu(nrintu)+2-iopt(3) + if(ktu.lt.mumin) ktu = mumin + if(ktu.eq.lastu1) go to 150 + rmin = r1 + rmax = r1 + l = mv*ktu + j = mr + do 145 i=1,l + if(r(j).lt.rmin) rmin = r(j) + if(r(j).gt.rmax) rmax = r(j) + j = j-1 + 145 continue + step(2) = rmax-rmin + lastu1 = ktu +c find the least-squares spline sinf(u,v). + 150 call fpopsp(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,r,mr,r0,r1,dr,iopt, + * idd,tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru, + * nrv,wrk,lwrk) + if(step(1).lt.0.) step(1) = -step(1) + if(step(2).lt.0.) step(2) = -step(2) + if(ier.eq.(-2)) fp0 = fp +c test whether the least-squares spline is an acceptable solution. + if(iopt(1).lt.0) go to 440 + fpms = fp-s + if(abs(fpms) .lt. acc) go to 440 +c if f(p=inf) < s, we accept the choice of knots. + if(fpms.lt.0.) go to 300 +c if nu=numax and nv=nvmax, sinf(u,v) is an interpolating spline + if(nu.eq.numax .and. nv.eq.nvmax) go to 430 +c increase the number of knots. +c if nu=nue and nv=nve we cannot further increase the number of knots +c because of the storage capacity limitation. + if(nu.eq.nue .and. nv.eq.nve) go to 420 + if(ider(1).eq.0) fpintu(1) = fpintu(1)+(r0-dr(1))**2 + if(ider(3).eq.0) fpintu(nrintu) = fpintu(nrintu)+(r1-dr(4))**2 + ier = 0 +c adjust the parameter reducu or reducv according to the direction +c in which the last added knots were located. + if (lastdi.lt.0) go to 160 + if (lastdi.eq.0) go to 155 + go to 170 + 155 nplv = 3 + idd(2) = ider(2) + idd(4) = ider(4) + fpold = fp + go to 230 + 160 reducu = fpold-fp + go to 175 + 170 reducv = fpold-fp +c store the sum of squared residuals for the current set of knots. + 175 fpold = fp +c find nplu, the number of knots we should add in the u-direction. + nplu = 1 + if(nu.eq.8) go to 180 + npl1 = nplusu*2 + rn = nplusu + if(reducu.gt.acc) npl1 = rn*fpms/reducu + nplu = min0(nplusu*2,max0(npl1,nplusu/2,1)) +c find nplv, the number of knots we should add in the v-direction. + 180 nplv = 3 + if(nv.eq.8) go to 190 + npl1 = nplusv*2 + rn = nplusv + if(reducv.gt.acc) npl1 = rn*fpms/reducv + nplv = min0(nplusv*2,max0(npl1,nplusv/2,1)) +c test whether we are going to add knots in the u- or v-direction. + 190 if (nplu.lt.nplv) go to 210 + if (nplu.eq.nplv) go to 200 + go to 230 + 200 if(lastdi.lt.0) go to 230 + 210 if(nu.eq.nue) go to 230 +c addition in the u-direction. + lastdi = -1 + nplusu = nplu + ifsu = 0 + istart = 0 + if(iopt(2).eq.0) istart = 1 + do 220 l=1,nplusu +c add a new knot in the u-direction + call fpknot(u,mu,tu,nu,fpintu,nrdatu,nrintu,nuest,istart) +c test whether we cannot further increase the number of knots in the +c u-direction. + if(nu.eq.nue) go to 270 + 220 continue + go to 270 + 230 if(nv.eq.nve) go to 210 +c addition in the v-direction. + lastdi = 1 + nplusv = nplv + ifsv = 0 + do 240 l=1,nplusv +c add a new knot in the v-direction. + call fpknot(v,mv,tv,nv,fpintv,nrdatv,nrintv,nvest,1) +c test whether we cannot further increase the number of knots in the +c v-direction. + if(nv.eq.nve) go to 270 + 240 continue +c restart the computations with the new set of knots. + 270 continue +c test whether the least-squares polynomial is a solution of our +c approximation problem. + 300 if(ier.eq.(-2)) go to 440 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline sp(u,v) c +c ***************************************************** c +c we have determined the number of knots and their position. we now c +c compute the b-spline coefficients of the smoothing spline sp(u,v). c +c this smoothing spline depends on the parameter p in such a way that c +c f(p) = sumi=1,mu(sumj=1,mv((z(i,j)-sp(u(i),v(j)))**2) c +c is a continuous, strictly decreasing function of p. moreover the c +c least-squares polynomial corresponds to p=0 and the least-squares c +c spline to p=infinity. then iteratively we have to determine the c +c positive value of p such that f(p)=s. the process which is proposed c +c here makes use of rational interpolation. f(p) is approximated by a c +c rational function r(p)=(u*p+v)/(p+w); three values of p (p1,p2,p3) c +c with corresponding values of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s)c +c are used to calculate the new value of p such that r(p)=s. c +c convergence is guaranteed by taking f1 > 0 and f3 < 0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c initial value for p. + p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = one + do 305 i=1,6 + drr(i) = dr(i) + 305 continue + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p)=s. + do 350 iter = 1,maxit +c find the smoothing spline sp(u,v) and the corresponding sum f(p). + call fpopsp(ifsu,ifsv,ifbu,ifbv,u,mu,v,mv,r,mr,r0,r1,drr,iopt, + * idd,tu,nu,tv,nv,nuest,nvest,p,step,c,nc,fp,fpintu,fpintv,nru, + * nrv,wrk,lwrk) +c test whether the approximation sp(u,v) is an acceptable solution. + fpms = fp-s + if(abs(fpms).lt.acc) go to 440 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 400 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 320 + if((f2-f3).gt.acc) go to 310 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 350 + 310 if(f2.lt.0.) ich3 = 1 + 320 if(ich1.ne.0) go to 340 + if((f1-f2).gt.acc) go to 330 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 350 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 350 +c test whether the iteration process proceeds as theoretically +c expected. + 330 if(f2.gt.0.) ich1 = 1 + 340 if(f2.ge.f1 .or. f2.le.f3) go to 410 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 350 continue +c error codes and messages. + 400 ier = 3 + go to 440 + 410 ier = 2 + go to 440 + 420 ier = 1 + go to 440 + 430 ier = -1 + fp = 0. + 440 return + end Added: branches/Interpolate1D/fitpack/fpsphe.f =================================================================== --- branches/Interpolate1D/fitpack/fpsphe.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpsphe.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,764 @@ + subroutine fpsphe(iopt,m,teta,phi,r,w,s,ntest,npest,eta,tol,maxit, + * + * ib1,ib3,nc,ncc,intest,nrest,nt,tt,np,tp,c,fp,sup,fpint,coord,f, + * ff,row,coco,cosi,a,q,bt,bp,spt,spp,h,index,nummer,wrk,lwrk,ier) +c .. +c ..scalar arguments.. + integer iopt,m,ntest,npest,maxit,ib1,ib3,nc,ncc,intest,nrest, + * nt,np,lwrk,ier + real*8 s,eta,tol,fp,sup +c ..array arguments.. + real*8 teta(m),phi(m),r(m),w(m),tt(ntest),tp(npest),c(nc), + * fpint(intest),coord(intest),f(ncc),ff(nc),row(npest),coco(npest), + * + * cosi(npest),a(ncc,ib1),q(ncc,ib3),bt(ntest,5),bp(npest,5), + * spt(m,4),spp(m,4),h(ib3),wrk(lwrk) + integer index(nrest),nummer(m) +c ..local scalars.. + real*8 aa,acc,arg,cn,co,c1,dmax,d1,d2,eps,facc,facs,fac1,fac2,fn, + * fpmax,fpms,f1,f2,f3,hti,htj,p,pi,pinv,piv,pi2,p1,p2,p3,ri,si, + * sigma,sq,store,wi,rn,one,con1,con9,con4,half,ten + integer i,iband,iband1,iband3,iband4,ich1,ich3,ii,ij,il,in,irot, + * iter,i1,i2,i3,j,jlt,jrot,j1,j2,l,la,lf,lh,ll,lp,lt,lwest,l1,l2, + * l3,l4,ncof,ncoff,npp,np4,nreg,nrint,nrr,nr1,ntt,nt4,nt6,num, + * num1,rank +c ..local arrays.. + real*8 ht(4),hp(4) +c ..function references.. + real*8 abs,atan,fprati,sqrt,cos,sin + integer min0 +c ..subroutine references.. +c fpback,fpbspl,fpgivs,fpdisc,fporde,fprank,fprota,fprpsp +c .. +c set constants + one = 0.1e+01 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 + half = 0.5e0 + ten = 0.1e+02 + pi = atan(one)*4 + pi2 = pi+pi + eps = sqrt(eta) + if(iopt.lt.0) go to 70 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s + if(iopt.eq.0) go to 10 + if(s.lt.sup) then + if (np.lt.11) go to 60 + go to 70 + endif +c if iopt=0 we begin by computing the weighted least-squares polynomial +c of the form +c s(teta,phi) = c1*f1(teta) + cn*fn(teta) +c where f1(teta) and fn(teta) are the cubic polynomials satisfying +c f1(0) = 1, f1(pi) = f1'(0) = f1'(pi) = 0 ; fn(teta) = 1-f1(teta). +c the corresponding weighted sum of squared residuals gives the upper +c bound sup for the smoothing factor s. + 10 sup = 0. + d1 = 0. + d2 = 0. + c1 = 0. + cn = 0. + fac1 = pi*(one + half) + fac2 = (one + one)/pi**3 + aa = 0. + do 40 i=1,m + wi = w(i) + ri = r(i)*wi + arg = teta(i) + fn = fac2*arg*arg*(fac1-arg) + f1 = (one-fn)*wi + fn = fn*wi + if(fn.eq.0.) go to 20 + call fpgivs(fn,d1,co,si) + call fprota(co,si,f1,aa) + call fprota(co,si,ri,cn) + 20 if(f1.eq.0.) go to 30 + call fpgivs(f1,d2,co,si) + call fprota(co,si,ri,c1) + 30 sup = sup+ri*ri + 40 continue + if(d2.ne.0.) c1 = c1/d2 + if(d1.ne.0.) cn = (cn-aa*c1)/d1 +c find the b-spline representation of this least-squares polynomial + nt = 8 + np = 8 + do 50 i=1,4 + c(i) = c1 + c(i+4) = c1 + c(i+8) = cn + c(i+12) = cn + tt(i) = 0. + tt(i+4) = pi + tp(i) = 0. + tp(i+4) = pi2 + 50 continue + fp = sup +c test whether the least-squares polynomial is an acceptable solution + fpms = sup-s + if(fpms.lt.acc) go to 960 +c test whether we cannot further increase the number of knots. + 60 if(npest.lt.11 .or. ntest.lt.9) go to 950 +c find the initial set of interior knots of the spherical spline in +c case iopt = 0. + np = 11 + tp(5) = pi*half + tp(6) = pi + tp(7) = tp(5)+pi + nt = 9 + tt(5) = tp(5) +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1 : computation of least-squares spherical splines. c +c ******************************************************** c +c if iopt < 0 we compute the least-squares spherical spline according c +c to the given set of knots. c +c if iopt >=0 we compute least-squares spherical splines with increas-c +c ing numbers of knots until the corresponding sum f(p=inf)<=s. c +c the initial set of knots then depends on the value of iopt: c +c if iopt=0 we start with one interior knot in the teta-direction c +c (pi/2) and three in the phi-direction (pi/2,pi,3*pi/2). c +c if iopt>0 we start with the set of knots found at the last call c +c of the routine. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c main loop for the different sets of knots. m is a save upper bound +c for the number of trials. + 70 do 570 iter=1,m +c find the position of the additional knots which are needed for the +c b-spline representation of s(teta,phi). + l1 = 4 + l2 = l1 + l3 = np-3 + l4 = l3 + tp(l2) = 0. + tp(l3) = pi2 + do 80 i=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tp(l2) = tp(l4)-pi2 + tp(l3) = tp(l1)+pi2 + 80 continue + l = nt + do 90 i=1,4 + tt(i) = 0. + tt(l) = pi + l = l-1 + 90 continue +c find nrint, the total number of knot intervals and nreg, the number +c of panels in which the approximation domain is subdivided by the +c intersection of knots. + ntt = nt-7 + npp = np-7 + nrr = npp/2 + nr1 = nrr+1 + nrint = ntt+npp + nreg = ntt*npp +c arrange the data points according to the panel they belong to. + call fporde(teta,phi,m,3,3,tt,nt,tp,np,nummer,index,nreg) +c find the b-spline coefficients coco and cosi of the cubic spline +c approximations sc(phi) and ss(phi) for cos(phi) and sin(phi). + do 100 i=1,npp + coco(i) = 0. + cosi(i) = 0. + do 100 j=1,npp + a(i,j) = 0. + 100 continue +c the coefficients coco and cosi are obtained from the conditions +c sc(tp(i))=cos(tp(i)),resp. ss(tp(i))=sin(tp(i)),i=4,5,...np-4. + do 150 i=1,npp + l2 = i+3 + arg = tp(l2) + call fpbspl(tp,np,3,arg,l2,hp) + do 110 j=1,npp + row(j) = 0. + 110 continue + ll = i + do 120 j=1,3 + if(ll.gt.npp) ll= 1 + row(ll) = row(ll)+hp(j) + ll = ll+1 + 120 continue + facc = cos(arg) + facs = sin(arg) + do 140 j=1,npp + piv = row(j) + if(piv.eq.0.) go to 140 + call fpgivs(piv,a(j,1),co,si) + call fprota(co,si,facc,coco(j)) + call fprota(co,si,facs,cosi(j)) + if(j.eq.npp) go to 150 + j1 = j+1 + i2 = 1 + do 130 l=j1,npp + i2 = i2+1 + call fprota(co,si,row(l),a(j,i2)) + 130 continue + 140 continue + 150 continue + call fpback(a,coco,npp,npp,coco,ncc) + call fpback(a,cosi,npp,npp,cosi,ncc) +c find ncof, the dimension of the spherical spline and ncoff, the +c number of coefficients in the standard b-spline representation. + nt4 = nt-4 + np4 = np-4 + ncoff = nt4*np4 + ncof = 6+npp*(ntt-1) +c find the bandwidth of the observation matrix a. + iband = 4*npp + if(ntt.eq.4) iband = 3*(npp+1) + if(ntt.lt.4) iband = ncof + iband1 = iband-1 +c initialize the observation matrix a. + do 160 i=1,ncof + f(i) = 0. + do 160 j=1,iband + a(i,j) = 0. + 160 continue +c initialize the sum of squared residuals. + fp = 0. +c fetch the data points in the new order. main loop for the +c different panels. + do 340 num=1,nreg +c fix certain constants for the current panel; jrot records the column +c number of the first non-zero element in a row of the observation +c matrix according to a data point of the panel. + num1 = num-1 + lt = num1/npp + l1 = lt+4 + lp = num1-lt*npp+1 + l2 = lp+3 + lt = lt+1 + jrot = 0 + if(lt.gt.2) jrot = 3+(lt-3)*npp +c test whether there are still data points in the current panel. + in = index(num) + 170 if(in.eq.0) go to 340 +c fetch a new data point. + wi = w(in) + ri = r(in)*wi +c evaluate for the teta-direction, the 4 non-zero b-splines at teta(in) + call fpbspl(tt,nt,3,teta(in),l1,ht) +c evaluate for the phi-direction, the 4 non-zero b-splines at phi(in) + call fpbspl(tp,np,3,phi(in),l2,hp) +c store the value of these b-splines in spt and spp resp. + do 180 i=1,4 + spp(in,i) = hp(i) + spt(in,i) = ht(i) + 180 continue +c initialize the new row of observation matrix. + do 190 i=1,iband + h(i) = 0. + 190 continue +c calculate the non-zero elements of the new row by making the cross +c products of the non-zero b-splines in teta- and phi-direction and +c by taking into account the conditions of the spherical splines. + do 200 i=1,npp + row(i) = 0. + 200 continue +c take into account the condition (3) of the spherical splines. + ll = lp + do 210 i=1,4 + if(ll.gt.npp) ll=1 + row(ll) = row(ll)+hp(i) + ll = ll+1 + 210 continue +c take into account the other conditions of the spherical splines. + if(lt.gt.2 .and. lt.lt.(ntt-1)) go to 230 + facc = 0. + facs = 0. + do 220 i=1,npp + facc = facc+row(i)*coco(i) + facs = facs+row(i)*cosi(i) + 220 continue +c fill in the non-zero elements of the new row. + 230 j1 = 0 + do 280 j =1,4 + jlt = j+lt + htj = ht(j) + if(jlt.gt.2 .and. jlt.le.nt4) go to 240 + j1 = j1+1 + h(j1) = h(j1)+htj + go to 280 + 240 if(jlt.eq.3 .or. jlt.eq.nt4) go to 260 + do 250 i=1,npp + j1 = j1+1 + h(j1) = row(i)*htj + 250 continue + go to 280 + 260 if(jlt.eq.3) go to 270 + h(j1+1) = facc*htj + h(j1+2) = facs*htj + h(j1+3) = htj + j1 = j1+2 + go to 280 + 270 h(1) = h(1)+htj + h(2) = facc*htj + h(3) = facs*htj + j1 = 3 + 280 continue + do 290 i=1,iband + h(i) = h(i)*wi + 290 continue +c rotate the row into triangle by givens transformations. + irot = jrot + do 310 i=1,iband + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 310 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(irot,1),co,si) +c apply that transformation to the right hand side. + call fprota(co,si,ri,f(irot)) + if(i.eq.iband) go to 320 +c apply that transformation to the left hand side. + i2 = 1 + i3 = i+1 + do 300 j=i3,iband + i2 = i2+1 + call fprota(co,si,h(j),a(irot,i2)) + 300 continue + 310 continue +c add the contribution of the row to the sum of squares of residual +c right hand sides. + 320 fp = fp+ri**2 +c find the number of the next data point in the panel. + 330 in = nummer(in) + go to 170 + 340 continue +c find dmax, the maximum value for the diagonal elements in the reduced +c triangle. + dmax = 0. + do 350 i=1,ncof + if(a(i,1).le.dmax) go to 350 + dmax = a(i,1) + 350 continue +c check whether the observation matrix is rank deficient. + sigma = eps*dmax + do 360 i=1,ncof + if(a(i,1).le.sigma) go to 370 + 360 continue +c backward substitution in case of full rank. + call fpback(a,f,ncof,iband,c,ncc) + rank = ncof + do 365 i=1,ncof + q(i,1) = a(i,1)/dmax + 365 continue + go to 390 +c in case of rank deficiency, find the minimum norm solution. + 370 lwest = ncof*iband+ncof+iband + if(lwrk.lt.lwest) go to 925 + lf = 1 + lh = lf+ncof + la = lh+iband + do 380 i=1,ncof + ff(i) = f(i) + do 380 j=1,iband + q(i,j) = a(i,j) + 380 continue + call fprank(q,ff,ncof,iband,ncc,sigma,c,sq,rank,wrk(la), + * wrk(lf),wrk(lh)) + do 385 i=1,ncof + q(i,1) = q(i,1)/dmax + 385 continue +c add to the sum of squared residuals, the contribution of reducing +c the rank. + fp = fp+sq +c find the coefficients in the standard b-spline representation of +c the spherical spline. + 390 call fprpsp(nt,np,coco,cosi,c,ff,ncoff) +c test whether the least-squares spline is an acceptable solution. + if(iopt.lt.0) then + if (fp.le.0) go to 970 + go to 980 + endif + fpms = fp-s + if(abs(fpms).le.acc) then + if (fp.le.0) go to 970 + go to 980 + endif +c if f(p=inf) < s, accept the choice of knots. + if(fpms.lt.0.) go to 580 +c test whether we cannot further increase the number of knots. + if(ncof.gt.m) go to 935 +c search where to add a new knot. +c find for each interval the sum of squared residuals fpint for the +c data points having the coordinate belonging to that knot interval. +c calculate also coord which is the same sum, weighted by the position +c of the data points considered. + 440 do 450 i=1,nrint + fpint(i) = 0. + coord(i) = 0. + 450 continue + do 490 num=1,nreg + num1 = num-1 + lt = num1/npp + l1 = lt+1 + lp = num1-lt*npp + l2 = lp+1+ntt + jrot = lt*np4+lp + in = index(num) + 460 if(in.eq.0) go to 490 + store = 0. + i1 = jrot + do 480 i=1,4 + hti = spt(in,i) + j1 = i1 + do 470 j=1,4 + j1 = j1+1 + store = store+hti*spp(in,j)*c(j1) + 470 continue + i1 = i1+np4 + 480 continue + store = (w(in)*(r(in)-store))**2 + fpint(l1) = fpint(l1)+store + coord(l1) = coord(l1)+store*teta(in) + fpint(l2) = fpint(l2)+store + coord(l2) = coord(l2)+store*phi(in) + in = nummer(in) + go to 460 + 490 continue +c find the interval for which fpint is maximal on the condition that +c there still can be added a knot. + l1 = 1 + l2 = nrint + if(ntest.lt.nt+1) l1=ntt+1 + if(npest.lt.np+2) l2=ntt +c test whether we cannot further increase the number of knots. + if(l1.gt.l2) go to 950 + 500 fpmax = 0. + l = 0 + do 510 i=l1,l2 + if(fpmax.ge.fpint(i)) go to 510 + l = i + fpmax = fpint(i) + 510 continue + if(l.eq.0) go to 930 +c calculate the position of the new knot. + arg = coord(l)/fpint(l) +c test in what direction the new knot is going to be added. + if(l.gt.ntt) go to 530 +c addition in the teta-direction + l4 = l+4 + fpint(l) = 0. + fac1 = tt(l4)-arg + fac2 = arg-tt(l4-1) + if(fac1.gt.(ten*fac2) .or. fac2.gt.(ten*fac1)) go to 500 + j = nt + do 520 i=l4,nt + tt(j+1) = tt(j) + j = j-1 + 520 continue + tt(l4) = arg + nt = nt+1 + go to 570 +c addition in the phi-direction + 530 l4 = l+4-ntt + if(arg.lt.pi) go to 540 + arg = arg-pi + l4 = l4-nrr + 540 fpint(l) = 0. + fac1 = tp(l4)-arg + fac2 = arg-tp(l4-1) + if(fac1.gt.(ten*fac2) .or. fac2.gt.(ten*fac1)) go to 500 + ll = nrr+4 + j = ll + do 550 i=l4,ll + tp(j+1) = tp(j) + j = j-1 + 550 continue + tp(l4) = arg + np = np+2 + nrr = nrr+1 + do 560 i=5,ll + j = i+nrr + tp(j) = tp(i)+pi + 560 continue +c restart the computations with the new set of knots. + 570 continue +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spherical spline. c +c ******************************************************** c +c we have determined the number of knots and their position. we now c +c compute the coefficients of the smoothing spline sp(teta,phi). c +c the observation matrix a is extended by the rows of a matrix, expres-c +c sing that sp(teta,phi) must be a constant function in the variable c +c phi and a cubic polynomial in the variable teta. the corresponding c +c weights of these additional rows are set to 1/(p). iteratively c +c we than have to determine the value of p such that f(p) = sum((w(i)* c +c (r(i)-sp(teta(i),phi(i))))**2) be = s. c +c we already know that the least-squares polynomial corresponds to p=0,c +c and that the least-squares spherical spline corresponds to p=infin. c +c the iteration process makes use of rational interpolation. since f(p)c +c is a convex and strictly decreasing function of p, it can be approx- c +c imated by a rational function of the form r(p) = (u*p+v)/(p+w). c +c three values of p (p1,p2,p3) with corresponding values of f(p) (f1= c +c f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used to calculate the new value c +c of p such that r(p)=s. convergence is guaranteed by taking f1>0,f3<0.c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c evaluate the discontinuity jumps of the 3-th order derivative of +c the b-splines at the knots tt(l),l=5,...,nt-4. + 580 call fpdisc(tt,nt,5,bt,ntest) +c evaluate the discontinuity jumps of the 3-th order derivative of +c the b-splines at the knots tp(l),l=5,...,np-4. + call fpdisc(tp,np,5,bp,npest) +c initial value for p. + p1 = 0. + f1 = sup-s + p3 = -one + f3 = fpms + p = 0. + do 585 i=1,ncof + p = p+a(i,1) + 585 continue + rn = ncof + p = rn/p +c find the bandwidth of the extended observation matrix. + iband4 = iband+3 + if(ntt.le.4) iband4 = ncof + iband3 = iband4 -1 + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p)=s. + do 920 iter=1,maxit + pinv = one/p +c store the triangularized observation matrix into q. + do 600 i=1,ncof + ff(i) = f(i) + do 590 j=1,iband4 + q(i,j) = 0. + 590 continue + do 600 j=1,iband + q(i,j) = a(i,j) + 600 continue +c extend the observation matrix with the rows of a matrix, expressing +c that for teta=cst. sp(teta,phi) must be a constant function. + nt6 = nt-6 + do 720 i=5,np4 + ii = i-4 + do 610 l=1,npp + row(l) = 0. + 610 continue + ll = ii + do 620 l=1,5 + if(ll.gt.npp) ll=1 + row(ll) = row(ll)+bp(ii,l) + ll = ll+1 + 620 continue + facc = 0. + facs = 0. + do 630 l=1,npp + facc = facc+row(l)*coco(l) + facs = facs+row(l)*cosi(l) + 630 continue + do 720 j=1,nt6 +c initialize the new row. + do 640 l=1,iband + h(l) = 0. + 640 continue +c fill in the non-zero elements of the row. jrot records the column +c number of the first non-zero element in the row. + jrot = 4+(j-2)*npp + if(j.gt.1 .and. j.lt.nt6) go to 650 + h(1) = facc + h(2) = facs + if(j.eq.1) jrot = 2 + go to 670 + 650 do 660 l=1,npp + h(l)=row(l) + 660 continue + 670 do 675 l=1,iband + h(l) = h(l)*pinv + 675 continue + ri = 0. +c rotate the new row into triangle by givens transformations. + do 710 irot=jrot,ncof + piv = h(1) + i2 = min0(iband1,ncof-irot) + if(piv.eq.0.) then + if (i2.le.0) go to 720 + go to 690 + endif +c calculate the parameters of the givens transformation. + call fpgivs(piv,q(irot,1),co,si) +c apply that givens transformation to the right hand side. + call fprota(co,si,ri,ff(irot)) + if(i2.eq.0) go to 720 +c apply that givens transformation to the left hand side. + do 680 l=1,i2 + l1 = l+1 + call fprota(co,si,h(l1),q(irot,l1)) + 680 continue + 690 do 700 l=1,i2 + h(l) = h(l+1) + 700 continue + h(i2+1) = 0. + 710 continue + 720 continue +c extend the observation matrix with the rows of a matrix expressing +c that for phi=cst. sp(teta,phi) must be a cubic polynomial. + do 810 i=5,nt4 + ii = i-4 + do 810 j=1,npp +c initialize the new row + do 730 l=1,iband4 + h(l) = 0. + 730 continue +c fill in the non-zero elements of the row. jrot records the column +c number of the first non-zero element in the row. + j1 = 1 + do 760 l=1,5 + il = ii+l + ij = npp + if(il.ne.3 .and. il.ne.nt4) go to 750 + j1 = j1+3-j + j2 = j1-2 + ij = 0 + if(il.ne.3) go to 740 + j1 = 1 + j2 = 2 + ij = j+2 + 740 h(j2) = bt(ii,l)*coco(j) + h(j2+1) = bt(ii,l)*cosi(j) + 750 h(j1) = h(j1)+bt(ii,l) + j1 = j1+ij + 760 continue + do 765 l=1,iband4 + h(l) = h(l)*pinv + 765 continue + ri = 0. + jrot = 1 + if(ii.gt.2) jrot = 3+j+(ii-3)*npp +c rotate the new row into triangle by givens transformations. + do 800 irot=jrot,ncof + piv = h(1) + i2 = min0(iband3,ncof-irot) + if(piv.eq.0.) then + if (i2.le.0) go to 810 + go to 780 + endif +c calculate the parameters of the givens transformation. + call fpgivs(piv,q(irot,1),co,si) +c apply that givens transformation to the right hand side. + call fprota(co,si,ri,ff(irot)) + if(i2.eq.0) go to 810 +c apply that givens transformation to the left hand side. + do 770 l=1,i2 + l1 = l+1 + call fprota(co,si,h(l1),q(irot,l1)) + 770 continue + 780 do 790 l=1,i2 + h(l) = h(l+1) + 790 continue + h(i2+1) = 0. + 800 continue + 810 continue +c find dmax, the maximum value for the diagonal elements in the +c reduced triangle. + dmax = 0. + do 820 i=1,ncof + if(q(i,1).le.dmax) go to 820 + dmax = q(i,1) + 820 continue +c check whether the matrix is rank deficient. + sigma = eps*dmax + do 830 i=1,ncof + if(q(i,1).le.sigma) go to 840 + 830 continue +c backward substitution in case of full rank. + call fpback(q,ff,ncof,iband4,c,ncc) + rank = ncof + go to 845 +c in case of rank deficiency, find the minimum norm solution. + 840 lwest = ncof*iband4+ncof+iband4 + if(lwrk.lt.lwest) go to 925 + lf = 1 + lh = lf+ncof + la = lh+iband4 + call fprank(q,ff,ncof,iband4,ncc,sigma,c,sq,rank,wrk(la), + * wrk(lf),wrk(lh)) + 845 do 850 i=1,ncof + q(i,1) = q(i,1)/dmax + 850 continue +c find the coefficients in the standard b-spline representation of +c the spherical spline. + call fprpsp(nt,np,coco,cosi,c,ff,ncoff) +c compute f(p). + fp = 0. + do 890 num = 1,nreg + num1 = num-1 + lt = num1/npp + lp = num1-lt*npp + jrot = lt*np4+lp + in = index(num) + 860 if(in.eq.0) go to 890 + store = 0. + i1 = jrot + do 880 i=1,4 + hti = spt(in,i) + j1 = i1 + do 870 j=1,4 + j1 = j1+1 + store = store+hti*spp(in,j)*c(j1) + 870 continue + i1 = i1+np4 + 880 continue + fp = fp+(w(in)*(r(in)-store))**2 + in = nummer(in) + go to 860 + 890 continue +c test whether the approximation sp(teta,phi) is an acceptable solution + fpms = fp-s + if(abs(fpms).le.acc) go to 980 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 940 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 900 + if((f2-f3).gt.acc) go to 895 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 920 + 895 if(f2.lt.0.) ich3 = 1 + 900 if(ich1.ne.0) go to 910 + if((f1-f2).gt.acc) go to 905 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 920 + if(p.ge.p3) p = p2*con1 +p3*con9 + go to 920 + 905 if(f2.gt.0.) ich1 = 1 +c test whether the iteration process proceeds as theoretically +c expected. + 910 if(f2.ge.f1 .or. f2.le.f3) go to 945 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 920 continue +c error codes and messages. + 925 ier = lwest + go to 990 + 930 ier = 5 + go to 990 + 935 ier = 4 + go to 990 + 940 ier = 3 + go to 990 + 945 ier = 2 + go to 990 + 950 ier = 1 + go to 990 + 960 ier = -2 + go to 990 + 970 ier = -1 + fp = 0. + 980 if(ncof.ne.rank) ier = -rank + 990 return + end Added: branches/Interpolate1D/fitpack/fpsuev.f =================================================================== --- branches/Interpolate1D/fitpack/fpsuev.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpsuev.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,80 @@ + subroutine fpsuev(idim,tu,nu,tv,nv,c,u,mu,v,mv,f,wu,wv,lu,lv) +c ..scalar arguments.. + integer idim,nu,nv,mu,mv +c ..array arguments.. + integer lu(mu),lv(mv) + real*8 tu(nu),tv(nv),c((nu-4)*(nv-4)*idim),u(mu),v(mv), + * f(mu*mv*idim),wu(mu,4),wv(mv,4) +c ..local scalars.. + integer i,i1,j,j1,k,l,l1,l2,l3,m,nuv,nu4,nv4 + real*8 arg,sp,tb,te +c ..local arrays.. + real*8 h(4) +c ..subroutine references.. +c fpbspl +c .. + nu4 = nu-4 + tb = tu(4) + te = tu(nu4+1) + l = 4 + l1 = l+1 + do 40 i=1,mu + arg = u(i) + if(arg.lt.tb) arg = tb + if(arg.gt.te) arg = te + 10 if(arg.lt.tu(l1) .or. l.eq.nu4) go to 20 + l = l1 + l1 = l+1 + go to 10 + 20 call fpbspl(tu,nu,3,arg,l,h) + lu(i) = l-4 + do 30 j=1,4 + wu(i,j) = h(j) + 30 continue + 40 continue + nv4 = nv-4 + tb = tv(4) + te = tv(nv4+1) + l = 4 + l1 = l+1 + do 80 i=1,mv + arg = v(i) + if(arg.lt.tb) arg = tb + if(arg.gt.te) arg = te + 50 if(arg.lt.tv(l1) .or. l.eq.nv4) go to 60 + l = l1 + l1 = l+1 + go to 50 + 60 call fpbspl(tv,nv,3,arg,l,h) + lv(i) = l-4 + do 70 j=1,4 + wv(i,j) = h(j) + 70 continue + 80 continue + m = 0 + nuv = nu4*nv4 + do 140 k=1,idim + l3 = (k-1)*nuv + do 130 i=1,mu + l = lu(i)*nv4+l3 + do 90 i1=1,4 + h(i1) = wu(i,i1) + 90 continue + do 120 j=1,mv + l1 = l+lv(j) + sp = 0. + do 110 i1=1,4 + l2 = l1 + do 100 j1=1,4 + l2 = l2+1 + sp = sp+c(l2)*h(i1)*wv(j,j1) + 100 continue + l1 = l1+nv4 + 110 continue + m = m+1 + f(m) = sp + 120 continue + 130 continue + 140 continue + return + end Added: branches/Interpolate1D/fitpack/fpsurf.f =================================================================== --- branches/Interpolate1D/fitpack/fpsurf.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpsurf.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,680 @@ + subroutine fpsurf(iopt,m,x,y,z,w,xb,xe,yb,ye,kxx,kyy,s,nxest, + * nyest,eta,tol,maxit,nmax,km1,km2,ib1,ib3,nc,intest,nrest, + * nx0,tx,ny0,ty,c,fp,fp0,fpint,coord,f,ff,a,q,bx,by,spx,spy,h, + * index,nummer,wrk,lwrk,ier) +c .. +c ..scalar arguments.. + real*8 xb,xe,yb,ye,s,eta,tol,fp,fp0 + integer iopt,m,kxx,kyy,nxest,nyest,maxit,nmax,km1,km2,ib1,ib3, + * nc,intest,nrest,nx0,ny0,lwrk,ier +c ..array arguments.. + real*8 x(m),y(m),z(m),w(m),tx(nmax),ty(nmax),c(nc),fpint(intest), + * coord(intest),f(nc),ff(nc),a(nc,ib1),q(nc,ib3),bx(nmax,km2), + * by(nmax,km2),spx(m,km1),spy(m,km1),h(ib3),wrk(lwrk) + integer index(nrest),nummer(m) +c ..local scalars.. + real*8 acc,arg,cos,dmax,fac1,fac2,fpmax,fpms,f1,f2,f3,hxi,p,pinv, + * piv,p1,p2,p3,sigma,sin,sq,store,wi,x0,x1,y0,y1,zi,eps, + * rn,one,con1,con9,con4,half,ten + integer i,iband,iband1,iband3,iband4,ibb,ichang,ich1,ich3,ii, + * in,irot,iter,i1,i2,i3,j,jrot,jxy,j1,kx,kx1,kx2,ky,ky1,ky2,l, + * la,lf,lh,lwest,lx,ly,l1,l2,n,ncof,nk1x,nk1y,nminx,nminy,nreg, + * nrint,num,num1,nx,nxe,nxx,ny,nye,nyy,n1,rank +c ..local arrays.. + real*8 hx(6),hy(6) +c ..function references.. + real*8 abs,fprati,sqrt + integer min0 +c ..subroutine references.. +c fpback,fpbspl,fpgivs,fpdisc,fporde,fprank,fprota +c .. +c set constants + one = 0.1e+01 + con1 = 0.1e0 + con9 = 0.9e0 + con4 = 0.4e-01 + half = 0.5e0 + ten = 0.1e+02 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 1: determination of the number of knots and their position. c +c **************************************************************** c +c given a set of knots we compute the least-squares spline sinf(x,y), c +c and the corresponding weighted sum of squared residuals fp=f(p=inf). c +c if iopt=-1 sinf(x,y) is the requested approximation. c +c if iopt=0 or iopt=1 we check whether we can accept the knots: c +c if fp <=s we will continue with the current set of knots. c +c if fp > s we will increase the number of knots and compute the c +c corresponding least-squares spline until finally fp<=s. c +c the initial choice of knots depends on the value of s and iopt. c +c if iopt=0 we first compute the least-squares polynomial of degree c +c kx in x and ky in y; nx=nminx=2*kx+2 and ny=nminy=2*ky+2. c +c fp0=f(0) denotes the corresponding weighted sum of squared c +c residuals c +c if iopt=1 we start with the knots found at the last call of the c +c routine, except for the case that s>=fp0; then we can compute c +c the least-squares polynomial directly. c +c eventually the independent variables x and y (and the corresponding c +c parameters) will be switched if this can reduce the bandwidth of the c +c system to be solved. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c ichang denotes whether(1) or not(-1) the directions have been inter- +c changed. + ichang = -1 + x0 = xb + x1 = xe + y0 = yb + y1 = ye + kx = kxx + ky = kyy + kx1 = kx+1 + ky1 = ky+1 + nxe = nxest + nye = nyest + eps = sqrt(eta) + if(iopt.lt.0) go to 20 +c calculation of acc, the absolute tolerance for the root of f(p)=s. + acc = tol*s + if(iopt.eq.0) go to 10 + if(fp0.gt.s) go to 20 +c initialization for the least-squares polynomial. + 10 nminx = 2*kx1 + nminy = 2*ky1 + nx = nminx + ny = nminy + ier = -2 + go to 30 + 20 nx = nx0 + ny = ny0 +c main loop for the different sets of knots. m is a save upper bound +c for the number of trials. + 30 do 420 iter=1,m +c find the position of the additional knots which are needed for the +c b-spline representation of s(x,y). + l = nx + do 40 i=1,kx1 + tx(i) = x0 + tx(l) = x1 + l = l-1 + 40 continue + l = ny + do 50 i=1,ky1 + ty(i) = y0 + ty(l) = y1 + l = l-1 + 50 continue +c find nrint, the total number of knot intervals and nreg, the number +c of panels in which the approximation domain is subdivided by the +c intersection of knots. + nxx = nx-2*kx1+1 + nyy = ny-2*ky1+1 + nrint = nxx+nyy + nreg = nxx*nyy +c find the bandwidth of the observation matrix a. +c if necessary, interchange the variables x and y, in order to obtain +c a minimal bandwidth. + iband1 = kx*(ny-ky1)+ky + l = ky*(nx-kx1)+kx + if(iband1.le.l) go to 130 + iband1 = l + ichang = -ichang + do 60 i=1,m + store = x(i) + x(i) = y(i) + y(i) = store + 60 continue + store = x0 + x0 = y0 + y0 = store + store = x1 + x1 = y1 + y1 = store + n = min0(nx,ny) + do 70 i=1,n + store = tx(i) + tx(i) = ty(i) + ty(i) = store + 70 continue + n1 = n+1 + if (nx.lt.ny) go to 80 + if (nx.eq.ny) go to 120 + go to 100 + 80 do 90 i=n1,ny + tx(i) = ty(i) + 90 continue + go to 120 + 100 do 110 i=n1,nx + ty(i) = tx(i) + 110 continue + 120 l = nx + nx = ny + ny = l + l = nxe + nxe = nye + nye = l + l = nxx + nxx = nyy + nyy = l + l = kx + kx = ky + ky = l + kx1 = kx+1 + ky1 = ky+1 + 130 iband = iband1+1 +c arrange the data points according to the panel they belong to. + call fporde(x,y,m,kx,ky,tx,nx,ty,ny,nummer,index,nreg) +c find ncof, the number of b-spline coefficients. + nk1x = nx-kx1 + nk1y = ny-ky1 + ncof = nk1x*nk1y +c initialize the observation matrix a. + do 140 i=1,ncof + f(i) = 0. + do 140 j=1,iband + a(i,j) = 0. + 140 continue +c initialize the sum of squared residuals. + fp = 0. +c fetch the data points in the new order. main loop for the +c different panels. + do 250 num=1,nreg +c fix certain constants for the current panel; jrot records the column +c number of the first non-zero element in a row of the observation +c matrix according to a data point of the panel. + num1 = num-1 + lx = num1/nyy + l1 = lx+kx1 + ly = num1-lx*nyy + l2 = ly+ky1 + jrot = lx*nk1y+ly +c test whether there are still data points in the panel. + in = index(num) + 150 if(in.eq.0) go to 250 +c fetch a new data point. + wi = w(in) + zi = z(in)*wi +c evaluate for the x-direction, the (kx+1) non-zero b-splines at x(in). + call fpbspl(tx,nx,kx,x(in),l1,hx) +c evaluate for the y-direction, the (ky+1) non-zero b-splines at y(in). + call fpbspl(ty,ny,ky,y(in),l2,hy) +c store the value of these b-splines in spx and spy respectively. + do 160 i=1,kx1 + spx(in,i) = hx(i) + 160 continue + do 170 i=1,ky1 + spy(in,i) = hy(i) + 170 continue +c initialize the new row of observation matrix. + do 180 i=1,iband + h(i) = 0. + 180 continue +c calculate the non-zero elements of the new row by making the cross +c products of the non-zero b-splines in x- and y-direction. + i1 = 0 + do 200 i=1,kx1 + hxi = hx(i) + j1 = i1 + do 190 j=1,ky1 + j1 = j1+1 + h(j1) = hxi*hy(j)*wi + 190 continue + i1 = i1+nk1y + 200 continue +c rotate the row into triangle by givens transformations . + irot = jrot + do 220 i=1,iband + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 220 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(irot,1),cos,sin) +c apply that transformation to the right hand side. + call fprota(cos,sin,zi,f(irot)) + if(i.eq.iband) go to 230 +c apply that transformation to the left hand side. + i2 = 1 + i3 = i+1 + do 210 j=i3,iband + i2 = i2+1 + call fprota(cos,sin,h(j),a(irot,i2)) + 210 continue + 220 continue +c add the contribution of the row to the sum of squares of residual +c right hand sides. + 230 fp = fp+zi**2 +c find the number of the next data point in the panel. + 240 in = nummer(in) + go to 150 + 250 continue +c find dmax, the maximum value for the diagonal elements in the reduced +c triangle. + dmax = 0. + do 260 i=1,ncof + if(a(i,1).le.dmax) go to 260 + dmax = a(i,1) + 260 continue +c check whether the observation matrix is rank deficient. + sigma = eps*dmax + do 270 i=1,ncof + if(a(i,1).le.sigma) go to 280 + 270 continue +c backward substitution in case of full rank. + call fpback(a,f,ncof,iband,c,nc) + rank = ncof + do 275 i=1,ncof + q(i,1) = a(i,1)/dmax + 275 continue + go to 300 +c in case of rank deficiency, find the minimum norm solution. +c check whether there is sufficient working space + 280 lwest = ncof*iband+ncof+iband + if(lwrk.lt.lwest) go to 780 + do 290 i=1,ncof + ff(i) = f(i) + do 290 j=1,iband + q(i,j) = a(i,j) + 290 continue + lf =1 + lh = lf+ncof + la = lh+iband + call fprank(q,ff,ncof,iband,nc,sigma,c,sq,rank,wrk(la), + * wrk(lf),wrk(lh)) + do 295 i=1,ncof + q(i,1) = q(i,1)/dmax + 295 continue +c add to the sum of squared residuals, the contribution of reducing +c the rank. + fp = fp+sq + 300 if(ier.eq.(-2)) fp0 = fp +c test whether the least-squares spline is an acceptable solution. + if(iopt.lt.0) go to 820 + fpms = fp-s + if(abs(fpms).le.acc) then + if (fp.le.0) go to 815 + go to 820 + endif +c test whether we can accept the choice of knots. + if(fpms.lt.0.) go to 430 +c test whether we cannot further increase the number of knots. + if(ncof.gt.m) go to 790 + ier = 0 +c search where to add a new knot. +c find for each interval the sum of squared residuals fpint for the +c data points having the coordinate belonging to that knot interval. +c calculate also coord which is the same sum, weighted by the position +c of the data points considered. + 310 do 320 i=1,nrint + fpint(i) = 0. + coord(i) = 0. + 320 continue + do 360 num=1,nreg + num1 = num-1 + lx = num1/nyy + l1 = lx+1 + ly = num1-lx*nyy + l2 = ly+1+nxx + jrot = lx*nk1y+ly + in = index(num) + 330 if(in.eq.0) go to 360 + store = 0. + i1 = jrot + do 350 i=1,kx1 + hxi = spx(in,i) + j1 = i1 + do 340 j=1,ky1 + j1 = j1+1 + store = store+hxi*spy(in,j)*c(j1) + 340 continue + i1 = i1+nk1y + 350 continue + store = (w(in)*(z(in)-store))**2 + fpint(l1) = fpint(l1)+store + coord(l1) = coord(l1)+store*x(in) + fpint(l2) = fpint(l2)+store + coord(l2) = coord(l2)+store*y(in) + in = nummer(in) + go to 330 + 360 continue +c find the interval for which fpint is maximal on the condition that +c there still can be added a knot. + 370 l = 0 + fpmax = 0. + l1 = 1 + l2 = nrint + if(nx.eq.nxe) l1 = nxx+1 + if(ny.eq.nye) l2 = nxx + if(l1.gt.l2) go to 810 + do 380 i=l1,l2 + if(fpmax.ge.fpint(i)) go to 380 + l = i + fpmax = fpint(i) + 380 continue +c test whether we cannot further increase the number of knots. + if(l.eq.0) go to 785 +c calculate the position of the new knot. + arg = coord(l)/fpint(l) +c test in what direction the new knot is going to be added. + if(l.gt.nxx) go to 400 +c addition in the x-direction. + jxy = l+kx1 + fpint(l) = 0. + fac1 = tx(jxy)-arg + fac2 = arg-tx(jxy-1) + if(fac1.gt.(ten*fac2) .or. fac2.gt.(ten*fac1)) go to 370 + j = nx + do 390 i=jxy,nx + tx(j+1) = tx(j) + j = j-1 + 390 continue + tx(jxy) = arg + nx = nx+1 + go to 420 +c addition in the y-direction. + 400 jxy = l+ky1-nxx + fpint(l) = 0. + fac1 = ty(jxy)-arg + fac2 = arg-ty(jxy-1) + if(fac1.gt.(ten*fac2) .or. fac2.gt.(ten*fac1)) go to 370 + j = ny + do 410 i=jxy,ny + ty(j+1) = ty(j) + j = j-1 + 410 continue + ty(jxy) = arg + ny = ny+1 +c restart the computations with the new set of knots. + 420 continue +c test whether the least-squares polynomial is a solution of our +c approximation problem. + 430 if(ier.eq.(-2)) go to 830 +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc +c part 2: determination of the smoothing spline sp(x,y) c +c ***************************************************** c +c we have determined the number of knots and their position. we now c +c compute the b-spline coefficients of the smoothing spline sp(x,y). c +c the observation matrix a is extended by the rows of a matrix, c +c expressing that sp(x,y) must be a polynomial of degree kx in x and c +c ky in y. the corresponding weights of these additional rows are set c +c to 1./p. iteratively we than have to determine the value of p c +c such that f(p)=sum((w(i)*(z(i)-sp(x(i),y(i))))**2) be = s. c +c we already know that the least-squares polynomial corresponds to c +c p=0 and that the least-squares spline corresponds to p=infinity. c +c the iteration process which is proposed here makes use of rational c +c interpolation. since f(p) is a convex and strictly decreasing c +c function of p, it can be approximated by a rational function r(p)= c +c (u*p+v)/(p+w). three values of p(p1,p2,p3) with corresponding values c +c of f(p) (f1=f(p1)-s,f2=f(p2)-s,f3=f(p3)-s) are used to calculate the c +c new value of p such that r(p)=s. convergence is guaranteed by taking c +c f1 > 0 and f3 < 0. c +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc + kx2 = kx1+1 +c test whether there are interior knots in the x-direction. + if(nk1x.eq.kx1) go to 440 +c evaluate the discotinuity jumps of the kx-th order derivative of +c the b-splines at the knots tx(l),l=kx+2,...,nx-kx-1. + call fpdisc(tx,nx,kx2,bx,nmax) + 440 ky2 = ky1 + 1 +c test whether there are interior knots in the y-direction. + if(nk1y.eq.ky1) go to 450 +c evaluate the discontinuity jumps of the ky-th order derivative of +c the b-splines at the knots ty(l),l=ky+2,...,ny-ky-1. + call fpdisc(ty,ny,ky2,by,nmax) +c initial value for p. + 450 p1 = 0. + f1 = fp0-s + p3 = -one + f3 = fpms + p = 0. + do 460 i=1,ncof + p = p+a(i,1) + 460 continue + rn = ncof + p = rn/p +c find the bandwidth of the extended observation matrix. + iband3 = kx1*nk1y + iband4 = iband3 +1 + ich1 = 0 + ich3 = 0 +c iteration process to find the root of f(p)=s. + do 770 iter=1,maxit + pinv = one/p +c store the triangularized observation matrix into q. + do 480 i=1,ncof + ff(i) = f(i) + do 470 j=1,iband + q(i,j) = a(i,j) + 470 continue + ibb = iband+1 + do 480 j=ibb,iband4 + q(i,j) = 0. + 480 continue + if(nk1y.eq.ky1) go to 560 +c extend the observation matrix with the rows of a matrix, expressing +c that for x=cst. sp(x,y) must be a polynomial in y of degree ky. + do 550 i=ky2,nk1y + ii = i-ky1 + do 550 j=1,nk1x +c initialize the new row. + do 490 l=1,iband + h(l) = 0. + 490 continue +c fill in the non-zero elements of the row. jrot records the column +c number of the first non-zero element in the row. + do 500 l=1,ky2 + h(l) = by(ii,l)*pinv + 500 continue + zi = 0. + jrot = (j-1)*nk1y+ii +c rotate the new row into triangle by givens transformations without +c square roots. + do 540 irot=jrot,ncof + piv = h(1) + i2 = min0(iband1,ncof-irot) + if(piv.eq.0.) then + if (i2.le.0) go to 550 + go to 520 + endif +c calculate the parameters of the givens transformation. + call fpgivs(piv,q(irot,1),cos,sin) +c apply that givens transformation to the right hand side. + call fprota(cos,sin,zi,ff(irot)) + if(i2.eq.0) go to 550 +c apply that givens transformation to the left hand side. + do 510 l=1,i2 + l1 = l+1 + call fprota(cos,sin,h(l1),q(irot,l1)) + 510 continue + 520 do 530 l=1,i2 + h(l) = h(l+1) + 530 continue + h(i2+1) = 0. + 540 continue + 550 continue + 560 if(nk1x.eq.kx1) go to 640 +c extend the observation matrix with the rows of a matrix expressing +c that for y=cst. sp(x,y) must be a polynomial in x of degree kx. + do 630 i=kx2,nk1x + ii = i-kx1 + do 630 j=1,nk1y +c initialize the new row + do 570 l=1,iband4 + h(l) = 0. + 570 continue +c fill in the non-zero elements of the row. jrot records the column +c number of the first non-zero element in the row. + j1 = 1 + do 580 l=1,kx2 + h(j1) = bx(ii,l)*pinv + j1 = j1+nk1y + 580 continue + zi = 0. + jrot = (i-kx2)*nk1y+j +c rotate the new row into triangle by givens transformations . + do 620 irot=jrot,ncof + piv = h(1) + i2 = min0(iband3,ncof-irot) + if(piv.eq.0.) then + if (i2.le.0) go to 630 + go to 600 + endif +c calculate the parameters of the givens transformation. + call fpgivs(piv,q(irot,1),cos,sin) +c apply that givens transformation to the right hand side. + call fprota(cos,sin,zi,ff(irot)) + if(i2.eq.0) go to 630 +c apply that givens transformation to the left hand side. + do 590 l=1,i2 + l1 = l+1 + call fprota(cos,sin,h(l1),q(irot,l1)) + 590 continue + 600 do 610 l=1,i2 + h(l) = h(l+1) + 610 continue + h(i2+1) = 0. + 620 continue + 630 continue +c find dmax, the maximum value for the diagonal elements in the +c reduced triangle. + 640 dmax = 0. + do 650 i=1,ncof + if(q(i,1).le.dmax) go to 650 + dmax = q(i,1) + 650 continue +c check whether the matrix is rank deficient. + sigma = eps*dmax + do 660 i=1,ncof + if(q(i,1).le.sigma) go to 670 + 660 continue +c backward substitution in case of full rank. + call fpback(q,ff,ncof,iband4,c,nc) + rank = ncof + go to 675 +c in case of rank deficiency, find the minimum norm solution. + 670 lwest = ncof*iband4+ncof+iband4 + if(lwrk.lt.lwest) go to 780 + lf = 1 + lh = lf+ncof + la = lh+iband4 + call fprank(q,ff,ncof,iband4,nc,sigma,c,sq,rank,wrk(la), + * wrk(lf),wrk(lh)) + 675 do 680 i=1,ncof + q(i,1) = q(i,1)/dmax + 680 continue +c compute f(p). + fp = 0. + do 720 num = 1,nreg + num1 = num-1 + lx = num1/nyy + ly = num1-lx*nyy + jrot = lx*nk1y+ly + in = index(num) + 690 if(in.eq.0) go to 720 + store = 0. + i1 = jrot + do 710 i=1,kx1 + hxi = spx(in,i) + j1 = i1 + do 700 j=1,ky1 + j1 = j1+1 + store = store+hxi*spy(in,j)*c(j1) + 700 continue + i1 = i1+nk1y + 710 continue + fp = fp+(w(in)*(z(in)-store))**2 + in = nummer(in) + go to 690 + 720 continue +c test whether the approximation sp(x,y) is an acceptable solution. + fpms = fp-s + if(abs(fpms).le.acc) go to 820 +c test whether the maximum allowable number of iterations has been +c reached. + if(iter.eq.maxit) go to 795 +c carry out one more step of the iteration process. + p2 = p + f2 = fpms + if(ich3.ne.0) go to 740 + if((f2-f3).gt.acc) go to 730 +c our initial choice of p is too large. + p3 = p2 + f3 = f2 + p = p*con4 + if(p.le.p1) p = p1*con9 + p2*con1 + go to 770 + 730 if(f2.lt.0.) ich3 = 1 + 740 if(ich1.ne.0) go to 760 + if((f1-f2).gt.acc) go to 750 +c our initial choice of p is too small + p1 = p2 + f1 = f2 + p = p/con4 + if(p3.lt.0.) go to 770 + if(p.ge.p3) p = p2*con1 + p3*con9 + go to 770 + 750 if(f2.gt.0.) ich1 = 1 +c test whether the iteration process proceeds as theoretically +c expected. + 760 if(f2.ge.f1 .or. f2.le.f3) go to 800 +c find the new value of p. + p = fprati(p1,f1,p2,f2,p3,f3) + 770 continue +c error codes and messages. + 780 ier = lwest + go to 830 + 785 ier = 5 + go to 830 + 790 ier = 4 + go to 830 + 795 ier = 3 + go to 830 + 800 ier = 2 + go to 830 + 810 ier = 1 + go to 830 + 815 ier = -1 + fp = 0. + 820 if(ncof.ne.rank) ier = -rank +c test whether x and y are in the original order. + 830 if(ichang.lt.0) go to 930 +c if not, interchange x and y once more. + l1 = 1 + do 840 i=1,nk1x + l2 = i + do 840 j=1,nk1y + f(l2) = c(l1) + l1 = l1+1 + l2 = l2+nk1x + 840 continue + do 850 i=1,ncof + c(i) = f(i) + 850 continue + do 860 i=1,m + store = x(i) + x(i) = y(i) + y(i) = store + 860 continue + n = min0(nx,ny) + do 870 i=1,n + store = tx(i) + tx(i) = ty(i) + ty(i) = store + 870 continue + n1 = n+1 + if (nx.lt.ny) go to 880 + if (nx.eq.ny) go to 920 + go to 900 + 880 do 890 i=n1,ny + tx(i) = ty(i) + 890 continue + go to 920 + 900 do 910 i=n1,nx + ty(i) = tx(i) + 910 continue + 920 l = nx + nx = ny + ny = l + 930 if(iopt.lt.0) go to 940 + nx0 = nx + ny0 = ny + 940 return + end + Added: branches/Interpolate1D/fitpack/fpsysy.f =================================================================== --- branches/Interpolate1D/fitpack/fpsysy.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fpsysy.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,56 @@ + subroutine fpsysy(a,n,g) +c subroutine fpsysy solves a linear n x n symmetric system +c (a) * (b) = (g) +c on input, vector g contains the right hand side ; on output it will +c contain the solution (b). +c .. +c ..scalar arguments.. + integer n +c ..array arguments.. + real*8 a(6,6),g(6) +c ..local scalars.. + real*8 fac + integer i,i1,j,k +c .. + g(1) = g(1)/a(1,1) + if(n.eq.1) return +c decomposition of the symmetric matrix (a) = (l) * (d) *(l)' +c with (l) a unit lower triangular matrix and (d) a diagonal +c matrix + do 10 k=2,n + a(k,1) = a(k,1)/a(1,1) + 10 continue + do 40 i=2,n + i1 = i-1 + do 30 k=i,n + fac = a(k,i) + do 20 j=1,i1 + fac = fac-a(j,j)*a(k,j)*a(i,j) + 20 continue + a(k,i) = fac + if(k.gt.i) a(k,i) = fac/a(i,i) + 30 continue + 40 continue +c solve the system (l)*(d)*(l)'*(b) = (g). +c first step : solve (l)*(d)*(c) = (g). + do 60 i=2,n + i1 = i-1 + fac = g(i) + do 50 j=1,i1 + fac = fac-g(j)*a(j,j)*a(i,j) + 50 continue + g(i) = fac/a(i,i) + 60 continue +c second step : solve (l)'*(b) = (c) + i = n + do 80 j=2,n + i1 = i + i = i-1 + fac = g(i) + do 70 k=i1,n + fac = fac-g(k)*a(k,i) + 70 continue + g(i) = fac + 80 continue + return + end Added: branches/Interpolate1D/fitpack/fptrnp.f =================================================================== --- branches/Interpolate1D/fitpack/fptrnp.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fptrnp.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,106 @@ + subroutine fptrnp(m,mm,idim,n,nr,sp,p,b,z,a,q,right) +c subroutine fptrnp reduces the (m+n-7) x (n-4) matrix a to upper +c triangular form and applies the same givens transformations to +c the (m) x (mm) x (idim) matrix z to obtain the (n-4) x (mm) x +c (idim) matrix q +c .. +c ..scalar arguments.. + real*8 p + integer m,mm,idim,n +c ..array arguments.. + real*8 sp(m,4),b(n,5),z(m*mm*idim),a(n,5),q((n-4)*mm*idim), + * right(mm*idim) + integer nr(m) +c ..local scalars.. + real*8 cos,pinv,piv,sin,one + integer i,iband,irot,it,ii,i2,i3,j,jj,l,mid,nmd,m2,m3, + * nrold,n4,number,n1 +c ..local arrays.. + real*8 h(7) +c ..subroutine references.. +c fpgivs,fprota +c .. + one = 1 + if(p.gt.0.) pinv = one/p + n4 = n-4 + mid = mm*idim + m2 = m*mm + m3 = n4*mm +c reduce the matrix (a) to upper triangular form (r) using givens +c rotations. apply the same transformations to the rows of matrix z +c to obtain the mm x (n-4) matrix g. +c store matrix (r) into (a) and g into q. +c initialization. + nmd = n4*mid + do 50 i=1,nmd + q(i) = 0. + 50 continue + do 100 i=1,n4 + do 100 j=1,5 + a(i,j) = 0. + 100 continue + nrold = 0 +c iband denotes the bandwidth of the matrices (a) and (r). + iband = 4 + do 750 it=1,m + number = nr(it) + 150 if(nrold.eq.number) go to 300 + if(p.le.0.) go to 700 + iband = 5 +c fetch a new row of matrix (b). + n1 = nrold+1 + do 200 j=1,5 + h(j) = b(n1,j)*pinv + 200 continue +c find the appropriate column of q. + do 250 j=1,mid + right(j) = 0. + 250 continue + irot = nrold + go to 450 +c fetch a new row of matrix (sp). + 300 h(iband) = 0. + do 350 j=1,4 + h(j) = sp(it,j) + 350 continue +c find the appropriate column of q. + j = 0 + do 400 ii=1,idim + l = (ii-1)*m2+(it-1)*mm + do 400 jj=1,mm + j = j+1 + l = l+1 + right(j) = z(l) + 400 continue + irot = number +c rotate the new row of matrix (a) into triangle. + 450 do 600 i=1,iband + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 600 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(irot,1),cos,sin) +c apply that transformation to the rows of matrix q. + j = 0 + do 500 ii=1,idim + l = (ii-1)*m3+irot + do 500 jj=1,mm + j = j+1 + call fprota(cos,sin,right(j),q(l)) + l = l+n4 + 500 continue +c apply that transformation to the columns of (a). + if(i.eq.iband) go to 650 + i2 = 1 + i3 = i+1 + do 550 j=i3,iband + i2 = i2+1 + call fprota(cos,sin,h(j),a(irot,i2)) + 550 continue + 600 continue + 650 if(nrold.eq.number) go to 750 + 700 nrold = nrold+1 + go to 150 + 750 continue + return + end Added: branches/Interpolate1D/fitpack/fptrpe.f =================================================================== --- branches/Interpolate1D/fitpack/fptrpe.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/fptrpe.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,212 @@ + subroutine fptrpe(m,mm,idim,n,nr,sp,p,b,z,a,aa,q,right) +c subroutine fptrpe reduces the (m+n-7) x (n-7) cyclic bandmatrix a +c to upper triangular form and applies the same givens transformations +c to the (m) x (mm) x (idim) matrix z to obtain the (n-7) x (mm) x +c (idim) matrix q. +c .. +c ..scalar arguments.. + real*8 p + integer m,mm,idim,n +c ..array arguments.. + real*8 sp(m,4),b(n,5),z(m*mm*idim),a(n,5),aa(n,4),q((n-7)*mm*idim) + *, + * right(mm*idim) + integer nr(m) +c ..local scalars.. + real*8 co,pinv,piv,si,one + integer i,iband,irot,it,ii,i2,i3,j,jj,l,mid,nmd,m2,m3, + * nrold,n4,number,n1,n7,n11,m1 +c ..local arrays.. + real*8 h(5),h1(5),h2(4) +c ..subroutine references.. +c fpgivs,fprota +c .. + one = 1 + if(p.gt.0.) pinv = one/p + n4 = n-4 + n7 = n-7 + n11 = n-11 + mid = mm*idim + m2 = m*mm + m3 = n7*mm + m1 = m-1 +c we determine the matrix (a) and then we reduce her to +c upper triangular form (r) using givens rotations. +c we apply the same transformations to the rows of matrix +c z to obtain the (mm) x (n-7) matrix g. +c we store matrix (r) into a and aa, g into q. +c the n7 x n7 upper triangular matrix (r) has the form +c | a1 ' | +c (r) = | ' a2 | +c | 0 ' | +c with (a2) a n7 x 4 matrix and (a1) a n11 x n11 upper +c triangular matrix of bandwidth 5. +c initialization. + nmd = n7*mid + do 50 i=1,nmd + q(i) = 0. + 50 continue + do 100 i=1,n4 + a(i,5) = 0. + do 100 j=1,4 + a(i,j) = 0. + aa(i,j) = 0. + 100 continue + jper = 0 + nrold = 0 + do 760 it=1,m1 + number = nr(it) + 120 if(nrold.eq.number) go to 180 + if(p.le.0.) go to 740 +c fetch a new row of matrix (b). + n1 = nrold+1 + do 140 j=1,5 + h(j) = b(n1,j)*pinv + 140 continue +c find the appropiate row of q. + do 160 j=1,mid + right(j) = 0. + 160 continue + go to 240 +c fetch a new row of matrix (sp) + 180 h(5) = 0. + do 200 j=1,4 + h(j) = sp(it,j) + 200 continue +c find the appropiate row of q. + j = 0 + do 220 ii=1,idim + l = (ii-1)*m2+(it-1)*mm + do 220 jj=1,mm + j = j+1 + l = l+1 + right(j) = z(l) + 220 continue +c test whether there are non-zero values in the new row of (a) +c corresponding to the b-splines n(j,*),j=n7+1,...,n4. + 240 if(nrold.lt.n11) go to 640 + if(jper.ne.0) go to 320 +c initialize the matrix (aa). + jk = n11+1 + do 300 i=1,4 + ik = jk + do 260 j=1,5 + if(ik.le.0) go to 280 + aa(ik,i) = a(ik,j) + ik = ik-1 + 260 continue + 280 jk = jk+1 + 300 continue + jper = 1 +c if one of the non-zero elements of the new row corresponds to one of +c the b-splines n(j;*),j=n7+1,...,n4,we take account of the periodicity +c conditions for setting up this row of (a). + 320 do 340 i=1,4 + h1(i) = 0. + h2(i) = 0. + 340 continue + h1(5) = 0. + j = nrold-n11 + do 420 i=1,5 + j = j+1 + l0 = j + 360 l1 = l0-4 + if(l1.le.0) go to 400 + if(l1.le.n11) go to 380 + l0 = l1-n11 + go to 360 + 380 h1(l1) = h(i) + go to 420 + 400 h2(l0) = h2(l0) + h(i) + 420 continue +c rotate the new row of (a) into triangle. + if(n11.le.0) go to 560 +c rotations with the rows 1,2,...,n11 of (a). + do 540 irot=1,n11 + piv = h1(1) + i2 = min0(n11-irot,4) + if(piv.eq.0.) go to 500 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(irot,1),co,si) +c apply that transformation to the columns of matrix q. + j = 0 + do 440 ii=1,idim + l = (ii-1)*m3+irot + do 440 jj=1,mm + j = j+1 + call fprota(co,si,right(j),q(l)) + l = l+n7 + 440 continue +c apply that transformation to the rows of (a) with respect to aa. + do 460 i=1,4 + call fprota(co,si,h2(i),aa(irot,i)) + 460 continue +c apply that transformation to the rows of (a) with respect to a. + if(i2.eq.0) go to 560 + do 480 i=1,i2 + i1 = i+1 + call fprota(co,si,h1(i1),a(irot,i1)) + 480 continue + 500 do 520 i=1,i2 + h1(i) = h1(i+1) + 520 continue + h1(i2+1) = 0. + 540 continue +c rotations with the rows n11+1,...,n7 of a. + 560 do 620 irot=1,4 + ij = n11+irot + if(ij.le.0) go to 620 + piv = h2(irot) + if(piv.eq.0.) go to 620 +c calculate the parameters of the givens transformation. + call fpgivs(piv,aa(ij,irot),co,si) +c apply that transformation to the columns of matrix q. + j = 0 + do 580 ii=1,idim + l = (ii-1)*m3+ij + do 580 jj=1,mm + j = j+1 + call fprota(co,si,right(j),q(l)) + l = l+n7 + 580 continue + if(irot.eq.4) go to 620 +c apply that transformation to the rows of (a) with respect to aa. + j1 = irot+1 + do 600 i=j1,4 + call fprota(co,si,h2(i),aa(ij,i)) + 600 continue + 620 continue + go to 720 +c rotation into triangle of the new row of (a), in case the elements +c corresponding to the b-splines n(j;*),j=n7+1,...,n4 are all zero. + 640 irot =nrold + do 700 i=1,5 + irot = irot+1 + piv = h(i) + if(piv.eq.0.) go to 700 +c calculate the parameters of the givens transformation. + call fpgivs(piv,a(irot,1),co,si) +c apply that transformation to the columns of matrix g. + j = 0 + do 660 ii=1,idim + l = (ii-1)*m3+irot + do 660 jj=1,mm + j = j+1 + call fprota(co,si,right(j),q(l)) + l = l+n7 + 660 continue +c apply that transformation to the rows of (a). + if(i.eq.5) go to 700 + i2 = 1 + i3 = i+1 + do 680 j=i3,5 + i2 = i2+1 + call fprota(co,si,h(j),a(irot,i2)) + 680 continue + 700 continue + 720 if(nrold.eq.number) go to 760 + 740 nrold = nrold+1 + go to 120 + 760 continue + return + end Added: branches/Interpolate1D/fitpack/insert.f =================================================================== --- branches/Interpolate1D/fitpack/insert.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/insert.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,102 @@ + subroutine insert(iopt,t,n,c,k,x,tt,nn,cc,nest,ier) +c subroutine insert inserts a new knot x into a spline function s(x) +c of degree k and calculates the b-spline representation of s(x) with +c respect to the new set of knots. in addition, if iopt.ne.0, s(x) +c will be considered as a periodic spline with period per=t(n-k)-t(k+1) +c satisfying the boundary constraints +c t(i+n-2*k-1) = t(i)+per ,i=1,2,...,2*k+1 +c c(i+n-2*k-1) = c(i) ,i=1,2,...,k +c in that case, the knots and b-spline coefficients returned will also +c satisfy these boundary constraints, i.e. +c tt(i+nn-2*k-1) = tt(i)+per ,i=1,2,...,2*k+1 +c cc(i+nn-2*k-1) = cc(i) ,i=1,2,...,k +c +c calling sequence: +c call insert(iopt,t,n,c,k,x,tt,nn,cc,nest,ier) +c +c input parameters: +c iopt : integer flag, specifying whether (iopt.ne.0) or not (iopt=0) +c the given spline must be considered as being periodic. +c t : array,length nest, which contains the position of the knots. +c n : integer, giving the total number of knots of s(x). +c c : array,length nest, which contains the b-spline coefficients. +c k : integer, giving the degree of s(x). +c x : real, which gives the location of the knot to be inserted. +c nest : integer specifying the dimension of the arrays t,c,tt and cc +c nest > n. +c +c output parameters: +c tt : array,length nest, which contains the position of the knots +c after insertion. +c nn : integer, giving the total number of knots after insertion +c cc : array,length nest, which contains the b-spline coefficients +c of s(x) with respect to the new set of knots. +c ier : error flag +c ier = 0 : normal return +c ier =10 : invalid input data (see restrictions) +c +c restrictions: +c nest > n +c t(k+1) <= x <= t(n-k) +c in case of a periodic spline (iopt.ne.0) there must be +c either at least k interior knots t(j) satisfying t(k+1)=0 the number of knots of the splines sj(u) and the position +c t(j),j=1,2,...,n is chosen automatically by the routine. the smooth- +c ness of s(u) is then achieved by minimalizing the discontinuity +c jumps of the k-th derivative of s(u) at the knots t(j),j=k+2,k+3,..., +c n-k-1. the amount of smoothness is determined by the condition that +c f(p)=sum((w(i)*dist(x(i),s(u(i))))**2) be <= s, with s a given non- +c negative constant, called the smoothing factor. +c the fit s(u) is given in the b-spline representation and can be +c evaluated by means of subroutine curev. +c +c calling sequence: +c call parcur(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,c, +c * fp,wrk,lwrk,iwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares spline curve (iopt=-1) or a smoothing spline +c curve (iopt=0 or 1) must be determined.if iopt=0 the routine +c will start with an initial set of knots t(i)=ub,t(i+k+1)=ue, +c i=1,2,...,k+1. if iopt=1 the routine will continue with the +c knots found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c ipar : integer flag. on entry ipar must specify whether (ipar=1) +c the user will supply the parameter values u(i),ub and ue +c or whether (ipar=0) these values are to be calculated by +c parcur. unchanged on exit. +c idim : integer. on entry idim must specify the dimension of the +c curve. 0 < idim < 11. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m > k. unchanged on exit. +c u : real array of dimension at least (m). in case ipar=1,before +c entry, u(i) must be set to the i-th value of the parameter +c variable u for i=1,2,...,m. these values must then be +c supplied in strictly ascending order and will be unchanged +c on exit. in case ipar=0, on exit,array u will contain the +c values u(i) as determined by parcur. +c mx : integer. on entry mx must specify the actual dimension of +c the array x as declared in the calling (sub)program. mx must +c not be too small (see x). unchanged on exit. +c x : real array of dimension at least idim*m. +c before entry, x(idim*(i-1)+j) must contain the j-th coord- +c inate of the i-th data point for i=1,2,...,m and j=1,2,..., +c idim. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. unchanged on exit. +c see also further comments. +c ub,ue : real values. on entry (in case ipar=1) ub and ue must +c contain the lower and upper bound for the parameter u. +c ub <=u(1), ue>= u(m). if ipar = 0 these values will +c automatically be set to 0 and 1 by parcur. +c k : integer. on entry k must specify the degree of the splines. +c 1<=k<=5. it is recommended to use cubic splines (k=3). +c the user is strongly dissuaded from choosing k even,together +c with a small s-value. unchanged on exit. +c s : real.on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments. +c nest : integer. on entry nest must contain an over-estimate of the +c total number of knots of the splines returned, to indicate +c the storage space available to the routine. nest >=2*k+2. +c in most practical situation nest=m/2 will be sufficient. +c always large enough is nest=m+k+1, the number of knots +c needed for interpolation (s=0). unchanged on exit. +c n : integer. +c unless ier = 10 (in case iopt >=0), n will contain the +c total number of knots of the smoothing spline curve returned +c if the computation mode iopt=1 is used this value of n +c should be left unchanged between subsequent calls. +c in case iopt=-1, the value of n must be specified on entry. +c t : real array of dimension at least (nest). +c on succesful exit, this array will contain the knots of the +c spline curve,i.e. the position of the interior knots t(k+2), +c t(k+3),..,t(n-k-1) as well as the position of the additional +c t(1)=t(2)=...=t(k+1)=ub and t(n-k)=...=t(n)=ue needed for +c the b-spline representation. +c if the computation mode iopt=1 is used, the values of t(1), +c t(2),...,t(n) should be left unchanged between subsequent +c calls. if the computation mode iopt=-1 is used, the values +c t(k+2),...,t(n-k-1) must be supplied by the user, before +c entry. see also the restrictions (ier=10). +c nc : integer. on entry nc must specify the actual dimension of +c the array c as declared in the calling (sub)program. nc +c must not be too small (see c). unchanged on exit. +c c : real array of dimension at least (nest*idim). +c on succesful exit, this array will contain the coefficients +c in the b-spline representation of the spline curve s(u),i.e. +c the b-spline coefficients of the spline sj(u) will be given +c in c(n*(j-1)+i),i=1,2,...,n-k-1 for j=1,2,...,idim. +c fp : real. unless ier = 10, fp contains the weighted sum of +c squared residuals of the spline curve returned. +c wrk : real array of dimension at least m*(k+1)+nest*(6+idim+3*k). +c used as working space. if the computation mode iopt=1 is +c used, the values wrk(1),...,wrk(n) should be left unchanged +c between subsequent calls. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (nest). +c used as working space. if the computation mode iopt=1 is +c used,the values iwrk(1),...,iwrk(n) should be left unchanged +c between subsequent calls. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the curve returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the curve returned is an interpolating +c spline curve (fp=0). +c ier=-2 : normal return. the curve returned is the weighted least- +c squares polynomial curve of degree k.in this extreme case +c fp gives the upper bound fp0 for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameter nest. +c probably causes : nest too small. if nest is already +c large (say nest > m/2), it may also indicate that s is +c too small +c the approximation returned is the least-squares spline +c curve according to the knots t(1),t(2),...,t(n). (n=nest) +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline curve +c with fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing curve +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 1<=k<=5, m>k, nest>2*k+2, w(i)>0,i=1,2,...,m +c 0<=ipar<=1, 0=(k+1)*m+nest*(6+idim+3*k), +c nc>=nest*idim +c if ipar=0: sum j=1,idim (x(idim*i+j)-x(idim*(i-1)+j))**2>0 +c i=1,2,...,m-1. +c if ipar=1: ub<=u(1)=0: s>=0 +c if s=0 : nest >= m+k+1 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the curve will be too smooth and signal will be +c lost ; if s is too small the curve will pick up too much noise. in +c the extreme cases the program will return an interpolating curve if +c s=0 and the least-squares polynomial curve of degree k if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c x(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in x(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c polynomial curve and the upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximating curve shows more detail) to obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if parcur is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c curve underlying the data. but, if the computation mode iopt=1 is +c used, the knots returned may also depend on the s-values at previous +c calls (if these were smaller). therefore, if after a number of +c trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c parcur once more with the selected value for s but now with iopt=0. +c indeed, parcur may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c +c the form of the approximating curve can strongly be affected by +c the choice of the parameter values u(i). if there is no physical +c reason for choosing a particular parameter u, often good results +c will be obtained with the choice of parcur (in case ipar=0), i.e. +c v(1)=0, v(i)=v(i-1)+q(i), i=2,...,m, u(i)=v(i)/v(m), i=1,..,m +c where +c q(i)= sqrt(sum j=1,idim (xj(i)-xj(i-1))**2 ) +c other possibilities for q(i) are +c q(i)= sum j=1,idim (xj(i)-xj(i-1))**2 +c q(i)= sum j=1,idim abs(xj(i)-xj(i-1)) +c q(i)= max j=1,idim abs(xj(i)-xj(i-1)) +c q(i)= 1 +c +c other subroutines required: +c fpback,fpbspl,fpchec,fppara,fpdisc,fpgivs,fpknot,fprati,fprota +c +c references: +c dierckx p. : algorithms for smoothing data with periodic and +c parametric splines, computer graphics and image +c processing 20 (1982) 171-184. +c dierckx p. : algorithms for smoothing data with periodic and param- +c etric splines, report tw55, dept. computer science, +c k.u.leuven, 1981. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + real*8 ub,ue,s,fp + integer iopt,ipar,idim,m,mx,k,nest,n,nc,lwrk,ier +c ..array arguments.. + real*8 u(m),x(mx),w(m),t(nest),c(nc),wrk(lwrk) + integer iwrk(nest) +c ..local scalars.. + real*8 tol,dist + integer i,ia,ib,ifp,ig,iq,iz,i1,i2,j,k1,k2,lwest,maxit,nmin,ncc +c ..function references + real*8 sqrt +c .. +c we set up the parameters tol and maxit + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 90 + if(ipar.lt.0 .or. ipar.gt.1) go to 90 + if(idim.le.0 .or. idim.gt.10) go to 90 + if(k.le.0 .or. k.gt.5) go to 90 + k1 = k+1 + k2 = k1+1 + nmin = 2*k1 + if(m.lt.k1 .or. nest.lt.nmin) go to 90 + ncc = nest*idim + if(mx.lt.m*idim .or. nc.lt.ncc) go to 90 + lwest = m*k1+nest*(6+idim+3*k) + if(lwrk.lt.lwest) go to 90 + if(ipar.ne.0 .or. iopt.gt.0) go to 40 + i1 = 0 + i2 = idim + u(1) = 0. + do 20 i=2,m + dist = 0. + do 10 j=1,idim + i1 = i1+1 + i2 = i2+1 + dist = dist+(x(i2)-x(i1))**2 + 10 continue + u(i) = u(i-1)+sqrt(dist) + 20 continue + if(u(m).le.0.) go to 90 + do 30 i=2,m + u(i) = u(i)/u(m) + 30 continue + ub = 0. + ue = 1. + u(m) = ue + 40 if(ub.gt.u(1) .or. ue.lt.u(m) .or. w(1).le.0.) go to 90 + do 50 i=2,m + if(u(i-1).ge.u(i) .or. w(i).le.0.) go to 90 + 50 continue + if(iopt.ge.0) go to 70 + if(n.lt.nmin .or. n.gt.nest) go to 90 + j = n + do 60 i=1,k1 + t(i) = ub + t(j) = ue + j = j-1 + 60 continue + call fpchec(u,m,t,n,k,ier) + if (ier.eq.0) go to 80 + go to 90 + 70 if(s.lt.0.) go to 90 + if(s.eq.0. .and. nest.lt.(m+k1)) go to 90 + ier = 0 +c we partition the working space and determine the spline curve. + 80 ifp = 1 + iz = ifp+nest + ia = iz+ncc + ib = ia+nest*k1 + ig = ib+nest*k2 + iq = ig+nest*k2 + call fppara(iopt,idim,m,u,mx,x,w,ub,ue,k,s,nest,tol,maxit,k1,k2, + * n,t,ncc,c,fp,wrk(ifp),wrk(iz),wrk(ia),wrk(ib),wrk(ig),wrk(iq), + * iwrk,ier) + 90 return + end Added: branches/Interpolate1D/fitpack/parder.f =================================================================== --- branches/Interpolate1D/fitpack/parder.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/parder.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,179 @@ + subroutine parder(tx,nx,ty,ny,c,kx,ky,nux,nuy,x,mx,y,my,z, + * wrk,lwrk,iwrk,kwrk,ier) +c subroutine parder evaluates on a grid (x(i),y(j)),i=1,...,mx; j=1,... +c ,my the partial derivative ( order nux,nuy) of a bivariate spline +c s(x,y) of degrees kx and ky, given in the b-spline representation. +c +c calling sequence: +c call parder(tx,nx,ty,ny,c,kx,ky,nux,nuy,x,mx,y,my,z,wrk,lwrk, +c * iwrk,kwrk,ier) +c +c input parameters: +c tx : real array, length nx, which contains the position of the +c knots in the x-direction. +c nx : integer, giving the total number of knots in the x-direction +c ty : real array, length ny, which contains the position of the +c knots in the y-direction. +c ny : integer, giving the total number of knots in the y-direction +c c : real array, length (nx-kx-1)*(ny-ky-1), which contains the +c b-spline coefficients. +c kx,ky : integer values, giving the degrees of the spline. +c nux : integer values, specifying the order of the partial +c nuy derivative. 0<=nux=1. +c y : real array of dimension (my). +c before entry y(j) must be set to the y co-ordinate of the +c j-th grid point along the y-axis. +c ty(ky+1)<=y(j-1)<=y(j)<=ty(ny-ky), j=2,...,my. +c my : on entry my must specify the number of grid points along +c the y-axis. my >=1. +c wrk : real array of dimension lwrk. used as workspace. +c lwrk : integer, specifying the dimension of wrk. +c lwrk >= mx*(kx+1-nux)+my*(ky+1-nuy)+(nx-kx-1)*(ny-ky-1) +c iwrk : integer array of dimension kwrk. used as workspace. +c kwrk : integer, specifying the dimension of iwrk. kwrk >= mx+my. +c +c output parameters: +c z : real array of dimension (mx*my). +c on succesful exit z(my*(i-1)+j) contains the value of the +c specified partial derivative of s(x,y) at the point +c (x(i),y(j)),i=1,...,mx;j=1,...,my. +c ier : integer error flag +c ier=0 : normal return +c ier=10: invalid input data (see restrictions) +c +c restrictions: +c mx >=1, my >=1, 0 <= nux < kx, 0 <= nuy < ky, kwrk>=mx+my +c lwrk>=mx*(kx+1-nux)+my*(ky+1-nuy)+(nx-kx-1)*(ny-ky-1), +c tx(kx+1) <= x(i-1) <= x(i) <= tx(nx-kx), i=2,...,mx +c ty(ky+1) <= y(j-1) <= y(j) <= ty(ny-ky), j=2,...,my +c +c other subroutines required: +c fpbisp,fpbspl +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1989 +c +c ..scalar arguments.. + integer nx,ny,kx,ky,nux,nuy,mx,my,lwrk,kwrk,ier +c ..array arguments.. + integer iwrk(kwrk) + real*8 tx(nx),ty(ny),c((nx-kx-1)*(ny-ky-1)),x(mx),y(my),z(mx*my), + * wrk(lwrk) +c ..local scalars.. + integer i,iwx,iwy,j,kkx,kky,kx1,ky1,lx,ly,lwest,l1,l2,m,m0,m1, + * nc,nkx1,nky1,nxx,nyy + real*8 ak,fac +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + kx1 = kx+1 + ky1 = ky+1 + nkx1 = nx-kx1 + nky1 = ny-ky1 + nc = nkx1*nky1 + if(nux.lt.0 .or. nux.ge.kx) go to 400 + if(nuy.lt.0 .or. nuy.ge.ky) go to 400 + lwest = nc +(kx1-nux)*mx+(ky1-nuy)*my + if(lwrk.lt.lwest) go to 400 + if(kwrk.lt.(mx+my)) go to 400 + if (mx.lt.1) go to 400 + if (mx.eq.1) go to 30 + go to 10 + 10 do 20 i=2,mx + if(x(i).lt.x(i-1)) go to 400 + 20 continue + 30 if (my.lt.1) go to 400 + if (my.eq.1) go to 60 + go to 40 + 40 do 50 i=2,my + if(y(i).lt.y(i-1)) go to 400 + 50 continue + 60 ier = 0 + nxx = nkx1 + nyy = nky1 + kkx = kx + kky = ky +c the partial derivative of order (nux,nuy) of a bivariate spline of +c degrees kx,ky is a bivariate spline of degrees kx-nux,ky-nuy. +c we calculate the b-spline coefficients of this spline + do 70 i=1,nc + wrk(i) = c(i) + 70 continue + if(nux.eq.0) go to 200 + lx = 1 + do 100 j=1,nux + ak = kkx + nxx = nxx-1 + l1 = lx + m0 = 1 + do 90 i=1,nxx + l1 = l1+1 + l2 = l1+kkx + fac = tx(l2)-tx(l1) + if(fac.le.0.) go to 90 + do 80 m=1,nyy + m1 = m0+nyy + wrk(m0) = (wrk(m1)-wrk(m0))*ak/fac + m0 = m0+1 + 80 continue + 90 continue + lx = lx+1 + kkx = kkx-1 + 100 continue + 200 if(nuy.eq.0) go to 300 + ly = 1 + do 230 j=1,nuy + ak = kky + nyy = nyy-1 + l1 = ly + do 220 i=1,nyy + l1 = l1+1 + l2 = l1+kky + fac = ty(l2)-ty(l1) + if(fac.le.0.) go to 220 + m0 = i + do 210 m=1,nxx + m1 = m0+1 + wrk(m0) = (wrk(m1)-wrk(m0))*ak/fac + m0 = m0+nky1 + 210 continue + 220 continue + ly = ly+1 + kky = kky-1 + 230 continue + m0 = nyy + m1 = nky1 + do 250 m=2,nxx + do 240 i=1,nyy + m0 = m0+1 + m1 = m1+1 + wrk(m0) = wrk(m1) + 240 continue + m1 = m1+nuy + 250 continue +c we partition the working space and evaluate the partial derivative + 300 iwx = 1+nxx*nyy + iwy = iwx+mx*(kx1-nux) + call fpbisp(tx(nux+1),nx-2*nux,ty(nuy+1),ny-2*nuy,wrk,kkx,kky, + * x,mx,y,my,z,wrk(iwx),wrk(iwy),iwrk(1),iwrk(mx+1)) + 400 return + end + Added: branches/Interpolate1D/fitpack/parsur.f =================================================================== --- branches/Interpolate1D/fitpack/parsur.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/parsur.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,391 @@ + subroutine parsur(iopt,ipar,idim,mu,u,mv,v,f,s,nuest,nvest, + * nu,tu,nv,tv,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c given the set of ordered points f(i,j) in the idim-dimensional space, +c corresponding to grid values (u(i),v(j)) ,i=1,...,mu ; j=1,...,mv, +c parsur determines a smooth approximating spline surface s(u,v) , i.e. +c f1 = s1(u,v) +c ... u(1) <= u <= u(mu) ; v(1) <= v <= v(mv) +c fidim = sidim(u,v) +c with sl(u,v), l=1,2,...,idim bicubic spline functions with common +c knots tu(i),i=1,...,nu in the u-variable and tv(j),j=1,...,nv in the +c v-variable. +c in addition, these splines will be periodic in the variable u if +c ipar(1) = 1 and periodic in the variable v if ipar(2) = 1. +c if iopt=-1, parsur determines the least-squares bicubic spline +c surface according to a given set of knots. +c if iopt>=0, the number of knots of s(u,v) and their position +c is chosen automatically by the routine. the smoothness of s(u,v) is +c achieved by minimalizing the discontinuity jumps of the derivatives +c of the splines at the knots. the amount of smoothness of s(u,v) is +c determined by the condition that +c fp=sumi=1,mu(sumj=1,mv(dist(f(i,j)-s(u(i),v(j)))**2))<=s, +c with s a given non-negative constant. +c the fit s(u,v) is given in its b-spline representation and can be +c evaluated by means of routine surev. +c +c calling sequence: +c call parsur(iopt,ipar,idim,mu,u,mv,v,f,s,nuest,nvest,nu,tu, +c * nv,tv,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer flag. unchanged on exit. +c on entry iopt must specify whether a least-squares surface +c (iopt=-1) or a smoothing surface (iopt=0 or 1)must be +c determined. +c if iopt=0 the routine will start with the initial set of +c knots needed for determining the least-squares polynomial +c surface. +c if iopt=1 the routine will continue with the set of knots +c found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt = 1 or iopt = 0. +c ipar : integer array of dimension 2. unchanged on exit. +c on entry ipar(1) must specify whether (ipar(1)=1) or not +c (ipar(1)=0) the splines must be periodic in the variable u. +c on entry ipar(2) must specify whether (ipar(2)=1) or not +c (ipar(2)=0) the splines must be periodic in the variable v. +c idim : integer. on entry idim must specify the dimension of the +c surface. 1 <= idim <= 3. unchanged on exit. +c mu : integer. on entry mu must specify the number of grid points +c along the u-axis. unchanged on exit. +c mu >= mumin where mumin=4-2*ipar(1) +c u : real array of dimension at least (mu). before entry, u(i) +c must be set to the u-co-ordinate of the i-th grid point +c along the u-axis, for i=1,2,...,mu. these values must be +c supplied in strictly ascending order. unchanged on exit. +c mv : integer. on entry mv must specify the number of grid points +c along the v-axis. unchanged on exit. +c mv >= mvmin where mvmin=4-2*ipar(2) +c v : real array of dimension at least (mv). before entry, v(j) +c must be set to the v-co-ordinate of the j-th grid point +c along the v-axis, for j=1,2,...,mv. these values must be +c supplied in strictly ascending order. unchanged on exit. +c f : real array of dimension at least (mu*mv*idim). +c before entry, f(mu*mv*(l-1)+mv*(i-1)+j) must be set to the +c l-th co-ordinate of the data point corresponding to the +c the grid point (u(i),v(j)) for l=1,...,idim ,i=1,...,mu +c and j=1,...,mv. unchanged on exit. +c if ipar(1)=1 it is expected that f(mu*mv*(l-1)+mv*(mu-1)+j) +c = f(mu*mv*(l-1)+j), l=1,...,idim ; j=1,...,mv +c if ipar(2)=1 it is expected that f(mu*mv*(l-1)+mv*(i-1)+mv) +c = f(mu*mv*(l-1)+mv*(i-1)+1), l=1,...,idim ; i=1,...,mu +c s : real. on entry (if iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c nuest : integer. unchanged on exit. +c nvest : integer. unchanged on exit. +c on entry, nuest and nvest must specify an upper bound for the +c number of knots required in the u- and v-directions respect. +c these numbers will also determine the storage space needed by +c the routine. nuest >= 8, nvest >= 8. +c in most practical situation nuest = mu/2, nvest=mv/2, will +c be sufficient. always large enough are nuest=mu+4+2*ipar(1), +c nvest = mv+4+2*ipar(2), the number of knots needed for +c interpolation (s=0). see also further comments. +c nu : integer. +c unless ier=10 (in case iopt>=0), nu will contain the total +c number of knots with respect to the u-variable, of the spline +c surface returned. if the computation mode iopt=1 is used, +c the value of nu should be left unchanged between subsequent +c calls. in case iopt=-1, the value of nu should be specified +c on entry. +c tu : real array of dimension at least (nuest). +c on succesful exit, this array will contain the knots of the +c splines with respect to the u-variable, i.e. the position of +c the interior knots tu(5),...,tu(nu-4) as well as the position +c of the additional knots tu(1),...,tu(4) and tu(nu-3),..., +c tu(nu) needed for the b-spline representation. +c if the computation mode iopt=1 is used,the values of tu(1) +c ...,tu(nu) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values tu(5), +c ...tu(nu-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c nv : integer. +c unless ier=10 (in case iopt>=0), nv will contain the total +c number of knots with respect to the v-variable, of the spline +c surface returned. if the computation mode iopt=1 is used, +c the value of nv should be left unchanged between subsequent +c calls. in case iopt=-1, the value of nv should be specified +c on entry. +c tv : real array of dimension at least (nvest). +c on succesful exit, this array will contain the knots of the +c splines with respect to the v-variable, i.e. the position of +c the interior knots tv(5),...,tv(nv-4) as well as the position +c of the additional knots tv(1),...,tv(4) and tv(nv-3),..., +c tv(nv) needed for the b-spline representation. +c if the computation mode iopt=1 is used,the values of tv(1) +c ...,tv(nv) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values tv(5), +c ...tv(nv-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c c : real array of dimension at least (nuest-4)*(nvest-4)*idim. +c on succesful exit, c contains the coefficients of the spline +c approximation s(u,v) +c fp : real. unless ier=10, fp contains the sum of squared +c residuals of the spline surface returned. +c wrk : real array of dimension (lwrk). used as workspace. +c if the computation mode iopt=1 is used the values of +c wrk(1),...,wrk(4) should be left unchanged between subsequent +c calls. +c lwrk : integer. on entry lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. +c lwrk must not be too small. +c lwrk >= 4+nuest*(mv*idim+11+4*ipar(1))+nvest*(11+4*ipar(2))+ +c 4*(mu+mv)+q*idim where q is the larger of mv and nuest. +c iwrk : integer array of dimension (kwrk). used as workspace. +c if the computation mode iopt=1 is used the values of +c iwrk(1),.,iwrk(3) should be left unchanged between subsequent +c calls. +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= 3+mu+mv+nuest+nvest. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the surface returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline surface returned is an +c interpolating surface (fp=0). +c ier=-2 : normal return. the surface returned is the least-squares +c polynomial surface. in this extreme case fp gives the +c upper bound for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters nuest and +c nvest. +c probably causes : nuest or nvest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the least-squares surface +c according to the current set of knots. the parameter fp +c gives the corresponding sum of squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing surface with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing surface +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 0<=ipar(1)<=1, 0<=ipar(2)<=1, 1 <=idim<=3 +c mu >= 4-2*ipar(1),mv >= 4-2*ipar(2), nuest >=8, nvest >= 8, +c kwrk>=3+mu+mv+nuest+nvest, +c lwrk >= 4+nuest*(mv*idim+11+4*ipar(1))+nvest*(11+4*ipar(2)) +c +4*(mu+mv)+max(nuest,mv)*idim +c u(i-1)=0: s>=0 +c if s=0: nuest>=mu+4+2*ipar(1) +c nvest>=mv+4+2*ipar(2) +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the surface will be too smooth and signal will be +c lost ; if s is too small the surface will pick up too much noise. in +c the extreme cases the program will return an interpolating surface +c if s=0 and the constrained least-squares polynomial surface if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the accuracy of the data values. +c if the user has an idea of the statistical errors on the data, he +c can also find a proper estimate for s. for, by assuming that, if he +c specifies the right s, parsur will return a surface s(u,v) which +c exactly reproduces the surface underlying the data he can evaluate +c the sum(dist(f(i,j)-s(u(i),v(j)))**2) to find a good estimate for s. +c for example, if he knows that the statistical errors on his f(i,j)- +c values is not greater than 0.1, he may expect that a good s should +c have a value not larger than mu*mv*(0.1)**2. +c if nothing is known about the statistical error in f(i,j), s must +c be determined by trial and error, taking account of the comments +c above. the best is then to start with a very large value of s (to +c determine the le-sq polynomial surface and the corresponding upper +c bound fp0 for s) and then to progressively decrease the value of s +c ( say by a factor 10 in the beginning, i.e. s=fp0/10,fp0/100,... +c and more carefully as the approximation shows more detail) to +c obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt = 1 the program will continue with the knots found at +c the last call of the routine. this will save a lot of computation +c time if parsur is called repeatedly for different values of s. +c the number of knots of the surface returned and their location will +c depend on the value of s and on the complexity of the shape of the +c surface underlying the data. if the computation mode iopt = 1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt=1,the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c parsur once more with the chosen value for s but now with iopt=0. +c indeed, parsur may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds nuest and +c nvest. indeed, if at a certain stage in parsur the number of knots +c in one direction (say nu) has reached the value of its upper bound +c (nuest), then from that moment on all subsequent knots are added +c in the other (v) direction. this may indicate that the value of +c nuest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c for example, by setting nuest=8 (the lowest allowable value for +c nuest), the user can indicate that he wants an approximation with +c splines which are simple cubic polynomials in the variable u. +c +c other subroutines required: +c fppasu,fpchec,fpchep,fpknot,fprati,fpgrpa,fptrnp,fpback, +c fpbacp,fpbspl,fptrpe,fpdisc,fpgivs,fprota +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1989 +c +c .. +c ..scalar arguments.. + real*8 s,fp + integer iopt,idim,mu,mv,nuest,nvest,nu,nv,lwrk,kwrk,ier +c ..array arguments.. + real*8 u(mu),v(mv),f(mu*mv*idim),tu(nuest),tv(nvest), + * c((nuest-4)*(nvest-4)*idim),wrk(lwrk) + integer ipar(2),iwrk(kwrk) +c ..local scalars.. + real*8 tol,ub,ue,vb,ve,peru,perv + integer i,j,jwrk,kndu,kndv,knru,knrv,kwest,l1,l2,l3,l4, + * lfpu,lfpv,lwest,lww,maxit,nc,mf,mumin,mvmin +c ..function references.. + integer max0 +c ..subroutine references.. +c fppasu,fpchec,fpchep +c .. +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 200 + if(ipar(1).lt.0 .or. ipar(1).gt.1) go to 200 + if(ipar(2).lt.0 .or. ipar(2).gt.1) go to 200 + if(idim.le.0 .or. idim.gt.3) go to 200 + mumin = 4-2*ipar(1) + if(mu.lt.mumin .or. nuest.lt.8) go to 200 + mvmin = 4-2*ipar(2) + if(mv.lt.mvmin .or. nvest.lt.8) go to 200 + mf = mu*mv + nc = (nuest-4)*(nvest-4) + lwest = 4+nuest*(mv*idim+11+4*ipar(1))+nvest*(11+4*ipar(2))+ + * 4*(mu+mv)+max0(nuest,mv)*idim + kwest = 3+mu+mv+nuest+nvest + if(lwrk.lt.lwest .or. kwrk.lt.kwest) go to 200 + do 10 i=2,mu + if(u(i-1).ge.u(i)) go to 200 + 10 continue + do 20 i=2,mv + if(v(i-1).ge.v(i)) go to 200 + 20 continue + if(iopt.ge.0) go to 100 + if(nu.lt.8 .or. nu.gt.nuest) go to 200 + ub = u(1) + ue = u(mu) + if (ipar(1).ne.0) go to 40 + j = nu + do 30 i=1,4 + tu(i) = ub + tu(j) = ue + j = j-1 + 30 continue + call fpchec(u,mu,tu,nu,3,ier) + if(ier.ne.0) go to 200 + go to 60 + 40 l1 = 4 + l2 = l1 + l3 = nu-3 + l4 = l3 + peru = ue-ub + tu(l2) = ub + tu(l3) = ue + do 50 j=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tu(l2) = tu(l4)-peru + tu(l3) = tu(l1)+peru + 50 continue + call fpchep(u,mu,tu,nu,3,ier) + if(ier.ne.0) go to 200 + 60 if(nv.lt.8 .or. nv.gt.nvest) go to 200 + vb = v(1) + ve = v(mv) + if (ipar(2).ne.0) go to 80 + j = nv + do 70 i=1,4 + tv(i) = vb + tv(j) = ve + j = j-1 + 70 continue + call fpchec(v,mv,tv,nv,3,ier) + if(ier.ne.0) go to 200 + go to 150 + 80 l1 = 4 + l2 = l1 + l3 = nv-3 + l4 = l3 + perv = ve-vb + tv(l2) = vb + tv(l3) = ve + do 90 j=1,3 + l1 = l1+1 + l2 = l2-1 + l3 = l3+1 + l4 = l4-1 + tv(l2) = tv(l4)-perv + tv(l3) = tv(l1)+perv + 90 continue + call fpchep(v,mv,tv,nv,3,ier) + if (ier.eq.0) go to 150 + go to 200 + 100 if(s.lt.0.) go to 200 + if(s.eq.0. .and. (nuest.lt.(mu+4+2*ipar(1)) .or. + * nvest.lt.(mv+4+2*ipar(2))) )go to 200 + ier = 0 +c we partition the working space and determine the spline approximation + 150 lfpu = 5 + lfpv = lfpu+nuest + lww = lfpv+nvest + jwrk = lwrk-4-nuest-nvest + knru = 4 + knrv = knru+mu + kndu = knrv+mv + kndv = kndu+nuest + call fppasu(iopt,ipar,idim,u,mu,v,mv,f,mf,s,nuest,nvest, + * tol,maxit,nc,nu,tu,nv,tv,c,fp,wrk(1),wrk(2),wrk(3),wrk(4), + * wrk(lfpu),wrk(lfpv),iwrk(1),iwrk(2),iwrk(3),iwrk(knru), + * iwrk(knrv),iwrk(kndu),iwrk(kndv),wrk(lww),jwrk,ier) + 200 return + end + Added: branches/Interpolate1D/fitpack/percur.f =================================================================== --- branches/Interpolate1D/fitpack/percur.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/percur.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,274 @@ + subroutine percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp, + * wrk,lwrk,iwrk,ier) +c given the set of data points (x(i),y(i)) and the set of positive +c numbers w(i),i=1,2,...,m-1, subroutine percur determines a smooth +c periodic spline approximation of degree k with period per=x(m)-x(1). +c if iopt=-1 percur calculates the weighted least-squares periodic +c spline according to a given set of knots. +c if iopt>=0 the number of knots of the spline s(x) and the position +c t(j),j=1,2,...,n is chosen automatically by the routine. the smooth- +c ness of s(x) is then achieved by minimalizing the discontinuity +c jumps of the k-th derivative of s(x) at the knots t(j),j=k+2,k+3,..., +c n-k-1. the amount of smoothness is determined by the condition that +c f(p)=sum((w(i)*(y(i)-s(x(i))))**2) be <= s, with s a given non- +c negative constant, called the smoothing factor. +c the fit s(x) is given in the b-spline representation (b-spline coef- +c ficients c(j),j=1,2,...,n-k-1) and can be evaluated by means of +c subroutine splev. +c +c calling sequence: +c call percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk, +c * lwrk,iwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares spline (iopt=-1) or a smoothing spline (iopt= +c 0 or 1) must be determined. if iopt=0 the routine will start +c with an initial set of knots t(i)=x(1)+(x(m)-x(1))*(i-k-1), +c i=1,2,...,2*k+2. if iopt=1 the routine will continue with +c the knots found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately +c preceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m > 1. unchanged on exit. +c x : real array of dimension at least (m). before entry, x(i) +c must be set to the i-th value of the independent variable x, +c for i=1,2,...,m. these values must be supplied in strictly +c ascending order. x(m) only indicates the length of the +c period of the spline, i.e per=x(m)-x(1). +c unchanged on exit. +c y : real array of dimension at least (m). before entry, y(i) +c must be set to the i-th value of the dependent variable y, +c for i=1,2,...,m-1. the element y(m) is not used. +c unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) +c must be set to the i-th value in the set of weights. the +c w(i) must be strictly positive. w(m) is not used. +c see also further comments. unchanged on exit. +c k : integer. on entry k must specify the degree of the spline. +c 1<=k<=5. it is recommended to use cubic splines (k=3). +c the user is strongly dissuaded from choosing k even,together +c with a small s-value. unchanged on exit. +c s : real.on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments. +c nest : integer. on entry nest must contain an over-estimate of the +c total number of knots of the spline returned, to indicate +c the storage space available to the routine. nest >=2*k+2. +c in most practical situation nest=m/2 will be sufficient. +c always large enough is nest=m+2*k,the number of knots needed +c for interpolation (s=0). unchanged on exit. +c n : integer. +c unless ier = 10 (in case iopt >=0), n will contain the +c total number of knots of the spline approximation returned. +c if the computation mode iopt=1 is used this value of n +c should be left unchanged between subsequent calls. +c in case iopt=-1, the value of n must be specified on entry. +c t : real array of dimension at least (nest). +c on succesful exit, this array will contain the knots of the +c spline,i.e. the position of the interior knots t(k+2),t(k+3) +c ...,t(n-k-1) as well as the position of the additional knots +c t(1),t(2),...,t(k+1)=x(1) and t(n-k)=x(m),..,t(n) needed for +c the b-spline representation. +c if the computation mode iopt=1 is used, the values of t(1), +c t(2),...,t(n) should be left unchanged between subsequent +c calls. if the computation mode iopt=-1 is used, the values +c t(k+2),...,t(n-k-1) must be supplied by the user, before +c entry. see also the restrictions (ier=10). +c c : real array of dimension at least (nest). +c on succesful exit, this array will contain the coefficients +c c(1),c(2),..,c(n-k-1) in the b-spline representation of s(x) +c fp : real. unless ier = 10, fp contains the weighted sum of +c squared residuals of the spline approximation returned. +c wrk : real array of dimension at least (m*(k+1)+nest*(8+5*k)). +c used as working space. if the computation mode iopt=1 is +c used, the values wrk(1),...,wrk(n) should be left unchanged +c between subsequent calls. +c lwrk : integer. on entry,lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. lwrk +c must not be too small (see wrk). unchanged on exit. +c iwrk : integer array of dimension at least (nest). +c used as working space. if the computation mode iopt=1 is +c used,the values iwrk(1),...,iwrk(n) should be left unchanged +c between subsequent calls. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c periodic spline (fp=0). +c ier=-2 : normal return. the spline returned is the weighted least- +c squares constant. in this extreme case fp gives the upper +c bound fp0 for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameter nest. +c probably causes : nest too small. if nest is already +c large (say nest > m/2), it may also indicate that s is +c too small +c the approximation returned is the least-squares periodic +c spline according to the knots t(1),t(2),...,t(n). (n=nest) +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 1<=k<=5, m>1, nest>2*k+2, w(i)>0,i=1,...,m-1 +c x(1)=(k+1)*m+nest*(8+5*k) +c if iopt=-1: 2*k+2<=n<=min(nest,m+2*k) +c x(1)=0: s>=0 +c if s=0 : nest >= m+2*k +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating periodic +c spline if s=0 and the weighted least-squares constant if s is very +c large. between these extremes, a properly chosen s will result in +c a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c y(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in y(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c constant and the corresponding upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximation shows more detail) to obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if percur is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. but, if the computation mode iopt=1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c percur once more with the selected value for s but now with iopt=0. +c indeed, percur may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c +c other subroutines required: +c fpbacp,fpbspl,fpchep,fpperi,fpdisc,fpgivs,fpknot,fprati,fprota +c +c references: +c dierckx p. : algorithms for smoothing data with periodic and +c parametric splines, computer graphics and image +c processing 20 (1982) 171-184. +c dierckx p. : algorithms for smoothing data with periodic and param- +c etric splines, report tw55, dept. computer science, +c k.u.leuven, 1981. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + real*8 s,fp + integer iopt,m,k,nest,n,lwrk,ier +c ..array arguments.. + real*8 x(m),y(m),w(m),t(nest),c(nest),wrk(lwrk) + integer iwrk(nest) +c ..local scalars.. + real*8 per,tol + integer i,ia1,ia2,ib,ifp,ig1,ig2,iq,iz,i1,i2,j1,j2,k1,k2,lwest, + * maxit,m1,nmin +c ..subroutine references.. +c perper,pcheck +c .. +c we set up the parameters tol and maxit + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(k.le.0 .or. k.gt.5) go to 50 + k1 = k+1 + k2 = k1+1 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 50 + nmin = 2*k1 + if(m.lt.2 .or. nest.lt.nmin) go to 50 + lwest = m*k1+nest*(8+5*k) + if(lwrk.lt.lwest) go to 50 + m1 = m-1 + do 10 i=1,m1 + if(x(i).ge.x(i+1) .or. w(i).le.0.) go to 50 + 10 continue + if(iopt.ge.0) go to 30 + if(n.le.nmin .or. n.gt.nest) go to 50 + per = x(m)-x(1) + j1 = k1 + t(j1) = x(1) + i1 = n-k + t(i1) = x(m) + j2 = j1 + i2 = i1 + do 20 i=1,k + i1 = i1+1 + i2 = i2-1 + j1 = j1+1 + j2 = j2-1 + t(j2) = t(i2)-per + t(i1) = t(j1)+per + 20 continue + call fpchep(x,m,t,n,k,ier) + if (ier.eq.0) go to 40 + go to 50 + 30 if(s.lt.0.) go to 50 + if(s.eq.0. .and. nest.lt.(m+2*k)) go to 50 + ier = 0 +c we partition the working space and determine the spline approximation. + 40 ifp = 1 + iz = ifp+nest + ia1 = iz+nest + ia2 = ia1+nest*k1 + ib = ia2+nest*k + ig1 = ib+nest*k2 + ig2 = ig1+nest*k2 + iq = ig2+nest*k1 + call fpperi(iopt,x,y,w,m,k,s,nest,tol,maxit,k1,k2,n,t,c,fp, + * wrk(ifp),wrk(iz),wrk(ia1),wrk(ia2),wrk(ib),wrk(ig1),wrk(ig2), + * wrk(iq),iwrk,ier) + 50 return + end Added: branches/Interpolate1D/fitpack/pogrid.f =================================================================== --- branches/Interpolate1D/fitpack/pogrid.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/pogrid.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,466 @@ + subroutine pogrid(iopt,ider,mu,u,mv,v,z,z0,r,s,nuest,nvest, + * nu,tu,nv,tv,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c subroutine pogrid fits a function f(x,y) to a set of data points +c z(i,j) given at the nodes (x,y)=(u(i)*cos(v(j)),u(i)*sin(v(j))), +c i=1,...,mu ; j=1,...,mv , of a radius-angle grid over a disc +c x ** 2 + y ** 2 <= r ** 2 . +c +c this approximation problem is reduced to the determination of a +c bicubic spline s(u,v) smoothing the data (u(i),v(j),z(i,j)) on the +c rectangle 0<=u<=r, v(1)<=v<=v(1)+2*pi +c in order to have continuous partial derivatives +c i+j +c d f(0,0) +c g(i,j) = ---------- +c i j +c dx dy +c +c s(u,v)=f(x,y) must satisfy the following conditions +c +c (1) s(0,v) = g(0,0) v(1)<=v<= v(1)+2*pi +c +c d s(0,v) +c (2) -------- = cos(v)*g(1,0)+sin(v)*g(0,1) v(1)<=v<= v(1)+2*pi +c d u +c +c moreover, s(u,v) must be periodic in the variable v, i.e. +c +c j j +c d s(u,vb) d s(u,ve) +c (3) ---------- = --------- 0 <=u<= r, j=0,1,2 , vb=v(1), +c j j ve=vb+2*pi +c d v d v +c +c the number of knots of s(u,v) and their position tu(i),i=1,2,...,nu; +c tv(j),j=1,2,...,nv, is chosen automatically by the routine. the +c smoothness of s(u,v) is achieved by minimalizing the discontinuity +c jumps of the derivatives of the spline at the knots. the amount of +c smoothness of s(u,v) is determined by the condition that +c fp=sumi=1,mu(sumj=1,mv((z(i,j)-s(u(i),v(j)))**2))+(z0-g(0,0))**2<=s, +c with s a given non-negative constant. +c the fit s(u,v) is given in its b-spline representation and can be +c evaluated by means of routine bispev. f(x,y) = s(u,v) can also be +c evaluated by means of function program evapol. +c +c calling sequence: +c call pogrid(iopt,ider,mu,u,mv,v,z,z0,r,s,nuest,nvest,nu,tu, +c * ,nv,tv,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer array of dimension 3, specifying different options. +c unchanged on exit. +c iopt(1):on entry iopt(1) must specify whether a least-squares spline +c (iopt(1)=-1) or a smoothing spline (iopt(1)=0 or 1) must be +c determined. +c if iopt(1)=0 the routine will start with an initial set of +c knots tu(i)=0,tu(i+4)=r,i=1,...,4;tv(i)=v(1)+(i-4)*2*pi,i=1,. +c ...,8. +c if iopt(1)=1 the routine will continue with the set of knots +c found at the last call of the routine. +c attention: a call with iopt(1)=1 must always be immediately +c preceded by another call with iopt(1) = 1 or iopt(1) = 0. +c iopt(2):on entry iopt(2) must specify the requested order of conti- +c nuity for f(x,y) at the origin. +c if iopt(2)=0 only condition (1) must be fulfilled and +c if iopt(2)=1 conditions (1)+(2) must be fulfilled. +c iopt(3):on entry iopt(3) must specify whether (iopt(3)=1) or not +c (iopt(3)=0) the approximation f(x,y) must vanish at the +c boundary of the approximation domain. +c ider : integer array of dimension 2, specifying different options. +c unchanged on exit. +c ider(1):on entry ider(1) must specify whether (ider(1)=0 or 1) or not +c (ider(1)=-1) there is a data value z0 at the origin. +c if ider(1)=1, z0 will be considered to be the right function +c value, and it will be fitted exactly (g(0,0)=z0=c(1)). +c if ider(1)=0, z0 will be considered to be a data value just +c like the other data values z(i,j). +c ider(2):on entry ider(2) must specify whether (ider(2)=1) or not +c (ider(2)=0) f(x,y) must have vanishing partial derivatives +c g(1,0) and g(0,1) at the origin. (in case iopt(2)=1) +c mu : integer. on entry mu must specify the number of grid points +c along the u-axis. unchanged on exit. +c mu >= mumin where mumin=4-iopt(3)-ider(2) if ider(1)<0 +c =3-iopt(3)-ider(2) if ider(1)>=0 +c u : real array of dimension at least (mu). before entry, u(i) +c must be set to the u-co-ordinate of the i-th grid point +c along the u-axis, for i=1,2,...,mu. these values must be +c positive and supplied in strictly ascending order. +c unchanged on exit. +c mv : integer. on entry mv must specify the number of grid points +c along the v-axis. mv > 3 . unchanged on exit. +c v : real array of dimension at least (mv). before entry, v(j) +c must be set to the v-co-ordinate of the j-th grid point +c along the v-axis, for j=1,2,...,mv. these values must be +c supplied in strictly ascending order. unchanged on exit. +c -pi <= v(1) < pi , v(mv) < v(1)+2*pi. +c z : real array of dimension at least (mu*mv). +c before entry, z(mv*(i-1)+j) must be set to the data value at +c the grid point (u(i),v(j)) for i=1,...,mu and j=1,...,mv. +c unchanged on exit. +c z0 : real value. on entry (if ider(1) >=0 ) z0 must specify the +c data value at the origin. unchanged on exit. +c r : real value. on entry r must specify the radius of the disk. +c r>=u(mu) (>u(mu) if iopt(3)=1). unchanged on exit. +c s : real. on entry (if iopt(1)>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c nuest : integer. unchanged on exit. +c nvest : integer. unchanged on exit. +c on entry, nuest and nvest must specify an upper bound for the +c number of knots required in the u- and v-directions respect. +c these numbers will also determine the storage space needed by +c the routine. nuest >= 8, nvest >= 8. +c in most practical situation nuest = mu/2, nvest=mv/2, will +c be sufficient. always large enough are nuest=mu+5+iopt(2)+ +c iopt(3), nvest = mv+7, the number of knots needed for +c interpolation (s=0). see also further comments. +c nu : integer. +c unless ier=10 (in case iopt(1)>=0), nu will contain the total +c number of knots with respect to the u-variable, of the spline +c approximation returned. if the computation mode iopt(1)=1 is +c used, the value of nu should be left unchanged between sub- +c sequent calls. in case iopt(1)=-1, the value of nu should be +c specified on entry. +c tu : real array of dimension at least (nuest). +c on succesful exit, this array will contain the knots of the +c spline with respect to the u-variable, i.e. the position of +c the interior knots tu(5),...,tu(nu-4) as well as the position +c of the additional knots tu(1)=...=tu(4)=0 and tu(nu-3)=...= +c tu(nu)=r needed for the b-spline representation. +c if the computation mode iopt(1)=1 is used,the values of tu(1) +c ...,tu(nu) should be left unchanged between subsequent calls. +c if the computation mode iopt(1)=-1 is used, the values tu(5), +c ...tu(nu-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c nv : integer. +c unless ier=10 (in case iopt(1)>=0), nv will contain the total +c number of knots with respect to the v-variable, of the spline +c approximation returned. if the computation mode iopt(1)=1 is +c used, the value of nv should be left unchanged between sub- +c sequent calls. in case iopt(1) = -1, the value of nv should +c be specified on entry. +c tv : real array of dimension at least (nvest). +c on succesful exit, this array will contain the knots of the +c spline with respect to the v-variable, i.e. the position of +c the interior knots tv(5),...,tv(nv-4) as well as the position +c of the additional knots tv(1),...,tv(4) and tv(nv-3),..., +c tv(nv) needed for the b-spline representation. +c if the computation mode iopt(1)=1 is used,the values of tv(1) +c ...,tv(nv) should be left unchanged between subsequent calls. +c if the computation mode iopt(1)=-1 is used, the values tv(5), +c ...tv(nv-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c c : real array of dimension at least (nuest-4)*(nvest-4). +c on succesful exit, c contains the coefficients of the spline +c approximation s(u,v) +c fp : real. unless ier=10, fp contains the sum of squared +c residuals of the spline approximation returned. +c wrk : real array of dimension (lwrk). used as workspace. +c if the computation mode iopt(1)=1 is used the values of +c wrk(1),...,wrk(8) should be left unchanged between subsequent +c calls. +c lwrk : integer. on entry lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. +c lwrk must not be too small. +c lwrk >= 8+nuest*(mv+nvest+3)+nvest*21+4*mu+6*mv+q +c where q is the larger of (mv+nvest) and nuest. +c iwrk : integer array of dimension (kwrk). used as workspace. +c if the computation mode iopt(1)=1 is used the values of +c iwrk(1),.,iwrk(4) should be left unchanged between subsequent +c calls. +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= 4+mu+mv+nuest+nvest. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c spline (fp=0). +c ier=-2 : normal return. the spline returned is the least-squares +c constrained polynomial. in this extreme case fp gives the +c upper bound for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters nuest and +c nvest. +c probably causes : nuest or nvest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the least-squares spline +c according to the current set of knots. the parameter fp +c gives the corresponding sum of squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt(1)<=1, 0<=iopt(2)<=1, 0<=iopt(3)<=1, +c -1<=ider(1)<=1, 0<=ider(2)<=1, ider(2)=0 if iopt(2)=0. +c mu >= mumin (see above), mv >= 4, nuest >=8, nvest >= 8, +c kwrk>=4+mu+mv+nuest+nvest, +c lwrk >= 8+nuest*(mv+nvest+3)+nvest*21+4*mu+6*mv+ +c max(nuest,mv+nvest) +c 0< u(i-1)=0: s>=0 +c if s=0: nuest>=mu+5+iopt(2)+iopt(3), nvest>=mv+7 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c pogrid does not allow individual weighting of the data-values. +c so, if these were determined to widely different accuracies, then +c perhaps the general data set routine polar should rather be used +c in spite of efficiency. +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the constrained least-squares polynomial(degrees 3,0)if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the accuracy of the data values. +c if the user has an idea of the statistical errors on the data, he +c can also find a proper estimate for s. for, by assuming that, if he +c specifies the right s, pogrid will return a spline s(u,v) which +c exactly reproduces the function underlying the data he can evaluate +c the sum((z(i,j)-s(u(i),v(j)))**2) to find a good estimate for this s +c for example, if he knows that the statistical errors on his z(i,j)- +c values is not greater than 0.1, he may expect that a good s should +c have a value not larger than mu*mv*(0.1)**2. +c if nothing is known about the statistical error in z(i,j), s must +c be determined by trial and error, taking account of the comments +c above. the best is then to start with a very large value of s (to +c determine the least-squares polynomial and the corresponding upper +c bound fp0 for s) and then to progressively decrease the value of s +c ( say by a factor 10 in the beginning, i.e. s=fp0/10,fp0/100,... +c and more carefully as the approximation shows more detail) to +c obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt(1)=0. +c if iopt(1) = 1 the program will continue with the knots found at +c the last call of the routine. this will save a lot of computation +c time if pogrid is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. if the computation mode iopt(1) = 1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt(1)=1,the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c pogrid once more with the chosen value for s but now with iopt(1)=0. +c indeed, pogrid may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds nuest and +c nvest. indeed, if at a certain stage in pogrid the number of knots +c in one direction (say nu) has reached the value of its upper bound +c (nuest), then from that moment on all subsequent knots are added +c in the other (v) direction. this may indicate that the value of +c nuest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c for example, by setting nuest=8 (the lowest allowable value for +c nuest), the user can indicate that he wants an approximation which +c is a simple cubic polynomial in the variable u. +c +c other subroutines required: +c fppogr,fpchec,fpchep,fpknot,fpopdi,fprati,fpgrdi,fpsysy,fpback, +c fpbacp,fpbspl,fpcyt1,fpcyt2,fpdisc,fpgivs,fprota +c +c references: +c dierckx p. : fast algorithms for smoothing data over a disc or a +c sphere using tensor product splines, in "algorithms +c for approximation", ed. j.c.mason and m.g.cox, +c clarendon press oxford, 1987, pp. 51-65 +c dierckx p. : fast algorithms for smoothing data over a disc or a +c sphere using tensor product splines, report tw73, dept. +c computer science,k.u.leuven, 1985. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : july 1985 +c latest update : march 1989 +c +c .. +c ..scalar arguments.. + real*8 z0,r,s,fp + integer mu,mv,nuest,nvest,nu,nv,lwrk,kwrk,ier +c ..array arguments.. + integer iopt(3),ider(2),iwrk(kwrk) + real*8 u(mu),v(mv),z(mu*mv),c((nuest-4)*(nvest-4)),tu(nuest), + * tv(nvest),wrk(lwrk) +c ..local scalars.. + real*8 per,pi,tol,uu,ve,zmax,zmin,one,half,rn,zb + integer i,i1,i2,j,jwrk,j1,j2,kndu,kndv,knru,knrv,kwest,l, + * ldz,lfpu,lfpv,lwest,lww,m,maxit,mumin,muu,nc +c ..function references.. + real*8 datan2 + integer max0 +c ..subroutine references.. +c fpchec,fpchep,fppogr +c .. +c set constants + one = 1d0 + half = 0.5e0 + pi = datan2(0d0,-one) + per = pi+pi + ve = v(1)+per +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations, a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt(1).lt.(-1) .or. iopt(1).gt.1) go to 200 + if(iopt(2).lt.0 .or. iopt(2).gt.1) go to 200 + if(iopt(3).lt.0 .or. iopt(3).gt.1) go to 200 + if(ider(1).lt.(-1) .or. ider(1).gt.1) go to 200 + if(ider(2).lt.0 .or. ider(2).gt.1) go to 200 + if(ider(2).eq.1 .and. iopt(2).eq.0) go to 200 + mumin = 4-iopt(3)-ider(2) + if(ider(1).ge.0) mumin = mumin-1 + if(mu.lt.mumin .or. mv.lt.4) go to 200 + if(nuest.lt.8 .or. nvest.lt.8) go to 200 + m = mu*mv + nc = (nuest-4)*(nvest-4) + lwest = 8+nuest*(mv+nvest+3)+21*nvest+4*mu+6*mv+ + * max0(nuest,mv+nvest) + kwest = 4+mu+mv+nuest+nvest + if(lwrk.lt.lwest .or. kwrk.lt.kwest) go to 200 + if(u(1).le.0. .or. u(mu).gt.r) go to 200 + if(iopt(3).eq.0) go to 10 + if(u(mu).eq.r) go to 200 + 10 if(mu.eq.1) go to 30 + do 20 i=2,mu + if(u(i-1).ge.u(i)) go to 200 + 20 continue + 30 if(v(1).lt. (-pi) .or. v(1).ge.pi ) go to 200 + if(v(mv).ge.v(1)+per) go to 200 + do 40 i=2,mv + if(v(i-1).ge.v(i)) go to 200 + 40 continue + if(iopt(1).gt.0) go to 140 +c if not given, we compute an estimate for z0. + if(ider(1).lt.0) go to 50 + zb = z0 + go to 70 + 50 zb = 0. + do 60 i=1,mv + zb = zb+z(i) + 60 continue + rn = mv + zb = zb/rn +c we determine the range of z-values. + 70 zmin = zb + zmax = zb + do 80 i=1,m + if(z(i).lt.zmin) zmin = z(i) + if(z(i).gt.zmax) zmax = z(i) + 80 continue + wrk(5) = zb + wrk(6) = 0. + wrk(7) = 0. + wrk(8) = zmax -zmin + iwrk(4) = mu + if(iopt(1).eq.0) go to 140 + if(nu.lt.8 .or. nu.gt.nuest) go to 200 + if(nv.lt.11 .or. nv.gt.nvest) go to 200 + j = nu + do 90 i=1,4 + tu(i) = 0. + tu(j) = r + j = j-1 + 90 continue + l = 9 + wrk(l) = 0. + if(iopt(2).eq.0) go to 100 + l = l+1 + uu = u(1) + if(uu.gt.tu(5)) uu = tu(5) + wrk(l) = uu*half + 100 do 110 i=1,mu + l = l+1 + wrk(l) = u(i) + 110 continue + if(iopt(3).eq.0) go to 120 + l = l+1 + wrk(l) = r + 120 muu = l-8 + call fpchec(wrk(9),muu,tu,nu,3,ier) + if(ier.ne.0) go to 200 + j1 = 4 + tv(j1) = v(1) + i1 = nv-3 + tv(i1) = ve + j2 = j1 + i2 = i1 + do 130 i=1,3 + i1 = i1+1 + i2 = i2-1 + j1 = j1+1 + j2 = j2-1 + tv(j2) = tv(i2)-per + tv(i1) = tv(j1)+per + 130 continue + l = 9 + do 135 i=1,mv + wrk(l) = v(i) + l = l+1 + 135 continue + wrk(l) = ve + call fpchep(wrk(9),mv+1,tv,nv,3,ier) + if (ier.eq.0) go to 150 + go to 200 + 140 if(s.lt.0.) go to 200 + if(s.eq.0. .and. (nuest.lt.(mu+5+iopt(2)+iopt(3)) .or. + * nvest.lt.(mv+7)) ) go to 200 +c we partition the working space and determine the spline approximation + 150 ldz = 5 + lfpu = 9 + lfpv = lfpu+nuest + lww = lfpv+nvest + jwrk = lwrk-8-nuest-nvest + knru = 5 + knrv = knru+mu + kndu = knrv+mv + kndv = kndu+nuest + call fppogr(iopt,ider,u,mu,v,mv,z,m,zb,r,s,nuest,nvest,tol,maxit, + * nc,nu,tu,nv,tv,c,fp,wrk(1),wrk(2),wrk(3),wrk(4),wrk(lfpu), + * wrk(lfpv),wrk(ldz),wrk(8),iwrk(1),iwrk(2),iwrk(3),iwrk(4), + * iwrk(knru),iwrk(knrv),iwrk(kndu),iwrk(kndv),wrk(lww),jwrk,ier) + 200 return + end + Added: branches/Interpolate1D/fitpack/polar.f =================================================================== --- branches/Interpolate1D/fitpack/polar.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/polar.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,450 @@ + subroutine polar(iopt,m,x,y,z,w,rad,s,nuest,nvest,eps,nu,tu, + * nv,tv,u,v,c,fp,wrk1,lwrk1,wrk2,lwrk2,iwrk,kwrk,ier) +c subroutine polar fits a smooth function f(x,y) to a set of data +c points (x(i),y(i),z(i)) scattered arbitrarily over an approximation +c domain x**2+y**2 <= rad(atan(y/x))**2. through the transformation +c x = u*rad(v)*cos(v) , y = u*rad(v)*sin(v) +c the approximation problem is reduced to the determination of a bi- +c cubic spline s(u,v) fitting a corresponding set of data points +c (u(i),v(i),z(i)) on the rectangle 0<=u<=1,-pi<=v<=pi. +c in order to have continuous partial derivatives +c i+j +c d f(0,0) +c g(i,j) = ---------- +c i j +c dx dy +c +c s(u,v)=f(x,y) must satisfy the following conditions +c +c (1) s(0,v) = g(0,0) -pi <=v<= pi. +c +c d s(0,v) +c (2) -------- = rad(v)*(cos(v)*g(1,0)+sin(v)*g(0,1)) +c d u +c -pi <=v<= pi +c 2 +c d s(0,v) 2 2 2 +c (3) -------- = rad(v)*(cos(v)*g(2,0)+sin(v)*g(0,2)+sin(2*v)*g(1,1)) +c 2 +c d u -pi <=v<= pi +c +c moreover, s(u,v) must be periodic in the variable v, i.e. +c +c j j +c d s(u,-pi) d s(u,pi) +c (4) ---------- = --------- 0 <=u<= 1, j=0,1,2 +c j j +c d v d v +c +c if iopt(1) < 0 circle calculates a weighted least-squares spline +c according to a given set of knots in u- and v- direction. +c if iopt(1) >=0, the number of knots in each direction and their pos- +c ition tu(j),j=1,2,...,nu ; tv(j),j=1,2,...,nv are chosen automatical- +c ly by the routine. the smoothness of s(u,v) is then achieved by mini- +c malizing the discontinuity jumps of the derivatives of the spline +c at the knots. the amount of smoothness of s(u,v) is determined by +c the condition that fp = sum((w(i)*(z(i)-s(u(i),v(i))))**2) be <= s, +c with s a given non-negative constant. +c the bicubic spline is given in its standard b-spline representation +c and the corresponding function f(x,y) can be evaluated by means of +c function program evapol. +c +c calling sequence: +c call polar(iopt,m,x,y,z,w,rad,s,nuest,nvest,eps,nu,tu, +c * nv,tv,u,v,wrk1,lwrk1,wrk2,lwrk2,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer array of dimension 3, specifying different options. +c unchanged on exit. +c iopt(1):on entry iopt(1) must specify whether a weighted +c least-squares polar spline (iopt(1)=-1) or a smoothing +c polar spline (iopt(1)=0 or 1) must be determined. +c if iopt(1)=0 the routine will start with an initial set of +c knots tu(i)=0,tu(i+4)=1,i=1,...,4;tv(i)=(2*i-9)*pi,i=1,...,8. +c if iopt(1)=1 the routine will continue with the set of knots +c found at the last call of the routine. +c attention: a call with iopt(1)=1 must always be immediately +c preceded by another call with iopt(1) = 1 or iopt(1) = 0. +c iopt(2):on entry iopt(2) must specify the requested order of conti- +c nuity for f(x,y) at the origin. +c if iopt(2)=0 only condition (1) must be fulfilled, +c if iopt(2)=1 conditions (1)+(2) must be fulfilled and +c if iopt(2)=2 conditions (1)+(2)+(3) must be fulfilled. +c iopt(3):on entry iopt(3) must specify whether (iopt(3)=1) or not +c (iopt(3)=0) the approximation f(x,y) must vanish at the +c boundary of the approximation domain. +c m : integer. on entry m must specify the number of data points. +c m >= 4-iopt(2)-iopt(3) unchanged on exit. +c x : real array of dimension at least (m). +c y : real array of dimension at least (m). +c z : real array of dimension at least (m). +c before entry, x(i),y(i),z(i) must be set to the co-ordinates +c of the i-th data point, for i=1,...,m. the order of the data +c points is immaterial. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) must +c be set to the i-th value in the set of weights. the w(i) must +c be strictly positive. unchanged on exit. +c rad : real function subprogram defining the boundary of the approx- +c imation domain, i.e x = rad(v)*cos(v) , y = rad(v)*sin(v), +c -pi <= v <= pi. +c must be declared external in the calling (sub)program. +c s : real. on entry (in case iopt(1) >=0) s must specify the +c smoothing factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c nuest : integer. unchanged on exit. +c nvest : integer. unchanged on exit. +c on entry, nuest and nvest must specify an upper bound for the +c number of knots required in the u- and v-directions resp. +c these numbers will also determine the storage space needed by +c the routine. nuest >= 8, nvest >= 8. +c in most practical situation nuest = nvest = 8+sqrt(m/2) will +c be sufficient. see also further comments. +c eps : real. +c on entry, eps must specify a threshold for determining the +c effective rank of an over-determined linear system of equat- +c ions. 0 < eps < 1. if the number of decimal digits in the +c computer representation of a real number is q, then 10**(-q) +c is a suitable value for eps in most practical applications. +c unchanged on exit. +c nu : integer. +c unless ier=10 (in case iopt(1) >=0),nu will contain the total +c number of knots with respect to the u-variable, of the spline +c approximation returned. if the computation mode iopt(1)=1 +c is used, the value of nu should be left unchanged between +c subsequent calls. +c in case iopt(1)=-1,the value of nu must be specified on entry +c tu : real array of dimension at least nuest. +c on succesful exit, this array will contain the knots of the +c spline with respect to the u-variable, i.e. the position +c of the interior knots tu(5),...,tu(nu-4) as well as the +c position of the additional knots tu(1)=...=tu(4)=0 and +c tu(nu-3)=...=tu(nu)=1 needed for the b-spline representation +c if the computation mode iopt(1)=1 is used,the values of +c tu(1),...,tu(nu) should be left unchanged between subsequent +c calls. if the computation mode iopt(1)=-1 is used,the values +c tu(5),...tu(nu-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c nv : integer. +c unless ier=10 (in case iopt(1)>=0), nv will contain the total +c number of knots with respect to the v-variable, of the spline +c approximation returned. if the computation mode iopt(1)=1 +c is used, the value of nv should be left unchanged between +c subsequent calls. in case iopt(1)=-1, the value of nv should +c be specified on entry. +c tv : real array of dimension at least nvest. +c on succesful exit, this array will contain the knots of the +c spline with respect to the v-variable, i.e. the position of +c the interior knots tv(5),...,tv(nv-4) as well as the position +c of the additional knots tv(1),...,tv(4) and tv(nv-3),..., +c tv(nv) needed for the b-spline representation. +c if the computation mode iopt(1)=1 is used, the values of +c tv(1),...,tv(nv) should be left unchanged between subsequent +c calls. if the computation mode iopt(1)=-1 is used,the values +c tv(5),...tv(nv-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c u : real array of dimension at least (m). +c v : real array of dimension at least (m). +c on succesful exit, u(i),v(i) contains the co-ordinates of +c the i-th data point with respect to the transformed rectan- +c gular approximation domain, for i=1,2,...,m. +c if the computation mode iopt(1)=1 is used the values of +c u(i),v(i) should be left unchanged between subsequent calls. +c c : real array of dimension at least (nuest-4)*(nvest-4). +c on succesful exit, c contains the coefficients of the spline +c approximation s(u,v). +c fp : real. unless ier=10, fp contains the weighted sum of +c squared residuals of the spline approximation returned. +c wrk1 : real array of dimension (lwrk1). used as workspace. +c if the computation mode iopt(1)=1 is used the value of +c wrk1(1) should be left unchanged between subsequent calls. +c on exit wrk1(2),wrk1(3),...,wrk1(1+ncof) will contain the +c values d(i)/max(d(i)),i=1,...,ncof=1+iopt(2)*(iopt(2)+3)/2+ +c (nv-7)*(nu-5-iopt(2)-iopt(3)) with d(i) the i-th diagonal el- +c ement of the triangular matrix for calculating the b-spline +c coefficients.it includes those elements whose square is < eps +c which are treated as 0 in the case of rank deficiency(ier=-2) +c lwrk1 : integer. on entry lwrk1 must specify the actual dimension of +c the array wrk1 as declared in the calling (sub)program. +c lwrk1 must not be too small. let +c k = nuest-7, l = nvest-7, p = 1+iopt(2)*(iopt(2)+3)/2, +c q = k+2-iopt(2)-iopt(3) then +c lwrk1 >= 129+10*k+21*l+k*l+(p+l*q)*(1+8*l+p)+8*m +c wrk2 : real array of dimension (lwrk2). used as workspace, but +c only in the case a rank deficient system is encountered. +c lwrk2 : integer. on entry lwrk2 must specify the actual dimension of +c the array wrk2 as declared in the calling (sub)program. +c lwrk2 > 0 . a save upper bound for lwrk2 = (p+l*q+1)*(4*l+p) +c +p+l*q where p,l,q are as above. if there are enough data +c points, scattered uniformly over the approximation domain +c and if the smoothing factor s is not too small, there is a +c good chance that this extra workspace is not needed. a lot +c of memory might therefore be saved by setting lwrk2=1. +c (see also ier > 10) +c iwrk : integer array of dimension (kwrk). used as workspace. +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= m+(nuest-7)*(nvest-7). +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c spline (fp=0). +c ier=-2 : normal return. the spline returned is the weighted least- +c squares constrained polynomial . in this extreme case +c fp gives the upper bound for the smoothing factor s. +c ier<-2 : warning. the coefficients of the spline returned have been +c computed as the minimal norm least-squares solution of a +c (numerically) rank deficient system. (-ier) gives the rank. +c especially if the rank deficiency which can be computed as +c 1+iopt(2)*(iopt(2)+3)/2+(nv-7)*(nu-5-iopt(2)-iopt(3))+ier +c is large the results may be inaccurate. +c they could also seriously depend on the value of eps. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters nuest and +c nvest. +c probably causes : nuest or nvest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the weighted least-squares +c polar spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small or badly chosen eps. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=4 : error. no more knots can be added because the dimension +c of the spline 1+iopt(2)*(iopt(2)+3)/2+(nv-7)*(nu-5-iopt(2) +c -iopt(3)) already exceeds the number of data points m. +c probably causes : either s or m too small. +c the approximation returned is the weighted least-squares +c polar spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=5 : error. no more knots can be added because the additional +c knot would (quasi) coincide with an old one. +c probably causes : s too small or too large a weight to an +c inaccurate data point. +c the approximation returned is the weighted least-squares +c polar spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt(1)<=1 , 0<=iopt(2)<=2 , 0<=iopt(3)<=1 , +c m>=4-iopt(2)-iopt(3) , nuest>=8 ,nvest >=8, 00, i=1,...,m +c lwrk1 >= 129+10*k+21*l+k*l+(p+l*q)*(1+8*l+p)+8*m +c kwrk >= m+(nuest-7)*(nvest-7) +c if iopt(1)=-1:9<=nu<=nuest,9+iopt(2)*(iopt(2)+1)<=nv<=nvest +c 0=0: s>=0 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c ier>10 : error. lwrk2 is too small, i.e. there is not enough work- +c space for computing the minimal least-squares solution of +c a rank deficient system of linear equations. ier gives the +c requested value for lwrk2. there is no approximation re- +c turned but, having saved the information contained in nu, +c nv,tu,tv,wrk1,u,v and having adjusted the value of lwrk2 +c and the dimension of the array wrk2 accordingly, the user +c can continue at the point the program was left, by calling +c polar with iopt(1)=1. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the constrained weighted least-squares polynomial if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c z(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in z(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c polynomial and the corresponding upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximation shows more detail) to obtain closer fits. +c to choose s very small is strongly discouraged. this considerably +c increases computation time and memory requirements. it may also +c cause rank-deficiency (ier<-2) and endager numerical stability. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt(1)=0. +c if iopt(1)=1 the program will continue with the set of knots found +c at the last call of the routine. this will save a lot of computation +c time if polar is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. if the computation mode iopt(1)=1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt(1)=1,the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c polar once more with the selected value for s but now with iopt(1)=0 +c indeed, polar may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds nuest and +c nvest. indeed, if at a certain stage in polar the number of knots +c in one direction (say nu) has reached the value of its upper bound +c (nuest), then from that moment on all subsequent knots are added +c in the other (v) direction. this may indicate that the value of +c nuest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c +c other subroutines required: +c fpback,fpbspl,fppola,fpdisc,fpgivs,fprank,fprati,fprota,fporde, +c fprppo +c +c references: +c dierckx p.: an algorithm for fitting data over a circle using tensor +c product splines,j.comp.appl.maths 15 (1986) 161-173. +c dierckx p.: an algorithm for fitting data on a circle using tensor +c product splines, report tw68, dept. computer science, +c k.u.leuven, 1984. +c dierckx p.: curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : june 1984 +c latest update : march 1989 +c +c .. +c ..scalar arguments.. + real*8 s,eps,fp + integer m,nuest,nvest,nu,nv,lwrk1,lwrk2,kwrk,ier +c ..array arguments.. + real*8 x(m),y(m),z(m),w(m),tu(nuest),tv(nvest),u(m),v(m), + * c((nuest-4)*(nvest-4)),wrk1(lwrk1),wrk2(lwrk2) + integer iopt(3),iwrk(kwrk) +c ..user specified function + real*8 rad +c ..local scalars.. + real*8 tol,pi,dist,r,one + integer i,ib1,ib3,ki,kn,kwest,la,lbu,lcc,lcs,lro,j + * lbv,lco,lf,lff,lfp,lh,lq,lsu,lsv,lwest,maxit,ncest,ncc,nuu, + * nvv,nreg,nrint,nu4,nv4,iopt1,iopt2,iopt3,ipar,nvmin +c ..function references.. + real*8 datan2,sqrt + external rad +c ..subroutine references.. +c fppola +c .. +c set up constants + one = 1d0 +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid,control is immediately repassed to the calling program. + ier = 10 + if(eps.le.0. .or. eps.ge.1.) go to 60 + iopt1 = iopt(1) + if(iopt1.lt.(-1) .or. iopt1.gt.1) go to 60 + iopt2 = iopt(2) + if(iopt2.lt.0 .or. iopt2.gt.2) go to 60 + iopt3 = iopt(3) + if(iopt3.lt.0 .or. iopt3.gt.1) go to 60 + if(m.lt.(4-iopt2-iopt3)) go to 60 + if(nuest.lt.8 .or. nvest.lt.8) go to 60 + nu4 = nuest-4 + nv4 = nvest-4 + ncest = nu4*nv4 + nuu = nuest-7 + nvv = nvest-7 + ipar = 1+iopt2*(iopt2+3)/2 + ncc = ipar+nvv*(nuest-5-iopt2-iopt3) + nrint = nuu+nvv + nreg = nuu*nvv + ib1 = 4*nvv + ib3 = ib1+ipar + lwest = ncc*(1+ib1+ib3)+2*nrint+ncest+m*8+ib3+5*nuest+12*nvest + kwest = m+nreg + if(lwrk1.lt.lwest .or. kwrk.lt.kwest) go to 60 + if(iopt1.gt.0) go to 40 + do 10 i=1,m + if(w(i).le.0.) go to 60 + dist = x(i)**2+y(i)**2 + u(i) = 0. + v(i) = 0. + if(dist.le.0.) go to 10 + v(i) = datan2(y(i),x(i)) + r = rad(v(i)) + if(r.le.0.) go to 60 + u(i) = sqrt(dist)/r + if(u(i).gt.one) go to 60 + 10 continue + if(iopt1.eq.0) go to 40 + nuu = nu-8 + if(nuu.lt.1 .or. nu.gt.nuest) go to 60 + tu(4) = 0. + do 20 i=1,nuu + j = i+4 + if(tu(j).le.tu(j-1) .or. tu(j).ge.one) go to 60 + 20 continue + nvv = nv-8 + nvmin = 9+iopt2*(iopt2+1) + if(nv.lt.nvmin .or. nv.gt.nvest) go to 60 + pi = datan2(0d0,-one) + tv(4) = -pi + do 30 i=1,nvv + j = i+4 + if(tv(j).le.tv(j-1) .or. tv(j).ge.pi) go to 60 + 30 continue + go to 50 + 40 if(s.lt.0.) go to 60 + 50 ier = 0 +c we partition the working space and determine the spline approximation + kn = 1 + ki = kn+m + lq = 2 + la = lq+ncc*ib3 + lf = la+ncc*ib1 + lff = lf+ncc + lfp = lff+ncest + lco = lfp+nrint + lh = lco+nrint + lbu = lh+ib3 + lbv = lbu+5*nuest + lro = lbv+5*nvest + lcc = lro+nvest + lcs = lcc+nvest + lsu = lcs+nvest*5 + lsv = lsu+m*4 + call fppola(iopt1,iopt2,iopt3,m,u,v,z,w,rad,s,nuest,nvest,eps,tol, + * + * maxit,ib1,ib3,ncest,ncc,nrint,nreg,nu,tu,nv,tv,c,fp,wrk1(1), + * wrk1(lfp),wrk1(lco),wrk1(lf),wrk1(lff),wrk1(lro),wrk1(lcc), + * wrk1(lcs),wrk1(la),wrk1(lq),wrk1(lbu),wrk1(lbv),wrk1(lsu), + * wrk1(lsv),wrk1(lh),iwrk(ki),iwrk(kn),wrk2,lwrk2,ier) + 60 return + end + Added: branches/Interpolate1D/fitpack/profil.f =================================================================== --- branches/Interpolate1D/fitpack/profil.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/profil.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,117 @@ + subroutine profil(iopt,tx,nx,ty,ny,c,kx,ky,u,nu,cu,ier) +c if iopt=0 subroutine profil calculates the b-spline coefficients of +c the univariate spline f(y) = s(u,y) with s(x,y) a bivariate spline of +c degrees kx and ky, given in the b-spline representation. +c if iopt = 1 it calculates the b-spline coefficients of the univariate +c spline g(x) = s(x,u) +c +c calling sequence: +c call profil(iopt,tx,nx,ty,ny,c,kx,ky,u,nu,cu,ier) +c +c input parameters: +c iopt : integer flag, specifying whether the profile f(y) (iopt=0) +c or the profile g(x) (iopt=1) must be determined. +c tx : real array, length nx, which contains the position of the +c knots in the x-direction. +c nx : integer, giving the total number of knots in the x-direction +c ty : real array, length ny, which contains the position of the +c knots in the y-direction. +c ny : integer, giving the total number of knots in the y-direction +c c : real array, length (nx-kx-1)*(ny-ky-1), which contains the +c b-spline coefficients. +c kx,ky : integer values, giving the degrees of the spline. +c u : real value, specifying the requested profile. +c tx(kx+1)<=u<=tx(nx-kx), if iopt=0. +c ty(ky+1)<=u<=ty(ny-ky), if iopt=1. +c nu : on entry nu must specify the dimension of the array cu. +c nu >= ny if iopt=0, nu >= nx if iopt=1. +c +c output parameters: +c cu : real array of dimension (nu). +c on succesful exit this array contains the b-spline +c ier : integer error flag +c ier=0 : normal return +c ier=10: invalid input data (see restrictions) +c +c restrictions: +c if iopt=0 : tx(kx+1) <= u <= tx(nx-kx), nu >=ny. +c if iopt=1 : ty(ky+1) <= u <= ty(ny-ky), nu >=nx. +c +c other subroutines required: +c fpbspl +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer iopt,nx,ny,kx,ky,nu,ier + real*8 u +c ..array arguments.. + real*8 tx(nx),ty(ny),c((nx-kx-1)*(ny-ky-1)),cu(nu) +c ..local scalars.. + integer i,j,kx1,ky1,l,l1,m,m0,nkx1,nky1 + real*8 sum +c ..local array + real*8 h(6) +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + kx1 = kx+1 + ky1 = ky+1 + nkx1 = nx-kx1 + nky1 = ny-ky1 + ier = 10 + if(iopt.ne.0) go to 200 + if(nu.lt.ny) go to 300 + if(u.lt.tx(kx1) .or. u.gt.tx(nkx1+1)) go to 300 +c the b-splinecoefficients of f(y) = s(u,y). + ier = 0 + l = kx1 + l1 = l+1 + 110 if(u.lt.tx(l1) .or. l.eq.nkx1) go to 120 + l = l1 + l1 = l+1 + go to 110 + 120 call fpbspl(tx,nx,kx,u,l,h) + m0 = (l-kx1)*nky1+1 + do 140 i=1,nky1 + m = m0 + sum = 0. + do 130 j=1,kx1 + sum = sum+h(j)*c(m) + m = m+nky1 + 130 continue + cu(i) = sum + m0 = m0+1 + 140 continue + go to 300 + 200 if(nu.lt.nx) go to 300 + if(u.lt.ty(ky1) .or. u.gt.ty(nky1+1)) go to 300 +c the b-splinecoefficients of g(x) = s(x,u). + ier = 0 + l = ky1 + l1 = l+1 + 210 if(u.lt.ty(l1) .or. l.eq.nky1) go to 220 + l = l1 + l1 = l+1 + go to 210 + 220 call fpbspl(ty,ny,ky,u,l,h) + m0 = l-ky + do 240 i=1,nkx1 + m = m0 + sum = 0. + do 230 j=1,ky1 + sum = sum+h(j)*c(m) + m = m+1 + 230 continue + cu(i) = sum + m0 = m0+nky1 + 240 continue + 300 return + end + Added: branches/Interpolate1D/fitpack/regrid.f =================================================================== --- branches/Interpolate1D/fitpack/regrid.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/regrid.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,353 @@ + subroutine regrid(iopt,mx,x,my,y,z,xb,xe,yb,ye,kx,ky,s, + * nxest,nyest,nx,tx,ny,ty,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c given the set of values z(i,j) on the rectangular grid (x(i),y(j)), +c i=1,...,mx;j=1,...,my, subroutine regrid determines a smooth bivar- +c iate spline approximation s(x,y) of degrees kx and ky on the rect- +c angle xb <= x <= xe, yb <= y <= ye. +c if iopt = -1 regrid calculates the least-squares spline according +c to a given set of knots. +c if iopt >= 0 the total numbers nx and ny of these knots and their +c position tx(j),j=1,...,nx and ty(j),j=1,...,ny are chosen automatic- +c ally by the routine. the smoothness of s(x,y) is then achieved by +c minimalizing the discontinuity jumps in the derivatives of s(x,y) +c across the boundaries of the subpanels (tx(i),tx(i+1))*(ty(j),ty(j+1). +c the amounth of smoothness is determined by the condition that f(p) = +c sum ((z(i,j)-s(x(i),y(j))))**2) be <= s, with s a given non-negative +c constant, called the smoothing factor. +c the fit is given in the b-spline representation (b-spline coefficients +c c((ny-ky-1)*(i-1)+j),i=1,...,nx-kx-1;j=1,...,ny-ky-1) and can be eval- +c uated by means of subroutine bispev. +c +c calling sequence: +c call regrid(iopt,mx,x,my,y,z,xb,xe,yb,ye,kx,ky,s,nxest,nyest, +c * nx,tx,ny,ty,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a least- +c squares spline (iopt=-1) or a smoothing spline (iopt=0 or 1) +c must be determined. +c if iopt=0 the routine will start with an initial set of knots +c tx(i)=xb,tx(i+kx+1)=xe,i=1,...,kx+1;ty(i)=yb,ty(i+ky+1)=ye,i= +c 1,...,ky+1. if iopt=1 the routine will continue with the set +c of knots found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately pre- +c ceded by another call with iopt=1 or iopt=0 and +c s.ne.0. +c unchanged on exit. +c mx : integer. on entry mx must specify the number of grid points +c along the x-axis. mx > kx . unchanged on exit. +c x : real array of dimension at least (mx). before entry, x(i) +c must be set to the x-co-ordinate of the i-th grid point +c along the x-axis, for i=1,2,...,mx. these values must be +c supplied in strictly ascending order. unchanged on exit. +c my : integer. on entry my must specify the number of grid points +c along the y-axis. my > ky . unchanged on exit. +c y : real array of dimension at least (my). before entry, y(j) +c must be set to the y-co-ordinate of the j-th grid point +c along the y-axis, for j=1,2,...,my. these values must be +c supplied in strictly ascending order. unchanged on exit. +c z : real array of dimension at least (mx*my). +c before entry, z(my*(i-1)+j) must be set to the data value at +c the grid point (x(i),y(j)) for i=1,...,mx and j=1,...,my. +c unchanged on exit. +c xb,xe : real values. on entry xb,xe,yb and ye must specify the bound- +c yb,ye aries of the rectangular approximation domain. +c xb<=x(i)<=xe,i=1,...,mx; yb<=y(j)<=ye,j=1,...,my. +c unchanged on exit. +c kx,ky : integer values. on entry kx and ky must specify the degrees +c of the spline. 1<=kx,ky<=5. it is recommended to use bicubic +c (kx=ky=3) splines. unchanged on exit. +c s : real. on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c nxest : integer. unchanged on exit. +c nyest : integer. unchanged on exit. +c on entry, nxest and nyest must specify an upper bound for the +c number of knots required in the x- and y-directions respect. +c these numbers will also determine the storage space needed by +c the routine. nxest >= 2*(kx+1), nyest >= 2*(ky+1). +c in most practical situation nxest = mx/2, nyest=my/2, will +c be sufficient. always large enough are nxest=mx+kx+1, nyest= +c my+ky+1, the number of knots needed for interpolation (s=0). +c see also further comments. +c nx : integer. +c unless ier=10 (in case iopt >=0), nx will contain the total +c number of knots with respect to the x-variable, of the spline +c approximation returned. if the computation mode iopt=1 is +c used, the value of nx should be left unchanged between sub- +c sequent calls. +c in case iopt=-1, the value of nx should be specified on entry +c tx : real array of dimension nmax. +c on succesful exit, this array will contain the knots of the +c spline with respect to the x-variable, i.e. the position of +c the interior knots tx(kx+2),...,tx(nx-kx-1) as well as the +c position of the additional knots tx(1)=...=tx(kx+1)=xb and +c tx(nx-kx)=...=tx(nx)=xe needed for the b-spline representat. +c if the computation mode iopt=1 is used, the values of tx(1), +c ...,tx(nx) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values tx(kx+2), +c ...tx(nx-kx-1) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c ny : integer. +c unless ier=10 (in case iopt >=0), ny will contain the total +c number of knots with respect to the y-variable, of the spline +c approximation returned. if the computation mode iopt=1 is +c used, the value of ny should be left unchanged between sub- +c sequent calls. +c in case iopt=-1, the value of ny should be specified on entry +c ty : real array of dimension nmax. +c on succesful exit, this array will contain the knots of the +c spline with respect to the y-variable, i.e. the position of +c the interior knots ty(ky+2),...,ty(ny-ky-1) as well as the +c position of the additional knots ty(1)=...=ty(ky+1)=yb and +c ty(ny-ky)=...=ty(ny)=ye needed for the b-spline representat. +c if the computation mode iopt=1 is used, the values of ty(1), +c ...,ty(ny) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values ty(ky+2), +c ...ty(ny-ky-1) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c c : real array of dimension at least (nxest-kx-1)*(nyest-ky-1). +c on succesful exit, c contains the coefficients of the spline +c approximation s(x,y) +c fp : real. unless ier=10, fp contains the sum of squared +c residuals of the spline approximation returned. +c wrk : real array of dimension (lwrk). used as workspace. +c if the computation mode iopt=1 is used the values of wrk(1), +c ...,wrk(4) should be left unchanged between subsequent calls. +c lwrk : integer. on entry lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. +c lwrk must not be too small. +c lwrk >= 4+nxest*(my+2*kx+5)+nyest*(2*ky+5)+mx*(kx+1)+ +c my*(ky+1) +u +c where u is the larger of my and nxest. +c iwrk : integer array of dimension (kwrk). used as workspace. +c if the computation mode iopt=1 is used the values of iwrk(1), +c ...,iwrk(3) should be left unchanged between subsequent calls +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= 3+mx+my+nxest+nyest. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c spline (fp=0). +c ier=-2 : normal return. the spline returned is the least-squares +c polynomial of degrees kx and ky. in this extreme case fp +c gives the upper bound for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters nxest and +c nyest. +c probably causes : nxest or nyest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the least-squares spline +c according to the current set of knots. the parameter fp +c gives the corresponding sum of squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 1<=kx,ky<=5, mx>kx, my>ky, nxest>=2*kx+2, +c nyest>=2*ky+2, kwrk>=3+mx+my+nxest+nyest, +c lwrk >= 4+nxest*(my+2*kx+5)+nyest*(2*ky+5)+mx*(kx+1)+ +c my*(ky+1) +max(my,nxest), +c xb<=x(i-1)=0: s>=0 +c if s=0 : nxest>=mx+kx+1, nyest>=my+ky+1 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c regrid does not allow individual weighting of the data-values. +c so, if these were determined to widely different accuracies, then +c perhaps the general data set routine surfit should rather be used +c in spite of efficiency. +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the least-squares polynomial (degrees kx,ky) if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the accuracy of the data values. +c if the user has an idea of the statistical errors on the data, he +c can also find a proper estimate for s. for, by assuming that, if he +c specifies the right s, regrid will return a spline s(x,y) which +c exactly reproduces the function underlying the data he can evaluate +c the sum((z(i,j)-s(x(i),y(j)))**2) to find a good estimate for this s +c for example, if he knows that the statistical errors on his z(i,j)- +c values is not greater than 0.1, he may expect that a good s should +c have a value not larger than mx*my*(0.1)**2. +c if nothing is known about the statistical error in z(i,j), s must +c be determined by trial and error, taking account of the comments +c above. the best is then to start with a very large value of s (to +c determine the least-squares polynomial and the corresponding upper +c bound fp0 for s) and then to progressively decrease the value of s +c ( say by a factor 10 in the beginning, i.e. s=fp0/10,fp0/100,... +c and more carefully as the approximation shows more detail) to +c obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if regrid is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. if the computation mode iopt=1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c regrid once more with the selected value for s but now with iopt=0. +c indeed, regrid may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds nxest and +c nyest. indeed, if at a certain stage in regrid the number of knots +c in one direction (say nx) has reached the value of its upper bound +c (nxest), then from that moment on all subsequent knots are added +c in the other (y) direction. this may indicate that the value of +c nxest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c for example, by setting nxest=2*kx+2 (the lowest allowable value for +c nxest), the user can indicate that he wants an approximation which +c is a simple polynomial of degree kx in the variable x. +c +c other subroutines required: +c fpback,fpbspl,fpregr,fpdisc,fpgivs,fpgrre,fprati,fprota,fpchec, +c fpknot +c +c references: +c dierckx p. : a fast algorithm for smoothing data on a rectangular +c grid while using spline functions, siam j.numer.anal. +c 19 (1982) 1286-1304. +c dierckx p. : a fast algorithm for smoothing data on a rectangular +c grid while using spline functions, report tw53, dept. +c computer science,k.u.leuven, 1980. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1989 +c +c .. +c ..scalar arguments.. + real*8 xb,xe,yb,ye,s,fp + integer iopt,mx,my,kx,ky,nxest,nyest,nx,ny,lwrk,kwrk,ier +c ..array arguments.. + real*8 x(mx),y(my),z(mx*my),tx(nxest),ty(nyest), + * c((nxest-kx-1)*(nyest-ky-1)),wrk(lwrk) + integer iwrk(kwrk) +c ..local scalars.. + real*8 tol + integer i,j,jwrk,kndx,kndy,knrx,knry,kwest,kx1,kx2,ky1,ky2, + * lfpx,lfpy,lwest,lww,maxit,nc,nminx,nminy,mz +c ..function references.. + integer max0 +c ..subroutine references.. +c fpregr,fpchec +c .. +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(kx.le.0 .or. kx.gt.5) go to 70 + kx1 = kx+1 + kx2 = kx1+1 + if(ky.le.0 .or. ky.gt.5) go to 70 + ky1 = ky+1 + ky2 = ky1+1 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 70 + nminx = 2*kx1 + if(mx.lt.kx1 .or. nxest.lt.nminx) go to 70 + nminy = 2*ky1 + if(my.lt.ky1 .or. nyest.lt.nminy) go to 70 + mz = mx*my + nc = (nxest-kx1)*(nyest-ky1) + lwest = 4+nxest*(my+2*kx2+1)+nyest*(2*ky2+1)+mx*kx1+ + * my*ky1+max0(nxest,my) + kwest = 3+mx+my+nxest+nyest + if(lwrk.lt.lwest .or. kwrk.lt.kwest) go to 70 + if(xb.gt.x(1) .or. xe.lt.x(mx)) go to 70 + do 10 i=2,mx + if(x(i-1).ge.x(i)) go to 70 + 10 continue + if(yb.gt.y(1) .or. ye.lt.y(my)) go to 70 + do 20 i=2,my + if(y(i-1).ge.y(i)) go to 70 + 20 continue + if(iopt.ge.0) go to 50 + if(nx.lt.nminx .or. nx.gt.nxest) go to 70 + j = nx + do 30 i=1,kx1 + tx(i) = xb + tx(j) = xe + j = j-1 + 30 continue + call fpchec(x,mx,tx,nx,kx,ier) + if(ier.ne.0) go to 70 + if(ny.lt.nminy .or. ny.gt.nyest) go to 70 + j = ny + do 40 i=1,ky1 + ty(i) = yb + ty(j) = ye + j = j-1 + 40 continue + call fpchec(y,my,ty,ny,ky,ier) + if (ier.eq.0) go to 60 + go to 70 + 50 if(s.lt.0.) go to 70 + if(s.eq.0. .and. (nxest.lt.(mx+kx1) .or. nyest.lt.(my+ky1)) ) + * go to 70 + ier = 0 +c we partition the working space and determine the spline approximation + 60 lfpx = 5 + lfpy = lfpx+nxest + lww = lfpy+nyest + jwrk = lwrk-4-nxest-nyest + knrx = 4 + knry = knrx+mx + kndx = knry+my + kndy = kndx+nxest + call fpregr(iopt,x,mx,y,my,z,mz,xb,xe,yb,ye,kx,ky,s,nxest,nyest, + * tol,maxit,nc,nx,tx,ny,ty,c,fp,wrk(1),wrk(2),wrk(3),wrk(4), + * wrk(lfpx),wrk(lfpy),iwrk(1),iwrk(2),iwrk(3),iwrk(knrx), + * iwrk(knry),iwrk(kndx),iwrk(kndy),wrk(lww),jwrk,ier) + 70 return + end + Added: branches/Interpolate1D/fitpack/spalde.f =================================================================== --- branches/Interpolate1D/fitpack/spalde.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/spalde.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,73 @@ + subroutine spalde(t,n,c,k1,x,d,ier) +c subroutine spalde evaluates at a point x all the derivatives +c (j-1) +c d(j) = s (x) , j=1,2,...,k1 +c of a spline s(x) of order k1 (degree k=k1-1), given in its b-spline +c representation. +c +c calling sequence: +c call spalde(t,n,c,k1,x,d,ier) +c +c input parameters: +c t : array,length n, which contains the position of the knots. +c n : integer, giving the total number of knots of s(x). +c c : array,length n, which contains the b-spline coefficients. +c k1 : integer, giving the order of s(x) (order=degree+1) +c x : real, which contains the point where the derivatives must +c be evaluated. +c +c output parameters: +c d : array,length k1, containing the derivative values of s(x). +c ier : error flag +c ier = 0 : normal return +c ier =10 : invalid input data (see restrictions) +c +c restrictions: +c t(k1) <= x <= t(n-k1+1) +c +c further comments: +c if x coincides with a knot, right derivatives are computed +c ( left derivatives if x = t(n-k1+1) ). +c +c other subroutines required: fpader. +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer n,k1,ier + real*8 x +c ..array arguments.. + real*8 t(n),c(n),d(k1) +c ..local scalars.. + integer l,nk1 +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + nk1 = n-k1 + if(x.lt.t(k1) .or. x.gt.t(nk1+1)) go to 300 +c search for knot interval t(l) <= x < t(l+1) + l = k1 + 100 if(x.lt.t(l+1) .or. l.eq.nk1) go to 200 + l = l+1 + go to 100 + 200 if(t(l).ge.t(l+1)) go to 300 + ier = 0 +c calculate the derivatives. + call fpader(t,n,c,k1,x,l,d) + 300 return + end Added: branches/Interpolate1D/fitpack/spgrid.f =================================================================== --- branches/Interpolate1D/fitpack/spgrid.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/spgrid.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,501 @@ + subroutine spgrid(iopt,ider,mu,u,mv,v,r,r0,r1,s,nuest,nvest, + * nu,tu,nv,tv,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c given the function values r(i,j) on the latitude-longitude grid +c (u(i),v(j)), i=1,...,mu ; j=1,...,mv , spgrid determines a smooth +c bicubic spline approximation on the rectangular domain 0<=u<=pi, +c vb<=v<=ve (vb = v(1), ve=vb+2*pi). +c this approximation s(u,v) will satisfy the properties +c +c (1) s(0,v) = s(0,0) = dr(1) +c +c d s(0,v) d s(0,0) d s(0,pi/2) +c (2) -------- = cos(v)* -------- + sin(v)* ----------- +c d u d u d u +c +c = cos(v)*dr(2)+sin(v)*dr(3) +c vb <= v <= ve +c (3) s(pi,v) = s(pi,0) = dr(4) +c +c d s(pi,v) d s(pi,0) d s(pi,pi/2) +c (4) -------- = cos(v)* --------- + sin(v)* ------------ +c d u d u d u +c +c = cos(v)*dr(5)+sin(v)*dr(6) +c +c and will be periodic in the variable v, i.e. +c +c j j +c d s(u,vb) d s(u,ve) +c (5) --------- = --------- 0 <=u<= pi , j=0,1,2 +c j j +c d v d v +c +c the number of knots of s(u,v) and their position tu(i),i=1,2,...,nu; +c tv(j),j=1,2,...,nv, is chosen automatically by the routine. the +c smoothness of s(u,v) is achieved by minimalizing the discontinuity +c jumps of the derivatives of the spline at the knots. the amount of +c smoothness of s(u,v) is determined by the condition that +c fp=sumi=1,mu(sumj=1,mv((r(i,j)-s(u(i),v(j)))**2))+(r0-s(0,v))**2 +c + (r1-s(pi,v))**2 <= s, with s a given non-negative constant. +c the fit s(u,v) is given in its b-spline representation and can be +c evaluated by means of routine bispev +c +c calling sequence: +c call spgrid(iopt,ider,mu,u,mv,v,r,r0,r1,s,nuest,nvest,nu,tu, +c * ,nv,tv,c,fp,wrk,lwrk,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer array of dimension 3, specifying different options. +c unchanged on exit. +c iopt(1):on entry iopt(1) must specify whether a least-squares spline +c (iopt(1)=-1) or a smoothing spline (iopt(1)=0 or 1) must be +c determined. +c if iopt(1)=0 the routine will start with an initial set of +c knots tu(i)=0,tu(i+4)=pi,i=1,...,4;tv(i)=v(1)+(i-4)*2*pi, +c i=1,...,8. +c if iopt(1)=1 the routine will continue with the set of knots +c found at the last call of the routine. +c attention: a call with iopt(1)=1 must always be immediately +c preceded by another call with iopt(1) = 1 or iopt(1) = 0. +c iopt(2):on entry iopt(2) must specify the requested order of conti- +c nuity at the pole u=0. +c if iopt(2)=0 only condition (1) must be fulfilled and +c if iopt(2)=1 conditions (1)+(2) must be fulfilled. +c iopt(3):on entry iopt(3) must specify the requested order of conti- +c nuity at the pole u=pi. +c if iopt(3)=0 only condition (3) must be fulfilled and +c if iopt(3)=1 conditions (3)+(4) must be fulfilled. +c ider : integer array of dimension 4, specifying different options. +c unchanged on exit. +c ider(1):on entry ider(1) must specify whether (ider(1)=0 or 1) or not +c (ider(1)=-1) there is a data value r0 at the pole u=0. +c if ider(1)=1, r0 will be considered to be the right function +c value, and it will be fitted exactly (s(0,v)=r0). +c if ider(1)=0, r0 will be considered to be a data value just +c like the other data values r(i,j). +c ider(2):on entry ider(2) must specify whether (ider(2)=1) or not +c (ider(2)=0) the approximation has vanishing derivatives +c dr(2) and dr(3) at the pole u=0 (in case iopt(2)=1) +c ider(3):on entry ider(3) must specify whether (ider(3)=0 or 1) or not +c (ider(3)=-1) there is a data value r1 at the pole u=pi. +c if ider(3)=1, r1 will be considered to be the right function +c value, and it will be fitted exactly (s(pi,v)=r1). +c if ider(3)=0, r1 will be considered to be a data value just +c like the other data values r(i,j). +c ider(4):on entry ider(4) must specify whether (ider(4)=1) or not +c (ider(4)=0) the approximation has vanishing derivatives +c dr(5) and dr(6) at the pole u=pi (in case iopt(3)=1) +c mu : integer. on entry mu must specify the number of grid points +c along the u-axis. unchanged on exit. +c mu >= 1, mu >=mumin=4-i0-i1-ider(2)-ider(4) with +c i0=min(1,ider(1)+1), i1=min(1,ider(3)+1) +c u : real array of dimension at least (mu). before entry, u(i) +c must be set to the u-co-ordinate of the i-th grid point +c along the u-axis, for i=1,2,...,mu. these values must be +c supplied in strictly ascending order. unchanged on exit. +c 0 < u(i) < pi. +c mv : integer. on entry mv must specify the number of grid points +c along the v-axis. mv > 3 . unchanged on exit. +c v : real array of dimension at least (mv). before entry, v(j) +c must be set to the v-co-ordinate of the j-th grid point +c along the v-axis, for j=1,2,...,mv. these values must be +c supplied in strictly ascending order. unchanged on exit. +c -pi <= v(1) < pi , v(mv) < v(1)+2*pi. +c r : real array of dimension at least (mu*mv). +c before entry, r(mv*(i-1)+j) must be set to the data value at +c the grid point (u(i),v(j)) for i=1,...,mu and j=1,...,mv. +c unchanged on exit. +c r0 : real value. on entry (if ider(1) >=0 ) r0 must specify the +c data value at the pole u=0. unchanged on exit. +c r1 : real value. on entry (if ider(1) >=0 ) r1 must specify the +c data value at the pole u=pi. unchanged on exit. +c s : real. on entry (if iopt(1)>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c nuest : integer. unchanged on exit. +c nvest : integer. unchanged on exit. +c on entry, nuest and nvest must specify an upper bound for the +c number of knots required in the u- and v-directions respect. +c these numbers will also determine the storage space needed by +c the routine. nuest >= 8, nvest >= 8. +c in most practical situation nuest = mu/2, nvest=mv/2, will +c be sufficient. always large enough are nuest=mu+6+iopt(2)+ +c iopt(3), nvest = mv+7, the number of knots needed for +c interpolation (s=0). see also further comments. +c nu : integer. +c unless ier=10 (in case iopt(1)>=0), nu will contain the total +c number of knots with respect to the u-variable, of the spline +c approximation returned. if the computation mode iopt(1)=1 is +c used, the value of nu should be left unchanged between sub- +c sequent calls. in case iopt(1)=-1, the value of nu should be +c specified on entry. +c tu : real array of dimension at least (nuest). +c on succesful exit, this array will contain the knots of the +c spline with respect to the u-variable, i.e. the position of +c the interior knots tu(5),...,tu(nu-4) as well as the position +c of the additional knots tu(1)=...=tu(4)=0 and tu(nu-3)=...= +c tu(nu)=pi needed for the b-spline representation. +c if the computation mode iopt(1)=1 is used,the values of tu(1) +c ...,tu(nu) should be left unchanged between subsequent calls. +c if the computation mode iopt(1)=-1 is used, the values tu(5), +c ...tu(nu-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c nv : integer. +c unless ier=10 (in case iopt(1)>=0), nv will contain the total +c number of knots with respect to the v-variable, of the spline +c approximation returned. if the computation mode iopt(1)=1 is +c used, the value of nv should be left unchanged between sub- +c sequent calls. in case iopt(1) = -1, the value of nv should +c be specified on entry. +c tv : real array of dimension at least (nvest). +c on succesful exit, this array will contain the knots of the +c spline with respect to the v-variable, i.e. the position of +c the interior knots tv(5),...,tv(nv-4) as well as the position +c of the additional knots tv(1),...,tv(4) and tv(nv-3),..., +c tv(nv) needed for the b-spline representation. +c if the computation mode iopt(1)=1 is used,the values of tv(1) +c ...,tv(nv) should be left unchanged between subsequent calls. +c if the computation mode iopt(1)=-1 is used, the values tv(5), +c ...tv(nv-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c c : real array of dimension at least (nuest-4)*(nvest-4). +c on succesful exit, c contains the coefficients of the spline +c approximation s(u,v) +c fp : real. unless ier=10, fp contains the sum of squared +c residuals of the spline approximation returned. +c wrk : real array of dimension (lwrk). used as workspace. +c if the computation mode iopt(1)=1 is used the values of +c wrk(1),..,wrk(12) should be left unchanged between subsequent +c calls. +c lwrk : integer. on entry lwrk must specify the actual dimension of +c the array wrk as declared in the calling (sub)program. +c lwrk must not be too small. +c lwrk >= 12+nuest*(mv+nvest+3)+nvest*24+4*mu+8*mv+q +c where q is the larger of (mv+nvest) and nuest. +c iwrk : integer array of dimension (kwrk). used as workspace. +c if the computation mode iopt(1)=1 is used the values of +c iwrk(1),.,iwrk(5) should be left unchanged between subsequent +c calls. +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= 5+mu+mv+nuest+nvest. +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c spline (fp=0). +c ier=-2 : normal return. the spline returned is the least-squares +c constrained polynomial. in this extreme case fp gives the +c upper bound for the smoothing factor s. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters nuest and +c nvest. +c probably causes : nuest or nvest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the least-squares spline +c according to the current set of knots. the parameter fp +c gives the corresponding sum of squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small. +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c sum of squared residuals does not satisfy the condition +c abs(fp-s)/s < tol. +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt(1)<=1, 0<=iopt(2)<=1, 0<=iopt(3)<=1, +c -1<=ider(1)<=1, 0<=ider(2)<=1, ider(2)=0 if iopt(2)=0. +c -1<=ider(3)<=1, 0<=ider(4)<=1, ider(4)=0 if iopt(3)=0. +c mu >= mumin (see above), mv >= 4, nuest >=8, nvest >= 8, +c kwrk>=5+mu+mv+nuest+nvest, +c lwrk >= 12+nuest*(mv+nvest+3)+nvest*24+4*mu+8*mv+ +c max(nuest,mv+nvest) +c 0< u(i-1)=0: s>=0 +c if s=0: nuest>=mu+6+iopt(2)+iopt(3), nvest>=mv+7 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c +c further comments: +c spgrid does not allow individual weighting of the data-values. +c so, if these were determined to widely different accuracies, then +c perhaps the general data set routine sphere should rather be used +c in spite of efficiency. +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the constrained least-squares polynomial(degrees 3,0)if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the accuracy of the data values. +c if the user has an idea of the statistical errors on the data, he +c can also find a proper estimate for s. for, by assuming that, if he +c specifies the right s, spgrid will return a spline s(u,v) which +c exactly reproduces the function underlying the data he can evaluate +c the sum((r(i,j)-s(u(i),v(j)))**2) to find a good estimate for this s +c for example, if he knows that the statistical errors on his r(i,j)- +c values is not greater than 0.1, he may expect that a good s should +c have a value not larger than mu*mv*(0.1)**2. +c if nothing is known about the statistical error in r(i,j), s must +c be determined by trial and error, taking account of the comments +c above. the best is then to start with a very large value of s (to +c determine the least-squares polynomial and the corresponding upper +c bound fp0 for s) and then to progressively decrease the value of s +c ( say by a factor 10 in the beginning, i.e. s=fp0/10,fp0/100,... +c and more carefully as the approximation shows more detail) to +c obtain closer fits. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt(1)=0. +c if iopt(1) = 1 the program will continue with the knots found at +c the last call of the routine. this will save a lot of computation +c time if spgrid is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. if the computation mode iopt(1) = 1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt(1)=1,the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c spgrid once more with the chosen value for s but now with iopt(1)=0. +c indeed, spgrid may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds nuest and +c nvest. indeed, if at a certain stage in spgrid the number of knots +c in one direction (say nu) has reached the value of its upper bound +c (nuest), then from that moment on all subsequent knots are added +c in the other (v) direction. this may indicate that the value of +c nuest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c for example, by setting nuest=8 (the lowest allowable value for +c nuest), the user can indicate that he wants an approximation which +c is a simple cubic polynomial in the variable u. +c +c other subroutines required: +c fpspgr,fpchec,fpchep,fpknot,fpopsp,fprati,fpgrsp,fpsysy,fpback, +c fpbacp,fpbspl,fpcyt1,fpcyt2,fpdisc,fpgivs,fprota +c +c references: +c dierckx p. : fast algorithms for smoothing data over a disc or a +c sphere using tensor product splines, in "algorithms +c for approximation", ed. j.c.mason and m.g.cox, +c clarendon press oxford, 1987, pp. 51-65 +c dierckx p. : fast algorithms for smoothing data over a disc or a +c sphere using tensor product splines, report tw73, dept. +c computer science,k.u.leuven, 1985. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : july 1985 +c latest update : march 1989 +c +c .. +c ..scalar arguments.. + real*8 r0,r1,s,fp + integer mu,mv,nuest,nvest,nu,nv,lwrk,kwrk,ier +c ..array arguments.. + integer iopt(3),ider(4),iwrk(kwrk) + real*8 u(mu),v(mv),r(mu*mv),c((nuest-4)*(nvest-4)),tu(nuest), + * tv(nvest),wrk(lwrk) +c ..local scalars.. + real*8 per,pi,tol,uu,ve,rmax,rmin,one,half,rn,rb,re + integer i,i1,i2,j,jwrk,j1,j2,kndu,kndv,knru,knrv,kwest,l, + * ldr,lfpu,lfpv,lwest,lww,m,maxit,mumin,muu,nc +c ..function references.. + real*8 datan2 + integer max0 +c ..subroutine references.. +c fpchec,fpchep,fpspgr +c .. +c set constants + one = 1d0 + half = 0.5e0 + pi = datan2(0d0,-one) + per = pi+pi + ve = v(1)+per +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations, a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + ier = 10 + if(iopt(1).lt.(-1) .or. iopt(1).gt.1) go to 200 + if(iopt(2).lt.0 .or. iopt(2).gt.1) go to 200 + if(iopt(3).lt.0 .or. iopt(3).gt.1) go to 200 + if(ider(1).lt.(-1) .or. ider(1).gt.1) go to 200 + if(ider(2).lt.0 .or. ider(2).gt.1) go to 200 + if(ider(2).eq.1 .and. iopt(2).eq.0) go to 200 + if(ider(3).lt.(-1) .or. ider(3).gt.1) go to 200 + if(ider(4).lt.0 .or. ider(4).gt.1) go to 200 + if(ider(4).eq.1 .and. iopt(3).eq.0) go to 200 + mumin = 4 + if(ider(1).ge.0) mumin = mumin-1 + if(iopt(2).eq.1 .and. ider(2).eq.1) mumin = mumin-1 + if(ider(3).ge.0) mumin = mumin-1 + if(iopt(3).eq.1 .and. ider(4).eq.1) mumin = mumin-1 + if(mumin.eq.0) mumin = 1 + if(mu.lt.mumin .or. mv.lt.4) go to 200 + if(nuest.lt.8 .or. nvest.lt.8) go to 200 + m = mu*mv + nc = (nuest-4)*(nvest-4) + lwest = 12+nuest*(mv+nvest+3)+24*nvest+4*mu+8*mv+ + * max0(nuest,mv+nvest) + kwest = 5+mu+mv+nuest+nvest + if(lwrk.lt.lwest .or. kwrk.lt.kwest) go to 200 + if(u(1).le.0. .or. u(mu).ge.pi) go to 200 + if(mu.eq.1) go to 30 + do 20 i=2,mu + if(u(i-1).ge.u(i)) go to 200 + 20 continue + 30 if(v(1).lt. (-pi) .or. v(1).ge.pi ) go to 200 + if(v(mv).ge.v(1)+per) go to 200 + do 40 i=2,mv + if(v(i-1).ge.v(i)) go to 200 + 40 continue + if(iopt(1).gt.0) go to 140 +c if not given, we compute an estimate for r0. + rn = mv + if(ider(1).lt.0) go to 45 + rb = r0 + go to 55 + 45 rb = 0. + do 50 i=1,mv + rb = rb+r(i) + 50 continue + rb = rb/rn +c if not given, we compute an estimate for r1. + 55 if(ider(3).lt.0) go to 60 + re = r1 + go to 70 + 60 re = 0. + j = m + do 65 i=1,mv + re = re+r(j) + j = j-1 + 65 continue + re = re/rn +c we determine the range of r-values. + 70 rmin = rb + rmax = re + do 80 i=1,m + if(r(i).lt.rmin) rmin = r(i) + if(r(i).gt.rmax) rmax = r(i) + 80 continue + wrk(5) = rb + wrk(6) = 0. + wrk(7) = 0. + wrk(8) = re + wrk(9) = 0. + wrk(10) = 0. + wrk(11) = rmax -rmin + wrk(12) = wrk(11) + iwrk(4) = mu + iwrk(5) = mu + if(iopt(1).eq.0) go to 140 + if(nu.lt.8 .or. nu.gt.nuest) go to 200 + if(nv.lt.11 .or. nv.gt.nvest) go to 200 + j = nu + do 90 i=1,4 + tu(i) = 0. + tu(j) = pi + j = j-1 + 90 continue + l = 13 + wrk(l) = 0. + if(iopt(2).eq.0) go to 100 + l = l+1 + uu = u(1) + if(uu.gt.tu(5)) uu = tu(5) + wrk(l) = uu*half + 100 do 110 i=1,mu + l = l+1 + wrk(l) = u(i) + 110 continue + if(iopt(3).eq.0) go to 120 + l = l+1 + uu = u(mu) + if(uu.lt.tu(nu-4)) uu = tu(nu-4) + wrk(l) = uu+(pi-uu)*half + 120 l = l+1 + wrk(l) = pi + muu = l-12 + call fpchec(wrk(13),muu,tu,nu,3,ier) + if(ier.ne.0) go to 200 + j1 = 4 + tv(j1) = v(1) + i1 = nv-3 + tv(i1) = ve + j2 = j1 + i2 = i1 + do 130 i=1,3 + i1 = i1+1 + i2 = i2-1 + j1 = j1+1 + j2 = j2-1 + tv(j2) = tv(i2)-per + tv(i1) = tv(j1)+per + 130 continue + l = 13 + do 135 i=1,mv + wrk(l) = v(i) + l = l+1 + 135 continue + wrk(l) = ve + call fpchep(wrk(13),mv+1,tv,nv,3,ier) + if (ier.eq.0) go to 150 + go to 200 + 140 if(s.lt.0.) go to 200 + if(s.eq.0. .and. (nuest.lt.(mu+6+iopt(2)+iopt(3)) .or. + * nvest.lt.(mv+7)) ) go to 200 +c we partition the working space and determine the spline approximation + 150 ldr = 5 + lfpu = 13 + lfpv = lfpu+nuest + lww = lfpv+nvest + jwrk = lwrk-12-nuest-nvest + knru = 6 + knrv = knru+mu + kndu = knrv+mv + kndv = kndu+nuest + call fpspgr(iopt,ider,u,mu,v,mv,r,m,rb,re,s,nuest,nvest,tol,maxit, + * + * nc,nu,tu,nv,tv,c,fp,wrk(1),wrk(2),wrk(3),wrk(4),wrk(lfpu), + * wrk(lfpv),wrk(ldr),wrk(11),iwrk(1),iwrk(2),iwrk(3),iwrk(4), + * iwrk(5),iwrk(knru),iwrk(knrv),iwrk(kndu),iwrk(kndv),wrk(lww), + * jwrk,ier) + 200 return + end Added: branches/Interpolate1D/fitpack/sphere.f =================================================================== --- branches/Interpolate1D/fitpack/sphere.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/sphere.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,404 @@ + subroutine sphere(iopt,m,teta,phi,r,w,s,ntest,npest,eps, + * nt,tt,np,tp,c,fp,wrk1,lwrk1,wrk2,lwrk2,iwrk,kwrk,ier) +c subroutine sphere determines a smooth bicubic spherical spline +c approximation s(teta,phi), 0 <= teta <= pi ; 0 <= phi <= 2*pi +c to a given set of data points (teta(i),phi(i),r(i)),i=1,2,...,m. +c such a spline has the following specific properties +c +c (1) s(0,phi) = constant 0 <=phi<= 2*pi. +c +c (2) s(pi,phi) = constant 0 <=phi<= 2*pi +c +c j j +c d s(teta,0) d s(teta,2*pi) +c (3) ----------- = ------------ 0 <=teta<=pi, j=0,1,2 +c j j +c d phi d phi +c +c d s(0,phi) d s(0,0) d s(0,pi/2) +c (4) ---------- = -------- *cos(phi) + ----------- *sin(phi) +c d teta d teta d teta +c +c d s(pi,phi) d s(pi,0) d s(pi,pi/2) +c (5) ----------- = ---------*cos(phi) + ------------*sin(phi) +c d teta d teta d teta +c +c if iopt =-1 sphere calculates a weighted least-squares spherical +c spline according to a given set of knots in teta- and phi- direction. +c if iopt >=0, the number of knots in each direction and their position +c tt(j),j=1,2,...,nt ; tp(j),j=1,2,...,np are chosen automatically by +c the routine. the smoothness of s(teta,phi) is then achieved by mini- +c malizing the discontinuity jumps of the derivatives of the spline +c at the knots. the amount of smoothness of s(teta,phi) is determined +c by the condition that fp = sum((w(i)*(r(i)-s(teta(i),phi(i))))**2) +c be <= s, with s a given non-negative constant. +c the spherical spline is given in the standard b-spline representation +c of bicubic splines and can be evaluated by means of subroutine bispev +c +c calling sequence: +c call sphere(iopt,m,teta,phi,r,w,s,ntest,npest,eps, +c * nt,tt,np,tp,c,fp,wrk1,lwrk1,wrk2,lwrk2,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares spherical spline (iopt=-1) or a smoothing +c spherical spline (iopt=0 or 1) must be determined. +c if iopt=0 the routine will start with an initial set of knots +c tt(i)=0,tt(i+4)=pi,i=1,...,4;tp(i)=0,tp(i+4)=2*pi,i=1,...,4. +c if iopt=1 the routine will continue with the set of knots +c found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately pre- +c ceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m >= 2. unchanged on exit. +c teta : real array of dimension at least (m). +c phi : real array of dimension at least (m). +c r : real array of dimension at least (m). +c before entry,teta(i),phi(i),r(i) must be set to the spherical +c co-ordinates of the i-th data point, for i=1,...,m.the order +c of the data points is immaterial. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) must +c be set to the i-th value in the set of weights. the w(i) must +c be strictly positive. unchanged on exit. +c s : real. on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c ntest : integer. unchanged on exit. +c npest : integer. unchanged on exit. +c on entry, ntest and npest must specify an upper bound for the +c number of knots required in the teta- and phi-directions. +c these numbers will also determine the storage space needed by +c the routine. ntest >= 8, npest >= 8. +c in most practical situation ntest = npest = 8+sqrt(m/2) will +c be sufficient. see also further comments. +c eps : real. +c on entry, eps must specify a threshold for determining the +c effective rank of an over-determined linear system of equat- +c ions. 0 < eps < 1. if the number of decimal digits in the +c computer representation of a real number is q, then 10**(-q) +c is a suitable value for eps in most practical applications. +c unchanged on exit. +c nt : integer. +c unless ier=10 (in case iopt >=0), nt will contain the total +c number of knots with respect to the teta-variable, of the +c spline approximation returned. if the computation mode iopt=1 +c is used, the value of nt should be left unchanged between +c subsequent calls. +c in case iopt=-1, the value of nt should be specified on entry +c tt : real array of dimension at least ntest. +c on succesful exit, this array will contain the knots of the +c spline with respect to the teta-variable, i.e. the position +c of the interior knots tt(5),...,tt(nt-4) as well as the +c position of the additional knots tt(1)=...=tt(4)=0 and +c tt(nt-3)=...=tt(nt)=pi needed for the b-spline representation +c if the computation mode iopt=1 is used, the values of tt(1), +c ...,tt(nt) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values tt(5), +c ...tt(nt-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c np : integer. +c unless ier=10 (in case iopt >=0), np will contain the total +c number of knots with respect to the phi-variable, of the +c spline approximation returned. if the computation mode iopt=1 +c is used, the value of np should be left unchanged between +c subsequent calls. +c in case iopt=-1, the value of np (>=9) should be specified +c on entry. +c tp : real array of dimension at least npest. +c on succesful exit, this array will contain the knots of the +c spline with respect to the phi-variable, i.e. the position of +c the interior knots tp(5),...,tp(np-4) as well as the position +c of the additional knots tp(1),...,tp(4) and tp(np-3),..., +c tp(np) needed for the b-spline representation. +c if the computation mode iopt=1 is used, the values of tp(1), +c ...,tp(np) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values tp(5), +c ...tp(np-4) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c c : real array of dimension at least (ntest-4)*(npest-4). +c on succesful exit, c contains the coefficients of the spline +c approximation s(teta,phi). +c fp : real. unless ier=10, fp contains the weighted sum of +c squared residuals of the spline approximation returned. +c wrk1 : real array of dimension (lwrk1). used as workspace. +c if the computation mode iopt=1 is used the value of wrk1(1) +c should be left unchanged between subsequent calls. +c on exit wrk1(2),wrk1(3),...,wrk1(1+ncof) will contain the +c values d(i)/max(d(i)),i=1,...,ncof=6+(np-7)*(nt-8) +c with d(i) the i-th diagonal element of the reduced triangular +c matrix for calculating the b-spline coefficients. it includes +c those elements whose square is less than eps,which are treat- +c ed as 0 in the case of presumed rank deficiency (ier<-2). +c lwrk1 : integer. on entry lwrk1 must specify the actual dimension of +c the array wrk1 as declared in the calling (sub)program. +c lwrk1 must not be too small. let +c u = ntest-7, v = npest-7, then +c lwrk1 >= 185+52*v+10*u+14*u*v+8*(u-1)*v**2+8*m +c wrk2 : real array of dimension (lwrk2). used as workspace, but +c only in the case a rank deficient system is encountered. +c lwrk2 : integer. on entry lwrk2 must specify the actual dimension of +c the array wrk2 as declared in the calling (sub)program. +c lwrk2 > 0 . a save upper bound for lwrk2 = 48+21*v+7*u*v+ +c 4*(u-1)*v**2 where u,v are as above. if there are enough data +c points, scattered uniformly over the approximation domain +c and if the smoothing factor s is not too small, there is a +c good chance that this extra workspace is not needed. a lot +c of memory might therefore be saved by setting lwrk2=1. +c (see also ier > 10) +c iwrk : integer array of dimension (kwrk). used as workspace. +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= m+(ntest-7)*(npest-7). +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is a spherical +c interpolating spline (fp=0). +c ier=-2 : normal return. the spline returned is the weighted least- +c squares constrained polynomial . in this extreme case +c fp gives the upper bound for the smoothing factor s. +c ier<-2 : warning. the coefficients of the spline returned have been +c computed as the minimal norm least-squares solution of a +c (numerically) rank deficient system. (-ier) gives the rank. +c especially if the rank deficiency which can be computed as +c 6+(nt-8)*(np-7)+ier, is large the results may be inaccurate +c they could also seriously depend on the value of eps. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters ntest and +c npest. +c probably causes : ntest or npest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the weighted least-squares +c spherical spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small or badly chosen eps. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=4 : error. no more knots can be added because the dimension +c of the spherical spline 6+(nt-8)*(np-7) already exceeds +c the number of data points m. +c probably causes : either s or m too small. +c the approximation returned is the weighted least-squares +c spherical spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=5 : error. no more knots can be added because the additional +c knot would (quasi) coincide with an old one. +c probably causes : s too small or too large a weight to an +c inaccurate data point. +c the approximation returned is the weighted least-squares +c spherical spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, m>=2, ntest>=8 ,npest >=8, 00, i=1,...,m +c lwrk1 >= 185+52*v+10*u+14*u*v+8*(u-1)*v**2+8*m +c kwrk >= m+(ntest-7)*(npest-7) +c if iopt=-1: 8<=nt<=ntest , 9<=np<=npest +c 0=0: s>=0 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c ier>10 : error. lwrk2 is too small, i.e. there is not enough work- +c space for computing the minimal least-squares solution of +c a rank deficient system of linear equations. ier gives the +c requested value for lwrk2. there is no approximation re- +c turned but, having saved the information contained in nt, +c np,tt,tp,wrk1, and having adjusted the value of lwrk2 and +c the dimension of the array wrk2 accordingly, the user can +c continue at the point the program was left, by calling +c sphere with iopt=1. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the constrained weighted least-squares polynomial if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c r(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in r(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c polynomial and the corresponding upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximation shows more detail) to obtain closer fits. +c to choose s very small is strongly discouraged. this considerably +c increases computation time and memory requirements. it may also +c cause rank-deficiency (ier<-2) and endager numerical stability. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if sphere is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. if the computation mode iopt=1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c sphere once more with the selected value for s but now with iopt=0. +c indeed, sphere may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds ntest and +c npest. indeed, if at a certain stage in sphere the number of knots +c in one direction (say nt) has reached the value of its upper bound +c (ntest), then from that moment on all subsequent knots are added +c in the other (phi) direction. this may indicate that the value of +c ntest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c for example, by setting ntest=8 (the lowest allowable value for +c ntest), the user can indicate that he wants an approximation which +c is a cubic polynomial in the variable teta. +c +c other subroutines required: +c fpback,fpbspl,fpsphe,fpdisc,fpgivs,fprank,fprati,fprota,fporde, +c fprpsp +c +c references: +c dierckx p. : algorithms for smoothing data on the sphere with tensor +c product splines, computing 32 (1984) 319-342. +c dierckx p. : algorithms for smoothing data on the sphere with tensor +c product splines, report tw62, dept. computer science, +c k.u.leuven, 1983. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : july 1983 +c latest update : march 1989 +c +c .. +c ..scalar arguments.. + real*8 s,eps,fp + integer iopt,m,ntest,npest,nt,np,lwrk1,lwrk2,kwrk,ier +c ..array arguments.. + real*8 teta(m),phi(m),r(m),w(m),tt(ntest),tp(npest), + * c((ntest-4)*(npest-4)),wrk1(lwrk1),wrk2(lwrk2) + integer iwrk(kwrk) +c ..local scalars.. + real*8 tol,pi,pi2,one + integer i,ib1,ib3,ki,kn,kwest,la,lbt,lcc,lcs,lro,j + * lbp,lco,lf,lff,lfp,lh,lq,lst,lsp,lwest,maxit,ncest,ncc,ntt, + * npp,nreg,nrint,ncof,nt4,np4 +c ..function references.. + real*8 atan +c ..subroutine references.. +c fpsphe +c .. +c set constants + one = 0.1e+01 +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid,control is immediately repassed to the calling program. + ier = 10 + if(eps.le.0. .or. eps.ge.1.) go to 80 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 80 + if(m.lt.2) go to 80 + if(ntest.lt.8 .or. npest.lt.8) go to 80 + nt4 = ntest-4 + np4 = npest-4 + ncest = nt4*np4 + ntt = ntest-7 + npp = npest-7 + ncc = 6+npp*(ntt-1) + nrint = ntt+npp + nreg = ntt*npp + ncof = 6+3*npp + ib1 = 4*npp + ib3 = ib1+3 + if(ncof.gt.ib1) ib1 = ncof + if(ncof.gt.ib3) ib3 = ncof + lwest = 185+52*npp+10*ntt+14*ntt*npp+8*(m+(ntt-1)*npp**2) + kwest = m+nreg + if(lwrk1.lt.lwest .or. kwrk.lt.kwest) go to 80 + if(iopt.gt.0) go to 60 + pi = atan(one)*4 + pi2 = pi+pi + do 20 i=1,m + if(w(i).le.0.) go to 80 + if(teta(i).lt.0. .or. teta(i).gt.pi) go to 80 + if(phi(i) .lt.0. .or. phi(i).gt.pi2) go to 80 + 20 continue + if(iopt.eq.0) go to 60 + ntt = nt-8 + if(ntt.lt.0 .or. nt.gt.ntest) go to 80 + if(ntt.eq.0) go to 40 + tt(4) = 0. + do 30 i=1,ntt + j = i+4 + if(tt(j).le.tt(j-1) .or. tt(j).ge.pi) go to 80 + 30 continue + 40 npp = np-8 + if(npp.lt.1 .or. np.gt.npest) go to 80 + tp(4) = 0. + do 50 i=1,npp + j = i+4 + if(tp(j).le.tp(j-1) .or. tp(j).ge.pi2) go to 80 + 50 continue + go to 70 + 60 if(s.lt.0.) go to 80 + 70 ier = 0 +c we partition the working space and determine the spline approximation + kn = 1 + ki = kn+m + lq = 2 + la = lq+ncc*ib3 + lf = la+ncc*ib1 + lff = lf+ncc + lfp = lff+ncest + lco = lfp+nrint + lh = lco+nrint + lbt = lh+ib3 + lbp = lbt+5*ntest + lro = lbp+5*npest + lcc = lro+npest + lcs = lcc+npest + lst = lcs+npest + lsp = lst+m*4 + call fpsphe(iopt,m,teta,phi,r,w,s,ntest,npest,eps,tol,maxit, + * ib1,ib3,ncest,ncc,nrint,nreg,nt,tt,np,tp,c,fp,wrk1(1),wrk1(lfp), + * wrk1(lco),wrk1(lf),wrk1(lff),wrk1(lro),wrk1(lcc),wrk1(lcs), + * wrk1(la),wrk1(lq),wrk1(lbt),wrk1(lbp),wrk1(lst),wrk1(lsp), + * wrk1(lh),iwrk(ki),iwrk(kn),wrk2,lwrk2,ier) + 80 return + end + Added: branches/Interpolate1D/fitpack/splder.f =================================================================== --- branches/Interpolate1D/fitpack/splder.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/splder.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,162 @@ + subroutine splder(t,n,c,k,nu,x,y,m,wrk,ier) +c subroutine splder evaluates in a number of points x(i),i=1,2,...,m +c the derivative of order nu of a spline s(x) of degree k,given in +c its b-spline representation. +c +c calling sequence: +c call splder(t,n,c,k,nu,x,y,m,wrk,ier) +c +c input parameters: +c t : array,length n, which contains the position of the knots. +c n : integer, giving the total number of knots of s(x). +c c : array,length n, which contains the b-spline coefficients. +c k : integer, giving the degree of s(x). +c nu : integer, specifying the order of the derivative. 0<=nu<=k +c x : array,length m, which contains the points where the deriv- +c ative of s(x) must be evaluated. +c m : integer, giving the number of points where the derivative +c of s(x) must be evaluated +c wrk : real array of dimension n. used as working space. +c +c output parameters: +c y : array,length m, giving the value of the derivative of s(x) +c at the different points. +c ier : error flag +c ier = 0 : normal return +c ier =10 : invalid input data (see restrictions) +c +c restrictions: +c 0 <= nu <= k +c m >= 1 +c t(k+1) <= x(i) <= x(i+1) <= t(n-k) , i=1,2,...,m-1. +c +c other subroutines required: fpbspl +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c++ pearu: 13 aug 20003 +c++ - disabled cliping x values to interval [min(t),max(t)] +c++ - removed the restriction of the orderness of x values +c++ - fixed initialization of sp to double precision value +c +c ..scalar arguments.. + integer n,k,nu,m,ier +c ..array arguments.. + real*8 t(n),c(n),x(m),y(m),wrk(n) +c ..local scalars.. + integer i,j,kk,k1,k2,l,ll,l1,l2,nk1,nk2,nn + real*8 ak,arg,fac,sp,tb,te +c++.. + integer k3 +c..++ +c ..local arrays .. + real*8 h(6) +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + if(nu.lt.0 .or. nu.gt.k) go to 200 +c-- if(m-1) 200,30,10 +c++.. + if(m.lt.1) go to 200 +c..++ +c-- 10 do 20 i=2,m +c-- if(x(i).lt.x(i-1)) go to 200 +c-- 20 continue + 30 ier = 0 +c fetch tb and te, the boundaries of the approximation interval. + k1 = k+1 + k3 = k1+1 + nk1 = n-k1 + tb = t(k1) + te = t(nk1+1) +c the derivative of order nu of a spline of degree k is a spline of +c degree k-nu,the b-spline coefficients wrk(i) of which can be found +c using the recurrence scheme of de boor. + l = 1 + kk = k + nn = n + do 40 i=1,nk1 + wrk(i) = c(i) + 40 continue + if(nu.eq.0) go to 100 + nk2 = nk1 + do 60 j=1,nu + ak = kk + nk2 = nk2-1 + l1 = l + do 50 i=1,nk2 + l1 = l1+1 + l2 = l1+kk + fac = t(l2)-t(l1) + if(fac.le.0.) go to 50 + wrk(i) = ak*(wrk(i+1)-wrk(i))/fac + 50 continue + l = l+1 + kk = kk-1 + 60 continue + if(kk.ne.0) go to 100 +c if nu=k the derivative is a piecewise constant function + j = 1 + do 90 i=1,m + arg = x(i) +c++.. + 65 if(arg.ge.t(l) .or. l+1.eq.k2) go to 70 + l1 = l + l = l-1 + j = j-1 + go to 65 +c..++ + 70 if(arg.lt.t(l+1) .or. l.eq.nk1) go to 80 + l = l+1 + j = j+1 + go to 70 + 80 y(i) = wrk(j) + 90 continue + go to 200 + 100 l = k1 + l1 = l+1 + k2 = k1-nu +c main loop for the different points. + do 180 i=1,m +c fetch a new x-value arg. + arg = x(i) +c-- if(arg.lt.tb) arg = tb +c-- if(arg.gt.te) arg = te +c search for knot interval t(l) <= arg < t(l+1) +c++.. + 135 if(arg.ge.t(l) .or. l1.eq.k3) go to 140 + l1 = l + l = l-1 + go to 135 +c..++ + 140 if(arg.lt.t(l1) .or. l.eq.nk1) go to 150 + l = l1 + l1 = l+1 + go to 140 +c evaluate the non-zero b-splines of degree k-nu at arg. + 150 call fpbspl(t,n,kk,arg,l,h) +c find the value of the derivative at x=arg. + sp = 0.0d0 + ll = l-k1 + do 160 j=1,k2 + ll = ll+1 + sp = sp+wrk(ll)*h(j) + 160 continue + y(i) = sp + 180 continue + 200 return + end Added: branches/Interpolate1D/fitpack/splev.f =================================================================== --- branches/Interpolate1D/fitpack/splev.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/splev.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,115 @@ + subroutine splev(t,n,c,k,x,y,m,ier) +c subroutine splev evaluates in a number of points x(i),i=1,2,...,m +c a spline s(x) of degree k, given in its b-spline representation. +c +c calling sequence: +c call splev(t,n,c,k,x,y,m,ier) +c +c input parameters: +c t : array,length n, which contains the position of the knots. +c n : integer, giving the total number of knots of s(x). +c c : array,length n, which contains the b-spline coefficients. +c k : integer, giving the degree of s(x). +c x : array,length m, which contains the points where s(x) must +c be evaluated. +c m : integer, giving the number of points where s(x) must be +c evaluated. +c +c output parameter: +c y : array,length m, giving the value of s(x) at the different +c points. +c ier : error flag +c ier = 0 : normal return +c ier =10 : invalid input data (see restrictions) +c +c restrictions: +c m >= 1 +c-- t(k+1) <= x(i) <= x(i+1) <= t(n-k) , i=1,2,...,m-1. +c +c other subroutines required: fpbspl. +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c++ pearu: 11 aug 2003 +c++ - disabled cliping x values to interval [min(t),max(t)] +c++ - removed the restriction of the orderness of x values +c++ - fixed initialization of sp to double precision value +c +c ..scalar arguments.. + integer n,k,m,ier +c ..array arguments.. + real*8 t(n),c(n),x(m),y(m) +c ..local scalars.. + integer i,j,k1,l,ll,l1,nk1 +c++.. + integer k2 +c..++ + real*8 arg,sp,tb,te +c ..local array.. + real*8 h(20) +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 +c-- if(m-1) 100,30,10 +c++.. + if(m.lt.1) go to 100 +c..++ +c-- 10 do 20 i=2,m +c-- if(x(i).lt.x(i-1)) go to 100 +c-- 20 continue + 30 ier = 0 +c fetch tb and te, the boundaries of the approximation interval. + k1 = k+1 +c++.. + k2 = k1+1 +c..++ + nk1 = n-k1 + tb = t(k1) + te = t(nk1+1) + l = k1 + l1 = l+1 +c main loop for the different points. + do 80 i=1,m +c fetch a new x-value arg. + arg = x(i) +c-- if(arg.lt.tb) arg = tb +c-- if(arg.gt.te) arg = te +c search for knot interval t(l) <= arg < t(l+1) +c++.. + 35 if(arg.ge.t(l) .or. l1.eq.k2) go to 40 + l1 = l + l = l-1 + go to 35 +c..++ + 40 if(arg.lt.t(l1) .or. l.eq.nk1) go to 50 + l = l1 + l1 = l+1 + go to 40 +c evaluate the non-zero b-splines at arg. + 50 call fpbspl(t,n,k,arg,l,h) +c find the value of s(x) at x=arg. + sp = 0.0d0 + ll = l-k1 + do 60 j=1,k1 + ll = ll+1 + sp = sp+c(ll)*h(j) + 60 continue + y(i) = sp + 80 continue + 100 return + end Added: branches/Interpolate1D/fitpack/splint.f =================================================================== --- branches/Interpolate1D/fitpack/splint.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/splint.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,58 @@ + real*8 function splint(t,n,c,k,a,b,wrk) +c function splint calculates the integral of a spline function s(x) +c of degree k, which is given in its normalized b-spline representation +c +c calling sequence: +c aint = splint(t,n,c,k,a,b,wrk) +c +c input parameters: +c t : array,length n,which contains the position of the knots +c of s(x). +c n : integer, giving the total number of knots of s(x). +c c : array,length n, containing the b-spline coefficients. +c k : integer, giving the degree of s(x). +c a,b : real values, containing the end points of the integration +c interval. s(x) is considered to be identically zero outside +c the interval (t(k+1),t(n-k)). +c +c output parameter: +c aint : real, containing the integral of s(x) between a and b. +c wrk : real array, length n. used as working space +c on output, wrk will contain the integrals of the normalized +c b-splines defined on the set of knots. +c +c other subroutines required: fpintb. +c +c references : +c gaffney p.w. : the calculation of indefinite integrals of b-splines +c j. inst. maths applics 17 (1976) 37-41. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + real*8 a,b + integer n,k +c ..array arguments.. + real*8 t(n),c(n),wrk(n) +c ..local scalars.. + integer i,nk1 +c .. + nk1 = n-k-1 +c calculate the integrals wrk(i) of the normalized b-splines +c ni,k+1(x), i=1,2,...nk1. + call fpintb(t,n,wrk,nk1,a,b) +c calculate the integral of s(x). + splint = 0.0d0 + do 10 i=1,nk1 + splint = splint+c(i)*wrk(i) + 10 continue + return + end Added: branches/Interpolate1D/fitpack/sproot.f =================================================================== --- branches/Interpolate1D/fitpack/sproot.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/sproot.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,183 @@ + subroutine sproot(t,n,c,zero,mest,m,ier) +c subroutine sproot finds the zeros of a cubic spline s(x),which is +c given in its normalized b-spline representation. +c +c calling sequence: +c call sproot(t,n,c,zero,mest,m,ier) +c +c input parameters: +c t : real array,length n, containing the knots of s(x). +c n : integer, containing the number of knots. n>=8 +c c : real array,length n, containing the b-spline coefficients. +c mest : integer, specifying the dimension of array zero. +c +c output parameters: +c zero : real array,lenth mest, containing the zeros of s(x). +c m : integer,giving the number of zeros. +c ier : error flag: +c ier = 0: normal return. +c ier = 1: the number of zeros exceeds mest. +c ier =10: invalid input data (see restrictions). +c +c other subroutines required: fpcuro +c +c restrictions: +c 1) n>= 8. +c 2) t(4) < t(5) < ... < t(n-4) < t(n-3). +c t(1) <= t(2) <= t(3) <= t(4) +c t(n-3) <= t(n-2) <= t(n-1) <= t(n) +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + integer n,mest,m,ier +c ..array arguments.. + real*8 t(n),c(n),zero(mest) +c ..local scalars.. + integer i,j,j1,l,n4 + real*8 ah,a0,a1,a2,a3,bh,b0,b1,c1,c2,c3,c4,c5,d4,d5,h1,h2, + * three,two,t1,t2,t3,t4,t5,zz + logical z0,z1,z2,z3,z4,nz0,nz1,nz2,nz3,nz4 +c ..local array.. + real*8 y(3) +c .. +c set some constants + two = 0.2d+01 + three = 0.3d+01 +c before starting computations a data check is made. if the input data +c are invalid, control is immediately repassed to the calling program. + n4 = n-4 + ier = 10 + if(n.lt.8) go to 800 + j = n + do 10 i=1,3 + if(t(i).gt.t(i+1)) go to 800 + if(t(j).lt.t(j-1)) go to 800 + j = j-1 + 10 continue + do 20 i=4,n4 + if(t(i).ge.t(i+1)) go to 800 + 20 continue +c the problem considered reduces to finding the zeros of the cubic +c polynomials pl(x) which define the cubic spline in each knot +c interval t(l)<=x<=t(l+1). a zero of pl(x) is also a zero of s(x) on +c the condition that it belongs to the knot interval. +c the cubic polynomial pl(x) is determined by computing s(t(l)), +c s'(t(l)),s(t(l+1)) and s'(t(l+1)). in fact we only have to compute +c s(t(l+1)) and s'(t(l+1)); because of the continuity conditions of +c splines and their derivatives, the value of s(t(l)) and s'(t(l)) +c is already known from the foregoing knot interval. + ier = 0 +c evaluate some constants for the first knot interval + h1 = t(4)-t(3) + h2 = t(5)-t(4) + t1 = t(4)-t(2) + t2 = t(5)-t(3) + t3 = t(6)-t(4) + t4 = t(5)-t(2) + t5 = t(6)-t(3) +c calculate a0 = s(t(4)) and ah = s'(t(4)). + c1 = c(1) + c2 = c(2) + c3 = c(3) + c4 = (c2-c1)/t4 + c5 = (c3-c2)/t5 + d4 = (h2*c1+t1*c2)/t4 + d5 = (t3*c2+h1*c3)/t5 + a0 = (h2*d4+h1*d5)/t2 + ah = three*(h2*c4+h1*c5)/t2 + z1 = .true. + if(ah.lt.0.0d0) z1 = .false. + nz1 = .not.z1 + m = 0 +c main loop for the different knot intervals. + do 300 l=4,n4 +c evaluate some constants for the knot interval t(l) <= x <= t(l+1). + h1 = h2 + h2 = t(l+2)-t(l+1) + t1 = t2 + t2 = t3 + t3 = t(l+3)-t(l+1) + t4 = t5 + t5 = t(l+3)-t(l) +c find a0 = s(t(l)), ah = s'(t(l)), b0 = s(t(l+1)) and bh = s'(t(l+1)). + c1 = c2 + c2 = c3 + c3 = c(l) + c4 = c5 + c5 = (c3-c2)/t5 + d4 = (h2*c1+t1*c2)/t4 + d5 = (h1*c3+t3*c2)/t5 + b0 = (h2*d4+h1*d5)/t2 + bh = three*(h2*c4+h1*c5)/t2 +c calculate the coefficients a0,a1,a2 and a3 of the cubic polynomial +c pl(x) = ql(y) = a0+a1*y+a2*y**2+a3*y**3 ; y = (x-t(l))/(t(l+1)-t(l)). + a1 = ah*h1 + b1 = bh*h1 + a2 = three*(b0-a0)-b1-two*a1 + a3 = two*(a0-b0)+b1+a1 +c test whether or not pl(x) could have a zero in the range +c t(l) <= x <= t(l+1). + z3 = .true. + if(b1.lt.0.0d0) z3 = .false. + nz3 = .not.z3 + if(a0*b0.le.0.0d0) go to 100 + z0 = .true. + if(a0.lt.0.0d0) z0 = .false. + nz0 = .not.z0 + z2 = .true. + if(a2.lt.0.) z2 = .false. + nz2 = .not.z2 + z4 = .true. + if(3.0d0*a3+a2.lt.0.0d0) z4 = .false. + nz4 = .not.z4 + if(.not.((z0.and.(nz1.and.(z3.or.z2.and.nz4).or.nz2.and. + * z3.and.z4).or.nz0.and.(z1.and.(nz3.or.nz2.and.z4).or.z2.and. + * nz3.and.nz4))))go to 200 +c find the zeros of ql(y). + 100 call fpcuro(a3,a2,a1,a0,y,j) + if(j.eq.0) go to 200 +c find which zeros of pl(x) are zeros of s(x). + do 150 i=1,j + if(y(i).lt.0.0d0 .or. y(i).gt.1.0d0) go to 150 +c test whether the number of zeros of s(x) exceeds mest. + if(m.ge.mest) go to 700 + m = m+1 + zero(m) = t(l)+h1*y(i) + 150 continue + 200 a0 = b0 + ah = bh + z1 = z3 + nz1 = nz3 + 300 continue +c the zeros of s(x) are arranged in increasing order. + if(m.lt.2) go to 800 + do 400 i=2,m + j = i + 350 j1 = j-1 + if(j1.eq.0) go to 400 + if(zero(j).ge.zero(j1)) go to 400 + zz = zero(j) + zero(j) = zero(j1) + zero(j1) = zz + j = j1 + go to 350 + 400 continue + j = m + m = 1 + do 500 i=2,j + if(zero(i).eq.zero(m)) go to 500 + m = m+1 + zero(m) = zero(i) + 500 continue + go to 800 + 700 ier = 1 + 800 return + end Added: branches/Interpolate1D/fitpack/surev.f =================================================================== --- branches/Interpolate1D/fitpack/surev.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/surev.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,106 @@ + subroutine surev(idim,tu,nu,tv,nv,c,u,mu,v,mv,f,mf,wrk,lwrk, + * iwrk,kwrk,ier) +c subroutine surev evaluates on a grid (u(i),v(j)),i=1,...,mu; j=1,... +c ,mv a bicubic spline surface of dimension idim, given in the +c b-spline representation. +c +c calling sequence: +c call surev(idim,tu,nu,tv,nv,c,u,mu,v,mv,f,mf,wrk,lwrk, +c * iwrk,kwrk,ier) +c +c input parameters: +c idim : integer, specifying the dimension of the spline surface. +c tu : real array, length nu, which contains the position of the +c knots in the u-direction. +c nu : integer, giving the total number of knots in the u-direction +c tv : real array, length nv, which contains the position of the +c knots in the v-direction. +c nv : integer, giving the total number of knots in the v-direction +c c : real array, length (nu-4)*(nv-4)*idim, which contains the +c b-spline coefficients. +c u : real array of dimension (mu). +c before entry u(i) must be set to the u co-ordinate of the +c i-th grid point along the u-axis. +c tu(4)<=u(i-1)<=u(i)<=tu(nu-3), i=2,...,mu. +c mu : on entry mu must specify the number of grid points along +c the u-axis. mu >=1. +c v : real array of dimension (mv). +c before entry v(j) must be set to the v co-ordinate of the +c j-th grid point along the v-axis. +c tv(4)<=v(j-1)<=v(j)<=tv(nv-3), j=2,...,mv. +c mv : on entry mv must specify the number of grid points along +c the v-axis. mv >=1. +c mf : on entry, mf must specify the dimension of the array f. +c mf >= mu*mv*idim +c wrk : real array of dimension lwrk. used as workspace. +c lwrk : integer, specifying the dimension of wrk. +c lwrk >= 4*(mu+mv) +c iwrk : integer array of dimension kwrk. used as workspace. +c kwrk : integer, specifying the dimension of iwrk. kwrk >= mu+mv. +c +c output parameters: +c f : real array of dimension (mf). +c on succesful exit f(mu*mv*(l-1)+mv*(i-1)+j) contains the +c l-th co-ordinate of the bicubic spline surface at the +c point (u(i),v(j)),l=1,...,idim,i=1,...,mu;j=1,...,mv. +c ier : integer error flag +c ier=0 : normal return +c ier=10: invalid input data (see restrictions) +c +c restrictions: +c mu >=1, mv >=1, lwrk>=4*(mu+mv), kwrk>=mu+mv , mf>=mu*mv*idim +c tu(4) <= u(i-1) <= u(i) <= tu(nu-3), i=2,...,mu +c tv(4) <= v(j-1) <= v(j) <= tv(nv-3), j=2,...,mv +c +c other subroutines required: +c fpsuev,fpbspl +c +c references : +c de boor c : on calculating with b-splines, j. approximation theory +c 6 (1972) 50-62. +c cox m.g. : the numerical evaluation of b-splines, j. inst. maths +c applics 10 (1972) 134-149. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author : +c p.dierckx +c dept. computer science, k.u.leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c latest update : march 1987 +c +c ..scalar arguments.. + integer idim,nu,nv,mu,mv,mf,lwrk,kwrk,ier +c ..array arguments.. + integer iwrk(kwrk) + real*8 tu(nu),tv(nv),c((nu-4)*(nv-4)*idim),u(mu),v(mv),f(mf), + * wrk(lwrk) +c ..local scalars.. + integer i,muv +c .. +c before starting computations a data check is made. if the input data +c are invalid control is immediately repassed to the calling program. + ier = 10 + if(mf.lt.mu*mv*idim) go to 100 + muv = mu+mv + if(lwrk.lt.4*muv) go to 100 + if(kwrk.lt.muv) go to 100 + if (mu.lt.1) go to 100 + if (mu.eq.1) go to 30 + go to 10 + 10 do 20 i=2,mu + if(u(i).lt.u(i-1)) go to 100 + 20 continue + 30 if (mv.lt.1) go to 100 + if (mv.eq.1) go to 60 + go to 40 + 40 do 50 i=2,mv + if(v(i).lt.v(i-1)) go to 100 + 50 continue + 60 ier = 0 + call fpsuev(idim,tu,nu,tv,nv,c,u,mu,v,mv,f,wrk(1),wrk(4*mu+1), + * iwrk(1),iwrk(mu+1)) + 100 return + end Added: branches/Interpolate1D/fitpack/surfit.f =================================================================== --- branches/Interpolate1D/fitpack/surfit.f 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack/surfit.f 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,412 @@ + subroutine surfit(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest, + * nmax,eps,nx,tx,ny,ty,c,fp,wrk1,lwrk1,wrk2,lwrk2,iwrk,kwrk,ier) +c given the set of data points (x(i),y(i),z(i)) and the set of positive +c numbers w(i),i=1,...,m, subroutine surfit determines a smooth bivar- +c iate spline approximation s(x,y) of degrees kx and ky on the rect- +c angle xb <= x <= xe, yb <= y <= ye. +c if iopt = -1 surfit calculates the weighted least-squares spline +c according to a given set of knots. +c if iopt >= 0 the total numbers nx and ny of these knots and their +c position tx(j),j=1,...,nx and ty(j),j=1,...,ny are chosen automatic- +c ally by the routine. the smoothness of s(x,y) is then achieved by +c minimalizing the discontinuity jumps in the derivatives of s(x,y) +c across the boundaries of the subpanels (tx(i),tx(i+1))*(ty(j),ty(j+1). +c the amounth of smoothness is determined by the condition that f(p) = +c sum ((w(i)*(z(i)-s(x(i),y(i))))**2) be <= s, with s a given non-neg- +c ative constant, called the smoothing factor. +c the fit is given in the b-spline representation (b-spline coefficients +c c((ny-ky-1)*(i-1)+j),i=1,...,nx-kx-1;j=1,...,ny-ky-1) and can be eval- +c uated by means of subroutine bispev. +c +c calling sequence: +c call surfit(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest, +c * nmax,eps,nx,tx,ny,ty,c,fp,wrk1,lwrk1,wrk2,lwrk2,iwrk,kwrk,ier) +c +c parameters: +c iopt : integer flag. on entry iopt must specify whether a weighted +c least-squares spline (iopt=-1) or a smoothing spline (iopt=0 +c or 1) must be determined. +c if iopt=0 the routine will start with an initial set of knots +c tx(i)=xb,tx(i+kx+1)=xe,i=1,...,kx+1;ty(i)=yb,ty(i+ky+1)=ye,i= +c 1,...,ky+1. if iopt=1 the routine will continue with the set +c of knots found at the last call of the routine. +c attention: a call with iopt=1 must always be immediately pre- +c ceded by another call with iopt=1 or iopt=0. +c unchanged on exit. +c m : integer. on entry m must specify the number of data points. +c m >= (kx+1)*(ky+1). unchanged on exit. +c x : real array of dimension at least (m). +c y : real array of dimension at least (m). +c z : real array of dimension at least (m). +c before entry, x(i),y(i),z(i) must be set to the co-ordinates +c of the i-th data point, for i=1,...,m. the order of the data +c points is immaterial. unchanged on exit. +c w : real array of dimension at least (m). before entry, w(i) must +c be set to the i-th value in the set of weights. the w(i) must +c be strictly positive. unchanged on exit. +c xb,xe : real values. on entry xb,xe,yb and ye must specify the bound- +c yb,ye aries of the rectangular approximation domain. +c xb<=x(i)<=xe,yb<=y(i)<=ye,i=1,...,m. unchanged on exit. +c kx,ky : integer values. on entry kx and ky must specify the degrees +c of the spline. 1<=kx,ky<=5. it is recommended to use bicubic +c (kx=ky=3) splines. unchanged on exit. +c s : real. on entry (in case iopt>=0) s must specify the smoothing +c factor. s >=0. unchanged on exit. +c for advice on the choice of s see further comments +c nxest : integer. unchanged on exit. +c nyest : integer. unchanged on exit. +c on entry, nxest and nyest must specify an upper bound for the +c number of knots required in the x- and y-directions respect. +c these numbers will also determine the storage space needed by +c the routine. nxest >= 2*(kx+1), nyest >= 2*(ky+1). +c in most practical situation nxest = kx+1+sqrt(m/2), nyest = +c ky+1+sqrt(m/2) will be sufficient. see also further comments. +c nmax : integer. on entry nmax must specify the actual dimension of +c the arrays tx and ty. nmax >= nxest, nmax >=nyest. +c unchanged on exit. +c eps : real. +c on entry, eps must specify a threshold for determining the +c effective rank of an over-determined linear system of equat- +c ions. 0 < eps < 1. if the number of decimal digits in the +c computer representation of a real number is q, then 10**(-q) +c is a suitable value for eps in most practical applications. +c unchanged on exit. +c nx : integer. +c unless ier=10 (in case iopt >=0), nx will contain the total +c number of knots with respect to the x-variable, of the spline +c approximation returned. if the computation mode iopt=1 is +c used, the value of nx should be left unchanged between sub- +c sequent calls. +c in case iopt=-1, the value of nx should be specified on entry +c tx : real array of dimension nmax. +c on succesful exit, this array will contain the knots of the +c spline with respect to the x-variable, i.e. the position of +c the interior knots tx(kx+2),...,tx(nx-kx-1) as well as the +c position of the additional knots tx(1)=...=tx(kx+1)=xb and +c tx(nx-kx)=...=tx(nx)=xe needed for the b-spline representat. +c if the computation mode iopt=1 is used, the values of tx(1), +c ...,tx(nx) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values tx(kx+2), +c ...tx(nx-kx-1) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c ny : integer. +c unless ier=10 (in case iopt >=0), ny will contain the total +c number of knots with respect to the y-variable, of the spline +c approximation returned. if the computation mode iopt=1 is +c used, the value of ny should be left unchanged between sub- +c sequent calls. +c in case iopt=-1, the value of ny should be specified on entry +c ty : real array of dimension nmax. +c on succesful exit, this array will contain the knots of the +c spline with respect to the y-variable, i.e. the position of +c the interior knots ty(ky+2),...,ty(ny-ky-1) as well as the +c position of the additional knots ty(1)=...=ty(ky+1)=yb and +c ty(ny-ky)=...=ty(ny)=ye needed for the b-spline representat. +c if the computation mode iopt=1 is used, the values of ty(1), +c ...,ty(ny) should be left unchanged between subsequent calls. +c if the computation mode iopt=-1 is used, the values ty(ky+2), +c ...ty(ny-ky-1) must be supplied by the user, before entry. +c see also the restrictions (ier=10). +c c : real array of dimension at least (nxest-kx-1)*(nyest-ky-1). +c on succesful exit, c contains the coefficients of the spline +c approximation s(x,y) +c fp : real. unless ier=10, fp contains the weighted sum of +c squared residuals of the spline approximation returned. +c wrk1 : real array of dimension (lwrk1). used as workspace. +c if the computation mode iopt=1 is used the value of wrk1(1) +c should be left unchanged between subsequent calls. +c on exit wrk1(2),wrk1(3),...,wrk1(1+(nx-kx-1)*(ny-ky-1)) will +c contain the values d(i)/max(d(i)),i=1,...,(nx-kx-1)*(ny-ky-1) +c with d(i) the i-th diagonal element of the reduced triangular +c matrix for calculating the b-spline coefficients. it includes +c those elements whose square is less than eps,which are treat- +c ed as 0 in the case of presumed rank deficiency (ier<-2). +c lwrk1 : integer. on entry lwrk1 must specify the actual dimension of +c the array wrk1 as declared in the calling (sub)program. +c lwrk1 must not be too small. let +c u = nxest-kx-1, v = nyest-ky-1, km = max(kx,ky)+1, +c ne = max(nxest,nyest), bx = kx*v+ky+1, by = ky*u+kx+1, +c if(bx.le.by) b1 = bx, b2 = b1+v-ky +c if(bx.gt.by) b1 = by, b2 = b1+u-kx then +c lwrk1 >= u*v*(2+b1+b2)+2*(u+v+km*(m+ne)+ne-kx-ky)+b2+1 +c wrk2 : real array of dimension (lwrk2). used as workspace, but +c only in the case a rank deficient system is encountered. +c lwrk2 : integer. on entry lwrk2 must specify the actual dimension of +c the array wrk2 as declared in the calling (sub)program. +c lwrk2 > 0 . a save upper boundfor lwrk2 = u*v*(b2+1)+b2 +c where u,v and b2 are as above. if there are enough data +c points, scattered uniformly over the approximation domain +c and if the smoothing factor s is not too small, there is a +c good chance that this extra workspace is not needed. a lot +c of memory might therefore be saved by setting lwrk2=1. +c (see also ier > 10) +c iwrk : integer array of dimension (kwrk). used as workspace. +c kwrk : integer. on entry kwrk must specify the actual dimension of +c the array iwrk as declared in the calling (sub)program. +c kwrk >= m+(nxest-2*kx-1)*(nyest-2*ky-1). +c ier : integer. unless the routine detects an error, ier contains a +c non-positive value on exit, i.e. +c ier=0 : normal return. the spline returned has a residual sum of +c squares fp such that abs(fp-s)/s <= tol with tol a relat- +c ive tolerance set to 0.001 by the program. +c ier=-1 : normal return. the spline returned is an interpolating +c spline (fp=0). +c ier=-2 : normal return. the spline returned is the weighted least- +c squares polynomial of degrees kx and ky. in this extreme +c case fp gives the upper bound for the smoothing factor s. +c ier<-2 : warning. the coefficients of the spline returned have been +c computed as the minimal norm least-squares solution of a +c (numerically) rank deficient system. (-ier) gives the rank. +c especially if the rank deficiency which can be computed as +c (nx-kx-1)*(ny-ky-1)+ier, is large the results may be inac- +c curate. they could also seriously depend on the value of +c eps. +c ier=1 : error. the required storage space exceeds the available +c storage space, as specified by the parameters nxest and +c nyest. +c probably causes : nxest or nyest too small. if these param- +c eters are already large, it may also indicate that s is +c too small +c the approximation returned is the weighted least-squares +c spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=2 : error. a theoretically impossible result was found during +c the iteration proces for finding a smoothing spline with +c fp = s. probably causes : s too small or badly chosen eps. +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=3 : error. the maximal number of iterations maxit (set to 20 +c by the program) allowed for finding a smoothing spline +c with fp=s has been reached. probably causes : s too small +c there is an approximation returned but the corresponding +c weighted sum of squared residuals does not satisfy the +c condition abs(fp-s)/s < tol. +c ier=4 : error. no more knots can be added because the number of +c b-spline coefficients (nx-kx-1)*(ny-ky-1) already exceeds +c the number of data points m. +c probably causes : either s or m too small. +c the approximation returned is the weighted least-squares +c spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=5 : error. no more knots can be added because the additional +c knot would (quasi) coincide with an old one. +c probably causes : s too small or too large a weight to an +c inaccurate data point. +c the approximation returned is the weighted least-squares +c spline according to the current set of knots. +c the parameter fp gives the corresponding weighted sum of +c squared residuals (fp>s). +c ier=10 : error. on entry, the input data are controlled on validity +c the following restrictions must be satisfied. +c -1<=iopt<=1, 1<=kx,ky<=5, m>=(kx+1)*(ky+1), nxest>=2*kx+2, +c nyest>=2*ky+2, 0=nxest, nmax>=nyest, +c xb<=x(i)<=xe, yb<=y(i)<=ye, w(i)>0, i=1,...,m +c lwrk1 >= u*v*(2+b1+b2)+2*(u+v+km*(m+ne)+ne-kx-ky)+b2+1 +c kwrk >= m+(nxest-2*kx-1)*(nyest-2*ky-1) +c if iopt=-1: 2*kx+2<=nx<=nxest +c xb=0: s>=0 +c if one of these conditions is found to be violated,control +c is immediately repassed to the calling program. in that +c case there is no approximation returned. +c ier>10 : error. lwrk2 is too small, i.e. there is not enough work- +c space for computing the minimal least-squares solution of +c a rank deficient system of linear equations. ier gives the +c requested value for lwrk2. there is no approximation re- +c turned but, having saved the information contained in nx, +c ny,tx,ty,wrk1, and having adjusted the value of lwrk2 and +c the dimension of the array wrk2 accordingly, the user can +c continue at the point the program was left, by calling +c surfit with iopt=1. +c +c further comments: +c by means of the parameter s, the user can control the tradeoff +c between closeness of fit and smoothness of fit of the approximation. +c if s is too large, the spline will be too smooth and signal will be +c lost ; if s is too small the spline will pick up too much noise. in +c the extreme cases the program will return an interpolating spline if +c s=0 and the weighted least-squares polynomial (degrees kx,ky)if s is +c very large. between these extremes, a properly chosen s will result +c in a good compromise between closeness of fit and smoothness of fit. +c to decide whether an approximation, corresponding to a certain s is +c satisfactory the user is highly recommended to inspect the fits +c graphically. +c recommended values for s depend on the weights w(i). if these are +c taken as 1/d(i) with d(i) an estimate of the standard deviation of +c z(i), a good s-value should be found in the range (m-sqrt(2*m),m+ +c sqrt(2*m)). if nothing is known about the statistical error in z(i) +c each w(i) can be set equal to one and s determined by trial and +c error, taking account of the comments above. the best is then to +c start with a very large value of s ( to determine the least-squares +c polynomial and the corresponding upper bound fp0 for s) and then to +c progressively decrease the value of s ( say by a factor 10 in the +c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the +c approximation shows more detail) to obtain closer fits. +c to choose s very small is strongly discouraged. this considerably +c increases computation time and memory requirements. it may also +c cause rank-deficiency (ier<-2) and endager numerical stability. +c to economize the search for a good s-value the program provides with +c different modes of computation. at the first call of the routine, or +c whenever he wants to restart with the initial set of knots the user +c must set iopt=0. +c if iopt=1 the program will continue with the set of knots found at +c the last call of the routine. this will save a lot of computation +c time if surfit is called repeatedly for different values of s. +c the number of knots of the spline returned and their location will +c depend on the value of s and on the complexity of the shape of the +c function underlying the data. if the computation mode iopt=1 +c is used, the knots returned may also depend on the s-values at +c previous calls (if these were smaller). therefore, if after a number +c of trials with different s-values and iopt=1, the user can finally +c accept a fit as satisfactory, it may be worthwhile for him to call +c surfit once more with the selected value for s but now with iopt=0. +c indeed, surfit may then return an approximation of the same quality +c of fit but with fewer knots and therefore better if data reduction +c is also an important objective for the user. +c the number of knots may also depend on the upper bounds nxest and +c nyest. indeed, if at a certain stage in surfit the number of knots +c in one direction (say nx) has reached the value of its upper bound +c (nxest), then from that moment on all subsequent knots are added +c in the other (y) direction. this may indicate that the value of +c nxest is too small. on the other hand, it gives the user the option +c of limiting the number of knots the routine locates in any direction +c for example, by setting nxest=2*kx+2 (the lowest allowable value for +c nxest), the user can indicate that he wants an approximation which +c is a simple polynomial of degree kx in the variable x. +c +c other subroutines required: +c fpback,fpbspl,fpsurf,fpdisc,fpgivs,fprank,fprati,fprota,fporde +c +c references: +c dierckx p. : an algorithm for surface fitting with spline functions +c ima j. numer. anal. 1 (1981) 267-283. +c dierckx p. : an algorithm for surface fitting with spline functions +c report tw50, dept. computer science,k.u.leuven, 1980. +c dierckx p. : curve and surface fitting with splines, monographs on +c numerical analysis, oxford university press, 1993. +c +c author: +c p.dierckx +c dept. computer science, k.u. leuven +c celestijnenlaan 200a, b-3001 heverlee, belgium. +c e-mail : Paul.Dierckx at cs.kuleuven.ac.be +c +c creation date : may 1979 +c latest update : march 1987 +c +c .. +c ..scalar arguments.. + real*8 xb,xe,yb,ye,s,eps,fp + integer iopt,m,kx,ky,nxest,nyest,nmax,nx,ny,lwrk1,lwrk2,kwrk,ier +c ..array arguments.. + real*8 x(m),y(m),z(m),w(m),tx(nmax),ty(nmax), + * c((nxest-kx-1)*(nyest-ky-1)),wrk1(lwrk1),wrk2(lwrk2) + integer iwrk(kwrk) +c ..local scalars.. + real*8 tol + integer i,ib1,ib3,jb1,ki,kmax,km1,km2,kn,kwest,kx1,ky1,la,lbx, + * lby,lco,lf,lff,lfp,lh,lq,lsx,lsy,lwest,maxit,ncest,nest,nek, + * nminx,nminy,nmx,nmy,nreg,nrint,nxk,nyk +c ..function references.. + integer max0 +c ..subroutine references.. +c fpsurf +c .. +c we set up the parameters tol and maxit. + maxit = 20 + tol = 0.1e-02 +c before starting computations a data check is made. if the input data +c are invalid,control is immediately repassed to the calling program. + ier = 10 + if(eps.le.0. .or. eps.ge.1.) go to 71 + if(kx.le.0 .or. kx.gt.5) go to 71 + kx1 = kx+1 + if(ky.le.0 .or. ky.gt.5) go to 71 + ky1 = ky+1 + kmax = max0(kx,ky) + km1 = kmax+1 + km2 = km1+1 + if(iopt.lt.(-1) .or. iopt.gt.1) go to 71 + if(m.lt.(kx1*ky1)) go to 71 + nminx = 2*kx1 + if(nxest.lt.nminx .or. nxest.gt.nmax) go to 71 + nminy = 2*ky1 + if(nyest.lt.nminy .or. nyest.gt.nmax) go to 71 + nest = max0(nxest,nyest) + nxk = nxest-kx1 + nyk = nyest-ky1 + ncest = nxk*nyk + nmx = nxest-nminx+1 + nmy = nyest-nminy+1 + nrint = nmx+nmy + nreg = nmx*nmy + ib1 = kx*nyk+ky1 + jb1 = ky*nxk+kx1 + ib3 = kx1*nyk+1 + if(ib1.le.jb1) go to 10 + ib1 = jb1 + ib3 = ky1*nxk+1 + 10 lwest = ncest*(2+ib1+ib3)+2*(nrint+nest*km2+m*km1)+ib3 + kwest = m+nreg + if(lwrk1.lt.lwest .or. kwrk.lt.kwest) go to 71 + if(xb.ge.xe .or. yb.ge.ye) go to 71 + do 20 i=1,m + if(w(i).le.0.) go to 70 + if(x(i).lt.xb .or. x(i).gt.xe) go to 71 + if(y(i).lt.yb .or. y(i).gt.ye) go to 71 + 20 continue + if(iopt.ge.0) go to 50 + if(nx.lt.nminx .or. nx.gt.nxest) go to 71 + nxk = nx-kx1 + tx(kx1) = xb + tx(nxk+1) = xe + do 30 i=kx1,nxk + if(tx(i+1).le.tx(i)) go to 72 + 30 continue + if(ny.lt.nminy .or. ny.gt.nyest) go to 71 + nyk = ny-ky1 + ty(ky1) = yb + ty(nyk+1) = ye + do 40 i=ky1,nyk + if(ty(i+1).le.ty(i)) go to 73 + 40 continue + go to 60 + 50 if(s.lt.0.) go to 71 + 60 ier = 0 +c we partition the working space and determine the spline approximation + kn = 1 + ki = kn+m + lq = 2 + la = lq+ncest*ib3 + lf = la+ncest*ib1 + lff = lf+ncest + lfp = lff+ncest + lco = lfp+nrint + lh = lco+nrint + lbx = lh+ib3 + nek = nest*km2 + lby = lbx+nek + lsx = lby+nek + lsy = lsx+m*km1 + call fpsurf(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest, + * eps,tol,maxit,nest,km1,km2,ib1,ib3,ncest,nrint,nreg,nx,tx, + * ny,ty,c,fp,wrk1(1),wrk1(lfp),wrk1(lco),wrk1(lf),wrk1(lff), + * wrk1(la),wrk1(lq),wrk1(lbx),wrk1(lby),wrk1(lsx),wrk1(lsy), + * wrk1(lh),iwrk(ki),iwrk(kn),wrk2,lwrk2,ier) + 70 return + 71 print*,"iopt,kx,ky,m=",iopt,kx,ky,m + print*,"nxest,nyest,nmax=",nxest,nyest,nmax + print*,"lwrk1,lwrk2,kwrk=",lwrk1,lwrk2,kwrk + print*,"xb,xe,yb,ye=",xb,xe,yb,ye + print*,"eps,s",eps,s + return + 72 print*,"tx=",tx + return + 73 print*,"ty=",ty + return + end Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,13 +1,20 @@ -""" fit_helper.py +""" +This module is used for spline interpolation, and functions +as a wrapper around the FITPACK Fortran interpolation +package. It is not intended to be directly accessed by +the user, but rather through the class Interpolate1D. -mimics the functionality of enthought.interpolate that is -contained in the module fitting.py +The code has been modified from an older version of +scipy.interpolate, where it was directly called by the +user. As such, it includes functionality not available through +Interpolate1D. For this reason, users may wish to get +under the hood. """ import numpy as np -import dfitpack #fixme: rename module fitpack_wrapper +import dfitpack class Spline(object): @@ -119,7 +126,7 @@ if x is (partially) ordered. """ - print 'length of x: ', len(x) + if len(x) == 0: return np.array([]) #hack to cope with shape (0,) if nu is None: return dfitpack.splev(*(self._eval_args+(x,))) @@ -190,13 +197,16 @@ T1 = time.clock() interp_func = Spline(x, y, k=1) T2 = time.clock() - print 'time to create linear interp function: ', T2 - T1 + print "time to create order 1 spline interpolation function with N = %i:" % N, T2 - T1 new_x = np.arange(N)+0.5 t1 = time.clock() new_y = interp_func(new_x) t2 = time.clock() - print '1d interp (sec):', t2 - t1 + print "time for order 1 spline interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) + + def runTest(self): + self.test_linearSpl() if __name__ == '__main__': unittest.main() Deleted: branches/Interpolate1D/fitpack_wrapper.pyc =================================================================== (Binary files differ) Deleted: branches/Interpolate1D/info_fit.py =================================================================== --- branches/Interpolate1D/info_fit.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/info_fit.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,12 +0,0 @@ -""" -Interpolation Tools -=================== - -Primary interpolation agent: - - Interpolate1D -- callable class, initialized with x and y to interpolate - from and indicator of how to deal with - extrapolation -""" - -postpone_import = 1 Modified: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,12 +1,12 @@ """ helper_funcs.py """ -import numpy -import sys; sys.path.append('C:\home\python\branches\interpolate2\entinterp') +import numpy as np +import sys import _interpolate -def make_array_safe(ary, typecode = numpy.float64): - ary = numpy.atleast_1d(numpy.asarray(ary, typecode)) +def make_array_safe(ary, typecode = np.float64): + ary = np.atleast_1d(np.asarray(ary, typecode)) if not ary.flags['CONTIGUOUS']: ary = ary.copy() return ary @@ -24,17 +24,17 @@ new_x 1-D array """ - x = make_array_safe(x, numpy.float64) - y = make_array_safe(y, numpy.float64) - new_x = make_array_safe(new_x, numpy.float64) + x = make_array_safe(x, np.float64) + y = make_array_safe(y, np.float64) + new_x = make_array_safe(new_x, np.float64) assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: - new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + new_y = np.zeros((y.shape[0], len(new_x)), np.float64) for i in range(len(new_y)): _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) else: - new_y = numpy.zeros(len(new_x), numpy.float64) + new_y = np.zeros(len(new_x), np.float64) _interpolate.linear_dddd(x, y, new_x, new_y) return new_y @@ -51,17 +51,17 @@ new_x 1-D array """ - x = make_array_safe(x, numpy.float64) - y = make_array_safe(y, numpy.float64) - new_x = make_array_safe(new_x, numpy.float64) + x = make_array_safe(x, np.float64) + y = make_array_safe(y, np.float64) + new_x = make_array_safe(new_x, np.float64) assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: - new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + new_y = np.zeros((y.shape[0], len(new_x)), np.float64) for i in range(len(new_y)): _interpolate.loginterp_dddd(x, y[i], new_x, new_y[i]) else: - new_y = numpy.zeros(len(new_x), numpy.float64) + new_y = np.zeros(len(new_x), np.float64) _interpolate.loginterp_dddd(x, y, new_x, new_y) return new_y @@ -79,20 +79,20 @@ 1-D array """ bad_index = None - x = make_array_safe(x, numpy.float64) - y = make_array_safe(y, numpy.float64) - new_x = make_array_safe(new_x, numpy.float64) + x = make_array_safe(x, np.float64) + y = make_array_safe(y, np.float64) + new_x = make_array_safe(new_x, np.float64) assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: - new_y = numpy.zeros((y.shape[0], len(new_x)), numpy.float64) + new_y = np.zeros((y.shape[0], len(new_x)), np.float64) for i in range(len(new_y)): bad_index = _interpolate.block_averave_above_dddd(x, y[i], new_x, new_y[i]) if bad_index is not None: break else: - new_y = numpy.zeros(len(new_x), numpy.float64) + new_y = np.zeros(len(new_x), np.float64) bad_index = _interpolate.block_average_above_dddd(x, y, new_x, new_y) if bad_index is not None: @@ -111,13 +111,13 @@ # This code is a little strange -- we really want a routine that # returns the index of values where x[j] < x[index] TINY = 1e-10 - indices = numpy.searchsorted(x, new_x+TINY)-1 + indices = np.searchsorted(x, new_x+TINY)-1 # If the value is at the front of the list, it'll have -1. # In this case, we will use the first (0), element in the array. # take requires the index array to be an Int - indices = numpy.atleast_1d(numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)) - new_y = numpy.take(y, indices, axis=-1) + indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(np.int)) + new_y = np.take(y, indices, axis=-1) return new_y def test_helper(): """ use numpy.allclose to test @@ -125,78 +125,24 @@ print "now testing accuracy of interpolation of linear data" - x = numpy.arange(10.) + x = np.arange(10.) y = 2.0*x - c = numpy.array([-1.0, 2.3, 10.5]) + c = np.array([-1.0, 2.3, 10.5]) - assert numpy.allclose( linear(x, y, c) , [-2.0, 4.6, 21.0] ), "problem in linear" - assert numpy.allclose( logarithmic(x, y, c) , [0. , 4.51738774 , 21.47836848] ), \ + assert np.allclose( linear(x, y, c) , [-2.0, 4.6, 21.0] ), "problem in linear" + assert np.allclose( logarithmic(x, y, c) , [0. , 4.51738774 , 21.47836848] ), \ "problem with logarithmic" - assert numpy.allclose( block_average_above(x, y, c) , [0., 2., 4.] ), \ + assert np.allclose( block_average_above(x, y, c) , [0., 2., 4.] ), \ "problem with block_average_above" -def compare_runtimes(): - from scipy import arange, ones - import time - - # basic linear interp - N = 3000. - x = arange(N) - y = arange(N) - new_x = arange(N)+0.5 - t1 = time.clock() - new_y = linear(x, y, new_x) - t2 = time.clock() - print '1d interp (sec):', t2 - t1 - print new_y[:5] - # basic block_average_above - N = 3000. - x = arange(N) - y = arange(N) - new_x = arange(N/2)*2 - t1 = time.clock() - new_y = block_average_above(x, y, new_x) - t2 = time.clock() - print '1d block_average_above (sec):', t2 - t1 - print new_y[:5] - - # y linear with y having multiple params - N = 3000. - x = arange(N) - y = ones((100,N)) * arange(N) - new_x = arange(N)+0.5 - t1 = time.clock() - new_y = linear(x, y, new_x) - t2 = time.clock() - print 'fast interpolate (sec):', t2 - t1 - print new_y[:5,:5] - - # scipy with multiple params - import scipy - N = 3000. - x = arange(N) - y = ones((100, N)) * arange(N) - new_x = arange(N) - t1 = time.clock() - interp = scipy.interpolate.interp1d(x, y) - new_y = interp(new_x) - t2 = time.clock() - print 'scipy interp1d (sec):', t2 - t1 - print new_y[:5,:5] - - -# Below is stuff from scipy.interpolate and fitpack - # Unit Test import unittest import time from numpy import arange, allclose, ones, NaN, isnan class Test(unittest.TestCase): - #def assertAllclose(self, x, y, rtol = 1.0e-5): - # self.assert_(numpy.allclose(x, y, rtol = rtol)) - + def assertAllclose(self, x, y, rtol=1.0e-5): for i, xi in enumerate(x): self.assert_(allclose(xi, y[i], rtol) or (isnan(xi) and isnan(y[i]))) @@ -209,7 +155,7 @@ t1 = time.clock() new_y = linear(x, y, new_x) t2 = time.clock() - print '1d interp (sec):', t2 - t1 + print "time for linear interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) @@ -222,7 +168,7 @@ t1 = time.clock() new_y = block_average_above(x, y, new_x) t2 = time.clock() - print '1d block_average_above (sec):', t2 - t1 + print "time for block_avg_above interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.0, 0.5, 2.5, 4.5, 6.5]) def test_linear2(self): @@ -233,7 +179,7 @@ t1 = time.clock() new_y = linear(x, y, new_x) t2 = time.clock() - print 'fast interpolate (sec):', t2 - t1 + print "time for 2D linear interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5,:5], [[ 0.5, 1.5, 2.5, 3.5, 4.5], [ 0.5, 1.5, 2.5, 3.5, 4.5], @@ -249,11 +195,16 @@ t1 = time.clock() new_y = logarithmic(x, y, new_x) t2 = time.clock() - print 'logarithmic interp (sec):', t2 - t1 - correct_y = [numpy.NaN, 1.41421356, 2.44948974, 3.46410162, 4.47213595] + print "time for logarithmic interpolation with N = %i:" % N, t2 - t1 + correct_y = [np.NaN, 1.41421356, 2.44948974, 3.46410162, 4.47213595] self.assertAllclose(new_y[:5], correct_y) - print "logo" + def runTest(self): + self.test_linear() + self.test_block_average_above() + self.test_linear2() + self.test_logarithmic() + if __name__ == '__main__': unittest.main() \ No newline at end of file Deleted: branches/Interpolate1D/interpolate_wrapper.pyc =================================================================== (Binary files differ) Added: branches/Interpolate1D/multipack.h =================================================================== --- branches/Interpolate1D/multipack.h 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/multipack.h 2008-07-18 19:44:12 UTC (rev 4550) @@ -0,0 +1,211 @@ +/* MULTIPACK module by Travis Oliphant + +Copyright (c) 2002 Travis Oliphant all rights reserved +Oliphant.Travis at altavista.net +Permission to use, modify, and distribute this software is given under the +terms of the SciPy (BSD style) license. See LICENSE.txt that came with +this distribution for specifics. + +NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. +*/ + + +/* This extension module is a collection of wrapper functions around +common FORTRAN code in the packages MINPACK, ODEPACK, and QUADPACK plus +some differential algebraic equation solvers. + +The wrappers are meant to be nearly direct translations between the +FORTAN code and Python. Some parameters like sizes do not need to be +passed since they are available from the objects. + +It is anticipated that a pure Python module be written to call these lower +level routines and make a simpler user interface. All of the routines define +default values for little-used parameters so that even the raw routines are +quite useful without a separate wrapper. + +FORTRAN Outputs that are not either an error indicator or the sought-after +results are placed in a dictionary and returned as an optional member of +the result tuple when the full_output argument is non-zero. +*/ + +#include "Python.h" +#include "numpy/arrayobject.h" + +#define PYERR(errobj,message) {PyErr_SetString(errobj,message); goto fail;} +#define PYERR2(errobj,message) {PyErr_Print(); PyErr_SetString(errobj, message); goto fail;} +#define ISCONTIGUOUS(m) ((m)->flags & CONTIGUOUS) + +#define STORE_VARS() PyObject *store_multipack_globals[4]; int store_multipack_globals3; + +#define INIT_FUNC(fun,arg,errobj) { /* Get extra arguments or set to zero length tuple */ \ + store_multipack_globals[0] = multipack_python_function; \ + store_multipack_globals[1] = multipack_extra_arguments; \ + if (arg == NULL) { \ + if ((arg = PyTuple_New(0)) == NULL) goto fail; \ + } \ + else \ + Py_INCREF(arg); /* We decrement on exit. */ \ + if (!PyTuple_Check(arg)) \ + PYERR(errobj,"Extra Arguments must be in a tuple"); \ + /* Set up callback functions */ \ + if (!PyCallable_Check(fun)) \ + PYERR(errobj,"First argument must be a callable function."); \ + multipack_python_function = fun; \ + multipack_extra_arguments = arg; } + +#define INIT_JAC_FUNC(fun,Dfun,arg,col_deriv,errobj) { \ + store_multipack_globals[0] = multipack_python_function; \ + store_multipack_globals[1] = multipack_extra_arguments; \ + store_multipack_globals[2] = multipack_python_jacobian; \ + store_multipack_globals3 = multipack_jac_transpose; \ + if (arg == NULL) { \ + if ((arg = PyTuple_New(0)) == NULL) goto fail; \ + } \ + else \ + Py_INCREF(arg); /* We decrement on exit. */ \ + if (!PyTuple_Check(arg)) \ + PYERR(errobj,"Extra Arguments must be in a tuple"); \ + /* Set up callback functions */ \ + if (!PyCallable_Check(fun) || (Dfun != Py_None && !PyCallable_Check(Dfun))) \ + PYERR(errobj,"The function and its Jacobian must be callable functions."); \ + multipack_python_function = fun; \ + multipack_extra_arguments = arg; \ + multipack_python_jacobian = Dfun; \ + multipack_jac_transpose = !(col_deriv);} + +#define RESTORE_JAC_FUNC() multipack_python_function = store_multipack_globals[0]; \ + multipack_extra_arguments = store_multipack_globals[1]; \ + multipack_python_jacobian = store_multipack_globals[2]; \ + multipack_jac_transpose = store_multipack_globals3; + +#define RESTORE_FUNC() multipack_python_function = store_multipack_globals[0]; \ + multipack_extra_arguments = store_multipack_globals[1]; + +#define SET_DIAG(ap_diag,o_diag,mode) { /* Set the diag vector from input */ \ + if (o_diag == NULL || o_diag == Py_None) { \ + ap_diag = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_DOUBLE); \ + if (ap_diag == NULL) goto fail; \ + diag = (double *)ap_diag -> data; \ + mode = 1; \ + } \ + else { \ + ap_diag = (PyArrayObject *)PyArray_ContiguousFromObject(o_diag, PyArray_DOUBLE, 1, 1); \ + if (ap_diag == NULL) goto fail; \ + diag = (double *)ap_diag -> data; \ + mode = 2; } } + +#define MATRIXC2F(jac,data,n,m) {double *p1=(double *)(jac), *p2, *p3=(double *)(data);\ +int i,j;\ +for (j=0;j<(m);p3++,j++) \ + for (p2=p3,i=0;i<(n);p2+=(m),i++,p1++) \ + *p1 = *p2; } +/* +static PyObject *multipack_python_function=NULL; +static PyObject *multipack_python_jacobian=NULL; +static PyObject *multipack_extra_arguments=NULL; +static int multipack_jac_transpose=1; +*/ + +static PyArrayObject * my_make_numpy_array(PyObject *y0, int type, int mindim, int maxdim) + /* This is just like PyArray_ContiguousFromObject except it handles + * single numeric datatypes as 1-element, rank-1 arrays instead of as + * scalars. + */ +{ + PyArrayObject *new_array; + PyObject *tmpobj; + + Py_INCREF(y0); + + if (PyInt_Check(y0) || PyFloat_Check(y0)) { + tmpobj = PyList_New(1); + PyList_SET_ITEM(tmpobj, 0, y0); /* reference now belongs to tmpobj */ + } + else + tmpobj = y0; + + new_array = (PyArrayObject *)PyArray_ContiguousFromObject(tmpobj, type, mindim, maxdim); + + Py_DECREF(tmpobj); + return new_array; +} + +static PyObject *call_python_function(PyObject *func, int n, double *x, PyObject *args, int dim, PyObject *error_obj) +{ + /* + This is a generic function to call a python function that takes a 1-D + sequence as a first argument and optional extra_arguments (should be a + zero-length tuple if none desired). The result of the function is + returned in a multiarray object. + -- build sequence object from values in x. + -- add extra arguments (if any) to an argument list. + -- call Python callable object + -- check if error occurred: + if so return NULL + -- if no error, place result of Python code into multiarray object. + */ + + PyArrayObject *sequence = NULL; + PyObject *arglist = NULL, *tmpobj = NULL; + PyObject *arg1 = NULL, *str1 = NULL; + PyObject *result = NULL; + PyArrayObject *result_array = NULL; + + /* Build sequence argument from inputs */ + sequence = (PyArrayObject *)PyArray_FromDimsAndData(1, &n, PyArray_DOUBLE, (char *)x); + if (sequence == NULL) PYERR2(error_obj,"Internal failure to make an array of doubles out of first\n argument to function call."); + + /* Build argument list */ + if ((arg1 = PyTuple_New(1)) == NULL) { + Py_DECREF(sequence); + return NULL; + } + PyTuple_SET_ITEM(arg1, 0, (PyObject *)sequence); + /* arg1 now owns sequence reference */ + if ((arglist = PySequence_Concat( arg1, args)) == NULL) + PYERR2(error_obj,"Internal error constructing argument list."); + + Py_DECREF(arg1); /* arglist has a reference to sequence, now. */ + + + /* Call function object --- variable passed to routine. Extra + arguments are in another passed variable. + */ + if ((result = PyEval_CallObject(func, arglist))==NULL) { + PyErr_Print(); + tmpobj = PyObject_GetAttrString(func, "func_name"); + if (tmpobj == NULL) goto fail; + str1 = PyString_FromString("Error occured while calling the Python function named "); + if (str1 == NULL) { Py_DECREF(tmpobj); goto fail;} + PyString_ConcatAndDel(&str1, tmpobj); + PyErr_SetString(error_obj, PyString_AsString(str1)); + Py_DECREF(str1); + goto fail; + } + + if ((result_array = (PyArrayObject *)PyArray_ContiguousFromObject(result, PyArray_DOUBLE, dim-1, dim))==NULL) + PYERR2(error_obj,"Result from function call is not a proper array of floats."); + + Py_DECREF(result); + Py_DECREF(arglist); + return (PyObject *)result_array; + + fail: + Py_XDECREF(arglist); + Py_XDECREF(result); + Py_XDECREF(arg1); + return NULL; +} + + + + + + + + + + + + + Modified: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-18 13:19:37 UTC (rev 4549) +++ branches/Interpolate1D/setup.py 2008-07-18 19:44:12 UTC (rev 4550) @@ -1,24 +1,30 @@ #!/usr/bin/env python +import os from os.path import join def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('', parent_package, top_path) + config = Configuration('', parent_package, top_path) #first arg was 'interpolate' + config.add_extension('_interpolate', ['_interpolate.cpp'], include_dirs = ['.'], depends = ['interpolate.h']) + config.add_library('fitpack', + sources=[join('fitpack', '*.f')], + ) + config.add_extension('dfitpack', sources=['fitpack.pyf'], libraries=['fitpack'], ) - + return config if __name__ == '__main__': from numpy.distutils.core import setup - setup(**configuration(top_path='').todict() ) \ No newline at end of file + setup(**configuration().todict()) \ No newline at end of file From scipy-svn at scipy.org Fri Jul 18 19:03:58 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 18 Jul 2008 18:03:58 -0500 (CDT) Subject: [Scipy-svn] r4551 - branches/Interpolate1D Message-ID: <20080718230358.D958D39C2EA@scipy.org> Author: fcady Date: 2008-07-18 18:03:56 -0500 (Fri, 18 Jul 2008) New Revision: 4551 Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/__init__.py Log: better doc strings, better handling of pathological input, and functional wrapper around Interpolate1D Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-18 19:44:12 UTC (rev 4550) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-18 23:03:56 UTC (rev 4551) @@ -1,7 +1,32 @@ -""" A module for intepolation """ + Interpolation of 1D data -# fixme: information strings giving mathematical descriptions of the actions + This module provides several functions and classes for interpolation + and extrapolation of 1D data (1D in both input and output). The + primary function provided is: + + interp1d(x, y, new_x) : from data points x and y, interpolates + values for points in new_x and + returns them as an array. + + Classes provided include: + + Interpolate1D : an object for interpolation of + various kinds. interp1d is a wrapper + around this class. + + Spline : an object for spline interpolation + + Functions provided include: + + linear : linear interpolation + logarithmic : logarithmic interpolation + block : block interpolation + block_average_above : block average above interpolation + +""" + +# FIXME: information strings giving mathematical descriptions of the actions # of the functions. from interpolate_wrapper import linear, logarithmic, block, block_average_above @@ -9,33 +34,34 @@ import numpy as np from numpy import array, arange, empty, float64, NaN -# fixme: use this to ensure proper type of all inputs and outputs in Interpolate1D +# FIXME: use this to ensure proper type of all inputs and outputs in Interpolate1D def make_array_safe(ary, typecode=np.float64): - # fixme: could pick correct typecode + # FIXME: could pick correct typecode ary = np.atleast_1d(np.asarray(ary, typecode)) if not ary.flags['CONTIGUOUS']: ary = ary.copy() return ary - -class Interpolate1D(object): - - - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, missing_data=[None, np.NaN]): - """ - Object for interpolation of 1D data. +def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): + """ A function for interpolation of 1D data. REQUIRED ARGUMENTS: - + x -- list or NumPy array x includes the x-values for the data set to interpolate from. It must be sorted in ascending order - + y -- list or NumPy array y includes the y-values for the data set to - interpolate from. + interpolate from. Note that y must be + one-dimensional. + new_x -- list or NumPy array + points whose value is to be interpolated from x and y. + new_x must be in sorted order, lowest to highest. + OPTIONAL ARGUMENTS: kind -- Usu. function or string. But can be any type. @@ -54,50 +80,177 @@ low (high) -- same as for kind Same options as for 'kind'. Defaults to returning numpy.NaN ('not a number') for all values outside the range of x. + + remove_bad_data -- bool + indicates whether to remove bad data. + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. + + numpy.NaN is always considered bad data. + + SAMPLE ACCEPTABLE ARGUMENTS: + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN + EXAMPLES: + >>> import numpy + >>> from Interpolate1D import interp1d + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> new_x = [.2, 2.3, 5.6] + >>> interp1d(x, y, new_x) + array([.2, 2.3, 5.6, NaN]) + """ + return Interpolate1D(x, y, kind=kind, low=low, high=high, kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ + remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) + +class Interpolate1D(object): + """ An object for interpolation of 1D data. + + REQUIRED ARGUMENTS: + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. Note that y must be + one-dimensional. + + OPTIONAL ARGUMENTS: - """ - # fixme: Handle checking if they are the correct size. - self._x = make_array_safe(x).copy() - self._y = make_array_safe(y).copy() + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + If nothing else, assumes the argument is intended as a value + to be returned for all arguments. Defaults to linear interpolation. - assert len(x) == len(y) , "x and y must be of the same length" - assert x.ndim == 1 , "x must be one-dimensional" - assert y.ndim == 1 , "y must be one-dimensional" - # fixme: let y be 2-dimensional. Involves reworking of Interpolate1D.__call__ - # because Spline enumerates y along the last, rather then first, axis, - # while concatenate works along first axis + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. + + remove_bad_data -- bool + indicates whether to remove bad data. + + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. + + numpy.NaN is always considered bad data. + + SAMPLE ACCEPTABLE ARGUMENTS: + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN + + EXAMPLES: + >>> import numpy + >>> from Interpolate1D import Interpolate1D + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> interp = Interpolate1D(x, y) + >>> new_x = [.2, 2.3, 5.6] + >>> interp(new_x) + array([.2, 2.3, 5.6, NaN]) + + """ + # FIXME: more informative descriptions of sample arguments + # FIXME: examples in doc string + + def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): + + #print "size of bad_data: ", len(bad_data) + + self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) + # FIXME: Handle checking if they are the correct size. + #self._x = make_array_safe(x).copy() + #self._y = make_array_safe(y).copy() + + #assert len(x) == len(y) , "x and y must be of the same length" + #assert x.ndim == 1 , "x must be one-dimensional" + #assert y.ndim == 1 , "y must be one-dimensional" + # FIXME: let y be 2-dimensional. Involves reworking of Interpolate1D.__call__ + # because Spline enumerates y along the last, rather then first, axis, + # while concatenate works along first axis + self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) self.low = self._init_interp_method(self._x, self._y, low, lowkw) self.high = self._init_interp_method(self._x, self._y, high, highkw) - def _format_array(x, y, missing_data=[None, np.NaN]): - # fixme: don't allow copying multiple times. - - assert len(x) > 0 and len(y) > 0 , "interpolation does not support\ - array of length 0" + def _format_array(self, x, y, remove_bad_data = False, bad_data = []):#=[None, np.NaN]):#=[None, np.NaN]): + """ + Assigns properly formatted versions of x and y to self._x and self._y. + Also records data types. + + Formatting includes removal of all points whose x or y coordinate + is in missing_data. This is the primary difference from + make_array_safe. + + """ + # FIXME: don't allow copying multiple times. + + # check acceptable lengths for x and y + assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ + arrays of length 0" assert len(x) == len(y) , "x and y must be of the same length" - mask = [((xi not in missing_data) and (y[i] not in missing_data)) \ - for i, xi in enumerate(x) ] - if isinstance(x, list): - x = [x[i] for (i, good_data) in enumerate(mask) if good_data] - else: + x = np.array(x) + y = np.array(y) + + # remove bad data + if remove_bad_data: + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) + print 'mask equals: ', mask, type(mask) + print 'x equals: ', x + print 'x[mask] is: ', x[mask] x = x[mask] - if isinstance(y, list): - y = [y[i] for (i, good_data) in enumerate(mask) if good_data] - else: y = y[mask] - self._xdtype = type(x[0]) - self._x = make_array_safe(x, _xdtype).copy() - self._ydtype = type(y[0]) - self._y = make_array_safe(y, _ydtype).copy() + # collect dataypes and make arrays + self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 + self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._x = make_array_safe(x, self._xdtype).copy() + self._y = make_array_safe(y, self._ydtype).copy() + + # check dimensionality assert self._x.ndim == 1 , "x must be one-dimensional" assert self._y.ndim == 1 , "y must be one-dimensional" def _init_interp_method(self, x, y, interp_arg, kw): + """ + User provides interp_arg and dictionary kw. _init_interp_method + returns the interpolating function from x and y specified by interp_arg, + possibly with extra keyword arguments given in kw. + + """ + # FIXME : error checking specific to interpolation method. x and y long + # enough for order-3 spline if that's indicated, etc. Functions should throw + # errors themselves when Interpolate1D is called, but errors at instantiation + # would be nice. + from inspect import isclass, isfunction if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: @@ -115,6 +268,9 @@ return result def __call__(self, x): + """ + + """ x = make_array_safe(x) low_mask = x Author: ptvirtan Date: 2008-07-19 17:24:45 -0500 (Sat, 19 Jul 2008) New Revision: 4552 Modified: trunk/scipy/linalg/decomp.py Log: Fix #704, factual error in cho_factor docstring Modified: trunk/scipy/linalg/decomp.py =================================================================== --- trunk/scipy/linalg/decomp.py 2008-07-18 23:03:56 UTC (rev 4551) +++ trunk/scipy/linalg/decomp.py 2008-07-19 22:24:45 UTC (rev 4552) @@ -903,11 +903,15 @@ def cho_factor(a, lower=0, overwrite_a=0): """Compute the Cholesky decomposition of a matrix, to use in cho_solve - Returns the Cholesky decomposition, :lm:`A = L L^*` or :lm:`A = U^* U` - of a Hermitian positive-definite matrix :lm:`A`. - + Returns a matrix containing the Cholesky decomposition, + ``A = L L*`` or ``A = U* U`` of a Hermitian positive-definite matrix `a`. The return value can be directly used as the first parameter to cho_solve. + .. warning:: + The returned matrix also contains random data in the entries not + used by the Cholesky decomposition. If you need to zero these + entries, use the function `cholesky` instead. + Parameters ---------- a : array, shape (M, M) @@ -921,11 +925,15 @@ Returns ------- c : array, shape (M, M) - Upper- or lower-triangular Cholesky factor of A - lower : array, shape (M, M) - Flag indicating whether the factor is lower or upper triangular + Matrix whose upper or lower triangle contains the Cholesky factor + of `a`. Other parts of the matrix contain random data. + lower : boolean + Flag indicating whether the factor is in the lower or upper triangle - Raises LinAlgError if decomposition fails + Raises + ------ + LinAlgError + Raised if decomposition fails. """ a1 = asarray_chkfinite(a) From scipy-svn at scipy.org Sat Jul 19 21:00:08 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 19 Jul 2008 20:00:08 -0500 (CDT) Subject: [Scipy-svn] r4553 - trunk/scipy/sandbox/mkufunc/mkufunc Message-ID: <20080720010008.6A54F39C226@scipy.org> Author: ilan Date: 2008-07-19 20:00:07 -0500 (Sat, 19 Jul 2008) New Revision: 4553 Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py Log: Added test for modulo Modified: trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py =================================================================== --- trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-19 22:24:45 UTC (rev 4552) +++ trunk/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py 2008-07-20 01:00:07 UTC (rev 4553) @@ -3,7 +3,7 @@ from numpy import array, arange, allclose -from mkufunc.api import Cfunc, genufunc, mkufunc +from api import Cfunc, genufunc, mkufunc class Util: @@ -238,7 +238,15 @@ x = arange(0, 2, 0.1) self.assertClose(uf(x), f(x)) + def test_modulo(self): + @mkufunc(int) + def f(i): + return i % 5 + + self.assert_(all(f(range(7)) == array([0, 1, 2, 3, 4, 0, 1]))) + self.assert_(all(f(arange(8)) == array([0, 1, 2, 3, 4, 0, 1, 2]))) + class Control_Flow_Tests(unittest.TestCase): def test_if(self): From scipy-svn at scipy.org Sun Jul 20 23:17:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 20 Jul 2008 22:17:18 -0500 (CDT) Subject: [Scipy-svn] r4554 - trunk/scipy/sandbox/mkufunc/examples Message-ID: <20080721031718.DCE2439C694@scipy.org> Author: ilan Date: 2008-07-20 22:17:18 -0500 (Sun, 20 Jul 2008) New Revision: 4554 Added: trunk/scipy/sandbox/mkufunc/examples/mandel_c.py trunk/scipy/sandbox/mkufunc/examples/mandel_mkImage.py trunk/scipy/sandbox/mkufunc/examples/mandel_py.py Removed: trunk/scipy/sandbox/mkufunc/examples/mandel-c.py trunk/scipy/sandbox/mkufunc/examples/mandel-py.py Log: Improved Mandelbrot set example Deleted: trunk/scipy/sandbox/mkufunc/examples/mandel-c.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel-c.py 2008-07-20 01:00:07 UTC (rev 4553) +++ trunk/scipy/sandbox/mkufunc/examples/mandel-c.py 2008-07-21 03:17:18 UTC (rev 4554) @@ -1,88 +0,0 @@ -#!/usr/bin/env python -""" ->>> mandel(-1, .3) -36 ->>> mandel(0, 0) --1 ->>> mandel(10, 10) -1 ->>> mandel(array([-1, 0, 10]), array([.3, 0, 10])) -array([36, -1, 1]) -""" -import hashlib - -from numpy import array -from scipy import weave - -support_code = ''' -#define D 1000 - -long iterations(double cr, double ci) -{ - long d = 1; - double zr=cr, zi=ci, zr2, zi2; - for(;;) { - zr2 = zr * zr; - zi2 = zi * zi; - if( zr2+zi2 > 16.0 ) return d; - if( ++d == D ) return -1; - zi = 2.0 * zr * zi + ci; - zr = zr2 - zi2 + cr; - } -} - -static void -PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) -{ - npy_intp i, n; - npy_intp is0 = steps[0]; - npy_intp is1 = steps[1]; - npy_intp os = steps[2]; - char *ip0 = args[0]; - char *ip1 = args[1]; - char *op = args[2]; - n = dimensions[0]; - - for(i = 0; i < n; i++) { - *(long *)op = iterations(*(double *)ip0, - *(double *)ip1); - ip0 += is0; - ip1 += is1; - op += os; - } -} - -static PyUFuncGenericFunction f_functions[] = { - PyUFunc_0, -}; - -static char f_types[] = { - NPY_DOUBLE, NPY_DOUBLE, NPY_LONG, -}; -''' -ufunc_info = weave.base_info.custom_info() -ufunc_info.add_header('"numpy/ufuncobject.h"') - -mandel = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/ -import_ufunc(); - -return_val = PyUFunc_FromFuncAndData( - f_functions, - NULL, - f_types, - 1, /* ntypes */ - 2, /* nin */ - 1, /* nout */ - PyUFunc_None, /* identity */ - "mandel", /* name */ - "returns number of iterations from cr, ci", /* doc */ - 0); - ''', - support_code=support_code, - verbose=0, - customize=ufunc_info) - - -if __name__ == '__main__': - import doctest - doctest.testmod() Deleted: trunk/scipy/sandbox/mkufunc/examples/mandel-py.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel-py.py 2008-07-20 01:00:07 UTC (rev 4553) +++ trunk/scipy/sandbox/mkufunc/examples/mandel-py.py 2008-07-21 03:17:18 UTC (rev 4554) @@ -1,37 +0,0 @@ -#!/usr/bin/env python -""" ->>> mandel(-1, .3) -36 ->>> mandel(0, 0) --1 ->>> mandel(10, 10) -1 ->>> mandel(array([-1, 0, 10]), array([.3, 0, 10])) -array([36, -1, 1]) -""" -from numpy import array -from mkufunc.api import mkufunc - -D = 1000 - - - at mkufunc([(float, float, int)]) -def mandel(cr, ci): - d = 1 - zr = cr - zi = ci - for d in xrange(1, D): - zr2 = zr * zr - zi2 = zi * zi - if zr2 + zi2 > 16: - return d - zi = 2.0 * zr * zi + ci - zr = zr2 - zi2 + cr - else: - return -1 - - - -if __name__ == '__main__': - import doctest - doctest.testmod() Added: trunk/scipy/sandbox/mkufunc/examples/mandel_c.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel_c.py 2008-07-20 01:00:07 UTC (rev 4553) +++ trunk/scipy/sandbox/mkufunc/examples/mandel_c.py 2008-07-21 03:17:18 UTC (rev 4554) @@ -0,0 +1,82 @@ +#!/usr/bin/env python +import hashlib + +from numpy import array +from scipy import weave + +support_code = ''' +#define D 1000 + +long iterations(double cr, double ci) +{ + long d = 1; + double zr=cr, zi=ci, zr2, zi2; + for(;;) { + zr2 = zr * zr; + zi2 = zi * zi; + if( zr2+zi2 > 16.0 ) return d; + if( ++d == D ) return -1; + zi = 2.0 * zr * zi + ci; + zr = zr2 - zi2 + cr; + } +} + +static void +PyUFunc_0(char **args, npy_intp *dimensions, npy_intp *steps, void *func) +{ + npy_intp i, n; + npy_intp is0 = steps[0]; + npy_intp is1 = steps[1]; + npy_intp os = steps[2]; + char *ip0 = args[0]; + char *ip1 = args[1]; + char *op = args[2]; + n = dimensions[0]; + + for(i = 0; i < n; i++) { + *(long *)op = iterations(*(double *)ip0, + *(double *)ip1); + ip0 += is0; + ip1 += is1; + op += os; + } +} + +static PyUFuncGenericFunction f_functions[] = { + PyUFunc_0, +}; + +static char f_types[] = { + NPY_DOUBLE, NPY_DOUBLE, NPY_LONG, +}; +''' +ufunc_info = weave.base_info.custom_info() +ufunc_info.add_header('"numpy/ufuncobject.h"') + +mandel = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/ +import_ufunc(); + +return_val = PyUFunc_FromFuncAndData( + f_functions, + NULL, + f_types, + 1, /* ntypes */ + 2, /* nin */ + 1, /* nout */ + PyUFunc_None, /* identity */ + "mandel", /* name */ + "returns number of iterations from cr, ci", /* doc */ + 0); + ''', + support_code=support_code, + verbose=0, + customize=ufunc_info) + + +if __name__ == '__main__': + + assert mandel(-1, .3) == 36 + assert mandel(0, 0) == -1 + assert mandel(10, 10) == 1 + assert all(mandel(array([-1, 0, 10]), array([.3, 0, 10])) == + array([36, -1, 1])) Added: trunk/scipy/sandbox/mkufunc/examples/mandel_mkImage.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel_mkImage.py 2008-07-20 01:00:07 UTC (rev 4553) +++ trunk/scipy/sandbox/mkufunc/examples/mandel_mkImage.py 2008-07-21 03:17:18 UTC (rev 4554) @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +# Before running this be sure to apply Travis Oliphant's patch to PIL: +# http://www.scipy.org/Cookbook/PIL + +import numpy +from PIL import Image + +from mkufunc.api import mkufunc + +from mandel_c import mandel + + + at mkufunc(int) +def color(i): + return (i * 10) % 256 + + n = i % 3 + if n == 0: + c = (255, 127, 128) + elif n == 1: + c = (128, 255, 0) + else: + c = (0, 128, 255) + + return c[0] + (c[1] + c[2]*256)*256 + + + +w, h = 1024, 768 + +x, y = numpy.ogrid[-2.5:+1.5:w*1j, -1.5:+1.5:h*1j] + +img = mandel(x, y) + +print img.dtype +print img.shape + +img = color(img) +img.dtype = numpy.uint8 +img = img.reshape(h, w, 4) + +print img.dtype +print img.shape + +pilImage = Image.fromarray(img) +pilImage.save('mandel.png') Property changes on: trunk/scipy/sandbox/mkufunc/examples/mandel_mkImage.py ___________________________________________________________________ Name: svn:executable + * Added: trunk/scipy/sandbox/mkufunc/examples/mandel_py.py =================================================================== --- trunk/scipy/sandbox/mkufunc/examples/mandel_py.py 2008-07-20 01:00:07 UTC (rev 4553) +++ trunk/scipy/sandbox/mkufunc/examples/mandel_py.py 2008-07-21 03:17:18 UTC (rev 4554) @@ -0,0 +1,31 @@ +#!/usr/bin/env python +from numpy import array +from mkufunc.api import mkufunc + +D = 1000 + + + at mkufunc([(float, float, int)]) +def mandel(cr, ci): + d = 1 + zr = cr + zi = ci + for d in xrange(1, D): + zr2 = zr * zr + zi2 = zi * zi + if zr2 + zi2 > 16: + return d + zi = 2.0 * zr * zi + ci + zr = zr2 - zi2 + cr + else: + return -1 + + + +if __name__ == '__main__': + + assert mandel(-1, .3) == 36 + assert mandel(0, 0) == -1 + assert mandel(10, 10) == 1 + assert all(mandel(array([-1, 0, 10]), array([.3, 0, 10])) == + array([36, -1, 1])) From scipy-svn at scipy.org Mon Jul 21 12:35:30 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 21 Jul 2008 11:35:30 -0500 (CDT) Subject: [Scipy-svn] r4555 - branches/Interpolate1D Message-ID: <20080721163530.EB2C139C603@scipy.org> Author: fcady Date: 2008-07-21 11:35:30 -0500 (Mon, 21 Jul 2008) New Revision: 4555 Added: branches/Interpolate1D/TODO.txt branches/Interpolate1D/interpolate1d.py Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/__init__.py Log: added a TODO.txt file discussing areas for improvement, removed CamelCase from main file name, and made minor changes Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-21 03:17:18 UTC (rev 4554) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-21 16:35:30 UTC (rev 4555) @@ -34,9 +34,7 @@ import numpy as np from numpy import array, arange, empty, float64, NaN -# FIXME: use this to ensure proper type of all inputs and outputs in Interpolate1D def make_array_safe(ary, typecode=np.float64): - # FIXME: could pick correct typecode ary = np.atleast_1d(np.asarray(ary, typecode)) if not ary.flags['CONTIGUOUS']: ary = ary.copy() @@ -112,90 +110,79 @@ return Interpolate1D(x, y, kind=kind, low=low, high=high, kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) -class Interpolate1D(object): +class interpolate1d(object): """ An object for interpolation of 1D data. + + REQUIRED ARGUMENTS: + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. Note that y must be + one-dimensional. + + OPTIONAL ARGUMENTS: - REQUIRED ARGUMENTS: + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + If nothing else, assumes the argument is intended as a value + to be returned for all arguments. Defaults to linear interpolation. + + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order + remove_bad_data -- bool + indicates whether to remove bad data. - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. - OPTIONAL ARGUMENTS: - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. + numpy.NaN is always considered bad data. + + SAMPLE ACCEPTABLE ARGUMENTS: + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. + EXAMPLES: + >>> import numpy + >>> from Interpolate1D import Interpolate1D + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> interp = Interpolate1D(x, y) + >>> new_x = [.2, 2.3, 5.6] + >>> interp(new_x) + array([.2, 2.3, 5.6, NaN]) - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - SAMPLE ACCEPTABLE ARGUMENTS: - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - EXAMPLES: - >>> import numpy - >>> from Interpolate1D import Interpolate1D - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> interp = Interpolate1D(x, y) - >>> new_x = [.2, 2.3, 5.6] - >>> interp(new_x) - array([.2, 2.3, 5.6, NaN]) - """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): - - #print "size of bad_data: ", len(bad_data) - + self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) - # FIXME: Handle checking if they are the correct size. - #self._x = make_array_safe(x).copy() - #self._y = make_array_safe(y).copy() + - #assert len(x) == len(y) , "x and y must be of the same length" - #assert x.ndim == 1 , "x must be one-dimensional" - #assert y.ndim == 1 , "y must be one-dimensional" - # FIXME: let y be 2-dimensional. Involves reworking of Interpolate1D.__call__ - # because Spline enumerates y along the last, rather then first, axis, - # while concatenate works along first axis - self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) self.low = self._init_interp_method(self._x, self._y, low, lowkw) self.high = self._init_interp_method(self._x, self._y, high, highkw) @@ -216,10 +203,10 @@ assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ arrays of length 0" assert len(x) == len(y) , "x and y must be of the same length" - x = np.array(x) - y = np.array(y) # remove bad data + x = np.array(x) + y = np.array(y) if remove_bad_data: mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and (y[i] not in bad_data) and (not np.isnan(y[i])) \ for i, xi in enumerate(x) ]) @@ -253,6 +240,7 @@ from inspect import isclass, isfunction + # FIXME : more string options available ('cubic', etc) if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] @@ -277,9 +265,10 @@ high_mask = x>self._x[-1] interp_mask = (~low_mask) & (~high_mask) - if len(x[low_mask]) == 0: new_low=np.array([]) # hack, since vectorize is failing - # work on lists/arrays of length 0 - # on computer where this is being + if len(x[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. + # if/else is a hack, since vectorize is failing + # to work on lists/arrays of length 0 + # on the computer where this is being # developed else: new_low = self.low(x[low_mask]) if len(x[interp_mask])==0: new_interp=np.array([]) Added: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-21 03:17:18 UTC (rev 4554) +++ branches/Interpolate1D/TODO.txt 2008-07-21 16:35:30 UTC (rev 4555) @@ -0,0 +1,59 @@ +TODO +This list contains a number of things which need fixing and/or +improvement. There's also a small explanatory +note with ideas. More info is often contained in FIXMEs +at appropriate places in the code. + + +**comment interpolate1d + + +**doc strings for interpolate1d and its members + + +**more strings user can pass ('cubic', etc) + + +**figure out NumPy version stuff with vectorize. +It would be nice to remove the hack I used. +I believe vectorize is supposed to handle arrays of +length 0, but it's not working on my computer. + + +**better handling of variable types +Currently everything is cast to a float64 if it is not already +a float32. Is this the best way to do it? + +Also, for the future, code should be added for record arrays, +which mix real values with strings. This is, I believe already +largely supported, but that's not because the code was written +with that in mind. I haven't thought through the details. + +Perhaps this should be done as another function/class which +wraps interpolate1d. + + +**allow y to be 2-dimensional +That way the interpolated function is from R1 -> Rn, and +not just R1 -> R1. This requires some thinking about axes. + + +**write regression tests +desired for fitpack_wrapper and _interpolate_wrapper +as well as interpolate1d. Recommend using the +shelve module + + +**pick best spline +Under-the-hood machinery currently comes from _interpolate.cpp +(used in enthought.interpolate) and FITPACK (Fortran, used in +scipy.interpolate). This isn't necessarily the best (for example, +speed of FITPACK is highly sensitive to parameter k). Other code +is used in scipy.ndimage and scipy.signal. There is surely other +code out there too. Figure out what is best and incorporate it. + + +**update for 2D and ND +This will probably take the form of two additional +classes both based on interpolate1d. Thus it probably +shouldn't be done until interpolate1d is more settled. Modified: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-21 03:17:18 UTC (rev 4554) +++ branches/Interpolate1D/__init__.py 2008-07-21 16:35:30 UTC (rev 4555) @@ -29,4 +29,4 @@ from interpolate_wrapper import linear, logarithmic, block, block_average_above from fitpack_wrapper import Spline -from Interpolate1D import Interpolate1D, interp1d \ No newline at end of file +from interpolate1d import interpolate1d, interp1d \ No newline at end of file Added: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-21 03:17:18 UTC (rev 4554) +++ branches/Interpolate1D/interpolate1d.py 2008-07-21 16:35:30 UTC (rev 4555) @@ -0,0 +1,384 @@ +""" + Interpolation of 1D data + + This module provides several functions and classes for interpolation + and extrapolation of 1D data (1D in both input and output). The + primary function provided is: + + interp1d(x, y, new_x) : from data points x and y, interpolates + values for points in new_x and + returns them as an array. + + Classes provided include: + + Interpolate1D : an object for interpolation of + various kinds. interp1d is a wrapper + around this class. + + Spline : an object for spline interpolation + + Functions provided include: + + linear : linear interpolation + logarithmic : logarithmic interpolation + block : block interpolation + block_average_above : block average above interpolation + +""" + +# FIXME: information strings giving mathematical descriptions of the actions +# of the functions. + +from interpolate_wrapper import linear, logarithmic, block, block_average_above +from fitpack_wrapper import Spline +import numpy as np +from numpy import array, arange, empty, float64, NaN + +def make_array_safe(ary, typecode=np.float64): + ary = np.atleast_1d(np.asarray(ary, typecode)) + if not ary.flags['CONTIGUOUS']: + ary = ary.copy() + return ary + +def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): + """ A function for interpolation of 1D data. + + REQUIRED ARGUMENTS: + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. Note that y must be + one-dimensional. + + new_x -- list or NumPy array + points whose value is to be interpolated from x and y. + new_x must be in sorted order, lowest to highest. + + OPTIONAL ARGUMENTS: + + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + If nothing else, assumes the argument is intended as a value + to be returned for all arguments. Defaults to linear interpolation. + + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. + + remove_bad_data -- bool + indicates whether to remove bad data. + + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. + + numpy.NaN is always considered bad data. + + SAMPLE ACCEPTABLE ARGUMENTS: + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN + + EXAMPLES: + >>> import numpy + >>> from Interpolate1D import interp1d + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> new_x = [.2, 2.3, 5.6] + >>> interp1d(x, y, new_x) + array([.2, 2.3, 5.6, NaN]) + """ + return Interpolate1D(x, y, kind=kind, low=low, high=high, kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ + remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) + +class interpolate1d(object): + """ An object for interpolation of 1D data. + + REQUIRED ARGUMENTS: + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. Note that y must be + one-dimensional. + + OPTIONAL ARGUMENTS: + + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + If nothing else, assumes the argument is intended as a value + to be returned for all arguments. Defaults to linear interpolation. + + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. + + remove_bad_data -- bool + indicates whether to remove bad data. + + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. + + numpy.NaN is always considered bad data. + + SAMPLE ACCEPTABLE ARGUMENTS: + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN + + EXAMPLES: + >>> import numpy + >>> from Interpolate1D import Interpolate1D + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> interp = Interpolate1D(x, y) + >>> new_x = [.2, 2.3, 5.6] + >>> interp(new_x) + array([.2, 2.3, 5.6, NaN]) + + """ + # FIXME: more informative descriptions of sample arguments + # FIXME: examples in doc string + + def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): + + self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) + + + self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) + self.low = self._init_interp_method(self._x, self._y, low, lowkw) + self.high = self._init_interp_method(self._x, self._y, high, highkw) + + def _format_array(self, x, y, remove_bad_data = False, bad_data = []):#=[None, np.NaN]):#=[None, np.NaN]): + """ + Assigns properly formatted versions of x and y to self._x and self._y. + Also records data types. + + Formatting includes removal of all points whose x or y coordinate + is in missing_data. This is the primary difference from + make_array_safe. + + """ + # FIXME: don't allow copying multiple times. + + # check acceptable lengths for x and y + assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ + arrays of length 0" + assert len(x) == len(y) , "x and y must be of the same length" + + # remove bad data + x = np.array(x) + y = np.array(y) + if remove_bad_data: + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) + print 'mask equals: ', mask, type(mask) + print 'x equals: ', x + print 'x[mask] is: ', x[mask] + x = x[mask] + y = y[mask] + + # collect dataypes and make arrays + self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 + self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._x = make_array_safe(x, self._xdtype).copy() + self._y = make_array_safe(y, self._ydtype).copy() + + # check dimensionality + assert self._x.ndim == 1 , "x must be one-dimensional" + assert self._y.ndim == 1 , "y must be one-dimensional" + + def _init_interp_method(self, x, y, interp_arg, kw): + """ + User provides interp_arg and dictionary kw. _init_interp_method + returns the interpolating function from x and y specified by interp_arg, + possibly with extra keyword arguments given in kw. + + """ + # FIXME : error checking specific to interpolation method. x and y long + # enough for order-3 spline if that's indicated, etc. Functions should throw + # errors themselves when Interpolate1D is called, but errors at instantiation + # would be nice. + + from inspect import isclass, isfunction + + # FIXME : more string options available ('cubic', etc) + if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: + func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ + 'block_average_above':block_average_above}[interp_arg] + result = lambda new_x : func(self._x, self._y, new_x, **kw) + elif interp_arg in ['Spline', Spline, 'spline']: + result = Spline(self._x, self._y, **kw) + elif isfunction(interp_arg): + result = lambda new_x : interp_arg(new_x, **kw) + elif isclass(interp_arg): + result = interp_arg(x, y, **kw) + else: + result = np.vectorize(lambda new_x : interp_arg) + return result + + def __call__(self, x): + """ + + """ + + x = make_array_safe(x) + low_mask = xself._x[-1] + interp_mask = (~low_mask) & (~high_mask) + + if len(x[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. + # if/else is a hack, since vectorize is failing + # to work on lists/arrays of length 0 + # on the computer where this is being + # developed + else: new_low = self.low(x[low_mask]) + if len(x[interp_mask])==0: new_interp=np.array([]) + else: new_interp = self.kind(x[interp_mask]) + if len(x[high_mask]) == 0: new_high = np.array([]) + else: new_high = self.high(x[high_mask]) + + result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes + + return result + +# unit testing +import unittest, time +class Test(unittest.TestCase): + + def assertAllclose(self, x, y): + self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) + + def test__interpolate_wrapper(self): + print "\n\nTESTING _interpolate_wrapper MODULE" + from interpolate_wrapper import Test + T = Test() + T.runTest() + + def test__fitpack_wrapper(self): + print "\n\nTESTING _fitpack_wrapper MODULE" + from fitpack_wrapper import Test + T = Test() + T.runTest() + + def test_spline1_defaultExt(self): + # make sure : spline order 1 (linear) interpolation works correctly + # make sure : default extrapolation works + print "\n\nTESTING LINEAR (1st ORDER) SPLINE" + N = 7 # must be > 5 + x = np.arange(N) + y = np.arange(N) + interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + + self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) + self.assert_(new_y[0] == None) + self.assert_(new_y[-1] == 599.73) + + def test_spline2(self): + print "\n\nTESTING 2nd ORDER SPLINE" + # make sure : order-2 splines work on linear data + N = 7 #must be > 5 + x = np.arange(N) + y = np.arange(N) + T1 = time.clock() + interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + T2 = time.clock() + print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 + new_x = np.arange(N+1)-0.5 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 + self.assertAllclose(new_x, new_y) + + # make sure for non-linear data + N = 7 + x = np.arange(N) + y = x**2 + interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_x**2, new_y) + + + def test_linear(self): + # make sure : linear interpolation works + # make sure : linear extrapolation works + print "\n\nTESTING LINEAR INTERPOLATION" + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + T1 = time.clock() + interp_func = Interpolate1D(x, y, kind='linear', low='linear', high='linear') + T2 = time.clock() + print "time to create linear interp function with N = %i: " % N, T2 - T1 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print "time to create linear interp function with N = %i: " % N, t2 - t1 + + self.assertAllclose(new_x, new_y) + + def test_noLow(self): + # make sure : having no out-of-range elements in new_x is fine + # There was a bug with this earlier. + N = 5 + x = arange(N) + y = arange(N) + new_x = arange(1,N-1)+.2 + interp_func = Interpolate1D(x, y, kind='linear', low='linear', high=np.NaN) + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_intper1d(self): + # make sure : interp1d works, at least in the linear case + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') + self.assertAllclose(new_x, new_y) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From scipy-svn at scipy.org Mon Jul 21 15:02:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 21 Jul 2008 14:02:33 -0500 (CDT) Subject: [Scipy-svn] r4556 - branches/Interpolate1D Message-ID: <20080721190233.62E9C39C2C4@scipy.org> Author: fcady Date: 2008-07-21 14:02:32 -0500 (Mon, 21 Jul 2008) New Revision: 4556 Added: branches/Interpolate1D/regression_test.py Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/__init__.py branches/Interpolate1D/interpolate1d.py Log: various changes, mostly to docstrings, and adding a simple regression test Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-21 16:35:30 UTC (rev 4555) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-21 19:02:32 UTC (rev 4556) @@ -11,7 +11,7 @@ Classes provided include: - Interpolate1D : an object for interpolation of + interpolate1d : an object for interpolation of various kinds. interp1d is a wrapper around this class. @@ -35,16 +35,21 @@ from numpy import array, arange, empty, float64, NaN def make_array_safe(ary, typecode=np.float64): + """Used to make sure that inputs and outputs are + properly formatted. + """ ary = np.atleast_1d(np.asarray(ary, typecode)) if not ary.flags['CONTIGUOUS']: ary = ary.copy() return ary -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): +def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): """ A function for interpolation of 1D data. - REQUIRED ARGUMENTS: + Parameters + ----------- x -- list or NumPy array x includes the x-values for the data set to @@ -60,7 +65,8 @@ points whose value is to be interpolated from x and y. new_x must be in sorted order, lowest to highest. - OPTIONAL ARGUMENTS: + Optional Arguments + ------------------- kind -- Usu. function or string. But can be any type. Specifies the type of extrapolation to use for values within @@ -89,7 +95,9 @@ numpy.NaN is always considered bad data. - SAMPLE ACCEPTABLE ARGUMENTS: + Acceptable Input Strings + ------------------------ + "linear" -- linear interpolation : default "logarithmic" -- logarithmic interpolation : linear in log space? "block" -- @@ -98,7 +106,9 @@ indicates order of spline numpy.NaN -- return numpy.NaN - EXAMPLES: + Examples + --------- + >>> import numpy >>> from Interpolate1D import interp1d >>> x = range(5) # note list is permitted @@ -107,14 +117,16 @@ >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) """ - return Interpolate1D(x, y, kind=kind, low=low, high=high, kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) + return Interpolate1D(x, y, kind=kind, low=low, high=high, \ + kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ + remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) -class interpolate1d(object): - """ An object for interpolation of 1D data. +class Interpolate1d(object): + """ A class for interpolation of 1D data. + + Parameters + ----------- - REQUIRED ARGUMENTS: - x -- list or NumPy array x includes the x-values for the data set to interpolate from. It must be sorted in @@ -125,7 +137,8 @@ interpolate from. Note that y must be one-dimensional. - OPTIONAL ARGUMENTS: + Optional Arguments + ------------------- kind -- Usu. function or string. But can be any type. Specifies the type of extrapolation to use for values within @@ -154,7 +167,9 @@ numpy.NaN is always considered bad data. - SAMPLE ACCEPTABLE ARGUMENTS: + Acceptable Input Strings + ------------------------ + "linear" -- linear interpolation : default "logarithmic" -- logarithmic interpolation : linear in log space? "block" -- @@ -163,21 +178,22 @@ indicates order of spline numpy.NaN -- return numpy.NaN - EXAMPLES: + Examples + --------- + >>> import numpy - >>> from Interpolate1D import Interpolate1D + >>> from Interpolate1D import interp1d >>> x = range(5) # note list is permitted >>> y = numpy.arange(5.) - >>> interp = Interpolate1D(x, y) >>> new_x = [.2, 2.3, 5.6] - >>> interp(new_x) + >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) - """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ + def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) @@ -187,15 +203,15 @@ self.low = self._init_interp_method(self._x, self._y, low, lowkw) self.high = self._init_interp_method(self._x, self._y, high, highkw) - def _format_array(self, x, y, remove_bad_data = False, bad_data = []):#=[None, np.NaN]):#=[None, np.NaN]): + def _format_array(self, x, y, remove_bad_data = False, bad_data = []): """ - Assigns properly formatted versions of x and y to self._x and self._y. - Also records data types. + Assigns properly formatted versions of x and y to self._x and self._y. + Also records data types. + + Formatting includes removal of all points whose x or y coordinate + is in missing_data. This is the primary difference from + make_array_safe. - Formatting includes removal of all points whose x or y coordinate - is in missing_data. This is the primary difference from - make_array_safe. - """ # FIXME: don't allow copying multiple times. @@ -208,11 +224,9 @@ x = np.array(x) y = np.array(y) if remove_bad_data: - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - print 'mask equals: ', mask, type(mask) - print 'x equals: ', x - print 'x[mask] is: ', x[mask] + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ + (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) x = x[mask] y = y[mask] @@ -228,15 +242,14 @@ def _init_interp_method(self, x, y, interp_arg, kw): """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. + User provides interp_arg and dictionary kw. _init_interp_method + returns the interpolating function from x and y specified by interp_arg, + possibly with extra keyword arguments given in kw. """ # FIXME : error checking specific to interpolation method. x and y long # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves when Interpolate1D is called, but errors at instantiation - # would be nice. + # errors themselves, but errors at instantiation would be nice. from inspect import isclass, isfunction @@ -257,7 +270,9 @@ def __call__(self, x): """ - + Input x must be in sorted order. + Breaks x into pieces in-range, below-range, and above range. + Performs appropriate operation on each and concatenates results. """ x = make_array_safe(x) @@ -277,6 +292,8 @@ else: new_high = self.high(x[high_mask]) result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes + # Would be nice to say result = zeros(dtype=?) + # and fill in return result @@ -288,25 +305,31 @@ self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) def test__interpolate_wrapper(self): + """ run unit test contained in interpolate_wrapper.py + """ print "\n\nTESTING _interpolate_wrapper MODULE" from interpolate_wrapper import Test T = Test() T.runTest() def test__fitpack_wrapper(self): + """ run unit test contained in fitpack_wrapper.py + """ print "\n\nTESTING _fitpack_wrapper MODULE" from fitpack_wrapper import Test T = Test() T.runTest() def test_spline1_defaultExt(self): - # make sure : spline order 1 (linear) interpolation works correctly - # make sure : default extrapolation works + """ + make sure : spline order 1 (linear) interpolation works correctly + make sure : default extrapolation works + """ print "\n\nTESTING LINEAR (1st ORDER) SPLINE" N = 7 # must be > 5 x = np.arange(N) y = np.arange(N) - interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) new_x = np.arange(N+1)-0.5 new_y = interp_func(new_x) @@ -315,13 +338,16 @@ self.assert_(new_y[-1] == 599.73) def test_spline2(self): + """ + make sure : order-2 splines work on linear data + make sure : order-2 splines work on non-linear data + """ print "\n\nTESTING 2nd ORDER SPLINE" - # make sure : order-2 splines work on linear data N = 7 #must be > 5 x = np.arange(N) y = np.arange(N) T1 = time.clock() - interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') T2 = time.clock() print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 new_x = np.arange(N+1)-0.5 @@ -335,22 +361,24 @@ N = 7 x = np.arange(N) y = x**2 - interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') new_x = np.arange(N+1)-0.5 new_y = interp_func(new_x) self.assertAllclose(new_x**2, new_y) def test_linear(self): - # make sure : linear interpolation works - # make sure : linear extrapolation works + """ + make sure : linear interpolation works + make sure : linear extrapolation works + """ print "\n\nTESTING LINEAR INTERPOLATION" N = 7 x = arange(N) y = arange(N) new_x = arange(N+1)-0.5 T1 = time.clock() - interp_func = Interpolate1D(x, y, kind='linear', low='linear', high='linear') + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') T2 = time.clock() print "time to create linear interp function with N = %i: " % N, T2 - T1 t1 = time.clock() @@ -361,18 +389,22 @@ self.assertAllclose(new_x, new_y) def test_noLow(self): - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. + """ + make sure : having no out-of-range elements in new_x is fine + There was a bug with this earlier. + """ N = 5 x = arange(N) y = arange(N) new_x = arange(1,N-1)+.2 - interp_func = Interpolate1D(x, y, kind='linear', low='linear', high=np.NaN) + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) new_y = interp_func(new_x) self.assertAllclose(new_x, new_y) def test_intper1d(self): - # make sure : interp1d works, at least in the linear case + """ + make sure : interp1d works, at least in the linear case + """ N = 7 x = arange(N) y = arange(N) Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-21 16:35:30 UTC (rev 4555) +++ branches/Interpolate1D/TODO.txt 2008-07-21 19:02:32 UTC (rev 4556) @@ -6,15 +6,29 @@ **comment interpolate1d +There's comments there already, but they should be +made better. **doc strings for interpolate1d and its members +There's docstrings there already, but they should be +made better. In particular, it must be ensured that +they are of the proper format and include examples. +The doc strings for __init__.py, interpolate1d.py, +Interpolate1d, and interp1d are virtually identical +and very long; perhaps a master string can be stored +somewhere that they all reference. This would make +updates of documentation easier. + **more strings user can pass ('cubic', etc) +User can specify interpolation type as a string argument +to interpolate1d at initialization. More strings should work. **figure out NumPy version stuff with vectorize. +In function interpolate1d._format_array. It would be nice to remove the hack I used. I believe vectorize is supposed to handle arrays of length 0, but it's not working on my computer. @@ -53,6 +67,13 @@ code out there too. Figure out what is best and incorporate it. +**high-level road map +when the module is more established, there should be a page on +the wiki which describes the big-picture of the module; what +the capabilities are and which should be added, large-scale +architecture of the module, etc. + + **update for 2D and ND This will probably take the form of two additional classes both based on interpolate1d. Thus it probably Modified: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-21 16:35:30 UTC (rev 4555) +++ branches/Interpolate1D/__init__.py 2008-07-21 19:02:32 UTC (rev 4556) @@ -1,32 +1,32 @@ #FIXME : better docstring """ -Interpolation of 1D data + Interpolation of 1D data -This module provides several functions and classes for interpolation -and extrapolation of 1D data (1D in both input and output). The -primary function provided is: + This module provides several functions and classes for interpolation + and extrapolation of 1D data (1D in both input and output). The + primary function provided is: - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. + interp1d(x, y, new_x) : from data points x and y, interpolates + values for points in new_x and + returns them as an array. -Classes provided include: + Classes provided include: - Interpolate1D : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - -Functions provided include: + Interpolate1d : an object for interpolation of + various kinds. interp1d is a wrapper + around this class. + + Spline : an object for spline interpolation + + Functions provided include: - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation + linear : linear interpolation + logarithmic : logarithmic interpolation + block : block interpolation + block_average_above : block average above interpolation """ from interpolate_wrapper import linear, logarithmic, block, block_average_above from fitpack_wrapper import Spline -from interpolate1d import interpolate1d, interp1d \ No newline at end of file +from interpolate1d import Interpolate1d, interp1d \ No newline at end of file Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-21 16:35:30 UTC (rev 4555) +++ branches/Interpolate1D/interpolate1d.py 2008-07-21 19:02:32 UTC (rev 4556) @@ -11,7 +11,7 @@ Classes provided include: - Interpolate1D : an object for interpolation of + interpolate1d : an object for interpolation of various kinds. interp1d is a wrapper around this class. @@ -35,16 +35,21 @@ from numpy import array, arange, empty, float64, NaN def make_array_safe(ary, typecode=np.float64): + """Used to make sure that inputs and outputs are + properly formatted. + """ ary = np.atleast_1d(np.asarray(ary, typecode)) if not ary.flags['CONTIGUOUS']: ary = ary.copy() return ary -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): +def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): """ A function for interpolation of 1D data. - REQUIRED ARGUMENTS: + Parameters + ----------- x -- list or NumPy array x includes the x-values for the data set to @@ -60,7 +65,8 @@ points whose value is to be interpolated from x and y. new_x must be in sorted order, lowest to highest. - OPTIONAL ARGUMENTS: + Optional Arguments + ------------------- kind -- Usu. function or string. But can be any type. Specifies the type of extrapolation to use for values within @@ -89,7 +95,9 @@ numpy.NaN is always considered bad data. - SAMPLE ACCEPTABLE ARGUMENTS: + Acceptable Input Strings + ------------------------ + "linear" -- linear interpolation : default "logarithmic" -- logarithmic interpolation : linear in log space? "block" -- @@ -98,7 +106,9 @@ indicates order of spline numpy.NaN -- return numpy.NaN - EXAMPLES: + Examples + --------- + >>> import numpy >>> from Interpolate1D import interp1d >>> x = range(5) # note list is permitted @@ -107,14 +117,16 @@ >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) """ - return Interpolate1D(x, y, kind=kind, low=low, high=high, kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) + return Interpolate1D(x, y, kind=kind, low=low, high=high, \ + kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ + remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) -class interpolate1d(object): - """ An object for interpolation of 1D data. +class Interpolate1d(object): + """ A class for interpolation of 1D data. + + Parameters + ----------- - REQUIRED ARGUMENTS: - x -- list or NumPy array x includes the x-values for the data set to interpolate from. It must be sorted in @@ -125,7 +137,8 @@ interpolate from. Note that y must be one-dimensional. - OPTIONAL ARGUMENTS: + Optional Arguments + ------------------- kind -- Usu. function or string. But can be any type. Specifies the type of extrapolation to use for values within @@ -154,7 +167,9 @@ numpy.NaN is always considered bad data. - SAMPLE ACCEPTABLE ARGUMENTS: + Acceptable Input Strings + ------------------------ + "linear" -- linear interpolation : default "logarithmic" -- logarithmic interpolation : linear in log space? "block" -- @@ -163,21 +178,22 @@ indicates order of spline numpy.NaN -- return numpy.NaN - EXAMPLES: + Examples + --------- + >>> import numpy - >>> from Interpolate1D import Interpolate1D + >>> from Interpolate1D import interp1d >>> x = range(5) # note list is permitted >>> y = numpy.arange(5.) - >>> interp = Interpolate1D(x, y) >>> new_x = [.2, 2.3, 5.6] - >>> interp(new_x) + >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) - """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, kindkw={}, lowkw={}, highkw={}, \ + def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) @@ -187,15 +203,15 @@ self.low = self._init_interp_method(self._x, self._y, low, lowkw) self.high = self._init_interp_method(self._x, self._y, high, highkw) - def _format_array(self, x, y, remove_bad_data = False, bad_data = []):#=[None, np.NaN]):#=[None, np.NaN]): + def _format_array(self, x, y, remove_bad_data = False, bad_data = []): """ - Assigns properly formatted versions of x and y to self._x and self._y. - Also records data types. + Assigns properly formatted versions of x and y to self._x and self._y. + Also records data types. + + Formatting includes removal of all points whose x or y coordinate + is in missing_data. This is the primary difference from + make_array_safe. - Formatting includes removal of all points whose x or y coordinate - is in missing_data. This is the primary difference from - make_array_safe. - """ # FIXME: don't allow copying multiple times. @@ -208,11 +224,9 @@ x = np.array(x) y = np.array(y) if remove_bad_data: - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - print 'mask equals: ', mask, type(mask) - print 'x equals: ', x - print 'x[mask] is: ', x[mask] + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ + (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) x = x[mask] y = y[mask] @@ -228,15 +242,14 @@ def _init_interp_method(self, x, y, interp_arg, kw): """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. + User provides interp_arg and dictionary kw. _init_interp_method + returns the interpolating function from x and y specified by interp_arg, + possibly with extra keyword arguments given in kw. """ # FIXME : error checking specific to interpolation method. x and y long # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves when Interpolate1D is called, but errors at instantiation - # would be nice. + # errors themselves, but errors at instantiation would be nice. from inspect import isclass, isfunction @@ -257,7 +270,9 @@ def __call__(self, x): """ - + Input x must be in sorted order. + Breaks x into pieces in-range, below-range, and above range. + Performs appropriate operation on each and concatenates results. """ x = make_array_safe(x) @@ -277,6 +292,8 @@ else: new_high = self.high(x[high_mask]) result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes + # Would be nice to say result = zeros(dtype=?) + # and fill in return result @@ -288,25 +305,31 @@ self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) def test__interpolate_wrapper(self): + """ run unit test contained in interpolate_wrapper.py + """ print "\n\nTESTING _interpolate_wrapper MODULE" from interpolate_wrapper import Test T = Test() T.runTest() def test__fitpack_wrapper(self): + """ run unit test contained in fitpack_wrapper.py + """ print "\n\nTESTING _fitpack_wrapper MODULE" from fitpack_wrapper import Test T = Test() T.runTest() def test_spline1_defaultExt(self): - # make sure : spline order 1 (linear) interpolation works correctly - # make sure : default extrapolation works + """ + make sure : spline order 1 (linear) interpolation works correctly + make sure : default extrapolation works + """ print "\n\nTESTING LINEAR (1st ORDER) SPLINE" N = 7 # must be > 5 x = np.arange(N) y = np.arange(N) - interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) new_x = np.arange(N+1)-0.5 new_y = interp_func(new_x) @@ -315,13 +338,16 @@ self.assert_(new_y[-1] == 599.73) def test_spline2(self): + """ + make sure : order-2 splines work on linear data + make sure : order-2 splines work on non-linear data + """ print "\n\nTESTING 2nd ORDER SPLINE" - # make sure : order-2 splines work on linear data N = 7 #must be > 5 x = np.arange(N) y = np.arange(N) T1 = time.clock() - interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') T2 = time.clock() print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 new_x = np.arange(N+1)-0.5 @@ -335,22 +361,24 @@ N = 7 x = np.arange(N) y = x**2 - interp_func = Interpolate1D(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') new_x = np.arange(N+1)-0.5 new_y = interp_func(new_x) self.assertAllclose(new_x**2, new_y) def test_linear(self): - # make sure : linear interpolation works - # make sure : linear extrapolation works + """ + make sure : linear interpolation works + make sure : linear extrapolation works + """ print "\n\nTESTING LINEAR INTERPOLATION" N = 7 x = arange(N) y = arange(N) new_x = arange(N+1)-0.5 T1 = time.clock() - interp_func = Interpolate1D(x, y, kind='linear', low='linear', high='linear') + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') T2 = time.clock() print "time to create linear interp function with N = %i: " % N, T2 - T1 t1 = time.clock() @@ -361,18 +389,22 @@ self.assertAllclose(new_x, new_y) def test_noLow(self): - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. + """ + make sure : having no out-of-range elements in new_x is fine + There was a bug with this earlier. + """ N = 5 x = arange(N) y = arange(N) new_x = arange(1,N-1)+.2 - interp_func = Interpolate1D(x, y, kind='linear', low='linear', high=np.NaN) + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) new_y = interp_func(new_x) self.assertAllclose(new_x, new_y) def test_intper1d(self): - # make sure : interp1d works, at least in the linear case + """ + make sure : interp1d works, at least in the linear case + """ N = 7 x = arange(N) y = arange(N) Added: branches/Interpolate1D/regression_test.py =================================================================== --- branches/Interpolate1D/regression_test.py 2008-07-21 16:35:30 UTC (rev 4555) +++ branches/Interpolate1D/regression_test.py 2008-07-21 19:02:32 UTC (rev 4556) @@ -0,0 +1,32 @@ +""" regression test: + + This script runs a simple regression test on the functionality of + the interpolation module. Currently, when run, it times each + unit test in interpolate1d.py and stores those times in a dict + of dicts; outer keys are time test was performed, and inner + keys are names of tests run. + +""" + +import shelve, time +from interpolate1d import Test + +# name of log file to which all data is stored. +filename = 'regression_test.dbm' + +log_total = shelve.open(filename) +current_time = str(time.localtime()[0:5]) # specified up to minute + +# run all tests in interpolate1d's test class +test_list = [name for name in dir(Test) if name.find('test_') == 0] +log_now = {} + +# record time taken for each test +for test_name in test_list: + t1 = time.clock() + eval('Test.%s' % test_name) + t2 = time.clock() + log_now[test_name] = t2-t1 + +log_total[current_time] = log_now +log_total.close() From scipy-svn at scipy.org Tue Jul 22 14:52:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 22 Jul 2008 13:52:20 -0500 (CDT) Subject: [Scipy-svn] r4557 - in trunk/scipy: cluster/tests fftpack/benchmarks fftpack/tests integrate/tests interpolate/tests io/tests lib/blas/tests lib/lapack/tests linalg/benchmarks linalg/tests maxentropy/tests misc/tests ndimage/tests odr/tests optimize/benchmarks optimize/tests signal/tests sparse/benchmarks sparse/linalg/dsolve/tests sparse/linalg/eigen/arpack/tests sparse/linalg/eigen/lobpcg/tests sparse/tests special/tests stats stats/models/tests stats/tests Message-ID: <20080722185220.12E0239C107@scipy.org> Author: alan.mcintyre Date: 2008-07-22 13:51:24 -0500 (Tue, 22 Jul 2008) New Revision: 4557 Modified: trunk/scipy/cluster/tests/test_hierarchy.py trunk/scipy/cluster/tests/test_vq.py trunk/scipy/fftpack/benchmarks/bench_basic.py trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py trunk/scipy/fftpack/tests/test_basic.py trunk/scipy/fftpack/tests/test_helper.py trunk/scipy/fftpack/tests/test_pseudo_diffs.py trunk/scipy/integrate/tests/test_integrate.py trunk/scipy/integrate/tests/test_quadpack.py trunk/scipy/integrate/tests/test_quadrature.py trunk/scipy/interpolate/tests/test_fitpack.py trunk/scipy/interpolate/tests/test_interpolate.py trunk/scipy/interpolate/tests/test_polyint.py trunk/scipy/interpolate/tests/test_rbf.py trunk/scipy/io/tests/test_array_import.py trunk/scipy/io/tests/test_mmio.py trunk/scipy/io/tests/test_npfile.py trunk/scipy/io/tests/test_recaster.py trunk/scipy/lib/blas/tests/test_blas.py trunk/scipy/lib/blas/tests/test_fblas.py trunk/scipy/lib/lapack/tests/test_lapack.py trunk/scipy/linalg/benchmarks/bench_basic.py trunk/scipy/linalg/tests/test_basic.py trunk/scipy/linalg/tests/test_blas.py trunk/scipy/linalg/tests/test_decomp.py trunk/scipy/linalg/tests/test_fblas.py trunk/scipy/linalg/tests/test_lapack.py trunk/scipy/linalg/tests/test_matfuncs.py trunk/scipy/maxentropy/tests/test_maxentropy.py trunk/scipy/misc/tests/test_pilutil.py trunk/scipy/ndimage/tests/test_ndimage.py trunk/scipy/ndimage/tests/test_registration.py trunk/scipy/odr/tests/test_odr.py trunk/scipy/optimize/benchmarks/bench_zeros.py trunk/scipy/optimize/tests/test_cobyla.py trunk/scipy/optimize/tests/test_nonlin.py trunk/scipy/optimize/tests/test_optimize.py trunk/scipy/optimize/tests/test_slsqp.py trunk/scipy/optimize/tests/test_zeros.py trunk/scipy/signal/tests/test_signaltools.py trunk/scipy/signal/tests/test_wavelets.py trunk/scipy/sparse/benchmarks/bench_sparse.py trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py trunk/scipy/sparse/tests/test_base.py trunk/scipy/sparse/tests/test_construct.py trunk/scipy/sparse/tests/test_spfuncs.py trunk/scipy/sparse/tests/test_sputils.py trunk/scipy/special/tests/test_basic.py trunk/scipy/special/tests/test_spfun_stats.py trunk/scipy/stats/models/tests/test_bspline.py trunk/scipy/stats/models/tests/test_formula.py trunk/scipy/stats/models/tests/test_glm.py trunk/scipy/stats/models/tests/test_regression.py trunk/scipy/stats/models/tests/test_rlm.py trunk/scipy/stats/models/tests/test_scale.py trunk/scipy/stats/models/tests/test_utils.py trunk/scipy/stats/morestats.py trunk/scipy/stats/tests/test_distributions.py trunk/scipy/stats/tests/test_mmorestats.py trunk/scipy/stats/tests/test_morestats.py trunk/scipy/stats/tests/test_mstats.py trunk/scipy/stats/tests/test_stats.py Log: Use numpy.testing.verbose to control when information not related to a test failure is displayed. Updated "if __name__ == '__main__'" boilerplate to use numpy.testing.run_module_suite instead of directly using nose.run. Removed code/functions (set_package_path,set_local_path,restore_path) that manipulates sys.path. Replaced print statements containing user warnings with warnings.warn. Modified: trunk/scipy/cluster/tests/test_hierarchy.py =================================================================== --- trunk/scipy/cluster/tests/test_hierarchy.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -122,7 +122,8 @@ Yr = squareform(A) s = A.shape k = 0 - print A.shape, Y.shape, Yr.shape + if verbose >= 3: + print A.shape, Y.shape, Yr.shape self.failUnless(len(s) == 2) self.failUnless(len(Yr.shape) == 1) self.failUnless(s[0] == s[1]) @@ -144,7 +145,8 @@ X = numpy.random.rand(n, 4) Y = pdist(X) A = squareform(Y) - print A.shape, Y.shape + if verbose >= 3: + print A.shape, Y.shape self.failUnless(numobs_dm(A) == n) def test_numobs_y_multi_matrix(self): @@ -206,5 +208,5 @@ return numpy.abs(a - b).max() < tol if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/cluster/tests/test_vq.py =================================================================== --- trunk/scipy/cluster/tests/test_vq.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/cluster/tests/test_vq.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -182,4 +182,4 @@ pass if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/fftpack/benchmarks/bench_basic.py =================================================================== --- trunk/scipy/fftpack/benchmarks/bench_basic.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/fftpack/benchmarks/bench_basic.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -217,4 +217,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py =================================================================== --- trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -183,4 +183,4 @@ print ' (secs for %s calls)' % (repeat) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/fftpack/tests/test_basic.py =================================================================== --- trunk/scipy/fftpack/tests/test_basic.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/fftpack/tests/test_basic.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -389,4 +389,4 @@ assert_array_almost_equal (fftn(ifftn(x)),x) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/fftpack/tests/test_helper.py =================================================================== --- trunk/scipy/fftpack/tests/test_helper.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/fftpack/tests/test_helper.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -58,4 +58,4 @@ assert_array_almost_equal(10*pi*rfftfreq(10,pi),x) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/fftpack/tests/test_pseudo_diffs.py =================================================================== --- trunk/scipy/fftpack/tests/test_pseudo_diffs.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/fftpack/tests/test_pseudo_diffs.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -314,4 +314,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/integrate/tests/test_integrate.py =================================================================== --- trunk/scipy/integrate/tests/test_integrate.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/integrate/tests/test_integrate.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -143,4 +143,4 @@ #------------------------------------------------------------------------------ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/integrate/tests/test_quadpack.py =================================================================== --- trunk/scipy/integrate/tests/test_quadpack.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/integrate/tests/test_quadpack.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -104,4 +104,4 @@ 8/3.0 * (b**4.0 - a**4.0)) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/integrate/tests/test_quadrature.py =================================================================== --- trunk/scipy/integrate/tests/test_quadrature.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/integrate/tests/test_quadrature.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -29,4 +29,4 @@ assert_equal(romb(numpy.arange(17)),128) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/interpolate/tests/test_fitpack.py =================================================================== --- trunk/scipy/interpolate/tests/test_fitpack.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/interpolate/tests/test_fitpack.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -144,4 +144,4 @@ assert_array_almost_equal(lut(x,y),z) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/interpolate/tests/test_interpolate.py =================================================================== --- trunk/scipy/interpolate/tests/test_interpolate.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/interpolate/tests/test_interpolate.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -245,4 +245,4 @@ assert_array_almost_equal(p.coeffs,pl.coeffs) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/interpolate/tests/test_polyint.py =================================================================== --- trunk/scipy/interpolate/tests/test_polyint.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/interpolate/tests/test_polyint.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -259,4 +259,4 @@ if __name__=='__main__': - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/interpolate/tests/test_rbf.py =================================================================== --- trunk/scipy/interpolate/tests/test_rbf.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/interpolate/tests/test_rbf.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -36,5 +36,4 @@ assert_array_almost_equal(di, d) if __name__ == "__main__": - import nose - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/io/tests/test_array_import.py =================================================================== --- trunk/scipy/io/tests/test_array_import.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/io/tests/test_array_import.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -24,7 +24,8 @@ fid.close() # Reopen the file and read in data fid = open(fname,"rb") - print "\nDon't worry about a warning regarding the number of bytes read." + if verbose >= 3: + print "\nDon't worry about a warning regarding the number of bytes read." b = numpyio.fread(fid,1000000,N.Int16,N.Int) fid.close() assert(N.product(a.astype(N.Int16) == b,axis=0)) @@ -64,4 +65,4 @@ f.close() if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/io/tests/test_mmio.py =================================================================== --- trunk/scipy/io/tests/test_mmio.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/io/tests/test_mmio.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -315,4 +315,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/io/tests/test_npfile.py =================================================================== --- trunk/scipy/io/tests/test_npfile.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/io/tests/test_npfile.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -102,4 +102,4 @@ assert_array_equal(npf.read_array(adt, shp, order='C'), cf_arr) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/io/tests/test_recaster.py =================================================================== --- trunk/scipy/io/tests/test_recaster.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/io/tests/test_recaster.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -173,4 +173,4 @@ 'Expected %s from %s, got %s' % (outp, inp, dtt) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/lib/blas/tests/test_blas.py =================================================================== --- trunk/scipy/lib/blas/tests/test_blas.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/lib/blas/tests/test_blas.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -223,4 +223,4 @@ """ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/lib/blas/tests/test_fblas.py =================================================================== --- trunk/scipy/lib/blas/tests/test_fblas.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/lib/blas/tests/test_fblas.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -522,4 +522,4 @@ """ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/lib/lapack/tests/test_lapack.py =================================================================== --- trunk/scipy/lib/lapack/tests/test_lapack.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/lib/lapack/tests/test_lapack.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -21,10 +21,10 @@ from scipy.lib.lapack import flapack, clapack -sys.path.insert(0, os.path.split(__file__)) +#sys.path.insert(0, os.path.split(__file__)) from gesv_tests import _test_gev from esv_tests import _test_ev -del sys.path[0] +#del sys.path[0] #class _test_ev: pass Modified: trunk/scipy/linalg/benchmarks/bench_basic.py =================================================================== --- trunk/scipy/linalg/benchmarks/bench_basic.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/benchmarks/bench_basic.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -127,4 +127,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/linalg/tests/test_basic.py =================================================================== --- trunk/scipy/linalg/tests/test_basic.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/tests/test_basic.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -429,4 +429,4 @@ assert_array_almost_equal(a_pinv,a_pinv2) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/linalg/tests/test_blas.py =================================================================== --- trunk/scipy/linalg/tests/test_blas.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/tests/test_blas.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -213,4 +213,4 @@ """ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/linalg/tests/test_decomp.py =================================================================== --- trunk/scipy/linalg/tests/test_decomp.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/tests/test_decomp.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -906,4 +906,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/linalg/tests/test_fblas.py =================================================================== --- trunk/scipy/linalg/tests/test_fblas.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/tests/test_fblas.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -525,4 +525,4 @@ """ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/linalg/tests/test_lapack.py =================================================================== --- trunk/scipy/linalg/tests/test_lapack.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/tests/test_lapack.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -68,4 +68,4 @@ """ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/linalg/tests/test_matfuncs.py =================================================================== --- trunk/scipy/linalg/tests/test_matfuncs.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/linalg/tests/test_matfuncs.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -98,4 +98,4 @@ assert_array_almost_equal(expm3(a),[[1,0],[0,1]]) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/maxentropy/tests/test_maxentropy.py =================================================================== --- trunk/scipy/maxentropy/tests/test_maxentropy.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/maxentropy/tests/test_maxentropy.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -36,4 +36,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/misc/tests/test_pilutil.py =================================================================== --- trunk/scipy/misc/tests/test_pilutil.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/misc/tests/test_pilutil.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -48,4 +48,4 @@ decorate_methods(TestPILUtil, _pilskip) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/ndimage/tests/test_ndimage.py =================================================================== --- trunk/scipy/ndimage/tests/test_ndimage.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/ndimage/tests/test_ndimage.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -5513,4 +5513,4 @@ # return len(result.failures), result.testsRun if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/ndimage/tests/test_registration.py =================================================================== --- trunk/scipy/ndimage/tests/test_registration.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/ndimage/tests/test_registration.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -186,7 +186,7 @@ if __name__ == "__main__": #nose.runmodule() - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/odr/tests/test_odr.py =================================================================== --- trunk/scipy/odr/tests/test_odr.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/odr/tests/test_odr.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -311,5 +311,5 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() #### EOF ####################################################################### Modified: trunk/scipy/optimize/benchmarks/bench_zeros.py =================================================================== --- trunk/scipy/optimize/benchmarks/bench_zeros.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/optimize/benchmarks/bench_zeros.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -32,4 +32,4 @@ print '\n\n' if __name__ == '__main__' : - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/optimize/tests/test_cobyla.py =================================================================== --- trunk/scipy/optimize/tests/test_cobyla.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/optimize/tests/test_cobyla.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -18,4 +18,4 @@ assert_almost_equal(x, [x0, x1], decimal=5) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/optimize/tests/test_nonlin.py =================================================================== --- trunk/scipy/optimize/tests/test_nonlin.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/optimize/tests/test_nonlin.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -91,4 +91,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/optimize/tests/test_optimize.py =================================================================== --- trunk/scipy/optimize/tests/test_optimize.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/optimize/tests/test_optimize.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -289,4 +289,4 @@ assert_array_equal(p0, p0_copy) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/optimize/tests/test_slsqp.py =================================================================== --- trunk/scipy/optimize/tests/test_slsqp.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/optimize/tests/test_slsqp.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -86,4 +86,4 @@ assert_array_almost_equal(x,[2,1],decimal=3) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/optimize/tests/test_zeros.py =================================================================== --- trunk/scipy/optimize/tests/test_zeros.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/optimize/tests/test_zeros.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -31,4 +31,4 @@ if __name__ == '__main__' : - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/signal/tests/test_signaltools.py =================================================================== --- trunk/scipy/signal/tests/test_signaltools.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/signal/tests/test_signaltools.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -56,4 +56,5 @@ [2,3,2]) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() + Modified: trunk/scipy/signal/tests/test_wavelets.py =================================================================== --- trunk/scipy/signal/tests/test_wavelets.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/signal/tests/test_wavelets.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -76,4 +76,4 @@ assert_array_almost_equal(x,y,decimal=2) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/benchmarks/bench_sparse.py =================================================================== --- trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -315,4 +315,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py =================================================================== --- trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -40,4 +40,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -239,8 +239,9 @@ exact_eval=d['eval'].astype(typ.upper()) ind=self.sort_choose(exact_eval,typ,k,which) exact_eval=exact_eval[ind] - print "exact" - print exact_eval + if verbose >= 3: + print "exact" + print exact_eval # compute eigenvalues @@ -248,7 +249,8 @@ ind=self.sort_choose(eval,typ,k,which) eval=eval[ind] evec=evec[:,ind] - print eval + if verbose >= 3: + print eval # check eigenvalues # check eigenvectors A*evec=eval*evec for i in range(k): @@ -269,4 +271,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -50,4 +50,4 @@ # 94.646308846854879, 95.30841709116271], decimal=11) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py =================================================================== --- trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -80,4 +80,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/tests/test_base.py =================================================================== --- trunk/scipy/sparse/tests/test_base.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/tests/test_base.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -1418,4 +1418,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/tests/test_construct.py =================================================================== --- trunk/scipy/sparse/tests/test_construct.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/tests/test_construct.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -205,4 +205,4 @@ [6,5,0]]) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/tests/test_spfuncs.py =================================================================== --- trunk/scipy/sparse/tests/test_spfuncs.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/tests/test_spfuncs.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -102,4 +102,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/sparse/tests/test_sputils.py =================================================================== --- trunk/scipy/sparse/tests/test_sputils.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/sparse/tests/test_sputils.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -67,4 +67,4 @@ assert_equal(isdense( np.matrix([1]) ),True) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/special/tests/test_basic.py =================================================================== --- trunk/scipy/special/tests/test_basic.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/special/tests/test_basic.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -2003,4 +2003,4 @@ assert_almost_equal(sy3,sphpy,4) #compare correct derivative val. (correct =-system val). if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/special/tests/test_spfun_stats.py =================================================================== --- trunk/scipy/special/tests/test_spfun_stats.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/special/tests/test_spfun_stats.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -35,4 +35,4 @@ pass if __name__ == '__main__': - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_bspline.py =================================================================== --- trunk/scipy/stats/models/tests/test_bspline.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_bspline.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -24,4 +24,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_formula.py =================================================================== --- trunk/scipy/stats/models/tests/test_formula.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_formula.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -314,4 +314,4 @@ assert_equal(set(ff.termnames()), set(['a', 'b', 'c', 'b*c'])) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_glm.py =================================================================== --- trunk/scipy/stats/models/tests/test_glm.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_glm.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -31,4 +31,4 @@ self.assertEquals(results.df_resid, 31) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_regression.py =================================================================== --- trunk/scipy/stats/models/tests/test_regression.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_regression.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -42,4 +42,4 @@ self.assertEquals(results.df_resid, 31) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_rlm.py =================================================================== --- trunk/scipy/stats/models/tests/test_rlm.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_rlm.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -27,4 +27,4 @@ self.assertEquals(results.df_resid, 31) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_scale.py =================================================================== --- trunk/scipy/stats/models/tests/test_scale.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_scale.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -50,4 +50,4 @@ self.assertEquals(m.shape, (40,10)) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/models/tests/test_utils.py =================================================================== --- trunk/scipy/stats/models/tests/test_utils.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/models/tests/test_utils.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -55,4 +55,4 @@ self.assertRaises(ValueError, utils.StepFunction, x, y) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/morestats.py =================================================================== --- trunk/scipy/stats/morestats.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/morestats.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -18,6 +18,7 @@ import futil import numpy as sb from numpy.testing.decorators import setastest +import warnings __all__ = ['find_repeats', 'bayes_mvs', 'kstat', 'kstatvar', 'probplot', 'ppcc_max', 'ppcc_plot', @@ -475,9 +476,9 @@ y = sort(x) a,w,pw,ifault = statlib.swilk(y,a[:N/2],init) if not ifault in [0,2]: - print ifault + warnings.warn(str(ifault)) if N > 5000: - print "p-value may not be accurate for N > 5000." + warnings.warn("p-value may not be accurate for N > 5000.") if reta: return w, pw, a else: @@ -616,7 +617,7 @@ repeats = (len(uxy) != len(xy)) exact = ((m<55) and (n<55) and not repeats) if repeats and ((m < 55) or (n < 55)): - print "Ties preclude use of exact statistic." + warnings.warn("Ties preclude use of exact statistic.") if exact: astart, a1, ifault = statlib.gscale(n,m) ind = AB-astart @@ -972,7 +973,7 @@ d = compress(not_equal(d,0),d,axis=-1) # Keep all non-zero differences count = len(d) if (count < 10): - print "Warning: sample size too small for normal approximation." + warnings.warn("Warning: sample size too small for normal approximation.") r = stats.rankdata(abs(d)) r_plus = sum((d > 0)*r,axis=0) r_minus = sum((d < 0)*r,axis=0) Modified: trunk/scipy/stats/tests/test_distributions.py =================================================================== --- trunk/scipy/stats/tests/test_distributions.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/tests/test_distributions.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -213,4 +213,4 @@ assert_equal(stats.expon.pdf(0),1) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/tests/test_mmorestats.py =================================================================== --- trunk/scipy/stats/tests/test_mmorestats.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/tests/test_mmorestats.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -100,4 +100,4 @@ ############################################################################### if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/tests/test_morestats.py =================================================================== --- trunk/scipy/stats/tests/test_morestats.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/tests/test_morestats.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -111,4 +111,4 @@ assert_array_equal(nums,[3,3,2,2]) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/tests/test_mstats.py =================================================================== --- trunk/scipy/stats/tests/test_mstats.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/tests/test_mstats.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -503,4 +503,4 @@ if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() Modified: trunk/scipy/stats/tests/test_stats.py =================================================================== --- trunk/scipy/stats/tests/test_stats.py 2008-07-21 19:02:32 UTC (rev 4556) +++ trunk/scipy/stats/tests/test_stats.py 2008-07-22 18:51:24 UTC (rev 4557) @@ -854,4 +854,4 @@ [0,2,3,4,0,0,0]) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() From scipy-svn at scipy.org Wed Jul 23 09:47:33 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 23 Jul 2008 08:47:33 -0500 (CDT) Subject: [Scipy-svn] r4558 - trunk/scipy/weave/tests Message-ID: <20080723134733.D57D439C78B@scipy.org> Author: alan.mcintyre Date: 2008-07-23 08:47:31 -0500 (Wed, 23 Jul 2008) New Revision: 4558 Modified: trunk/scipy/weave/tests/test_size_check.py Log: Replaced "from numpy import *" with standard "import numpy as np". Replaced nose.run call with run_module_suite. Modified: trunk/scipy/weave/tests/test_size_check.py =================================================================== --- trunk/scipy/weave/tests/test_size_check.py 2008-07-22 18:51:24 UTC (rev 4557) +++ trunk/scipy/weave/tests/test_size_check.py 2008-07-23 13:47:31 UTC (rev 4558) @@ -1,16 +1,12 @@ import os -from numpy import * +import numpy as np from numpy.testing import * from scipy.weave import size_check from scipy.weave.ast_tools import * +empty = np.array(()) -import numpy as nx - -empty = array(()) - - class TestMakeSameLength(TestCase): def generic_check(self,x,y,desired): @@ -24,19 +20,19 @@ self.generic_check(x,y,desired) def test_x_scalar(self): x,y = (),(1,2) - desired = array((1,1)),array((1,2)) + desired = np.array((1,1)), np.array((1,2)) self.generic_check(x,y,desired) def test_y_scalar(self): x,y = (1,2),() - desired = array((1,2)),array((1,1)) + desired = np.array((1,2)), np.array((1,1)) self.generic_check(x,y,desired) def test_x_short(self): x,y = (1,2),(1,2,3) - desired = array((1,1,2)),array((1,2,3)) + desired = np.array((1,1,2)), np.array((1,2,3)) self.generic_check(x,y,desired) def test_y_short(self): x,y = (1,2,3),(1,2) - desired = array((1,2,3)),array((1,1,2)) + desired = np.array((1,2,3)), np.array((1,1,2)) self.generic_check(x,y,desired) class TestBinaryOpSize(TestCase): @@ -48,7 +44,7 @@ self.failUnlessRaises(ValueError, size_check.binary_op_size, x, y) def desired_type(self,val): - return array(val) + return np.array(val) def test_scalar(self): x,y = (),() desired = self.desired_type(()) @@ -101,9 +97,9 @@ class TestDummyArray(TestBinaryOpSize): def generic_check(self,x,y,desired): if type(x) is type(()): - x = ones(x) + x = np.ones(x) if type(y) is type(()): - y = ones(y) + y = np.ones(y) xx = size_check.dummy_array(x) yy = size_check.dummy_array(y) ops = ['+', '-', '/', '*', '<<', '>>'] @@ -113,7 +109,7 @@ assert_array_equal(actual,desired) def desired_type(self,val): - return size_check.dummy_array(array(val),1) + return size_check.dummy_array(np.array(val),1) class TestDummyArrayIndexing(TestCase): def generic_check(self,ary,expr,desired): @@ -122,7 +118,7 @@ #print desired, actual assert_array_equal(actual,desired, expr) def generic_wrap(self,a,expr): - desired = array(eval(expr).shape) + desired = np.array(eval(expr).shape) try: self.generic_check(a,expr,desired) except IndexError: @@ -131,19 +127,19 @@ 'valid array shape -> %s' % (expr, str(desired)) raise AttributeError, msg def generic_1d(self,expr): - a = arange(10) + a = np.arange(10) self.generic_wrap(a,expr) def generic_2d(self,expr): - a = ones((10,20)) + a = np.ones((10,20)) self.generic_wrap(a,expr) def generic_3d(self,expr): - a = ones((10,20,1)) + a = np.ones((10,20,1)) self.generic_wrap(a,expr) def generic_1d_index(self,expr): - a = arange(10) + a = np.arange(10) #print expr ,eval(expr) - desired = array(()) + desired = np.array(()) self.generic_check(a,expr,desired) def test_1d_index_0(self): self.generic_1d_index('a[0]') @@ -269,33 +265,33 @@ class TestReduction(TestCase): def test_1d_0(self): - a = ones((5,)) + a = np.ones((5,)) actual = size_check.reduction(a,0) desired = size_check.dummy_array((),1) assert_array_equal(actual.shape,desired.shape) def test_2d_0(self): - a = ones((5,10)) + a = np.ones((5,10)) actual = size_check.reduction(a,0) desired = size_check.dummy_array((10,),1) assert_array_equal(actual.shape,desired.shape) def test_2d_1(self): - a = ones((5,10)) + a = np.ones((5,10)) actual = size_check.reduction(a,1) desired = size_check.dummy_array((5,),1) assert_array_equal(actual.shape,desired.shape) def test_3d_0(self): - a = ones((5,6,7)) + a = np.ones((5,6,7)) actual = size_check.reduction(a,1) desired = size_check.dummy_array((5,7),1) assert_array_equal(actual.shape,desired.shape) def test_error0(self): - a = ones((5,)) + a = np.ones((5,)) try: actual = size_check.reduction(a,-2) except ValueError: pass def test_error1(self): - a = ones((5,)) + a = np.ones((5,)) try: actual = size_check.reduction(a,1) except ValueError: @@ -324,7 +320,7 @@ print 'DEISRED:',desired def generic_wrap(self,expr,**kw): try: - x = array(eval(expr,kw)) + x = np.array(eval(expr,kw)) try: desired = x.shape except: @@ -333,41 +329,41 @@ desired = 'failed' self.generic_check(expr,desired,**kw) def test_generic_1d(self): - a = arange(10) + a = np.arange(10) expr = 'a[:]' self.generic_wrap(expr,a=a) expr = 'a[:] + a' self.generic_wrap(expr,a=a) bad_expr = 'a[4:] + a' self.generic_wrap(bad_expr,a=a) - a = arange(10) - b = ones((1,10)) + a = np.arange(10) + b = np.ones((1,10)) expr = 'a + b' self.generic_wrap(expr,a=a,b=b) bad_expr = 'a[:5] + b' self.generic_wrap(bad_expr,a=a,b=b) def test_single_index(self): - a = arange(10) + a = np.arange(10) expr = 'a[5] + a[3]' self.generic_wrap(expr,a=a) def test_calculated_index(self): - a = arange(10) + a = np.arange(10) nx = 0 expr = 'a[5] + a[nx+3]' size_check.check_expr(expr,locals()) def test_calculated_index2(self): - a = arange(10) + a = np.arange(10) nx = 0 expr = 'a[1:5] + a[nx+1:5+nx]' size_check.check_expr(expr,locals()) def generic_2d(self,expr): - a = ones((10,20)) + a = np.ones((10,20)) self.generic_wrap(a,expr) def generic_3d(self,expr): - a = ones((10,20,1)) + a = np.ones((10,20,1)) self.generic_wrap(a,expr) if __name__ == "__main__": - nose.run(argv=['', __file__]) + run_module_suite() From scipy-svn at scipy.org Wed Jul 23 16:49:38 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 23 Jul 2008 15:49:38 -0500 (CDT) Subject: [Scipy-svn] r4559 - branches/Interpolate1D Message-ID: <20080723204938.8D9BD39C780@scipy.org> Author: fcady Date: 2008-07-23 15:49:37 -0500 (Wed, 23 Jul 2008) New Revision: 4559 Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/interpolate1d.py Log: various minor edits Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-23 13:47:31 UTC (rev 4558) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-23 20:49:37 UTC (rev 4559) @@ -145,8 +145,9 @@ the range of x. If a string is passed, it will look for an object or function with that name and call it when evaluating. If a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. + A constant signifies a function which returns that constant + (e.g. val and lambda x : val are equivalent). Defaults to linear + interpolation. kindkw -- dictionary If kind is a class, function or string, additional keyword arguments @@ -195,10 +196,11 @@ def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): - + + # store properly-formatted versions of x and y self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) - + # store interpolation functions for each range self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) self.low = self._init_interp_method(self._x, self._y, low, lowkw) self.high = self._init_interp_method(self._x, self._y, high, highkw) @@ -230,7 +232,7 @@ x = x[mask] y = y[mask] - # collect dataypes and make arrays + # select proper dataypes and make arrays self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) self._x = make_array_safe(x, self._xdtype).copy() @@ -255,12 +257,15 @@ # FIXME : more string options available ('cubic', etc) if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: + # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] result = lambda new_x : func(self._x, self._y, new_x, **kw) elif interp_arg in ['Spline', Spline, 'spline']: + # spline is a special case of above result = Spline(self._x, self._y, **kw) elif isfunction(interp_arg): + # assume user has passed a function result = lambda new_x : interp_arg(new_x, **kw) elif isclass(interp_arg): result = interp_arg(x, y, **kw) @@ -276,10 +281,13 @@ """ x = make_array_safe(x) + + # masks indicate which elements fall into which interpolation region low_mask = xself._x[-1] interp_mask = (~low_mask) & (~high_mask) + # use correct function for x values in each region if len(x[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. # if/else is a hack, since vectorize is failing # to work on lists/arrays of length 0 Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-23 13:47:31 UTC (rev 4558) +++ branches/Interpolate1D/TODO.txt 2008-07-23 20:49:37 UTC (rev 4559) @@ -52,12 +52,10 @@ not just R1 -> R1. This requires some thinking about axes. -**write regression tests +**improve regression tests desired for fitpack_wrapper and _interpolate_wrapper -as well as interpolate1d. Recommend using the -shelve module +as well as interpolate1d. - **pick best spline Under-the-hood machinery currently comes from _interpolate.cpp (used in enthought.interpolate) and FITPACK (Fortran, used in @@ -73,7 +71,14 @@ the capabilities are and which should be added, large-scale architecture of the module, etc. +It might note which underlying C/Fortran modules can or should +be modified or merged. It would be great if either 1) there were +only 1 extension module, or 2) the modules showed natural +differentiation of functionality (one for splines, one for simple +operations, etc), rather than being a holdover of where they +were stolen from. + **update for 2D and ND This will probably take the form of two additional classes both based on interpolate1d. Thus it probably Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-23 13:47:31 UTC (rev 4558) +++ branches/Interpolate1D/interpolate1d.py 2008-07-23 20:49:37 UTC (rev 4559) @@ -145,8 +145,9 @@ the range of x. If a string is passed, it will look for an object or function with that name and call it when evaluating. If a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. + A constant signifies a function which returns that constant + (e.g. val and lambda x : val are equivalent). Defaults to linear + interpolation. kindkw -- dictionary If kind is a class, function or string, additional keyword arguments @@ -195,10 +196,11 @@ def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): - + + # store properly-formatted versions of x and y self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) - + # store interpolation functions for each range self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) self.low = self._init_interp_method(self._x, self._y, low, lowkw) self.high = self._init_interp_method(self._x, self._y, high, highkw) @@ -230,7 +232,7 @@ x = x[mask] y = y[mask] - # collect dataypes and make arrays + # select proper dataypes and make arrays self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) self._x = make_array_safe(x, self._xdtype).copy() @@ -255,12 +257,15 @@ # FIXME : more string options available ('cubic', etc) if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: + # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] result = lambda new_x : func(self._x, self._y, new_x, **kw) elif interp_arg in ['Spline', Spline, 'spline']: + # spline is a special case of above result = Spline(self._x, self._y, **kw) elif isfunction(interp_arg): + # assume user has passed a function result = lambda new_x : interp_arg(new_x, **kw) elif isclass(interp_arg): result = interp_arg(x, y, **kw) @@ -276,10 +281,13 @@ """ x = make_array_safe(x) + + # masks indicate which elements fall into which interpolation region low_mask = xself._x[-1] interp_mask = (~low_mask) & (~high_mask) + # use correct function for x values in each region if len(x[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. # if/else is a hack, since vectorize is failing # to work on lists/arrays of length 0 From scipy-svn at scipy.org Thu Jul 24 15:43:55 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 24 Jul 2008 14:43:55 -0500 (CDT) Subject: [Scipy-svn] r4560 - branches/Interpolate1D Message-ID: <20080724194355.5FCC239C4BF@scipy.org> Author: fcady Date: 2008-07-24 14:43:52 -0500 (Thu, 24 Jul 2008) New Revision: 4560 Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/__init__.py branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/interpolate_wrapper.py branches/Interpolate1D/setup.py Log: better init, fitpack_wrapper trimmer down, and TODO.txt more clear and informative Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-24 19:43:52 UTC (rev 4560) @@ -11,7 +11,7 @@ Classes provided include: - interpolate1d : an object for interpolation of + Interpolate1d : an object for interpolation of various kinds. interp1d is a wrapper around this class. @@ -117,7 +117,7 @@ >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) """ - return Interpolate1D(x, y, kind=kind, low=low, high=high, \ + return Interpolate1d(x, y, kind=kind, low=low, high=high, \ kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) @@ -255,7 +255,6 @@ from inspect import isclass, isfunction - # FIXME : more string options available ('cubic', etc) if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ @@ -264,6 +263,13 @@ elif interp_arg in ['Spline', Spline, 'spline']: # spline is a special case of above result = Spline(self._x, self._y, **kw) + elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ + 'quadratic', 'Quad', 'quad']: + # specify certain kinds of splines + if interp_arg in ['cubic', 'Cubic']: + result = Spline(self._x, self._y, k=3) + elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: + result = Spline(self._x, self._y, k=2) elif isfunction(interp_arg): # assume user has passed a function result = lambda new_x : interp_arg(new_x, **kw) @@ -279,7 +285,8 @@ Breaks x into pieces in-range, below-range, and above range. Performs appropriate operation on each and concatenates results. """ - + # FIXME : make_array_safe may also be called within the interpolation technique. + # waste of time, but ok for the time being. x = make_array_safe(x) # masks indicate which elements fall into which interpolation region @@ -349,6 +356,8 @@ """ make sure : order-2 splines work on linear data make sure : order-2 splines work on non-linear data + make sure : 'cubic' and 'quad' as arguments yield + the desired spline """ print "\n\nTESTING 2nd ORDER SPLINE" N = 7 #must be > 5 @@ -369,7 +378,7 @@ N = 7 x = np.arange(N) y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') new_x = np.arange(N+1)-0.5 new_y = interp_func(new_x) self.assertAllclose(new_x**2, new_y) Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/TODO.txt 2008-07-24 19:43:52 UTC (rev 4560) @@ -5,81 +5,121 @@ at appropriate places in the code. +**handle smoothing in fitpack_wrapper + The default smoothing parameter (s) means we aren't actually + doing interpolation. Also, small but non-zero s makes the + algorithm very slow. Figure out how to handle this, prob by + not letting the user see s and setting it to 0. + + This may be best handled by modifying fitpack_wrapper.py. + + +**pick best spline + Under-the-hood machinery currently comes from _interpolate.cpp + (used in enthought.interpolate) and FITPACK (Fortran, used in + scipy.interpolate). This isn't necessarily the best (for example, + speed of FITPACK is highly sensitive to parameter s). Other code + is used in scipy.ndimage and scipy.signal. There is surely other + code out there too. Figure out what is best and incorporate it. + + Signal code is slower than FITPACK, and NDImage really only does + filtering. I'm inclined to stay with FITPACK. + + +**clean up fitpack_wrapper.py + Currently is all hacked together from scipy.interpolate. + There is unused functionality, commented-out functionality, + and other undesirables. Once it has been established what + we will include, that stuff needs to be cleaned up, and the + rest needs to be either removed or set aside. + + **comment interpolate1d -There's comments there already, but they should be -made better. + There's comments there already, but they should be + made better. **doc strings for interpolate1d and its members -There's docstrings there already, but they should be -made better. In particular, it must be ensured that -they are of the proper format and include examples. + There's docstrings there already, but they should be + made better. In particular, it must be ensured that + they are of the proper format and include examples. -The doc strings for __init__.py, interpolate1d.py, -Interpolate1d, and interp1d are virtually identical -and very long; perhaps a master string can be stored -somewhere that they all reference. This would make -updates of documentation easier. + The doc strings for __init__.py, interpolate1d.py, + Interpolate1d, and interp1d are virtually identical + and very long; perhaps a master string can be stored + somewhere that they all reference. This would make + updates of documentation easier. -**more strings user can pass ('cubic', etc) -User can specify interpolation type as a string argument -to interpolate1d at initialization. More strings should work. - - **figure out NumPy version stuff with vectorize. -In function interpolate1d._format_array. -It would be nice to remove the hack I used. -I believe vectorize is supposed to handle arrays of -length 0, but it's not working on my computer. + In function interpolate1d._format_array. + It would be nice to remove the hack I used. + I believe vectorize is supposed to handle arrays of + length 0, but it's not working on my computer. **better handling of variable types -Currently everything is cast to a float64 if it is not already -a float32. Is this the best way to do it? + Currently everything is cast to a float64 if it is not already + a float32. Is this the best way to do it? -Also, for the future, code should be added for record arrays, -which mix real values with strings. This is, I believe already -largely supported, but that's not because the code was written -with that in mind. I haven't thought through the details. + Also, for the future, code should be added for record arrays, + which mix real values with strings. This is, I believe already + largely supported, but that's not because the code was written + with that in mind. I haven't thought through the details. -Perhaps this should be done as another function/class which -wraps interpolate1d. + Perhaps this should be done as another function/class which + wraps interpolate1d. -**allow y to be 2-dimensional -That way the interpolated function is from R1 -> Rn, and -not just R1 -> R1. This requires some thinking about axes. +**improve regression tests + desired for fitpack_wrapper and _interpolate_wrapper + as well as interpolate1d. -**improve regression tests -desired for fitpack_wrapper and _interpolate_wrapper -as well as interpolate1d. +**high-level road map + when the module is more established, there should be a page on + the wiki which describes the big-picture of the module; what + the capabilities are and which should be added, large-scale + architecture of the module, etc. -**pick best spline -Under-the-hood machinery currently comes from _interpolate.cpp -(used in enthought.interpolate) and FITPACK (Fortran, used in -scipy.interpolate). This isn't necessarily the best (for example, -speed of FITPACK is highly sensitive to parameter k). Other code -is used in scipy.ndimage and scipy.signal. There is surely other -code out there too. Figure out what is best and incorporate it. + It might note which underlying C/Fortran modules can or should + be modified or merged. It would be great if either 1) there were + only 1 extension module, or 2) the modules showed natural + differentiation of functionality (one for splines, one for simple + operations, etc), rather than being a holdover of where they + were stolen from. -**high-level road map -when the module is more established, there should be a page on -the wiki which describes the big-picture of the module; what -the capabilities are and which should be added, large-scale -architecture of the module, etc. +**update for 2D and ND + This will probably take the form of two additional + classes both based on interpolate1d. Thus it probably + shouldn't be done until interpolate1d is more settled. -It might note which underlying C/Fortran modules can or should -be modified or merged. It would be great if either 1) there were -only 1 extension module, or 2) the modules showed natural -differentiation of functionality (one for splines, one for simple -operations, etc), rather than being a holdover of where they -were stolen from. +**more convenient way to enter kw arguments + currently users have to pass in dictionaries of additional + keyword arguments for specific interpolation types. + This is kind of awkward, and it would be nice to let + them pass in a single argument. But this is low priority. -**update for 2D and ND -This will probably take the form of two additional -classes both based on interpolate1d. Thus it probably -shouldn't be done until interpolate1d is more settled. + +**allow y to be 2-dimensional + That way the interpolated function is from R1 -> Rn, and + not just R1 -> R1. This requires some thinking about axes. + + The interpolation should, I think, be along columns, so each + row of y is one complete observation. This is because 1) rows + are separated more from each other when an array is displayed, + and 2) the user may want to enter the data as y=array([obs1, obs2, ...]). + + There are two big problem. First, interpolate_wrapper interpolates + along rows, because each row is contiguous. Second, + FITPACK doesn't support 2D y arrays. + + The solution is to have the user indicate which axis to interpolate + along, and take the transpose if need be (also copy, so that + the columns become contiguous). Then when the user enters newx, + all under-the-hood interpolation is performed on contiguous + arrays. + + Whatever is done must be very well commented. Modified: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/__init__.py 2008-07-24 19:43:52 UTC (rev 4560) @@ -1,32 +1,12 @@ -#FIXME : better docstring -""" - Interpolation of 1D data - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: +# information about included functions +from info import __doc__ - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - +# basic interpolation routines from interpolate_wrapper import linear, logarithmic, block, block_average_above + +#support for spline interpolation from fitpack_wrapper import Spline + +# wrapping for all supported interpolation types. from interpolate1d import Interpolate1d, interp1d \ No newline at end of file Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-24 19:43:52 UTC (rev 4560) @@ -2,19 +2,19 @@ This module is used for spline interpolation, and functions as a wrapper around the FITPACK Fortran interpolation package. It is not intended to be directly accessed by -the user, but rather through the class Interpolate1D. +the user, but rather through the class Interpolate1d. The code has been modified from an older version of scipy.interpolate, where it was directly called by the user. As such, it includes functionality not available through -Interpolate1D. For this reason, users may wish to get +Interpolate1d. For this reason, users may wish to get under the hood. """ import numpy as np -import dfitpack +import dfitpack # lower-level wrapper around FITPACK class Spline(object): @@ -30,7 +30,7 @@ BivariateSpline - a similar class for bivariate spline interpolation """ - def __init__(self, x, y, w=None, bbox = [None]*2, k=3, s=None): + def __init__(self, x, y, w=None, bbox = [None]*2, k=3, s=0.0): """ Input: x,y - 1-d sequences of data points (x must be @@ -44,46 +44,21 @@ k=3 - degree of the univariate spline. s - positive smoothing factor defined for estimation condition: - sum((w[i]*(y[i]-s(x[i])))**2,axis=0) <= s + sum((w[i]*( y[i]-s(x[i]) ))**2,axis=0) <= s Default s=len(w) which should be a good value if 1/w[i] is an estimate of the standard deviation of y[i]. """ #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier - data = dfitpack.fpcurf0(x,y,k,w=w, - xb=bbox[0],xe=bbox[1],s=s) + data = dfitpack.fpcurf0(x, y, k, w=w, + xb=bbox[0], xe=bbox[1], s=s) if data[-1]==1: # nest too small, setting to maximum bound data = self._reset_nest(data) self._data = data - self._reset_class() - - def _reset_class(self): - data = self._data + # the relevant part of self._reset_class() n,t,c,k,ier = data[7],data[8],data[9],data[5],data[-1] self._eval_args = t[:n],c[:n],k - if ier==0: - # the spline returned has a residual sum of squares fp - # such that abs(fp-s)/s <= tol with tol a relative - # tolerance set to 0.001 by the program - pass - elif ier==-1: - # the spline returned is an interpolating spline - #self.__class__ = InterpolatedUnivariateSpline - pass - elif ier==-2: - # the spline returned is the weighted least-squares - # polynomial of degree k. In this extreme case fp gives - # the upper bound fp0 for the smoothing factor s. - #self.__class__ = LSQUnivariateSpline - pass - else: - # error - #if ier==1: - # self.__class__ = LSQUnivariateSpline - #message = _curfit_messages.get(ier,'ier=%s' % (ier)) - #warnings.warn(message) - pass def _reset_nest(self, data, nest=None): n = data[10] @@ -118,7 +93,7 @@ # nest too small, setting to maximum bound data = self._reset_nest(data) self._data = data - self._reset_class() + #self._reset_class() def __call__(self, x, nu=None): """ Evaluate spline (or its nu-th derivative) at positions x. Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/interpolate1d.py 2008-07-24 19:43:52 UTC (rev 4560) @@ -11,7 +11,7 @@ Classes provided include: - interpolate1d : an object for interpolation of + Interpolate1d : an object for interpolation of various kinds. interp1d is a wrapper around this class. @@ -117,7 +117,7 @@ >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) """ - return Interpolate1D(x, y, kind=kind, low=low, high=high, \ + return Interpolate1d(x, y, kind=kind, low=low, high=high, \ kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) @@ -255,7 +255,6 @@ from inspect import isclass, isfunction - # FIXME : more string options available ('cubic', etc) if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ @@ -264,6 +263,13 @@ elif interp_arg in ['Spline', Spline, 'spline']: # spline is a special case of above result = Spline(self._x, self._y, **kw) + elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ + 'quadratic', 'Quad', 'quad']: + # specify certain kinds of splines + if interp_arg in ['cubic', 'Cubic']: + result = Spline(self._x, self._y, k=3) + elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: + result = Spline(self._x, self._y, k=2) elif isfunction(interp_arg): # assume user has passed a function result = lambda new_x : interp_arg(new_x, **kw) @@ -279,7 +285,8 @@ Breaks x into pieces in-range, below-range, and above range. Performs appropriate operation on each and concatenates results. """ - + # FIXME : make_array_safe may also be called within the interpolation technique. + # waste of time, but ok for the time being. x = make_array_safe(x) # masks indicate which elements fall into which interpolation region @@ -349,6 +356,8 @@ """ make sure : order-2 splines work on linear data make sure : order-2 splines work on non-linear data + make sure : 'cubic' and 'quad' as arguments yield + the desired spline """ print "\n\nTESTING 2nd ORDER SPLINE" N = 7 #must be > 5 @@ -369,7 +378,7 @@ N = 7 x = np.arange(N) y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') new_x = np.arange(N+1)-0.5 new_y = interp_func(new_x) self.assertAllclose(new_x**2, new_y) Modified: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-24 19:43:52 UTC (rev 4560) @@ -31,7 +31,7 @@ assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: new_y = np.zeros((y.shape[0], len(new_x)), np.float64) - for i in range(len(new_y)): + for i in range(len(new_y)): # for each row _interpolate.linear_dddd(x, y[i], new_x, new_y[i]) else: new_y = np.zeros(len(new_x), np.float64) Modified: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-23 20:49:37 UTC (rev 4559) +++ branches/Interpolate1D/setup.py 2008-07-24 19:43:52 UTC (rev 4560) @@ -6,7 +6,7 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('', parent_package, top_path) #first arg was 'interpolate' + config = Configuration('', parent_package, top_path) config.add_extension('_interpolate', From scipy-svn at scipy.org Thu Jul 24 17:13:18 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 24 Jul 2008 16:13:18 -0500 (CDT) Subject: [Scipy-svn] r4561 - branches/Interpolate1D Message-ID: <20080724211318.CF81039C8D4@scipy.org> Author: fcady Date: 2008-07-24 16:13:18 -0500 (Thu, 24 Jul 2008) New Revision: 4561 Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/interpolate1d.py Log: test included for proper removal of bad data points Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-24 19:43:52 UTC (rev 4560) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-24 21:13:18 UTC (rev 4561) @@ -45,7 +45,7 @@ def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): + remove_bad_data = False, bad_data=[], interp_axis = 0): """ A function for interpolation of 1D data. Parameters @@ -196,51 +196,47 @@ def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): + # FIXME: don't allow copying multiple times. + # FIXME : allow no copying, in case user has huge dataset - # store properly-formatted versions of x and y - self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) - - # store interpolation functions for each range - self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) - self.low = self._init_interp_method(self._x, self._y, low, lowkw) - self.high = self._init_interp_method(self._x, self._y, high, highkw) - - def _format_array(self, x, y, remove_bad_data = False, bad_data = []): - """ - Assigns properly formatted versions of x and y to self._x and self._y. - Also records data types. - - Formatting includes removal of all points whose x or y coordinate - is in missing_data. This is the primary difference from - make_array_safe. - - """ - # FIXME: don't allow copying multiple times. - - # check acceptable lengths for x and y + # check acceptable size and dimensions + x = np.array(x) + y = np.array(y) assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ arrays of length 0" + assert x.ndim == 1 , "x must be one-dimensional" + assert y.ndim == 1 , "y must be one-dimensional" assert len(x) == len(y) , "x and y must be of the same length" - # remove bad data - x = np.array(x) - y = np.array(y) + # remove bad data, is there is any if remove_bad_data: - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - + x, y = self._remove_bad_data(x, y, bad_data) + # select proper dataypes and make arrays self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) self._x = make_array_safe(x, self._xdtype).copy() self._y = make_array_safe(y, self._ydtype).copy() - - # check dimensionality - assert self._x.ndim == 1 , "x must be one-dimensional" - assert self._y.ndim == 1 , "y must be one-dimensional" + + # store interpolation functions for each range + self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) + self.low = self._init_interp_method(self._x, self._y, low, lowkw) + self.high = self._init_interp_method(self._x, self._y, high, highkw) + + def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): + """ removes data points whose x or y coordinate is + either in bad_data or is a NaN. + """ + # FIXME : In the future, it may be good to just replace the bad points with good guesses. + # Especially in generalizing the higher dimensions + # FIXME : This step is very inefficient because it iterates over the array + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ + (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) + x = x[mask] + y = y[mask] + return x, y + def _init_interp_method(self, x, y, interp_arg, kw): """ @@ -429,5 +425,16 @@ new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') self.assertAllclose(new_x, new_y) + def test_removeBad(self): + """make sure : interp1d works with bad data + """ + N = 7.0 # must be >=5 + x = arange(N); x[2] = np.NaN + y = arange(N); y[4] = None; y[0]=np.NaN + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ + remove_bad_data = True, bad_data = [None]) + self.assertAllclose(new_x, new_y) + if __name__ == '__main__': unittest.main() \ No newline at end of file Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-24 19:43:52 UTC (rev 4560) +++ branches/Interpolate1D/TODO.txt 2008-07-24 21:13:18 UTC (rev 4561) @@ -94,6 +94,13 @@ This will probably take the form of two additional classes both based on interpolate1d. Thus it probably shouldn't be done until interpolate1d is more settled. + + There is an interesting problem here. Most of the extensions + I have assume a regular grid. First off, this is often unrealistic. + Secondly, if I DO use a rectangular grid, how do I deal with bad + data? The best way is probably a pre-processing where you + interpolate values for the bad points (linear would be a nice simple + way to do it at first, just to get it working) **more convenient way to enter kw arguments @@ -123,3 +130,11 @@ arrays. Whatever is done must be very well commented. + + Also, there's a problem with removing bad data and still + retaining a rectangular array. I would have to store a list + of (x,y) pairs, which suggests I should do this with a wrapper + function anyway. Not memory efficient, but oh well. In the + future, however, when x is a ND array, I should work around this; + I should have it be Rn -> Rm and fill in missing values to the best + of my ability. Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-24 19:43:52 UTC (rev 4560) +++ branches/Interpolate1D/interpolate1d.py 2008-07-24 21:13:18 UTC (rev 4561) @@ -45,7 +45,7 @@ def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): + remove_bad_data = False, bad_data=[], interp_axis = 0): """ A function for interpolation of 1D data. Parameters @@ -196,51 +196,47 @@ def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[]): + # FIXME: don't allow copying multiple times. + # FIXME : allow no copying, in case user has huge dataset - # store properly-formatted versions of x and y - self._format_array(x, y, remove_bad_data = remove_bad_data, bad_data = bad_data) - - # store interpolation functions for each range - self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) - self.low = self._init_interp_method(self._x, self._y, low, lowkw) - self.high = self._init_interp_method(self._x, self._y, high, highkw) - - def _format_array(self, x, y, remove_bad_data = False, bad_data = []): - """ - Assigns properly formatted versions of x and y to self._x and self._y. - Also records data types. - - Formatting includes removal of all points whose x or y coordinate - is in missing_data. This is the primary difference from - make_array_safe. - - """ - # FIXME: don't allow copying multiple times. - - # check acceptable lengths for x and y + # check acceptable size and dimensions + x = np.array(x) + y = np.array(y) assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ arrays of length 0" + assert x.ndim == 1 , "x must be one-dimensional" + assert y.ndim == 1 , "y must be one-dimensional" assert len(x) == len(y) , "x and y must be of the same length" - # remove bad data - x = np.array(x) - y = np.array(y) + # remove bad data, is there is any if remove_bad_data: - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - + x, y = self._remove_bad_data(x, y, bad_data) + # select proper dataypes and make arrays self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) self._x = make_array_safe(x, self._xdtype).copy() self._y = make_array_safe(y, self._ydtype).copy() - - # check dimensionality - assert self._x.ndim == 1 , "x must be one-dimensional" - assert self._y.ndim == 1 , "y must be one-dimensional" + + # store interpolation functions for each range + self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) + self.low = self._init_interp_method(self._x, self._y, low, lowkw) + self.high = self._init_interp_method(self._x, self._y, high, highkw) + + def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): + """ removes data points whose x or y coordinate is + either in bad_data or is a NaN. + """ + # FIXME : In the future, it may be good to just replace the bad points with good guesses. + # Especially in generalizing the higher dimensions + # FIXME : This step is very inefficient because it iterates over the array + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ + (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) + x = x[mask] + y = y[mask] + return x, y + def _init_interp_method(self, x, y, interp_arg, kw): """ @@ -429,5 +425,16 @@ new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') self.assertAllclose(new_x, new_y) + def test_removeBad(self): + """make sure : interp1d works with bad data + """ + N = 7.0 # must be >=5 + x = arange(N); x[2] = np.NaN + y = arange(N); y[4] = None; y[0]=np.NaN + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ + remove_bad_data = True, bad_data = [None]) + self.assertAllclose(new_x, new_y) + if __name__ == '__main__': unittest.main() \ No newline at end of file From scipy-svn at scipy.org Fri Jul 25 12:26:27 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 25 Jul 2008 11:26:27 -0500 (CDT) Subject: [Scipy-svn] r4562 - trunk/scipy/ndimage/src Message-ID: <20080725162627.4991239C663@scipy.org> Author: fcady Date: 2008-07-25 11:26:25 -0500 (Fri, 25 Jul 2008) New Revision: 4562 Modified: trunk/scipy/ndimage/src/nd_image.c trunk/scipy/ndimage/src/nd_image.h trunk/scipy/ndimage/src/ni_filters.c trunk/scipy/ndimage/src/ni_filters.h trunk/scipy/ndimage/src/ni_fourier.c trunk/scipy/ndimage/src/ni_fourier.h trunk/scipy/ndimage/src/ni_interpolation.c trunk/scipy/ndimage/src/ni_interpolation.h trunk/scipy/ndimage/src/ni_measure.c trunk/scipy/ndimage/src/ni_measure.h trunk/scipy/ndimage/src/ni_morphology.c trunk/scipy/ndimage/src/ni_morphology.h trunk/scipy/ndimage/src/ni_support.c trunk/scipy/ndimage/src/ni_support.h Log: used a python script to change spacing from 2 to 4 Modified: trunk/scipy/ndimage/src/nd_image.c =================================================================== --- trunk/scipy/ndimage/src/nd_image.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/nd_image.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,1320 +1,1320 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define ND_IMPORT_ARRAY -#include "nd_image.h" -#undef ND_IMPORT_ARRAY -#include "ni_support.h" -#include "ni_filters.h" -#include "ni_fourier.h" -#include "ni_morphology.h" -#include "ni_interpolation.h" -#include "ni_measure.h" - -typedef struct { - PyObject *function; - PyObject *extra_arguments; - PyObject *extra_keywords; -} NI_PythonCallbackData; - -/* Convert an input array of any type, not necessarily contiguous */ -static int -NI_ObjectToInputArray(PyObject *object, PyArrayObject **array) -{ - *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); - return *array ? 1 : 0; -} - -/* Convert an input array of any type, not necessarily contiguous */ -static int -NI_ObjectToOptionalInputArray(PyObject *object, PyArrayObject **array) -{ - if (object == Py_None) { - *array = NULL; - return 1; - } else { - *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); - return *array ? 1 : 0; - } -} - -/* Convert an output array of any type, not necessarily contiguous */ -static int -NI_ObjectToOutputArray(PyObject *object, PyArrayObject **array) -{ - *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); - return *array ? 1 : 0; -} - -/* Convert an output array of any type, not necessarily contiguous */ -static int -NI_ObjectToOptionalOutputArray(PyObject *object, PyArrayObject **array) -{ - if (object == Py_None) { - *array = NULL; - return 1; - } else { - *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); - return *array ? 1 : 0; - } -} - -/* Convert an input/output array of any type, not necessarily contiguous */ -static int -NI_ObjectToIoArray(PyObject *object, PyArrayObject **array) -{ - *array = NA_IoArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); - return *array ? 1 : 0; -} - -/* Convert an Long sequence */ -static maybelong -NI_ObjectToLongSequenceAndLength(PyObject *object, maybelong **sequence) -{ - long *pa, ii; - PyArrayObject *array = NA_InputArray(object, PyArray_LONG, NPY_CARRAY); - maybelong length = PyArray_SIZE(array); - - *sequence = (maybelong*)malloc(length * sizeof(maybelong)); - if (!*sequence) { - PyErr_NoMemory(); - Py_XDECREF(array); - return -1; - } - pa = (long*)PyArray_DATA(array); - for(ii = 0; ii < length; ii++) - (*sequence)[ii] = pa[ii]; - Py_XDECREF(array); - return length; -} - -static int -NI_ObjectToLongSequence(PyObject *object, maybelong **sequence) -{ - return NI_ObjectToLongSequenceAndLength(object, sequence) >= 0; -} - -/*********************************************************************/ -/* wrapper functions: */ -/*********************************************************************/ - -static PyObject *Py_Correlate1D(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *weights = NULL; - int axis, mode; - long origin; - double cval; - - if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &weights, &axis, - NI_ObjectToOutputArray, &output, &mode, &cval, &origin)) - goto exit; - if (!NI_Correlate1D(input, weights, axis, output, - (NI_ExtendMode)mode, cval, origin)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(weights); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_Correlate(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *weights = NULL; - maybelong *origin = NULL; - int mode; - double cval; - - if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output, - &mode, &cval, NI_ObjectToLongSequence, &origin)) - goto exit; - if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval, - origin)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(weights); - Py_XDECREF(output); - if (origin) - free(origin); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_UniformFilter1D(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL; - int axis, mode; - long filter_size, origin; - double cval; - - if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input, - &filter_size, &axis, NI_ObjectToOutputArray, &output, - &mode, &cval, &origin)) - goto exit; - if (!NI_UniformFilter1D(input, filter_size, axis, output, - (NI_ExtendMode)mode, cval, origin)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_MinOrMaxFilter1D(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL; - int axis, mode, minimum; - long filter_size, origin; - double cval; - - if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input, - &filter_size, &axis, NI_ObjectToOutputArray, &output, - &mode, &cval, &origin, &minimum)) - goto exit; - if (!NI_MinOrMaxFilter1D(input, filter_size, axis, output, - (NI_ExtendMode)mode, cval, origin, minimum)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_MinOrMaxFilter(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *footprint = NULL; - PyArrayObject *structure = NULL; - maybelong *origin = NULL; - int mode, minimum; - double cval; - - if (!PyArg_ParseTuple(args, "O&O&O&O&idO&i", NI_ObjectToInputArray, - &input, NI_ObjectToInputArray, &footprint, - NI_ObjectToOptionalInputArray, &structure, - NI_ObjectToOutputArray, &output, &mode, &cval, - NI_ObjectToLongSequence, &origin, &minimum)) - goto exit; - if (!NI_MinOrMaxFilter(input, footprint, structure, output, - (NI_ExtendMode)mode, cval, origin, minimum)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(footprint); - Py_XDECREF(structure); - Py_XDECREF(output); - if (origin) - free(origin); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_RankFilter(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *footprint = NULL; - maybelong *origin = NULL; - int mode, rank; - double cval; - - if (!PyArg_ParseTuple(args, "O&iO&O&idO&", NI_ObjectToInputArray, - &input, &rank, NI_ObjectToInputArray, &footprint, - NI_ObjectToOutputArray, &output, &mode, &cval, - NI_ObjectToLongSequence, &origin)) - goto exit; - if (!NI_RankFilter(input, rank, footprint, output, (NI_ExtendMode)mode, - cval, origin)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(footprint); - Py_XDECREF(output); - if (origin) - free(origin); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static int Py_Filter1DFunc(double *iline, maybelong ilen, - double *oline, maybelong olen, void *data) -{ - PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL; - PyObject *rv = NULL, *args = NULL, *tmp = NULL; - maybelong ii; - double *po = NULL; - NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; - - py_ibuffer = NA_NewArray(iline, PyArray_DOUBLE, 1, &ilen); - py_obuffer = NA_NewArray(NULL, PyArray_DOUBLE, 1, &olen); - if (!py_ibuffer || !py_obuffer) - goto exit; - tmp = Py_BuildValue("(OO)", py_ibuffer, py_obuffer); - if (!tmp) - goto exit; - args = PySequence_Concat(tmp, cbdata->extra_arguments); - if (!args) - goto exit; - rv = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); - if (!rv) - goto exit; - po = (double*)PyArray_DATA(py_obuffer); - for(ii = 0; ii < olen; ii++) - oline[ii] = po[ii]; -exit: - Py_XDECREF(py_ibuffer); - Py_XDECREF(py_obuffer); - Py_XDECREF(rv); - Py_XDECREF(args); - Py_XDECREF(tmp); - return PyErr_Occurred() ? 0 : 1; -} - -static PyObject *Py_GenericFilter1D(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL; - PyObject *fnc = NULL, *extra_arguments = NULL, *extra_keywords = NULL; - void *func = Py_Filter1DFunc, *data = NULL; - NI_PythonCallbackData cbdata; - int axis, mode; - long origin, filter_size; - double cval; - - if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray, - &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray, - &output, &mode, &cval, &origin, &extra_arguments, &extra_keywords)) - goto exit; - if (!PyTuple_Check(extra_arguments)) { - PyErr_SetString(PyExc_RuntimeError, - "extra_arguments must be a tuple"); - goto exit; - } - if (!PyDict_Check(extra_keywords)) { - PyErr_SetString(PyExc_RuntimeError, - "extra_keywords must be a dictionary"); - goto exit; - } - if (PyCObject_Check(fnc)) { - func = PyCObject_AsVoidPtr(fnc); - data = PyCObject_GetDesc(fnc); - } else if (PyCallable_Check(fnc)) { - cbdata.function = fnc; - cbdata.extra_arguments = extra_arguments; - cbdata.extra_keywords = extra_keywords; - data = (void*)&cbdata; - } else { - PyErr_SetString(PyExc_RuntimeError, - "function parameter is not callable"); - goto exit; - } - if (!NI_GenericFilter1D(input, func, data, filter_size, axis, output, - (NI_ExtendMode)mode, cval, origin)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static int Py_FilterFunc(double *buffer, maybelong filter_size, - double *output, void *data) -{ - PyArrayObject *py_buffer = NULL; - PyObject *rv = NULL, *args = NULL, *tmp = NULL; - NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; - - py_buffer = NA_NewArray(buffer, PyArray_DOUBLE, 1, &filter_size); - if (!py_buffer) - goto exit; - tmp = Py_BuildValue("(O)", py_buffer); - if (!tmp) - goto exit; - args = PySequence_Concat(tmp, cbdata->extra_arguments); - if (!args) - goto exit; - rv = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); - if (!rv) - goto exit; - *output = PyFloat_AsDouble(rv); -exit: - Py_XDECREF(py_buffer); - Py_XDECREF(rv); - Py_XDECREF(args); - Py_XDECREF(tmp); - return PyErr_Occurred() ? 0 : 1; -} - -static PyObject *Py_GenericFilter(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *footprint = NULL; - PyObject *fnc = NULL, *extra_arguments = NULL, *extra_keywords = NULL; - void *func = Py_FilterFunc, *data = NULL; - NI_PythonCallbackData cbdata; - int mode; - maybelong *origin = NULL; - double cval; - - if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray, - &input, &fnc, NI_ObjectToInputArray, &footprint, - NI_ObjectToOutputArray, &output, &mode, &cval, - NI_ObjectToLongSequence, &origin, - &extra_arguments, &extra_keywords)) - goto exit; - if (!PyTuple_Check(extra_arguments)) { - PyErr_SetString(PyExc_RuntimeError, - "extra_arguments must be a tuple"); - goto exit; - } - if (!PyDict_Check(extra_keywords)) { - PyErr_SetString(PyExc_RuntimeError, - "extra_keywords must be a dictionary"); - goto exit; - } - if (PyCObject_Check(fnc)) { - func = PyCObject_AsVoidPtr(fnc); - data = PyCObject_GetDesc(fnc); - } else if (PyCallable_Check(fnc)) { - cbdata.function = fnc; - cbdata.extra_arguments = extra_arguments; - cbdata.extra_keywords = extra_keywords; - data = (void*)&cbdata; - } else { - PyErr_SetString(PyExc_RuntimeError, - "function parameter is not callable"); - goto exit; - } - if (!NI_GenericFilter(input, func, data, footprint, output, - (NI_ExtendMode)mode, cval, origin)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(output); - Py_XDECREF(footprint); - if (origin) - free(origin); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_FourierFilter(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *parameters = NULL; - int axis, filter_type; - long n; - - if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, ¶meters, &n, &axis, - NI_ObjectToOutputArray, &output, &filter_type)) - goto exit; - - if (!NI_FourierFilter(input, parameters, n, axis, output, filter_type)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(parameters); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_FourierShift(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *shifts = NULL; - int axis; - long n; - - if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &shifts, &n, &axis, - NI_ObjectToOutputArray, &output)) - goto exit; - - if (!NI_FourierShift(input, shifts, n, axis, output)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(shifts); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_SplineFilter1D(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL; - int axis, order; - - if (!PyArg_ParseTuple(args, "O&iiO&", NI_ObjectToInputArray, &input, - &order, &axis, NI_ObjectToOutputArray, &output)) - goto exit; - - if (!NI_SplineFilter1D(input, order, axis, output)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank, - void *data) -{ - PyObject *coors = NULL, *rets = NULL, *args = NULL, *tmp = NULL; - maybelong ii; - NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; - - coors = PyTuple_New(orank); - if (!coors) - goto exit; - for(ii = 0; ii < orank; ii++) { - PyTuple_SetItem(coors, ii, PyInt_FromLong(ocoor[ii])); - if (PyErr_Occurred()) - goto exit; - } - tmp = Py_BuildValue("(O)", coors); - if (!tmp) - goto exit; - args = PySequence_Concat(tmp, cbdata->extra_arguments); - if (!args) - goto exit; - rets = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); - if (!rets) - goto exit; - for(ii = 0; ii < irank; ii++) { - icoor[ii] = PyFloat_AsDouble(PyTuple_GetItem(rets, ii)); - if (PyErr_Occurred()) - goto exit; - } -exit: - Py_XDECREF(coors); - Py_XDECREF(tmp); - Py_XDECREF(rets); - Py_XDECREF(args); - return PyErr_Occurred() ? 0 : 1; -} - - -static PyObject *Py_GeometricTransform(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL; - PyArrayObject *coordinates = NULL, *matrix = NULL, *shift = NULL; - PyObject *fnc = NULL, *extra_arguments = NULL, *extra_keywords = NULL; - int mode, order; - double cval; - void *func = NULL, *data = NULL; - NI_PythonCallbackData cbdata; - - if (!PyArg_ParseTuple(args, "O&OO&O&O&O&iidOO", NI_ObjectToInputArray, - &input, &fnc, NI_ObjectToOptionalInputArray, - &coordinates, NI_ObjectToOptionalInputArray, - &matrix, NI_ObjectToOptionalInputArray, &shift, - NI_ObjectToOutputArray, &output, &order, &mode, - &cval, &extra_arguments, &extra_keywords)) - goto exit; - - if (fnc != Py_None) { - if (!PyTuple_Check(extra_arguments)) { - PyErr_SetString(PyExc_RuntimeError, - "extra_arguments must be a tuple"); - goto exit; - } - if (!PyDict_Check(extra_keywords)) { - PyErr_SetString(PyExc_RuntimeError, - "extra_keywords must be a dictionary"); - goto exit; - } - if (PyCObject_Check(fnc)) { - func = PyCObject_AsVoidPtr(fnc); - data = PyCObject_GetDesc(fnc); - } else if (PyCallable_Check(fnc)) { - func = Py_Map; - cbdata.function = fnc; - cbdata.extra_arguments = extra_arguments; - cbdata.extra_keywords = extra_keywords; - data = (void*)&cbdata; - } else { - PyErr_SetString(PyExc_RuntimeError, - "function parameter is not callable"); - goto exit; - } - } - - if (!NI_GeometricTransform(input, func, data, matrix, shift, coordinates, - output, order, (NI_ExtendMode)mode, cval)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(output); - Py_XDECREF(coordinates); - Py_XDECREF(matrix); - Py_XDECREF(shift); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_ZoomShift(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *shift = NULL; - PyArrayObject *zoom = NULL; - int mode, order; - double cval; - - if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray, - &input, NI_ObjectToOptionalInputArray, &zoom, - NI_ObjectToOptionalInputArray, &shift, NI_ObjectToOutputArray, - &output, &order, &mode, &cval)) - goto exit; - - if (!NI_ZoomShift(input, zoom, shift, output, order, (NI_ExtendMode)mode, - cval)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(shift); - Py_XDECREF(zoom); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_Label(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *strct = NULL; - maybelong max_label; - - if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &strct, NI_ObjectToOutputArray, &output)) - goto exit; - - if (!NI_Label(input, strct, &max_label, output)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(strct); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue("l", (long)max_label); -} - -static PyObject *Py_FindObjects(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL; - PyObject *result = NULL, *tuple = NULL, *start = NULL, *end = NULL; - PyObject *slc = NULL; - int jj; - long max_label; - maybelong ii, *regions = NULL; - - if (!PyArg_ParseTuple(args, "O&l", NI_ObjectToInputArray, &input, - &max_label)) - goto exit; - - if (max_label < 0) - max_label = 0; - if (max_label > 0) { - if (input->nd > 0) { - regions = (maybelong*)malloc(2 * max_label * input->nd * - sizeof(maybelong)); - } else { - regions = (maybelong*)malloc(max_label * sizeof(maybelong)); - } - if (!regions) { - PyErr_NoMemory(); - goto exit; - } - } - - if (!NI_FindObjects(input, max_label, regions)) - goto exit; - - result = PyList_New(max_label); - if (!result) { - PyErr_NoMemory(); - goto exit; - } - - for(ii = 0; ii < max_label; ii++) { - maybelong idx = input->nd > 0 ? 2 * input->nd * ii : ii; - if (regions[idx] >= 0) { - PyObject *tuple = PyTuple_New(input->nd); - if (!tuple) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < input->nd; jj++) { - start = PyInt_FromLong(regions[idx + jj]); - end = PyInt_FromLong(regions[idx + jj + input->nd]); - if (!start || !end) { - PyErr_NoMemory(); - goto exit; - } - slc = PySlice_New(start, end, NULL); - if (!slc) { - PyErr_NoMemory(); - goto exit; - } - Py_XDECREF(start); - Py_XDECREF(end); - start = end = NULL; - PyTuple_SetItem(tuple, jj, slc); - slc = NULL; - } - PyList_SetItem(result, ii, tuple); - tuple = NULL; - } else { - Py_INCREF(Py_None); - PyList_SetItem(result, ii, Py_None); - } - } - - Py_INCREF(result); - - exit: - Py_XDECREF(input); - Py_XDECREF(result); - Py_XDECREF(tuple); - Py_XDECREF(start); - Py_XDECREF(end); - Py_XDECREF(slc); - if (regions) - free(regions); - if (PyErr_Occurred()) { - Py_XDECREF(result); - return NULL; - } else { - return result; - } -} - -static PyObject *Py_WatershedIFT(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *markers = NULL; - PyArrayObject *strct = NULL; - - if (!PyArg_ParseTuple(args, "O&O&O&O&", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &markers, NI_ObjectToInputArray, - &strct, NI_ObjectToOutputArray, &output)) - goto exit; - - if (!NI_WatershedIFT(input, markers, strct, output)) - goto exit; - -exit: - Py_XDECREF(input); - Py_XDECREF(markers); - Py_XDECREF(strct); - Py_XDECREF(output); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static int _NI_GetIndices(PyObject* indices_object, - maybelong** result_indices, maybelong* min_label, - maybelong* max_label, maybelong* n_results) -{ - maybelong *indices = NULL, n_indices, ii; - - if (indices_object == Py_None) { - *min_label = -1; - *n_results = 1; - } else { - n_indices = NI_ObjectToLongSequenceAndLength(indices_object, &indices); - if (n_indices < 0) - goto exit; - if (n_indices < 1) { - PyErr_SetString(PyExc_RuntimeError, "no correct indices provided"); - goto exit; - } else { - *min_label = *max_label = indices[0]; - if (*min_label < 0) { - PyErr_SetString(PyExc_RuntimeError, - "negative indices not allowed"); - goto exit; - } - for(ii = 1; ii < n_indices; ii++) { - if (indices[ii] < 0) { - PyErr_SetString(PyExc_RuntimeError, - "negative indices not allowed"); - goto exit; - } - if (indices[ii] < *min_label) - *min_label = indices[ii]; - if (indices[ii] > *max_label) - *max_label = indices[ii]; - } - *result_indices = (maybelong*)malloc((*max_label - *min_label + 1) * - sizeof(maybelong)); - if (!*result_indices) { - PyErr_NoMemory(); - goto exit; - } - for(ii = 0; ii < *max_label - *min_label + 1; ii++) - (*result_indices)[ii] = -1; - *n_results = 0; - for(ii = 0; ii < n_indices; ii++) { - if ((*result_indices)[indices[ii] - *min_label] >= 0) { - PyErr_SetString(PyExc_RuntimeError, "duplicate index"); - goto exit; - } - (*result_indices)[indices[ii] - *min_label] = ii; - ++(*n_results); - } - } - } - exit: - if (indices) - free(indices); - return PyErr_Occurred() == NULL; -} - - -PyObject* _NI_BuildMeasurementResultArrayObject(maybelong n_results, - PyArrayObject** values) -{ - PyObject *result = NULL; - if (n_results > 1) { - result = PyList_New(n_results); - if (result) { - maybelong ii; - for(ii = 0; ii < n_results; ii++) { - PyList_SET_ITEM(result, ii, (PyObject*)values[ii]); - Py_XINCREF(values[ii]); - } - } - } else { - result = (PyObject*)values[0]; - Py_XINCREF(values[0]); - } - return result; -} - - -PyObject* _NI_BuildMeasurementResultDouble(maybelong n_results, - double* values) -{ - PyObject *result = NULL; - if (n_results > 1) { - result = PyList_New(n_results); - if (result) { - int ii; - for(ii = 0; ii < n_results; ii++) { - PyObject* val = PyFloat_FromDouble(values[ii]); - if (!val) { - Py_XDECREF(result); - return NULL; - } - PyList_SET_ITEM(result, ii, val); - } - } - } else { - result = Py_BuildValue("d", values[0]); - } - return result; -} - - -PyObject* _NI_BuildMeasurementResultDoubleTuple(maybelong n_results, - int tuple_size, double* values) -{ - PyObject *result = NULL; - maybelong ii; - int jj; - - if (n_results > 1) { - result = PyList_New(n_results); - if (result) { - for(ii = 0; ii < n_results; ii++) { - PyObject* val = PyTuple_New(tuple_size); - if (!val) { - Py_XDECREF(result); - return NULL; - } - for(jj = 0; jj < tuple_size; jj++) { - maybelong idx = jj + ii * tuple_size; - PyTuple_SetItem(val, jj, PyFloat_FromDouble(values[idx])); - if (PyErr_Occurred()) { - Py_XDECREF(result); - return NULL; - } - } - PyList_SET_ITEM(result, ii, val); - } - } - } else { - result = PyTuple_New(tuple_size); - if (result) { - for(ii = 0; ii < tuple_size; ii++) { - PyTuple_SetItem(result, ii, PyFloat_FromDouble(values[ii])); - if (PyErr_Occurred()) { - Py_XDECREF(result); - return NULL; - } - } - } - } - return result; -} - - -PyObject* _NI_BuildMeasurementResultInt(maybelong n_results, - maybelong* values) -{ - PyObject *result = NULL; - if (n_results > 1) { - result = PyList_New(n_results); - if (result) { - maybelong ii; - for(ii = 0; ii < n_results; ii++) { - PyObject* val = PyInt_FromLong(values[ii]); - if (!val) { - Py_XDECREF(result); - return NULL; - } - PyList_SET_ITEM(result, ii, val); - } - } - } else { - result = Py_BuildValue("l", values[0]); - } - return result; -} - - -static PyObject *Py_Statistics(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *labels = NULL; - PyObject *indices_object, *result = NULL; - PyObject *res1 = NULL, *res2 = NULL, *res3 = NULL, *res4 = NULL; - double *dresult1 = NULL, *dresult2 = NULL; - maybelong *lresult1 = NULL, *lresult2 = NULL; - maybelong min_label, max_label, *result_indices = NULL, n_results, ii; - int type; - - if (!PyArg_ParseTuple(args, "O&O&Oi", NI_ObjectToInputArray, &input, - NI_ObjectToOptionalInputArray, &labels, &indices_object, &type)) - goto exit; - - if (!_NI_GetIndices(indices_object, &result_indices, &min_label, - &max_label, &n_results)) - goto exit; - - if (type >= 0 && type <= 7) { - dresult1 = (double*)malloc(n_results * sizeof(double)); - if (!dresult1) { - PyErr_NoMemory(); - goto exit; - } - } - if (type == 2 || type == 7) { - dresult2 = (double*)malloc(n_results * sizeof(double)); - if (!dresult2) { - PyErr_NoMemory(); - goto exit; - } - } - if (type == 1 || type == 2 || (type >= 5 && type <= 7)) { - lresult1 = (maybelong*)malloc(n_results * sizeof(maybelong)); - if (!lresult1) { - PyErr_NoMemory(); - goto exit; - } - } - if (type == 7) { - lresult2 = (maybelong*)malloc(n_results * sizeof(maybelong)); - if (!lresult2) { - PyErr_NoMemory(); - goto exit; - } - } - switch(type) { - case 0: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, dresult1, NULL, NULL, NULL, NULL, NULL, NULL)) - goto exit; - result = _NI_BuildMeasurementResultDouble(n_results, dresult1); - break; - case 1: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, dresult1, lresult1, NULL, NULL, NULL, NULL, NULL)) - goto exit; - for(ii = 0; ii < n_results; ii++) - dresult1[ii] = lresult1[ii] > 0 ? dresult1[ii] / lresult1[ii] : 0.0; - - result = _NI_BuildMeasurementResultDouble(n_results, dresult1); - break; - case 2: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, dresult1, lresult1, dresult2, NULL, NULL, NULL, NULL)) - goto exit; - result = _NI_BuildMeasurementResultDouble(n_results, dresult2); - break; - case 3: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, NULL, NULL, NULL, dresult1, NULL, NULL, NULL)) - goto exit; - result = _NI_BuildMeasurementResultDouble(n_results, dresult1); - break; - case 4: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, NULL, NULL, NULL, NULL, dresult1, NULL, NULL)) - goto exit; - result = _NI_BuildMeasurementResultDouble(n_results, dresult1); - break; - case 5: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, NULL, NULL, NULL, dresult1, NULL, lresult1, NULL)) - goto exit; - result = _NI_BuildMeasurementResultInt(n_results, lresult1); - break; - case 6: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, NULL, NULL, NULL, NULL, dresult1, NULL, lresult1)) - goto exit; - result = _NI_BuildMeasurementResultInt(n_results, lresult1); - break; - case 7: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, NULL, NULL, NULL, dresult1, dresult2, - lresult1, lresult2)) - goto exit; - res1 = _NI_BuildMeasurementResultDouble(n_results, dresult1); - res2 = _NI_BuildMeasurementResultDouble(n_results, dresult2); - res3 = _NI_BuildMeasurementResultInt(n_results, lresult1); - res4 = _NI_BuildMeasurementResultInt(n_results, lresult2); - if (!res1 || !res2 || !res3 || !res4) - goto exit; - result = Py_BuildValue("OOOO", res1, res2, res3, res4); - break; - default: - PyErr_SetString(PyExc_RuntimeError, "operation not supported"); - goto exit; - } - - exit: - Py_XDECREF(input); - Py_XDECREF(labels); - if (result_indices) - free(result_indices); - if (dresult1) - free(dresult1); - if (dresult2) - free(dresult2); - if (lresult1) - free(lresult1); - if (lresult2) - free(lresult2); - return result; -} - - -static PyObject *Py_CenterOfMass(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *labels = NULL; - PyObject *indices_object, *result = NULL; - double *center_of_mass = NULL; - maybelong min_label, max_label, *result_indices = NULL, n_results; - - if (!PyArg_ParseTuple(args, "O&O&O", NI_ObjectToInputArray, &input, - NI_ObjectToOptionalInputArray, &labels, &indices_object)) - goto exit; - - if (!_NI_GetIndices(indices_object, &result_indices, &min_label, - &max_label, &n_results)) - goto exit; - - center_of_mass = (double*)malloc(input->nd * n_results * - sizeof(double)); - if (!center_of_mass) { - PyErr_NoMemory(); - goto exit; - } - - if (!NI_CenterOfMass(input, labels, min_label, max_label, - result_indices, n_results, center_of_mass)) - goto exit; - - result = _NI_BuildMeasurementResultDoubleTuple(n_results, input->nd, - center_of_mass); - - exit: - Py_XDECREF(input); - Py_XDECREF(labels); - if (result_indices) - free(result_indices); - if (center_of_mass) - free(center_of_mass); - return result; -} - -static PyObject *Py_Histogram(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *labels = NULL, **histograms = NULL; - PyObject *indices_object, *result = NULL; - maybelong min_label, max_label, *result_indices = NULL, n_results; - maybelong jj, nbins; - long nbins_in; - double min, max; - - if (!PyArg_ParseTuple(args, "O&ddlO&O", NI_ObjectToInputArray, &input, - &min, &max, &nbins_in, NI_ObjectToOptionalInputArray, - &labels, &indices_object)) - goto exit; - nbins = nbins_in; - - if (!_NI_GetIndices(indices_object, &result_indices, &min_label, - &max_label, &n_results)) - goto exit; - - /* Set all pointers to NULL, so that freeing the memory */ - /* doesn't cause problems. */ - histograms = (PyArrayObject**)calloc(input->nd * n_results, - sizeof(PyArrayObject*)); - if (!histograms) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < n_results; jj++) { - histograms[jj] = NA_NewArray(NULL, tInt32, 1, &nbins); - if (!histograms[jj]) { - PyErr_NoMemory(); - goto exit; - } - } - - if (!NI_Histogram(input, labels, min_label, max_label, result_indices, - n_results, histograms, min, max, nbins)) - goto exit; - - result = _NI_BuildMeasurementResultArrayObject(n_results, histograms); - - exit: - Py_XDECREF(input); - Py_XDECREF(labels); - if (result_indices) - free(result_indices); - if (histograms) { - for(jj = 0; jj < n_results; jj++) { - Py_XDECREF(histograms[jj]); - } - free(histograms); - } - return result; -} - -static PyObject *Py_DistanceTransformBruteForce(PyObject *obj, - PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *features = NULL; - PyArrayObject *sampling = NULL; - int metric; - - if (!PyArg_ParseTuple(args, "O&iO&O&O&", NI_ObjectToInputArray, &input, - &metric, NI_ObjectToOptionalInputArray, &sampling, - NI_ObjectToOptionalOutputArray, &output, - NI_ObjectToOptionalOutputArray, &features)) - goto exit; - if (!NI_DistanceTransformBruteForce(input, metric, sampling, - output, features)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(sampling); - Py_XDECREF(output); - Py_XDECREF(features); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_DistanceTransformOnePass(PyObject *obj, PyObject *args) -{ - PyArrayObject *strct = NULL, *distances = NULL, *features = NULL; - - if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &strct, - NI_ObjectToIoArray, &distances, - NI_ObjectToOptionalOutputArray, &features)) - goto exit; - if (!NI_DistanceTransformOnePass(strct, distances, features)) - goto exit; -exit: - Py_XDECREF(strct); - Py_XDECREF(distances); - Py_XDECREF(features); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyObject *Py_EuclideanFeatureTransform(PyObject *obj, - PyObject *args) -{ - PyArrayObject *input = NULL, *features = NULL, *sampling = NULL; - - if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, - NI_ObjectToOptionalInputArray, &sampling, - NI_ObjectToOutputArray, &features)) - goto exit; - if (!NI_EuclideanFeatureTransform(input, sampling, features)) - goto exit; -exit: - Py_XDECREF(input); - Py_XDECREF(sampling); - Py_XDECREF(features); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static void _FreeCoordinateList(void* ptr) -{ - NI_FreeCoordinateList((NI_CoordinateList*)ptr); -} - -static PyObject *Py_BinaryErosion(PyObject *obj, PyObject *args) -{ - PyArrayObject *input = NULL, *output = NULL, *strct = NULL; - PyArrayObject *mask = NULL; - PyObject *cobj = NULL; - int border_value, invert, center_is_true; - int changed = 0, return_coordinates; - NI_CoordinateList *coordinate_list = NULL; - maybelong *origins = NULL; - - if (!PyArg_ParseTuple(args, "O&O&O&O&iO&iii", NI_ObjectToInputArray, - &input, NI_ObjectToInputArray, &strct, - NI_ObjectToOptionalInputArray, &mask, - NI_ObjectToOutputArray, &output, &border_value, - NI_ObjectToLongSequence, &origins, &invert, - ¢er_is_true, &return_coordinates)) - goto exit; - if (!NI_BinaryErosion(input, strct, mask, output, border_value, - origins, invert, center_is_true, &changed, - return_coordinates ? &coordinate_list : NULL)) - goto exit; - if (return_coordinates) { - cobj = PyCObject_FromVoidPtr(coordinate_list, _FreeCoordinateList); - } -exit: - Py_XDECREF(input); - Py_XDECREF(strct); - Py_XDECREF(mask); - Py_XDECREF(output); - if (origins) - free(origins); - if (PyErr_Occurred()) { - Py_XDECREF(cobj); - return NULL; - } else { - if (return_coordinates) { - return Py_BuildValue("iN", changed, cobj); - } else { - return Py_BuildValue("i", changed); - } - } -} - -static PyObject *Py_BinaryErosion2(PyObject *obj, PyObject *args) -{ - PyArrayObject *array = NULL, *strct = NULL, *mask = NULL; - PyObject *cobj = NULL; - int invert, niter; - maybelong *origins = NULL; - - if (!PyArg_ParseTuple(args, "O&O&O&iO&iO", NI_ObjectToIoArray, &array, - NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray, - &mask, &niter, NI_ObjectToLongSequence, &origins, &invert, - &cobj)) - goto exit; - - if (PyCObject_Check(cobj)) { - NI_CoordinateList *cobj_data = PyCObject_AsVoidPtr(cobj); - if (!NI_BinaryErosion2(array, strct, mask, niter, origins, invert, - &cobj_data)) - goto exit; - } else { - PyErr_SetString(PyExc_RuntimeError, "cannot convert CObject"); - goto exit; - } -exit: - Py_XDECREF(array); - Py_XDECREF(strct); - Py_XDECREF(mask); - if (origins) free(origins); - return PyErr_Occurred() ? NULL : Py_BuildValue(""); -} - -static PyMethodDef methods[] = { - {"correlate1d", (PyCFunction)Py_Correlate1D, - METH_VARARGS, NULL}, - {"correlate", (PyCFunction)Py_Correlate, - METH_VARARGS, NULL}, - {"uniform_filter1d", (PyCFunction)Py_UniformFilter1D, - METH_VARARGS, NULL}, - {"min_or_max_filter1d", (PyCFunction)Py_MinOrMaxFilter1D, - METH_VARARGS, NULL}, - {"min_or_max_filter", (PyCFunction)Py_MinOrMaxFilter, - METH_VARARGS, NULL}, - {"rank_filter", (PyCFunction)Py_RankFilter, - METH_VARARGS, NULL}, - {"generic_filter", (PyCFunction)Py_GenericFilter, - METH_VARARGS, NULL}, - {"generic_filter1d", (PyCFunction)Py_GenericFilter1D, - METH_VARARGS, NULL}, - {"fourier_filter", (PyCFunction)Py_FourierFilter, - METH_VARARGS, NULL}, - {"fourier_shift", (PyCFunction)Py_FourierShift, - METH_VARARGS, NULL}, - {"spline_filter1d", (PyCFunction)Py_SplineFilter1D, - METH_VARARGS, NULL}, - {"geometric_transform", (PyCFunction)Py_GeometricTransform, - METH_VARARGS, NULL}, - {"zoom_shift", (PyCFunction)Py_ZoomShift, - METH_VARARGS, NULL}, - {"label", (PyCFunction)Py_Label, - METH_VARARGS, NULL}, - {"find_objects", (PyCFunction)Py_FindObjects, - METH_VARARGS, NULL}, - {"watershed_ift", (PyCFunction)Py_WatershedIFT, - METH_VARARGS, NULL}, - {"statistics", (PyCFunction)Py_Statistics, - METH_VARARGS, NULL}, - {"center_of_mass", (PyCFunction)Py_CenterOfMass, - METH_VARARGS, NULL}, - {"histogram", (PyCFunction)Py_Histogram, - METH_VARARGS, NULL}, - {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce, - METH_VARARGS, NULL}, - {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass, - METH_VARARGS, NULL}, - {"euclidean_feature_transform", - (PyCFunction)Py_EuclideanFeatureTransform, - METH_VARARGS, NULL}, - {"binary_erosion", (PyCFunction)Py_BinaryErosion, - METH_VARARGS, NULL}, - {"binary_erosion2", (PyCFunction)Py_BinaryErosion2, - METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL} -}; - -PyMODINIT_FUNC init_nd_image(void) -{ - Py_InitModule("_nd_image", methods); - import_array(); -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define ND_IMPORT_ARRAY +#include "nd_image.h" +#undef ND_IMPORT_ARRAY +#include "ni_support.h" +#include "ni_filters.h" +#include "ni_fourier.h" +#include "ni_morphology.h" +#include "ni_interpolation.h" +#include "ni_measure.h" + +typedef struct { + PyObject *function; + PyObject *extra_arguments; + PyObject *extra_keywords; +} NI_PythonCallbackData; + +/* Convert an input array of any type, not necessarily contiguous */ +static int +NI_ObjectToInputArray(PyObject *object, PyArrayObject **array) +{ + *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); + return *array ? 1 : 0; +} + +/* Convert an input array of any type, not necessarily contiguous */ +static int +NI_ObjectToOptionalInputArray(PyObject *object, PyArrayObject **array) +{ + if (object == Py_None) { + *array = NULL; + return 1; + } else { + *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); + return *array ? 1 : 0; + } +} + +/* Convert an output array of any type, not necessarily contiguous */ +static int +NI_ObjectToOutputArray(PyObject *object, PyArrayObject **array) +{ + *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); + return *array ? 1 : 0; +} + +/* Convert an output array of any type, not necessarily contiguous */ +static int +NI_ObjectToOptionalOutputArray(PyObject *object, PyArrayObject **array) +{ + if (object == Py_None) { + *array = NULL; + return 1; + } else { + *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); + return *array ? 1 : 0; + } +} + +/* Convert an input/output array of any type, not necessarily contiguous */ +static int +NI_ObjectToIoArray(PyObject *object, PyArrayObject **array) +{ + *array = NA_IoArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); + return *array ? 1 : 0; +} + +/* Convert an Long sequence */ +static maybelong +NI_ObjectToLongSequenceAndLength(PyObject *object, maybelong **sequence) +{ + long *pa, ii; + PyArrayObject *array = NA_InputArray(object, PyArray_LONG, NPY_CARRAY); + maybelong length = PyArray_SIZE(array); + + *sequence = (maybelong*)malloc(length * sizeof(maybelong)); + if (!*sequence) { + PyErr_NoMemory(); + Py_XDECREF(array); + return -1; + } + pa = (long*)PyArray_DATA(array); + for(ii = 0; ii < length; ii++) + (*sequence)[ii] = pa[ii]; + Py_XDECREF(array); + return length; +} + +static int +NI_ObjectToLongSequence(PyObject *object, maybelong **sequence) +{ + return NI_ObjectToLongSequenceAndLength(object, sequence) >= 0; +} + +/*********************************************************************/ +/* wrapper functions: */ +/*********************************************************************/ + +static PyObject *Py_Correlate1D(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *weights = NULL; + int axis, mode; + long origin; + double cval; + + if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &weights, &axis, + NI_ObjectToOutputArray, &output, &mode, &cval, &origin)) + goto exit; + if (!NI_Correlate1D(input, weights, axis, output, + (NI_ExtendMode)mode, cval, origin)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(weights); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_Correlate(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *weights = NULL; + maybelong *origin = NULL; + int mode; + double cval; + + if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output, + &mode, &cval, NI_ObjectToLongSequence, &origin)) + goto exit; + if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval, + origin)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(weights); + Py_XDECREF(output); + if (origin) + free(origin); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_UniformFilter1D(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL; + int axis, mode; + long filter_size, origin; + double cval; + + if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input, + &filter_size, &axis, NI_ObjectToOutputArray, &output, + &mode, &cval, &origin)) + goto exit; + if (!NI_UniformFilter1D(input, filter_size, axis, output, + (NI_ExtendMode)mode, cval, origin)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_MinOrMaxFilter1D(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL; + int axis, mode, minimum; + long filter_size, origin; + double cval; + + if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input, + &filter_size, &axis, NI_ObjectToOutputArray, &output, + &mode, &cval, &origin, &minimum)) + goto exit; + if (!NI_MinOrMaxFilter1D(input, filter_size, axis, output, + (NI_ExtendMode)mode, cval, origin, minimum)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_MinOrMaxFilter(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *footprint = NULL; + PyArrayObject *structure = NULL; + maybelong *origin = NULL; + int mode, minimum; + double cval; + + if (!PyArg_ParseTuple(args, "O&O&O&O&idO&i", NI_ObjectToInputArray, + &input, NI_ObjectToInputArray, &footprint, + NI_ObjectToOptionalInputArray, &structure, + NI_ObjectToOutputArray, &output, &mode, &cval, + NI_ObjectToLongSequence, &origin, &minimum)) + goto exit; + if (!NI_MinOrMaxFilter(input, footprint, structure, output, + (NI_ExtendMode)mode, cval, origin, minimum)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(footprint); + Py_XDECREF(structure); + Py_XDECREF(output); + if (origin) + free(origin); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_RankFilter(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *footprint = NULL; + maybelong *origin = NULL; + int mode, rank; + double cval; + + if (!PyArg_ParseTuple(args, "O&iO&O&idO&", NI_ObjectToInputArray, + &input, &rank, NI_ObjectToInputArray, &footprint, + NI_ObjectToOutputArray, &output, &mode, &cval, + NI_ObjectToLongSequence, &origin)) + goto exit; + if (!NI_RankFilter(input, rank, footprint, output, (NI_ExtendMode)mode, + cval, origin)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(footprint); + Py_XDECREF(output); + if (origin) + free(origin); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static int Py_Filter1DFunc(double *iline, maybelong ilen, + double *oline, maybelong olen, void *data) +{ + PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL; + PyObject *rv = NULL, *args = NULL, *tmp = NULL; + maybelong ii; + double *po = NULL; + NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; + + py_ibuffer = NA_NewArray(iline, PyArray_DOUBLE, 1, &ilen); + py_obuffer = NA_NewArray(NULL, PyArray_DOUBLE, 1, &olen); + if (!py_ibuffer || !py_obuffer) + goto exit; + tmp = Py_BuildValue("(OO)", py_ibuffer, py_obuffer); + if (!tmp) + goto exit; + args = PySequence_Concat(tmp, cbdata->extra_arguments); + if (!args) + goto exit; + rv = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); + if (!rv) + goto exit; + po = (double*)PyArray_DATA(py_obuffer); + for(ii = 0; ii < olen; ii++) + oline[ii] = po[ii]; +exit: + Py_XDECREF(py_ibuffer); + Py_XDECREF(py_obuffer); + Py_XDECREF(rv); + Py_XDECREF(args); + Py_XDECREF(tmp); + return PyErr_Occurred() ? 0 : 1; +} + +static PyObject *Py_GenericFilter1D(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL; + PyObject *fnc = NULL, *extra_arguments = NULL, *extra_keywords = NULL; + void *func = Py_Filter1DFunc, *data = NULL; + NI_PythonCallbackData cbdata; + int axis, mode; + long origin, filter_size; + double cval; + + if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray, + &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray, + &output, &mode, &cval, &origin, &extra_arguments, &extra_keywords)) + goto exit; + if (!PyTuple_Check(extra_arguments)) { + PyErr_SetString(PyExc_RuntimeError, + "extra_arguments must be a tuple"); + goto exit; + } + if (!PyDict_Check(extra_keywords)) { + PyErr_SetString(PyExc_RuntimeError, + "extra_keywords must be a dictionary"); + goto exit; + } + if (PyCObject_Check(fnc)) { + func = PyCObject_AsVoidPtr(fnc); + data = PyCObject_GetDesc(fnc); + } else if (PyCallable_Check(fnc)) { + cbdata.function = fnc; + cbdata.extra_arguments = extra_arguments; + cbdata.extra_keywords = extra_keywords; + data = (void*)&cbdata; + } else { + PyErr_SetString(PyExc_RuntimeError, + "function parameter is not callable"); + goto exit; + } + if (!NI_GenericFilter1D(input, func, data, filter_size, axis, output, + (NI_ExtendMode)mode, cval, origin)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static int Py_FilterFunc(double *buffer, maybelong filter_size, + double *output, void *data) +{ + PyArrayObject *py_buffer = NULL; + PyObject *rv = NULL, *args = NULL, *tmp = NULL; + NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; + + py_buffer = NA_NewArray(buffer, PyArray_DOUBLE, 1, &filter_size); + if (!py_buffer) + goto exit; + tmp = Py_BuildValue("(O)", py_buffer); + if (!tmp) + goto exit; + args = PySequence_Concat(tmp, cbdata->extra_arguments); + if (!args) + goto exit; + rv = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); + if (!rv) + goto exit; + *output = PyFloat_AsDouble(rv); +exit: + Py_XDECREF(py_buffer); + Py_XDECREF(rv); + Py_XDECREF(args); + Py_XDECREF(tmp); + return PyErr_Occurred() ? 0 : 1; +} + +static PyObject *Py_GenericFilter(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *footprint = NULL; + PyObject *fnc = NULL, *extra_arguments = NULL, *extra_keywords = NULL; + void *func = Py_FilterFunc, *data = NULL; + NI_PythonCallbackData cbdata; + int mode; + maybelong *origin = NULL; + double cval; + + if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray, + &input, &fnc, NI_ObjectToInputArray, &footprint, + NI_ObjectToOutputArray, &output, &mode, &cval, + NI_ObjectToLongSequence, &origin, + &extra_arguments, &extra_keywords)) + goto exit; + if (!PyTuple_Check(extra_arguments)) { + PyErr_SetString(PyExc_RuntimeError, + "extra_arguments must be a tuple"); + goto exit; + } + if (!PyDict_Check(extra_keywords)) { + PyErr_SetString(PyExc_RuntimeError, + "extra_keywords must be a dictionary"); + goto exit; + } + if (PyCObject_Check(fnc)) { + func = PyCObject_AsVoidPtr(fnc); + data = PyCObject_GetDesc(fnc); + } else if (PyCallable_Check(fnc)) { + cbdata.function = fnc; + cbdata.extra_arguments = extra_arguments; + cbdata.extra_keywords = extra_keywords; + data = (void*)&cbdata; + } else { + PyErr_SetString(PyExc_RuntimeError, + "function parameter is not callable"); + goto exit; + } + if (!NI_GenericFilter(input, func, data, footprint, output, + (NI_ExtendMode)mode, cval, origin)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(output); + Py_XDECREF(footprint); + if (origin) + free(origin); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_FourierFilter(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *parameters = NULL; + int axis, filter_type; + long n; + + if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, ¶meters, &n, &axis, + NI_ObjectToOutputArray, &output, &filter_type)) + goto exit; + + if (!NI_FourierFilter(input, parameters, n, axis, output, filter_type)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(parameters); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_FourierShift(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *shifts = NULL; + int axis; + long n; + + if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &shifts, &n, &axis, + NI_ObjectToOutputArray, &output)) + goto exit; + + if (!NI_FourierShift(input, shifts, n, axis, output)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(shifts); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_SplineFilter1D(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL; + int axis, order; + + if (!PyArg_ParseTuple(args, "O&iiO&", NI_ObjectToInputArray, &input, + &order, &axis, NI_ObjectToOutputArray, &output)) + goto exit; + + if (!NI_SplineFilter1D(input, order, axis, output)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank, + void *data) +{ + PyObject *coors = NULL, *rets = NULL, *args = NULL, *tmp = NULL; + maybelong ii; + NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; + + coors = PyTuple_New(orank); + if (!coors) + goto exit; + for(ii = 0; ii < orank; ii++) { + PyTuple_SetItem(coors, ii, PyInt_FromLong(ocoor[ii])); + if (PyErr_Occurred()) + goto exit; + } + tmp = Py_BuildValue("(O)", coors); + if (!tmp) + goto exit; + args = PySequence_Concat(tmp, cbdata->extra_arguments); + if (!args) + goto exit; + rets = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); + if (!rets) + goto exit; + for(ii = 0; ii < irank; ii++) { + icoor[ii] = PyFloat_AsDouble(PyTuple_GetItem(rets, ii)); + if (PyErr_Occurred()) + goto exit; + } +exit: + Py_XDECREF(coors); + Py_XDECREF(tmp); + Py_XDECREF(rets); + Py_XDECREF(args); + return PyErr_Occurred() ? 0 : 1; +} + + +static PyObject *Py_GeometricTransform(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL; + PyArrayObject *coordinates = NULL, *matrix = NULL, *shift = NULL; + PyObject *fnc = NULL, *extra_arguments = NULL, *extra_keywords = NULL; + int mode, order; + double cval; + void *func = NULL, *data = NULL; + NI_PythonCallbackData cbdata; + + if (!PyArg_ParseTuple(args, "O&OO&O&O&O&iidOO", NI_ObjectToInputArray, + &input, &fnc, NI_ObjectToOptionalInputArray, + &coordinates, NI_ObjectToOptionalInputArray, + &matrix, NI_ObjectToOptionalInputArray, &shift, + NI_ObjectToOutputArray, &output, &order, &mode, + &cval, &extra_arguments, &extra_keywords)) + goto exit; + + if (fnc != Py_None) { + if (!PyTuple_Check(extra_arguments)) { + PyErr_SetString(PyExc_RuntimeError, + "extra_arguments must be a tuple"); + goto exit; + } + if (!PyDict_Check(extra_keywords)) { + PyErr_SetString(PyExc_RuntimeError, + "extra_keywords must be a dictionary"); + goto exit; + } + if (PyCObject_Check(fnc)) { + func = PyCObject_AsVoidPtr(fnc); + data = PyCObject_GetDesc(fnc); + } else if (PyCallable_Check(fnc)) { + func = Py_Map; + cbdata.function = fnc; + cbdata.extra_arguments = extra_arguments; + cbdata.extra_keywords = extra_keywords; + data = (void*)&cbdata; + } else { + PyErr_SetString(PyExc_RuntimeError, + "function parameter is not callable"); + goto exit; + } + } + + if (!NI_GeometricTransform(input, func, data, matrix, shift, coordinates, + output, order, (NI_ExtendMode)mode, cval)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(output); + Py_XDECREF(coordinates); + Py_XDECREF(matrix); + Py_XDECREF(shift); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_ZoomShift(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *shift = NULL; + PyArrayObject *zoom = NULL; + int mode, order; + double cval; + + if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray, + &input, NI_ObjectToOptionalInputArray, &zoom, + NI_ObjectToOptionalInputArray, &shift, NI_ObjectToOutputArray, + &output, &order, &mode, &cval)) + goto exit; + + if (!NI_ZoomShift(input, zoom, shift, output, order, (NI_ExtendMode)mode, + cval)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(shift); + Py_XDECREF(zoom); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_Label(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *strct = NULL; + maybelong max_label; + + if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &strct, NI_ObjectToOutputArray, &output)) + goto exit; + + if (!NI_Label(input, strct, &max_label, output)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(strct); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue("l", (long)max_label); +} + +static PyObject *Py_FindObjects(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL; + PyObject *result = NULL, *tuple = NULL, *start = NULL, *end = NULL; + PyObject *slc = NULL; + int jj; + long max_label; + maybelong ii, *regions = NULL; + + if (!PyArg_ParseTuple(args, "O&l", NI_ObjectToInputArray, &input, + &max_label)) + goto exit; + + if (max_label < 0) + max_label = 0; + if (max_label > 0) { + if (input->nd > 0) { + regions = (maybelong*)malloc(2 * max_label * input->nd * + sizeof(maybelong)); + } else { + regions = (maybelong*)malloc(max_label * sizeof(maybelong)); + } + if (!regions) { + PyErr_NoMemory(); + goto exit; + } + } + + if (!NI_FindObjects(input, max_label, regions)) + goto exit; + + result = PyList_New(max_label); + if (!result) { + PyErr_NoMemory(); + goto exit; + } + + for(ii = 0; ii < max_label; ii++) { + maybelong idx = input->nd > 0 ? 2 * input->nd * ii : ii; + if (regions[idx] >= 0) { + PyObject *tuple = PyTuple_New(input->nd); + if (!tuple) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < input->nd; jj++) { + start = PyInt_FromLong(regions[idx + jj]); + end = PyInt_FromLong(regions[idx + jj + input->nd]); + if (!start || !end) { + PyErr_NoMemory(); + goto exit; + } + slc = PySlice_New(start, end, NULL); + if (!slc) { + PyErr_NoMemory(); + goto exit; + } + Py_XDECREF(start); + Py_XDECREF(end); + start = end = NULL; + PyTuple_SetItem(tuple, jj, slc); + slc = NULL; + } + PyList_SetItem(result, ii, tuple); + tuple = NULL; + } else { + Py_INCREF(Py_None); + PyList_SetItem(result, ii, Py_None); + } + } + + Py_INCREF(result); + + exit: + Py_XDECREF(input); + Py_XDECREF(result); + Py_XDECREF(tuple); + Py_XDECREF(start); + Py_XDECREF(end); + Py_XDECREF(slc); + if (regions) + free(regions); + if (PyErr_Occurred()) { + Py_XDECREF(result); + return NULL; + } else { + return result; + } +} + +static PyObject *Py_WatershedIFT(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *markers = NULL; + PyArrayObject *strct = NULL; + + if (!PyArg_ParseTuple(args, "O&O&O&O&", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &markers, NI_ObjectToInputArray, + &strct, NI_ObjectToOutputArray, &output)) + goto exit; + + if (!NI_WatershedIFT(input, markers, strct, output)) + goto exit; + +exit: + Py_XDECREF(input); + Py_XDECREF(markers); + Py_XDECREF(strct); + Py_XDECREF(output); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static int _NI_GetIndices(PyObject* indices_object, + maybelong** result_indices, maybelong* min_label, + maybelong* max_label, maybelong* n_results) +{ + maybelong *indices = NULL, n_indices, ii; + + if (indices_object == Py_None) { + *min_label = -1; + *n_results = 1; + } else { + n_indices = NI_ObjectToLongSequenceAndLength(indices_object, &indices); + if (n_indices < 0) + goto exit; + if (n_indices < 1) { + PyErr_SetString(PyExc_RuntimeError, "no correct indices provided"); + goto exit; + } else { + *min_label = *max_label = indices[0]; + if (*min_label < 0) { + PyErr_SetString(PyExc_RuntimeError, + "negative indices not allowed"); + goto exit; + } + for(ii = 1; ii < n_indices; ii++) { + if (indices[ii] < 0) { + PyErr_SetString(PyExc_RuntimeError, + "negative indices not allowed"); + goto exit; + } + if (indices[ii] < *min_label) + *min_label = indices[ii]; + if (indices[ii] > *max_label) + *max_label = indices[ii]; + } + *result_indices = (maybelong*)malloc((*max_label - *min_label + 1) * + sizeof(maybelong)); + if (!*result_indices) { + PyErr_NoMemory(); + goto exit; + } + for(ii = 0; ii < *max_label - *min_label + 1; ii++) + (*result_indices)[ii] = -1; + *n_results = 0; + for(ii = 0; ii < n_indices; ii++) { + if ((*result_indices)[indices[ii] - *min_label] >= 0) { + PyErr_SetString(PyExc_RuntimeError, "duplicate index"); + goto exit; + } + (*result_indices)[indices[ii] - *min_label] = ii; + ++(*n_results); + } + } + } + exit: + if (indices) + free(indices); + return PyErr_Occurred() == NULL; +} + + +PyObject* _NI_BuildMeasurementResultArrayObject(maybelong n_results, + PyArrayObject** values) +{ + PyObject *result = NULL; + if (n_results > 1) { + result = PyList_New(n_results); + if (result) { + maybelong ii; + for(ii = 0; ii < n_results; ii++) { + PyList_SET_ITEM(result, ii, (PyObject*)values[ii]); + Py_XINCREF(values[ii]); + } + } + } else { + result = (PyObject*)values[0]; + Py_XINCREF(values[0]); + } + return result; +} + + +PyObject* _NI_BuildMeasurementResultDouble(maybelong n_results, + double* values) +{ + PyObject *result = NULL; + if (n_results > 1) { + result = PyList_New(n_results); + if (result) { + int ii; + for(ii = 0; ii < n_results; ii++) { + PyObject* val = PyFloat_FromDouble(values[ii]); + if (!val) { + Py_XDECREF(result); + return NULL; + } + PyList_SET_ITEM(result, ii, val); + } + } + } else { + result = Py_BuildValue("d", values[0]); + } + return result; +} + + +PyObject* _NI_BuildMeasurementResultDoubleTuple(maybelong n_results, + int tuple_size, double* values) +{ + PyObject *result = NULL; + maybelong ii; + int jj; + + if (n_results > 1) { + result = PyList_New(n_results); + if (result) { + for(ii = 0; ii < n_results; ii++) { + PyObject* val = PyTuple_New(tuple_size); + if (!val) { + Py_XDECREF(result); + return NULL; + } + for(jj = 0; jj < tuple_size; jj++) { + maybelong idx = jj + ii * tuple_size; + PyTuple_SetItem(val, jj, PyFloat_FromDouble(values[idx])); + if (PyErr_Occurred()) { + Py_XDECREF(result); + return NULL; + } + } + PyList_SET_ITEM(result, ii, val); + } + } + } else { + result = PyTuple_New(tuple_size); + if (result) { + for(ii = 0; ii < tuple_size; ii++) { + PyTuple_SetItem(result, ii, PyFloat_FromDouble(values[ii])); + if (PyErr_Occurred()) { + Py_XDECREF(result); + return NULL; + } + } + } + } + return result; +} + + +PyObject* _NI_BuildMeasurementResultInt(maybelong n_results, + maybelong* values) +{ + PyObject *result = NULL; + if (n_results > 1) { + result = PyList_New(n_results); + if (result) { + maybelong ii; + for(ii = 0; ii < n_results; ii++) { + PyObject* val = PyInt_FromLong(values[ii]); + if (!val) { + Py_XDECREF(result); + return NULL; + } + PyList_SET_ITEM(result, ii, val); + } + } + } else { + result = Py_BuildValue("l", values[0]); + } + return result; +} + + +static PyObject *Py_Statistics(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *labels = NULL; + PyObject *indices_object, *result = NULL; + PyObject *res1 = NULL, *res2 = NULL, *res3 = NULL, *res4 = NULL; + double *dresult1 = NULL, *dresult2 = NULL; + maybelong *lresult1 = NULL, *lresult2 = NULL; + maybelong min_label, max_label, *result_indices = NULL, n_results, ii; + int type; + + if (!PyArg_ParseTuple(args, "O&O&Oi", NI_ObjectToInputArray, &input, + NI_ObjectToOptionalInputArray, &labels, &indices_object, &type)) + goto exit; + + if (!_NI_GetIndices(indices_object, &result_indices, &min_label, + &max_label, &n_results)) + goto exit; + + if (type >= 0 && type <= 7) { + dresult1 = (double*)malloc(n_results * sizeof(double)); + if (!dresult1) { + PyErr_NoMemory(); + goto exit; + } + } + if (type == 2 || type == 7) { + dresult2 = (double*)malloc(n_results * sizeof(double)); + if (!dresult2) { + PyErr_NoMemory(); + goto exit; + } + } + if (type == 1 || type == 2 || (type >= 5 && type <= 7)) { + lresult1 = (maybelong*)malloc(n_results * sizeof(maybelong)); + if (!lresult1) { + PyErr_NoMemory(); + goto exit; + } + } + if (type == 7) { + lresult2 = (maybelong*)malloc(n_results * sizeof(maybelong)); + if (!lresult2) { + PyErr_NoMemory(); + goto exit; + } + } + switch(type) { + case 0: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, dresult1, NULL, NULL, NULL, NULL, NULL, NULL)) + goto exit; + result = _NI_BuildMeasurementResultDouble(n_results, dresult1); + break; + case 1: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, dresult1, lresult1, NULL, NULL, NULL, NULL, NULL)) + goto exit; + for(ii = 0; ii < n_results; ii++) + dresult1[ii] = lresult1[ii] > 0 ? dresult1[ii] / lresult1[ii] : 0.0; + + result = _NI_BuildMeasurementResultDouble(n_results, dresult1); + break; + case 2: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, dresult1, lresult1, dresult2, NULL, NULL, NULL, NULL)) + goto exit; + result = _NI_BuildMeasurementResultDouble(n_results, dresult2); + break; + case 3: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, NULL, NULL, NULL, dresult1, NULL, NULL, NULL)) + goto exit; + result = _NI_BuildMeasurementResultDouble(n_results, dresult1); + break; + case 4: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, NULL, NULL, NULL, NULL, dresult1, NULL, NULL)) + goto exit; + result = _NI_BuildMeasurementResultDouble(n_results, dresult1); + break; + case 5: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, NULL, NULL, NULL, dresult1, NULL, lresult1, NULL)) + goto exit; + result = _NI_BuildMeasurementResultInt(n_results, lresult1); + break; + case 6: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, NULL, NULL, NULL, NULL, dresult1, NULL, lresult1)) + goto exit; + result = _NI_BuildMeasurementResultInt(n_results, lresult1); + break; + case 7: + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, NULL, NULL, NULL, dresult1, dresult2, + lresult1, lresult2)) + goto exit; + res1 = _NI_BuildMeasurementResultDouble(n_results, dresult1); + res2 = _NI_BuildMeasurementResultDouble(n_results, dresult2); + res3 = _NI_BuildMeasurementResultInt(n_results, lresult1); + res4 = _NI_BuildMeasurementResultInt(n_results, lresult2); + if (!res1 || !res2 || !res3 || !res4) + goto exit; + result = Py_BuildValue("OOOO", res1, res2, res3, res4); + break; + default: + PyErr_SetString(PyExc_RuntimeError, "operation not supported"); + goto exit; + } + + exit: + Py_XDECREF(input); + Py_XDECREF(labels); + if (result_indices) + free(result_indices); + if (dresult1) + free(dresult1); + if (dresult2) + free(dresult2); + if (lresult1) + free(lresult1); + if (lresult2) + free(lresult2); + return result; +} + + +static PyObject *Py_CenterOfMass(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *labels = NULL; + PyObject *indices_object, *result = NULL; + double *center_of_mass = NULL; + maybelong min_label, max_label, *result_indices = NULL, n_results; + + if (!PyArg_ParseTuple(args, "O&O&O", NI_ObjectToInputArray, &input, + NI_ObjectToOptionalInputArray, &labels, &indices_object)) + goto exit; + + if (!_NI_GetIndices(indices_object, &result_indices, &min_label, + &max_label, &n_results)) + goto exit; + + center_of_mass = (double*)malloc(input->nd * n_results * + sizeof(double)); + if (!center_of_mass) { + PyErr_NoMemory(); + goto exit; + } + + if (!NI_CenterOfMass(input, labels, min_label, max_label, + result_indices, n_results, center_of_mass)) + goto exit; + + result = _NI_BuildMeasurementResultDoubleTuple(n_results, input->nd, + center_of_mass); + + exit: + Py_XDECREF(input); + Py_XDECREF(labels); + if (result_indices) + free(result_indices); + if (center_of_mass) + free(center_of_mass); + return result; +} + +static PyObject *Py_Histogram(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *labels = NULL, **histograms = NULL; + PyObject *indices_object, *result = NULL; + maybelong min_label, max_label, *result_indices = NULL, n_results; + maybelong jj, nbins; + long nbins_in; + double min, max; + + if (!PyArg_ParseTuple(args, "O&ddlO&O", NI_ObjectToInputArray, &input, + &min, &max, &nbins_in, NI_ObjectToOptionalInputArray, + &labels, &indices_object)) + goto exit; + nbins = nbins_in; + + if (!_NI_GetIndices(indices_object, &result_indices, &min_label, + &max_label, &n_results)) + goto exit; + + /* Set all pointers to NULL, so that freeing the memory */ + /* doesn't cause problems. */ + histograms = (PyArrayObject**)calloc(input->nd * n_results, + sizeof(PyArrayObject*)); + if (!histograms) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < n_results; jj++) { + histograms[jj] = NA_NewArray(NULL, tInt32, 1, &nbins); + if (!histograms[jj]) { + PyErr_NoMemory(); + goto exit; + } + } + + if (!NI_Histogram(input, labels, min_label, max_label, result_indices, + n_results, histograms, min, max, nbins)) + goto exit; + + result = _NI_BuildMeasurementResultArrayObject(n_results, histograms); + + exit: + Py_XDECREF(input); + Py_XDECREF(labels); + if (result_indices) + free(result_indices); + if (histograms) { + for(jj = 0; jj < n_results; jj++) { + Py_XDECREF(histograms[jj]); + } + free(histograms); + } + return result; +} + +static PyObject *Py_DistanceTransformBruteForce(PyObject *obj, + PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *features = NULL; + PyArrayObject *sampling = NULL; + int metric; + + if (!PyArg_ParseTuple(args, "O&iO&O&O&", NI_ObjectToInputArray, &input, + &metric, NI_ObjectToOptionalInputArray, &sampling, + NI_ObjectToOptionalOutputArray, &output, + NI_ObjectToOptionalOutputArray, &features)) + goto exit; + if (!NI_DistanceTransformBruteForce(input, metric, sampling, + output, features)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(sampling); + Py_XDECREF(output); + Py_XDECREF(features); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_DistanceTransformOnePass(PyObject *obj, PyObject *args) +{ + PyArrayObject *strct = NULL, *distances = NULL, *features = NULL; + + if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &strct, + NI_ObjectToIoArray, &distances, + NI_ObjectToOptionalOutputArray, &features)) + goto exit; + if (!NI_DistanceTransformOnePass(strct, distances, features)) + goto exit; +exit: + Py_XDECREF(strct); + Py_XDECREF(distances); + Py_XDECREF(features); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyObject *Py_EuclideanFeatureTransform(PyObject *obj, + PyObject *args) +{ + PyArrayObject *input = NULL, *features = NULL, *sampling = NULL; + + if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, + NI_ObjectToOptionalInputArray, &sampling, + NI_ObjectToOutputArray, &features)) + goto exit; + if (!NI_EuclideanFeatureTransform(input, sampling, features)) + goto exit; +exit: + Py_XDECREF(input); + Py_XDECREF(sampling); + Py_XDECREF(features); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static void _FreeCoordinateList(void* ptr) +{ + NI_FreeCoordinateList((NI_CoordinateList*)ptr); +} + +static PyObject *Py_BinaryErosion(PyObject *obj, PyObject *args) +{ + PyArrayObject *input = NULL, *output = NULL, *strct = NULL; + PyArrayObject *mask = NULL; + PyObject *cobj = NULL; + int border_value, invert, center_is_true; + int changed = 0, return_coordinates; + NI_CoordinateList *coordinate_list = NULL; + maybelong *origins = NULL; + + if (!PyArg_ParseTuple(args, "O&O&O&O&iO&iii", NI_ObjectToInputArray, + &input, NI_ObjectToInputArray, &strct, + NI_ObjectToOptionalInputArray, &mask, + NI_ObjectToOutputArray, &output, &border_value, + NI_ObjectToLongSequence, &origins, &invert, + ¢er_is_true, &return_coordinates)) + goto exit; + if (!NI_BinaryErosion(input, strct, mask, output, border_value, + origins, invert, center_is_true, &changed, + return_coordinates ? &coordinate_list : NULL)) + goto exit; + if (return_coordinates) { + cobj = PyCObject_FromVoidPtr(coordinate_list, _FreeCoordinateList); + } +exit: + Py_XDECREF(input); + Py_XDECREF(strct); + Py_XDECREF(mask); + Py_XDECREF(output); + if (origins) + free(origins); + if (PyErr_Occurred()) { + Py_XDECREF(cobj); + return NULL; + } else { + if (return_coordinates) { + return Py_BuildValue("iN", changed, cobj); + } else { + return Py_BuildValue("i", changed); + } + } +} + +static PyObject *Py_BinaryErosion2(PyObject *obj, PyObject *args) +{ + PyArrayObject *array = NULL, *strct = NULL, *mask = NULL; + PyObject *cobj = NULL; + int invert, niter; + maybelong *origins = NULL; + + if (!PyArg_ParseTuple(args, "O&O&O&iO&iO", NI_ObjectToIoArray, &array, + NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray, + &mask, &niter, NI_ObjectToLongSequence, &origins, &invert, + &cobj)) + goto exit; + + if (PyCObject_Check(cobj)) { + NI_CoordinateList *cobj_data = PyCObject_AsVoidPtr(cobj); + if (!NI_BinaryErosion2(array, strct, mask, niter, origins, invert, + &cobj_data)) + goto exit; + } else { + PyErr_SetString(PyExc_RuntimeError, "cannot convert CObject"); + goto exit; + } +exit: + Py_XDECREF(array); + Py_XDECREF(strct); + Py_XDECREF(mask); + if (origins) free(origins); + return PyErr_Occurred() ? NULL : Py_BuildValue(""); +} + +static PyMethodDef methods[] = { + {"correlate1d", (PyCFunction)Py_Correlate1D, + METH_VARARGS, NULL}, + {"correlate", (PyCFunction)Py_Correlate, + METH_VARARGS, NULL}, + {"uniform_filter1d", (PyCFunction)Py_UniformFilter1D, + METH_VARARGS, NULL}, + {"min_or_max_filter1d", (PyCFunction)Py_MinOrMaxFilter1D, + METH_VARARGS, NULL}, + {"min_or_max_filter", (PyCFunction)Py_MinOrMaxFilter, + METH_VARARGS, NULL}, + {"rank_filter", (PyCFunction)Py_RankFilter, + METH_VARARGS, NULL}, + {"generic_filter", (PyCFunction)Py_GenericFilter, + METH_VARARGS, NULL}, + {"generic_filter1d", (PyCFunction)Py_GenericFilter1D, + METH_VARARGS, NULL}, + {"fourier_filter", (PyCFunction)Py_FourierFilter, + METH_VARARGS, NULL}, + {"fourier_shift", (PyCFunction)Py_FourierShift, + METH_VARARGS, NULL}, + {"spline_filter1d", (PyCFunction)Py_SplineFilter1D, + METH_VARARGS, NULL}, + {"geometric_transform", (PyCFunction)Py_GeometricTransform, + METH_VARARGS, NULL}, + {"zoom_shift", (PyCFunction)Py_ZoomShift, + METH_VARARGS, NULL}, + {"label", (PyCFunction)Py_Label, + METH_VARARGS, NULL}, + {"find_objects", (PyCFunction)Py_FindObjects, + METH_VARARGS, NULL}, + {"watershed_ift", (PyCFunction)Py_WatershedIFT, + METH_VARARGS, NULL}, + {"statistics", (PyCFunction)Py_Statistics, + METH_VARARGS, NULL}, + {"center_of_mass", (PyCFunction)Py_CenterOfMass, + METH_VARARGS, NULL}, + {"histogram", (PyCFunction)Py_Histogram, + METH_VARARGS, NULL}, + {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce, + METH_VARARGS, NULL}, + {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass, + METH_VARARGS, NULL}, + {"euclidean_feature_transform", + (PyCFunction)Py_EuclideanFeatureTransform, + METH_VARARGS, NULL}, + {"binary_erosion", (PyCFunction)Py_BinaryErosion, + METH_VARARGS, NULL}, + {"binary_erosion2", (PyCFunction)Py_BinaryErosion2, + METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} +}; + +PyMODINIT_FUNC init_nd_image(void) +{ + Py_InitModule("_nd_image", methods); + import_array(); +} Modified: trunk/scipy/ndimage/src/nd_image.h =================================================================== --- trunk/scipy/ndimage/src/nd_image.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/nd_image.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,278 +1,278 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ND_IMAGE_H -#define ND_IMAGE_H - -#include "Python.h" - -#ifndef ND_IMPORT_ARRAY -#define NO_IMPORT_ARRAY -#endif - -#include -#undef NO_IMPORT_ARRAY - -/* Eventually get rid of everything below this line */ - -typedef enum -{ - tAny=-1, - tBool=PyArray_BOOL, - tInt8=PyArray_INT8, - tUInt8=PyArray_UINT8, - tInt16=PyArray_INT16, - tUInt16=PyArray_UINT16, - tInt32=PyArray_INT32, - tUInt32=PyArray_UINT32, - tInt64=PyArray_INT64, - tUInt64=PyArray_UINT64, - tFloat32=PyArray_FLOAT32, - tFloat64=PyArray_FLOAT64, - tComplex64=PyArray_COMPLEX64, - tComplex128=PyArray_COMPLEX128, - tObject=PyArray_OBJECT, /* placeholder... does nothing */ - tMaxType=PyArray_NTYPES, - tDefault=PyArray_FLOAT64, - tLong=PyArray_LONG, -} NumarrayType; - -#define NI_MAXDIM NPY_MAXDIMS - -typedef npy_intp maybelong; -#define MAXDIM NPY_MAXDIMS - -#define HAS_UINT64 1 - - - -#ifdef ND_IMPORT_ARRAY - -/* Numarray Helper Functions */ - -static PyArrayObject* -NA_InputArray(PyObject *a, NumarrayType t, int requires) -{ - PyArray_Descr *descr; - if (t == tAny) descr = NULL; - else descr = PyArray_DescrFromType(t); - return (PyArrayObject *) \ - PyArray_CheckFromAny(a, descr, 0, 0, requires, NULL); -} - -/* satisfies ensures that 'a' meets a set of requirements and matches -the specified type. -*/ -static int -satisfies(PyArrayObject *a, int requirements, NumarrayType t) -{ - int type_ok = (a->descr->type_num == t) || (t == tAny); - - if (PyArray_ISCARRAY(a)) - return type_ok; - if (PyArray_ISBYTESWAPPED(a) && (requirements & NPY_NOTSWAPPED)) - return 0; - if (!PyArray_ISALIGNED(a) && (requirements & NPY_ALIGNED)) - return 0; - if (!PyArray_ISCONTIGUOUS(a) && (requirements & NPY_CONTIGUOUS)) - return 0; - if (!PyArray_ISWRITEABLE(a) && (requirements & NPY_WRITEABLE)) - return 0; - if (requirements & NPY_ENSURECOPY) - return 0; - return type_ok; -} - -static PyArrayObject * -NA_OutputArray(PyObject *a, NumarrayType t, int requires) -{ - PyArray_Descr *dtype; - PyArrayObject *ret; - - if (!PyArray_Check(a) || !PyArray_ISWRITEABLE(a)) { - PyErr_Format(PyExc_TypeError, - "NA_OutputArray: only writeable arrays work for output."); - return NULL; - } - - if (satisfies((PyArrayObject *)a, requires, t)) { - Py_INCREF(a); - return (PyArrayObject *)a; - } - if (t == tAny) { - dtype = PyArray_DESCR(a); - Py_INCREF(dtype); - } - else { - dtype = PyArray_DescrFromType(t); - } - ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM(a), PyArray_DIMS(a), - dtype, 0); - ret->flags |= NPY_UPDATEIFCOPY; - ret->base = a; - PyArray_FLAGS(a) &= ~NPY_WRITEABLE; - Py_INCREF(a); - return ret; -} - -/* NA_IoArray is a combination of NA_InputArray and NA_OutputArray. - -Unlike NA_OutputArray, if a temporary is required it is initialized to a copy -of the input array. - -Unlike NA_InputArray, deallocating any resulting temporary array results in a -copy from the temporary back to the original. -*/ -static PyArrayObject * -NA_IoArray(PyObject *a, NumarrayType t, int requires) -{ - PyArrayObject *shadow = NA_InputArray(a, t, requires | NPY_UPDATEIFCOPY ); - - if (!shadow) return NULL; - - /* Guard against non-writable, but otherwise satisfying requires. - In this case, shadow == a. - */ - if (!PyArray_ISWRITEABLE(shadow)) { - PyErr_Format(PyExc_TypeError, - "NA_IoArray: I/O array must be writable array"); - PyArray_XDECREF_ERR(shadow); - return NULL; - } - - return shadow; -} - -#define NUM_LITTLE_ENDIAN 0 -#define NUM_BIG_ENDIAN 1 - -static int -NA_ByteOrder(void) -{ - unsigned long byteorder_test; - byteorder_test = 1; - if (*((char *) &byteorder_test)) - return NUM_LITTLE_ENDIAN; - else - return NUM_BIG_ENDIAN; -} - -/* ignores bytestride */ -static PyArrayObject * -NA_NewAllFromBuffer(int ndim, maybelong *shape, NumarrayType type, - PyObject *bufferObject, maybelong byteoffset, maybelong bytestride, - int byteorder, int aligned, int writeable) -{ - PyArrayObject *self = NULL; - PyArray_Descr *dtype; - - if (type == tAny) - type = tDefault; - - dtype = PyArray_DescrFromType(type); - if (dtype == NULL) return NULL; - - if (byteorder != NA_ByteOrder()) { - PyArray_Descr *temp; - temp = PyArray_DescrNewByteorder(dtype, PyArray_SWAP); - Py_DECREF(dtype); - if (temp == NULL) return NULL; - dtype = temp; - } - - if (bufferObject == Py_None || bufferObject == NULL) { - self = (PyArrayObject *) \ - PyArray_NewFromDescr(&PyArray_Type, dtype, - ndim, shape, NULL, NULL, - 0, NULL); - } - else { - npy_intp size = 1; - int i; - PyArrayObject *newself; - PyArray_Dims newdims; - for(i=0; idata, buffer, PyArray_NBYTES(result)); - } else { - memset(result->data, 0, PyArray_NBYTES(result)); - } - } - } - return result; -} - -/* Create a new numarray which is initially a C_array, or which -references a C_array: aligned, !byteswapped, contiguous, ... -Call with buffer==NULL to allocate storage. -*/ -static PyArrayObject * -NA_NewArray(void *buffer, NumarrayType type, int ndim, maybelong *shape) -{ - return (PyArrayObject *) NA_NewAll(ndim, shape, type, buffer, 0, 0, - NA_ByteOrder(), 1, 1); -} - -#endif /* ND_IMPORT_ARRAY */ - -#endif /* ND_IMAGE_H */ +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ND_IMAGE_H +#define ND_IMAGE_H + +#include "Python.h" + +#ifndef ND_IMPORT_ARRAY +#define NO_IMPORT_ARRAY +#endif + +#include +#undef NO_IMPORT_ARRAY + +/* Eventually get rid of everything below this line */ + +typedef enum +{ + tAny=-1, + tBool=PyArray_BOOL, + tInt8=PyArray_INT8, + tUInt8=PyArray_UINT8, + tInt16=PyArray_INT16, + tUInt16=PyArray_UINT16, + tInt32=PyArray_INT32, + tUInt32=PyArray_UINT32, + tInt64=PyArray_INT64, + tUInt64=PyArray_UINT64, + tFloat32=PyArray_FLOAT32, + tFloat64=PyArray_FLOAT64, + tComplex64=PyArray_COMPLEX64, + tComplex128=PyArray_COMPLEX128, + tObject=PyArray_OBJECT, /* placeholder... does nothing */ + tMaxType=PyArray_NTYPES, + tDefault=PyArray_FLOAT64, + tLong=PyArray_LONG, +} NumarrayType; + +#define NI_MAXDIM NPY_MAXDIMS + +typedef npy_intp maybelong; +#define MAXDIM NPY_MAXDIMS + +#define HAS_UINT64 1 + + + +#ifdef ND_IMPORT_ARRAY + +/* Numarray Helper Functions */ + +static PyArrayObject* +NA_InputArray(PyObject *a, NumarrayType t, int requires) +{ + PyArray_Descr *descr; + if (t == tAny) descr = NULL; + else descr = PyArray_DescrFromType(t); + return (PyArrayObject *) \ + PyArray_CheckFromAny(a, descr, 0, 0, requires, NULL); +} + +/* satisfies ensures that 'a' meets a set of requirements and matches +the specified type. +*/ +static int +satisfies(PyArrayObject *a, int requirements, NumarrayType t) +{ + int type_ok = (a->descr->type_num == t) || (t == tAny); + + if (PyArray_ISCARRAY(a)) + return type_ok; + if (PyArray_ISBYTESWAPPED(a) && (requirements & NPY_NOTSWAPPED)) + return 0; + if (!PyArray_ISALIGNED(a) && (requirements & NPY_ALIGNED)) + return 0; + if (!PyArray_ISCONTIGUOUS(a) && (requirements & NPY_CONTIGUOUS)) + return 0; + if (!PyArray_ISWRITEABLE(a) && (requirements & NPY_WRITEABLE)) + return 0; + if (requirements & NPY_ENSURECOPY) + return 0; + return type_ok; +} + +static PyArrayObject * +NA_OutputArray(PyObject *a, NumarrayType t, int requires) +{ + PyArray_Descr *dtype; + PyArrayObject *ret; + + if (!PyArray_Check(a) || !PyArray_ISWRITEABLE(a)) { + PyErr_Format(PyExc_TypeError, + "NA_OutputArray: only writeable arrays work for output."); + return NULL; + } + + if (satisfies((PyArrayObject *)a, requires, t)) { + Py_INCREF(a); + return (PyArrayObject *)a; + } + if (t == tAny) { + dtype = PyArray_DESCR(a); + Py_INCREF(dtype); + } + else { + dtype = PyArray_DescrFromType(t); + } + ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM(a), PyArray_DIMS(a), + dtype, 0); + ret->flags |= NPY_UPDATEIFCOPY; + ret->base = a; + PyArray_FLAGS(a) &= ~NPY_WRITEABLE; + Py_INCREF(a); + return ret; +} + +/* NA_IoArray is a combination of NA_InputArray and NA_OutputArray. + +Unlike NA_OutputArray, if a temporary is required it is initialized to a copy +of the input array. + +Unlike NA_InputArray, deallocating any resulting temporary array results in a +copy from the temporary back to the original. +*/ +static PyArrayObject * +NA_IoArray(PyObject *a, NumarrayType t, int requires) +{ + PyArrayObject *shadow = NA_InputArray(a, t, requires | NPY_UPDATEIFCOPY ); + + if (!shadow) return NULL; + + /* Guard against non-writable, but otherwise satisfying requires. + In this case, shadow == a. + */ + if (!PyArray_ISWRITEABLE(shadow)) { + PyErr_Format(PyExc_TypeError, + "NA_IoArray: I/O array must be writable array"); + PyArray_XDECREF_ERR(shadow); + return NULL; + } + + return shadow; +} + +#define NUM_LITTLE_ENDIAN 0 +#define NUM_BIG_ENDIAN 1 + +static int +NA_ByteOrder(void) +{ + unsigned long byteorder_test; + byteorder_test = 1; + if (*((char *) &byteorder_test)) + return NUM_LITTLE_ENDIAN; + else + return NUM_BIG_ENDIAN; +} + +/* ignores bytestride */ +static PyArrayObject * +NA_NewAllFromBuffer(int ndim, maybelong *shape, NumarrayType type, + PyObject *bufferObject, maybelong byteoffset, maybelong bytestride, + int byteorder, int aligned, int writeable) +{ + PyArrayObject *self = NULL; + PyArray_Descr *dtype; + + if (type == tAny) + type = tDefault; + + dtype = PyArray_DescrFromType(type); + if (dtype == NULL) return NULL; + + if (byteorder != NA_ByteOrder()) { + PyArray_Descr *temp; + temp = PyArray_DescrNewByteorder(dtype, PyArray_SWAP); + Py_DECREF(dtype); + if (temp == NULL) return NULL; + dtype = temp; + } + + if (bufferObject == Py_None || bufferObject == NULL) { + self = (PyArrayObject *) \ + PyArray_NewFromDescr(&PyArray_Type, dtype, + ndim, shape, NULL, NULL, + 0, NULL); + } + else { + npy_intp size = 1; + int i; + PyArrayObject *newself; + PyArray_Dims newdims; + for(i=0; idata, buffer, PyArray_NBYTES(result)); + } else { + memset(result->data, 0, PyArray_NBYTES(result)); + } + } + } + return result; +} + +/* Create a new numarray which is initially a C_array, or which +references a C_array: aligned, !byteswapped, contiguous, ... +Call with buffer==NULL to allocate storage. +*/ +static PyArrayObject * +NA_NewArray(void *buffer, NumarrayType type, int ndim, maybelong *shape) +{ + return (PyArrayObject *) NA_NewAll(ndim, shape, type, buffer, 0, 0, + NA_ByteOrder(), 1, 1); +} + +#endif /* ND_IMPORT_ARRAY */ + +#endif /* ND_IMAGE_H */ Modified: trunk/scipy/ndimage/src/ni_filters.c =================================================================== --- trunk/scipy/ndimage/src/ni_filters.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_filters.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,888 +1,888 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ni_support.h" -#include "ni_filters.h" -#include -#include - -#define BUFFER_SIZE 256000 - -int NI_Correlate1D(PyArrayObject *input, PyArrayObject *weights, - int axis, PyArrayObject *output, NI_ExtendMode mode, - double cval, maybelong origin) -{ - int symmetric = 0, ii, jj, more; - maybelong ll, lines, length, size1, size2, filter_size; - double *ibuffer = NULL, *obuffer = NULL; - Float64 *fw; - NI_LineBuffer iline_buffer, oline_buffer; - - /* test for symmetry or anti-symmetry: */ - filter_size = weights->dimensions[0]; - size1 = filter_size / 2; - size2 = filter_size - size1 - 1; - fw = (void *)PyArray_DATA(weights); - if (filter_size & 0x1) { - symmetric = 1; - for(ii = 1; ii <= filter_size / 2; ii++) { - if (fabs(fw[ii + size1] - fw[size1 - ii]) > DBL_EPSILON) { - symmetric = 0; - break; - } - } - if (symmetric == 0) { - symmetric = -1; - for(ii = 1; ii <= filter_size / 2; ii++) { - if (fabs(fw[size1 + ii] + fw[size1 - ii]) > DBL_EPSILON) { - symmetric = 0; - break; - } - } - } - } - /* allocate and initialize the line buffers: */ - lines = -1; - if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, - &lines, BUFFER_SIZE, &ibuffer)) - goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, - &obuffer)) - goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, - lines, ibuffer, mode, cval, &iline_buffer)) - goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, - &oline_buffer)) - goto exit; - length = input->nd > 0 ? input->dimensions[axis] : 1; - fw += size1; - /* iterate over all the array lines: */ - do { - /* copy lines from array to buffer: */ - if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) - goto exit; - /* iterate over the lines in the buffers: */ - for(ii = 0; ii < lines; ii++) { - /* get lines: */ - double *iline = NI_GET_LINE(iline_buffer, ii) + size1; - double *oline = NI_GET_LINE(oline_buffer, ii); - /* the correlation calculation: */ - if (symmetric > 0) { - for(ll = 0; ll < length; ll++) { - oline[ll] = iline[0] * fw[0]; - for(jj = -size1 ; jj < 0; jj++) - oline[ll] += (iline[jj] + iline[-jj]) * fw[jj]; - ++iline; - } - } else if (symmetric < 0) { - for(ll = 0; ll < length; ll++) { - oline[ll] = iline[0] * fw[0]; - for(jj = -size1 ; jj < 0; jj++) - oline[ll] += (iline[jj] - iline[-jj]) * fw[jj]; - ++iline; - } - } else { - for(ll = 0; ll < length; ll++) { - oline[ll] = iline[size2] * fw[size2]; - for(jj = -size1; jj < size2; jj++) - oline[ll] += iline[jj] * fw[jj]; - ++iline; - } - } - } - /* copy lines from buffer to array: */ - if (!NI_LineBufferToArray(&oline_buffer)) - goto exit; - } while(more); -exit: - if (ibuffer) free(ibuffer); - if (obuffer) free(obuffer); - return PyErr_Occurred() ? 0 : 1; -} - -#define CASE_CORRELATE_POINT(_pi, _weights, _offsets, _filter_size, \ - _cvalue, _type, _res, _mv) \ -case t ## _type: \ -{ \ - maybelong _ii, _offset; \ - for(_ii = 0; _ii < _filter_size; _ii++) { \ - _offset = _offsets[_ii]; \ - if (_offset == _mv) \ - _res += _weights[_ii] * _cvalue; \ - else \ - _res += _weights[_ii] * (double)*(_type*)(_pi + _offset); \ - } \ -} \ -break - -#define CASE_FILTER_OUT(_po, _tmp, _type) \ -case t ## _type: \ - *(_type*)_po = (_type)_tmp; \ - break - -int NI_Correlate(PyArrayObject* input, PyArrayObject* weights, - PyArrayObject* output, NI_ExtendMode mode, - double cvalue, maybelong *origins) -{ - Bool *pf = NULL; - maybelong fsize, jj, kk, filter_size = 0, border_flag_value; - maybelong *offsets = NULL, *oo, size; - NI_FilterIterator fi; - NI_Iterator ii, io; - char *pi, *po; - Float64 *pw; - Float64 *ww = NULL; - int ll; - - /* get the the footprint: */ - fsize = 1; - for(ll = 0; ll < weights->nd; ll++) - fsize *= weights->dimensions[ll]; - pw = (Float64*)PyArray_DATA(weights); - pf = (Bool*)malloc(fsize * sizeof(Bool)); - if (!pf) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < fsize; jj++) { - if (fabs(pw[jj]) > DBL_EPSILON) { - pf[jj] = 1; - ++filter_size; - } else { - pf[jj] = 0; - } - } - /* copy the weights to contiguous memory: */ - ww = (Float64*)malloc(filter_size * sizeof(Float64)); - if (!ww) { - PyErr_NoMemory(); - goto exit; - } - jj = 0; - for(kk = 0; kk < fsize; kk++) { - if (pf[kk]) { - ww[jj++] = pw[kk]; - } - } - /* initialize filter offsets: */ - if (!NI_InitFilterOffsets(input, pf, weights->dimensions, origins, - mode, &offsets, &border_flag_value, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, weights->dimensions, filter_size, - input->dimensions, origins, &fi)) - goto exit; - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - /* get data pointers an array size: */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* iterator over the elements: */ - oo = offsets; - for(jj = 0; jj < size; jj++) { - double tmp = 0.0; - switch (input->descr->type_num) { - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Bool, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt8, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt16, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt32, - tmp, border_flag_value); -#if HAS_UINT64 - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt64, - tmp, border_flag_value); -#endif - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int8, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int16, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int32, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int64, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Float32, - tmp, border_flag_value); - CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Float64, - tmp, border_flag_value); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FILTER_OUT(po, tmp, Bool); - CASE_FILTER_OUT(po, tmp, UInt8); - CASE_FILTER_OUT(po, tmp, UInt16); - CASE_FILTER_OUT(po, tmp, UInt32); -#if HAS_UINT64 - CASE_FILTER_OUT(po, tmp, UInt64); -#endif - CASE_FILTER_OUT(po, tmp, Int8); - CASE_FILTER_OUT(po, tmp, Int16); - CASE_FILTER_OUT(po, tmp, Int32); - CASE_FILTER_OUT(po, tmp, Int64); - CASE_FILTER_OUT(po, tmp, Float32); - CASE_FILTER_OUT(po, tmp, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); - } -exit: - if (offsets) free(offsets); - if (ww) free(ww); - if (pf) free(pf); - return PyErr_Occurred() ? 0 : 1; -} - -int -NI_UniformFilter1D(PyArrayObject *input, long filter_size, - int axis, PyArrayObject *output, NI_ExtendMode mode, - double cval, long origin) -{ - maybelong lines, kk, ll, length, size1, size2; - int more; - double *ibuffer = NULL, *obuffer = NULL; - NI_LineBuffer iline_buffer, oline_buffer; - - size1 = filter_size / 2; - size2 = filter_size - size1 - 1; - /* allocate and initialize the line buffers: */ - lines = -1; - if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, - &lines, BUFFER_SIZE, &ibuffer)) - goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, - &obuffer)) - goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, - lines, ibuffer, mode, cval, &iline_buffer)) - goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, - &oline_buffer)) - goto exit; - length = input->nd > 0 ? input->dimensions[axis] : 1; - - /* iterate over all the array lines: */ - do { - /* copy lines from array to buffer: */ - if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) - goto exit; - /* iterate over the lines in the buffers: */ - for(kk = 0; kk < lines; kk++) { - /* get lines: */ - double *iline = NI_GET_LINE(iline_buffer, kk); - double *oline = NI_GET_LINE(oline_buffer, kk); - /* do the uniform filter: */ - double tmp = 0.0; - double *l1 = iline; - double *l2 = iline + filter_size; - for(ll = 0; ll < filter_size; ll++) - tmp += iline[ll]; - tmp /= (double)filter_size; - oline[0] = tmp; - for(ll = 1; ll < length; ll++) { - tmp += (*l2++ - *l1++) / (double)filter_size; - oline[ll] = tmp; - } - } - /* copy lines from buffer to array: */ - if (!NI_LineBufferToArray(&oline_buffer)) - goto exit; - } while(more); - - exit: - if (ibuffer) free(ibuffer); - if (obuffer) free(obuffer); - return PyErr_Occurred() ? 0 : 1; -} - -int -NI_MinOrMaxFilter1D(PyArrayObject *input, long filter_size, - int axis, PyArrayObject *output, NI_ExtendMode mode, - double cval, long origin, int minimum) -{ - maybelong lines, kk, jj, ll, length, size1, size2; - int more; - double *ibuffer = NULL, *obuffer = NULL; - NI_LineBuffer iline_buffer, oline_buffer; - - size1 = filter_size / 2; - size2 = filter_size - size1 - 1; - /* allocate and initialize the line buffers: */ - lines = -1; - if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, - &lines, BUFFER_SIZE, &ibuffer)) - goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, - &obuffer)) - goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, - lines, ibuffer, mode, cval, &iline_buffer)) - goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, - &oline_buffer)) - goto exit; - length = input->nd > 0 ? input->dimensions[axis] : 1; - - /* iterate over all the array lines: */ - do { - /* copy lines from array to buffer: */ - if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) - goto exit; - /* iterate over the lines in the buffers: */ - for(kk = 0; kk < lines; kk++) { - /* get lines: */ - double *iline = NI_GET_LINE(iline_buffer, kk) + size1; - double *oline = NI_GET_LINE(oline_buffer, kk); - for(ll = 0; ll < length; ll++) { - /* find minimum or maximum filter: */ - double val = iline[ll - size1]; - for(jj = -size1 + 1; jj <= size2; jj++) { - double tmp = iline[ll + jj]; - if (minimum) { - if (tmp < val) - val = tmp; - } else { - if (tmp > val) - val = tmp; - } - } - oline[ll] = val; - } - } - /* copy lines from buffer to array: */ - if (!NI_LineBufferToArray(&oline_buffer)) - goto exit; - } while(more); - - exit: - if (ibuffer) free(ibuffer); - if (obuffer) free(obuffer); - return PyErr_Occurred() ? 0 : 1; -} - - -#define CASE_MIN_OR_MAX_POINT(_pi, _offsets, _filter_size, _cval, \ - _type, _minimum, _res, _mv, _ss) \ -case t ## _type: \ -{ \ - maybelong _ii, _oo = *_offsets; \ - _type _cv = (_type)_cval, _tmp; \ - _res = _oo == _mv ? _cv : *(_type*)(_pi + _oo); \ - if (_ss) \ - _res += *_ss; \ - for(_ii = 1; _ii < _filter_size; _ii++) { \ - _oo = _offsets[_ii]; \ - _tmp = _oo == _mv ? _cv : *(_type*)(_pi + _oo); \ - if (_ss) \ - _tmp += _ss[_ii]; \ - if (_minimum) { \ - if (_tmp < _res) \ - _res = (_type)_tmp; \ - } else { \ - if (_tmp > _res) \ - _res = (_type)_tmp; \ - } \ - } \ -} \ -break - -int NI_MinOrMaxFilter(PyArrayObject* input, PyArrayObject* footprint, - PyArrayObject* structure, PyArrayObject* output, - NI_ExtendMode mode, double cvalue, maybelong *origins, int minimum) -{ - Bool *pf = NULL; - maybelong fsize, jj, kk, filter_size = 0, border_flag_value; - maybelong *offsets = NULL, *oo, size; - NI_FilterIterator fi; - NI_Iterator ii, io; - char *pi, *po; - int ll; - double *ss = NULL; - Float64 *ps; - - /* get the the footprint: */ - fsize = 1; - for(ll = 0; ll < footprint->nd; ll++) - fsize *= footprint->dimensions[ll]; - pf = (Bool*)PyArray_DATA(footprint); - for(jj = 0; jj < fsize; jj++) { - if (pf[jj]) { - ++filter_size; - } - } - /* get the structure: */ - if (structure) { - ss = (double*)malloc(filter_size * sizeof(double)); - if (!ss) { - PyErr_NoMemory(); - goto exit; - } - /* copy the weights to contiguous memory: */ - ps = (Float64*)PyArray_DATA(structure); - jj = 0; - for(kk = 0; kk < fsize; kk++) - if (pf[kk]) - ss[jj++] = minimum ? -ps[kk] : ps[kk]; - } - /* initialize filter offsets: */ - if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, - mode, &offsets, &border_flag_value, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, footprint->dimensions, - filter_size, input->dimensions, origins, &fi)) - goto exit; - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - /* get data pointers an array size: */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* iterator over the elements: */ - oo = offsets; - for(jj = 0; jj < size; jj++) { - double tmp = 0.0; - switch (input->descr->type_num) { - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Bool, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt8, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt16, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt32, - minimum, tmp, border_flag_value, ss); -#if HAS_UINT64 - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt64, - minimum, tmp, border_flag_value, ss); -#endif - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int8, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int16, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int32, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int64, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Float32, - minimum, tmp, border_flag_value, ss); - CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Float64, - minimum, tmp, border_flag_value, ss); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FILTER_OUT(po, tmp, Bool); - CASE_FILTER_OUT(po, tmp, UInt8); - CASE_FILTER_OUT(po, tmp, UInt16); - CASE_FILTER_OUT(po, tmp, UInt32); -#if HAS_UINT64 - CASE_FILTER_OUT(po, tmp, UInt64); -#endif - CASE_FILTER_OUT(po, tmp, Int8); - CASE_FILTER_OUT(po, tmp, Int16); - CASE_FILTER_OUT(po, tmp, Int32); - CASE_FILTER_OUT(po, tmp, Int64); - CASE_FILTER_OUT(po, tmp, Float32); - CASE_FILTER_OUT(po, tmp, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); - } -exit: - if (offsets) free(offsets); - if (ss) free(ss); - return PyErr_Occurred() ? 0 : 1; -} - -static double NI_Select(double *buffer, int min, int max, int rank) -{ - int ii, jj; - double x, t; - - if (min == max) - return buffer[min]; - - x = buffer[min]; - ii = min - 1; - jj = max + 1; - for(;;) { - do - jj--; - while(buffer[jj] > x); - do - ii++; - while(buffer[ii] < x); - if (ii < jj) { - t = buffer[ii]; - buffer[ii] = buffer[jj]; - buffer[jj] = t; - } else { - break; - } - } - - ii = jj - min + 1; - if (rank < ii) - return NI_Select(buffer, min, jj, rank); - else - return NI_Select(buffer, jj + 1, max, rank - ii); -} - -#define CASE_RANK_POINT(_pi, _offsets, _filter_size, _cval, _type, \ - _rank, _buffer, _res, _mv) \ -case t ## _type: \ -{ \ - maybelong _ii; \ - for(_ii = 0; _ii < _filter_size; _ii++) { \ - maybelong _offset = _offsets[_ii]; \ - if (_offset == _mv) \ - _buffer[_ii] = (_type)_cval; \ - else \ - _buffer[_ii] = *(_type*)(_pi + _offsets[_ii]); \ - } \ - _res = (_type)NI_Select(_buffer, 0, _filter_size - 1, _rank); \ -} \ -break - -int NI_RankFilter(PyArrayObject* input, int rank, - PyArrayObject* footprint, PyArrayObject* output, - NI_ExtendMode mode, double cvalue, maybelong *origins) -{ - maybelong fsize, jj, filter_size = 0, border_flag_value; - maybelong *offsets = NULL, *oo, size; - NI_FilterIterator fi; - NI_Iterator ii, io; - char *pi, *po; - Bool *pf = NULL; - double *buffer = NULL; - int ll; - - /* get the the footprint: */ - fsize = 1; - for(ll = 0; ll < footprint->nd; ll++) - fsize *= footprint->dimensions[ll]; - pf = (Bool*)PyArray_DATA(footprint); - for(jj = 0; jj < fsize; jj++) { - if (pf[jj]) { - ++filter_size; - } - } - /* buffer for rank calculation: */ - buffer = (double*)malloc(filter_size * sizeof(double)); - if (!buffer) { - PyErr_NoMemory(); - goto exit; - } - /* iterator over the elements: */ - oo = offsets; - /* initialize filter offsets: */ - if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, - mode, &offsets, &border_flag_value, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, footprint->dimensions, - filter_size, input->dimensions, origins, &fi)) - goto exit; - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - /* get data pointers an array size: */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* iterator over the elements: */ - oo = offsets; - for(jj = 0; jj < size; jj++) { - double tmp = 0.0; - switch (input->descr->type_num) { - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Bool, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt8, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt16, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt32, - rank, buffer, tmp, border_flag_value); -#if HAS_UINT64 - CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt64, - rank, buffer, tmp, border_flag_value); -#endif - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int8, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int16, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int32, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int64, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Float32, - rank, buffer, tmp, border_flag_value); - CASE_RANK_POINT(pi, oo, filter_size, cvalue, Float64, - rank, buffer, tmp, border_flag_value); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FILTER_OUT(po, tmp, Bool); - CASE_FILTER_OUT(po, tmp, UInt8); - CASE_FILTER_OUT(po, tmp, UInt16); - CASE_FILTER_OUT(po, tmp, UInt32); -#if HAS_UINT64 - CASE_FILTER_OUT(po, tmp, UInt64); -#endif - CASE_FILTER_OUT(po, tmp, Int8); - CASE_FILTER_OUT(po, tmp, Int16); - CASE_FILTER_OUT(po, tmp, Int32); - CASE_FILTER_OUT(po, tmp, Int64); - CASE_FILTER_OUT(po, tmp, Float32); - CASE_FILTER_OUT(po, tmp, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); - } -exit: - if (offsets) free(offsets); - if (buffer) free(buffer); - return PyErr_Occurred() ? 0 : 1; -} - -int NI_GenericFilter1D(PyArrayObject *input, - int (*function)(double*, maybelong, double*, maybelong, void*), - void* data, long filter_size, int axis, PyArrayObject *output, - NI_ExtendMode mode, double cval, long origin) -{ - int more; - maybelong ii, lines, length, size1, size2; - double *ibuffer = NULL, *obuffer = NULL; - NI_LineBuffer iline_buffer, oline_buffer; - - /* allocate and initialize the line buffers: */ - size1 = filter_size / 2; - size2 = filter_size - size1 - 1; - lines = -1; - if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, - &lines, BUFFER_SIZE, &ibuffer)) - goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, - &obuffer)) - goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, - lines, ibuffer, mode, cval, &iline_buffer)) - goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, - &oline_buffer)) - goto exit; - length = input->nd > 0 ? input->dimensions[axis] : 1; - /* iterate over all the array lines: */ - do { - /* copy lines from array to buffer: */ - if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) - goto exit; - /* iterate over the lines in the buffers: */ - for(ii = 0; ii < lines; ii++) { - /* get lines: */ - double *iline = NI_GET_LINE(iline_buffer, ii); - double *oline = NI_GET_LINE(oline_buffer, ii); - if (!function(iline, length + size1 + size2, oline, length, data)) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, - "unknown error in line processing function"); - goto exit; - } - } - /* copy lines from buffer to array: */ - if (!NI_LineBufferToArray(&oline_buffer)) - goto exit; - } while(more); -exit: - if (ibuffer) free(ibuffer); - if (obuffer) free(obuffer); - return PyErr_Occurred() ? 0 : 1; -} - -#define CASE_FILTER_POINT(_pi, _offsets, _filter_size, _cvalue, _type, \ - _res, _mv, _function, _data, _buffer) \ -case t ## _type: \ -{ \ - maybelong _ii, _offset; \ - for(_ii = 0; _ii < _filter_size; _ii++) { \ - _offset = _offsets[_ii]; \ - if (_offset == _mv) \ - _buffer[_ii] = (double)_cvalue; \ - else \ - _buffer[_ii] = (double)*(_type*)(_pi + _offset); \ - } \ - if (!_function(_buffer, _filter_size, &_res, _data)) { \ - if (!PyErr_Occurred()) \ - PyErr_SetString(PyExc_RuntimeError, \ - "unknown error in filter function"); \ - goto exit; \ - } \ -} \ -break - - -int NI_GenericFilter(PyArrayObject* input, - int (*function)(double*, maybelong, double*, void*), void *data, - PyArrayObject* footprint, PyArrayObject* output, - NI_ExtendMode mode, double cvalue, maybelong *origins) -{ - Bool *pf = NULL; - maybelong fsize, jj, filter_size = 0, border_flag_value; - maybelong *offsets = NULL, *oo, size; - NI_FilterIterator fi; - NI_Iterator ii, io; - char *pi, *po; - double *buffer = NULL; - int ll; - - /* get the the footprint: */ - fsize = 1; - for(ll = 0; ll < footprint->nd; ll++) - fsize *= footprint->dimensions[ll]; - pf = (Bool*)PyArray_DATA(footprint); - for(jj = 0; jj < fsize; jj++) { - if (pf[jj]) - ++filter_size; - } - /* initialize filter offsets: */ - if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, - mode, &offsets, &border_flag_value, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, footprint->dimensions, - filter_size, input->dimensions, origins, &fi)) - goto exit; - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - /* get data pointers an array size: */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* buffer for filter calculation: */ - buffer = (double*)malloc(filter_size * sizeof(double)); - if (!buffer) { - PyErr_NoMemory(); - goto exit; - } - /* iterate over the elements: */ - oo = offsets; - for(jj = 0; jj < size; jj++) { - double tmp = 0.0; - switch (input->descr->type_num) { - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Bool, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt8, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt16, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt32, - tmp, border_flag_value, function, data, buffer); -#if HAS_UINT64 - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt64, - tmp, border_flag_value, function, data, buffer); -#endif - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int8, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int16, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int32, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int64, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Float32, - tmp, border_flag_value, function, data, buffer); - CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Float64, - tmp, border_flag_value, function, data, buffer); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FILTER_OUT(po, tmp, Bool); - CASE_FILTER_OUT(po, tmp, UInt8); - CASE_FILTER_OUT(po, tmp, UInt16); - CASE_FILTER_OUT(po, tmp, UInt32); -#if HAS_UINT64 - CASE_FILTER_OUT(po, tmp, UInt64); -#endif - CASE_FILTER_OUT(po, tmp, Int8); - CASE_FILTER_OUT(po, tmp, Int16); - CASE_FILTER_OUT(po, tmp, Int32); - CASE_FILTER_OUT(po, tmp, Int64); - CASE_FILTER_OUT(po, tmp, Float32); - CASE_FILTER_OUT(po, tmp, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - goto exit; - } - NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); - } -exit: - if (offsets) free(offsets); - if (buffer) free(buffer); - return PyErr_Occurred() ? 0 : 1; -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ni_support.h" +#include "ni_filters.h" +#include +#include + +#define BUFFER_SIZE 256000 + +int NI_Correlate1D(PyArrayObject *input, PyArrayObject *weights, + int axis, PyArrayObject *output, NI_ExtendMode mode, + double cval, maybelong origin) +{ + int symmetric = 0, ii, jj, more; + maybelong ll, lines, length, size1, size2, filter_size; + double *ibuffer = NULL, *obuffer = NULL; + Float64 *fw; + NI_LineBuffer iline_buffer, oline_buffer; + + /* test for symmetry or anti-symmetry: */ + filter_size = weights->dimensions[0]; + size1 = filter_size / 2; + size2 = filter_size - size1 - 1; + fw = (void *)PyArray_DATA(weights); + if (filter_size & 0x1) { + symmetric = 1; + for(ii = 1; ii <= filter_size / 2; ii++) { + if (fabs(fw[ii + size1] - fw[size1 - ii]) > DBL_EPSILON) { + symmetric = 0; + break; + } + } + if (symmetric == 0) { + symmetric = -1; + for(ii = 1; ii <= filter_size / 2; ii++) { + if (fabs(fw[size1 + ii] + fw[size1 - ii]) > DBL_EPSILON) { + symmetric = 0; + break; + } + } + } + } + /* allocate and initialize the line buffers: */ + lines = -1; + if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, + &lines, BUFFER_SIZE, &ibuffer)) + goto exit; + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + &obuffer)) + goto exit; + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + lines, ibuffer, mode, cval, &iline_buffer)) + goto exit; + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + &oline_buffer)) + goto exit; + length = input->nd > 0 ? input->dimensions[axis] : 1; + fw += size1; + /* iterate over all the array lines: */ + do { + /* copy lines from array to buffer: */ + if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) + goto exit; + /* iterate over the lines in the buffers: */ + for(ii = 0; ii < lines; ii++) { + /* get lines: */ + double *iline = NI_GET_LINE(iline_buffer, ii) + size1; + double *oline = NI_GET_LINE(oline_buffer, ii); + /* the correlation calculation: */ + if (symmetric > 0) { + for(ll = 0; ll < length; ll++) { + oline[ll] = iline[0] * fw[0]; + for(jj = -size1 ; jj < 0; jj++) + oline[ll] += (iline[jj] + iline[-jj]) * fw[jj]; + ++iline; + } + } else if (symmetric < 0) { + for(ll = 0; ll < length; ll++) { + oline[ll] = iline[0] * fw[0]; + for(jj = -size1 ; jj < 0; jj++) + oline[ll] += (iline[jj] - iline[-jj]) * fw[jj]; + ++iline; + } + } else { + for(ll = 0; ll < length; ll++) { + oline[ll] = iline[size2] * fw[size2]; + for(jj = -size1; jj < size2; jj++) + oline[ll] += iline[jj] * fw[jj]; + ++iline; + } + } + } + /* copy lines from buffer to array: */ + if (!NI_LineBufferToArray(&oline_buffer)) + goto exit; + } while(more); +exit: + if (ibuffer) free(ibuffer); + if (obuffer) free(obuffer); + return PyErr_Occurred() ? 0 : 1; +} + +#define CASE_CORRELATE_POINT(_pi, _weights, _offsets, _filter_size, \ + _cvalue, _type, _res, _mv) \ +case t ## _type: \ +{ \ + maybelong _ii, _offset; \ + for(_ii = 0; _ii < _filter_size; _ii++) { \ + _offset = _offsets[_ii]; \ + if (_offset == _mv) \ + _res += _weights[_ii] * _cvalue; \ + else \ + _res += _weights[_ii] * (double)*(_type*)(_pi + _offset); \ + } \ +} \ +break + +#define CASE_FILTER_OUT(_po, _tmp, _type) \ +case t ## _type: \ + *(_type*)_po = (_type)_tmp; \ + break + +int NI_Correlate(PyArrayObject* input, PyArrayObject* weights, + PyArrayObject* output, NI_ExtendMode mode, + double cvalue, maybelong *origins) +{ + Bool *pf = NULL; + maybelong fsize, jj, kk, filter_size = 0, border_flag_value; + maybelong *offsets = NULL, *oo, size; + NI_FilterIterator fi; + NI_Iterator ii, io; + char *pi, *po; + Float64 *pw; + Float64 *ww = NULL; + int ll; + + /* get the the footprint: */ + fsize = 1; + for(ll = 0; ll < weights->nd; ll++) + fsize *= weights->dimensions[ll]; + pw = (Float64*)PyArray_DATA(weights); + pf = (Bool*)malloc(fsize * sizeof(Bool)); + if (!pf) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < fsize; jj++) { + if (fabs(pw[jj]) > DBL_EPSILON) { + pf[jj] = 1; + ++filter_size; + } else { + pf[jj] = 0; + } + } + /* copy the weights to contiguous memory: */ + ww = (Float64*)malloc(filter_size * sizeof(Float64)); + if (!ww) { + PyErr_NoMemory(); + goto exit; + } + jj = 0; + for(kk = 0; kk < fsize; kk++) { + if (pf[kk]) { + ww[jj++] = pw[kk]; + } + } + /* initialize filter offsets: */ + if (!NI_InitFilterOffsets(input, pf, weights->dimensions, origins, + mode, &offsets, &border_flag_value, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(input->nd, weights->dimensions, filter_size, + input->dimensions, origins, &fi)) + goto exit; + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + /* get data pointers an array size: */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* iterator over the elements: */ + oo = offsets; + for(jj = 0; jj < size; jj++) { + double tmp = 0.0; + switch (input->descr->type_num) { + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Bool, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt8, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt16, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt32, + tmp, border_flag_value); +#if HAS_UINT64 + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt64, + tmp, border_flag_value); +#endif + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int8, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int16, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int32, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int64, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Float32, + tmp, border_flag_value); + CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Float64, + tmp, border_flag_value); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FILTER_OUT(po, tmp, Bool); + CASE_FILTER_OUT(po, tmp, UInt8); + CASE_FILTER_OUT(po, tmp, UInt16); + CASE_FILTER_OUT(po, tmp, UInt32); +#if HAS_UINT64 + CASE_FILTER_OUT(po, tmp, UInt64); +#endif + CASE_FILTER_OUT(po, tmp, Int8); + CASE_FILTER_OUT(po, tmp, Int16); + CASE_FILTER_OUT(po, tmp, Int32); + CASE_FILTER_OUT(po, tmp, Int64); + CASE_FILTER_OUT(po, tmp, Float32); + CASE_FILTER_OUT(po, tmp, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); + } +exit: + if (offsets) free(offsets); + if (ww) free(ww); + if (pf) free(pf); + return PyErr_Occurred() ? 0 : 1; +} + +int +NI_UniformFilter1D(PyArrayObject *input, long filter_size, + int axis, PyArrayObject *output, NI_ExtendMode mode, + double cval, long origin) +{ + maybelong lines, kk, ll, length, size1, size2; + int more; + double *ibuffer = NULL, *obuffer = NULL; + NI_LineBuffer iline_buffer, oline_buffer; + + size1 = filter_size / 2; + size2 = filter_size - size1 - 1; + /* allocate and initialize the line buffers: */ + lines = -1; + if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, + &lines, BUFFER_SIZE, &ibuffer)) + goto exit; + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + &obuffer)) + goto exit; + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + lines, ibuffer, mode, cval, &iline_buffer)) + goto exit; + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + &oline_buffer)) + goto exit; + length = input->nd > 0 ? input->dimensions[axis] : 1; + + /* iterate over all the array lines: */ + do { + /* copy lines from array to buffer: */ + if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) + goto exit; + /* iterate over the lines in the buffers: */ + for(kk = 0; kk < lines; kk++) { + /* get lines: */ + double *iline = NI_GET_LINE(iline_buffer, kk); + double *oline = NI_GET_LINE(oline_buffer, kk); + /* do the uniform filter: */ + double tmp = 0.0; + double *l1 = iline; + double *l2 = iline + filter_size; + for(ll = 0; ll < filter_size; ll++) + tmp += iline[ll]; + tmp /= (double)filter_size; + oline[0] = tmp; + for(ll = 1; ll < length; ll++) { + tmp += (*l2++ - *l1++) / (double)filter_size; + oline[ll] = tmp; + } + } + /* copy lines from buffer to array: */ + if (!NI_LineBufferToArray(&oline_buffer)) + goto exit; + } while(more); + + exit: + if (ibuffer) free(ibuffer); + if (obuffer) free(obuffer); + return PyErr_Occurred() ? 0 : 1; +} + +int +NI_MinOrMaxFilter1D(PyArrayObject *input, long filter_size, + int axis, PyArrayObject *output, NI_ExtendMode mode, + double cval, long origin, int minimum) +{ + maybelong lines, kk, jj, ll, length, size1, size2; + int more; + double *ibuffer = NULL, *obuffer = NULL; + NI_LineBuffer iline_buffer, oline_buffer; + + size1 = filter_size / 2; + size2 = filter_size - size1 - 1; + /* allocate and initialize the line buffers: */ + lines = -1; + if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, + &lines, BUFFER_SIZE, &ibuffer)) + goto exit; + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + &obuffer)) + goto exit; + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + lines, ibuffer, mode, cval, &iline_buffer)) + goto exit; + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + &oline_buffer)) + goto exit; + length = input->nd > 0 ? input->dimensions[axis] : 1; + + /* iterate over all the array lines: */ + do { + /* copy lines from array to buffer: */ + if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) + goto exit; + /* iterate over the lines in the buffers: */ + for(kk = 0; kk < lines; kk++) { + /* get lines: */ + double *iline = NI_GET_LINE(iline_buffer, kk) + size1; + double *oline = NI_GET_LINE(oline_buffer, kk); + for(ll = 0; ll < length; ll++) { + /* find minimum or maximum filter: */ + double val = iline[ll - size1]; + for(jj = -size1 + 1; jj <= size2; jj++) { + double tmp = iline[ll + jj]; + if (minimum) { + if (tmp < val) + val = tmp; + } else { + if (tmp > val) + val = tmp; + } + } + oline[ll] = val; + } + } + /* copy lines from buffer to array: */ + if (!NI_LineBufferToArray(&oline_buffer)) + goto exit; + } while(more); + + exit: + if (ibuffer) free(ibuffer); + if (obuffer) free(obuffer); + return PyErr_Occurred() ? 0 : 1; +} + + +#define CASE_MIN_OR_MAX_POINT(_pi, _offsets, _filter_size, _cval, \ + _type, _minimum, _res, _mv, _ss) \ +case t ## _type: \ +{ \ + maybelong _ii, _oo = *_offsets; \ + _type _cv = (_type)_cval, _tmp; \ + _res = _oo == _mv ? _cv : *(_type*)(_pi + _oo); \ + if (_ss) \ + _res += *_ss; \ + for(_ii = 1; _ii < _filter_size; _ii++) { \ + _oo = _offsets[_ii]; \ + _tmp = _oo == _mv ? _cv : *(_type*)(_pi + _oo); \ + if (_ss) \ + _tmp += _ss[_ii]; \ + if (_minimum) { \ + if (_tmp < _res) \ + _res = (_type)_tmp; \ + } else { \ + if (_tmp > _res) \ + _res = (_type)_tmp; \ + } \ + } \ +} \ +break + +int NI_MinOrMaxFilter(PyArrayObject* input, PyArrayObject* footprint, + PyArrayObject* structure, PyArrayObject* output, + NI_ExtendMode mode, double cvalue, maybelong *origins, int minimum) +{ + Bool *pf = NULL; + maybelong fsize, jj, kk, filter_size = 0, border_flag_value; + maybelong *offsets = NULL, *oo, size; + NI_FilterIterator fi; + NI_Iterator ii, io; + char *pi, *po; + int ll; + double *ss = NULL; + Float64 *ps; + + /* get the the footprint: */ + fsize = 1; + for(ll = 0; ll < footprint->nd; ll++) + fsize *= footprint->dimensions[ll]; + pf = (Bool*)PyArray_DATA(footprint); + for(jj = 0; jj < fsize; jj++) { + if (pf[jj]) { + ++filter_size; + } + } + /* get the structure: */ + if (structure) { + ss = (double*)malloc(filter_size * sizeof(double)); + if (!ss) { + PyErr_NoMemory(); + goto exit; + } + /* copy the weights to contiguous memory: */ + ps = (Float64*)PyArray_DATA(structure); + jj = 0; + for(kk = 0; kk < fsize; kk++) + if (pf[kk]) + ss[jj++] = minimum ? -ps[kk] : ps[kk]; + } + /* initialize filter offsets: */ + if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, + mode, &offsets, &border_flag_value, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(input->nd, footprint->dimensions, + filter_size, input->dimensions, origins, &fi)) + goto exit; + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + /* get data pointers an array size: */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* iterator over the elements: */ + oo = offsets; + for(jj = 0; jj < size; jj++) { + double tmp = 0.0; + switch (input->descr->type_num) { + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Bool, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt8, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt16, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt32, + minimum, tmp, border_flag_value, ss); +#if HAS_UINT64 + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt64, + minimum, tmp, border_flag_value, ss); +#endif + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int8, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int16, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int32, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int64, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Float32, + minimum, tmp, border_flag_value, ss); + CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Float64, + minimum, tmp, border_flag_value, ss); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FILTER_OUT(po, tmp, Bool); + CASE_FILTER_OUT(po, tmp, UInt8); + CASE_FILTER_OUT(po, tmp, UInt16); + CASE_FILTER_OUT(po, tmp, UInt32); +#if HAS_UINT64 + CASE_FILTER_OUT(po, tmp, UInt64); +#endif + CASE_FILTER_OUT(po, tmp, Int8); + CASE_FILTER_OUT(po, tmp, Int16); + CASE_FILTER_OUT(po, tmp, Int32); + CASE_FILTER_OUT(po, tmp, Int64); + CASE_FILTER_OUT(po, tmp, Float32); + CASE_FILTER_OUT(po, tmp, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); + } +exit: + if (offsets) free(offsets); + if (ss) free(ss); + return PyErr_Occurred() ? 0 : 1; +} + +static double NI_Select(double *buffer, int min, int max, int rank) +{ + int ii, jj; + double x, t; + + if (min == max) + return buffer[min]; + + x = buffer[min]; + ii = min - 1; + jj = max + 1; + for(;;) { + do + jj--; + while(buffer[jj] > x); + do + ii++; + while(buffer[ii] < x); + if (ii < jj) { + t = buffer[ii]; + buffer[ii] = buffer[jj]; + buffer[jj] = t; + } else { + break; + } + } + + ii = jj - min + 1; + if (rank < ii) + return NI_Select(buffer, min, jj, rank); + else + return NI_Select(buffer, jj + 1, max, rank - ii); +} + +#define CASE_RANK_POINT(_pi, _offsets, _filter_size, _cval, _type, \ + _rank, _buffer, _res, _mv) \ +case t ## _type: \ +{ \ + maybelong _ii; \ + for(_ii = 0; _ii < _filter_size; _ii++) { \ + maybelong _offset = _offsets[_ii]; \ + if (_offset == _mv) \ + _buffer[_ii] = (_type)_cval; \ + else \ + _buffer[_ii] = *(_type*)(_pi + _offsets[_ii]); \ + } \ + _res = (_type)NI_Select(_buffer, 0, _filter_size - 1, _rank); \ +} \ +break + +int NI_RankFilter(PyArrayObject* input, int rank, + PyArrayObject* footprint, PyArrayObject* output, + NI_ExtendMode mode, double cvalue, maybelong *origins) +{ + maybelong fsize, jj, filter_size = 0, border_flag_value; + maybelong *offsets = NULL, *oo, size; + NI_FilterIterator fi; + NI_Iterator ii, io; + char *pi, *po; + Bool *pf = NULL; + double *buffer = NULL; + int ll; + + /* get the the footprint: */ + fsize = 1; + for(ll = 0; ll < footprint->nd; ll++) + fsize *= footprint->dimensions[ll]; + pf = (Bool*)PyArray_DATA(footprint); + for(jj = 0; jj < fsize; jj++) { + if (pf[jj]) { + ++filter_size; + } + } + /* buffer for rank calculation: */ + buffer = (double*)malloc(filter_size * sizeof(double)); + if (!buffer) { + PyErr_NoMemory(); + goto exit; + } + /* iterator over the elements: */ + oo = offsets; + /* initialize filter offsets: */ + if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, + mode, &offsets, &border_flag_value, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(input->nd, footprint->dimensions, + filter_size, input->dimensions, origins, &fi)) + goto exit; + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + /* get data pointers an array size: */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* iterator over the elements: */ + oo = offsets; + for(jj = 0; jj < size; jj++) { + double tmp = 0.0; + switch (input->descr->type_num) { + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Bool, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt8, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt16, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt32, + rank, buffer, tmp, border_flag_value); +#if HAS_UINT64 + CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt64, + rank, buffer, tmp, border_flag_value); +#endif + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int8, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int16, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int32, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int64, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Float32, + rank, buffer, tmp, border_flag_value); + CASE_RANK_POINT(pi, oo, filter_size, cvalue, Float64, + rank, buffer, tmp, border_flag_value); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FILTER_OUT(po, tmp, Bool); + CASE_FILTER_OUT(po, tmp, UInt8); + CASE_FILTER_OUT(po, tmp, UInt16); + CASE_FILTER_OUT(po, tmp, UInt32); +#if HAS_UINT64 + CASE_FILTER_OUT(po, tmp, UInt64); +#endif + CASE_FILTER_OUT(po, tmp, Int8); + CASE_FILTER_OUT(po, tmp, Int16); + CASE_FILTER_OUT(po, tmp, Int32); + CASE_FILTER_OUT(po, tmp, Int64); + CASE_FILTER_OUT(po, tmp, Float32); + CASE_FILTER_OUT(po, tmp, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); + } +exit: + if (offsets) free(offsets); + if (buffer) free(buffer); + return PyErr_Occurred() ? 0 : 1; +} + +int NI_GenericFilter1D(PyArrayObject *input, + int (*function)(double*, maybelong, double*, maybelong, void*), + void* data, long filter_size, int axis, PyArrayObject *output, + NI_ExtendMode mode, double cval, long origin) +{ + int more; + maybelong ii, lines, length, size1, size2; + double *ibuffer = NULL, *obuffer = NULL; + NI_LineBuffer iline_buffer, oline_buffer; + + /* allocate and initialize the line buffers: */ + size1 = filter_size / 2; + size2 = filter_size - size1 - 1; + lines = -1; + if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, + &lines, BUFFER_SIZE, &ibuffer)) + goto exit; + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + &obuffer)) + goto exit; + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + lines, ibuffer, mode, cval, &iline_buffer)) + goto exit; + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + &oline_buffer)) + goto exit; + length = input->nd > 0 ? input->dimensions[axis] : 1; + /* iterate over all the array lines: */ + do { + /* copy lines from array to buffer: */ + if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) + goto exit; + /* iterate over the lines in the buffers: */ + for(ii = 0; ii < lines; ii++) { + /* get lines: */ + double *iline = NI_GET_LINE(iline_buffer, ii); + double *oline = NI_GET_LINE(oline_buffer, ii); + if (!function(iline, length + size1 + size2, oline, length, data)) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, + "unknown error in line processing function"); + goto exit; + } + } + /* copy lines from buffer to array: */ + if (!NI_LineBufferToArray(&oline_buffer)) + goto exit; + } while(more); +exit: + if (ibuffer) free(ibuffer); + if (obuffer) free(obuffer); + return PyErr_Occurred() ? 0 : 1; +} + +#define CASE_FILTER_POINT(_pi, _offsets, _filter_size, _cvalue, _type, \ + _res, _mv, _function, _data, _buffer) \ +case t ## _type: \ +{ \ + maybelong _ii, _offset; \ + for(_ii = 0; _ii < _filter_size; _ii++) { \ + _offset = _offsets[_ii]; \ + if (_offset == _mv) \ + _buffer[_ii] = (double)_cvalue; \ + else \ + _buffer[_ii] = (double)*(_type*)(_pi + _offset); \ + } \ + if (!_function(_buffer, _filter_size, &_res, _data)) { \ + if (!PyErr_Occurred()) \ + PyErr_SetString(PyExc_RuntimeError, \ + "unknown error in filter function"); \ + goto exit; \ + } \ +} \ +break + + +int NI_GenericFilter(PyArrayObject* input, + int (*function)(double*, maybelong, double*, void*), void *data, + PyArrayObject* footprint, PyArrayObject* output, + NI_ExtendMode mode, double cvalue, maybelong *origins) +{ + Bool *pf = NULL; + maybelong fsize, jj, filter_size = 0, border_flag_value; + maybelong *offsets = NULL, *oo, size; + NI_FilterIterator fi; + NI_Iterator ii, io; + char *pi, *po; + double *buffer = NULL; + int ll; + + /* get the the footprint: */ + fsize = 1; + for(ll = 0; ll < footprint->nd; ll++) + fsize *= footprint->dimensions[ll]; + pf = (Bool*)PyArray_DATA(footprint); + for(jj = 0; jj < fsize; jj++) { + if (pf[jj]) + ++filter_size; + } + /* initialize filter offsets: */ + if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, + mode, &offsets, &border_flag_value, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(input->nd, footprint->dimensions, + filter_size, input->dimensions, origins, &fi)) + goto exit; + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + /* get data pointers an array size: */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* buffer for filter calculation: */ + buffer = (double*)malloc(filter_size * sizeof(double)); + if (!buffer) { + PyErr_NoMemory(); + goto exit; + } + /* iterate over the elements: */ + oo = offsets; + for(jj = 0; jj < size; jj++) { + double tmp = 0.0; + switch (input->descr->type_num) { + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Bool, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt8, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt16, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt32, + tmp, border_flag_value, function, data, buffer); +#if HAS_UINT64 + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt64, + tmp, border_flag_value, function, data, buffer); +#endif + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int8, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int16, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int32, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int64, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Float32, + tmp, border_flag_value, function, data, buffer); + CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Float64, + tmp, border_flag_value, function, data, buffer); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FILTER_OUT(po, tmp, Bool); + CASE_FILTER_OUT(po, tmp, UInt8); + CASE_FILTER_OUT(po, tmp, UInt16); + CASE_FILTER_OUT(po, tmp, UInt32); +#if HAS_UINT64 + CASE_FILTER_OUT(po, tmp, UInt64); +#endif + CASE_FILTER_OUT(po, tmp, Int8); + CASE_FILTER_OUT(po, tmp, Int16); + CASE_FILTER_OUT(po, tmp, Int32); + CASE_FILTER_OUT(po, tmp, Int64); + CASE_FILTER_OUT(po, tmp, Float32); + CASE_FILTER_OUT(po, tmp, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + goto exit; + } + NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); + } +exit: + if (offsets) free(offsets); + if (buffer) free(buffer); + return PyErr_Occurred() ? 0 : 1; +} Modified: trunk/scipy/ndimage/src/ni_filters.h =================================================================== --- trunk/scipy/ndimage/src/ni_filters.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_filters.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,54 +1,54 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NI_FILTERS_H -#define NI_FILTERS_H - -int NI_Correlate1D(PyArrayObject*, PyArrayObject*, int, PyArrayObject*, - NI_ExtendMode, double, maybelong); -int NI_Correlate(PyArrayObject*, PyArrayObject*, PyArrayObject*, - NI_ExtendMode, double, maybelong*); -int NI_UniformFilter1D(PyArrayObject*, long, int, PyArrayObject*, - NI_ExtendMode, double, long); -int NI_MinOrMaxFilter1D(PyArrayObject*, long, int, PyArrayObject*, - NI_ExtendMode, double, long, int); -int NI_MinOrMaxFilter(PyArrayObject*, PyArrayObject*, PyArrayObject*, - PyArrayObject*, NI_ExtendMode, double, maybelong*, - int); -int NI_RankFilter(PyArrayObject*, int, PyArrayObject*, PyArrayObject*, - NI_ExtendMode, double, maybelong*); -int NI_GenericFilter1D(PyArrayObject*, int (*)(double*, maybelong, - double*, maybelong, void*), void*, long, int, - PyArrayObject*, NI_ExtendMode, double, long); -int NI_GenericFilter(PyArrayObject*, int (*)(double*, maybelong, double*, - void*), void*, PyArrayObject*, PyArrayObject*, - NI_ExtendMode, double, maybelong*); -#endif +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NI_FILTERS_H +#define NI_FILTERS_H + +int NI_Correlate1D(PyArrayObject*, PyArrayObject*, int, PyArrayObject*, + NI_ExtendMode, double, maybelong); +int NI_Correlate(PyArrayObject*, PyArrayObject*, PyArrayObject*, + NI_ExtendMode, double, maybelong*); +int NI_UniformFilter1D(PyArrayObject*, long, int, PyArrayObject*, + NI_ExtendMode, double, long); +int NI_MinOrMaxFilter1D(PyArrayObject*, long, int, PyArrayObject*, + NI_ExtendMode, double, long, int); +int NI_MinOrMaxFilter(PyArrayObject*, PyArrayObject*, PyArrayObject*, + PyArrayObject*, NI_ExtendMode, double, maybelong*, + int); +int NI_RankFilter(PyArrayObject*, int, PyArrayObject*, PyArrayObject*, + NI_ExtendMode, double, maybelong*); +int NI_GenericFilter1D(PyArrayObject*, int (*)(double*, maybelong, + double*, maybelong, void*), void*, long, int, + PyArrayObject*, NI_ExtendMode, double, long); +int NI_GenericFilter(PyArrayObject*, int (*)(double*, maybelong, double*, + void*), void*, PyArrayObject*, PyArrayObject*, + NI_ExtendMode, double, maybelong*); +#endif Modified: trunk/scipy/ndimage/src/ni_fourier.c =================================================================== --- trunk/scipy/ndimage/src/ni_fourier.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_fourier.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,548 +1,548 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ni_support.h" -#include -#include -#include - -#if !defined(M_PI) -#define M_PI 3.14159265358979323846 -#endif - -#define _NI_GAUSSIAN 0 -#define _NI_UNIFORM 1 -#define _NI_ELLIPSOID 2 - -static double polevl(double x, const double coef[], int N) -{ - double ans; - const double *p = coef; - int i = N; - - ans = *p++; - do - ans = ans * x + *p++; - while(--i); - - return ans ; -} - -double p1evl(double x, const double coef[], int N) -{ - double ans; - const double *p = coef; - int i = N - 1; - - ans = x + *p++; - do - ans = ans * x + *p++; - while(--i); - - return ans; -} - -#define THPIO4 2.35619449019234492885 -#define SQ2OPI .79788456080286535588 -#define Z1 1.46819706421238932572E1 -#define Z2 4.92184563216946036703E1 - -static double _bessel_j1(double x) -{ - double w, z, p, q, xn; - const double RP[4] = { - -8.99971225705559398224E8, - 4.52228297998194034323E11, - -7.27494245221818276015E13, - 3.68295732863852883286E15, - }; - const double RQ[8] = { - 6.20836478118054335476E2, - 2.56987256757748830383E5, - 8.35146791431949253037E7, - 2.21511595479792499675E10, - 4.74914122079991414898E12, - 7.84369607876235854894E14, - 8.95222336184627338078E16, - 5.32278620332680085395E18, - }; - const double PP[7] = { - 7.62125616208173112003E-4, - 7.31397056940917570436E-2, - 1.12719608129684925192E0, - 5.11207951146807644818E0, - 8.42404590141772420927E0, - 5.21451598682361504063E0, - 1.00000000000000000254E0, - }; - const double PQ[7] = { - 5.71323128072548699714E-4, - 6.88455908754495404082E-2, - 1.10514232634061696926E0, - 5.07386386128601488557E0, - 8.39985554327604159757E0, - 5.20982848682361821619E0, - 9.99999999999999997461E-1, - }; - const double QP[8] = { - 5.10862594750176621635E-2, - 4.98213872951233449420E0, - 7.58238284132545283818E1, - 3.66779609360150777800E2, - 7.10856304998926107277E2, - 5.97489612400613639965E2, - 2.11688757100572135698E2, - 2.52070205858023719784E1, - }; - const double QQ[7] = { - 7.42373277035675149943E1, - 1.05644886038262816351E3, - 4.98641058337653607651E3, - 9.56231892404756170795E3, - 7.99704160447350683650E3, - 2.82619278517639096600E3, - 3.36093607810698293419E2, - }; - - w = x; - if (x < 0) - w = -x; - - if (w <= 5.0) { - z = x * x; - w = polevl(z, RP, 3) / p1evl(z, RQ, 8); - w = w * x * (z - Z1) * (z - Z2); - return w ; - } - - w = 5.0 / x; - z = w * w; - p = polevl(z, PP, 6) / polevl(z, PQ, 6); - q = polevl(z, QP, 7) / p1evl(z, QQ, 7); - xn = x - THPIO4; - p = p * cos(xn) - w * q * sin(xn); - return p * SQ2OPI / sqrt(x); -} - -#define CASE_FOURIER_OUT_RR(_po, _tmp, _type) \ -case t ## _type: \ - *(_type*)_po = _tmp; \ - break - -#define CASE_FOURIER_OUT_RC(_po, _tmp, _type) \ -case t ## _type: \ - (*(_type*)_po).real = tmp; \ - (*(_type*)_po).imag = 0.0; \ - break - -#define CASE_FOURIER_OUT_CC(_po, _tmp_r, _tmp_i, _type) \ -case t ## _type: \ - (*(_type*)_po).real = _tmp_r; \ - (*(_type*)_po).imag = _tmp_i; \ - break - -#define CASE_FOURIER_FILTER_RC(_pi, _tmp, _tmp_r, _tmp_i, _type) \ -case t ## _type: \ - _tmp_r = (*(_type*)_pi).real * _tmp; \ - _tmp_i = (*(_type*)_pi).imag * _tmp; \ - break; - -#define CASE_FOURIER_FILTER_RR(_pi, _tmp, _type) \ -case t ## _type: \ - _tmp *= *(_type*)_pi; \ - break; - -int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array, - maybelong n, int axis, PyArrayObject* output, int filter_type) -{ - NI_Iterator ii, io; - char *pi, *po; - double *parameters = NULL, **params = NULL; - maybelong kk, hh, size; - Float64 *iparameters = (void *)PyArray_DATA(parameter_array); - int ll; - - /* precalculate the parameters: */ - parameters = (double*)malloc(input->nd * sizeof(double)); - if (!parameters) { - PyErr_NoMemory(); - goto exit; - } - for(kk = 0; kk < input->nd; kk++) { - /* along the direction of the real transform we must use the given - length of that dimensons, unless a complex transform is assumed - (n < 0): */ - int shape = kk == axis ? - (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk]; - switch (filter_type) { - case _NI_GAUSSIAN: - parameters[kk] = *iparameters++ * M_PI / (double)shape; - parameters[kk] = -2.0 * parameters[kk] * parameters[kk]; - break; - case _NI_ELLIPSOID: - case _NI_UNIFORM: - parameters[kk] = *iparameters++; - break; - } - } - /* allocate memory for tables: */ - params = (double**) malloc(input->nd * sizeof(double*)); - if (!params) { - PyErr_NoMemory(); - goto exit; - } - for(kk = 0; kk < input->nd; kk++) - params[kk] = NULL; - for(kk = 0; kk < input->nd; kk++) { - if (input->dimensions[kk] > 1) { - params[kk] = (double*)malloc(input->dimensions[kk] * sizeof(double)); - if (!params[kk]) { - PyErr_NoMemory(); - goto exit; - } - } - } - switch (filter_type) { - case _NI_GAUSSIAN: - /* calculate the tables of exponentials: */ - for (hh = 0; hh < input->nd; hh++) { - if (params[hh]) { - if (hh == axis && n >= 0) { - for(kk = 0; kk < input->dimensions[hh]; kk++) { - double tmp = parameters[hh] * kk * kk; - params[hh][kk] = fabs(tmp) > 50.0 ? 0.0 : exp(tmp); - } - } else { - int jj = 0; - for(kk = 0; kk < (input->dimensions[hh] + 1) / 2; kk++) { - double tmp = parameters[hh] * kk * kk; - params[hh][jj++] = fabs(tmp) > 50.0 ? 0.0 : exp(tmp); - } - for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) { - double tmp = parameters[hh] * kk * kk; - params[hh][jj++] = fabs(tmp) > 50.0 ? 0.0 : exp(tmp); - } - } - } - } - break; - case _NI_UNIFORM: - /* calculate the tables of parameters: */ - for (hh = 0; hh < input->nd; hh++) { - if (params[hh]) { - params[hh][0] = 1.0; - if (hh == axis && n >= 0) { - double tmp = M_PI * parameters[hh] / n; - for(kk = 1; kk < input->dimensions[hh]; kk++) - params[hh][kk] = tmp > 0.0 ? - sin(tmp * kk) / (tmp * kk) : 0.0; - } else { - double tmp = M_PI * parameters[hh] / input->dimensions[hh]; - int jj = 1; - for(kk = 1; kk < (input->dimensions[hh] + 1) / 2; kk++) - params[hh][jj++] = tmp > 0.0 ? - sin(tmp * kk) / (tmp * kk) : 0.0; - for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) - params[hh][jj++] = tmp > 0.0 ? - sin(tmp * kk) / (tmp * kk) : 0.0; - } - } - } - break; - case _NI_ELLIPSOID: - /* calculate the tables of parameters: */ - for (hh = 0; hh < input->nd; hh++) { - if (params[hh]) { - params[hh][0] = 1.0; - if (hh == axis && n >= 0) { - double tmp = M_PI * parameters[hh] / n; - for(kk = 0; kk < input->dimensions[hh]; kk++) - params[hh][kk] = (double)kk * tmp; - } else { - double tmp = M_PI * parameters[hh] / input->dimensions[hh]; - int jj = 0; - for(kk = 0; kk < (input->dimensions[hh] + 1) / 2; kk++) - params[hh][jj++] = (double)kk * tmp; - for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) - params[hh][jj++] = (double)kk * tmp; - } - } else if (input->dimensions[hh] > 0) { - params[hh][0] = 1.0; - } - } - if (input->nd > 1) - for(hh = 0; hh < input->nd; hh++) - for(kk = 0; kk < input->dimensions[hh]; kk++) - params[hh][kk] = params[hh][kk] * params[hh][kk]; - break; - default: - break; - } - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* iterator over the elements: */ - for(hh = 0; hh < size; hh++) { - double tmp = 1.0; - switch (filter_type) { - case _NI_GAUSSIAN: - case _NI_UNIFORM: - for(kk = 0; kk < input->nd; kk++) - if (params[kk]) - tmp *= params[kk][ii.coordinates[kk]]; - break; - case _NI_ELLIPSOID: - switch (input->nd) { - case 1: - tmp = params[0][ii.coordinates[0]]; - tmp = tmp > 0.0 ? sin(tmp) / (tmp) : 1.0; - break; - case 2: - tmp = 0.0; - for(kk = 0; kk < 2; kk++) - tmp += params[kk][ii.coordinates[kk]]; - tmp = sqrt(tmp); - tmp = tmp > 0.0 ? 2.0 * _bessel_j1(tmp) / tmp : 1.0; - break; - case 3: - { - double r = 0.0; - for(kk = 0; kk < 3; kk++) - r += params[kk][ii.coordinates[kk]]; - r = sqrt(r); - if (r > 0.0) { - tmp = 3.0 * (sin(r) - r * cos(r)); - tmp /= r * r * r; - } else { - tmp = 1.0; - } - } - break; - } - break; - default: - break; - } - if (input->descr->type_num == tComplex64 || - input->descr->type_num == tComplex128) { - double tmp_r = 0.0, tmp_i = 0.0; - switch (input->descr->type_num) { - CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex64); - CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex128); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex64); - CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex128); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - } else { - switch (input->descr->type_num) { - CASE_FOURIER_FILTER_RR(pi, tmp, Bool) - CASE_FOURIER_FILTER_RR(pi, tmp, UInt8) - CASE_FOURIER_FILTER_RR(pi, tmp, UInt16) - CASE_FOURIER_FILTER_RR(pi, tmp, UInt32) -#if HAS_UINT64 - CASE_FOURIER_FILTER_RR(pi, tmp, UInt64) -#endif - CASE_FOURIER_FILTER_RR(pi, tmp, Int8) - CASE_FOURIER_FILTER_RR(pi, tmp, Int16) - CASE_FOURIER_FILTER_RR(pi, tmp, Int32) - CASE_FOURIER_FILTER_RR(pi, tmp, Int64) - CASE_FOURIER_FILTER_RR(pi, tmp, Float32) - CASE_FOURIER_FILTER_RR(pi, tmp, Float64) - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FOURIER_OUT_RR(po, tmp, Float32); - CASE_FOURIER_OUT_RR(po, tmp, Float64); - CASE_FOURIER_OUT_RC(po, tmp, Complex64); - CASE_FOURIER_OUT_RC(po, tmp, Complex128); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - } - NI_ITERATOR_NEXT2(ii, io, pi, po); - } - - exit: - if (parameters) free(parameters); - if (params) { - for(kk = 0; kk < input->nd; kk++) - if (params[kk]) free(params[kk]); - free(params); - } - return PyErr_Occurred() ? 0 : 1; -} - -#define CASE_FOURIER_SHIFT_R(_pi, _tmp, _r, _i, _cost, _sint, _type) \ -case t ## _type: \ - _tmp = *(_type*)_pi; \ - _r = _tmp * _cost; \ - _i = _tmp * _sint; \ - break; - -#define CASE_FOURIER_SHIFT_C(_pi, _r, _i, _cost, _sint, _type) \ -case t ## _type: \ - _r = (*(_type*)_pi).real * _cost - (*(_type*)_pi).imag * _sint; \ - _i = (*(_type*)_pi).real * _sint + (*(_type*)_pi).imag * _cost; \ - break; - -int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array, - maybelong n, int axis, PyArrayObject* output) -{ - NI_Iterator ii, io; - char *pi, *po; - double *shifts = NULL, **params = NULL; - maybelong kk, hh, size; - Float64 *ishifts = (void *)PyArray_DATA(shift_array); - int ll; - - /* precalculate the shifts: */ - shifts = (double*)malloc(input->nd * sizeof(double)); - if (!shifts) { - PyErr_NoMemory(); - goto exit; - } - for(kk = 0; kk < input->nd; kk++) { - /* along the direction of the real transform we must use the given - length of that dimensons, unless a complex transform is assumed - (n < 0): */ - int shape = kk == axis ? - (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk]; - shifts[kk] = -2.0 * M_PI * *ishifts++ / (double)shape; - } - /* allocate memory for tables: */ - params = (double**) malloc(input->nd * sizeof(double*)); - if (!params) { - PyErr_NoMemory(); - goto exit; - } - for(kk = 0; kk < input->nd; kk++) - params[kk] = NULL; - for(kk = 0; kk < input->nd; kk++) { - if (input->dimensions[kk] > 1) { - params[kk] = (double*)malloc(input->dimensions[kk] * sizeof(double)); - if (!params[kk]) { - PyErr_NoMemory(); - goto exit; - } - } - } - for (hh = 0; hh < input->nd; hh++) { - if (params[hh]) { - if (hh == axis && n >= 0) { - for(kk = 0; kk < input->dimensions[hh]; kk++) - params[hh][kk] = shifts[hh] * kk; - } else { - int jj = 0; - for(kk = 0; kk < (input->dimensions[hh] + 1) / 2; kk++) { - params[hh][jj++] = shifts[hh] * kk; - } - for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) { - params[hh][jj++] = shifts[hh] * kk; - } - } - } - } - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* iterator over the elements: */ - for(hh = 0; hh < size; hh++) { - double tmp = 0.0, sint, cost, r = 0.0, i = 0.0; - for(kk = 0; kk < input->nd; kk++) - if (params[kk]) - tmp += params[kk][ii.coordinates[kk]]; - sint = sin(tmp); - cost = cos(tmp); - switch (input->descr->type_num) { - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Bool) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt8) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt16) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt32) -#if HAS_UINT64 - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt64) -#endif - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int8) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int16) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int32) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int64) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float32) - CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float64) - CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex64) - CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex128) - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_FOURIER_OUT_CC(po, r, i, Complex64); - CASE_FOURIER_OUT_CC(po, r, i, Complex128); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - NI_ITERATOR_NEXT2(ii, io, pi, po); - } - - exit: - if (shifts) free(shifts); - if (params) { - for(kk = 0; kk < input->nd; kk++) - if (params[kk]) free(params[kk]); - free(params); - } - return PyErr_Occurred() ? 0 : 1; -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ni_support.h" +#include +#include +#include + +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 +#endif + +#define _NI_GAUSSIAN 0 +#define _NI_UNIFORM 1 +#define _NI_ELLIPSOID 2 + +static double polevl(double x, const double coef[], int N) +{ + double ans; + const double *p = coef; + int i = N; + + ans = *p++; + do + ans = ans * x + *p++; + while(--i); + + return ans ; +} + +double p1evl(double x, const double coef[], int N) +{ + double ans; + const double *p = coef; + int i = N - 1; + + ans = x + *p++; + do + ans = ans * x + *p++; + while(--i); + + return ans; +} + +#define THPIO4 2.35619449019234492885 +#define SQ2OPI .79788456080286535588 +#define Z1 1.46819706421238932572E1 +#define Z2 4.92184563216946036703E1 + +static double _bessel_j1(double x) +{ + double w, z, p, q, xn; + const double RP[4] = { + -8.99971225705559398224E8, + 4.52228297998194034323E11, + -7.27494245221818276015E13, + 3.68295732863852883286E15, + }; + const double RQ[8] = { + 6.20836478118054335476E2, + 2.56987256757748830383E5, + 8.35146791431949253037E7, + 2.21511595479792499675E10, + 4.74914122079991414898E12, + 7.84369607876235854894E14, + 8.95222336184627338078E16, + 5.32278620332680085395E18, + }; + const double PP[7] = { + 7.62125616208173112003E-4, + 7.31397056940917570436E-2, + 1.12719608129684925192E0, + 5.11207951146807644818E0, + 8.42404590141772420927E0, + 5.21451598682361504063E0, + 1.00000000000000000254E0, + }; + const double PQ[7] = { + 5.71323128072548699714E-4, + 6.88455908754495404082E-2, + 1.10514232634061696926E0, + 5.07386386128601488557E0, + 8.39985554327604159757E0, + 5.20982848682361821619E0, + 9.99999999999999997461E-1, + }; + const double QP[8] = { + 5.10862594750176621635E-2, + 4.98213872951233449420E0, + 7.58238284132545283818E1, + 3.66779609360150777800E2, + 7.10856304998926107277E2, + 5.97489612400613639965E2, + 2.11688757100572135698E2, + 2.52070205858023719784E1, + }; + const double QQ[7] = { + 7.42373277035675149943E1, + 1.05644886038262816351E3, + 4.98641058337653607651E3, + 9.56231892404756170795E3, + 7.99704160447350683650E3, + 2.82619278517639096600E3, + 3.36093607810698293419E2, + }; + + w = x; + if (x < 0) + w = -x; + + if (w <= 5.0) { + z = x * x; + w = polevl(z, RP, 3) / p1evl(z, RQ, 8); + w = w * x * (z - Z1) * (z - Z2); + return w ; + } + + w = 5.0 / x; + z = w * w; + p = polevl(z, PP, 6) / polevl(z, PQ, 6); + q = polevl(z, QP, 7) / p1evl(z, QQ, 7); + xn = x - THPIO4; + p = p * cos(xn) - w * q * sin(xn); + return p * SQ2OPI / sqrt(x); +} + +#define CASE_FOURIER_OUT_RR(_po, _tmp, _type) \ +case t ## _type: \ + *(_type*)_po = _tmp; \ + break + +#define CASE_FOURIER_OUT_RC(_po, _tmp, _type) \ +case t ## _type: \ + (*(_type*)_po).real = tmp; \ + (*(_type*)_po).imag = 0.0; \ + break + +#define CASE_FOURIER_OUT_CC(_po, _tmp_r, _tmp_i, _type) \ +case t ## _type: \ + (*(_type*)_po).real = _tmp_r; \ + (*(_type*)_po).imag = _tmp_i; \ + break + +#define CASE_FOURIER_FILTER_RC(_pi, _tmp, _tmp_r, _tmp_i, _type) \ +case t ## _type: \ + _tmp_r = (*(_type*)_pi).real * _tmp; \ + _tmp_i = (*(_type*)_pi).imag * _tmp; \ + break; + +#define CASE_FOURIER_FILTER_RR(_pi, _tmp, _type) \ +case t ## _type: \ + _tmp *= *(_type*)_pi; \ + break; + +int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array, + maybelong n, int axis, PyArrayObject* output, int filter_type) +{ + NI_Iterator ii, io; + char *pi, *po; + double *parameters = NULL, **params = NULL; + maybelong kk, hh, size; + Float64 *iparameters = (void *)PyArray_DATA(parameter_array); + int ll; + + /* precalculate the parameters: */ + parameters = (double*)malloc(input->nd * sizeof(double)); + if (!parameters) { + PyErr_NoMemory(); + goto exit; + } + for(kk = 0; kk < input->nd; kk++) { + /* along the direction of the real transform we must use the given + length of that dimensons, unless a complex transform is assumed + (n < 0): */ + int shape = kk == axis ? + (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk]; + switch (filter_type) { + case _NI_GAUSSIAN: + parameters[kk] = *iparameters++ * M_PI / (double)shape; + parameters[kk] = -2.0 * parameters[kk] * parameters[kk]; + break; + case _NI_ELLIPSOID: + case _NI_UNIFORM: + parameters[kk] = *iparameters++; + break; + } + } + /* allocate memory for tables: */ + params = (double**) malloc(input->nd * sizeof(double*)); + if (!params) { + PyErr_NoMemory(); + goto exit; + } + for(kk = 0; kk < input->nd; kk++) + params[kk] = NULL; + for(kk = 0; kk < input->nd; kk++) { + if (input->dimensions[kk] > 1) { + params[kk] = (double*)malloc(input->dimensions[kk] * sizeof(double)); + if (!params[kk]) { + PyErr_NoMemory(); + goto exit; + } + } + } + switch (filter_type) { + case _NI_GAUSSIAN: + /* calculate the tables of exponentials: */ + for (hh = 0; hh < input->nd; hh++) { + if (params[hh]) { + if (hh == axis && n >= 0) { + for(kk = 0; kk < input->dimensions[hh]; kk++) { + double tmp = parameters[hh] * kk * kk; + params[hh][kk] = fabs(tmp) > 50.0 ? 0.0 : exp(tmp); + } + } else { + int jj = 0; + for(kk = 0; kk < (input->dimensions[hh] + 1) / 2; kk++) { + double tmp = parameters[hh] * kk * kk; + params[hh][jj++] = fabs(tmp) > 50.0 ? 0.0 : exp(tmp); + } + for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) { + double tmp = parameters[hh] * kk * kk; + params[hh][jj++] = fabs(tmp) > 50.0 ? 0.0 : exp(tmp); + } + } + } + } + break; + case _NI_UNIFORM: + /* calculate the tables of parameters: */ + for (hh = 0; hh < input->nd; hh++) { + if (params[hh]) { + params[hh][0] = 1.0; + if (hh == axis && n >= 0) { + double tmp = M_PI * parameters[hh] / n; + for(kk = 1; kk < input->dimensions[hh]; kk++) + params[hh][kk] = tmp > 0.0 ? + sin(tmp * kk) / (tmp * kk) : 0.0; + } else { + double tmp = M_PI * parameters[hh] / input->dimensions[hh]; + int jj = 1; + for(kk = 1; kk < (input->dimensions[hh] + 1) / 2; kk++) + params[hh][jj++] = tmp > 0.0 ? + sin(tmp * kk) / (tmp * kk) : 0.0; + for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) + params[hh][jj++] = tmp > 0.0 ? + sin(tmp * kk) / (tmp * kk) : 0.0; + } + } + } + break; + case _NI_ELLIPSOID: + /* calculate the tables of parameters: */ + for (hh = 0; hh < input->nd; hh++) { + if (params[hh]) { + params[hh][0] = 1.0; + if (hh == axis && n >= 0) { + double tmp = M_PI * parameters[hh] / n; + for(kk = 0; kk < input->dimensions[hh]; kk++) + params[hh][kk] = (double)kk * tmp; + } else { + double tmp = M_PI * parameters[hh] / input->dimensions[hh]; + int jj = 0; + for(kk = 0; kk < (input->dimensions[hh] + 1) / 2; kk++) + params[hh][jj++] = (double)kk * tmp; + for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) + params[hh][jj++] = (double)kk * tmp; + } + } else if (input->dimensions[hh] > 0) { + params[hh][0] = 1.0; + } + } + if (input->nd > 1) + for(hh = 0; hh < input->nd; hh++) + for(kk = 0; kk < input->dimensions[hh]; kk++) + params[hh][kk] = params[hh][kk] * params[hh][kk]; + break; + default: + break; + } + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* iterator over the elements: */ + for(hh = 0; hh < size; hh++) { + double tmp = 1.0; + switch (filter_type) { + case _NI_GAUSSIAN: + case _NI_UNIFORM: + for(kk = 0; kk < input->nd; kk++) + if (params[kk]) + tmp *= params[kk][ii.coordinates[kk]]; + break; + case _NI_ELLIPSOID: + switch (input->nd) { + case 1: + tmp = params[0][ii.coordinates[0]]; + tmp = tmp > 0.0 ? sin(tmp) / (tmp) : 1.0; + break; + case 2: + tmp = 0.0; + for(kk = 0; kk < 2; kk++) + tmp += params[kk][ii.coordinates[kk]]; + tmp = sqrt(tmp); + tmp = tmp > 0.0 ? 2.0 * _bessel_j1(tmp) / tmp : 1.0; + break; + case 3: + { + double r = 0.0; + for(kk = 0; kk < 3; kk++) + r += params[kk][ii.coordinates[kk]]; + r = sqrt(r); + if (r > 0.0) { + tmp = 3.0 * (sin(r) - r * cos(r)); + tmp /= r * r * r; + } else { + tmp = 1.0; + } + } + break; + } + break; + default: + break; + } + if (input->descr->type_num == tComplex64 || + input->descr->type_num == tComplex128) { + double tmp_r = 0.0, tmp_i = 0.0; + switch (input->descr->type_num) { + CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex64); + CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex128); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex64); + CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex128); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + } else { + switch (input->descr->type_num) { + CASE_FOURIER_FILTER_RR(pi, tmp, Bool) + CASE_FOURIER_FILTER_RR(pi, tmp, UInt8) + CASE_FOURIER_FILTER_RR(pi, tmp, UInt16) + CASE_FOURIER_FILTER_RR(pi, tmp, UInt32) +#if HAS_UINT64 + CASE_FOURIER_FILTER_RR(pi, tmp, UInt64) +#endif + CASE_FOURIER_FILTER_RR(pi, tmp, Int8) + CASE_FOURIER_FILTER_RR(pi, tmp, Int16) + CASE_FOURIER_FILTER_RR(pi, tmp, Int32) + CASE_FOURIER_FILTER_RR(pi, tmp, Int64) + CASE_FOURIER_FILTER_RR(pi, tmp, Float32) + CASE_FOURIER_FILTER_RR(pi, tmp, Float64) + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FOURIER_OUT_RR(po, tmp, Float32); + CASE_FOURIER_OUT_RR(po, tmp, Float64); + CASE_FOURIER_OUT_RC(po, tmp, Complex64); + CASE_FOURIER_OUT_RC(po, tmp, Complex128); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + } + NI_ITERATOR_NEXT2(ii, io, pi, po); + } + + exit: + if (parameters) free(parameters); + if (params) { + for(kk = 0; kk < input->nd; kk++) + if (params[kk]) free(params[kk]); + free(params); + } + return PyErr_Occurred() ? 0 : 1; +} + +#define CASE_FOURIER_SHIFT_R(_pi, _tmp, _r, _i, _cost, _sint, _type) \ +case t ## _type: \ + _tmp = *(_type*)_pi; \ + _r = _tmp * _cost; \ + _i = _tmp * _sint; \ + break; + +#define CASE_FOURIER_SHIFT_C(_pi, _r, _i, _cost, _sint, _type) \ +case t ## _type: \ + _r = (*(_type*)_pi).real * _cost - (*(_type*)_pi).imag * _sint; \ + _i = (*(_type*)_pi).real * _sint + (*(_type*)_pi).imag * _cost; \ + break; + +int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array, + maybelong n, int axis, PyArrayObject* output) +{ + NI_Iterator ii, io; + char *pi, *po; + double *shifts = NULL, **params = NULL; + maybelong kk, hh, size; + Float64 *ishifts = (void *)PyArray_DATA(shift_array); + int ll; + + /* precalculate the shifts: */ + shifts = (double*)malloc(input->nd * sizeof(double)); + if (!shifts) { + PyErr_NoMemory(); + goto exit; + } + for(kk = 0; kk < input->nd; kk++) { + /* along the direction of the real transform we must use the given + length of that dimensons, unless a complex transform is assumed + (n < 0): */ + int shape = kk == axis ? + (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk]; + shifts[kk] = -2.0 * M_PI * *ishifts++ / (double)shape; + } + /* allocate memory for tables: */ + params = (double**) malloc(input->nd * sizeof(double*)); + if (!params) { + PyErr_NoMemory(); + goto exit; + } + for(kk = 0; kk < input->nd; kk++) + params[kk] = NULL; + for(kk = 0; kk < input->nd; kk++) { + if (input->dimensions[kk] > 1) { + params[kk] = (double*)malloc(input->dimensions[kk] * sizeof(double)); + if (!params[kk]) { + PyErr_NoMemory(); + goto exit; + } + } + } + for (hh = 0; hh < input->nd; hh++) { + if (params[hh]) { + if (hh == axis && n >= 0) { + for(kk = 0; kk < input->dimensions[hh]; kk++) + params[hh][kk] = shifts[hh] * kk; + } else { + int jj = 0; + for(kk = 0; kk < (input->dimensions[hh] + 1) / 2; kk++) { + params[hh][jj++] = shifts[hh] * kk; + } + for(kk = -(input->dimensions[hh] / 2); kk < 0; kk++) { + params[hh][jj++] = shifts[hh] * kk; + } + } + } + } + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* iterator over the elements: */ + for(hh = 0; hh < size; hh++) { + double tmp = 0.0, sint, cost, r = 0.0, i = 0.0; + for(kk = 0; kk < input->nd; kk++) + if (params[kk]) + tmp += params[kk][ii.coordinates[kk]]; + sint = sin(tmp); + cost = cos(tmp); + switch (input->descr->type_num) { + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Bool) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt8) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt16) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt32) +#if HAS_UINT64 + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, UInt64) +#endif + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int8) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int16) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int32) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int64) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float32) + CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float64) + CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex64) + CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex128) + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_FOURIER_OUT_CC(po, r, i, Complex64); + CASE_FOURIER_OUT_CC(po, r, i, Complex128); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + NI_ITERATOR_NEXT2(ii, io, pi, po); + } + + exit: + if (shifts) free(shifts); + if (params) { + for(kk = 0; kk < input->nd; kk++) + if (params[kk]) free(params[kk]); + free(params); + } + return PyErr_Occurred() ? 0 : 1; +} Modified: trunk/scipy/ndimage/src/ni_fourier.h =================================================================== --- trunk/scipy/ndimage/src/ni_fourier.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_fourier.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,40 +1,40 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NI_FOURIER_H -#define NI_FOURIER_H - -int NI_FourierFilter(PyArrayObject*, PyArrayObject*, maybelong, int, - PyArrayObject*, int); -int NI_FourierShift(PyArrayObject*, PyArrayObject*, maybelong, int, - PyArrayObject*); - -#endif +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NI_FOURIER_H +#define NI_FOURIER_H + +int NI_FourierFilter(PyArrayObject*, PyArrayObject*, maybelong, int, + PyArrayObject*, int); +int NI_FourierShift(PyArrayObject*, PyArrayObject*, maybelong, int, + PyArrayObject*); + +#endif Modified: trunk/scipy/ndimage/src/ni_interpolation.c =================================================================== --- trunk/scipy/ndimage/src/ni_interpolation.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_interpolation.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,966 +1,966 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ni_support.h" -#include "ni_interpolation.h" -#include -#include - -/* calculate the B-spline interpolation coefficients for given x: */ -static void -spline_coefficients(double x, int order, double *result) -{ - int hh; - double y, start; - - if (order & 1) { - start = (int)floor(x) - order / 2; - } else { - start = (int)floor(x + 0.5) - order / 2; - } - - for(hh = 0; hh <= order; hh++) { - y = fabs(start - x + hh); - - switch(order) { - case 1: - result[hh] = y > 1.0 ? 0.0 : 1.0 - y; - break; - case 2: - if (y < 0.5) { - result[hh] = 0.75 - y * y; - } else if (y < 1.5) { - y = 1.5 - y; - result[hh] = 0.5 * y * y; - } else { - result[hh] = 0.0; - } - break; - case 3: - if (y < 1.0) { - result[hh] = - (y * y * (y - 2.0) * 3.0 + 4.0) / 6.0; - } else if (y < 2.0) { - y = 2.0 - y; - result[hh] = y * y * y / 6.0; - } else { - result[hh] = 0.0; - } - break; - case 4: - if (y < 0.5) { - y *= y; - result[hh] = y * (y * 0.25 - 0.625) + 115.0 / 192.0; - } else if (y < 1.5) { - result[hh] = y * (y * (y * (5.0 / 6.0 - y / 6.0) - 1.25) + - 5.0 / 24.0) + 55.0 / 96.0; - } else if (y < 2.5) { - y -= 2.5; - y *= y; - result[hh] = y * y / 24.0; - } else { - result[hh] = 0.0; - } - break; - case 5: - if (y < 1.0) { - double f = y * y; - result[hh] = - f * (f * (0.25 - y / 12.0) - 0.5) + 0.55; - } else if (y < 2.0) { - result[hh] = y * (y * (y * (y * (y / 24.0 - 0.375) - + 1.25) - 1.75) + 0.625) + 0.425; - } else if (y < 3.0) { - double f = 3.0 - y; - y = f * f; - result[hh] = f * y * y / 120.0; - } else { - result[hh] = 0.0; - } - break; - } - } -} - -/* map a coordinate outside the borders, according to the requested - boundary condition: */ -static double -map_coordinate(double in, maybelong len, int mode) -{ - if (in < 0) { - switch (mode) { - case NI_EXTEND_MIRROR: - if (len <= 1) { - in = 0; - } else { - maybelong sz2 = 2 * len - 2; - in = sz2 * (maybelong)(-in / sz2) + in; - in = in <= 1 - len ? in + sz2 : -in; - } - break; - case NI_EXTEND_REFLECT: - if (len <= 1) { - in = 0; - } else { - maybelong sz2 = 2 * len; - if (in < -sz2) - in = sz2 * (maybelong)(-in / sz2) + in; - in = in < -len ? in + sz2 : -in - 1; - } - break; - case NI_EXTEND_WRAP: - if (len <= 1) { - in = 0; - } else { - maybelong sz = len - 1; - // Integer division of -in/sz gives (-in mod sz) - // Note that 'in' is negative - in += sz * ((maybelong)(-in / sz) + 1); - } - break; - case NI_EXTEND_NEAREST: - in = 0; - break; - case NI_EXTEND_CONSTANT: - in = -1; - break; - } - } else if (in > len-1) { - switch (mode) { - case NI_EXTEND_MIRROR: - if (len <= 1) { - in = 0; - } else { - maybelong sz2 = 2 * len - 2; - in -= sz2 * (maybelong)(in / sz2); - if (in >= len) - in = sz2 - in; - } - break; - case NI_EXTEND_REFLECT: - if (len <= 1) { - in = 0; - } else { - maybelong sz2 = 2 * len; - in -= sz2 * (maybelong)(in / sz2); - if (in >= len) - in = sz2 - in - 1; - } - break; - case NI_EXTEND_WRAP: - if (len <= 1) { - in = 0; - } else { - maybelong sz = len - 1; - in -= sz * (maybelong)(in / sz); - } - break; - case NI_EXTEND_NEAREST: - in = len - 1; - break; - case NI_EXTEND_CONSTANT: - in = -1; - break; - } - } - - return in; -} - -#define BUFFER_SIZE 256000 -#define TOLERANCE 1e-15 - -/* one-dimensional spline filter: */ -int NI_SplineFilter1D(PyArrayObject *input, int order, int axis, - PyArrayObject *output) -{ - int hh, npoles = 0, more; - maybelong kk, ll, lines, len; - double *buffer = NULL, weight, pole[2]; - NI_LineBuffer iline_buffer, oline_buffer; - - len = input->nd > 0 ? input->dimensions[axis] : 1; - if (len < 1) - goto exit; - - /* these are used in the spline filter calculation below: */ - switch (order) { - case 2: - npoles = 1; - pole[0] = sqrt(8.0) - 3.0; - break; - case 3: - npoles = 1; - pole[0] = sqrt(3.0) - 2.0; - break; - case 4: - npoles = 2; - pole[0] = sqrt(664.0 - sqrt(438976.0)) + sqrt(304.0) - 19.0; - pole[1] = sqrt(664.0 + sqrt(438976.0)) - sqrt(304.0) - 19.0; - break; - case 5: - npoles = 2; - pole[0] = sqrt(67.5 - sqrt(4436.25)) + sqrt(26.25) - 6.5; - pole[1] = sqrt(67.5 + sqrt(4436.25)) - sqrt(26.25) - 6.5; - break; - default: - break; - } - - weight = 1.0; - for(hh = 0; hh < npoles; hh++) - weight *= (1.0 - pole[hh]) * (1.0 - 1.0 / pole[hh]); - - /* allocate an initialize the line buffer, only a single one is used, - because the calculation is in-place: */ - lines = -1; - if (!NI_AllocateLineBuffer(input, axis, 0, 0, &lines, BUFFER_SIZE, - &buffer)) - goto exit; - if (!NI_InitLineBuffer(input, axis, 0, 0, lines, buffer, - NI_EXTEND_DEFAULT, 0.0, &iline_buffer)) - goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, buffer, - NI_EXTEND_DEFAULT, 0.0, &oline_buffer)) - goto exit; - - /* iterate over all the array lines: */ - do { - /* copy lines from array to buffer: */ - if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) - goto exit; - /* iterate over the lines in the buffer: */ - for(kk = 0; kk < lines; kk++) { - /* get line: */ - double *ln = NI_GET_LINE(iline_buffer, kk); - /* spline filter: */ - if (len > 1) { - for(ll = 0; ll < len; ll++) - ln[ll] *= weight; - for(hh = 0; hh < npoles; hh++) { - double p = pole[hh]; - int max = (int)ceil(log(TOLERANCE) / log(fabs(p))); - if (max < len) { - double zn = p; - double sum = ln[0]; - for(ll = 1; ll < max; ll++) { - sum += zn * ln[ll]; - zn *= p; - } - ln[0] = sum; - } else { - double zn = p; - double iz = 1.0 / p; - double z2n = pow(p, (double)(len - 1)); - double sum = ln[0] + z2n * ln[len - 1]; - z2n *= z2n * iz; - for(ll = 1; ll <= len - 2; ll++) { - sum += (zn + z2n) * ln[ll]; - zn *= p; - z2n *= iz; - } - ln[0] = sum / (1.0 - zn * zn); - } - for(ll = 1; ll < len; ll++) - ln[ll] += p * ln[ll - 1]; - ln[len-1] = (p / (p * p - 1.0)) * (ln[len-1] + p * ln[len-2]); - for(ll = len - 2; ll >= 0; ll--) - ln[ll] = p * (ln[ll + 1] - ln[ll]); - } - } - } - /* copy lines from buffer to array: */ - if (!NI_LineBufferToArray(&oline_buffer)) - goto exit; - } while(more); - - exit: - if (buffer) free(buffer); - return PyErr_Occurred() ? 0 : 1; -} - -#define CASE_MAP_COORDINATES(_p, _coor, _rank, _stride, _type) \ -case t ## _type: \ -{ \ - int _hh; \ - for(_hh = 0; _hh < _rank; _hh++) { \ - _coor[_hh] = *(_type*)_p; \ - _p += _stride; \ - } \ -} \ -break; - -#define CASE_INTERP_COEFF(_coeff, _pi, _idx, _type) \ -case t ## _type: \ - _coeff = *(_type*)(_pi + _idx); \ - break; - -#define CASE_INTERP_OUT(_po, _t, _type) \ -case t ## _type: \ - *(_type*)_po = (_type)_t; \ - break; - -#define CASE_INTERP_OUT_UINT(_po, _t, _type, type_min, type_max) \ -case t ## _type: \ - _t = _t > 0 ? _t + 0.5 : 0; \ - _t = _t > type_max ? type_max : t; \ - _t = _t < type_min ? type_min : t; \ - *(_type*)_po = (_type)_t; \ - break; - -#define CASE_INTERP_OUT_INT(_po, _t, _type, type_min, type_max) \ -case t ## _type: \ - _t = _t > 0 ? _t + 0.5 : _t - 0.5; \ - _t = _t > type_max ? type_max : t; \ - _t = _t < type_min ? type_min : t; \ - *(_type*)_po = (_type)_t; \ - break; - -int -NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*, - int, int, void*), void* map_data, PyArrayObject* matrix_ar, - PyArrayObject* shift_ar, PyArrayObject *coordinates, - PyArrayObject *output, int order, int mode, double cval) -{ - char *po, *pi, *pc = NULL; - maybelong **edge_offsets = NULL, **data_offsets = NULL, filter_size; - maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL; - maybelong cstride = 0, kk, hh, ll, jj, *idxs = NULL; - maybelong size; - double **splvals = NULL, icoor[MAXDIM]; - double idimensions[MAXDIM], istrides[MAXDIM]; - NI_Iterator io, ic; - Float64 *matrix = matrix_ar ? (Float64*)PyArray_DATA(matrix_ar) : NULL; - Float64 *shift = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; - int irank = 0, orank, qq; - - for(kk = 0; kk < input->nd; kk++) { - idimensions[kk] = input->dimensions[kk]; - istrides[kk] = input->strides[kk]; - } - irank = input->nd; - orank = output->nd; - - /* if the mapping is from array coordinates: */ - if (coordinates) { - /* initialze a line iterator along the first axis: */ - if (!NI_InitPointIterator(coordinates, &ic)) - goto exit; - cstride = ic.strides[0]; - if (!NI_LineIterator(&ic, 0)) - goto exit; - pc = (void *)(PyArray_DATA(coordinates)); - } - - /* offsets used at the borders: */ - edge_offsets = (maybelong**)malloc(irank * sizeof(maybelong*)); - data_offsets = (maybelong**)malloc(irank * sizeof(maybelong*)); - if (!edge_offsets || !data_offsets) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < irank; jj++) - data_offsets[jj] = NULL; - for(jj = 0; jj < irank; jj++) { - data_offsets[jj] = (maybelong*)malloc((order + 1) * sizeof(maybelong)); - if (!data_offsets[jj]) { - PyErr_NoMemory(); - goto exit; - } - } - /* will hold the spline coefficients: */ - splvals = (double**)malloc(irank * sizeof(double*)); - if (!splvals) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < irank; jj++) - splvals[jj] = NULL; - for(jj = 0; jj < irank; jj++) { - splvals[jj] = (double*)malloc((order + 1) * sizeof(double)); - if (!splvals[jj]) { - PyErr_NoMemory(); - goto exit; - } - } - - filter_size = 1; - for(jj = 0; jj < irank; jj++) - filter_size *= order + 1; - idxs = (maybelong*)malloc(filter_size * sizeof(idxs)); - if (!idxs) { - PyErr_NoMemory(); - goto exit; - } - - /* initialize output iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - - /* get data pointers: */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - - /* make a table of all possible coordinates within the spline filter: */ - fcoordinates = (maybelong*)malloc(irank * filter_size * sizeof(maybelong)); - /* make a table of all offsets within the spline filter: */ - foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong)); - if (!fcoordinates || !foffsets) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < irank; jj++) - ftmp[jj] = 0; - kk = 0; - for(hh = 0; hh < filter_size; hh++) { - for(jj = 0; jj < irank; jj++) - fcoordinates[jj + hh * irank] = ftmp[jj]; - foffsets[hh] = kk; - for(jj = irank - 1; jj >= 0; jj--) { - if (ftmp[jj] < order) { - ftmp[jj]++; - kk += istrides[jj]; - break; - } else { - ftmp[jj] = 0; - kk -= istrides[jj] * order; - } - } - } - - size = 1; - for(qq = 0; qq < output->nd; qq++) - size *= output->dimensions[qq]; - for(kk = 0; kk < size; kk++) { - double t = 0.0; - int constant = 0, edge = 0, offset = 0; - if (map) { - /* call mappint functions: */ - if (!map(io.coordinates, icoor, orank, irank, map_data)) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, - "unknown error in mapping function"); - goto exit; - } - } else if (matrix) { - /* do an affine transformation: */ - Float64 *p = matrix; - for(hh = 0; hh < irank; hh++) { - icoor[hh] = 0.0; - for(ll = 0; ll < orank; ll++) - icoor[hh] += io.coordinates[ll] * *p++; - icoor[hh] += shift[hh]; - } - } else if (coordinates) { - /* mapping is from an coordinates array: */ - char *p = pc; - switch(coordinates->descr->type_num) { - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Bool); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt8); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt16); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt32); -#if HAS_UINT64 - CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt64); -#endif - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int8); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int16); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int32); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int64); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float32); - CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, - "coordinate array data type not supported"); - goto exit; - } - } - /* iterate over axes: */ - for(hh = 0; hh < irank; hh++) { - /* if the input coordinate is outside the borders, map it: */ - double cc = map_coordinate(icoor[hh], idimensions[hh], mode); - if (cc > -1.0) { - /* find the filter location along this axis: */ - int start; - if (order & 1) { - start = (int)floor(cc) - order / 2; - } else { - start = (int)floor(cc + 0.5) - order / 2; - } - /* get the offset to the start of the filter: */ - offset += istrides[hh] * start; - if (start < 0 || start + order >= idimensions[hh]) { - /* implement border mapping, if outside border: */ - edge = 1; - edge_offsets[hh] = data_offsets[hh]; - for(ll = 0; ll <= order; ll++) { - int idx = start + ll; - int len = idimensions[hh]; - if (len <= 1) { - idx = 0; - } else { - int s2 = 2 * len - 2; - if (idx < 0) { - idx = s2 * (int)(-idx / s2) + idx; - idx = idx <= 1 - len ? idx + s2 : -idx; - } else if (idx >= len) { - idx -= s2 * (int)(idx / s2); - if (idx >= len) - idx = s2 - idx; - } - } - /* calculate and store the offests at this edge: */ - edge_offsets[hh][ll] = istrides[hh] * (idx - start); - } - } else { - /* we are not at the border, use precalculated offsets: */ - edge_offsets[hh] = NULL; - } - spline_coefficients(cc, order, splvals[hh]); - } else { - /* we use the constant border condition: */ - constant = 1; - break; - } - } - - if (!constant) { - maybelong *ff = fcoordinates; - for(hh = 0; hh < filter_size; hh++) { - int idx = 0; - if (edge) { - for(ll = 0; ll < irank; ll++) { - if (edge_offsets[ll]) - idx += edge_offsets[ll][ff[ll]]; - else - idx += ff[ll] * istrides[ll]; - } - } else { - idx = foffsets[hh]; - } - idx += offset; - idxs[hh] = idx; - ff += irank; - } - } - if (!constant) { - maybelong *ff = fcoordinates; - t = 0.0; - for(hh = 0; hh < filter_size; hh++) { - double coeff = 0.0; - switch(input->descr->type_num) { - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); -#if HAS_UINT64 - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); -#endif - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - /* calculate the interpolated value: */ - for(ll = 0; ll < irank; ll++) - if (order > 0) - coeff *= splvals[ll][ff[ll]]; - t += coeff; - ff += irank; - } - } else { - t = cval; - } - /* store output value: */ - switch (output->descr->type_num) { - CASE_INTERP_OUT(po, t, Bool); - CASE_INTERP_OUT_UINT(po, t, UInt8, 0, MAX_UINT8); - CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); - CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); -#if HAS_UINT64 - /* FIXME */ - CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT32); -#endif - CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); - CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); - CASE_INTERP_OUT_INT(po, t, Int32, MIN_INT32, MAX_INT32); - CASE_INTERP_OUT_INT(po, t, Int64, MIN_INT64, MAX_INT64); - CASE_INTERP_OUT(po, t, Float32); - CASE_INTERP_OUT(po, t, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - if (coordinates) { - NI_ITERATOR_NEXT2(io, ic, po, pc); - } else { - NI_ITERATOR_NEXT(io, po); - } - } - - exit: - if (edge_offsets) - free(edge_offsets); - if (data_offsets) { - for(jj = 0; jj < irank; jj++) - free(data_offsets[jj]); - free(data_offsets); - } - if (splvals) { - for(jj = 0; jj < irank; jj++) - free(splvals[jj]); - free(splvals); - } - if (foffsets) - free(foffsets); - if (fcoordinates) - free(fcoordinates); - if (idxs) - free(idxs); - return PyErr_Occurred() ? 0 : 1; -} - -int NI_ZoomShift(PyArrayObject *input, PyArrayObject* zoom_ar, - PyArrayObject* shift_ar, PyArrayObject *output, - int order, int mode, double cval) -{ - char *po, *pi; - maybelong **zeros = NULL, **offsets = NULL, ***edge_offsets = NULL; - maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL; - maybelong jj, hh, kk, filter_size, odimensions[MAXDIM]; - maybelong idimensions[MAXDIM], istrides[MAXDIM], *idxs = NULL; - maybelong size; - double ***splvals = NULL; - NI_Iterator io; - Float64 *zooms = zoom_ar ? (Float64*)PyArray_DATA(zoom_ar) : NULL; - Float64 *shifts = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; - int rank = 0, qq; - - for(kk = 0; kk < input->nd; kk++) { - idimensions[kk] = input->dimensions[kk]; - istrides[kk] = input->strides[kk]; - odimensions[kk] = output->dimensions[kk]; - } - rank = input->nd; - - /* if the mode is 'constant' we need some temps later: */ - if (mode == NI_EXTEND_CONSTANT) { - zeros = (maybelong**)malloc(rank * sizeof(maybelong*)); - if (!zeros) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < rank; jj++) - zeros[jj] = NULL; - for(jj = 0; jj < rank; jj++) { - zeros[jj] = (maybelong*)malloc(odimensions[jj] * sizeof(maybelong)); - if(!zeros[jj]) { - PyErr_NoMemory(); - goto exit; - } - } - } - - /* store offsets, along each axis: */ - offsets = (maybelong**)malloc(rank * sizeof(maybelong*)); - /* store spline coefficients, along each axis: */ - splvals = (double***)malloc(rank * sizeof(double**)); - /* store offsets at all edges: */ - edge_offsets = (maybelong***)malloc(rank * sizeof(maybelong**)); - if (!offsets || !splvals || !edge_offsets) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < rank; jj++) { - offsets[jj] = NULL; - splvals[jj] = NULL; - edge_offsets[jj] = NULL; - } - for(jj = 0; jj < rank; jj++) { - offsets[jj] = (maybelong*)malloc(odimensions[jj] * sizeof(maybelong)); - splvals[jj] = (double**)malloc(odimensions[jj] * sizeof(double*)); - edge_offsets[jj] = (maybelong**)malloc(odimensions[jj] * sizeof(maybelong*)); - if (!offsets[jj] || !splvals[jj] || !edge_offsets[jj]) { - PyErr_NoMemory(); - goto exit; - } - for(hh = 0; hh < odimensions[jj]; hh++) { - splvals[jj][hh] = NULL; - edge_offsets[jj][hh] = NULL; - } - } - - /* precalculate offsets, and offsets at the edge: */ - for(jj = 0; jj < rank; jj++) { - double shift = 0.0, zoom = 0.0; - if (shifts) - shift = shifts[jj]; - if (zooms) - zoom = zooms[jj]; - for(kk = 0; kk < odimensions[jj]; kk++) { - double cc = (double)kk; - if (shifts) - cc += shift; - if (zooms) - cc *= zoom; - cc = map_coordinate(cc, idimensions[jj], mode); - if (cc > -1.0) { - int start; - if (zeros && zeros[jj]) - zeros[jj][kk] = 0; - if (order & 1) { - start = (int)floor(cc) - order / 2; - } else { - start = (int)floor(cc + 0.5) - order / 2; - } - offsets[jj][kk] = istrides[jj] * start; - if (start < 0 || start + order >= idimensions[jj]) { - edge_offsets[jj][kk] = (maybelong*)malloc((order + 1) * sizeof(maybelong)); - if (!edge_offsets[jj][kk]) { - PyErr_NoMemory(); - goto exit; - } - for(hh = 0; hh <= order; hh++) { - int idx = start + hh; - int len = idimensions[jj]; - if (len <= 1) { - idx = 0; - } else { - int s2 = 2 * len - 2; - if (idx < 0) { - idx = s2 * (int)(-idx / s2) + idx; - idx = idx <= 1 - len ? idx + s2 : -idx; - } else if (idx >= len) { - idx -= s2 * (int)(idx / s2); - if (idx >= len) - idx = s2 - idx; - } - } - edge_offsets[jj][kk][hh] = istrides[jj] * (idx - start); - } - } - if (order > 0) { - splvals[jj][kk] = (double*)malloc((order + 1) * sizeof(double)); - if (!splvals[jj][kk]) { - PyErr_NoMemory(); - goto exit; - } - spline_coefficients(cc, order, splvals[jj][kk]); - } - } else { - zeros[jj][kk] = 1; - } - } - } - - filter_size = 1; - for(jj = 0; jj < rank; jj++) - filter_size *= order + 1; - idxs = (maybelong*)malloc(filter_size * sizeof(idxs)); - if (!idxs) { - PyErr_NoMemory(); - goto exit; - } - - if (!NI_InitPointIterator(output, &io)) - goto exit; - - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - - /* store all coordinates and offsets with filter: */ - fcoordinates = (maybelong*)malloc(rank * filter_size * sizeof(maybelong)); - foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong)); - if (!fcoordinates || !foffsets) { - PyErr_NoMemory(); - goto exit; - } - - for(jj = 0; jj < rank; jj++) - ftmp[jj] = 0; - kk = 0; - for(hh = 0; hh < filter_size; hh++) { - for(jj = 0; jj < rank; jj++) - fcoordinates[jj + hh * rank] = ftmp[jj]; - foffsets[hh] = kk; - for(jj = rank - 1; jj >= 0; jj--) { - if (ftmp[jj] < order) { - ftmp[jj]++; - kk += istrides[jj]; - break; - } else { - ftmp[jj] = 0; - kk -= istrides[jj] * order; - } - } - } - size = 1; - for(qq = 0; qq < output->nd; qq++) - size *= output->dimensions[qq]; - for(kk = 0; kk < size; kk++) { - double t = 0.0; - int edge = 0, oo = 0, zero = 0; - - for(hh = 0; hh < rank; hh++) { - if (zeros && zeros[hh][io.coordinates[hh]]) { - /* we use constant border condition */ - zero = 1; - break; - } - oo += offsets[hh][io.coordinates[hh]]; - if (edge_offsets[hh][io.coordinates[hh]]) - edge = 1; - } - - if (!zero) { - maybelong *ff = fcoordinates; - for(hh = 0; hh < filter_size; hh++) { - int idx = 0; - if (edge) { - /* use precalculated edge offsets: */ - for(jj = 0; jj < rank; jj++) { - if (edge_offsets[jj][io.coordinates[jj]]) - idx += edge_offsets[jj][io.coordinates[jj]][ff[jj]]; - else - idx += ff[jj] * istrides[jj]; - } - idx += oo; - } else { - /* use normal offsets: */ - idx += oo + foffsets[hh]; - } - idxs[hh] = idx; - ff += rank; - } - } - if (!zero) { - maybelong *ff = fcoordinates; - t = 0.0; - for(hh = 0; hh < filter_size; hh++) { - double coeff = 0.0; - switch(input->descr->type_num) { - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); -#if HAS_UINT64 - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); -#endif - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - /* calculate interpolated value: */ - for(jj = 0; jj < rank; jj++) - if (order > 0) - coeff *= splvals[jj][io.coordinates[jj]][ff[jj]]; - t += coeff; - ff += rank; - } - } else { - t = cval; - } - /* store output: */ - switch (output->descr->type_num) { - CASE_INTERP_OUT(po, t, Bool); - CASE_INTERP_OUT_UINT(po, t, UInt8, 0, MAX_UINT8); - CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); - CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); -#if HAS_UINT64 - /* FIXME */ - CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT32); -#endif - CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); - CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); - CASE_INTERP_OUT_INT(po, t, Int32, MIN_INT32, MAX_INT32); - CASE_INTERP_OUT_INT(po, t, Int64, MIN_INT64, MAX_INT64); - CASE_INTERP_OUT(po, t, Float32); - CASE_INTERP_OUT(po, t, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - NI_ITERATOR_NEXT(io, po); - } - - exit: - if (zeros) { - for(jj = 0; jj < rank; jj++) - if (zeros[jj]) - free(zeros[jj]); - free(zeros); - } - if (offsets) { - for(jj = 0; jj < rank; jj++) - if (offsets[jj]) - free(offsets[jj]); - free(offsets); - } - if (splvals) { - for(jj = 0; jj < rank; jj++) { - if (splvals[jj]) { - for(hh = 0; hh < odimensions[jj]; hh++) - if (splvals[jj][hh]) - free(splvals[jj][hh]); - free(splvals[jj]); - } - } - free(splvals); - } - if (edge_offsets) { - for(jj = 0; jj < rank; jj++) { - if (edge_offsets[jj]) { - for(hh = 0; hh < odimensions[jj]; hh++) - if (edge_offsets[jj][hh]) - free(edge_offsets[jj][hh]); - free(edge_offsets[jj]); - } - } - free(edge_offsets); - } - if (foffsets) - free(foffsets); - if (fcoordinates) - free(fcoordinates); - if (idxs) - free(idxs); - return PyErr_Occurred() ? 0 : 1; -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ni_support.h" +#include "ni_interpolation.h" +#include +#include + +/* calculate the B-spline interpolation coefficients for given x: */ +static void +spline_coefficients(double x, int order, double *result) +{ + int hh; + double y, start; + + if (order & 1) { + start = (int)floor(x) - order / 2; + } else { + start = (int)floor(x + 0.5) - order / 2; + } + + for(hh = 0; hh <= order; hh++) { + y = fabs(start - x + hh); + + switch(order) { + case 1: + result[hh] = y > 1.0 ? 0.0 : 1.0 - y; + break; + case 2: + if (y < 0.5) { + result[hh] = 0.75 - y * y; + } else if (y < 1.5) { + y = 1.5 - y; + result[hh] = 0.5 * y * y; + } else { + result[hh] = 0.0; + } + break; + case 3: + if (y < 1.0) { + result[hh] = + (y * y * (y - 2.0) * 3.0 + 4.0) / 6.0; + } else if (y < 2.0) { + y = 2.0 - y; + result[hh] = y * y * y / 6.0; + } else { + result[hh] = 0.0; + } + break; + case 4: + if (y < 0.5) { + y *= y; + result[hh] = y * (y * 0.25 - 0.625) + 115.0 / 192.0; + } else if (y < 1.5) { + result[hh] = y * (y * (y * (5.0 / 6.0 - y / 6.0) - 1.25) + + 5.0 / 24.0) + 55.0 / 96.0; + } else if (y < 2.5) { + y -= 2.5; + y *= y; + result[hh] = y * y / 24.0; + } else { + result[hh] = 0.0; + } + break; + case 5: + if (y < 1.0) { + double f = y * y; + result[hh] = + f * (f * (0.25 - y / 12.0) - 0.5) + 0.55; + } else if (y < 2.0) { + result[hh] = y * (y * (y * (y * (y / 24.0 - 0.375) + + 1.25) - 1.75) + 0.625) + 0.425; + } else if (y < 3.0) { + double f = 3.0 - y; + y = f * f; + result[hh] = f * y * y / 120.0; + } else { + result[hh] = 0.0; + } + break; + } + } +} + +/* map a coordinate outside the borders, according to the requested + boundary condition: */ +static double +map_coordinate(double in, maybelong len, int mode) +{ + if (in < 0) { + switch (mode) { + case NI_EXTEND_MIRROR: + if (len <= 1) { + in = 0; + } else { + maybelong sz2 = 2 * len - 2; + in = sz2 * (maybelong)(-in / sz2) + in; + in = in <= 1 - len ? in + sz2 : -in; + } + break; + case NI_EXTEND_REFLECT: + if (len <= 1) { + in = 0; + } else { + maybelong sz2 = 2 * len; + if (in < -sz2) + in = sz2 * (maybelong)(-in / sz2) + in; + in = in < -len ? in + sz2 : -in - 1; + } + break; + case NI_EXTEND_WRAP: + if (len <= 1) { + in = 0; + } else { + maybelong sz = len - 1; + // Integer division of -in/sz gives (-in mod sz) + // Note that 'in' is negative + in += sz * ((maybelong)(-in / sz) + 1); + } + break; + case NI_EXTEND_NEAREST: + in = 0; + break; + case NI_EXTEND_CONSTANT: + in = -1; + break; + } + } else if (in > len-1) { + switch (mode) { + case NI_EXTEND_MIRROR: + if (len <= 1) { + in = 0; + } else { + maybelong sz2 = 2 * len - 2; + in -= sz2 * (maybelong)(in / sz2); + if (in >= len) + in = sz2 - in; + } + break; + case NI_EXTEND_REFLECT: + if (len <= 1) { + in = 0; + } else { + maybelong sz2 = 2 * len; + in -= sz2 * (maybelong)(in / sz2); + if (in >= len) + in = sz2 - in - 1; + } + break; + case NI_EXTEND_WRAP: + if (len <= 1) { + in = 0; + } else { + maybelong sz = len - 1; + in -= sz * (maybelong)(in / sz); + } + break; + case NI_EXTEND_NEAREST: + in = len - 1; + break; + case NI_EXTEND_CONSTANT: + in = -1; + break; + } + } + + return in; +} + +#define BUFFER_SIZE 256000 +#define TOLERANCE 1e-15 + +/* one-dimensional spline filter: */ +int NI_SplineFilter1D(PyArrayObject *input, int order, int axis, + PyArrayObject *output) +{ + int hh, npoles = 0, more; + maybelong kk, ll, lines, len; + double *buffer = NULL, weight, pole[2]; + NI_LineBuffer iline_buffer, oline_buffer; + + len = input->nd > 0 ? input->dimensions[axis] : 1; + if (len < 1) + goto exit; + + /* these are used in the spline filter calculation below: */ + switch (order) { + case 2: + npoles = 1; + pole[0] = sqrt(8.0) - 3.0; + break; + case 3: + npoles = 1; + pole[0] = sqrt(3.0) - 2.0; + break; + case 4: + npoles = 2; + pole[0] = sqrt(664.0 - sqrt(438976.0)) + sqrt(304.0) - 19.0; + pole[1] = sqrt(664.0 + sqrt(438976.0)) - sqrt(304.0) - 19.0; + break; + case 5: + npoles = 2; + pole[0] = sqrt(67.5 - sqrt(4436.25)) + sqrt(26.25) - 6.5; + pole[1] = sqrt(67.5 + sqrt(4436.25)) - sqrt(26.25) - 6.5; + break; + default: + break; + } + + weight = 1.0; + for(hh = 0; hh < npoles; hh++) + weight *= (1.0 - pole[hh]) * (1.0 - 1.0 / pole[hh]); + + /* allocate an initialize the line buffer, only a single one is used, + because the calculation is in-place: */ + lines = -1; + if (!NI_AllocateLineBuffer(input, axis, 0, 0, &lines, BUFFER_SIZE, + &buffer)) + goto exit; + if (!NI_InitLineBuffer(input, axis, 0, 0, lines, buffer, + NI_EXTEND_DEFAULT, 0.0, &iline_buffer)) + goto exit; + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, buffer, + NI_EXTEND_DEFAULT, 0.0, &oline_buffer)) + goto exit; + + /* iterate over all the array lines: */ + do { + /* copy lines from array to buffer: */ + if (!NI_ArrayToLineBuffer(&iline_buffer, &lines, &more)) + goto exit; + /* iterate over the lines in the buffer: */ + for(kk = 0; kk < lines; kk++) { + /* get line: */ + double *ln = NI_GET_LINE(iline_buffer, kk); + /* spline filter: */ + if (len > 1) { + for(ll = 0; ll < len; ll++) + ln[ll] *= weight; + for(hh = 0; hh < npoles; hh++) { + double p = pole[hh]; + int max = (int)ceil(log(TOLERANCE) / log(fabs(p))); + if (max < len) { + double zn = p; + double sum = ln[0]; + for(ll = 1; ll < max; ll++) { + sum += zn * ln[ll]; + zn *= p; + } + ln[0] = sum; + } else { + double zn = p; + double iz = 1.0 / p; + double z2n = pow(p, (double)(len - 1)); + double sum = ln[0] + z2n * ln[len - 1]; + z2n *= z2n * iz; + for(ll = 1; ll <= len - 2; ll++) { + sum += (zn + z2n) * ln[ll]; + zn *= p; + z2n *= iz; + } + ln[0] = sum / (1.0 - zn * zn); + } + for(ll = 1; ll < len; ll++) + ln[ll] += p * ln[ll - 1]; + ln[len-1] = (p / (p * p - 1.0)) * (ln[len-1] + p * ln[len-2]); + for(ll = len - 2; ll >= 0; ll--) + ln[ll] = p * (ln[ll + 1] - ln[ll]); + } + } + } + /* copy lines from buffer to array: */ + if (!NI_LineBufferToArray(&oline_buffer)) + goto exit; + } while(more); + + exit: + if (buffer) free(buffer); + return PyErr_Occurred() ? 0 : 1; +} + +#define CASE_MAP_COORDINATES(_p, _coor, _rank, _stride, _type) \ +case t ## _type: \ +{ \ + int _hh; \ + for(_hh = 0; _hh < _rank; _hh++) { \ + _coor[_hh] = *(_type*)_p; \ + _p += _stride; \ + } \ +} \ +break; + +#define CASE_INTERP_COEFF(_coeff, _pi, _idx, _type) \ +case t ## _type: \ + _coeff = *(_type*)(_pi + _idx); \ + break; + +#define CASE_INTERP_OUT(_po, _t, _type) \ +case t ## _type: \ + *(_type*)_po = (_type)_t; \ + break; + +#define CASE_INTERP_OUT_UINT(_po, _t, _type, type_min, type_max) \ +case t ## _type: \ + _t = _t > 0 ? _t + 0.5 : 0; \ + _t = _t > type_max ? type_max : t; \ + _t = _t < type_min ? type_min : t; \ + *(_type*)_po = (_type)_t; \ + break; + +#define CASE_INTERP_OUT_INT(_po, _t, _type, type_min, type_max) \ +case t ## _type: \ + _t = _t > 0 ? _t + 0.5 : _t - 0.5; \ + _t = _t > type_max ? type_max : t; \ + _t = _t < type_min ? type_min : t; \ + *(_type*)_po = (_type)_t; \ + break; + +int +NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*, + int, int, void*), void* map_data, PyArrayObject* matrix_ar, + PyArrayObject* shift_ar, PyArrayObject *coordinates, + PyArrayObject *output, int order, int mode, double cval) +{ + char *po, *pi, *pc = NULL; + maybelong **edge_offsets = NULL, **data_offsets = NULL, filter_size; + maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL; + maybelong cstride = 0, kk, hh, ll, jj, *idxs = NULL; + maybelong size; + double **splvals = NULL, icoor[MAXDIM]; + double idimensions[MAXDIM], istrides[MAXDIM]; + NI_Iterator io, ic; + Float64 *matrix = matrix_ar ? (Float64*)PyArray_DATA(matrix_ar) : NULL; + Float64 *shift = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; + int irank = 0, orank, qq; + + for(kk = 0; kk < input->nd; kk++) { + idimensions[kk] = input->dimensions[kk]; + istrides[kk] = input->strides[kk]; + } + irank = input->nd; + orank = output->nd; + + /* if the mapping is from array coordinates: */ + if (coordinates) { + /* initialze a line iterator along the first axis: */ + if (!NI_InitPointIterator(coordinates, &ic)) + goto exit; + cstride = ic.strides[0]; + if (!NI_LineIterator(&ic, 0)) + goto exit; + pc = (void *)(PyArray_DATA(coordinates)); + } + + /* offsets used at the borders: */ + edge_offsets = (maybelong**)malloc(irank * sizeof(maybelong*)); + data_offsets = (maybelong**)malloc(irank * sizeof(maybelong*)); + if (!edge_offsets || !data_offsets) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < irank; jj++) + data_offsets[jj] = NULL; + for(jj = 0; jj < irank; jj++) { + data_offsets[jj] = (maybelong*)malloc((order + 1) * sizeof(maybelong)); + if (!data_offsets[jj]) { + PyErr_NoMemory(); + goto exit; + } + } + /* will hold the spline coefficients: */ + splvals = (double**)malloc(irank * sizeof(double*)); + if (!splvals) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < irank; jj++) + splvals[jj] = NULL; + for(jj = 0; jj < irank; jj++) { + splvals[jj] = (double*)malloc((order + 1) * sizeof(double)); + if (!splvals[jj]) { + PyErr_NoMemory(); + goto exit; + } + } + + filter_size = 1; + for(jj = 0; jj < irank; jj++) + filter_size *= order + 1; + idxs = (maybelong*)malloc(filter_size * sizeof(idxs)); + if (!idxs) { + PyErr_NoMemory(); + goto exit; + } + + /* initialize output iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + + /* get data pointers: */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + + /* make a table of all possible coordinates within the spline filter: */ + fcoordinates = (maybelong*)malloc(irank * filter_size * sizeof(maybelong)); + /* make a table of all offsets within the spline filter: */ + foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong)); + if (!fcoordinates || !foffsets) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < irank; jj++) + ftmp[jj] = 0; + kk = 0; + for(hh = 0; hh < filter_size; hh++) { + for(jj = 0; jj < irank; jj++) + fcoordinates[jj + hh * irank] = ftmp[jj]; + foffsets[hh] = kk; + for(jj = irank - 1; jj >= 0; jj--) { + if (ftmp[jj] < order) { + ftmp[jj]++; + kk += istrides[jj]; + break; + } else { + ftmp[jj] = 0; + kk -= istrides[jj] * order; + } + } + } + + size = 1; + for(qq = 0; qq < output->nd; qq++) + size *= output->dimensions[qq]; + for(kk = 0; kk < size; kk++) { + double t = 0.0; + int constant = 0, edge = 0, offset = 0; + if (map) { + /* call mappint functions: */ + if (!map(io.coordinates, icoor, orank, irank, map_data)) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, + "unknown error in mapping function"); + goto exit; + } + } else if (matrix) { + /* do an affine transformation: */ + Float64 *p = matrix; + for(hh = 0; hh < irank; hh++) { + icoor[hh] = 0.0; + for(ll = 0; ll < orank; ll++) + icoor[hh] += io.coordinates[ll] * *p++; + icoor[hh] += shift[hh]; + } + } else if (coordinates) { + /* mapping is from an coordinates array: */ + char *p = pc; + switch(coordinates->descr->type_num) { + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Bool); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt8); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt16); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt32); +#if HAS_UINT64 + CASE_MAP_COORDINATES(p, icoor, irank, cstride, UInt64); +#endif + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int8); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int16); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int32); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Int64); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float32); + CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, + "coordinate array data type not supported"); + goto exit; + } + } + /* iterate over axes: */ + for(hh = 0; hh < irank; hh++) { + /* if the input coordinate is outside the borders, map it: */ + double cc = map_coordinate(icoor[hh], idimensions[hh], mode); + if (cc > -1.0) { + /* find the filter location along this axis: */ + int start; + if (order & 1) { + start = (int)floor(cc) - order / 2; + } else { + start = (int)floor(cc + 0.5) - order / 2; + } + /* get the offset to the start of the filter: */ + offset += istrides[hh] * start; + if (start < 0 || start + order >= idimensions[hh]) { + /* implement border mapping, if outside border: */ + edge = 1; + edge_offsets[hh] = data_offsets[hh]; + for(ll = 0; ll <= order; ll++) { + int idx = start + ll; + int len = idimensions[hh]; + if (len <= 1) { + idx = 0; + } else { + int s2 = 2 * len - 2; + if (idx < 0) { + idx = s2 * (int)(-idx / s2) + idx; + idx = idx <= 1 - len ? idx + s2 : -idx; + } else if (idx >= len) { + idx -= s2 * (int)(idx / s2); + if (idx >= len) + idx = s2 - idx; + } + } + /* calculate and store the offests at this edge: */ + edge_offsets[hh][ll] = istrides[hh] * (idx - start); + } + } else { + /* we are not at the border, use precalculated offsets: */ + edge_offsets[hh] = NULL; + } + spline_coefficients(cc, order, splvals[hh]); + } else { + /* we use the constant border condition: */ + constant = 1; + break; + } + } + + if (!constant) { + maybelong *ff = fcoordinates; + for(hh = 0; hh < filter_size; hh++) { + int idx = 0; + if (edge) { + for(ll = 0; ll < irank; ll++) { + if (edge_offsets[ll]) + idx += edge_offsets[ll][ff[ll]]; + else + idx += ff[ll] * istrides[ll]; + } + } else { + idx = foffsets[hh]; + } + idx += offset; + idxs[hh] = idx; + ff += irank; + } + } + if (!constant) { + maybelong *ff = fcoordinates; + t = 0.0; + for(hh = 0; hh < filter_size; hh++) { + double coeff = 0.0; + switch(input->descr->type_num) { + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); +#if HAS_UINT64 + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); +#endif + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + /* calculate the interpolated value: */ + for(ll = 0; ll < irank; ll++) + if (order > 0) + coeff *= splvals[ll][ff[ll]]; + t += coeff; + ff += irank; + } + } else { + t = cval; + } + /* store output value: */ + switch (output->descr->type_num) { + CASE_INTERP_OUT(po, t, Bool); + CASE_INTERP_OUT_UINT(po, t, UInt8, 0, MAX_UINT8); + CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); + CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); +#if HAS_UINT64 + /* FIXME */ + CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT32); +#endif + CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); + CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); + CASE_INTERP_OUT_INT(po, t, Int32, MIN_INT32, MAX_INT32); + CASE_INTERP_OUT_INT(po, t, Int64, MIN_INT64, MAX_INT64); + CASE_INTERP_OUT(po, t, Float32); + CASE_INTERP_OUT(po, t, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + if (coordinates) { + NI_ITERATOR_NEXT2(io, ic, po, pc); + } else { + NI_ITERATOR_NEXT(io, po); + } + } + + exit: + if (edge_offsets) + free(edge_offsets); + if (data_offsets) { + for(jj = 0; jj < irank; jj++) + free(data_offsets[jj]); + free(data_offsets); + } + if (splvals) { + for(jj = 0; jj < irank; jj++) + free(splvals[jj]); + free(splvals); + } + if (foffsets) + free(foffsets); + if (fcoordinates) + free(fcoordinates); + if (idxs) + free(idxs); + return PyErr_Occurred() ? 0 : 1; +} + +int NI_ZoomShift(PyArrayObject *input, PyArrayObject* zoom_ar, + PyArrayObject* shift_ar, PyArrayObject *output, + int order, int mode, double cval) +{ + char *po, *pi; + maybelong **zeros = NULL, **offsets = NULL, ***edge_offsets = NULL; + maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL; + maybelong jj, hh, kk, filter_size, odimensions[MAXDIM]; + maybelong idimensions[MAXDIM], istrides[MAXDIM], *idxs = NULL; + maybelong size; + double ***splvals = NULL; + NI_Iterator io; + Float64 *zooms = zoom_ar ? (Float64*)PyArray_DATA(zoom_ar) : NULL; + Float64 *shifts = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; + int rank = 0, qq; + + for(kk = 0; kk < input->nd; kk++) { + idimensions[kk] = input->dimensions[kk]; + istrides[kk] = input->strides[kk]; + odimensions[kk] = output->dimensions[kk]; + } + rank = input->nd; + + /* if the mode is 'constant' we need some temps later: */ + if (mode == NI_EXTEND_CONSTANT) { + zeros = (maybelong**)malloc(rank * sizeof(maybelong*)); + if (!zeros) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < rank; jj++) + zeros[jj] = NULL; + for(jj = 0; jj < rank; jj++) { + zeros[jj] = (maybelong*)malloc(odimensions[jj] * sizeof(maybelong)); + if(!zeros[jj]) { + PyErr_NoMemory(); + goto exit; + } + } + } + + /* store offsets, along each axis: */ + offsets = (maybelong**)malloc(rank * sizeof(maybelong*)); + /* store spline coefficients, along each axis: */ + splvals = (double***)malloc(rank * sizeof(double**)); + /* store offsets at all edges: */ + edge_offsets = (maybelong***)malloc(rank * sizeof(maybelong**)); + if (!offsets || !splvals || !edge_offsets) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < rank; jj++) { + offsets[jj] = NULL; + splvals[jj] = NULL; + edge_offsets[jj] = NULL; + } + for(jj = 0; jj < rank; jj++) { + offsets[jj] = (maybelong*)malloc(odimensions[jj] * sizeof(maybelong)); + splvals[jj] = (double**)malloc(odimensions[jj] * sizeof(double*)); + edge_offsets[jj] = (maybelong**)malloc(odimensions[jj] * sizeof(maybelong*)); + if (!offsets[jj] || !splvals[jj] || !edge_offsets[jj]) { + PyErr_NoMemory(); + goto exit; + } + for(hh = 0; hh < odimensions[jj]; hh++) { + splvals[jj][hh] = NULL; + edge_offsets[jj][hh] = NULL; + } + } + + /* precalculate offsets, and offsets at the edge: */ + for(jj = 0; jj < rank; jj++) { + double shift = 0.0, zoom = 0.0; + if (shifts) + shift = shifts[jj]; + if (zooms) + zoom = zooms[jj]; + for(kk = 0; kk < odimensions[jj]; kk++) { + double cc = (double)kk; + if (shifts) + cc += shift; + if (zooms) + cc *= zoom; + cc = map_coordinate(cc, idimensions[jj], mode); + if (cc > -1.0) { + int start; + if (zeros && zeros[jj]) + zeros[jj][kk] = 0; + if (order & 1) { + start = (int)floor(cc) - order / 2; + } else { + start = (int)floor(cc + 0.5) - order / 2; + } + offsets[jj][kk] = istrides[jj] * start; + if (start < 0 || start + order >= idimensions[jj]) { + edge_offsets[jj][kk] = (maybelong*)malloc((order + 1) * sizeof(maybelong)); + if (!edge_offsets[jj][kk]) { + PyErr_NoMemory(); + goto exit; + } + for(hh = 0; hh <= order; hh++) { + int idx = start + hh; + int len = idimensions[jj]; + if (len <= 1) { + idx = 0; + } else { + int s2 = 2 * len - 2; + if (idx < 0) { + idx = s2 * (int)(-idx / s2) + idx; + idx = idx <= 1 - len ? idx + s2 : -idx; + } else if (idx >= len) { + idx -= s2 * (int)(idx / s2); + if (idx >= len) + idx = s2 - idx; + } + } + edge_offsets[jj][kk][hh] = istrides[jj] * (idx - start); + } + } + if (order > 0) { + splvals[jj][kk] = (double*)malloc((order + 1) * sizeof(double)); + if (!splvals[jj][kk]) { + PyErr_NoMemory(); + goto exit; + } + spline_coefficients(cc, order, splvals[jj][kk]); + } + } else { + zeros[jj][kk] = 1; + } + } + } + + filter_size = 1; + for(jj = 0; jj < rank; jj++) + filter_size *= order + 1; + idxs = (maybelong*)malloc(filter_size * sizeof(idxs)); + if (!idxs) { + PyErr_NoMemory(); + goto exit; + } + + if (!NI_InitPointIterator(output, &io)) + goto exit; + + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + + /* store all coordinates and offsets with filter: */ + fcoordinates = (maybelong*)malloc(rank * filter_size * sizeof(maybelong)); + foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong)); + if (!fcoordinates || !foffsets) { + PyErr_NoMemory(); + goto exit; + } + + for(jj = 0; jj < rank; jj++) + ftmp[jj] = 0; + kk = 0; + for(hh = 0; hh < filter_size; hh++) { + for(jj = 0; jj < rank; jj++) + fcoordinates[jj + hh * rank] = ftmp[jj]; + foffsets[hh] = kk; + for(jj = rank - 1; jj >= 0; jj--) { + if (ftmp[jj] < order) { + ftmp[jj]++; + kk += istrides[jj]; + break; + } else { + ftmp[jj] = 0; + kk -= istrides[jj] * order; + } + } + } + size = 1; + for(qq = 0; qq < output->nd; qq++) + size *= output->dimensions[qq]; + for(kk = 0; kk < size; kk++) { + double t = 0.0; + int edge = 0, oo = 0, zero = 0; + + for(hh = 0; hh < rank; hh++) { + if (zeros && zeros[hh][io.coordinates[hh]]) { + /* we use constant border condition */ + zero = 1; + break; + } + oo += offsets[hh][io.coordinates[hh]]; + if (edge_offsets[hh][io.coordinates[hh]]) + edge = 1; + } + + if (!zero) { + maybelong *ff = fcoordinates; + for(hh = 0; hh < filter_size; hh++) { + int idx = 0; + if (edge) { + /* use precalculated edge offsets: */ + for(jj = 0; jj < rank; jj++) { + if (edge_offsets[jj][io.coordinates[jj]]) + idx += edge_offsets[jj][io.coordinates[jj]][ff[jj]]; + else + idx += ff[jj] * istrides[jj]; + } + idx += oo; + } else { + /* use normal offsets: */ + idx += oo + foffsets[hh]; + } + idxs[hh] = idx; + ff += rank; + } + } + if (!zero) { + maybelong *ff = fcoordinates; + t = 0.0; + for(hh = 0; hh < filter_size; hh++) { + double coeff = 0.0; + switch(input->descr->type_num) { + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); +#if HAS_UINT64 + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); +#endif + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + /* calculate interpolated value: */ + for(jj = 0; jj < rank; jj++) + if (order > 0) + coeff *= splvals[jj][io.coordinates[jj]][ff[jj]]; + t += coeff; + ff += rank; + } + } else { + t = cval; + } + /* store output: */ + switch (output->descr->type_num) { + CASE_INTERP_OUT(po, t, Bool); + CASE_INTERP_OUT_UINT(po, t, UInt8, 0, MAX_UINT8); + CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); + CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); +#if HAS_UINT64 + /* FIXME */ + CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT32); +#endif + CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); + CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); + CASE_INTERP_OUT_INT(po, t, Int32, MIN_INT32, MAX_INT32); + CASE_INTERP_OUT_INT(po, t, Int64, MIN_INT64, MAX_INT64); + CASE_INTERP_OUT(po, t, Float32); + CASE_INTERP_OUT(po, t, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + NI_ITERATOR_NEXT(io, po); + } + + exit: + if (zeros) { + for(jj = 0; jj < rank; jj++) + if (zeros[jj]) + free(zeros[jj]); + free(zeros); + } + if (offsets) { + for(jj = 0; jj < rank; jj++) + if (offsets[jj]) + free(offsets[jj]); + free(offsets); + } + if (splvals) { + for(jj = 0; jj < rank; jj++) { + if (splvals[jj]) { + for(hh = 0; hh < odimensions[jj]; hh++) + if (splvals[jj][hh]) + free(splvals[jj][hh]); + free(splvals[jj]); + } + } + free(splvals); + } + if (edge_offsets) { + for(jj = 0; jj < rank; jj++) { + if (edge_offsets[jj]) { + for(hh = 0; hh < odimensions[jj]; hh++) + if (edge_offsets[jj][hh]) + free(edge_offsets[jj][hh]); + free(edge_offsets[jj]); + } + } + free(edge_offsets); + } + if (foffsets) + free(foffsets); + if (fcoordinates) + free(fcoordinates); + if (idxs) + free(idxs); + return PyErr_Occurred() ? 0 : 1; +} Modified: trunk/scipy/ndimage/src/ni_interpolation.h =================================================================== --- trunk/scipy/ndimage/src/ni_interpolation.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_interpolation.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,43 +1,43 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NI_INTERPOLATION_H -#define NI_INTERPOLATION_H - -int NI_SplineFilter1D(PyArrayObject*, int, int, PyArrayObject*); -int NI_GeometricTransform(PyArrayObject*, int (*)(maybelong*, double*, int, int, - void*), void*, PyArrayObject*, PyArrayObject*, - PyArrayObject*, PyArrayObject*, int, int, - double); -int NI_ZoomShift(PyArrayObject*, PyArrayObject*, PyArrayObject*, - PyArrayObject*, int, int, double); - -#endif +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NI_INTERPOLATION_H +#define NI_INTERPOLATION_H + +int NI_SplineFilter1D(PyArrayObject*, int, int, PyArrayObject*); +int NI_GeometricTransform(PyArrayObject*, int (*)(maybelong*, double*, int, int, + void*), void*, PyArrayObject*, PyArrayObject*, + PyArrayObject*, PyArrayObject*, int, int, + double); +int NI_ZoomShift(PyArrayObject*, PyArrayObject*, PyArrayObject*, + PyArrayObject*, int, int, double); + +#endif Modified: trunk/scipy/ndimage/src/ni_measure.c =================================================================== --- trunk/scipy/ndimage/src/ni_measure.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_measure.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,1197 +1,1197 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ni_support.h" -#include "ni_measure.h" -#include -#include -#include -#include - -typedef struct { - Int32 index1, index2; - void* next; -} _index_pair; - -#define CASE_LABEL(_p, _pi, _type) \ -case t ## _type: \ - *_p = *(_type*)_pi ? -1 : 0; \ - break - -int NI_Label(PyArrayObject* input, PyArrayObject* strct, - maybelong *max_label, PyArrayObject* output) -{ - int kk; - maybelong jj, ll, ssize, size, filter_size, *offsets = NULL; - maybelong mask_value, *oo; - Bool *ps, *footprint = NULL; - char *pi, *po; - Int32 index = 0, *index_map = NULL; - NI_FilterIterator fi; - NI_Iterator ii, io; - _index_pair *pairs = NULL; - - /* structure size */ - ssize = 1; - for(kk = 0; kk < strct->nd; kk++) - ssize *= strct->dimensions[kk]; - /* we only use the first half of the structure data, so we make a - temporary structure for use with the filter functions: */ - footprint = (Bool*)malloc(ssize * sizeof(Bool)); - if (!footprint) { - PyErr_NoMemory(); - goto exit; - } - ps = (Bool*)PyArray_DATA(strct); - filter_size = 0; - for(jj = 0; jj < ssize / 2; jj++) { - footprint[jj] = ps[jj]; - if (ps[jj]) - ++filter_size; - } - for(jj = ssize / 2; jj < ssize; jj++) - footprint[jj] = 0; - /* get data and size */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(kk = 0; kk < output->nd; kk++) - size *= output->dimensions[kk]; - if (!NI_InitPointIterator(input, &ii)) - goto exit; - if (!NI_InitPointIterator(output, &io)) - goto exit; - /* set all elements in the output corresponding to non-zero elements - in input to -1: */ - for(jj = 0; jj < size; jj++) { - Int32 *p = (Int32*)po; - switch (input->descr->type_num) { - CASE_LABEL(p, pi, Bool); - CASE_LABEL(p, pi, UInt8); - CASE_LABEL(p, pi, UInt16); - CASE_LABEL(p, pi, UInt32); -#if HAS_UINT64 - CASE_LABEL(p, pi, UInt64); -#endif - CASE_LABEL(p, pi, Int8); - CASE_LABEL(p, pi, Int16); - CASE_LABEL(p, pi, Int32); - CASE_LABEL(p, pi, Int64); - CASE_LABEL(p, pi, Float32); - CASE_LABEL(p, pi, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - NI_ITERATOR_NEXT2(ii, io, pi, po); - } - - /* calculate the filter offsets: */ - if (!NI_InitFilterOffsets(output, footprint, strct->dimensions, NULL, - NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, strct->dimensions, filter_size, - input->dimensions, NULL, &fi)) - goto exit; - /* reset output iterator: */ - NI_ITERATOR_RESET(io); - po = (void *)PyArray_DATA(output); - /* iterator over the elements: */ - oo = offsets; - for(jj = 0; jj < size; jj++) { - if (*(Int32*)po < 0) { - Int32 neighbor = 0; - /* iterate over structuring element: */ - for(ll = 0; ll < filter_size; ll++) { - int offset = oo[ll]; - if (offset != mask_value) { - Int32 tt = *(Int32*)(po + offset); - if (tt > 0) { - /* this element is next to an already found object: */ - if (neighbor && neighbor != tt) { - /* we have two objects that must be merged later: */ - _index_pair* tp = (_index_pair*)malloc(sizeof(_index_pair)); - if (!tp) { - PyErr_NoMemory(); - goto exit; - } - tp->next = pairs; - /* the pairs must be ordered: */ - if (neighbor < tt) { - tp->index1 = neighbor; - tp->index2 = tt; - } else { - tp->index1 = tt; - tp->index2 = neighbor; - } - pairs = tp; - } else { - neighbor = tt; - } - } - } - } - if (neighbor) { - /* this point belongs to an existing object */ - *(Int32*)po = neighbor; - } else { - /* this may be a new object: */ - *(Int32*)po = ++index; - } - } - NI_FILTER_NEXT(fi, io, oo, po); - } - *max_label = index; - /* merge any touching objects: */ - if (pairs) { - Int32 counter; - index_map = (Int32*)malloc(index * sizeof(Int32)); - if (!index_map) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < index; jj++) - index_map[jj] = (Int32)jj; - while (pairs) { - Int32 idx1 = pairs->index1 - 1; - Int32 idx2 = pairs->index2 - 1; - if (index_map[idx2] == idx1 || index_map[idx2] == idx2) { - /* if this pair was already processed, or if idx2 was not - mapped yet, we delete this pair and map idx2 to idx1: */ - _index_pair *tp = pairs; - pairs = tp->next; - free(tp); - index_map[idx2] = idx1; - } else { - /* idx2 was already mapped, therefore we find what it was - mapped to and change the current pair to the result of that - and idx1. Since the pair is not destroyed, it will be - re-processed with the adapted values. */ - idx2 = index_map[idx2]; - /* keep the pairs ordered: */ - if (idx1 < idx2) { - pairs->index1 = idx1 + 1; - pairs->index2 = idx2 + 1; - } else { - pairs->index1 = idx2 + 1; - pairs->index2 = idx1 + 1; - } - } - } - for(jj = 0; jj < index; jj++) { - /* if the current index maps to a index that is also mapped, - change it to map to that index. Since an index always maps to - a lower index or to itself, this will make sure that at the - end all indices map to an unmapped index. */ - if (index_map[index_map[jj]] < index_map[jj]) - index_map[jj] = index_map[index_map[jj]]; - } - /* renumber the indices that are not mapped: */ - counter = 0; - for(jj = 0; jj < index; jj++) - if (index_map[jj] == jj) - index_map[jj] = ++counter; - else - index_map[jj] = index_map[index_map[jj]]; - } - - /* relabel the output if we merged some objects: */ - if (index_map) { - *max_label = 0; - NI_ITERATOR_RESET(io); - po = (void *)PyArray_DATA(output); - for(jj = 0; jj < size; jj++) { - Int32 p = *(Int32*)po; - if (p > 0 ) - *(Int32*)po = index_map[p - 1]; - if (*(Int32*)po > *max_label) - *max_label = *(Int32*)po; - NI_ITERATOR_NEXT(io, po); - } - } - exit: - if (offsets) free(offsets); - if (index_map) free(index_map); - while (pairs) { - _index_pair *tp = pairs; - pairs = (_index_pair*)pairs->next; - free(tp); - } - if (footprint) - free(footprint); - return PyErr_Occurred() ? 0 : 1; -} - -#define CASE_FIND_OBJECT_POINT(_pi, _regions, _rank, _dimensions, \ - _max_label, _ii, _type) \ -case t ## _type: \ -{ \ - int _kk; \ - maybelong _sindex = *(_type*)_pi - 1; \ - if (_sindex >= 0 && _sindex < _max_label) { \ - if (_rank > 0) { \ - _sindex *= 2 * _rank; \ - if (_regions[_sindex] < 0) { \ - for(_kk = 0; _kk < _rank; _kk++) { \ - maybelong _cc = _ii.coordinates[_kk]; \ - _regions[_sindex + _kk] = _cc; \ - _regions[_sindex + _kk + _rank] = _cc + 1; \ - } \ - } else { \ - for(_kk = 0; _kk < _rank; _kk++) { \ - maybelong _cc = _ii.coordinates[_kk]; \ - if (_cc < _regions[_sindex + _kk]) \ - _regions[_sindex + _kk] = _cc; \ - if (_cc + 1 > _regions[_sindex + _kk + _rank]) \ - _regions[_sindex + _kk + _rank] = _cc + 1; \ - } \ - } \ - } else { \ - _regions[_sindex] = 1; \ - } \ - } \ -} \ -break - -int NI_FindObjects(PyArrayObject* input, maybelong max_label, - maybelong* regions) -{ - int kk; - maybelong size, jj; - NI_Iterator ii; - char *pi; - - /* get input data, size and iterator: */ - pi = (void *)PyArray_DATA(input); - size = 1; - for(kk = 0; kk < input->nd; kk++) - size *= input->dimensions[kk]; - if (!NI_InitPointIterator(input, &ii)) - goto exit; - if (input->nd > 0) { - for(jj = 0; jj < 2 * input->nd * max_label; jj++) - regions[jj] = -1; - } else { - for(jj = 0; jj < max_label; jj++) - regions[jj] = -1; - } - /* iterate over all points: */ - for(jj = 0 ; jj < size; jj++) { - switch (input->descr->type_num) { - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, Bool); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, UInt8); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, UInt16); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, UInt32); -#if HAS_UINT64 - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, UInt64); -#endif - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, Int8); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, Int16); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, Int32); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, - max_label, ii, Int64); - break; - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - NI_ITERATOR_NEXT(ii, pi); - } - exit: - return PyErr_Occurred() ? 0 : 1; -} - - -/* macro to get input value: */ -#if HAS_UINT64 -#define NI_GET_VALUE(_pi, _v, _type) \ -{ \ - switch(_type) { \ - case tBool: \ - _v = (*(Bool*)_pi) != 0; \ - break; \ - case tUInt8: \ - _v = *(UInt8*)_pi; \ - break; \ - case tUInt16: \ - _v = *(UInt16*)_pi; \ - break; \ - case tUInt32: \ - _v = *(UInt32*)_pi; \ - break; \ - case tInt8: \ - _v = *(Int8*)_pi; \ - break; \ - case tInt16: \ - _v = *(Int16*)_pi; \ - break; \ - case tInt32: \ - _v = *(Int32*)_pi; \ - break; \ - case tInt64: \ - _v = *(Int64*)_pi; \ - break; \ - case tUInt64: \ - _v = *(UInt64*)_pi; \ - break; \ - case tFloat32: \ - _v = *(Float32*)_pi; \ - break; \ - case tFloat64: \ - _v = *(Float64*)_pi; \ - break; \ - default: \ - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ - return 0; \ - } \ -} -#else -#define NI_GET_VALUE(_pi, _v, _type) \ -{ \ - switch(_type) { \ - case tBool: \ - _v = (*(Bool*)_pi) != 0; \ - break; \ - case tUInt8: \ - _v = *(UInt8*)_pi; \ - break; \ - case tUInt16: \ - _v = *(UInt16*)_pi; \ - break; \ - case tUInt32: \ - _v = *(UInt32*)_pi; \ - break; \ - case tInt8: \ - _v = *(Int8*)_pi; \ - break; \ - case tInt16: \ - _v = *(Int16*)_pi; \ - break; \ - case tInt32: \ - _v = *(Int32*)_pi; \ - break; \ - case tInt64: \ - _v = *(Int64*)_pi; \ - break; \ - case tFloat32: \ - _v = *(Float32*)_pi; \ - break; \ - case tFloat64: \ - _v = *(Float64*)_pi; \ - break; \ - default: \ - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ - return 0; \ - } \ -} -#endif - -/* macro to get label value: */ -#if HAS_UINT64 -#define NI_GET_LABEL(_pm, _label, _type) \ -{ \ - if (_pm) { \ - switch(_type) { \ - case tBool: \ - _label = *(Bool*)_pm; \ - break; \ - case tUInt8: \ - _label = *(UInt8*)_pm; \ - break; \ - case tUInt16: \ - _label = *(UInt16*)_pm; \ - break; \ - case tUInt32: \ - _label = *(UInt32*)_pm; \ - break; \ - case tUInt64: \ - _label = *(UInt64*)_pm; \ - break; \ - case tInt8: \ - _label = *(Int8*)_pm; \ - break; \ - case tInt16: \ - _label = *(Int16*)_pm; \ - break; \ - case tInt32: \ - _label = *(Int32*)_pm; \ - break; \ - case tInt64: \ - _label = *(Int64*)_pm; \ - break; \ - case tFloat32: \ - _label = *(Float32*)_pm; \ - break; \ - case tFloat64: \ - _label = *(Float64*)_pm; \ - break; \ - default: \ - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ - return 0; \ - } \ - } \ -} -#else -#define NI_GET_LABEL(_pm, _label, _type) \ -{ \ - if (_pm) { \ - switch(_type) { \ - case tBool: \ - _label = *(Bool*)_pm; \ - break; \ - case tUInt8: \ - _label = *(UInt8*)_pm; \ - break; \ - case tUInt16: \ - _label = *(UInt16*)_pm; \ - break; \ - case tUInt32: \ - _label = *(UInt32*)_pm; \ - break; \ - case tInt8: \ - _label = *(Int8*)_pm; \ - break; \ - case tInt16: \ - _label = *(Int16*)_pm; \ - break; \ - case tInt32: \ - _label = *(Int32*)_pm; \ - break; \ - case tInt64: \ - _label = *(Int64*)_pm; \ - break; \ - case tFloat32: \ - _label = *(Float32*)_pm; \ - break; \ - case tFloat64: \ - _label = *(Float64*)_pm; \ - break; \ - default: \ - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ - return 0; \ - } \ - } \ -} -#endif - -int NI_Statistics(PyArrayObject *input, PyArrayObject *labels, - maybelong min_label, maybelong max_label, maybelong *indices, - maybelong n_results, double *sum, maybelong *total, double *variance, - double *minimum, double *maximum, maybelong* min_pos, maybelong* max_pos) -{ - char *pi = NULL, *pm = NULL; - NI_Iterator ii, mi; - maybelong jj, size, idx = 0, label = 1, doit = 1; - int qq; - - /* input iterator: */ - if (!NI_InitPointIterator(input, &ii)) - return 0; - /* input data: */ - pi = (void *)PyArray_DATA(input); - if (labels) { - if (!NI_InitPointIterator(labels, &mi)) - return 0; - pm = (void *)PyArray_DATA(labels); - } - /* input size: */ - size = 1; - for(qq = 0; qq < input->nd; qq++) - size *= input->dimensions[qq]; - for(jj = 0; jj < n_results; jj++) { - if (sum) - sum[jj] = 0.0; - if (total) - total[jj] = 0; - if (variance) - variance[jj] = 0; - if (minimum) - minimum[jj] = DBL_MAX; - if (maximum) - maximum[jj] = -DBL_MAX; - if (min_pos) - min_pos[jj] = 0; - if (max_pos) - max_pos[jj] = 0; - } - /* iterate over array: */ - for(jj = 0; jj < size; jj++) { - NI_GET_LABEL(pm, label, labels->descr->type_num); - if (min_label >= 0) { - if (label >= min_label && label <= max_label) { - idx = indices[label - min_label]; - doit = idx >= 0; - } else { - doit = 0; - } - } else { - doit = label != 0; - } - if (doit) { - double val; - NI_GET_VALUE(pi, val, input->descr->type_num); - if (sum) - sum[idx] += val; - if (total) - total[idx]++; - if (minimum && val < minimum[idx]) { - minimum[idx] = val; - if (min_pos) - min_pos[idx] = jj; - } - if (maximum && (val > maximum[idx])) { - maximum[idx] = val; - if (max_pos) - max_pos[idx] = jj; - } - } - if (labels) { - NI_ITERATOR_NEXT2(ii, mi, pi, pm); - } else { - NI_ITERATOR_NEXT(ii, pi); - } - } - if (minimum) { - for(jj = 0; jj < n_results; jj++) { - if (!(minimum[jj] < DBL_MAX)) - minimum[jj] = 0.0; - } - } - if (maximum) { - for(jj = 0; jj < n_results; jj++) { - if (!(maximum[jj] > -DBL_MAX)) - maximum[jj] = 0.0; - } - } - if (variance) { - int do_var = 0; - for(jj = 0; jj < n_results; jj++) - if (total[jj] > 1) { - do_var = 1; - break; - } - if (do_var) { - /* reset input iterator: */ - NI_ITERATOR_RESET(ii); - pi = (void *)PyArray_DATA(input); - if (labels) { - /* reset label iterator: */ - NI_ITERATOR_RESET(mi); - pm = (void *)PyArray_DATA(labels); - } - for(jj = 0; jj < size; jj++) { - NI_GET_LABEL(pm, label, labels->descr->type_num); - if (min_label >= 0) { - if (label >= min_label && label <= max_label) { - idx = indices[label - min_label]; - doit = idx >= 0; - } else { - doit = 0; - } - } else { - doit = label != 0; - } - if (doit) { - double val; - NI_GET_VALUE(pi, val, input->descr->type_num); - val = val - sum[idx] / total[idx]; - variance[idx] += val * val; - } - if (labels) { - NI_ITERATOR_NEXT2(ii, mi, pi, pm); - } else { - NI_ITERATOR_NEXT(ii, pi); - } - } - for(jj = 0; jj < n_results; jj++) - variance[jj] = (total[jj] > 1 ? - variance[jj] / (total[jj] - 1) : 0.0); - } - } - return 1; -} - - -int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels, - maybelong min_label, maybelong max_label, maybelong *indices, - maybelong n_results, double *center_of_mass) -{ - char *pi = NULL, *pm = NULL; - NI_Iterator ii, mi; - maybelong jj, kk, size, idx = 0, label = 1, doit = 1; - double *sum = NULL; - int qq; - - /* input iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* input data: */ - pi = (void *)PyArray_DATA(input); - if (labels) { - if (!NI_InitPointIterator(labels, &mi)) - goto exit; - pm = (void *)PyArray_DATA(labels); - } - /* input size: */ - size = 1; - for(qq = 0; qq < input->nd; qq++) - size *= input->dimensions[qq]; - sum = (double*)malloc(n_results * sizeof(double)); - if (!sum) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < n_results; jj++) { - sum[jj] = 0.0; - for(kk = 0; kk < input->nd; kk++) - center_of_mass[jj * input->nd + kk] = 0.0; - } - /* iterate over array: */ - for(jj = 0; jj < size; jj++) { - NI_GET_LABEL(pm, label, labels->descr->type_num); - if (min_label >= 0) { - if (label >= min_label && label <= max_label) { - idx = indices[label - min_label]; - doit = idx >= 0; - } else { - doit = 0; - } - } else { - doit = label != 0; - } - if (doit) { - double val; - NI_GET_VALUE(pi, val, input->descr->type_num); - sum[idx] += val; - for(kk = 0; kk < input->nd; kk++) - center_of_mass[idx * input->nd + kk] += val * ii.coordinates[kk]; - } - if (labels) { - NI_ITERATOR_NEXT2(ii, mi, pi, pm); - } else { - NI_ITERATOR_NEXT(ii, pi); - } - } - for(jj = 0; jj < n_results; jj++) - for(kk = 0; kk < input->nd; kk++) - center_of_mass[jj * input->nd + kk] /= sum[jj]; - exit: - if (sum) - free(sum); - return PyErr_Occurred() == NULL; -} - - -int NI_Histogram(PyArrayObject *input, PyArrayObject *labels, - maybelong min_label, maybelong max_label, maybelong *indices, - maybelong n_results, PyArrayObject **histograms, - double min, double max, maybelong nbins) -{ - char *pi = NULL, *pm = NULL; - NI_Iterator ii, mi; - maybelong jj, kk, size, idx = 0, label = 1, doit = 1; - Int32 **ph = NULL; - double bsize; - int qq; - - /* input iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* input data: */ - pi = (void *)PyArray_DATA(input); - if (labels) { - if (!NI_InitPointIterator(labels, &mi)) - goto exit; - pm = (void *)PyArray_DATA(labels); - } - ph = (Int32**)malloc(n_results * sizeof(Int32*)); - if (!ph) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < n_results; jj++) { - ph[jj] = (Int32*)PyArray_DATA(histograms[jj]); - for(kk = 0; kk < nbins; kk++) - ph[jj][kk] = 0; - } - bsize = (max - min) / (double)nbins; - /* input size: */ - size = 1; - for(qq = 0; qq < input->nd; qq++) - size *= input->dimensions[qq]; - /* iterate over array: */ - for(jj = 0; jj < size; jj++) { - NI_GET_LABEL(pm, label, labels->descr->type_num); - if (min_label >= 0) { - if (label >= min_label && label <= max_label) { - idx = indices[label - min_label]; - doit = idx >= 0; - } else { - doit = 0; - } - } else { - doit = label != 0; - } - if (doit) { - int bin; - double val; - NI_GET_VALUE(pi, val, input->descr->type_num); - if (val >= min && val < max) { - bin = (int)((val - min) / bsize); - ++(ph[idx][bin]); - } - } - if (labels) { - NI_ITERATOR_NEXT2(ii, mi, pi, pm); - } else { - NI_ITERATOR_NEXT(ii, pi); - } - } - exit: - if (ph) - free(ph); - return PyErr_Occurred() == NULL; -} - -#define WS_GET_INDEX(_index, _c_strides, _b_strides, _rank, _out, \ - _contiguous, _type) \ -do { \ - if (_contiguous) { \ - _out = _index * sizeof(_type); \ - } else { \ - int _qq; \ - maybelong _cc, _idx = _index; \ - _out = 0; \ - for (_qq = 0; _qq < _rank; _qq++) { \ - _cc = _idx / _c_strides[_qq]; \ - _idx -= _cc * _c_strides[_qq]; \ - _out += _b_strides[_qq] * _cc; \ - } \ - } \ -} while(0) - -#define CASE_GET_INPUT(_ival, _pi, _type) \ -case t ## _type: \ - _ival = *((_type*)_pi); \ - break - -#define CASE_GET_LABEL(_label, _pm, _type) \ -case t ## _type: \ - _label = *(_type*)_pm; \ - break - -#define CASE_PUT_LABEL(_label, _pl, _type) \ -case t ## _type: \ - *((_type*)_pl) = _label; \ - break - -#define CASE_WINDEX1(_v_index, _p_index, _strides, _istrides, _irank, \ - _icont, _p_idx, _v_idx, _pi, _vval, _pval, _type) \ -case t ## _type: \ - WS_GET_INDEX(_v_index, _strides, _istrides, _irank, _p_idx, _icont, \ - _type); \ - WS_GET_INDEX(_p_index, _strides, _istrides, _irank, _v_idx, _icont, \ - _type); \ - _vval = *(_type*)(_pi + _v_idx); \ - _pval = *(_type*)(_pi + _p_idx); \ - break - -#define CASE_WINDEX2(_v_index, _strides, _ostrides, _irank, _idx, \ - _ocont, _label, _pl, _type) \ -case t ## _type: \ - WS_GET_INDEX(_v_index, _strides, _ostrides, _irank, _idx, \ - _ocont, _type); \ - _label = *(_type*)(_pl + _idx); \ - break - -#define CASE_WINDEX3(_p_index, _strides, _ostrides, _irank, _idx, \ - _ocont, _label, _pl, _type) \ -case t ## _type: \ - WS_GET_INDEX(_p_index, _strides, _ostrides, _irank, _idx, \ - _ocont, _type); \ - *(_type*)(_pl + _idx) = _label; \ -break - -#define DONE_TYPE UInt8 -#define COST_TYPE UInt16 -#define WS_MAXDIM 7 - -typedef struct { - maybelong index; - COST_TYPE cost; - void *next, *prev; - DONE_TYPE done; -} NI_WatershedElement; - -int NI_WatershedIFT(PyArrayObject* input, PyArrayObject* markers, - PyArrayObject* strct, PyArrayObject* output) -{ - char *pl, *pm, *pi; - int ll; - maybelong size, jj, hh, kk, maxval; - maybelong strides[WS_MAXDIM], coordinates[WS_MAXDIM]; - maybelong *nstrides = NULL, nneigh, ssize; - int i_contiguous, o_contiguous; - NI_WatershedElement *temp = NULL, **first = NULL, **last = NULL; - Bool *ps = NULL; - NI_Iterator mi, ii, li; - - i_contiguous = PyArray_ISCONTIGUOUS(input); - o_contiguous = PyArray_ISCONTIGUOUS(output); - ssize = 1; - for(ll = 0; ll < strct->nd; ll++) - ssize *= strct->dimensions[ll]; - if (input->nd > WS_MAXDIM) { - PyErr_SetString(PyExc_RuntimeError, "too many dimensions"); - goto exit; - } - size = 1; - for(ll = 0; ll < input->nd; ll++) - size *= input->dimensions[ll]; - /* Storage for the temporary queue data. */ - temp = (NI_WatershedElement*)malloc(size * sizeof(NI_WatershedElement)); - if (!temp) { - PyErr_NoMemory(); - goto exit; - } - pi = (void *)PyArray_DATA(input); - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* Initialization and find the maximum of the input. */ - maxval = 0; - for(jj = 0; jj < size; jj++) { - int ival = 0; - switch(input->descr->type_num) { - CASE_GET_INPUT(ival, pi, UInt8); - CASE_GET_INPUT(ival, pi, UInt16); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - temp[jj].index = jj; - temp[jj].done = 0; - if (ival > maxval) - maxval = ival; - NI_ITERATOR_NEXT(ii, pi); - } - pi = (void *)PyArray_DATA(input); - /* Allocate and initialize the storage for the queue. */ - first = (NI_WatershedElement**)malloc((maxval + 1) * - sizeof(NI_WatershedElement*)); - last = (NI_WatershedElement**)malloc((maxval + 1) * - sizeof(NI_WatershedElement*)); - if (!first || !last) { - PyErr_NoMemory(); - goto exit; - } - for(hh = 0; hh <= maxval; hh++) { - first[hh] = NULL; - last[hh] = NULL; - } - if (!NI_InitPointIterator(markers, &mi)) - goto exit; - if (!NI_InitPointIterator(output, &li)) - goto exit; - pm = (void *)PyArray_DATA(markers); - pl = (void *)PyArray_DATA(output); - /* initialize all nodes */ - for(ll = 0; ll < input->nd; ll++) - coordinates[ll] = 0; - for(jj = 0; jj < size; jj++) { - /* get marker */ - int label = 0; - switch(markers->descr->type_num) { - CASE_GET_LABEL(label, pm, UInt8); - CASE_GET_LABEL(label, pm, UInt16); - CASE_GET_LABEL(label, pm, UInt32); -#if HAS_UINT64 - CASE_GET_LABEL(label, pm, UInt64); -#endif - CASE_GET_LABEL(label, pm, Int8); - CASE_GET_LABEL(label, pm, Int16); - CASE_GET_LABEL(label, pm, Int32); - CASE_GET_LABEL(label, pm, Int64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - switch(output->descr->type_num) { - CASE_PUT_LABEL(label, pl, UInt8); - CASE_PUT_LABEL(label, pl, UInt16); - CASE_PUT_LABEL(label, pl, UInt32); -#if HAS_UINT64 - CASE_PUT_LABEL(label, pl, UInt64); -#endif - CASE_PUT_LABEL(label, pl, Int8); - CASE_PUT_LABEL(label, pl, Int16); - CASE_PUT_LABEL(label, pl, Int32); - CASE_PUT_LABEL(label, pl, Int64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - NI_ITERATOR_NEXT2(mi, li, pm, pl); - if (label != 0) { - /* This node is a marker */ - temp[jj].cost = 0; - if (!first[0]) { - first[0] = &(temp[jj]); - first[0]->next = NULL; - first[0]->prev = NULL; - last[0] = first[0]; - } else { - if (label > 0) { - /* object markers are enqueued at the beginning, so they are - processed first. */ - temp[jj].next = first[0]; - temp[jj].prev = NULL; - first[0]->prev = &(temp[jj]); - first[0] = &(temp[jj]); - } else { - /* background markers are enqueued at the end, so they are - processed after the object markers. */ - temp[jj].next = NULL; - temp[jj].prev = last[0]; - last[0]->next = &(temp[jj]); - last[0] = &(temp[jj]); - } - } - } else { - /* This node is not a marker */ - temp[jj].cost = maxval + 1; - temp[jj].next = NULL; - temp[jj].prev = NULL; - } - for(ll = input->nd - 1; ll >= 0; ll--) - if (coordinates[ll] < input->dimensions[ll] - 1) { - coordinates[ll]++; - break; - } else { - coordinates[ll] = 0; - } - } - - pl = (void *)PyArray_DATA(output); - ps = (Bool*)PyArray_DATA(strct); - nneigh = 0; - for (kk = 0; kk < ssize; kk++) - if (ps[kk] && kk != (ssize / 2)) - ++nneigh; - nstrides = (maybelong*)malloc(nneigh * sizeof(maybelong)); - if (!nstrides) { - PyErr_NoMemory(); - goto exit; - } - strides[input->nd - 1] = 1; - for(ll = input->nd - 2; ll >= 0; ll--) - strides[ll] = input->dimensions[ll + 1] * strides[ll + 1]; - for(ll = 0; ll < input->nd; ll++) - coordinates[ll] = -1; - for(kk = 0; kk < nneigh; kk++) - nstrides[kk] = 0; - jj = 0; - for(kk = 0; kk < ssize; kk++) { - if (ps[kk]) { - int offset = 0; - for(ll = 0; ll < input->nd; ll++) - offset += coordinates[ll] * strides[ll]; - if (offset != 0) - nstrides[jj++] += offset; - } - for(ll = input->nd - 1; ll >= 0; ll--) - if (coordinates[ll] < 1) { - coordinates[ll]++; - break; - } else { - coordinates[ll] = -1; - } - } - /* Propagation phase: */ - for(jj = 0; jj <= maxval; jj++) { - while (first[jj]) { - /* dequeue first element: */ - NI_WatershedElement *v = first[jj]; - first[jj] = first[jj]->next; - if (first[jj]) - first[jj]->prev = NULL; - v->prev = NULL; - v->next = NULL; - /* Mark element as done: */ - v->done = 1; - /* Iterate over the neighbors of the element: */ - for(hh = 0; hh < nneigh; hh++) { - maybelong v_index = v->index, p_index = v->index, idx, cc; - int qq, outside = 0; - p_index += nstrides[hh]; - /* check if the neighbor is within the extent of the array: */ - idx = p_index; - for (qq = 0; qq < input->nd; qq++) { - cc = idx / strides[qq]; - if (cc < 0 || cc >= input->dimensions[qq]) { - outside = 1; - break; - } - idx -= cc * strides[qq]; - } - if (!outside) { - NI_WatershedElement *p = &(temp[p_index]); - if (!(p->done)) { - /* If the neighbor was not processed yet: */ - int max, pval, vval, wvp, pcost, label, p_idx, v_idx; - switch(input->descr->type_num) { - CASE_WINDEX1(v_index, p_index, strides, input->strides, - input->nd, i_contiguous, p_idx, v_idx, pi, - vval, pval, UInt8); - CASE_WINDEX1(v_index, p_index, strides, input->strides, - input->nd, i_contiguous, p_idx, v_idx, pi, - vval, pval, UInt16); - default: - PyErr_SetString(PyExc_RuntimeError, - "data type not supported"); - goto exit; - } - /* Calculate cost: */ - wvp = pval - vval; - if (wvp < 0) - wvp = -wvp; - /* Find the maximum of this cost and the current - element cost: */ - pcost = p->cost; - max = v->cost > wvp ? v->cost : wvp; - if (max < pcost) { - /* If this maximum is less than the neighbors cost, - adapt the cost and the label of the neighbor: */ - int idx; - p->cost = max; - switch(output->descr->type_num) { - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt8); - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt16); - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt32); -#if HAS_UINT64 - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt64); -#endif - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int8); - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int16); - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int32); - CASE_WINDEX2(v_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int64); - default: - PyErr_SetString(PyExc_RuntimeError, - "data type not supported"); - goto exit; - } - switch(output->descr->type_num) { - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt8); - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt16); - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt32); -#if HAS_UINT64 - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, UInt64); -#endif - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int8); - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int16); - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int32); - CASE_WINDEX3(p_index, strides, output->strides, input->nd, - idx, o_contiguous, label, pl, Int64); - default: - PyErr_SetString(PyExc_RuntimeError, - "data type not supported"); - goto exit; - } - /* If the neighbor is in a queue, remove it: */ - if (p->next || p->prev) { - NI_WatershedElement *prev = p->prev, *next = p->next; - if (first[pcost] == p) - first[pcost] = next; - if (last[pcost] == p) - last[pcost] = prev; - if (prev) - prev->next = next; - if (next) - next->prev = prev; - } - /* Insert the neighbor in the appropiate queue: */ - if (label < 0) { - p->prev = last[max]; - p->next = NULL; - if (last[max]) - last[max]->next = p; - last[max] = p; - if (!first[max]) - first[max] = p; - } else { - p->next = first[max]; - p->prev = NULL; - if (first[max]) - first[max]->prev = p; - first[max] = p; - if (!last[max]) - last[max] = p; - } - } - } - } - } - } - } - exit: - if (temp) - free(temp); - if (first) - free(first); - if (last) - free(last); - if (nstrides) - free(nstrides); - return PyErr_Occurred() ? 0 : 1; -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ni_support.h" +#include "ni_measure.h" +#include +#include +#include +#include + +typedef struct { + Int32 index1, index2; + void* next; +} _index_pair; + +#define CASE_LABEL(_p, _pi, _type) \ +case t ## _type: \ + *_p = *(_type*)_pi ? -1 : 0; \ + break + +int NI_Label(PyArrayObject* input, PyArrayObject* strct, + maybelong *max_label, PyArrayObject* output) +{ + int kk; + maybelong jj, ll, ssize, size, filter_size, *offsets = NULL; + maybelong mask_value, *oo; + Bool *ps, *footprint = NULL; + char *pi, *po; + Int32 index = 0, *index_map = NULL; + NI_FilterIterator fi; + NI_Iterator ii, io; + _index_pair *pairs = NULL; + + /* structure size */ + ssize = 1; + for(kk = 0; kk < strct->nd; kk++) + ssize *= strct->dimensions[kk]; + /* we only use the first half of the structure data, so we make a + temporary structure for use with the filter functions: */ + footprint = (Bool*)malloc(ssize * sizeof(Bool)); + if (!footprint) { + PyErr_NoMemory(); + goto exit; + } + ps = (Bool*)PyArray_DATA(strct); + filter_size = 0; + for(jj = 0; jj < ssize / 2; jj++) { + footprint[jj] = ps[jj]; + if (ps[jj]) + ++filter_size; + } + for(jj = ssize / 2; jj < ssize; jj++) + footprint[jj] = 0; + /* get data and size */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(kk = 0; kk < output->nd; kk++) + size *= output->dimensions[kk]; + if (!NI_InitPointIterator(input, &ii)) + goto exit; + if (!NI_InitPointIterator(output, &io)) + goto exit; + /* set all elements in the output corresponding to non-zero elements + in input to -1: */ + for(jj = 0; jj < size; jj++) { + Int32 *p = (Int32*)po; + switch (input->descr->type_num) { + CASE_LABEL(p, pi, Bool); + CASE_LABEL(p, pi, UInt8); + CASE_LABEL(p, pi, UInt16); + CASE_LABEL(p, pi, UInt32); +#if HAS_UINT64 + CASE_LABEL(p, pi, UInt64); +#endif + CASE_LABEL(p, pi, Int8); + CASE_LABEL(p, pi, Int16); + CASE_LABEL(p, pi, Int32); + CASE_LABEL(p, pi, Int64); + CASE_LABEL(p, pi, Float32); + CASE_LABEL(p, pi, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + NI_ITERATOR_NEXT2(ii, io, pi, po); + } + + /* calculate the filter offsets: */ + if (!NI_InitFilterOffsets(output, footprint, strct->dimensions, NULL, + NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(input->nd, strct->dimensions, filter_size, + input->dimensions, NULL, &fi)) + goto exit; + /* reset output iterator: */ + NI_ITERATOR_RESET(io); + po = (void *)PyArray_DATA(output); + /* iterator over the elements: */ + oo = offsets; + for(jj = 0; jj < size; jj++) { + if (*(Int32*)po < 0) { + Int32 neighbor = 0; + /* iterate over structuring element: */ + for(ll = 0; ll < filter_size; ll++) { + int offset = oo[ll]; + if (offset != mask_value) { + Int32 tt = *(Int32*)(po + offset); + if (tt > 0) { + /* this element is next to an already found object: */ + if (neighbor && neighbor != tt) { + /* we have two objects that must be merged later: */ + _index_pair* tp = (_index_pair*)malloc(sizeof(_index_pair)); + if (!tp) { + PyErr_NoMemory(); + goto exit; + } + tp->next = pairs; + /* the pairs must be ordered: */ + if (neighbor < tt) { + tp->index1 = neighbor; + tp->index2 = tt; + } else { + tp->index1 = tt; + tp->index2 = neighbor; + } + pairs = tp; + } else { + neighbor = tt; + } + } + } + } + if (neighbor) { + /* this point belongs to an existing object */ + *(Int32*)po = neighbor; + } else { + /* this may be a new object: */ + *(Int32*)po = ++index; + } + } + NI_FILTER_NEXT(fi, io, oo, po); + } + *max_label = index; + /* merge any touching objects: */ + if (pairs) { + Int32 counter; + index_map = (Int32*)malloc(index * sizeof(Int32)); + if (!index_map) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < index; jj++) + index_map[jj] = (Int32)jj; + while (pairs) { + Int32 idx1 = pairs->index1 - 1; + Int32 idx2 = pairs->index2 - 1; + if (index_map[idx2] == idx1 || index_map[idx2] == idx2) { + /* if this pair was already processed, or if idx2 was not + mapped yet, we delete this pair and map idx2 to idx1: */ + _index_pair *tp = pairs; + pairs = tp->next; + free(tp); + index_map[idx2] = idx1; + } else { + /* idx2 was already mapped, therefore we find what it was + mapped to and change the current pair to the result of that + and idx1. Since the pair is not destroyed, it will be + re-processed with the adapted values. */ + idx2 = index_map[idx2]; + /* keep the pairs ordered: */ + if (idx1 < idx2) { + pairs->index1 = idx1 + 1; + pairs->index2 = idx2 + 1; + } else { + pairs->index1 = idx2 + 1; + pairs->index2 = idx1 + 1; + } + } + } + for(jj = 0; jj < index; jj++) { + /* if the current index maps to a index that is also mapped, + change it to map to that index. Since an index always maps to + a lower index or to itself, this will make sure that at the + end all indices map to an unmapped index. */ + if (index_map[index_map[jj]] < index_map[jj]) + index_map[jj] = index_map[index_map[jj]]; + } + /* renumber the indices that are not mapped: */ + counter = 0; + for(jj = 0; jj < index; jj++) + if (index_map[jj] == jj) + index_map[jj] = ++counter; + else + index_map[jj] = index_map[index_map[jj]]; + } + + /* relabel the output if we merged some objects: */ + if (index_map) { + *max_label = 0; + NI_ITERATOR_RESET(io); + po = (void *)PyArray_DATA(output); + for(jj = 0; jj < size; jj++) { + Int32 p = *(Int32*)po; + if (p > 0 ) + *(Int32*)po = index_map[p - 1]; + if (*(Int32*)po > *max_label) + *max_label = *(Int32*)po; + NI_ITERATOR_NEXT(io, po); + } + } + exit: + if (offsets) free(offsets); + if (index_map) free(index_map); + while (pairs) { + _index_pair *tp = pairs; + pairs = (_index_pair*)pairs->next; + free(tp); + } + if (footprint) + free(footprint); + return PyErr_Occurred() ? 0 : 1; +} + +#define CASE_FIND_OBJECT_POINT(_pi, _regions, _rank, _dimensions, \ + _max_label, _ii, _type) \ +case t ## _type: \ +{ \ + int _kk; \ + maybelong _sindex = *(_type*)_pi - 1; \ + if (_sindex >= 0 && _sindex < _max_label) { \ + if (_rank > 0) { \ + _sindex *= 2 * _rank; \ + if (_regions[_sindex] < 0) { \ + for(_kk = 0; _kk < _rank; _kk++) { \ + maybelong _cc = _ii.coordinates[_kk]; \ + _regions[_sindex + _kk] = _cc; \ + _regions[_sindex + _kk + _rank] = _cc + 1; \ + } \ + } else { \ + for(_kk = 0; _kk < _rank; _kk++) { \ + maybelong _cc = _ii.coordinates[_kk]; \ + if (_cc < _regions[_sindex + _kk]) \ + _regions[_sindex + _kk] = _cc; \ + if (_cc + 1 > _regions[_sindex + _kk + _rank]) \ + _regions[_sindex + _kk + _rank] = _cc + 1; \ + } \ + } \ + } else { \ + _regions[_sindex] = 1; \ + } \ + } \ +} \ +break + +int NI_FindObjects(PyArrayObject* input, maybelong max_label, + maybelong* regions) +{ + int kk; + maybelong size, jj; + NI_Iterator ii; + char *pi; + + /* get input data, size and iterator: */ + pi = (void *)PyArray_DATA(input); + size = 1; + for(kk = 0; kk < input->nd; kk++) + size *= input->dimensions[kk]; + if (!NI_InitPointIterator(input, &ii)) + goto exit; + if (input->nd > 0) { + for(jj = 0; jj < 2 * input->nd * max_label; jj++) + regions[jj] = -1; + } else { + for(jj = 0; jj < max_label; jj++) + regions[jj] = -1; + } + /* iterate over all points: */ + for(jj = 0 ; jj < size; jj++) { + switch (input->descr->type_num) { + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, Bool); + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, UInt8); + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, UInt16); + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, UInt32); +#if HAS_UINT64 + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, UInt64); +#endif + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, Int8); + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, Int16); + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, Int32); + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + max_label, ii, Int64); + break; + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + NI_ITERATOR_NEXT(ii, pi); + } + exit: + return PyErr_Occurred() ? 0 : 1; +} + + +/* macro to get input value: */ +#if HAS_UINT64 +#define NI_GET_VALUE(_pi, _v, _type) \ +{ \ + switch(_type) { \ + case tBool: \ + _v = (*(Bool*)_pi) != 0; \ + break; \ + case tUInt8: \ + _v = *(UInt8*)_pi; \ + break; \ + case tUInt16: \ + _v = *(UInt16*)_pi; \ + break; \ + case tUInt32: \ + _v = *(UInt32*)_pi; \ + break; \ + case tInt8: \ + _v = *(Int8*)_pi; \ + break; \ + case tInt16: \ + _v = *(Int16*)_pi; \ + break; \ + case tInt32: \ + _v = *(Int32*)_pi; \ + break; \ + case tInt64: \ + _v = *(Int64*)_pi; \ + break; \ + case tUInt64: \ + _v = *(UInt64*)_pi; \ + break; \ + case tFloat32: \ + _v = *(Float32*)_pi; \ + break; \ + case tFloat64: \ + _v = *(Float64*)_pi; \ + break; \ + default: \ + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ + return 0; \ + } \ +} +#else +#define NI_GET_VALUE(_pi, _v, _type) \ +{ \ + switch(_type) { \ + case tBool: \ + _v = (*(Bool*)_pi) != 0; \ + break; \ + case tUInt8: \ + _v = *(UInt8*)_pi; \ + break; \ + case tUInt16: \ + _v = *(UInt16*)_pi; \ + break; \ + case tUInt32: \ + _v = *(UInt32*)_pi; \ + break; \ + case tInt8: \ + _v = *(Int8*)_pi; \ + break; \ + case tInt16: \ + _v = *(Int16*)_pi; \ + break; \ + case tInt32: \ + _v = *(Int32*)_pi; \ + break; \ + case tInt64: \ + _v = *(Int64*)_pi; \ + break; \ + case tFloat32: \ + _v = *(Float32*)_pi; \ + break; \ + case tFloat64: \ + _v = *(Float64*)_pi; \ + break; \ + default: \ + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ + return 0; \ + } \ +} +#endif + +/* macro to get label value: */ +#if HAS_UINT64 +#define NI_GET_LABEL(_pm, _label, _type) \ +{ \ + if (_pm) { \ + switch(_type) { \ + case tBool: \ + _label = *(Bool*)_pm; \ + break; \ + case tUInt8: \ + _label = *(UInt8*)_pm; \ + break; \ + case tUInt16: \ + _label = *(UInt16*)_pm; \ + break; \ + case tUInt32: \ + _label = *(UInt32*)_pm; \ + break; \ + case tUInt64: \ + _label = *(UInt64*)_pm; \ + break; \ + case tInt8: \ + _label = *(Int8*)_pm; \ + break; \ + case tInt16: \ + _label = *(Int16*)_pm; \ + break; \ + case tInt32: \ + _label = *(Int32*)_pm; \ + break; \ + case tInt64: \ + _label = *(Int64*)_pm; \ + break; \ + case tFloat32: \ + _label = *(Float32*)_pm; \ + break; \ + case tFloat64: \ + _label = *(Float64*)_pm; \ + break; \ + default: \ + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ + return 0; \ + } \ + } \ +} +#else +#define NI_GET_LABEL(_pm, _label, _type) \ +{ \ + if (_pm) { \ + switch(_type) { \ + case tBool: \ + _label = *(Bool*)_pm; \ + break; \ + case tUInt8: \ + _label = *(UInt8*)_pm; \ + break; \ + case tUInt16: \ + _label = *(UInt16*)_pm; \ + break; \ + case tUInt32: \ + _label = *(UInt32*)_pm; \ + break; \ + case tInt8: \ + _label = *(Int8*)_pm; \ + break; \ + case tInt16: \ + _label = *(Int16*)_pm; \ + break; \ + case tInt32: \ + _label = *(Int32*)_pm; \ + break; \ + case tInt64: \ + _label = *(Int64*)_pm; \ + break; \ + case tFloat32: \ + _label = *(Float32*)_pm; \ + break; \ + case tFloat64: \ + _label = *(Float64*)_pm; \ + break; \ + default: \ + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \ + return 0; \ + } \ + } \ +} +#endif + +int NI_Statistics(PyArrayObject *input, PyArrayObject *labels, + maybelong min_label, maybelong max_label, maybelong *indices, + maybelong n_results, double *sum, maybelong *total, double *variance, + double *minimum, double *maximum, maybelong* min_pos, maybelong* max_pos) +{ + char *pi = NULL, *pm = NULL; + NI_Iterator ii, mi; + maybelong jj, size, idx = 0, label = 1, doit = 1; + int qq; + + /* input iterator: */ + if (!NI_InitPointIterator(input, &ii)) + return 0; + /* input data: */ + pi = (void *)PyArray_DATA(input); + if (labels) { + if (!NI_InitPointIterator(labels, &mi)) + return 0; + pm = (void *)PyArray_DATA(labels); + } + /* input size: */ + size = 1; + for(qq = 0; qq < input->nd; qq++) + size *= input->dimensions[qq]; + for(jj = 0; jj < n_results; jj++) { + if (sum) + sum[jj] = 0.0; + if (total) + total[jj] = 0; + if (variance) + variance[jj] = 0; + if (minimum) + minimum[jj] = DBL_MAX; + if (maximum) + maximum[jj] = -DBL_MAX; + if (min_pos) + min_pos[jj] = 0; + if (max_pos) + max_pos[jj] = 0; + } + /* iterate over array: */ + for(jj = 0; jj < size; jj++) { + NI_GET_LABEL(pm, label, labels->descr->type_num); + if (min_label >= 0) { + if (label >= min_label && label <= max_label) { + idx = indices[label - min_label]; + doit = idx >= 0; + } else { + doit = 0; + } + } else { + doit = label != 0; + } + if (doit) { + double val; + NI_GET_VALUE(pi, val, input->descr->type_num); + if (sum) + sum[idx] += val; + if (total) + total[idx]++; + if (minimum && val < minimum[idx]) { + minimum[idx] = val; + if (min_pos) + min_pos[idx] = jj; + } + if (maximum && (val > maximum[idx])) { + maximum[idx] = val; + if (max_pos) + max_pos[idx] = jj; + } + } + if (labels) { + NI_ITERATOR_NEXT2(ii, mi, pi, pm); + } else { + NI_ITERATOR_NEXT(ii, pi); + } + } + if (minimum) { + for(jj = 0; jj < n_results; jj++) { + if (!(minimum[jj] < DBL_MAX)) + minimum[jj] = 0.0; + } + } + if (maximum) { + for(jj = 0; jj < n_results; jj++) { + if (!(maximum[jj] > -DBL_MAX)) + maximum[jj] = 0.0; + } + } + if (variance) { + int do_var = 0; + for(jj = 0; jj < n_results; jj++) + if (total[jj] > 1) { + do_var = 1; + break; + } + if (do_var) { + /* reset input iterator: */ + NI_ITERATOR_RESET(ii); + pi = (void *)PyArray_DATA(input); + if (labels) { + /* reset label iterator: */ + NI_ITERATOR_RESET(mi); + pm = (void *)PyArray_DATA(labels); + } + for(jj = 0; jj < size; jj++) { + NI_GET_LABEL(pm, label, labels->descr->type_num); + if (min_label >= 0) { + if (label >= min_label && label <= max_label) { + idx = indices[label - min_label]; + doit = idx >= 0; + } else { + doit = 0; + } + } else { + doit = label != 0; + } + if (doit) { + double val; + NI_GET_VALUE(pi, val, input->descr->type_num); + val = val - sum[idx] / total[idx]; + variance[idx] += val * val; + } + if (labels) { + NI_ITERATOR_NEXT2(ii, mi, pi, pm); + } else { + NI_ITERATOR_NEXT(ii, pi); + } + } + for(jj = 0; jj < n_results; jj++) + variance[jj] = (total[jj] > 1 ? + variance[jj] / (total[jj] - 1) : 0.0); + } + } + return 1; +} + + +int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels, + maybelong min_label, maybelong max_label, maybelong *indices, + maybelong n_results, double *center_of_mass) +{ + char *pi = NULL, *pm = NULL; + NI_Iterator ii, mi; + maybelong jj, kk, size, idx = 0, label = 1, doit = 1; + double *sum = NULL; + int qq; + + /* input iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* input data: */ + pi = (void *)PyArray_DATA(input); + if (labels) { + if (!NI_InitPointIterator(labels, &mi)) + goto exit; + pm = (void *)PyArray_DATA(labels); + } + /* input size: */ + size = 1; + for(qq = 0; qq < input->nd; qq++) + size *= input->dimensions[qq]; + sum = (double*)malloc(n_results * sizeof(double)); + if (!sum) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < n_results; jj++) { + sum[jj] = 0.0; + for(kk = 0; kk < input->nd; kk++) + center_of_mass[jj * input->nd + kk] = 0.0; + } + /* iterate over array: */ + for(jj = 0; jj < size; jj++) { + NI_GET_LABEL(pm, label, labels->descr->type_num); + if (min_label >= 0) { + if (label >= min_label && label <= max_label) { + idx = indices[label - min_label]; + doit = idx >= 0; + } else { + doit = 0; + } + } else { + doit = label != 0; + } + if (doit) { + double val; + NI_GET_VALUE(pi, val, input->descr->type_num); + sum[idx] += val; + for(kk = 0; kk < input->nd; kk++) + center_of_mass[idx * input->nd + kk] += val * ii.coordinates[kk]; + } + if (labels) { + NI_ITERATOR_NEXT2(ii, mi, pi, pm); + } else { + NI_ITERATOR_NEXT(ii, pi); + } + } + for(jj = 0; jj < n_results; jj++) + for(kk = 0; kk < input->nd; kk++) + center_of_mass[jj * input->nd + kk] /= sum[jj]; + exit: + if (sum) + free(sum); + return PyErr_Occurred() == NULL; +} + + +int NI_Histogram(PyArrayObject *input, PyArrayObject *labels, + maybelong min_label, maybelong max_label, maybelong *indices, + maybelong n_results, PyArrayObject **histograms, + double min, double max, maybelong nbins) +{ + char *pi = NULL, *pm = NULL; + NI_Iterator ii, mi; + maybelong jj, kk, size, idx = 0, label = 1, doit = 1; + Int32 **ph = NULL; + double bsize; + int qq; + + /* input iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* input data: */ + pi = (void *)PyArray_DATA(input); + if (labels) { + if (!NI_InitPointIterator(labels, &mi)) + goto exit; + pm = (void *)PyArray_DATA(labels); + } + ph = (Int32**)malloc(n_results * sizeof(Int32*)); + if (!ph) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < n_results; jj++) { + ph[jj] = (Int32*)PyArray_DATA(histograms[jj]); + for(kk = 0; kk < nbins; kk++) + ph[jj][kk] = 0; + } + bsize = (max - min) / (double)nbins; + /* input size: */ + size = 1; + for(qq = 0; qq < input->nd; qq++) + size *= input->dimensions[qq]; + /* iterate over array: */ + for(jj = 0; jj < size; jj++) { + NI_GET_LABEL(pm, label, labels->descr->type_num); + if (min_label >= 0) { + if (label >= min_label && label <= max_label) { + idx = indices[label - min_label]; + doit = idx >= 0; + } else { + doit = 0; + } + } else { + doit = label != 0; + } + if (doit) { + int bin; + double val; + NI_GET_VALUE(pi, val, input->descr->type_num); + if (val >= min && val < max) { + bin = (int)((val - min) / bsize); + ++(ph[idx][bin]); + } + } + if (labels) { + NI_ITERATOR_NEXT2(ii, mi, pi, pm); + } else { + NI_ITERATOR_NEXT(ii, pi); + } + } + exit: + if (ph) + free(ph); + return PyErr_Occurred() == NULL; +} + +#define WS_GET_INDEX(_index, _c_strides, _b_strides, _rank, _out, \ + _contiguous, _type) \ +do { \ + if (_contiguous) { \ + _out = _index * sizeof(_type); \ + } else { \ + int _qq; \ + maybelong _cc, _idx = _index; \ + _out = 0; \ + for (_qq = 0; _qq < _rank; _qq++) { \ + _cc = _idx / _c_strides[_qq]; \ + _idx -= _cc * _c_strides[_qq]; \ + _out += _b_strides[_qq] * _cc; \ + } \ + } \ +} while(0) + +#define CASE_GET_INPUT(_ival, _pi, _type) \ +case t ## _type: \ + _ival = *((_type*)_pi); \ + break + +#define CASE_GET_LABEL(_label, _pm, _type) \ +case t ## _type: \ + _label = *(_type*)_pm; \ + break + +#define CASE_PUT_LABEL(_label, _pl, _type) \ +case t ## _type: \ + *((_type*)_pl) = _label; \ + break + +#define CASE_WINDEX1(_v_index, _p_index, _strides, _istrides, _irank, \ + _icont, _p_idx, _v_idx, _pi, _vval, _pval, _type) \ +case t ## _type: \ + WS_GET_INDEX(_v_index, _strides, _istrides, _irank, _p_idx, _icont, \ + _type); \ + WS_GET_INDEX(_p_index, _strides, _istrides, _irank, _v_idx, _icont, \ + _type); \ + _vval = *(_type*)(_pi + _v_idx); \ + _pval = *(_type*)(_pi + _p_idx); \ + break + +#define CASE_WINDEX2(_v_index, _strides, _ostrides, _irank, _idx, \ + _ocont, _label, _pl, _type) \ +case t ## _type: \ + WS_GET_INDEX(_v_index, _strides, _ostrides, _irank, _idx, \ + _ocont, _type); \ + _label = *(_type*)(_pl + _idx); \ + break + +#define CASE_WINDEX3(_p_index, _strides, _ostrides, _irank, _idx, \ + _ocont, _label, _pl, _type) \ +case t ## _type: \ + WS_GET_INDEX(_p_index, _strides, _ostrides, _irank, _idx, \ + _ocont, _type); \ + *(_type*)(_pl + _idx) = _label; \ +break + +#define DONE_TYPE UInt8 +#define COST_TYPE UInt16 +#define WS_MAXDIM 7 + +typedef struct { + maybelong index; + COST_TYPE cost; + void *next, *prev; + DONE_TYPE done; +} NI_WatershedElement; + +int NI_WatershedIFT(PyArrayObject* input, PyArrayObject* markers, + PyArrayObject* strct, PyArrayObject* output) +{ + char *pl, *pm, *pi; + int ll; + maybelong size, jj, hh, kk, maxval; + maybelong strides[WS_MAXDIM], coordinates[WS_MAXDIM]; + maybelong *nstrides = NULL, nneigh, ssize; + int i_contiguous, o_contiguous; + NI_WatershedElement *temp = NULL, **first = NULL, **last = NULL; + Bool *ps = NULL; + NI_Iterator mi, ii, li; + + i_contiguous = PyArray_ISCONTIGUOUS(input); + o_contiguous = PyArray_ISCONTIGUOUS(output); + ssize = 1; + for(ll = 0; ll < strct->nd; ll++) + ssize *= strct->dimensions[ll]; + if (input->nd > WS_MAXDIM) { + PyErr_SetString(PyExc_RuntimeError, "too many dimensions"); + goto exit; + } + size = 1; + for(ll = 0; ll < input->nd; ll++) + size *= input->dimensions[ll]; + /* Storage for the temporary queue data. */ + temp = (NI_WatershedElement*)malloc(size * sizeof(NI_WatershedElement)); + if (!temp) { + PyErr_NoMemory(); + goto exit; + } + pi = (void *)PyArray_DATA(input); + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* Initialization and find the maximum of the input. */ + maxval = 0; + for(jj = 0; jj < size; jj++) { + int ival = 0; + switch(input->descr->type_num) { + CASE_GET_INPUT(ival, pi, UInt8); + CASE_GET_INPUT(ival, pi, UInt16); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + temp[jj].index = jj; + temp[jj].done = 0; + if (ival > maxval) + maxval = ival; + NI_ITERATOR_NEXT(ii, pi); + } + pi = (void *)PyArray_DATA(input); + /* Allocate and initialize the storage for the queue. */ + first = (NI_WatershedElement**)malloc((maxval + 1) * + sizeof(NI_WatershedElement*)); + last = (NI_WatershedElement**)malloc((maxval + 1) * + sizeof(NI_WatershedElement*)); + if (!first || !last) { + PyErr_NoMemory(); + goto exit; + } + for(hh = 0; hh <= maxval; hh++) { + first[hh] = NULL; + last[hh] = NULL; + } + if (!NI_InitPointIterator(markers, &mi)) + goto exit; + if (!NI_InitPointIterator(output, &li)) + goto exit; + pm = (void *)PyArray_DATA(markers); + pl = (void *)PyArray_DATA(output); + /* initialize all nodes */ + for(ll = 0; ll < input->nd; ll++) + coordinates[ll] = 0; + for(jj = 0; jj < size; jj++) { + /* get marker */ + int label = 0; + switch(markers->descr->type_num) { + CASE_GET_LABEL(label, pm, UInt8); + CASE_GET_LABEL(label, pm, UInt16); + CASE_GET_LABEL(label, pm, UInt32); +#if HAS_UINT64 + CASE_GET_LABEL(label, pm, UInt64); +#endif + CASE_GET_LABEL(label, pm, Int8); + CASE_GET_LABEL(label, pm, Int16); + CASE_GET_LABEL(label, pm, Int32); + CASE_GET_LABEL(label, pm, Int64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + switch(output->descr->type_num) { + CASE_PUT_LABEL(label, pl, UInt8); + CASE_PUT_LABEL(label, pl, UInt16); + CASE_PUT_LABEL(label, pl, UInt32); +#if HAS_UINT64 + CASE_PUT_LABEL(label, pl, UInt64); +#endif + CASE_PUT_LABEL(label, pl, Int8); + CASE_PUT_LABEL(label, pl, Int16); + CASE_PUT_LABEL(label, pl, Int32); + CASE_PUT_LABEL(label, pl, Int64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + NI_ITERATOR_NEXT2(mi, li, pm, pl); + if (label != 0) { + /* This node is a marker */ + temp[jj].cost = 0; + if (!first[0]) { + first[0] = &(temp[jj]); + first[0]->next = NULL; + first[0]->prev = NULL; + last[0] = first[0]; + } else { + if (label > 0) { + /* object markers are enqueued at the beginning, so they are + processed first. */ + temp[jj].next = first[0]; + temp[jj].prev = NULL; + first[0]->prev = &(temp[jj]); + first[0] = &(temp[jj]); + } else { + /* background markers are enqueued at the end, so they are + processed after the object markers. */ + temp[jj].next = NULL; + temp[jj].prev = last[0]; + last[0]->next = &(temp[jj]); + last[0] = &(temp[jj]); + } + } + } else { + /* This node is not a marker */ + temp[jj].cost = maxval + 1; + temp[jj].next = NULL; + temp[jj].prev = NULL; + } + for(ll = input->nd - 1; ll >= 0; ll--) + if (coordinates[ll] < input->dimensions[ll] - 1) { + coordinates[ll]++; + break; + } else { + coordinates[ll] = 0; + } + } + + pl = (void *)PyArray_DATA(output); + ps = (Bool*)PyArray_DATA(strct); + nneigh = 0; + for (kk = 0; kk < ssize; kk++) + if (ps[kk] && kk != (ssize / 2)) + ++nneigh; + nstrides = (maybelong*)malloc(nneigh * sizeof(maybelong)); + if (!nstrides) { + PyErr_NoMemory(); + goto exit; + } + strides[input->nd - 1] = 1; + for(ll = input->nd - 2; ll >= 0; ll--) + strides[ll] = input->dimensions[ll + 1] * strides[ll + 1]; + for(ll = 0; ll < input->nd; ll++) + coordinates[ll] = -1; + for(kk = 0; kk < nneigh; kk++) + nstrides[kk] = 0; + jj = 0; + for(kk = 0; kk < ssize; kk++) { + if (ps[kk]) { + int offset = 0; + for(ll = 0; ll < input->nd; ll++) + offset += coordinates[ll] * strides[ll]; + if (offset != 0) + nstrides[jj++] += offset; + } + for(ll = input->nd - 1; ll >= 0; ll--) + if (coordinates[ll] < 1) { + coordinates[ll]++; + break; + } else { + coordinates[ll] = -1; + } + } + /* Propagation phase: */ + for(jj = 0; jj <= maxval; jj++) { + while (first[jj]) { + /* dequeue first element: */ + NI_WatershedElement *v = first[jj]; + first[jj] = first[jj]->next; + if (first[jj]) + first[jj]->prev = NULL; + v->prev = NULL; + v->next = NULL; + /* Mark element as done: */ + v->done = 1; + /* Iterate over the neighbors of the element: */ + for(hh = 0; hh < nneigh; hh++) { + maybelong v_index = v->index, p_index = v->index, idx, cc; + int qq, outside = 0; + p_index += nstrides[hh]; + /* check if the neighbor is within the extent of the array: */ + idx = p_index; + for (qq = 0; qq < input->nd; qq++) { + cc = idx / strides[qq]; + if (cc < 0 || cc >= input->dimensions[qq]) { + outside = 1; + break; + } + idx -= cc * strides[qq]; + } + if (!outside) { + NI_WatershedElement *p = &(temp[p_index]); + if (!(p->done)) { + /* If the neighbor was not processed yet: */ + int max, pval, vval, wvp, pcost, label, p_idx, v_idx; + switch(input->descr->type_num) { + CASE_WINDEX1(v_index, p_index, strides, input->strides, + input->nd, i_contiguous, p_idx, v_idx, pi, + vval, pval, UInt8); + CASE_WINDEX1(v_index, p_index, strides, input->strides, + input->nd, i_contiguous, p_idx, v_idx, pi, + vval, pval, UInt16); + default: + PyErr_SetString(PyExc_RuntimeError, + "data type not supported"); + goto exit; + } + /* Calculate cost: */ + wvp = pval - vval; + if (wvp < 0) + wvp = -wvp; + /* Find the maximum of this cost and the current + element cost: */ + pcost = p->cost; + max = v->cost > wvp ? v->cost : wvp; + if (max < pcost) { + /* If this maximum is less than the neighbors cost, + adapt the cost and the label of the neighbor: */ + int idx; + p->cost = max; + switch(output->descr->type_num) { + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt8); + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt16); + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt32); +#if HAS_UINT64 + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt64); +#endif + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int8); + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int16); + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int32); + CASE_WINDEX2(v_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int64); + default: + PyErr_SetString(PyExc_RuntimeError, + "data type not supported"); + goto exit; + } + switch(output->descr->type_num) { + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt8); + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt16); + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt32); +#if HAS_UINT64 + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, UInt64); +#endif + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int8); + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int16); + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int32); + CASE_WINDEX3(p_index, strides, output->strides, input->nd, + idx, o_contiguous, label, pl, Int64); + default: + PyErr_SetString(PyExc_RuntimeError, + "data type not supported"); + goto exit; + } + /* If the neighbor is in a queue, remove it: */ + if (p->next || p->prev) { + NI_WatershedElement *prev = p->prev, *next = p->next; + if (first[pcost] == p) + first[pcost] = next; + if (last[pcost] == p) + last[pcost] = prev; + if (prev) + prev->next = next; + if (next) + next->prev = prev; + } + /* Insert the neighbor in the appropiate queue: */ + if (label < 0) { + p->prev = last[max]; + p->next = NULL; + if (last[max]) + last[max]->next = p; + last[max] = p; + if (!first[max]) + first[max] = p; + } else { + p->next = first[max]; + p->prev = NULL; + if (first[max]) + first[max]->prev = p; + first[max] = p; + if (!last[max]) + last[max] = p; + } + } + } + } + } + } + } + exit: + if (temp) + free(temp); + if (first) + free(first); + if (last) + free(last); + if (nstrides) + free(nstrides); + return PyErr_Occurred() ? 0 : 1; +} Modified: trunk/scipy/ndimage/src/ni_measure.h =================================================================== --- trunk/scipy/ndimage/src/ni_measure.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_measure.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,59 +1,59 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NI_MEASURE_H -#define NI_MEASURE_H - -#include "nd_image.h" - -/* structure for array regions to find objects: */ -typedef struct { - int start[NI_MAXDIM], end[NI_MAXDIM]; -} NI_ObjectRegion; - -int NI_Label(PyArrayObject*, PyArrayObject*, maybelong*, PyArrayObject*); - -int NI_FindObjects(PyArrayObject*, maybelong, maybelong*); - -int NI_CenterOfMass(PyArrayObject*, PyArrayObject*, maybelong, maybelong, - maybelong*, maybelong, double*); - -int NI_Histogram(PyArrayObject*, PyArrayObject*, maybelong, maybelong, - maybelong*, maybelong, PyArrayObject**, double, double, maybelong); - -int NI_Statistics(PyArrayObject*, PyArrayObject*, maybelong, maybelong, - maybelong*, maybelong, double*, maybelong*, double*, - double*, double*, maybelong*, maybelong*); - -int NI_WatershedIFT(PyArrayObject*, PyArrayObject*, PyArrayObject*, - PyArrayObject*); - -#endif +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NI_MEASURE_H +#define NI_MEASURE_H + +#include "nd_image.h" + +/* structure for array regions to find objects: */ +typedef struct { + int start[NI_MAXDIM], end[NI_MAXDIM]; +} NI_ObjectRegion; + +int NI_Label(PyArrayObject*, PyArrayObject*, maybelong*, PyArrayObject*); + +int NI_FindObjects(PyArrayObject*, maybelong, maybelong*); + +int NI_CenterOfMass(PyArrayObject*, PyArrayObject*, maybelong, maybelong, + maybelong*, maybelong, double*); + +int NI_Histogram(PyArrayObject*, PyArrayObject*, maybelong, maybelong, + maybelong*, maybelong, PyArrayObject**, double, double, maybelong); + +int NI_Statistics(PyArrayObject*, PyArrayObject*, maybelong, maybelong, + maybelong*, maybelong, double*, maybelong*, double*, + double*, double*, maybelong*, maybelong*); + +int NI_WatershedIFT(PyArrayObject*, PyArrayObject*, PyArrayObject*, + PyArrayObject*); + +#endif Modified: trunk/scipy/ndimage/src/ni_morphology.c =================================================================== --- trunk/scipy/ndimage/src/ni_morphology.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_morphology.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,955 +1,955 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ni_support.h" -#include "ni_morphology.h" -#include -#include -#include -#include - -#define LIST_SIZE 100000 - -#define CASE_GET_MASK(_msk_value, _pm, _type) \ -case t ## _type: \ - _msk_value = *(_type*)_pm ? 1 : 0; \ - break - -#define CASE_OUTPUT(_po, _out, _type) \ -case t ## _type: \ - *(_type*)_po = (_type)_out; \ - break - -#define CASE_NI_ERODE_POINT(_pi, _out, _offsets, _filter_size, _type, \ - _mv, _border_value, _bv, _center_is_true,\ - _true, _false, _changed) \ -case t ## _type: \ -{ \ - maybelong _ii, _oo; \ - int _in = *(_type*)_pi ? 1 : 0; \ - if (_mv) { \ - if (_center_is_true && _in == false) { \ - _changed = 0; \ - _out = _in; \ - } else { \ - _out = _true; \ - for(_ii = 0; _ii < _filter_size; _ii++) { \ - _oo = _offsets[_ii]; \ - if (_oo == _bv) { \ - if (!_border_value) { \ - _out = _false; \ - break; \ - } \ - } else { \ - int _nn = *(_type*)(_pi + _oo) ? _true : _false; \ - if (!_nn) { \ - _out = _false; \ - break; \ - } \ - } \ - } \ - _changed = _out != _in; \ - } \ - } else { \ - _out = _in; \ - } \ -} \ -break - -int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct, - PyArrayObject* mask, PyArrayObject* output, int bdr_value, - maybelong *origins, int invert, int center_is_true, int* changed, - NI_CoordinateList **coordinate_list) -{ - maybelong struct_size = 0, *offsets = NULL, size, *oo, jj; - maybelong ssize, block_size = 0, *current = NULL, border_flag_value; - int kk, true, false, msk_value; - NI_Iterator ii, io, mi; - NI_FilterIterator fi; - Bool *ps, out = 0; - char *pi, *po, *pm = NULL; - NI_CoordinateBlock *block = NULL; - - ps = (Bool*)PyArray_DATA(strct); - ssize = 1; - for(kk = 0; kk < strct->nd; kk++) - ssize *= strct->dimensions[kk]; - for(jj = 0; jj < ssize; jj++) - if (ps[jj]) ++struct_size; - if (mask) { - if (!NI_InitPointIterator(mask, &mi)) - return 0; - pm = (void *)PyArray_DATA(mask); - } - /* calculate the filter offsets: */ - if (!NI_InitFilterOffsets(input, ps, strct->dimensions, origins, - NI_EXTEND_CONSTANT, &offsets, &border_flag_value, NULL)) - goto exit; - /* initialize input element iterator: */ - if (!NI_InitPointIterator(input, &ii)) - goto exit; - /* initialize output element iterator: */ - if (!NI_InitPointIterator(output, &io)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, strct->dimensions, struct_size, - input->dimensions, origins, &fi)) - goto exit; - - /* get data pointers an size: */ - pi = (void *)PyArray_DATA(input); - po = (void *)PyArray_DATA(output); - size = 1; - for(kk = 0; kk < input->nd; kk++) - size *= input->dimensions[kk]; - if (invert) { - bdr_value = bdr_value ? 0 : 1; - true = 0; - false = 1; - } else { - bdr_value = bdr_value ? 1 : 0; - true = 1; - false = 0; - } - if (coordinate_list) { - block_size = LIST_SIZE / input->nd / sizeof(int); - if (block_size < 1) - block_size = 1; - if (block_size > size) - block_size = size; - *coordinate_list = NI_InitCoordinateList(block_size, input->nd); - if (!*coordinate_list) - goto exit; - } - /* iterator over the elements: */ - oo = offsets; - *changed = 0; - msk_value = 1; - for(jj = 0; jj < size; jj++) { - int pchange = 0; - if (mask) { - switch(mask->descr->type_num) { - CASE_GET_MASK(msk_value, pm, Bool); - CASE_GET_MASK(msk_value, pm, UInt8); - CASE_GET_MASK(msk_value, pm, UInt16); - CASE_GET_MASK(msk_value, pm, UInt32); -#if HAS_UINT64 - CASE_GET_MASK(msk_value, pm, UInt64); -#endif - CASE_GET_MASK(msk_value, pm, Int8); - CASE_GET_MASK(msk_value, pm, Int16); - CASE_GET_MASK(msk_value, pm, Int32); - CASE_GET_MASK(msk_value, pm, Int64); - CASE_GET_MASK(msk_value, pm, Float32); - CASE_GET_MASK(msk_value, pm, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - return 0; - } - } - switch (input->descr->type_num) { - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Bool, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt8, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt16, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt32, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); -#if HAS_UINT64 - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt64, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); -#endif - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int8, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int16, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int32, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int64, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float32, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float64, msk_value, - bdr_value, border_flag_value, center_is_true, - true, false, pchange); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - switch (output->descr->type_num) { - CASE_OUTPUT(po, out, Bool); - CASE_OUTPUT(po, out, UInt8); - CASE_OUTPUT(po, out, UInt16); - CASE_OUTPUT(po, out, UInt32); -#if HAS_UINT64 - CASE_OUTPUT(po, out, UInt64); -#endif - CASE_OUTPUT(po, out, Int8); - CASE_OUTPUT(po, out, Int16); - CASE_OUTPUT(po, out, Int32); - CASE_OUTPUT(po, out, Int64); - CASE_OUTPUT(po, out, Float32); - CASE_OUTPUT(po, out, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - if (pchange) { - *changed = 1; - if (coordinate_list) { - if (block == NULL || block->size == block_size) { - block = NI_CoordinateListAddBlock(*coordinate_list); - current = block->coordinates; - } - for(kk = 0; kk < input->nd; kk++) - *current++ = ii.coordinates[kk]; - block->size++; - } - } - if (mask) { - NI_FILTER_NEXT3(fi, ii, io, mi, oo, pi, po, pm); - } else { - NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); - } - } - - exit: - if (offsets) - free(offsets); - if (PyErr_Occurred()) { - if (coordinate_list) { - NI_FreeCoordinateList(*coordinate_list); - *coordinate_list = NULL; - } - return 0; - } else { - return 1; - } - return PyErr_Occurred() ? 0 : 1; -} - -#define CASE_ERODE_POINT2(_struct_size, _offsets, _coordinate_offsets, \ - _pi, _oo, _irank, _list1, _list2, \ - _current_coors1, _current_coors2, _block1, \ - _block2, _bf_value, _true, _false, _type, \ - _mklist) \ -case t ## _type: \ -{ \ - maybelong _hh, _kk; \ - for(_hh = 0; _hh < _struct_size; _hh++) { \ - maybelong _to = _offsets[_oo + _hh]; \ - if (_to != _bf_value && *(_type*)(_pi + _to) == _true) { \ - if (_mklist) { \ - maybelong *_tc = &(_coordinate_offsets[(_oo + _hh) * _irank]); \ - if (_block2 == NULL || _block2->size == _list2->block_size) { \ - _block2 = NI_CoordinateListAddBlock(_list2); \ - _current_coors2 = _block2->coordinates; \ - } \ - for(_kk = 0; _kk < _irank; _kk++) \ - *_current_coors2++ = _current_coors1[_kk] + _tc[_kk]; \ - _block2->size++; \ - } \ - *(_type*)(_pi + _to) = _false; \ - } \ - } \ -} \ -break - -int NI_BinaryErosion2(PyArrayObject* array, PyArrayObject* strct, - PyArrayObject* mask, int niter, maybelong *origins, - int invert, NI_CoordinateList **iclist) -{ - maybelong struct_size = 0, *offsets = NULL, oo, jj, ssize; - maybelong *coordinate_offsets = NULL, size = 0; - maybelong *current_coordinates1 = NULL, *current_coordinates2 = NULL; - maybelong kk, border_flag_value, current = 0; - int true, false; - NI_Iterator ii, mi; - NI_FilterIterator fi, ci; - Bool *ps; - char *pi, *ibase, *pm = NULL; - NI_CoordinateBlock *block1 = NULL, *block2 = NULL; - NI_CoordinateList *list1 = NULL, *list2 = NULL; - - ps = (Bool*)PyArray_DATA(strct); - ssize = 1; - for(kk = 0; kk < strct->nd; kk++) - ssize *= strct->dimensions[kk]; - for(jj = 0; jj < ssize; jj++) - if (ps[jj]) ++struct_size; - - /* calculate the filter offsets: */ - if (!NI_InitFilterOffsets(array, ps, strct->dimensions, origins, - NI_EXTEND_CONSTANT, &offsets, - &border_flag_value, &coordinate_offsets)) - goto exit; - - /* initialize input element iterator: */ - if (!NI_InitPointIterator(array, &ii)) - goto exit; - - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size, - array->dimensions, origins, &fi)) - goto exit; - if (!NI_InitFilterIterator(array->nd, strct->dimensions, - struct_size * array->nd, array->dimensions, - origins, &ci)) - goto exit; - - /* get data pointers and size: */ - ibase = pi = (void *)PyArray_DATA(array); - - if (invert) { - true = 0; - false = 1; - } else { - true = 1; - false = 0; - } - - if (mask) { - /* iterator, data pointer and type of mask array: */ - if (!NI_InitPointIterator(mask, &mi)) - return 0; - pm = (void *)PyArray_DATA(mask); - - size = 1; - for(kk = 0; kk < array->nd; kk++) - size *= array->dimensions[kk]; - - for(jj = 0; jj < size; jj++) { - if (*(Int8*)pm) { - *(Int8*)pm = -1; - } else { - *(Int8*)pm = (Int8)*(Bool*)pi; - *(Bool*)pi = false; - } - NI_ITERATOR_NEXT2(ii, mi, pi, pm) - } - NI_ITERATOR_RESET(ii) - pi = (void *)PyArray_DATA(array); - } - - list1 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank); - list2 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank); - if (!list1 || !list2) - goto exit; - if (NI_CoordinateListStealBlocks(list2, *iclist)) - goto exit; - block2 = list2->blocks; - jj = 0; - while(block1 || block2) { - int mklist = 1; - if (!block1) { - if (niter <= 0 || jj < niter) { - if (NI_CoordinateListStealBlocks(list1, list2)) - goto exit; - block1 = list1->blocks; - block2 = NULL; - current_coordinates1 = block1->coordinates; - current = 0; - ++jj; - mklist = niter <= 0 || jj < niter; - } else { - break; - } - } - NI_ITERATOR_GOTO(ii, current_coordinates1, ibase, pi); - NI_FILTER_GOTO(fi, ii, 0, oo); - - switch (array->descr->type_num) { - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Bool, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, UInt8, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, UInt16, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, UInt32, mklist); -#if HAS_UINT64 - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, UInt64, mklist); -#endif - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Int8, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Int16, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Int32, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Int64, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Float32, mklist); - CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, - border_flag_value, true, false, Float64, mklist); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - goto exit; - } - - ++current; - if (current == block1->size) { - block1 = NI_CoordinateListDeleteBlock(list1); - if (block1) { - current_coordinates1 = block1->coordinates; - current = 0; - } - } else { - current_coordinates1 += array->nd; - } - } - - if (mask) { - NI_ITERATOR_RESET(ii) - NI_ITERATOR_RESET(mi) - pi = (void *)PyArray_DATA(array); - pm = (void *)PyArray_DATA(mask); - for(jj = 0; jj < size; jj++) { - int value = *(Int8*)pm; - if (value >= 0) - *(Bool*)pi = value; - NI_ITERATOR_NEXT2(ii, mi, pi, pm) - } - } - - exit: - if (offsets) - free(offsets); - if (coordinate_offsets) - free(coordinate_offsets); - NI_FreeCoordinateList(list1); - NI_FreeCoordinateList(list2); - if (PyErr_Occurred()) { - return 0; - } else { - return 1; - } - return PyErr_Occurred() ? 0 : 1; -} - - -#define NI_DISTANCE_EUCLIDIAN 1 -#define NI_DISTANCE_CITY_BLOCK 2 -#define NI_DISTANCE_CHESSBOARD 3 - -typedef struct { - maybelong *coordinates; - maybelong index; - void *next; -} NI_BorderElement; - -int NI_DistanceTransformBruteForce(PyArrayObject* input, int metric, - PyArrayObject *sampling_arr, - PyArrayObject* distances, - PyArrayObject* features) -{ - maybelong size, jj, min_index = 0; - int kk; - NI_BorderElement *border_elements = NULL, *temp; - NI_Iterator ii, di, fi; - char *pi, *pd = NULL, *pf = NULL; - Float64 *sampling = sampling_arr ? (void *)PyArray_DATA(sampling_arr) : NULL; - - /* check the output arrays: */ - if (distances) { - pd = (void *)PyArray_DATA(distances); - if (!NI_InitPointIterator(distances, &di)) - goto exit; - } - - if (features) { - pf = (void *)PyArray_DATA(features); - if (!NI_InitPointIterator(features, &fi)) - goto exit; - } - - size = 1; - for(kk = 0; kk < input->nd; kk++) - size *= input->dimensions[kk]; - pi = (void *)PyArray_DATA(input); - - if (!NI_InitPointIterator(input, &ii)) - goto exit; - - for(jj = 0; jj < size; jj++) { - if (*(Int8*)pi < 0) { - temp = (NI_BorderElement*)malloc(sizeof(NI_BorderElement)); - if (!temp) { - PyErr_NoMemory(); - goto exit; - } - temp->next = border_elements; - border_elements = temp; - temp->index = jj; - temp->coordinates = (maybelong*)malloc(input->nd * sizeof(maybelong)); - for(kk = 0; kk < input->nd; kk++) - temp->coordinates[kk] = ii.coordinates[kk]; - } - NI_ITERATOR_NEXT(ii, pi); - } - - NI_ITERATOR_RESET(ii); - pi = (void *)PyArray_DATA(input); - - switch(metric) { - case NI_DISTANCE_EUCLIDIAN: - for(jj = 0; jj < size; jj++) { - if (*(Int8*)pi > 0) { - double distance = DBL_MAX; - temp = border_elements; - while(temp) { - double d = 0.0, t; - for(kk = 0; kk < input->nd; kk++) { - t = ii.coordinates[kk] - temp->coordinates[kk]; - if (sampling) - t *= sampling[kk]; - d += t * t; - } - if (d < distance) { - distance = d; - if (features) - min_index = temp->index; - } - temp = temp->next; - } - if (distances) - *(Float64*)pd = sqrt(distance); - if (features) - *(Int32*)pf = min_index; - } else { - if (distances) - *(Float64*)pd = 0.0; - if (features) - *(Int32*)pf = jj; - } - if (features && distances) { - NI_ITERATOR_NEXT3(ii, di, fi, pi, pd, pf); - } else if (distances) { - NI_ITERATOR_NEXT2(ii, di, pi, pd); - } else { - NI_ITERATOR_NEXT2(ii, fi, pi, pf); - } - } - break; - case NI_DISTANCE_CITY_BLOCK: - case NI_DISTANCE_CHESSBOARD: - for(jj = 0; jj < size; jj++) { - if (*(Int8*)pi > 0) { - unsigned long distance = ULONG_MAX; - temp = border_elements; - while(temp) { - unsigned int d = 0; - maybelong t; - for(kk = 0; kk < input->nd; kk++) { - t = ii.coordinates[kk] - temp->coordinates[kk]; - if (t < 0) - t = -t; - if (metric == NI_DISTANCE_CITY_BLOCK) { - d += t; - } else { - if ((unsigned int)t > d) - d = t; - } - } - if (d < distance) { - distance = d; - if (features) - min_index = temp->index; - } - temp = temp->next; - } - if (distances) - *(UInt32*)pd = distance; - if (features) - *(Int32*)pf = min_index; - } else { - if (distances) - *(UInt32*)pd = 0; - if (features) - *(Int32*)pf = jj; - } - if (features && distances) { - NI_ITERATOR_NEXT3(ii, di, fi, pi, pd, pf); - } else if (distances) { - NI_ITERATOR_NEXT2(ii, di, pi, pd); - } else { - NI_ITERATOR_NEXT2(ii, fi, pi, pf); - } - } - break; - default: - PyErr_SetString(PyExc_RuntimeError, "distance metric not supported"); - goto exit; - } - - exit: - while (border_elements) { - temp = border_elements; - border_elements = border_elements->next; - if (temp->coordinates) - free(temp->coordinates); - free(temp); - } - return PyErr_Occurred() ? 0 : 1; -} - - -int NI_DistanceTransformOnePass(PyArrayObject *strct, - PyArrayObject* distances, PyArrayObject *features) -{ - int kk; - maybelong jj, ii, ssize, size, filter_size, mask_value, *oo; - maybelong *foffsets = NULL, *foo = NULL, *offsets = NULL; - Bool *ps, *pf = NULL, *footprint = NULL; - char *pd; - NI_FilterIterator si, ti; - NI_Iterator di, fi; - - ssize = 1; - for(kk = 0; kk < strct->nd; kk++) - ssize *= strct->dimensions[kk]; - - /* we only use the first half of the structure data, so we make a - temporary structure for use with the filter functions: */ - footprint = (Bool*)malloc(ssize * sizeof(Bool)); - if (!footprint) { - PyErr_NoMemory(); - goto exit; - } - ps = (Bool*)PyArray_DATA(strct); - filter_size = 0; - for(jj = 0; jj < ssize / 2; jj++) { - footprint[jj] = ps[jj]; - if (ps[jj]) - ++filter_size; - } - for(jj = ssize / 2; jj < ssize; jj++) - footprint[jj] = 0; - /* get data and size */ - pd = (void *)PyArray_DATA(distances); - size = 1; - for(kk = 0; kk < distances->nd; kk++) - size *= distances->dimensions[kk]; - if (!NI_InitPointIterator(distances, &di)) - goto exit; - /* calculate the filter offsets: */ - if (!NI_InitFilterOffsets(distances, footprint, strct->dimensions, NULL, - NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(distances->nd, strct->dimensions, - filter_size, distances->dimensions, NULL, &si)) - goto exit; - - if (features) { - maybelong dummy; - /* initialize point iterator: */ - pf = (void *)PyArray_DATA(features); - if (!NI_InitPointIterator(features, &fi)) - goto exit; - /* calculate the filter offsets: */ - if (!NI_InitFilterOffsets(features, footprint, strct->dimensions, - NULL, NI_EXTEND_CONSTANT, &foffsets, &dummy, NULL)) - goto exit; - /* initialize filter iterator: */ - if (!NI_InitFilterIterator(distances->nd, strct->dimensions, - filter_size, distances->dimensions, NULL, &ti)) - goto exit; - } - /* iterator over the elements: */ - oo = offsets; - if (features) - foo = foffsets; - for(jj = 0; jj < size; jj++) { - Int32 value = *(Int32*)pd; - if (value != 0) { - Int32 min = value; - maybelong min_offset = 0; - /* iterate over structuring element: */ - for(ii = 0; ii < filter_size; ii++) { - maybelong offset = oo[ii]; - Int32 tt = -1; - if (offset < mask_value) - tt = *(Int32*)(pd + offset); - if (tt >= 0) { - if ((min < 0) || (tt + 1 < min)) { - min = tt + 1; - if (features) - min_offset = foo[ii]; - } - } - } - *(Int32*)pd = min; - if (features) - *(Int32*)pf = *(Int32*)(pf + min_offset); - } - if (features) { - NI_FILTER_NEXT(ti, fi, foo, pf); - } - NI_FILTER_NEXT(si, di, oo, pd); - } - - exit: - if (offsets) free(offsets); - if (foffsets) free(foffsets); - if (footprint) - free(footprint); - return PyErr_Occurred() ? 0 : 1; -} - -static void _VoronoiFT(char *pf, maybelong len, maybelong *coor, int rank, - int d, maybelong stride, maybelong cstride, - maybelong **f, maybelong *g, Float64 *sampling) -{ - maybelong l = -1, ii, maxl, idx1, idx2; - int jj; - - for(ii = 0; ii < len; ii++) - for(jj = 0; jj < rank; jj++) - f[ii][jj] = *(Int32*)(pf + ii * stride + cstride * jj); - for(ii = 0; ii < len; ii++) { - if (*(Int32*)(pf + ii * stride) >= 0) { - double fd = f[ii][d]; - double wR = 0.0; - for(jj = 0; jj < rank; jj++) { - if (jj != d) { - double tw = f[ii][jj] - coor[jj]; - if (sampling) - tw *= sampling[jj]; - wR += tw * tw; - } - } - while(l >= 1) { - double a, b, c, uR = 0.0, vR = 0.0, f1; - idx1 = g[l]; - f1 = f[idx1][d]; - idx2 = g[l - 1]; - a = f1 - f[idx2][d]; - b = fd - f1; - if (sampling) { - a *= sampling[d]; - b *= sampling[d]; - } - c = a + b; - for(jj = 0; jj < rank; jj++) { - if (jj != d) { - double cc = coor[jj]; - double tu = f[idx2][jj] - cc; - double tv = f[idx1][jj] - cc; - if (sampling) { - tu *= sampling[jj]; - tv *= sampling[jj]; - } - uR += tu * tu; - vR += tv * tv; - } - } - if (c * vR - b * uR - a * wR - a * b * c <= 0.0) - break; - --l; - } - ++l; - g[l] = ii; - } - } - maxl = l; - if (maxl >= 0) { - l = 0; - for (ii = 0; ii < len; ii++) { - double delta1 = 0.0, t; - for(jj = 0; jj < rank; jj++) { - t = jj == d ? f[g[l]][jj] - ii : f[g[l]][jj] - coor[jj]; - if (sampling) - t *= sampling[jj]; - delta1 += t * t; - } - while (l < maxl) { - double delta2 = 0.0; - for(jj = 0; jj < rank; jj++) { - t = jj == d ? f[g[l + 1]][jj] - ii : f[g[l + 1]][jj] - coor[jj]; - if (sampling) - t *= sampling[jj]; - delta2 += t * t; - } - if (delta1 <= delta2) - break; - delta1 = delta2; - ++l; - } - idx1 = g[l]; - for(jj = 0; jj < rank; jj++) - *(Int32*)(pf + ii * stride + jj * cstride) = f[idx1][jj]; - } - } -} - - -/* Recursive feature transform */ -static void _ComputeFT(char *pi, char *pf, maybelong *ishape, - maybelong *istrides, maybelong *fstrides, int rank, - int d, maybelong *coor, maybelong **f, maybelong *g, - PyArrayObject *features, Float64 *sampling) -{ - int kk; - maybelong jj; - - if (d == 0) { - char *tf1 = pf; - for(jj = 0; jj < ishape[0]; jj++) { - if (*(Int8*)pi) { - *(Int32*)tf1 = -1; - } else { - char *tf2 = tf1; - *(Int32*)tf2 = jj; - for(kk = 1; kk < rank; kk++) { - tf2 += fstrides[0]; - *(Int32*)tf2 = coor[kk]; - } - } - pi += istrides[0]; - tf1 += fstrides[1]; - } - _VoronoiFT(pf, ishape[0], coor, rank, 0, fstrides[1], fstrides[0], f, - g, sampling); - } else { - UInt32 axes = 0; - char *tf = pf; - maybelong size = 1; - NI_Iterator ii; - - for(jj = 0; jj < ishape[d]; jj++) { - coor[d] = jj; - _ComputeFT(pi, tf, ishape, istrides, fstrides, rank, d - 1, coor, f, - g, features, sampling); - pi += istrides[d]; - tf += fstrides[d + 1]; - } - - for(jj = 0; jj < d; jj++) { - axes |= (UInt32)1 << (jj + 1); - size *= ishape[jj]; - } - NI_InitPointIterator(features, &ii); - NI_SubspaceIterator(&ii, axes); - tf = pf; - for(jj = 0; jj < size; jj++) { - for(kk = 0; kk < d; kk++) - coor[kk] = ii.coordinates[kk]; - _VoronoiFT(tf, ishape[d], coor, rank, d, fstrides[d + 1], - fstrides[0], f, g, sampling); - NI_ITERATOR_NEXT(ii, tf); - } - for(kk = 0; kk < d; kk++) - coor[kk] = 0; - } -} - -/* Exact euclidean feature transform, as described in: C. R. Maurer, - Jr., R. Qi, V. Raghavan, "A linear time algorithm for computing - exact euclidean distance transforms of binary images in arbitrary - dimensions. IEEE Trans. PAMI 25, 265-270, 2003. */ -int NI_EuclideanFeatureTransform(PyArrayObject* input, - PyArrayObject *sampling_arr, - PyArrayObject* features) -{ - int ii; - maybelong coor[NI_MAXDIM], mx = 0, jj; - maybelong *tmp = NULL, **f = NULL, *g = NULL; - char *pi, *pf; - Float64 *sampling = sampling_arr ? ((void *)PyArray_DATA(sampling_arr)) : NULL; - - pi = (void *)PyArray_DATA(input); - pf = (void *)PyArray_DATA(features); - for(ii = 0; ii < input->nd; ii++) { - coor[ii] = 0; - if (input->dimensions[ii] > mx) - mx = input->dimensions[ii]; - } - - /* Some temporaries */ - f = (maybelong**)malloc(mx * sizeof(maybelong*)); - g = (maybelong*)malloc(mx * sizeof(maybelong)); - tmp = (maybelong*)malloc(mx * input->nd * sizeof(maybelong)); - if (!f || !g || !tmp) { - PyErr_NoMemory(); - goto exit; - } - for(jj = 0; jj < mx; jj++) - f[jj] = tmp + jj * input->nd; - - /* First call of recursive feature transform */ - _ComputeFT(pi, pf, input->dimensions, input->strides, features->strides, - input->nd, input->nd - 1, coor, f, g, features, sampling); - - exit: - if (f) - free(f); - if (g) - free(g); - if (tmp) - free(tmp); - - return PyErr_Occurred() ? 0 : 1; -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ni_support.h" +#include "ni_morphology.h" +#include +#include +#include +#include + +#define LIST_SIZE 100000 + +#define CASE_GET_MASK(_msk_value, _pm, _type) \ +case t ## _type: \ + _msk_value = *(_type*)_pm ? 1 : 0; \ + break + +#define CASE_OUTPUT(_po, _out, _type) \ +case t ## _type: \ + *(_type*)_po = (_type)_out; \ + break + +#define CASE_NI_ERODE_POINT(_pi, _out, _offsets, _filter_size, _type, \ + _mv, _border_value, _bv, _center_is_true,\ + _true, _false, _changed) \ +case t ## _type: \ +{ \ + maybelong _ii, _oo; \ + int _in = *(_type*)_pi ? 1 : 0; \ + if (_mv) { \ + if (_center_is_true && _in == false) { \ + _changed = 0; \ + _out = _in; \ + } else { \ + _out = _true; \ + for(_ii = 0; _ii < _filter_size; _ii++) { \ + _oo = _offsets[_ii]; \ + if (_oo == _bv) { \ + if (!_border_value) { \ + _out = _false; \ + break; \ + } \ + } else { \ + int _nn = *(_type*)(_pi + _oo) ? _true : _false; \ + if (!_nn) { \ + _out = _false; \ + break; \ + } \ + } \ + } \ + _changed = _out != _in; \ + } \ + } else { \ + _out = _in; \ + } \ +} \ +break + +int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct, + PyArrayObject* mask, PyArrayObject* output, int bdr_value, + maybelong *origins, int invert, int center_is_true, int* changed, + NI_CoordinateList **coordinate_list) +{ + maybelong struct_size = 0, *offsets = NULL, size, *oo, jj; + maybelong ssize, block_size = 0, *current = NULL, border_flag_value; + int kk, true, false, msk_value; + NI_Iterator ii, io, mi; + NI_FilterIterator fi; + Bool *ps, out = 0; + char *pi, *po, *pm = NULL; + NI_CoordinateBlock *block = NULL; + + ps = (Bool*)PyArray_DATA(strct); + ssize = 1; + for(kk = 0; kk < strct->nd; kk++) + ssize *= strct->dimensions[kk]; + for(jj = 0; jj < ssize; jj++) + if (ps[jj]) ++struct_size; + if (mask) { + if (!NI_InitPointIterator(mask, &mi)) + return 0; + pm = (void *)PyArray_DATA(mask); + } + /* calculate the filter offsets: */ + if (!NI_InitFilterOffsets(input, ps, strct->dimensions, origins, + NI_EXTEND_CONSTANT, &offsets, &border_flag_value, NULL)) + goto exit; + /* initialize input element iterator: */ + if (!NI_InitPointIterator(input, &ii)) + goto exit; + /* initialize output element iterator: */ + if (!NI_InitPointIterator(output, &io)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(input->nd, strct->dimensions, struct_size, + input->dimensions, origins, &fi)) + goto exit; + + /* get data pointers an size: */ + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); + size = 1; + for(kk = 0; kk < input->nd; kk++) + size *= input->dimensions[kk]; + if (invert) { + bdr_value = bdr_value ? 0 : 1; + true = 0; + false = 1; + } else { + bdr_value = bdr_value ? 1 : 0; + true = 1; + false = 0; + } + if (coordinate_list) { + block_size = LIST_SIZE / input->nd / sizeof(int); + if (block_size < 1) + block_size = 1; + if (block_size > size) + block_size = size; + *coordinate_list = NI_InitCoordinateList(block_size, input->nd); + if (!*coordinate_list) + goto exit; + } + /* iterator over the elements: */ + oo = offsets; + *changed = 0; + msk_value = 1; + for(jj = 0; jj < size; jj++) { + int pchange = 0; + if (mask) { + switch(mask->descr->type_num) { + CASE_GET_MASK(msk_value, pm, Bool); + CASE_GET_MASK(msk_value, pm, UInt8); + CASE_GET_MASK(msk_value, pm, UInt16); + CASE_GET_MASK(msk_value, pm, UInt32); +#if HAS_UINT64 + CASE_GET_MASK(msk_value, pm, UInt64); +#endif + CASE_GET_MASK(msk_value, pm, Int8); + CASE_GET_MASK(msk_value, pm, Int16); + CASE_GET_MASK(msk_value, pm, Int32); + CASE_GET_MASK(msk_value, pm, Int64); + CASE_GET_MASK(msk_value, pm, Float32); + CASE_GET_MASK(msk_value, pm, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + return 0; + } + } + switch (input->descr->type_num) { + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Bool, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt8, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt16, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt32, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); +#if HAS_UINT64 + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt64, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); +#endif + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int8, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int16, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int32, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int64, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float32, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float64, msk_value, + bdr_value, border_flag_value, center_is_true, + true, false, pchange); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + switch (output->descr->type_num) { + CASE_OUTPUT(po, out, Bool); + CASE_OUTPUT(po, out, UInt8); + CASE_OUTPUT(po, out, UInt16); + CASE_OUTPUT(po, out, UInt32); +#if HAS_UINT64 + CASE_OUTPUT(po, out, UInt64); +#endif + CASE_OUTPUT(po, out, Int8); + CASE_OUTPUT(po, out, Int16); + CASE_OUTPUT(po, out, Int32); + CASE_OUTPUT(po, out, Int64); + CASE_OUTPUT(po, out, Float32); + CASE_OUTPUT(po, out, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + if (pchange) { + *changed = 1; + if (coordinate_list) { + if (block == NULL || block->size == block_size) { + block = NI_CoordinateListAddBlock(*coordinate_list); + current = block->coordinates; + } + for(kk = 0; kk < input->nd; kk++) + *current++ = ii.coordinates[kk]; + block->size++; + } + } + if (mask) { + NI_FILTER_NEXT3(fi, ii, io, mi, oo, pi, po, pm); + } else { + NI_FILTER_NEXT2(fi, ii, io, oo, pi, po); + } + } + + exit: + if (offsets) + free(offsets); + if (PyErr_Occurred()) { + if (coordinate_list) { + NI_FreeCoordinateList(*coordinate_list); + *coordinate_list = NULL; + } + return 0; + } else { + return 1; + } + return PyErr_Occurred() ? 0 : 1; +} + +#define CASE_ERODE_POINT2(_struct_size, _offsets, _coordinate_offsets, \ + _pi, _oo, _irank, _list1, _list2, \ + _current_coors1, _current_coors2, _block1, \ + _block2, _bf_value, _true, _false, _type, \ + _mklist) \ +case t ## _type: \ +{ \ + maybelong _hh, _kk; \ + for(_hh = 0; _hh < _struct_size; _hh++) { \ + maybelong _to = _offsets[_oo + _hh]; \ + if (_to != _bf_value && *(_type*)(_pi + _to) == _true) { \ + if (_mklist) { \ + maybelong *_tc = &(_coordinate_offsets[(_oo + _hh) * _irank]); \ + if (_block2 == NULL || _block2->size == _list2->block_size) { \ + _block2 = NI_CoordinateListAddBlock(_list2); \ + _current_coors2 = _block2->coordinates; \ + } \ + for(_kk = 0; _kk < _irank; _kk++) \ + *_current_coors2++ = _current_coors1[_kk] + _tc[_kk]; \ + _block2->size++; \ + } \ + *(_type*)(_pi + _to) = _false; \ + } \ + } \ +} \ +break + +int NI_BinaryErosion2(PyArrayObject* array, PyArrayObject* strct, + PyArrayObject* mask, int niter, maybelong *origins, + int invert, NI_CoordinateList **iclist) +{ + maybelong struct_size = 0, *offsets = NULL, oo, jj, ssize; + maybelong *coordinate_offsets = NULL, size = 0; + maybelong *current_coordinates1 = NULL, *current_coordinates2 = NULL; + maybelong kk, border_flag_value, current = 0; + int true, false; + NI_Iterator ii, mi; + NI_FilterIterator fi, ci; + Bool *ps; + char *pi, *ibase, *pm = NULL; + NI_CoordinateBlock *block1 = NULL, *block2 = NULL; + NI_CoordinateList *list1 = NULL, *list2 = NULL; + + ps = (Bool*)PyArray_DATA(strct); + ssize = 1; + for(kk = 0; kk < strct->nd; kk++) + ssize *= strct->dimensions[kk]; + for(jj = 0; jj < ssize; jj++) + if (ps[jj]) ++struct_size; + + /* calculate the filter offsets: */ + if (!NI_InitFilterOffsets(array, ps, strct->dimensions, origins, + NI_EXTEND_CONSTANT, &offsets, + &border_flag_value, &coordinate_offsets)) + goto exit; + + /* initialize input element iterator: */ + if (!NI_InitPointIterator(array, &ii)) + goto exit; + + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size, + array->dimensions, origins, &fi)) + goto exit; + if (!NI_InitFilterIterator(array->nd, strct->dimensions, + struct_size * array->nd, array->dimensions, + origins, &ci)) + goto exit; + + /* get data pointers and size: */ + ibase = pi = (void *)PyArray_DATA(array); + + if (invert) { + true = 0; + false = 1; + } else { + true = 1; + false = 0; + } + + if (mask) { + /* iterator, data pointer and type of mask array: */ + if (!NI_InitPointIterator(mask, &mi)) + return 0; + pm = (void *)PyArray_DATA(mask); + + size = 1; + for(kk = 0; kk < array->nd; kk++) + size *= array->dimensions[kk]; + + for(jj = 0; jj < size; jj++) { + if (*(Int8*)pm) { + *(Int8*)pm = -1; + } else { + *(Int8*)pm = (Int8)*(Bool*)pi; + *(Bool*)pi = false; + } + NI_ITERATOR_NEXT2(ii, mi, pi, pm) + } + NI_ITERATOR_RESET(ii) + pi = (void *)PyArray_DATA(array); + } + + list1 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank); + list2 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank); + if (!list1 || !list2) + goto exit; + if (NI_CoordinateListStealBlocks(list2, *iclist)) + goto exit; + block2 = list2->blocks; + jj = 0; + while(block1 || block2) { + int mklist = 1; + if (!block1) { + if (niter <= 0 || jj < niter) { + if (NI_CoordinateListStealBlocks(list1, list2)) + goto exit; + block1 = list1->blocks; + block2 = NULL; + current_coordinates1 = block1->coordinates; + current = 0; + ++jj; + mklist = niter <= 0 || jj < niter; + } else { + break; + } + } + NI_ITERATOR_GOTO(ii, current_coordinates1, ibase, pi); + NI_FILTER_GOTO(fi, ii, 0, oo); + + switch (array->descr->type_num) { + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Bool, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, UInt8, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, UInt16, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, UInt32, mklist); +#if HAS_UINT64 + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, UInt64, mklist); +#endif + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Int8, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Int16, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Int32, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Int64, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Float32, mklist); + CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, + border_flag_value, true, false, Float64, mklist); + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + goto exit; + } + + ++current; + if (current == block1->size) { + block1 = NI_CoordinateListDeleteBlock(list1); + if (block1) { + current_coordinates1 = block1->coordinates; + current = 0; + } + } else { + current_coordinates1 += array->nd; + } + } + + if (mask) { + NI_ITERATOR_RESET(ii) + NI_ITERATOR_RESET(mi) + pi = (void *)PyArray_DATA(array); + pm = (void *)PyArray_DATA(mask); + for(jj = 0; jj < size; jj++) { + int value = *(Int8*)pm; + if (value >= 0) + *(Bool*)pi = value; + NI_ITERATOR_NEXT2(ii, mi, pi, pm) + } + } + + exit: + if (offsets) + free(offsets); + if (coordinate_offsets) + free(coordinate_offsets); + NI_FreeCoordinateList(list1); + NI_FreeCoordinateList(list2); + if (PyErr_Occurred()) { + return 0; + } else { + return 1; + } + return PyErr_Occurred() ? 0 : 1; +} + + +#define NI_DISTANCE_EUCLIDIAN 1 +#define NI_DISTANCE_CITY_BLOCK 2 +#define NI_DISTANCE_CHESSBOARD 3 + +typedef struct { + maybelong *coordinates; + maybelong index; + void *next; +} NI_BorderElement; + +int NI_DistanceTransformBruteForce(PyArrayObject* input, int metric, + PyArrayObject *sampling_arr, + PyArrayObject* distances, + PyArrayObject* features) +{ + maybelong size, jj, min_index = 0; + int kk; + NI_BorderElement *border_elements = NULL, *temp; + NI_Iterator ii, di, fi; + char *pi, *pd = NULL, *pf = NULL; + Float64 *sampling = sampling_arr ? (void *)PyArray_DATA(sampling_arr) : NULL; + + /* check the output arrays: */ + if (distances) { + pd = (void *)PyArray_DATA(distances); + if (!NI_InitPointIterator(distances, &di)) + goto exit; + } + + if (features) { + pf = (void *)PyArray_DATA(features); + if (!NI_InitPointIterator(features, &fi)) + goto exit; + } + + size = 1; + for(kk = 0; kk < input->nd; kk++) + size *= input->dimensions[kk]; + pi = (void *)PyArray_DATA(input); + + if (!NI_InitPointIterator(input, &ii)) + goto exit; + + for(jj = 0; jj < size; jj++) { + if (*(Int8*)pi < 0) { + temp = (NI_BorderElement*)malloc(sizeof(NI_BorderElement)); + if (!temp) { + PyErr_NoMemory(); + goto exit; + } + temp->next = border_elements; + border_elements = temp; + temp->index = jj; + temp->coordinates = (maybelong*)malloc(input->nd * sizeof(maybelong)); + for(kk = 0; kk < input->nd; kk++) + temp->coordinates[kk] = ii.coordinates[kk]; + } + NI_ITERATOR_NEXT(ii, pi); + } + + NI_ITERATOR_RESET(ii); + pi = (void *)PyArray_DATA(input); + + switch(metric) { + case NI_DISTANCE_EUCLIDIAN: + for(jj = 0; jj < size; jj++) { + if (*(Int8*)pi > 0) { + double distance = DBL_MAX; + temp = border_elements; + while(temp) { + double d = 0.0, t; + for(kk = 0; kk < input->nd; kk++) { + t = ii.coordinates[kk] - temp->coordinates[kk]; + if (sampling) + t *= sampling[kk]; + d += t * t; + } + if (d < distance) { + distance = d; + if (features) + min_index = temp->index; + } + temp = temp->next; + } + if (distances) + *(Float64*)pd = sqrt(distance); + if (features) + *(Int32*)pf = min_index; + } else { + if (distances) + *(Float64*)pd = 0.0; + if (features) + *(Int32*)pf = jj; + } + if (features && distances) { + NI_ITERATOR_NEXT3(ii, di, fi, pi, pd, pf); + } else if (distances) { + NI_ITERATOR_NEXT2(ii, di, pi, pd); + } else { + NI_ITERATOR_NEXT2(ii, fi, pi, pf); + } + } + break; + case NI_DISTANCE_CITY_BLOCK: + case NI_DISTANCE_CHESSBOARD: + for(jj = 0; jj < size; jj++) { + if (*(Int8*)pi > 0) { + unsigned long distance = ULONG_MAX; + temp = border_elements; + while(temp) { + unsigned int d = 0; + maybelong t; + for(kk = 0; kk < input->nd; kk++) { + t = ii.coordinates[kk] - temp->coordinates[kk]; + if (t < 0) + t = -t; + if (metric == NI_DISTANCE_CITY_BLOCK) { + d += t; + } else { + if ((unsigned int)t > d) + d = t; + } + } + if (d < distance) { + distance = d; + if (features) + min_index = temp->index; + } + temp = temp->next; + } + if (distances) + *(UInt32*)pd = distance; + if (features) + *(Int32*)pf = min_index; + } else { + if (distances) + *(UInt32*)pd = 0; + if (features) + *(Int32*)pf = jj; + } + if (features && distances) { + NI_ITERATOR_NEXT3(ii, di, fi, pi, pd, pf); + } else if (distances) { + NI_ITERATOR_NEXT2(ii, di, pi, pd); + } else { + NI_ITERATOR_NEXT2(ii, fi, pi, pf); + } + } + break; + default: + PyErr_SetString(PyExc_RuntimeError, "distance metric not supported"); + goto exit; + } + + exit: + while (border_elements) { + temp = border_elements; + border_elements = border_elements->next; + if (temp->coordinates) + free(temp->coordinates); + free(temp); + } + return PyErr_Occurred() ? 0 : 1; +} + + +int NI_DistanceTransformOnePass(PyArrayObject *strct, + PyArrayObject* distances, PyArrayObject *features) +{ + int kk; + maybelong jj, ii, ssize, size, filter_size, mask_value, *oo; + maybelong *foffsets = NULL, *foo = NULL, *offsets = NULL; + Bool *ps, *pf = NULL, *footprint = NULL; + char *pd; + NI_FilterIterator si, ti; + NI_Iterator di, fi; + + ssize = 1; + for(kk = 0; kk < strct->nd; kk++) + ssize *= strct->dimensions[kk]; + + /* we only use the first half of the structure data, so we make a + temporary structure for use with the filter functions: */ + footprint = (Bool*)malloc(ssize * sizeof(Bool)); + if (!footprint) { + PyErr_NoMemory(); + goto exit; + } + ps = (Bool*)PyArray_DATA(strct); + filter_size = 0; + for(jj = 0; jj < ssize / 2; jj++) { + footprint[jj] = ps[jj]; + if (ps[jj]) + ++filter_size; + } + for(jj = ssize / 2; jj < ssize; jj++) + footprint[jj] = 0; + /* get data and size */ + pd = (void *)PyArray_DATA(distances); + size = 1; + for(kk = 0; kk < distances->nd; kk++) + size *= distances->dimensions[kk]; + if (!NI_InitPointIterator(distances, &di)) + goto exit; + /* calculate the filter offsets: */ + if (!NI_InitFilterOffsets(distances, footprint, strct->dimensions, NULL, + NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(distances->nd, strct->dimensions, + filter_size, distances->dimensions, NULL, &si)) + goto exit; + + if (features) { + maybelong dummy; + /* initialize point iterator: */ + pf = (void *)PyArray_DATA(features); + if (!NI_InitPointIterator(features, &fi)) + goto exit; + /* calculate the filter offsets: */ + if (!NI_InitFilterOffsets(features, footprint, strct->dimensions, + NULL, NI_EXTEND_CONSTANT, &foffsets, &dummy, NULL)) + goto exit; + /* initialize filter iterator: */ + if (!NI_InitFilterIterator(distances->nd, strct->dimensions, + filter_size, distances->dimensions, NULL, &ti)) + goto exit; + } + /* iterator over the elements: */ + oo = offsets; + if (features) + foo = foffsets; + for(jj = 0; jj < size; jj++) { + Int32 value = *(Int32*)pd; + if (value != 0) { + Int32 min = value; + maybelong min_offset = 0; + /* iterate over structuring element: */ + for(ii = 0; ii < filter_size; ii++) { + maybelong offset = oo[ii]; + Int32 tt = -1; + if (offset < mask_value) + tt = *(Int32*)(pd + offset); + if (tt >= 0) { + if ((min < 0) || (tt + 1 < min)) { + min = tt + 1; + if (features) + min_offset = foo[ii]; + } + } + } + *(Int32*)pd = min; + if (features) + *(Int32*)pf = *(Int32*)(pf + min_offset); + } + if (features) { + NI_FILTER_NEXT(ti, fi, foo, pf); + } + NI_FILTER_NEXT(si, di, oo, pd); + } + + exit: + if (offsets) free(offsets); + if (foffsets) free(foffsets); + if (footprint) + free(footprint); + return PyErr_Occurred() ? 0 : 1; +} + +static void _VoronoiFT(char *pf, maybelong len, maybelong *coor, int rank, + int d, maybelong stride, maybelong cstride, + maybelong **f, maybelong *g, Float64 *sampling) +{ + maybelong l = -1, ii, maxl, idx1, idx2; + int jj; + + for(ii = 0; ii < len; ii++) + for(jj = 0; jj < rank; jj++) + f[ii][jj] = *(Int32*)(pf + ii * stride + cstride * jj); + for(ii = 0; ii < len; ii++) { + if (*(Int32*)(pf + ii * stride) >= 0) { + double fd = f[ii][d]; + double wR = 0.0; + for(jj = 0; jj < rank; jj++) { + if (jj != d) { + double tw = f[ii][jj] - coor[jj]; + if (sampling) + tw *= sampling[jj]; + wR += tw * tw; + } + } + while(l >= 1) { + double a, b, c, uR = 0.0, vR = 0.0, f1; + idx1 = g[l]; + f1 = f[idx1][d]; + idx2 = g[l - 1]; + a = f1 - f[idx2][d]; + b = fd - f1; + if (sampling) { + a *= sampling[d]; + b *= sampling[d]; + } + c = a + b; + for(jj = 0; jj < rank; jj++) { + if (jj != d) { + double cc = coor[jj]; + double tu = f[idx2][jj] - cc; + double tv = f[idx1][jj] - cc; + if (sampling) { + tu *= sampling[jj]; + tv *= sampling[jj]; + } + uR += tu * tu; + vR += tv * tv; + } + } + if (c * vR - b * uR - a * wR - a * b * c <= 0.0) + break; + --l; + } + ++l; + g[l] = ii; + } + } + maxl = l; + if (maxl >= 0) { + l = 0; + for (ii = 0; ii < len; ii++) { + double delta1 = 0.0, t; + for(jj = 0; jj < rank; jj++) { + t = jj == d ? f[g[l]][jj] - ii : f[g[l]][jj] - coor[jj]; + if (sampling) + t *= sampling[jj]; + delta1 += t * t; + } + while (l < maxl) { + double delta2 = 0.0; + for(jj = 0; jj < rank; jj++) { + t = jj == d ? f[g[l + 1]][jj] - ii : f[g[l + 1]][jj] - coor[jj]; + if (sampling) + t *= sampling[jj]; + delta2 += t * t; + } + if (delta1 <= delta2) + break; + delta1 = delta2; + ++l; + } + idx1 = g[l]; + for(jj = 0; jj < rank; jj++) + *(Int32*)(pf + ii * stride + jj * cstride) = f[idx1][jj]; + } + } +} + + +/* Recursive feature transform */ +static void _ComputeFT(char *pi, char *pf, maybelong *ishape, + maybelong *istrides, maybelong *fstrides, int rank, + int d, maybelong *coor, maybelong **f, maybelong *g, + PyArrayObject *features, Float64 *sampling) +{ + int kk; + maybelong jj; + + if (d == 0) { + char *tf1 = pf; + for(jj = 0; jj < ishape[0]; jj++) { + if (*(Int8*)pi) { + *(Int32*)tf1 = -1; + } else { + char *tf2 = tf1; + *(Int32*)tf2 = jj; + for(kk = 1; kk < rank; kk++) { + tf2 += fstrides[0]; + *(Int32*)tf2 = coor[kk]; + } + } + pi += istrides[0]; + tf1 += fstrides[1]; + } + _VoronoiFT(pf, ishape[0], coor, rank, 0, fstrides[1], fstrides[0], f, + g, sampling); + } else { + UInt32 axes = 0; + char *tf = pf; + maybelong size = 1; + NI_Iterator ii; + + for(jj = 0; jj < ishape[d]; jj++) { + coor[d] = jj; + _ComputeFT(pi, tf, ishape, istrides, fstrides, rank, d - 1, coor, f, + g, features, sampling); + pi += istrides[d]; + tf += fstrides[d + 1]; + } + + for(jj = 0; jj < d; jj++) { + axes |= (UInt32)1 << (jj + 1); + size *= ishape[jj]; + } + NI_InitPointIterator(features, &ii); + NI_SubspaceIterator(&ii, axes); + tf = pf; + for(jj = 0; jj < size; jj++) { + for(kk = 0; kk < d; kk++) + coor[kk] = ii.coordinates[kk]; + _VoronoiFT(tf, ishape[d], coor, rank, d, fstrides[d + 1], + fstrides[0], f, g, sampling); + NI_ITERATOR_NEXT(ii, tf); + } + for(kk = 0; kk < d; kk++) + coor[kk] = 0; + } +} + +/* Exact euclidean feature transform, as described in: C. R. Maurer, + Jr., R. Qi, V. Raghavan, "A linear time algorithm for computing + exact euclidean distance transforms of binary images in arbitrary + dimensions. IEEE Trans. PAMI 25, 265-270, 2003. */ +int NI_EuclideanFeatureTransform(PyArrayObject* input, + PyArrayObject *sampling_arr, + PyArrayObject* features) +{ + int ii; + maybelong coor[NI_MAXDIM], mx = 0, jj; + maybelong *tmp = NULL, **f = NULL, *g = NULL; + char *pi, *pf; + Float64 *sampling = sampling_arr ? ((void *)PyArray_DATA(sampling_arr)) : NULL; + + pi = (void *)PyArray_DATA(input); + pf = (void *)PyArray_DATA(features); + for(ii = 0; ii < input->nd; ii++) { + coor[ii] = 0; + if (input->dimensions[ii] > mx) + mx = input->dimensions[ii]; + } + + /* Some temporaries */ + f = (maybelong**)malloc(mx * sizeof(maybelong*)); + g = (maybelong*)malloc(mx * sizeof(maybelong)); + tmp = (maybelong*)malloc(mx * input->nd * sizeof(maybelong)); + if (!f || !g || !tmp) { + PyErr_NoMemory(); + goto exit; + } + for(jj = 0; jj < mx; jj++) + f[jj] = tmp + jj * input->nd; + + /* First call of recursive feature transform */ + _ComputeFT(pi, pf, input->dimensions, input->strides, features->strides, + input->nd, input->nd - 1, coor, f, g, features, sampling); + + exit: + if (f) + free(f); + if (g) + free(g); + if (tmp) + free(tmp); + + return PyErr_Occurred() ? 0 : 1; +} Modified: trunk/scipy/ndimage/src/ni_morphology.h =================================================================== --- trunk/scipy/ndimage/src/ni_morphology.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_morphology.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,46 +1,46 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NI_MORPHOLOGY_H -#define NI_MORPHOLOGY_H - -int NI_BinaryErosion(PyArrayObject*, PyArrayObject*, PyArrayObject*, - PyArrayObject*, int, maybelong*, int, int, int*, NI_CoordinateList**); -int NI_BinaryErosion2(PyArrayObject*, PyArrayObject*, PyArrayObject*, - int, maybelong*, int, NI_CoordinateList**); -int NI_DistanceTransformBruteForce(PyArrayObject*, int, PyArrayObject*, - PyArrayObject*, PyArrayObject*); -int NI_DistanceTransformOnePass(PyArrayObject*, PyArrayObject *, - PyArrayObject*); -int NI_EuclideanFeatureTransform(PyArrayObject*, PyArrayObject*, - PyArrayObject*); - -#endif +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NI_MORPHOLOGY_H +#define NI_MORPHOLOGY_H + +int NI_BinaryErosion(PyArrayObject*, PyArrayObject*, PyArrayObject*, + PyArrayObject*, int, maybelong*, int, int, int*, NI_CoordinateList**); +int NI_BinaryErosion2(PyArrayObject*, PyArrayObject*, PyArrayObject*, + int, maybelong*, int, NI_CoordinateList**); +int NI_DistanceTransformBruteForce(PyArrayObject*, int, PyArrayObject*, + PyArrayObject*, PyArrayObject*); +int NI_DistanceTransformOnePass(PyArrayObject*, PyArrayObject *, + PyArrayObject*); +int NI_EuclideanFeatureTransform(PyArrayObject*, PyArrayObject*, + PyArrayObject*); + +#endif Modified: trunk/scipy/ndimage/src/ni_support.c =================================================================== --- trunk/scipy/ndimage/src/ni_support.c 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_support.c 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,751 +1,751 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ni_support.h" - -/* initialize iterations over single array elements: */ -int NI_InitPointIterator(PyArrayObject *array, NI_Iterator *iterator) -{ - int ii; - - iterator->rank_m1 = array->nd - 1; - for(ii = 0; ii < array->nd; ii++) { - /* adapt dimensions for use in the macros: */ - iterator->dimensions[ii] = array->dimensions[ii] - 1; - /* initialize coordinates: */ - iterator->coordinates[ii] = 0; - /* initialize strides: */ - iterator->strides[ii] = array->strides[ii]; - /* calculate the strides to move back at the end of an axis: */ - iterator->backstrides[ii] = - array->strides[ii] * iterator->dimensions[ii]; - } - return 1; -} - - -/* initialize iteration over a lower sub-space: */ -int NI_SubspaceIterator(NI_Iterator *iterator, UInt32 axes) -{ - int ii, last = 0; - - for(ii = 0; ii <= iterator->rank_m1; ii++) { - if (axes & (((UInt32)1) << ii)) { - if (last != ii) { - iterator->dimensions[last] = iterator->dimensions[ii]; - iterator->strides[last] = iterator->strides[ii]; - iterator->backstrides[last] = iterator->backstrides[ii]; - } - ++last; - } - } - iterator->rank_m1 = last - 1; - return 1; -} - -/* initialize iteration over array lines: */ -int NI_LineIterator(NI_Iterator *iterator, int axis) -{ - UInt32 axes = ((UInt32)1) << axis; - return NI_SubspaceIterator(iterator, ~axes); -} - - -/******************************************************************/ -/* Line buffers */ -/******************************************************************/ - -/* Allocate line buffer data */ -int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1, - maybelong size2, maybelong *lines, maybelong max_size, double **buffer) -{ - maybelong line_size, max_lines; - int ii; - - /* the number of lines of the array is an upper limit for the - number of lines in the buffer: */ - max_lines = 1; - for(ii = 0; ii < array->nd; ii++) - max_lines *= array->dimensions[ii]; - if (array->nd > 0 && array->dimensions[axis] > 0) - max_lines /= array->dimensions[axis]; - /* calculate the space needed for one line, including space to - support the boundary conditions: */ - line_size = sizeof(double) * (array->dimensions[axis] + size1 + size2); - /* if *lines < 1, no number of lines is proposed, so we calculate it - from the maximum size allowed: */ - if (*lines < 1) { - *lines = line_size > 0 ? max_size / line_size : 0; - if (*lines < 1) - *lines = 1; - } - /* no need to allocate too many lines: */ - if (*lines > max_lines) - *lines = max_lines; - /* allocate data for the buffer: */ - *buffer = (double*)malloc(*lines * line_size); - if (!*buffer) { - PyErr_NoMemory(); - return 0; - } - return 1; -} - -/* Initialize a line buffer */ -int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1, - maybelong size2, maybelong buffer_lines, double *buffer_data, - NI_ExtendMode extend_mode, double extend_value, NI_LineBuffer *buffer) -{ - maybelong line_length = 0, array_lines = 0, size; - int ii; - - size = 1; - for(ii = 0; ii < array->nd; ii++) - size *= array->dimensions[ii]; - /* check if the buffer is big enough: */ - if (size > 0 && buffer_lines < 1) { - PyErr_SetString(PyExc_RuntimeError, "buffer too small"); - return 0; - } - /* Initialize a line iterator to move over the array: */ - if (!NI_InitPointIterator(array, &(buffer->iterator))) - return 0; - if (!NI_LineIterator(&(buffer->iterator), axis)) - return 0; - line_length = array->nd > 0 ? array->dimensions[axis] : 1; - if (line_length > 0) - array_lines = line_length > 0 ? size / line_length : 1; - /* initialize the buffer structure: */ - buffer->array_data = (void *)PyArray_DATA(array); - buffer->buffer_data = buffer_data; - buffer->buffer_lines = buffer_lines; - buffer->array_type = array->descr->type_num; - buffer->array_lines = array_lines; - buffer->next_line = 0; - buffer->size1 = size1; - buffer->size2 = size2; - buffer->line_length = line_length; - buffer->line_stride = array->nd > 0 ? array->strides[axis] : 0; - buffer->extend_mode = extend_mode; - buffer->extend_value = extend_value; - return 1; -} - -/* Extend a line in memory to implement boundary conditions: */ -int NI_ExtendLine(double *line, maybelong length, maybelong size1, - maybelong size2, NI_ExtendMode mode, double constant_value) -{ - maybelong ii, jj, length1, nextend, rextend; - double *l1, *l2, *l3, val; - - switch (mode) { - case NI_EXTEND_WRAP: - nextend = size1 / length; - rextend = size1 - nextend * length; - l1 = line + size1 + length - rextend; - l2 = line; - for(ii = 0; ii < rextend; ii++) - *l2++ = *l1++; - for(ii = 0; ii < nextend; ii++) { - l1 = line + size1; - for(jj = 0; jj < length; jj++) - *l2++ = *l1++; - } - nextend = size2 / length; - rextend = size2 - nextend * length; - l1 = line + size1; - l2 = line + size1 + length; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; - for(jj = 0; jj < length; jj++) - *l2++ = *l3++; - } - for(ii = 0; ii < rextend; ii++) - *l2++ = *l1++; - break; - case NI_EXTEND_MIRROR: - if (length == 1) { - l1 = line; - val = line[size1]; - for(ii = 0; ii < size1; ii++) - *l1++ = val; - l1 = line + size1 + length; - val = line[size1 + length - 1]; - for(ii = 0; ii < size2; ii++) - *l1++ = val; - } else { - length1 = length - 1; - nextend = size1 / length1; - rextend = size1 - nextend * length1; - l1 = line + size1 + 1; - l2 = l1 - 2; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; - for(jj = 0; jj < length1; jj++) - *l2-- = *l3++; - l1 -= length1; - } - for(ii = 0; ii < rextend; ii++) - *l2-- = *l1++; - nextend = size2 / length1; - rextend = size2 - nextend * length1; - l1 = line + size1 + length1 - 1; - l2 = l1 + 2; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; - for(jj = 0; jj < length1; jj++) - *l2++ = *l3--; - l1 += length1; - } - for(ii = 0; ii < rextend; ii++) - *l2++ = *l1--; - } - break; - case NI_EXTEND_REFLECT: - nextend = size1 / length; - rextend = size1 - nextend * length; - l1 = line + size1; - l2 = l1 - 1; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; - for(jj = 0; jj < length; jj++) - *l2-- = *l3++; - l1 -= length; - } - l3 = l1; - for(ii = 0; ii < rextend; ii++) - *l2-- = *l3++; - nextend = size2 / length; - rextend = size2 - nextend * length; - l1 = line + size1 + length - 1; - l2 = l1 + 1; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; - for(jj = 0; jj < length; jj++) - *l2++ = *l3--; - l1 += length; - } - for(ii = 0; ii < rextend; ii++) - *l2++ = *l1--; - break; - case NI_EXTEND_NEAREST: - l1 = line; - val = line[size1]; - for(ii = 0; ii < size1; ii++) - *l1++ = val; - l1 = line + size1 + length; - val = line[size1 + length - 1]; - for(ii = 0; ii < size2; ii++) - *l1++ = val; - break; - case NI_EXTEND_CONSTANT: - l1 = line; - for(ii = 0; ii < size1; ii++) - *l1++ = constant_value; - l1 = line + size1 + length; - for(ii = 0; ii < size2; ii++) - *l1++ = constant_value; - break; - default: - PyErr_SetString(PyExc_RuntimeError, "mode not supported"); - return 0; - } - return 1; -} - - -#define CASE_COPY_DATA_TO_LINE(_pi, _po, _length, _stride, _type) \ -case t ## _type: \ -{ \ - maybelong _ii; \ - for(_ii = 0; _ii < _length; _ii++) { \ - _po[_ii] = (double)*(_type*)_pi; \ - _pi += _stride; \ - } \ -} \ -break - - -/* Copy a line from an array to a buffer: */ -int NI_ArrayToLineBuffer(NI_LineBuffer *buffer, - maybelong *number_of_lines, int *more) -{ - double *pb = buffer->buffer_data; - char *pa; - maybelong length = buffer->line_length; - - pb += buffer->size1; - *number_of_lines = 0; - /* fill until all lines in the array have been processed, or until - the buffer is full: */ - while (buffer->next_line < buffer->array_lines && - *number_of_lines < buffer->buffer_lines) { - pa = buffer->array_data; - /* copy the data from the array to the buffer: */ - switch (buffer->array_type) { - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Bool); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt8); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt16); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt32); -#if HAS_UINT64 - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt64); -#endif - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int8); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int16); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int32); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int64); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Float32); - CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Float64); - default: - PyErr_Format(PyExc_RuntimeError, "array type %d not supported", buffer->array_type); - return 0; - } - /* goto next line in the array: */ - NI_ITERATOR_NEXT(buffer->iterator, buffer->array_data); - /* implement boundary conditions to the line: */ - if (buffer->size1 + buffer->size2 > 0) - if (!NI_ExtendLine(pb - buffer->size1, length, buffer->size1, - buffer->size2, buffer->extend_mode, - buffer->extend_value)) - return 0; - /* The number of the array lines copied: */ - ++(buffer->next_line); - /* keep track of (and return) the number of lines in the buffer: */ - ++(*number_of_lines); - pb += buffer->line_length + buffer->size1 + buffer->size2; - } - /* if not all array lines were processed, *more is set true: */ - *more = buffer->next_line < buffer->array_lines; - return 1; -} - -#define CASE_COPY_LINE_TO_DATA(_pi, _po, _length, _stride, _type) \ -case t ## _type: \ -{ \ - maybelong _ii; \ - for(_ii = 0; _ii < _length; _ii++) { \ - *(_type*)_po = (_type)_pi[_ii]; \ - _po += _stride; \ - } \ -} \ -break - -/* Copy a line from a buffer to an array: */ -int NI_LineBufferToArray(NI_LineBuffer *buffer) -{ - double *pb = buffer->buffer_data; - char *pa; - maybelong jj, length = buffer->line_length; - - pb += buffer->size1; - for(jj = 0; jj < buffer->buffer_lines; jj++) { - /* if all array lines are copied return: */ - if (buffer->next_line == buffer->array_lines) - break; - pa = buffer->array_data; - /* copy data from the buffer to the array: */ - switch (buffer->array_type) { - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Bool); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt8); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt16); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt32); -#if HAS_UINT64 - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt64); -#endif - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int8); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int16); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int32); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int64); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Float32); - CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "array type not supported"); - return 0; - } - /* move to the next line in the array: */ - NI_ITERATOR_NEXT(buffer->iterator, buffer->array_data); - /* number of lines copied: */ - ++(buffer->next_line); - /* move the buffer data pointer to the next line: */ - pb += buffer->line_length + buffer->size1 + buffer->size2; - } - return 1; -} - -/******************************************************************/ -/* Multi-dimensional filter support functions */ -/******************************************************************/ - -/* Initialize a filter iterator: */ -int -NI_InitFilterIterator(int rank, maybelong *filter_shape, - maybelong filter_size, maybelong *array_shape, - maybelong *origins, NI_FilterIterator *iterator) -{ - int ii; - maybelong fshape[MAXDIM], forigins[MAXDIM]; - - for(ii = 0; ii < rank; ii++) { - fshape[ii] = *filter_shape++; - forigins[ii] = origins ? *origins++ : 0; - } - /* calculate the strides, used to move the offsets pointer through - the offsets table: */ - if (rank > 0) { - iterator->strides[rank - 1] = filter_size; - for(ii = rank - 2; ii >= 0; ii--) { - maybelong step = array_shape[ii + 1] < fshape[ii + 1] ? - array_shape[ii + 1] : fshape[ii + 1]; - iterator->strides[ii] = iterator->strides[ii + 1] * step; - } - } - for(ii = 0; ii < rank; ii++) { - maybelong step = array_shape[ii] < fshape[ii] ? - array_shape[ii] : fshape[ii]; - maybelong orgn = fshape[ii] / 2 + forigins[ii]; - /* stride for stepping back to previous offsets: */ - iterator->backstrides[ii] = (step - 1) * iterator->strides[ii]; - /* initialize boundary extension sizes: */ - iterator->bound1[ii] = orgn; - iterator->bound2[ii] = array_shape[ii] - fshape[ii] + orgn; - } - return 1; -} - -/* Calculate the offsets to the filter points, for all border regions and - the interior of the array: */ -int NI_InitFilterOffsets(PyArrayObject *array, Bool *footprint, - maybelong *filter_shape, maybelong* origins, - NI_ExtendMode mode, maybelong **offsets, maybelong *border_flag_value, - maybelong **coordinate_offsets) -{ - int rank, ii; - maybelong kk, ll, filter_size = 1, offsets_size = 1, max_size = 0; - maybelong max_stride = 0, *ashape = NULL, *astrides = NULL; - maybelong footprint_size = 0, coordinates[MAXDIM], position[MAXDIM]; - maybelong fshape[MAXDIM], forigins[MAXDIM], *po, *pc = NULL; - - rank = array->nd; - ashape = array->dimensions; - astrides = array->strides; - for(ii = 0; ii < rank; ii++) { - fshape[ii] = *filter_shape++; - forigins[ii] = origins ? *origins++ : 0.0; - } - /* the size of the footprint array: */ - for(ii = 0; ii < rank; ii++) - filter_size *= fshape[ii]; - /* calculate the number of non-zero elements in the footprint: */ - if (footprint) { - for(kk = 0; kk < filter_size; kk++) - if (footprint[kk]) - ++footprint_size; - } else { - footprint_size = filter_size; - } - /* calculate how many sets of offsets must be stored: */ - for(ii = 0; ii < rank; ii++) - offsets_size *= (ashape[ii] < fshape[ii] ? ashape[ii] : fshape[ii]); - /* allocate offsets data: */ - *offsets = (maybelong*)malloc(offsets_size * footprint_size * - sizeof(maybelong)); - if (!*offsets) { - PyErr_NoMemory(); - goto exit; - } - if (coordinate_offsets) { - *coordinate_offsets = (maybelong*)malloc(offsets_size * rank * - footprint_size * sizeof(maybelong)); - if (!*coordinate_offsets) { - PyErr_NoMemory(); - goto exit; - } - } - for(ii = 0; ii < rank; ii++) { - maybelong stride; - /* find maximum axis size: */ - if (ashape[ii] > max_size) - max_size = ashape[ii]; - /* find maximum stride: */ - stride = astrides[ii] < 0 ? -astrides[ii] : astrides[ii]; - if (stride > max_stride) - max_stride = stride; - /* coordinates for iterating over the kernel elements: */ - coordinates[ii] = 0; - /* keep track of the kernel position: */ - position[ii] = 0; - } - /* the flag to indicate that we are outside the border must have a - value that is larger than any possible offset: */ - *border_flag_value = max_size * max_stride + 1; - /* calculate all possible offsets to elements in the filter kernel, - for all regions in the array (interior and border regions): */ - po = *offsets; - if (coordinate_offsets) { - pc = *coordinate_offsets; - } - /* iterate over all regions: */ - for(ll = 0; ll < offsets_size; ll++) { - /* iterate over the elements in the footprint array: */ - for(kk = 0; kk < filter_size; kk++) { - maybelong offset = 0; - /* only calculate an offset if the footprint is 1: */ - if (!footprint || footprint[kk]) { - /* find offsets along all axes: */ - for(ii = 0; ii < rank; ii++) { - maybelong orgn = fshape[ii] / 2 + forigins[ii]; - maybelong cc = coordinates[ii] - orgn + position[ii]; - maybelong len = ashape[ii]; - /* apply boundary conditions, if necessary: */ - switch (mode) { - case NI_EXTEND_MIRROR: - if (cc < 0) { - if (len <= 1) { - cc = 0; - } else { - int sz2 = 2 * len - 2; - cc = sz2 * (int)(-cc / sz2) + cc; - cc = cc <= 1 - len ? cc + sz2 : -cc; - } - } else if (cc >= len) { - if (len <= 1) { - cc = 0; - } else { - int sz2 = 2 * len - 2; - cc -= sz2 * (int)(cc / sz2); - if (cc >= len) - cc = sz2 - cc; - } - } - break; - case NI_EXTEND_REFLECT: - if (cc < 0) { - if (len <= 1) { - cc = 0; - } else { - int sz2 = 2 * len; - if (cc < -sz2) - cc = sz2 * (int)(-cc / sz2) + cc; - cc = cc < -len ? cc + sz2 : -cc - 1; - } - } else if (cc >= len) { - if (len <= 1) {cc = 0; - } else { - int sz2 = 2 * len; - cc -= sz2 * (int)(cc / sz2); - if (cc >= len) - cc = sz2 - cc - 1; - } - } - break; - case NI_EXTEND_WRAP: - if (cc < 0) { - if (len <= 1) { - cc = 0; - } else { - int sz = len; - cc += sz * (int)(-cc / sz); - if (cc < 0) - cc += sz; - } - } else if (cc >= len) { - if (len <= 1) { - cc = 0; - } else { - int sz = len; - cc -= sz * (int)(cc / sz); - } - } - break; - case NI_EXTEND_NEAREST: - if (cc < 0) { - cc = 0; - } else if (cc >= len) { - cc = len - 1; - } - break; - case NI_EXTEND_CONSTANT: - if (cc < 0 || cc >= len) - cc = *border_flag_value; - break; - default: - PyErr_SetString(PyExc_RuntimeError, - "boundary mode not supported"); - goto exit; - } - - /* calculate offset along current axis: */ - if (cc == *border_flag_value) { - /* just flag that we are outside the border */ - offset = *border_flag_value; - if (coordinate_offsets) - pc[ii] = 0; - break; - } else { - /* use an offset that is possibly mapped from outside the - border: */ - cc = cc - position[ii]; - offset += astrides[ii] * cc; - if (coordinate_offsets) - pc[ii] = cc; - } - } - /* store the offset */ - *po++ = offset; - if (coordinate_offsets) - pc += rank; - } - /* next point in the filter: */ - for(ii = rank - 1; ii >= 0; ii--) { - if (coordinates[ii] < fshape[ii] - 1) { - coordinates[ii]++; - break; - } else { - coordinates[ii] = 0; - } - } - } - - /* move to the next array region: */ - for(ii = rank - 1; ii >= 0; ii--) { - int orgn = fshape[ii] / 2 + forigins[ii]; - if (position[ii] == orgn) { - position[ii] += ashape[ii] - fshape[ii] + 1; - if (position[ii] <= orgn) - position[ii] = orgn + 1; - } else { - position[ii]++; - } - if (position[ii] < ashape[ii]) { - break; - } else { - position[ii] = 0; - } - } - } - - exit: - if (PyErr_Occurred()) { - if (*offsets) - free(*offsets); - if (coordinate_offsets && *coordinate_offsets) - free(*coordinate_offsets); - return 0; - } else { - return 1; - } -} - -NI_CoordinateList* NI_InitCoordinateList(int size, int rank) -{ - NI_CoordinateList *list = \ - (NI_CoordinateList*)malloc(sizeof(NI_CoordinateList)); - if (!list) { - PyErr_NoMemory(); - return NULL; - } - list->block_size = size; - list->rank = rank; - list->blocks = NULL; - return list; -} - -int NI_CoordinateListStealBlocks(NI_CoordinateList *list1, - NI_CoordinateList *list2) -{ - if (list1->block_size != list2->block_size || - list1->rank != list2->rank) { - PyErr_SetString(PyExc_RuntimeError, "coordinate lists not compatible"); - return 1; - } - if (list1->blocks) { - PyErr_SetString(PyExc_RuntimeError, "first is list not empty"); - return 1; - } - list1->blocks = list2->blocks; - list2->blocks = NULL; - return 0; -} - -NI_CoordinateBlock* NI_CoordinateListAddBlock(NI_CoordinateList *list) -{ - NI_CoordinateBlock* block = NULL; - block = (NI_CoordinateBlock*)malloc(sizeof(NI_CoordinateBlock)); - if (!block) { - PyErr_NoMemory(); - goto exit; - } - block->coordinates = (maybelong*)malloc(list->block_size * list->rank * - sizeof(maybelong)); - if (!block->coordinates) { - PyErr_NoMemory(); - goto exit; - } - block->next = list->blocks; - list->blocks = block; - block->size = 0; - -exit: - if (PyErr_Occurred()) { - if (block) - free(block); - return NULL; - } - return block; -} - -NI_CoordinateBlock* NI_CoordinateListDeleteBlock(NI_CoordinateList *list) -{ - NI_CoordinateBlock* block = list->blocks; - if (block) { - list->blocks = block->next; - if (block->coordinates) - free(block->coordinates); - free(block); - } - return list->blocks; -} - -void NI_FreeCoordinateList(NI_CoordinateList *list) -{ - if (list) { - NI_CoordinateBlock *block = list->blocks; - while (block) { - NI_CoordinateBlock *tmp = block; - block = block->next; - if (tmp->coordinates) - free(tmp->coordinates); - free(tmp); - } - list->blocks = NULL; - free(list); - } -} +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ni_support.h" + +/* initialize iterations over single array elements: */ +int NI_InitPointIterator(PyArrayObject *array, NI_Iterator *iterator) +{ + int ii; + + iterator->rank_m1 = array->nd - 1; + for(ii = 0; ii < array->nd; ii++) { + /* adapt dimensions for use in the macros: */ + iterator->dimensions[ii] = array->dimensions[ii] - 1; + /* initialize coordinates: */ + iterator->coordinates[ii] = 0; + /* initialize strides: */ + iterator->strides[ii] = array->strides[ii]; + /* calculate the strides to move back at the end of an axis: */ + iterator->backstrides[ii] = + array->strides[ii] * iterator->dimensions[ii]; + } + return 1; +} + + +/* initialize iteration over a lower sub-space: */ +int NI_SubspaceIterator(NI_Iterator *iterator, UInt32 axes) +{ + int ii, last = 0; + + for(ii = 0; ii <= iterator->rank_m1; ii++) { + if (axes & (((UInt32)1) << ii)) { + if (last != ii) { + iterator->dimensions[last] = iterator->dimensions[ii]; + iterator->strides[last] = iterator->strides[ii]; + iterator->backstrides[last] = iterator->backstrides[ii]; + } + ++last; + } + } + iterator->rank_m1 = last - 1; + return 1; +} + +/* initialize iteration over array lines: */ +int NI_LineIterator(NI_Iterator *iterator, int axis) +{ + UInt32 axes = ((UInt32)1) << axis; + return NI_SubspaceIterator(iterator, ~axes); +} + + +/******************************************************************/ +/* Line buffers */ +/******************************************************************/ + +/* Allocate line buffer data */ +int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1, + maybelong size2, maybelong *lines, maybelong max_size, double **buffer) +{ + maybelong line_size, max_lines; + int ii; + + /* the number of lines of the array is an upper limit for the + number of lines in the buffer: */ + max_lines = 1; + for(ii = 0; ii < array->nd; ii++) + max_lines *= array->dimensions[ii]; + if (array->nd > 0 && array->dimensions[axis] > 0) + max_lines /= array->dimensions[axis]; + /* calculate the space needed for one line, including space to + support the boundary conditions: */ + line_size = sizeof(double) * (array->dimensions[axis] + size1 + size2); + /* if *lines < 1, no number of lines is proposed, so we calculate it + from the maximum size allowed: */ + if (*lines < 1) { + *lines = line_size > 0 ? max_size / line_size : 0; + if (*lines < 1) + *lines = 1; + } + /* no need to allocate too many lines: */ + if (*lines > max_lines) + *lines = max_lines; + /* allocate data for the buffer: */ + *buffer = (double*)malloc(*lines * line_size); + if (!*buffer) { + PyErr_NoMemory(); + return 0; + } + return 1; +} + +/* Initialize a line buffer */ +int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1, + maybelong size2, maybelong buffer_lines, double *buffer_data, + NI_ExtendMode extend_mode, double extend_value, NI_LineBuffer *buffer) +{ + maybelong line_length = 0, array_lines = 0, size; + int ii; + + size = 1; + for(ii = 0; ii < array->nd; ii++) + size *= array->dimensions[ii]; + /* check if the buffer is big enough: */ + if (size > 0 && buffer_lines < 1) { + PyErr_SetString(PyExc_RuntimeError, "buffer too small"); + return 0; + } + /* Initialize a line iterator to move over the array: */ + if (!NI_InitPointIterator(array, &(buffer->iterator))) + return 0; + if (!NI_LineIterator(&(buffer->iterator), axis)) + return 0; + line_length = array->nd > 0 ? array->dimensions[axis] : 1; + if (line_length > 0) + array_lines = line_length > 0 ? size / line_length : 1; + /* initialize the buffer structure: */ + buffer->array_data = (void *)PyArray_DATA(array); + buffer->buffer_data = buffer_data; + buffer->buffer_lines = buffer_lines; + buffer->array_type = array->descr->type_num; + buffer->array_lines = array_lines; + buffer->next_line = 0; + buffer->size1 = size1; + buffer->size2 = size2; + buffer->line_length = line_length; + buffer->line_stride = array->nd > 0 ? array->strides[axis] : 0; + buffer->extend_mode = extend_mode; + buffer->extend_value = extend_value; + return 1; +} + +/* Extend a line in memory to implement boundary conditions: */ +int NI_ExtendLine(double *line, maybelong length, maybelong size1, + maybelong size2, NI_ExtendMode mode, double constant_value) +{ + maybelong ii, jj, length1, nextend, rextend; + double *l1, *l2, *l3, val; + + switch (mode) { + case NI_EXTEND_WRAP: + nextend = size1 / length; + rextend = size1 - nextend * length; + l1 = line + size1 + length - rextend; + l2 = line; + for(ii = 0; ii < rextend; ii++) + *l2++ = *l1++; + for(ii = 0; ii < nextend; ii++) { + l1 = line + size1; + for(jj = 0; jj < length; jj++) + *l2++ = *l1++; + } + nextend = size2 / length; + rextend = size2 - nextend * length; + l1 = line + size1; + l2 = line + size1 + length; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; + for(jj = 0; jj < length; jj++) + *l2++ = *l3++; + } + for(ii = 0; ii < rextend; ii++) + *l2++ = *l1++; + break; + case NI_EXTEND_MIRROR: + if (length == 1) { + l1 = line; + val = line[size1]; + for(ii = 0; ii < size1; ii++) + *l1++ = val; + l1 = line + size1 + length; + val = line[size1 + length - 1]; + for(ii = 0; ii < size2; ii++) + *l1++ = val; + } else { + length1 = length - 1; + nextend = size1 / length1; + rextend = size1 - nextend * length1; + l1 = line + size1 + 1; + l2 = l1 - 2; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; + for(jj = 0; jj < length1; jj++) + *l2-- = *l3++; + l1 -= length1; + } + for(ii = 0; ii < rextend; ii++) + *l2-- = *l1++; + nextend = size2 / length1; + rextend = size2 - nextend * length1; + l1 = line + size1 + length1 - 1; + l2 = l1 + 2; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; + for(jj = 0; jj < length1; jj++) + *l2++ = *l3--; + l1 += length1; + } + for(ii = 0; ii < rextend; ii++) + *l2++ = *l1--; + } + break; + case NI_EXTEND_REFLECT: + nextend = size1 / length; + rextend = size1 - nextend * length; + l1 = line + size1; + l2 = l1 - 1; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; + for(jj = 0; jj < length; jj++) + *l2-- = *l3++; + l1 -= length; + } + l3 = l1; + for(ii = 0; ii < rextend; ii++) + *l2-- = *l3++; + nextend = size2 / length; + rextend = size2 - nextend * length; + l1 = line + size1 + length - 1; + l2 = l1 + 1; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; + for(jj = 0; jj < length; jj++) + *l2++ = *l3--; + l1 += length; + } + for(ii = 0; ii < rextend; ii++) + *l2++ = *l1--; + break; + case NI_EXTEND_NEAREST: + l1 = line; + val = line[size1]; + for(ii = 0; ii < size1; ii++) + *l1++ = val; + l1 = line + size1 + length; + val = line[size1 + length - 1]; + for(ii = 0; ii < size2; ii++) + *l1++ = val; + break; + case NI_EXTEND_CONSTANT: + l1 = line; + for(ii = 0; ii < size1; ii++) + *l1++ = constant_value; + l1 = line + size1 + length; + for(ii = 0; ii < size2; ii++) + *l1++ = constant_value; + break; + default: + PyErr_SetString(PyExc_RuntimeError, "mode not supported"); + return 0; + } + return 1; +} + + +#define CASE_COPY_DATA_TO_LINE(_pi, _po, _length, _stride, _type) \ +case t ## _type: \ +{ \ + maybelong _ii; \ + for(_ii = 0; _ii < _length; _ii++) { \ + _po[_ii] = (double)*(_type*)_pi; \ + _pi += _stride; \ + } \ +} \ +break + + +/* Copy a line from an array to a buffer: */ +int NI_ArrayToLineBuffer(NI_LineBuffer *buffer, + maybelong *number_of_lines, int *more) +{ + double *pb = buffer->buffer_data; + char *pa; + maybelong length = buffer->line_length; + + pb += buffer->size1; + *number_of_lines = 0; + /* fill until all lines in the array have been processed, or until + the buffer is full: */ + while (buffer->next_line < buffer->array_lines && + *number_of_lines < buffer->buffer_lines) { + pa = buffer->array_data; + /* copy the data from the array to the buffer: */ + switch (buffer->array_type) { + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Bool); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt8); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt16); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt32); +#if HAS_UINT64 + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, UInt64); +#endif + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int8); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int16); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int32); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Int64); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Float32); + CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Float64); + default: + PyErr_Format(PyExc_RuntimeError, "array type %d not supported", buffer->array_type); + return 0; + } + /* goto next line in the array: */ + NI_ITERATOR_NEXT(buffer->iterator, buffer->array_data); + /* implement boundary conditions to the line: */ + if (buffer->size1 + buffer->size2 > 0) + if (!NI_ExtendLine(pb - buffer->size1, length, buffer->size1, + buffer->size2, buffer->extend_mode, + buffer->extend_value)) + return 0; + /* The number of the array lines copied: */ + ++(buffer->next_line); + /* keep track of (and return) the number of lines in the buffer: */ + ++(*number_of_lines); + pb += buffer->line_length + buffer->size1 + buffer->size2; + } + /* if not all array lines were processed, *more is set true: */ + *more = buffer->next_line < buffer->array_lines; + return 1; +} + +#define CASE_COPY_LINE_TO_DATA(_pi, _po, _length, _stride, _type) \ +case t ## _type: \ +{ \ + maybelong _ii; \ + for(_ii = 0; _ii < _length; _ii++) { \ + *(_type*)_po = (_type)_pi[_ii]; \ + _po += _stride; \ + } \ +} \ +break + +/* Copy a line from a buffer to an array: */ +int NI_LineBufferToArray(NI_LineBuffer *buffer) +{ + double *pb = buffer->buffer_data; + char *pa; + maybelong jj, length = buffer->line_length; + + pb += buffer->size1; + for(jj = 0; jj < buffer->buffer_lines; jj++) { + /* if all array lines are copied return: */ + if (buffer->next_line == buffer->array_lines) + break; + pa = buffer->array_data; + /* copy data from the buffer to the array: */ + switch (buffer->array_type) { + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Bool); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt8); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt16); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt32); +#if HAS_UINT64 + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, UInt64); +#endif + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int8); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int16); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int32); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Int64); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Float32); + CASE_COPY_LINE_TO_DATA(pb, pa, length, buffer->line_stride, Float64); + default: + PyErr_SetString(PyExc_RuntimeError, "array type not supported"); + return 0; + } + /* move to the next line in the array: */ + NI_ITERATOR_NEXT(buffer->iterator, buffer->array_data); + /* number of lines copied: */ + ++(buffer->next_line); + /* move the buffer data pointer to the next line: */ + pb += buffer->line_length + buffer->size1 + buffer->size2; + } + return 1; +} + +/******************************************************************/ +/* Multi-dimensional filter support functions */ +/******************************************************************/ + +/* Initialize a filter iterator: */ +int +NI_InitFilterIterator(int rank, maybelong *filter_shape, + maybelong filter_size, maybelong *array_shape, + maybelong *origins, NI_FilterIterator *iterator) +{ + int ii; + maybelong fshape[MAXDIM], forigins[MAXDIM]; + + for(ii = 0; ii < rank; ii++) { + fshape[ii] = *filter_shape++; + forigins[ii] = origins ? *origins++ : 0; + } + /* calculate the strides, used to move the offsets pointer through + the offsets table: */ + if (rank > 0) { + iterator->strides[rank - 1] = filter_size; + for(ii = rank - 2; ii >= 0; ii--) { + maybelong step = array_shape[ii + 1] < fshape[ii + 1] ? + array_shape[ii + 1] : fshape[ii + 1]; + iterator->strides[ii] = iterator->strides[ii + 1] * step; + } + } + for(ii = 0; ii < rank; ii++) { + maybelong step = array_shape[ii] < fshape[ii] ? + array_shape[ii] : fshape[ii]; + maybelong orgn = fshape[ii] / 2 + forigins[ii]; + /* stride for stepping back to previous offsets: */ + iterator->backstrides[ii] = (step - 1) * iterator->strides[ii]; + /* initialize boundary extension sizes: */ + iterator->bound1[ii] = orgn; + iterator->bound2[ii] = array_shape[ii] - fshape[ii] + orgn; + } + return 1; +} + +/* Calculate the offsets to the filter points, for all border regions and + the interior of the array: */ +int NI_InitFilterOffsets(PyArrayObject *array, Bool *footprint, + maybelong *filter_shape, maybelong* origins, + NI_ExtendMode mode, maybelong **offsets, maybelong *border_flag_value, + maybelong **coordinate_offsets) +{ + int rank, ii; + maybelong kk, ll, filter_size = 1, offsets_size = 1, max_size = 0; + maybelong max_stride = 0, *ashape = NULL, *astrides = NULL; + maybelong footprint_size = 0, coordinates[MAXDIM], position[MAXDIM]; + maybelong fshape[MAXDIM], forigins[MAXDIM], *po, *pc = NULL; + + rank = array->nd; + ashape = array->dimensions; + astrides = array->strides; + for(ii = 0; ii < rank; ii++) { + fshape[ii] = *filter_shape++; + forigins[ii] = origins ? *origins++ : 0.0; + } + /* the size of the footprint array: */ + for(ii = 0; ii < rank; ii++) + filter_size *= fshape[ii]; + /* calculate the number of non-zero elements in the footprint: */ + if (footprint) { + for(kk = 0; kk < filter_size; kk++) + if (footprint[kk]) + ++footprint_size; + } else { + footprint_size = filter_size; + } + /* calculate how many sets of offsets must be stored: */ + for(ii = 0; ii < rank; ii++) + offsets_size *= (ashape[ii] < fshape[ii] ? ashape[ii] : fshape[ii]); + /* allocate offsets data: */ + *offsets = (maybelong*)malloc(offsets_size * footprint_size * + sizeof(maybelong)); + if (!*offsets) { + PyErr_NoMemory(); + goto exit; + } + if (coordinate_offsets) { + *coordinate_offsets = (maybelong*)malloc(offsets_size * rank * + footprint_size * sizeof(maybelong)); + if (!*coordinate_offsets) { + PyErr_NoMemory(); + goto exit; + } + } + for(ii = 0; ii < rank; ii++) { + maybelong stride; + /* find maximum axis size: */ + if (ashape[ii] > max_size) + max_size = ashape[ii]; + /* find maximum stride: */ + stride = astrides[ii] < 0 ? -astrides[ii] : astrides[ii]; + if (stride > max_stride) + max_stride = stride; + /* coordinates for iterating over the kernel elements: */ + coordinates[ii] = 0; + /* keep track of the kernel position: */ + position[ii] = 0; + } + /* the flag to indicate that we are outside the border must have a + value that is larger than any possible offset: */ + *border_flag_value = max_size * max_stride + 1; + /* calculate all possible offsets to elements in the filter kernel, + for all regions in the array (interior and border regions): */ + po = *offsets; + if (coordinate_offsets) { + pc = *coordinate_offsets; + } + /* iterate over all regions: */ + for(ll = 0; ll < offsets_size; ll++) { + /* iterate over the elements in the footprint array: */ + for(kk = 0; kk < filter_size; kk++) { + maybelong offset = 0; + /* only calculate an offset if the footprint is 1: */ + if (!footprint || footprint[kk]) { + /* find offsets along all axes: */ + for(ii = 0; ii < rank; ii++) { + maybelong orgn = fshape[ii] / 2 + forigins[ii]; + maybelong cc = coordinates[ii] - orgn + position[ii]; + maybelong len = ashape[ii]; + /* apply boundary conditions, if necessary: */ + switch (mode) { + case NI_EXTEND_MIRROR: + if (cc < 0) { + if (len <= 1) { + cc = 0; + } else { + int sz2 = 2 * len - 2; + cc = sz2 * (int)(-cc / sz2) + cc; + cc = cc <= 1 - len ? cc + sz2 : -cc; + } + } else if (cc >= len) { + if (len <= 1) { + cc = 0; + } else { + int sz2 = 2 * len - 2; + cc -= sz2 * (int)(cc / sz2); + if (cc >= len) + cc = sz2 - cc; + } + } + break; + case NI_EXTEND_REFLECT: + if (cc < 0) { + if (len <= 1) { + cc = 0; + } else { + int sz2 = 2 * len; + if (cc < -sz2) + cc = sz2 * (int)(-cc / sz2) + cc; + cc = cc < -len ? cc + sz2 : -cc - 1; + } + } else if (cc >= len) { + if (len <= 1) {cc = 0; + } else { + int sz2 = 2 * len; + cc -= sz2 * (int)(cc / sz2); + if (cc >= len) + cc = sz2 - cc - 1; + } + } + break; + case NI_EXTEND_WRAP: + if (cc < 0) { + if (len <= 1) { + cc = 0; + } else { + int sz = len; + cc += sz * (int)(-cc / sz); + if (cc < 0) + cc += sz; + } + } else if (cc >= len) { + if (len <= 1) { + cc = 0; + } else { + int sz = len; + cc -= sz * (int)(cc / sz); + } + } + break; + case NI_EXTEND_NEAREST: + if (cc < 0) { + cc = 0; + } else if (cc >= len) { + cc = len - 1; + } + break; + case NI_EXTEND_CONSTANT: + if (cc < 0 || cc >= len) + cc = *border_flag_value; + break; + default: + PyErr_SetString(PyExc_RuntimeError, + "boundary mode not supported"); + goto exit; + } + + /* calculate offset along current axis: */ + if (cc == *border_flag_value) { + /* just flag that we are outside the border */ + offset = *border_flag_value; + if (coordinate_offsets) + pc[ii] = 0; + break; + } else { + /* use an offset that is possibly mapped from outside the + border: */ + cc = cc - position[ii]; + offset += astrides[ii] * cc; + if (coordinate_offsets) + pc[ii] = cc; + } + } + /* store the offset */ + *po++ = offset; + if (coordinate_offsets) + pc += rank; + } + /* next point in the filter: */ + for(ii = rank - 1; ii >= 0; ii--) { + if (coordinates[ii] < fshape[ii] - 1) { + coordinates[ii]++; + break; + } else { + coordinates[ii] = 0; + } + } + } + + /* move to the next array region: */ + for(ii = rank - 1; ii >= 0; ii--) { + int orgn = fshape[ii] / 2 + forigins[ii]; + if (position[ii] == orgn) { + position[ii] += ashape[ii] - fshape[ii] + 1; + if (position[ii] <= orgn) + position[ii] = orgn + 1; + } else { + position[ii]++; + } + if (position[ii] < ashape[ii]) { + break; + } else { + position[ii] = 0; + } + } + } + + exit: + if (PyErr_Occurred()) { + if (*offsets) + free(*offsets); + if (coordinate_offsets && *coordinate_offsets) + free(*coordinate_offsets); + return 0; + } else { + return 1; + } +} + +NI_CoordinateList* NI_InitCoordinateList(int size, int rank) +{ + NI_CoordinateList *list = \ + (NI_CoordinateList*)malloc(sizeof(NI_CoordinateList)); + if (!list) { + PyErr_NoMemory(); + return NULL; + } + list->block_size = size; + list->rank = rank; + list->blocks = NULL; + return list; +} + +int NI_CoordinateListStealBlocks(NI_CoordinateList *list1, + NI_CoordinateList *list2) +{ + if (list1->block_size != list2->block_size || + list1->rank != list2->rank) { + PyErr_SetString(PyExc_RuntimeError, "coordinate lists not compatible"); + return 1; + } + if (list1->blocks) { + PyErr_SetString(PyExc_RuntimeError, "first is list not empty"); + return 1; + } + list1->blocks = list2->blocks; + list2->blocks = NULL; + return 0; +} + +NI_CoordinateBlock* NI_CoordinateListAddBlock(NI_CoordinateList *list) +{ + NI_CoordinateBlock* block = NULL; + block = (NI_CoordinateBlock*)malloc(sizeof(NI_CoordinateBlock)); + if (!block) { + PyErr_NoMemory(); + goto exit; + } + block->coordinates = (maybelong*)malloc(list->block_size * list->rank * + sizeof(maybelong)); + if (!block->coordinates) { + PyErr_NoMemory(); + goto exit; + } + block->next = list->blocks; + list->blocks = block; + block->size = 0; + +exit: + if (PyErr_Occurred()) { + if (block) + free(block); + return NULL; + } + return block; +} + +NI_CoordinateBlock* NI_CoordinateListDeleteBlock(NI_CoordinateList *list) +{ + NI_CoordinateBlock* block = list->blocks; + if (block) { + list->blocks = block->next; + if (block->coordinates) + free(block->coordinates); + free(block); + } + return list->blocks; +} + +void NI_FreeCoordinateList(NI_CoordinateList *list) +{ + if (list) { + NI_CoordinateBlock *block = list->blocks; + while (block) { + NI_CoordinateBlock *tmp = block; + block = block->next; + if (tmp->coordinates) + free(tmp->coordinates); + free(tmp); + } + list->blocks = NULL; + free(list); + } +} Modified: trunk/scipy/ndimage/src/ni_support.h =================================================================== --- trunk/scipy/ndimage/src/ni_support.h 2008-07-24 21:13:18 UTC (rev 4561) +++ trunk/scipy/ndimage/src/ni_support.h 2008-07-25 16:26:25 UTC (rev 4562) @@ -1,323 +1,323 @@ -/* Copyright (C) 2003-2005 Peter J. Verveer - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NI_SUPPORT_H -#define NI_SUPPORT_H - -#include "nd_image.h" -#include -#include -#include -#include - -/* The different boundary conditions. The mirror condition is not used - by the python code, but C code is kept around in case we might wish - to add it. */ -typedef enum { - NI_EXTEND_FIRST = 0, - NI_EXTEND_NEAREST = 0, - NI_EXTEND_WRAP = 1, - NI_EXTEND_REFLECT = 2, - NI_EXTEND_MIRROR = 3, - NI_EXTEND_CONSTANT = 4, - NI_EXTEND_LAST = NI_EXTEND_CONSTANT, - NI_EXTEND_DEFAULT = NI_EXTEND_MIRROR -} NI_ExtendMode; - -/******************************************************************/ -/* Iterators */ -/******************************************************************/ - -/******************************************************************/ -/* Iterators */ -/******************************************************************/ - -/* the iterator structure: */ -typedef struct { - int rank_m1; - maybelong dimensions[MAXDIM]; - maybelong coordinates[MAXDIM]; - maybelong strides[MAXDIM]; - maybelong backstrides[MAXDIM]; -} NI_Iterator; - -/* initialize iterations over single array elements: */ -int NI_InitPointIterator(PyArrayObject*, NI_Iterator*); - -/* initialize iterations over an arbritrary sub-space: */ -int NI_SubspaceIterator(NI_Iterator*, UInt32); - -/* initialize iteration over array lines: */ -int NI_LineIterator(NI_Iterator*, int); - -/* reset an iterator */ -#define NI_ITERATOR_RESET(iterator) \ -{ \ - int _ii; \ - for(_ii = 0; _ii <= (iterator).rank_m1; _ii++) \ - (iterator).coordinates[_ii] = 0; \ -} - -/* go to the next point in a single array */ -#define NI_ITERATOR_NEXT(iterator, pointer) \ -{ \ - int _ii; \ - for(_ii = (iterator).rank_m1; _ii >= 0; _ii--) \ - if ((iterator).coordinates[_ii] < (iterator).dimensions[_ii]) { \ - (iterator).coordinates[_ii]++; \ - pointer += (iterator).strides[_ii]; \ - break; \ - } else { \ - (iterator).coordinates[_ii] = 0; \ - pointer -= (iterator).backstrides[_ii]; \ - } \ -} - -/* go to the next point in two arrays of the same size */ -#define NI_ITERATOR_NEXT2(iterator1, iterator2, pointer1, pointer2) \ -{ \ - int _ii; \ - for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) \ - if ((iterator1).coordinates[_ii] < (iterator1).dimensions[_ii]) { \ - (iterator1).coordinates[_ii]++; \ - pointer1 += (iterator1).strides[_ii]; \ - pointer2 += (iterator2).strides[_ii]; \ - break; \ - } else { \ - (iterator1).coordinates[_ii] = 0; \ - pointer1 -= (iterator1).backstrides[_ii]; \ - pointer2 -= (iterator2).backstrides[_ii]; \ - } \ -} - -/* go to the next point in three arrays of the same size */ -#define NI_ITERATOR_NEXT3(iterator1, iterator2, iterator3, \ - pointer1, pointer2, pointer3) \ -{ \ - int _ii; \ - for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) \ - if ((iterator1).coordinates[_ii] < (iterator1).dimensions[_ii]) { \ - (iterator1).coordinates[_ii]++; \ - pointer1 += (iterator1).strides[_ii]; \ - pointer2 += (iterator2).strides[_ii]; \ - pointer3 += (iterator3).strides[_ii]; \ - break; \ - } else { \ - (iterator1).coordinates[_ii] = 0; \ - pointer1 -= (iterator1).backstrides[_ii]; \ - pointer2 -= (iterator2).backstrides[_ii]; \ - pointer3 -= (iterator3).backstrides[_ii]; \ - } \ -} - -/* go to an arbitrary point in a single array */ -#define NI_ITERATOR_GOTO(iterator, destination, base, pointer) \ -{ \ - int _ii; \ - pointer = base; \ - for(_ii = (iterator).rank_m1; _ii >= 0; _ii--) { \ - pointer += destination[_ii] * (iterator).strides[_ii]; \ - (iterator).coordinates[_ii] = destination[_ii]; \ - } \ -} - -/******************************************************************/ -/* Line buffers */ -/******************************************************************/ - -/* the linebuffer structure: */ -typedef struct { - double *buffer_data; - maybelong buffer_lines, line_length, line_stride; - maybelong size1, size2, array_lines, next_line; - NI_Iterator iterator; - char* array_data; - NumarrayType array_type; - NI_ExtendMode extend_mode; - double extend_value; -} NI_LineBuffer; - -/* Get the next line being processed: */ -#define NI_GET_LINE(_buffer, _line) \ - ((_buffer).buffer_data + (_line) * ((_buffer).line_length + \ - (_buffer).size1 + (_buffer).size2)) -/* Allocate line buffer data */ -int NI_AllocateLineBuffer(PyArrayObject*, int, maybelong, maybelong, - maybelong*, maybelong, double**); - -/* Initialize a line buffer */ -int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong, - double*, NI_ExtendMode, double, NI_LineBuffer*); - -/* Extend a line in memory to implement boundary conditions: */ -int NI_ExtendLine(double*, maybelong, maybelong, maybelong, NI_ExtendMode, double); - -/* Copy a line from an array to a buffer: */ -int NI_ArrayToLineBuffer(NI_LineBuffer*, maybelong*, int*); - -/* Copy a line from a buffer to an array: */ -int NI_LineBufferToArray(NI_LineBuffer*); - -/******************************************************************/ -/* Multi-dimensional filter support functions */ -/******************************************************************/ - -/* the filter iterator structure: */ -typedef struct { - maybelong strides[MAXDIM], backstrides[MAXDIM]; - maybelong bound1[MAXDIM], bound2[MAXDIM]; -} NI_FilterIterator; - -/* Initialize a filter iterator: */ -int NI_InitFilterIterator(int, maybelong*, maybelong, maybelong*, - maybelong*, NI_FilterIterator*); - -/* Calculate the offsets to the filter points, for all border regions and - the interior of the array: */ -int NI_InitFilterOffsets(PyArrayObject*, Bool*, maybelong*, - maybelong*, NI_ExtendMode, maybelong**, maybelong*, maybelong**); - -/* Move to the next point in an array, possible changing the filter - offsets, to adapt to boundary conditions: */ -#define NI_FILTER_NEXT(iteratorf, iterator1, pointerf, pointer1) \ -{ \ - int _ii; \ - for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) { \ - maybelong _pp = (iterator1).coordinates[_ii]; \ - if (_pp < (iterator1).dimensions[_ii]) { \ - if (_pp < (iteratorf).bound1[_ii] || \ - _pp >= (iteratorf).bound2[_ii]) \ - pointerf += (iteratorf).strides[_ii]; \ - (iterator1).coordinates[_ii]++; \ - pointer1 += (iterator1).strides[_ii]; \ - break; \ - } else { \ - (iterator1).coordinates[_ii] = 0; \ - pointer1 -= (iterator1).backstrides[_ii]; \ - pointerf -= (iteratorf).backstrides[_ii]; \ - } \ - } \ -} - -/* Move to the next point in two arrays, possible changing the pointer - to the filter offsets when moving into a different region in the - array: */ -#define NI_FILTER_NEXT2(iteratorf, iterator1, iterator2, \ - pointerf, pointer1, pointer2) \ -{ \ - int _ii; \ - for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) { \ - maybelong _pp = (iterator1).coordinates[_ii]; \ - if (_pp < (iterator1).dimensions[_ii]) { \ - if (_pp < (iteratorf).bound1[_ii] || \ - _pp >= (iteratorf).bound2[_ii]) \ - pointerf += (iteratorf).strides[_ii]; \ - (iterator1).coordinates[_ii]++; \ - pointer1 += (iterator1).strides[_ii]; \ - pointer2 += (iterator2).strides[_ii]; \ - break; \ - } else { \ - (iterator1).coordinates[_ii] = 0; \ - pointer1 -= (iterator1).backstrides[_ii]; \ - pointer2 -= (iterator2).backstrides[_ii]; \ - pointerf -= (iteratorf).backstrides[_ii]; \ - } \ - } \ -} - -/* Move to the next point in three arrays, possible changing the pointer - to the filter offsets when moving into a different region in the - array: */ -#define NI_FILTER_NEXT3(iteratorf, iterator1, iterator2, iterator3, \ - pointerf, pointer1, pointer2, pointer3) \ -{ \ - int _ii; \ - for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) { \ - maybelong _pp = (iterator1).coordinates[_ii]; \ - if (_pp < (iterator1).dimensions[_ii]) { \ - if (_pp < (iteratorf).bound1[_ii] || \ - _pp >= (iteratorf).bound2[_ii]) \ - pointerf += (iteratorf).strides[_ii]; \ - (iterator1).coordinates[_ii]++; \ - pointer1 += (iterator1).strides[_ii]; \ - pointer2 += (iterator2).strides[_ii]; \ - pointer3 += (iterator3).strides[_ii]; \ - break; \ - } else { \ - (iterator1).coordinates[_ii] = 0; \ - pointer1 -= (iterator1).backstrides[_ii]; \ - pointer2 -= (iterator2).backstrides[_ii]; \ - pointer3 -= (iterator3).backstrides[_ii]; \ - pointerf -= (iteratorf).backstrides[_ii]; \ - } \ - } \ -} - -/* Move the pointer to the filter offsets according to the given - coordinates: */ -#define NI_FILTER_GOTO(iteratorf, iterator, fbase, pointerf) \ -{ \ - int _ii; \ - maybelong _jj; \ - pointerf = fbase; \ - for(_ii = iterator.rank_m1; _ii >= 0; _ii--) { \ - maybelong _pp = iterator.coordinates[_ii]; \ - maybelong b1 = (iteratorf).bound1[_ii]; \ - maybelong b2 = (iteratorf).bound2[_ii]; \ - if (_pp < b1) { \ - _jj = _pp; \ - } else if (_pp > b2 && b2 >= b1) { \ - _jj = _pp + b1 - b2; \ - } else { \ - _jj = b1; \ - } \ - pointerf += (iteratorf).strides[_ii] * _jj; \ - } \ -} - -typedef struct { - maybelong *coordinates; - int size; - void *next; -} NI_CoordinateBlock; - -typedef struct { - int block_size, rank; - void *blocks; -} NI_CoordinateList; - -NI_CoordinateList* NI_InitCoordinateList(int, int); -int NI_CoordinateListStealBlocks(NI_CoordinateList*, NI_CoordinateList*); -NI_CoordinateBlock* NI_CoordinateListAddBlock(NI_CoordinateList*); -NI_CoordinateBlock* NI_CoordinateListDeleteBlock(NI_CoordinateList*); -void NI_FreeCoordinateList(NI_CoordinateList*); - -#endif +/* Copyright (C) 2003-2005 Peter J. Verveer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NI_SUPPORT_H +#define NI_SUPPORT_H + +#include "nd_image.h" +#include +#include +#include +#include + +/* The different boundary conditions. The mirror condition is not used + by the python code, but C code is kept around in case we might wish + to add it. */ +typedef enum { + NI_EXTEND_FIRST = 0, + NI_EXTEND_NEAREST = 0, + NI_EXTEND_WRAP = 1, + NI_EXTEND_REFLECT = 2, + NI_EXTEND_MIRROR = 3, + NI_EXTEND_CONSTANT = 4, + NI_EXTEND_LAST = NI_EXTEND_CONSTANT, + NI_EXTEND_DEFAULT = NI_EXTEND_MIRROR +} NI_ExtendMode; + +/******************************************************************/ +/* Iterators */ +/******************************************************************/ + +/******************************************************************/ +/* Iterators */ +/******************************************************************/ + +/* the iterator structure: */ +typedef struct { + int rank_m1; + maybelong dimensions[MAXDIM]; + maybelong coordinates[MAXDIM]; + maybelong strides[MAXDIM]; + maybelong backstrides[MAXDIM]; +} NI_Iterator; + +/* initialize iterations over single array elements: */ +int NI_InitPointIterator(PyArrayObject*, NI_Iterator*); + +/* initialize iterations over an arbritrary sub-space: */ +int NI_SubspaceIterator(NI_Iterator*, UInt32); + +/* initialize iteration over array lines: */ +int NI_LineIterator(NI_Iterator*, int); + +/* reset an iterator */ +#define NI_ITERATOR_RESET(iterator) \ +{ \ + int _ii; \ + for(_ii = 0; _ii <= (iterator).rank_m1; _ii++) \ + (iterator).coordinates[_ii] = 0; \ +} + +/* go to the next point in a single array */ +#define NI_ITERATOR_NEXT(iterator, pointer) \ +{ \ + int _ii; \ + for(_ii = (iterator).rank_m1; _ii >= 0; _ii--) \ + if ((iterator).coordinates[_ii] < (iterator).dimensions[_ii]) { \ + (iterator).coordinates[_ii]++; \ + pointer += (iterator).strides[_ii]; \ + break; \ + } else { \ + (iterator).coordinates[_ii] = 0; \ + pointer -= (iterator).backstrides[_ii]; \ + } \ +} + +/* go to the next point in two arrays of the same size */ +#define NI_ITERATOR_NEXT2(iterator1, iterator2, pointer1, pointer2) \ +{ \ + int _ii; \ + for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) \ + if ((iterator1).coordinates[_ii] < (iterator1).dimensions[_ii]) { \ + (iterator1).coordinates[_ii]++; \ + pointer1 += (iterator1).strides[_ii]; \ + pointer2 += (iterator2).strides[_ii]; \ + break; \ + } else { \ + (iterator1).coordinates[_ii] = 0; \ + pointer1 -= (iterator1).backstrides[_ii]; \ + pointer2 -= (iterator2).backstrides[_ii]; \ + } \ +} + +/* go to the next point in three arrays of the same size */ +#define NI_ITERATOR_NEXT3(iterator1, iterator2, iterator3, \ + pointer1, pointer2, pointer3) \ +{ \ + int _ii; \ + for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) \ + if ((iterator1).coordinates[_ii] < (iterator1).dimensions[_ii]) { \ + (iterator1).coordinates[_ii]++; \ + pointer1 += (iterator1).strides[_ii]; \ + pointer2 += (iterator2).strides[_ii]; \ + pointer3 += (iterator3).strides[_ii]; \ + break; \ + } else { \ + (iterator1).coordinates[_ii] = 0; \ + pointer1 -= (iterator1).backstrides[_ii]; \ + pointer2 -= (iterator2).backstrides[_ii]; \ + pointer3 -= (iterator3).backstrides[_ii]; \ + } \ +} + +/* go to an arbitrary point in a single array */ +#define NI_ITERATOR_GOTO(iterator, destination, base, pointer) \ +{ \ + int _ii; \ + pointer = base; \ + for(_ii = (iterator).rank_m1; _ii >= 0; _ii--) { \ + pointer += destination[_ii] * (iterator).strides[_ii]; \ + (iterator).coordinates[_ii] = destination[_ii]; \ + } \ +} + +/******************************************************************/ +/* Line buffers */ +/******************************************************************/ + +/* the linebuffer structure: */ +typedef struct { + double *buffer_data; + maybelong buffer_lines, line_length, line_stride; + maybelong size1, size2, array_lines, next_line; + NI_Iterator iterator; + char* array_data; + NumarrayType array_type; + NI_ExtendMode extend_mode; + double extend_value; +} NI_LineBuffer; + +/* Get the next line being processed: */ +#define NI_GET_LINE(_buffer, _line) \ + ((_buffer).buffer_data + (_line) * ((_buffer).line_length + \ + (_buffer).size1 + (_buffer).size2)) +/* Allocate line buffer data */ +int NI_AllocateLineBuffer(PyArrayObject*, int, maybelong, maybelong, + maybelong*, maybelong, double**); + +/* Initialize a line buffer */ +int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong, + double*, NI_ExtendMode, double, NI_LineBuffer*); + +/* Extend a line in memory to implement boundary conditions: */ +int NI_ExtendLine(double*, maybelong, maybelong, maybelong, NI_ExtendMode, double); + +/* Copy a line from an array to a buffer: */ +int NI_ArrayToLineBuffer(NI_LineBuffer*, maybelong*, int*); + +/* Copy a line from a buffer to an array: */ +int NI_LineBufferToArray(NI_LineBuffer*); + +/******************************************************************/ +/* Multi-dimensional filter support functions */ +/******************************************************************/ + +/* the filter iterator structure: */ +typedef struct { + maybelong strides[MAXDIM], backstrides[MAXDIM]; + maybelong bound1[MAXDIM], bound2[MAXDIM]; +} NI_FilterIterator; + +/* Initialize a filter iterator: */ +int NI_InitFilterIterator(int, maybelong*, maybelong, maybelong*, + maybelong*, NI_FilterIterator*); + +/* Calculate the offsets to the filter points, for all border regions and + the interior of the array: */ +int NI_InitFilterOffsets(PyArrayObject*, Bool*, maybelong*, + maybelong*, NI_ExtendMode, maybelong**, maybelong*, maybelong**); + +/* Move to the next point in an array, possible changing the filter + offsets, to adapt to boundary conditions: */ +#define NI_FILTER_NEXT(iteratorf, iterator1, pointerf, pointer1) \ +{ \ + int _ii; \ + for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) { \ + maybelong _pp = (iterator1).coordinates[_ii]; \ + if (_pp < (iterator1).dimensions[_ii]) { \ + if (_pp < (iteratorf).bound1[_ii] || \ + _pp >= (iteratorf).bound2[_ii]) \ + pointerf += (iteratorf).strides[_ii]; \ + (iterator1).coordinates[_ii]++; \ + pointer1 += (iterator1).strides[_ii]; \ + break; \ + } else { \ + (iterator1).coordinates[_ii] = 0; \ + pointer1 -= (iterator1).backstrides[_ii]; \ + pointerf -= (iteratorf).backstrides[_ii]; \ + } \ + } \ +} + +/* Move to the next point in two arrays, possible changing the pointer + to the filter offsets when moving into a different region in the + array: */ +#define NI_FILTER_NEXT2(iteratorf, iterator1, iterator2, \ + pointerf, pointer1, pointer2) \ +{ \ + int _ii; \ + for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) { \ + maybelong _pp = (iterator1).coordinates[_ii]; \ + if (_pp < (iterator1).dimensions[_ii]) { \ + if (_pp < (iteratorf).bound1[_ii] || \ + _pp >= (iteratorf).bound2[_ii]) \ + pointerf += (iteratorf).strides[_ii]; \ + (iterator1).coordinates[_ii]++; \ + pointer1 += (iterator1).strides[_ii]; \ + pointer2 += (iterator2).strides[_ii]; \ + break; \ + } else { \ + (iterator1).coordinates[_ii] = 0; \ + pointer1 -= (iterator1).backstrides[_ii]; \ + pointer2 -= (iterator2).backstrides[_ii]; \ + pointerf -= (iteratorf).backstrides[_ii]; \ + } \ + } \ +} + +/* Move to the next point in three arrays, possible changing the pointer + to the filter offsets when moving into a different region in the + array: */ +#define NI_FILTER_NEXT3(iteratorf, iterator1, iterator2, iterator3, \ + pointerf, pointer1, pointer2, pointer3) \ +{ \ + int _ii; \ + for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) { \ + maybelong _pp = (iterator1).coordinates[_ii]; \ + if (_pp < (iterator1).dimensions[_ii]) { \ + if (_pp < (iteratorf).bound1[_ii] || \ + _pp >= (iteratorf).bound2[_ii]) \ + pointerf += (iteratorf).strides[_ii]; \ + (iterator1).coordinates[_ii]++; \ + pointer1 += (iterator1).strides[_ii]; \ + pointer2 += (iterator2).strides[_ii]; \ + pointer3 += (iterator3).strides[_ii]; \ + break; \ + } else { \ + (iterator1).coordinates[_ii] = 0; \ + pointer1 -= (iterator1).backstrides[_ii]; \ + pointer2 -= (iterator2).backstrides[_ii]; \ + pointer3 -= (iterator3).backstrides[_ii]; \ + pointerf -= (iteratorf).backstrides[_ii]; \ + } \ + } \ +} + +/* Move the pointer to the filter offsets according to the given + coordinates: */ +#define NI_FILTER_GOTO(iteratorf, iterator, fbase, pointerf) \ +{ \ + int _ii; \ + maybelong _jj; \ + pointerf = fbase; \ + for(_ii = iterator.rank_m1; _ii >= 0; _ii--) { \ + maybelong _pp = iterator.coordinates[_ii]; \ + maybelong b1 = (iteratorf).bound1[_ii]; \ + maybelong b2 = (iteratorf).bound2[_ii]; \ + if (_pp < b1) { \ + _jj = _pp; \ + } else if (_pp > b2 && b2 >= b1) { \ + _jj = _pp + b1 - b2; \ + } else { \ + _jj = b1; \ + } \ + pointerf += (iteratorf).strides[_ii] * _jj; \ + } \ +} + +typedef struct { + maybelong *coordinates; + int size; + void *next; +} NI_CoordinateBlock; + +typedef struct { + int block_size, rank; + void *blocks; +} NI_CoordinateList; + +NI_CoordinateList* NI_InitCoordinateList(int, int); +int NI_CoordinateListStealBlocks(NI_CoordinateList*, NI_CoordinateList*); +NI_CoordinateBlock* NI_CoordinateListAddBlock(NI_CoordinateList*); +NI_CoordinateBlock* NI_CoordinateListDeleteBlock(NI_CoordinateList*); +void NI_FreeCoordinateList(NI_CoordinateList*); + +#endif From scipy-svn at scipy.org Fri Jul 25 16:46:46 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 25 Jul 2008 15:46:46 -0500 (CDT) Subject: [Scipy-svn] r4563 - branches/Interpolate1D Message-ID: <20080725204646.2C86E39C8EE@scipy.org> Author: fcady Date: 2008-07-25 15:46:43 -0500 (Fri, 25 Jul 2008) New Revision: 4563 Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/interpolate_wrapper.py Log: better unit tests, and allow user to input a callable class that has been instantiated but does not yet have x and y Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-25 16:26:25 UTC (rev 4562) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-25 20:46:43 UTC (rev 4563) @@ -192,6 +192,7 @@ """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string + # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash a warning (esp if we interpolate missing values), but work anyway. def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ @@ -212,12 +213,9 @@ if remove_bad_data: x, y = self._remove_bad_data(x, y, bad_data) - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - + # FIXME : may be good to let x and y be initialized later, or changed after-the-fact + self._init_xy(x, y) + # store interpolation functions for each range self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) self.low = self._init_interp_method(self._x, self._y, low, lowkw) @@ -236,8 +234,14 @@ x = x[mask] y = y[mask] return x, y - + def _init_xy(self, x, y): + # select proper dataypes and make arrays + self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 + self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._x = make_array_safe(x, self._xdtype).copy() + self._y = make_array_safe(y, self._ydtype).copy() + def _init_interp_method(self, x, y, interp_arg, kw): """ User provides interp_arg and dictionary kw. _init_interp_method @@ -251,28 +255,55 @@ from inspect import isclass, isfunction + # primary usage : user passes a string indicating a known function if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] result = lambda new_x : func(self._x, self._y, new_x, **kw) elif interp_arg in ['Spline', Spline, 'spline']: - # spline is a special case of above + # use the Spline class from fitpack_wrapper result = Spline(self._x, self._y, **kw) elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad']: - # specify certain kinds of splines + 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: + # specify specific kinds of splines if interp_arg in ['cubic', 'Cubic']: result = Spline(self._x, self._y, k=3) elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: result = Spline(self._x, self._y, k=2) + elif interp_arg in ['Quintic', 'quintic']: + result = Spline(self._x, self._y, k=4) + + # secondary usage : user passes a callable class + elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): + if hasattr(interp_arg, 'init_xy'): + result = interp_arg(**kw) + result.init_xy(self._x, self._y) + elif hasattr(interp_arg, 'set_xy'): + result = interp_arg(**kw) + result.set_xy(self._x, self._y) + else: + result = interp_arg(x, y, **kw) + + # user passes an instance of a callable class which has yet + # to have its x and y initialized. + elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): + result = interp_arg + result.init_xy(self._x, self._y) + elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): + result = interp_arg + result.set_xy(self._x, self._y) + + # user passes a function to be called + elif isfunction(interp_arg) and interp.func_code.argcount == 3: + result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) elif isfunction(interp_arg): - # assume user has passed a function result = lambda new_x : interp_arg(new_x, **kw) - elif isclass(interp_arg): - result = interp_arg(x, y, **kw) + + # default : user has passed a default value to always be returned else: result = np.vectorize(lambda new_x : interp_arg) + return result def __call__(self, x): @@ -315,7 +346,7 @@ def assertAllclose(self, x, y): self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - def test__interpolate_wrapper(self): + def test_interpolate_wrapper(self): """ run unit test contained in interpolate_wrapper.py """ print "\n\nTESTING _interpolate_wrapper MODULE" @@ -323,7 +354,7 @@ T = Test() T.runTest() - def test__fitpack_wrapper(self): + def test_fitpack_wrapper(self): """ run unit test contained in fitpack_wrapper.py """ print "\n\nTESTING _fitpack_wrapper MODULE" @@ -331,6 +362,56 @@ T = Test() T.runTest() + def test_instantiationFormat(self): + """ make sure : all allowed instantiation formats are supported + """ + + # make sure : an instance of a callable class in which + # x and y haven't been initiated works + print 'hello' + N = 7 #must be > 5 + x = np.arange(N) + y = np.arange(N) + interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_callFormat(self): + """ make sure : all allowed calling formats are supported + """ + # make sure : having no out-of-range elements in new_x is fine + # There was a bug with this earlier. + N = 5 + x = arange(N) + y = arange(N) + new_x = arange(1,N-1)+.2 + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_removeBad(self): + """make sure : interp1d works with bad data + """ + N = 7.0 # must be >=5 + x = arange(N); x[2] = np.NaN + y = arange(N); y[4] = None; y[0]=np.NaN + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ + remove_bad_data = True, bad_data = [None]) + self.assertAllclose(new_x, new_y) + + def test_intper1d(self): + """ + make sure : interp1d works, at least in the linear case + """ + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') + self.assertAllclose(new_x, new_y) + def test_spline1_defaultExt(self): """ make sure : spline order 1 (linear) interpolation works correctly @@ -401,40 +482,11 @@ self.assertAllclose(new_x, new_y) - def test_noLow(self): - """ - make sure : having no out-of-range elements in new_x is fine - There was a bug with this earlier. - """ - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) + - def test_intper1d(self): - """ - make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) + - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) + if __name__ == '__main__': unittest.main() \ No newline at end of file Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-25 16:26:25 UTC (rev 4562) +++ branches/Interpolate1D/TODO.txt 2008-07-25 20:46:43 UTC (rev 4563) @@ -5,25 +5,33 @@ at appropriate places in the code. +**include license for FITPACK + take it from scipy.interpolate. + + **handle smoothing in fitpack_wrapper The default smoothing parameter (s) means we aren't actually doing interpolation. Also, small but non-zero s makes the algorithm very slow. Figure out how to handle this, prob by not letting the user see s and setting it to 0. - This may be best handled by modifying fitpack_wrapper.py. + Then again, users very often want to smooth data at the same + time. FITPACK suffers from VERY slow performance when s + is very small but not 0. This is a problem. **pick best spline Under-the-hood machinery currently comes from _interpolate.cpp (used in enthought.interpolate) and FITPACK (Fortran, used in scipy.interpolate). This isn't necessarily the best (for example, - speed of FITPACK is highly sensitive to parameter s). Other code + speed of FITPACK is highly sensitive to smoothing parameter s). Other code is used in scipy.ndimage and scipy.signal. There is surely other code out there too. Figure out what is best and incorporate it. - Signal code is slower than FITPACK, and NDImage really only does - filtering. I'm inclined to stay with FITPACK. + Signal code is slower than FITPACK, and NDImage requires a + regular grid. I'm inclined to stay with FITPACK, except for the + slow performance when x is small (we could add a hack to not + let s be tiny > 0). **clean up fitpack_wrapper.py @@ -36,7 +44,8 @@ **comment interpolate1d There's comments there already, but they should be - made better. + made better. Plus, features are changing, which requires + updating the documentation. **doc strings for interpolate1d and its members @@ -51,8 +60,8 @@ updates of documentation easier. -**figure out NumPy version stuff with vectorize. - In function interpolate1d._format_array. +**figure out NumPy stuff with vectorize. + In function interpolate1d.__call__ It would be nice to remove the hack I used. I believe vectorize is supposed to handle arrays of length 0, but it's not working on my computer. @@ -96,45 +105,25 @@ shouldn't be done until interpolate1d is more settled. There is an interesting problem here. Most of the extensions - I have assume a regular grid. First off, this is often unrealistic. - Secondly, if I DO use a rectangular grid, how do I deal with bad + I have assume a regular grid. First off, this is often not general. + Secondly, if I DO use a regular grid, how do I deal with bad data? The best way is probably a pre-processing where you interpolate values for the bad points (linear would be a nice simple way to do it at first, just to get it working) -**more convenient way to enter kw arguments - currently users have to pass in dictionaries of additional - keyword arguments for specific interpolation types. - This is kind of awkward, and it would be nice to let - them pass in a single argument. But this is low priority. - - -**allow y to be 2-dimensional - That way the interpolated function is from R1 -> Rn, and - not just R1 -> R1. This requires some thinking about axes. - - The interpolation should, I think, be along columns, so each - row of y is one complete observation. This is because 1) rows - are separated more from each other when an array is displayed, - and 2) the user may want to enter the data as y=array([obs1, obs2, ...]). - - There are two big problem. First, interpolate_wrapper interpolates - along rows, because each row is contiguous. Second, - FITPACK doesn't support 2D y arrays. - - The solution is to have the user indicate which axis to interpolate - along, and take the transpose if need be (also copy, so that - the columns become contiguous). Then when the user enters newx, - all under-the-hood interpolation is performed on contiguous - arrays. - - Whatever is done must be very well commented. - - Also, there's a problem with removing bad data and still - retaining a rectangular array. I would have to store a list - of (x,y) pairs, which suggests I should do this with a wrapper - function anyway. Not memory efficient, but oh well. In the - future, however, when x is a ND array, I should work around this; - I should have it be Rn -> Rm and fill in missing values to the best - of my ability. +**allow y to be 2-dimensional? + It is not decided whether this feature should be supported, but + I don't think it should; I think there should be another class with + that functionality which wraps Interpolate1d. The main reasons + are: + 1) interpolation should probably be along columns, so the user + can enter data as enter the data as y=array([obs1, obs2, ...]). But + the interpolate_wrapper and fitpack_wrapper interpolate along + rows; this means there would be messy transposes in the code. + 2) FITPACK doesn't support 2D y arrays, which means we would + have to store the y columns separately + 3) If we remove bad data, bearing in mind (2), we would also + have to store copies of x, since the bad data in the y cols aren't + at the same locations, meaning that different data points should be + deleted for each column. Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-25 16:26:25 UTC (rev 4562) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-25 20:46:43 UTC (rev 4563) @@ -14,7 +14,7 @@ import numpy as np -import dfitpack # lower-level wrapper around FITPACK +import dfitpack # extension module containing FITPACK subroutines class Spline(object): @@ -30,7 +30,7 @@ BivariateSpline - a similar class for bivariate spline interpolation """ - def __init__(self, x, y, w=None, bbox = [None]*2, k=3, s=0.0): + def __init__(self, x=None, y=None, w=None, bbox = [None]*2, k=3, s=0.0): """ Input: x,y - 1-d sequences of data points (x must be @@ -49,9 +49,23 @@ if 1/w[i] is an estimate of the standard deviation of y[i]. """ + + self._k = k + self._s = s + self._bbox = bbox + self._w = w + + if x is not None and y is not None: + self.init_xy(x, y) + self._is_initialized = True + else: + self._is_initialized = False + + def init_xy(self, x, y): + #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier - data = dfitpack.fpcurf0(x, y, k, w=w, - xb=bbox[0], xe=bbox[1], s=s) + data = dfitpack.fpcurf0(x, y, self._k, w=self._w, + xb=self._bbox[0], xe=self._bbox[1], s=self._s) if data[-1]==1: # nest too small, setting to maximum bound data = self._reset_nest(data) @@ -59,6 +73,8 @@ # the relevant part of self._reset_class() n,t,c,k,ier = data[7],data[8],data[9],data[5],data[-1] self._eval_args = t[:n],c[:n],k + + self._is_initialized = True def _reset_nest(self, data, nest=None): n = data[10] @@ -101,11 +117,13 @@ if x is (partially) ordered. """ - - if len(x) == 0: return np.array([]) #hack to cope with shape (0,) - if nu is None: - return dfitpack.splev(*(self._eval_args+(x,))) - return dfitpack.splder(nu=nu,*(self._eval_args+(x,))) + if self._is_initialized: + if len(x) == 0: return np.array([]) #hack to cope with shape (0,) + if nu is None: + return dfitpack.splev(*(self._eval_args+(x,))) + return dfitpack.splder(nu=nu,*(self._eval_args+(x,))) + else: + raise TypeError, "x and y must be set before interpolation is possible" def get_knots(self): """ Return the positions of (boundary and interior) @@ -165,23 +183,58 @@ def assertAllclose(self, x, y): self.assert_(np.allclose(x, y)) - def test_linearSpl(self): + def test_linearInterp(self): + """ make sure : linear interpolation (spline with order = 1, s = 0)works + """ N = 3000. x = np.arange(N) y = np.arange(N) - T1 = time.clock() + #T1 = time.clock() interp_func = Spline(x, y, k=1) - T2 = time.clock() - print "time to create order 1 spline interpolation function with N = %i:" % N, T2 - T1 + #T2 = time.clock() + #print "time to create order 1 spline interpolation function with N = %i:" % N, T2 - T1 new_x = np.arange(N)+0.5 - t1 = time.clock() + #t1 = time.clock() new_y = interp_func(new_x) - t2 = time.clock() - print "time for order 1 spline interpolation with N = %i:" % N, t2 - t1 + #t2 = time.clock() + #print "time for order 1 spline interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) + + def test_quadInterp(self): + """ make sure : quadratic interpolation (spline with order = 2, s = 0)works + """ + N = 3000. + x = np.arange(N) + y = x**2 + interp_func = Spline(x, y, k=2) + #print "time to create order 1 spline interpolation function with N = %i:" % N, T2 - T1 + new_x = np.arange(N)+0.5 + #t1 = time.clock() + new_y = interp_func(x) + #t2 = time.clock() + #print "time for order 1 spline interpolation with N = %i:" % N, t2 - t1 + self.assertAllclose(new_y, y) + + + def test_inputFormat(self): + """ make sure : it's possible to instantiate Spline without x and y + """ + #print "testing input format" + N = 3000. + x = np.arange(N) + y = np.arange(N) + interp_func = Spline(k=1) + interp_func.init_xy(x, y) + new_x = np.arange(N)+0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) def runTest(self): - self.test_linearSpl() + test_list = [name for name in dir(self) if name.find('test_')==0] + for test_name in test_list: + exec("self.%s()" % test_name) + + if __name__ == '__main__': unittest.main() Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-25 16:26:25 UTC (rev 4562) +++ branches/Interpolate1D/interpolate1d.py 2008-07-25 20:46:43 UTC (rev 4563) @@ -192,6 +192,7 @@ """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string + # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash a warning (esp if we interpolate missing values), but work anyway. def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ @@ -212,12 +213,9 @@ if remove_bad_data: x, y = self._remove_bad_data(x, y, bad_data) - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - + # FIXME : may be good to let x and y be initialized later, or changed after-the-fact + self._init_xy(x, y) + # store interpolation functions for each range self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) self.low = self._init_interp_method(self._x, self._y, low, lowkw) @@ -236,8 +234,14 @@ x = x[mask] y = y[mask] return x, y - + def _init_xy(self, x, y): + # select proper dataypes and make arrays + self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 + self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._x = make_array_safe(x, self._xdtype).copy() + self._y = make_array_safe(y, self._ydtype).copy() + def _init_interp_method(self, x, y, interp_arg, kw): """ User provides interp_arg and dictionary kw. _init_interp_method @@ -251,28 +255,55 @@ from inspect import isclass, isfunction + # primary usage : user passes a string indicating a known function if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] result = lambda new_x : func(self._x, self._y, new_x, **kw) elif interp_arg in ['Spline', Spline, 'spline']: - # spline is a special case of above + # use the Spline class from fitpack_wrapper result = Spline(self._x, self._y, **kw) elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad']: - # specify certain kinds of splines + 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: + # specify specific kinds of splines if interp_arg in ['cubic', 'Cubic']: result = Spline(self._x, self._y, k=3) elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: result = Spline(self._x, self._y, k=2) + elif interp_arg in ['Quintic', 'quintic']: + result = Spline(self._x, self._y, k=4) + + # secondary usage : user passes a callable class + elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): + if hasattr(interp_arg, 'init_xy'): + result = interp_arg(**kw) + result.init_xy(self._x, self._y) + elif hasattr(interp_arg, 'set_xy'): + result = interp_arg(**kw) + result.set_xy(self._x, self._y) + else: + result = interp_arg(x, y, **kw) + + # user passes an instance of a callable class which has yet + # to have its x and y initialized. + elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): + result = interp_arg + result.init_xy(self._x, self._y) + elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): + result = interp_arg + result.set_xy(self._x, self._y) + + # user passes a function to be called + elif isfunction(interp_arg) and interp.func_code.argcount == 3: + result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) elif isfunction(interp_arg): - # assume user has passed a function result = lambda new_x : interp_arg(new_x, **kw) - elif isclass(interp_arg): - result = interp_arg(x, y, **kw) + + # default : user has passed a default value to always be returned else: result = np.vectorize(lambda new_x : interp_arg) + return result def __call__(self, x): @@ -315,7 +346,7 @@ def assertAllclose(self, x, y): self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - def test__interpolate_wrapper(self): + def test_interpolate_wrapper(self): """ run unit test contained in interpolate_wrapper.py """ print "\n\nTESTING _interpolate_wrapper MODULE" @@ -323,7 +354,7 @@ T = Test() T.runTest() - def test__fitpack_wrapper(self): + def test_fitpack_wrapper(self): """ run unit test contained in fitpack_wrapper.py """ print "\n\nTESTING _fitpack_wrapper MODULE" @@ -331,6 +362,56 @@ T = Test() T.runTest() + def test_instantiationFormat(self): + """ make sure : all allowed instantiation formats are supported + """ + + # make sure : an instance of a callable class in which + # x and y haven't been initiated works + print 'hello' + N = 7 #must be > 5 + x = np.arange(N) + y = np.arange(N) + interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_callFormat(self): + """ make sure : all allowed calling formats are supported + """ + # make sure : having no out-of-range elements in new_x is fine + # There was a bug with this earlier. + N = 5 + x = arange(N) + y = arange(N) + new_x = arange(1,N-1)+.2 + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_removeBad(self): + """make sure : interp1d works with bad data + """ + N = 7.0 # must be >=5 + x = arange(N); x[2] = np.NaN + y = arange(N); y[4] = None; y[0]=np.NaN + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ + remove_bad_data = True, bad_data = [None]) + self.assertAllclose(new_x, new_y) + + def test_intper1d(self): + """ + make sure : interp1d works, at least in the linear case + """ + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') + self.assertAllclose(new_x, new_y) + def test_spline1_defaultExt(self): """ make sure : spline order 1 (linear) interpolation works correctly @@ -401,40 +482,11 @@ self.assertAllclose(new_x, new_y) - def test_noLow(self): - """ - make sure : having no out-of-range elements in new_x is fine - There was a bug with this earlier. - """ - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) + - def test_intper1d(self): - """ - make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) + - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) + if __name__ == '__main__': unittest.main() \ No newline at end of file Modified: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-25 16:26:25 UTC (rev 4562) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-25 20:46:43 UTC (rev 4563) @@ -155,7 +155,7 @@ t1 = time.clock() new_y = linear(x, y, new_x) t2 = time.clock() - print "time for linear interpolation with N = %i:" % N, t2 - t1 + #print "time for linear interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) @@ -168,7 +168,7 @@ t1 = time.clock() new_y = block_average_above(x, y, new_x) t2 = time.clock() - print "time for block_avg_above interpolation with N = %i:" % N, t2 - t1 + #print "time for block_avg_above interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5], [0.0, 0.5, 2.5, 4.5, 6.5]) def test_linear2(self): @@ -179,7 +179,7 @@ t1 = time.clock() new_y = linear(x, y, new_x) t2 = time.clock() - print "time for 2D linear interpolation with N = %i:" % N, t2 - t1 + #print "time for 2D linear interpolation with N = %i:" % N, t2 - t1 self.assertAllclose(new_y[:5,:5], [[ 0.5, 1.5, 2.5, 3.5, 4.5], [ 0.5, 1.5, 2.5, 3.5, 4.5], @@ -188,22 +188,21 @@ [ 0.5, 1.5, 2.5, 3.5, 4.5]]) def test_logarithmic(self): - N = 3000. + N = 4000. x = arange(N) y = arange(N) new_x = arange(N)+0.5 t1 = time.clock() new_y = logarithmic(x, y, new_x) t2 = time.clock() - print "time for logarithmic interpolation with N = %i:" % N, t2 - t1 + #print "time for logarithmic interpolation with N = %i:" % N, t2 - t1 correct_y = [np.NaN, 1.41421356, 2.44948974, 3.46410162, 4.47213595] self.assertAllclose(new_y[:5], correct_y) def runTest(self): - self.test_linear() - self.test_block_average_above() - self.test_linear2() - self.test_logarithmic() + test_list = [name for name in dir(self) if name.find('test_')==0] + for test_name in test_list: + exec("self.%s()" % test_name) if __name__ == '__main__': unittest.main() From scipy-svn at scipy.org Mon Jul 28 15:41:45 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 14:41:45 -0500 (CDT) Subject: [Scipy-svn] r4564 - branches/Interpolate1D Message-ID: <20080728194145.ABCC139C4FD@scipy.org> Author: fcady Date: 2008-07-28 14:41:44 -0500 (Mon, 28 Jul 2008) New Revision: 4564 Added: branches/Interpolate1D/example_script.py Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/interpolate1d.py Log: added example script demonstrating use of interpolate1d.py Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-25 20:46:43 UTC (rev 4563) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-28 19:41:44 UTC (rev 4564) @@ -130,7 +130,7 @@ x -- list or NumPy array x includes the x-values for the data set to interpolate from. It must be sorted in - ascending order + ascending order. y -- list or NumPy array y includes the y-values for the data set to @@ -159,7 +159,7 @@ a number') for all values outside the range of x. remove_bad_data -- bool - indicates whether to remove bad data. + indicates whether to remove bad data points from x and y. bad_data -- list List of values (in x or y) which indicate unacceptable data. All points @@ -168,7 +168,7 @@ numpy.NaN is always considered bad data. - Acceptable Input Strings + Some Acceptable Input Strings ------------------------ "linear" -- linear interpolation : default @@ -192,7 +192,8 @@ """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash a warning (esp if we interpolate missing values), but work anyway. + # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash + # a warning (esp if we interpolate missing values), but work anyway. def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ @@ -203,8 +204,7 @@ # check acceptable size and dimensions x = np.array(x) y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ - arrays of length 0" + assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" assert x.ndim == 1 , "x must be one-dimensional" assert y.ndim == 1 , "y must be one-dimensional" assert len(x) == len(y) , "x and y must be of the same length" @@ -213,13 +213,14 @@ if remove_bad_data: x, y = self._remove_bad_data(x, y, bad_data) + # store data # FIXME : may be good to let x and y be initialized later, or changed after-the-fact self._init_xy(x, y) # store interpolation functions for each range - self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) - self.low = self._init_interp_method(self._x, self._y, low, lowkw) - self.high = self._init_interp_method(self._x, self._y, high, highkw) + self.kind = self._init_interp_method(kind, kindkw) + self.low = self._init_interp_method(low, lowkw) + self.high = self._init_interp_method(high, highkw) def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): """ removes data points whose x or y coordinate is @@ -242,7 +243,7 @@ self._x = make_array_safe(x, self._xdtype).copy() self._y = make_array_safe(y, self._ydtype).copy() - def _init_interp_method(self, x, y, interp_arg, kw): + def _init_interp_method(self, interp_arg, kw): """ User provides interp_arg and dictionary kw. _init_interp_method returns the interpolating function from x and y specified by interp_arg, @@ -295,7 +296,11 @@ result.set_xy(self._x, self._y) # user passes a function to be called - elif isfunction(interp_arg) and interp.func_code.argcount == 3: + # FIXME : I think there is too much flexibility allowed here; it makes + # there be more pathological side cases to consider. Functions + # should perhaps be reqired to be of the form f(x, y, newx, **kw) + elif isfunction(interp_arg) and interp.func_code.argcount >= 3: + # assume x, y and newx are all passed to interp_arg result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) elif isfunction(interp_arg): result = lambda new_x : interp_arg(new_x, **kw) @@ -306,7 +311,7 @@ return result - def __call__(self, x): + def __call__(self, newx): """ Input x must be in sorted order. Breaks x into pieces in-range, below-range, and above range. @@ -314,24 +319,24 @@ """ # FIXME : make_array_safe may also be called within the interpolation technique. # waste of time, but ok for the time being. - x = make_array_safe(x) + newx = make_array_safe(newx) # masks indicate which elements fall into which interpolation region - low_mask = xself._x[-1] + low_mask = newxself._x[-1] interp_mask = (~low_mask) & (~high_mask) # use correct function for x values in each region - if len(x[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. + if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. # if/else is a hack, since vectorize is failing # to work on lists/arrays of length 0 # on the computer where this is being # developed - else: new_low = self.low(x[low_mask]) - if len(x[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(x[interp_mask]) - if len(x[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(x[high_mask]) + else: new_low = self.low(newx[low_mask]) + if len(newx[interp_mask])==0: new_interp=np.array([]) + else: new_interp = self.kind(newx[interp_mask]) + if len(newx[high_mask]) == 0: new_high = np.array([]) + else: new_high = self.high(newx[high_mask]) result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes # Would be nice to say result = zeros(dtype=?) @@ -349,7 +354,7 @@ def test_interpolate_wrapper(self): """ run unit test contained in interpolate_wrapper.py """ - print "\n\nTESTING _interpolate_wrapper MODULE" + #print "\n\nTESTING _interpolate_wrapper MODULE" from interpolate_wrapper import Test T = Test() T.runTest() @@ -357,7 +362,7 @@ def test_fitpack_wrapper(self): """ run unit test contained in fitpack_wrapper.py """ - print "\n\nTESTING _fitpack_wrapper MODULE" + #print "\n\nTESTING _fitpack_wrapper MODULE" from fitpack_wrapper import Test T = Test() T.runTest() @@ -367,8 +372,7 @@ """ # make sure : an instance of a callable class in which - # x and y haven't been initiated works - print 'hello' + # x and y haven't been initiated works N = 7 #must be > 5 x = np.arange(N) y = np.arange(N) @@ -402,9 +406,8 @@ self.assertAllclose(new_x, new_y) def test_intper1d(self): + """ make sure : interp1d works, at least in the linear case """ - make sure : interp1d works, at least in the linear case - """ N = 7 x = arange(N) y = arange(N) @@ -413,11 +416,10 @@ self.assertAllclose(new_x, new_y) def test_spline1_defaultExt(self): - """ - make sure : spline order 1 (linear) interpolation works correctly + """ make sure : spline order 1 (linear) interpolation works correctly make sure : default extrapolation works """ - print "\n\nTESTING LINEAR (1st ORDER) SPLINE" + #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" N = 7 # must be > 5 x = np.arange(N) y = np.arange(N) @@ -430,13 +432,12 @@ self.assert_(new_y[-1] == 599.73) def test_spline2(self): - """ - make sure : order-2 splines work on linear data + """ make sure : order-2 splines work on linear data make sure : order-2 splines work on non-linear data make sure : 'cubic' and 'quad' as arguments yield the desired spline """ - print "\n\nTESTING 2nd ORDER SPLINE" + #print "\n\nTESTING 2nd ORDER SPLINE" N = 7 #must be > 5 x = np.arange(N) y = np.arange(N) @@ -462,11 +463,10 @@ def test_linear(self): - """ - make sure : linear interpolation works + """ make sure : linear interpolation works make sure : linear extrapolation works """ - print "\n\nTESTING LINEAR INTERPOLATION" + #print "\n\nTESTING LINEAR INTERPOLATION" N = 7 x = arange(N) y = arange(N) @@ -482,11 +482,6 @@ self.assertAllclose(new_x, new_y) - - - - - if __name__ == '__main__': unittest.main() \ No newline at end of file Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-25 20:46:43 UTC (rev 4563) +++ branches/Interpolate1D/TODO.txt 2008-07-28 19:41:44 UTC (rev 4564) @@ -5,26 +5,25 @@ at appropriate places in the code. -**include license for FITPACK - take it from scipy.interpolate. +************ PRESSING ISSUES *********** +**handle smoothing + There is a question of whether, if, and how much to allow + smoothing of the data. If we smooth, we're not technically + interpolating, but users often want to smooth data. -**handle smoothing in fitpack_wrapper - The default smoothing parameter (s) means we aren't actually - doing interpolation. Also, small but non-zero s makes the - algorithm very slow. Figure out how to handle this, prob by - not letting the user see s and setting it to 0. + In fitpack_wrapper the smoothing parameter is s. It now defaults + to 0.0 (exact interpolation). Zero smoothing and moderate (s ~ 1) + are fast, but small non-zero s makes the algorithm VERY slow. - Then again, users very often want to smooth data at the same - time. FITPACK suffers from VERY slow performance when s - is very small but not 0. This is a problem. + Currently the user does see s in Interpolate1d; no smoothing + is available. The Spline class, however, has it available (default = 0.0). **pick best spline Under-the-hood machinery currently comes from _interpolate.cpp (used in enthought.interpolate) and FITPACK (Fortran, used in - scipy.interpolate). This isn't necessarily the best (for example, - speed of FITPACK is highly sensitive to smoothing parameter s). Other code + scipy.interpolate). This isn't necessarily the best. Other code is used in scipy.ndimage and scipy.signal. There is surely other code out there too. Figure out what is best and incorporate it. @@ -35,15 +34,44 @@ **clean up fitpack_wrapper.py - Currently is all hacked together from scipy.interpolate. + Currently it is all hacked together from scipy.interpolate. There is unused functionality, commented-out functionality, and other undesirables. Once it has been established what - we will include, that stuff needs to be cleaned up, and the + we will include, and what should be accessible to the user, + that stuff needs to be cleaned up, and the rest needs to be either removed or set aside. + +**better handling of variable types + Currently everything is cast to a float64 if it is not already + a float32. Is this the best way to do it? -**comment interpolate1d - There's comments there already, but they should be + There's also the question of Y being 2-dimensional and/or + incorporating strings for record arrays. My instinct is to + have Interpolate1d only interpolate functions that are from + R1 -> R1. That's how it is currently designed. Other stuff + can be made as wrappers around Interpolate1d. + + See also "allow y to be 2-dimensional?" below + + + +*********** DOCUENTATION-TYPE AND NON-URGENT TASKS ******* + +**improve regression tests + desired for fitpack_wrapper and _interpolate_wrapper + as well as Interpolate1d. What I have now is + really basic. + + +**improve unit tests + interpolate1d.py has its own unit tests, which also call + the unit tests of fitpack_wrapper and _interpolate_wrapper. + But they could surely be made better. + + +**comment all files + There are comments there already, but they should be made better. Plus, features are changing, which requires updating the documentation. @@ -61,30 +89,42 @@ **figure out NumPy stuff with vectorize. - In function interpolate1d.__call__ + In function Interpolate1d.__call__ It would be nice to remove the hack I used. I believe vectorize is supposed to handle arrays of length 0, but it's not working on my computer. + + + +********* LONGER TERM ************ +**update for 2D and ND + This will probably take the form of two additional + classes both based on interpolate1d. Thus it probably + shouldn't be done until interpolate1d is more settled. + + There is an interesting problem here. Most of the extensions + I have assume a regular grid. First off, this is often not general. + Secondly, if I DO use a regular grid, how do I deal with bad + data? The best way is probably a pre-processing where you + interpolate values for the bad points (linear would be a nice simple + way to do it at first, just to get it working) + + We should probably use something other than FITPACK for this. + First off it's at most 2D. But much worse, it doesn't evaluate at + a set of points; it evaluates over a grid, which requires inputs + being in sorted order (both in x and y coordinates). This makes + input inconvenient and the code runs a lot slower than ndimage. + ND image has 2 main downsides :1) it requires x and y be uniform + spacing (since its really interpolating entries of an array, rather + than values of a function on Rn), and 2) the C code is TERRIBLY + documented/commented. But that can be fixed. + + So we may have two separate classes: Interpolate1d which is + based on FITPACK (or something else, depending on what + happens with the smoothing parameter), and InterpolateNd + which is based on ndimage. -**better handling of variable types - Currently everything is cast to a float64 if it is not already - a float32. Is this the best way to do it? - - Also, for the future, code should be added for record arrays, - which mix real values with strings. This is, I believe already - largely supported, but that's not because the code was written - with that in mind. I haven't thought through the details. - - Perhaps this should be done as another function/class which - wraps interpolate1d. - - -**improve regression tests - desired for fitpack_wrapper and _interpolate_wrapper - as well as interpolate1d. - - **high-level road map when the module is more established, there should be a page on the wiki which describes the big-picture of the module; what @@ -99,19 +139,6 @@ were stolen from. -**update for 2D and ND - This will probably take the form of two additional - classes both based on interpolate1d. Thus it probably - shouldn't be done until interpolate1d is more settled. - - There is an interesting problem here. Most of the extensions - I have assume a regular grid. First off, this is often not general. - Secondly, if I DO use a regular grid, how do I deal with bad - data? The best way is probably a pre-processing where you - interpolate values for the bad points (linear would be a nice simple - way to do it at first, just to get it working) - - **allow y to be 2-dimensional? It is not decided whether this feature should be supported, but I don't think it should; I think there should be another class with Added: branches/Interpolate1D/example_script.py =================================================================== --- branches/Interpolate1D/example_script.py 2008-07-25 20:46:43 UTC (rev 4563) +++ branches/Interpolate1D/example_script.py 2008-07-28 19:41:44 UTC (rev 4564) @@ -0,0 +1,41 @@ +# sample operation script +import numpy as np +import interpolate1d as I +import matplotlib.pyplot as P + + +N = 10.0 +x = np.arange(N) +y = np.sin(x) + + +## Interpolating in-range data +newx = np.arange(.05, N, .05) + +# block interpolation +interp = I.Interpolate1d(x, y, 'block') +y_block = interp(newx) + +# linear interpolation +interp = I.Interpolate1d(x, y, 'linear') +y_linear = interp(newx) + +# 2nd order spline +interp = I.Interpolate1d(x, y, 'quad') +y_quad = interp(newx) + +# 3rd order spline +interp = I.Interpolate1d(x, y, 'cubic') +y_cubic = interp(newx) + + +# plot result +print "plotting results" +P.hold(True) +P.plot(newx, y_block) +P.plot(newx, y_linear) +P.plot(newx, y_quad) +P.plot(newx, y_cubic) +P.show() +print "plotted results" + Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-25 20:46:43 UTC (rev 4563) +++ branches/Interpolate1D/interpolate1d.py 2008-07-28 19:41:44 UTC (rev 4564) @@ -130,7 +130,7 @@ x -- list or NumPy array x includes the x-values for the data set to interpolate from. It must be sorted in - ascending order + ascending order. y -- list or NumPy array y includes the y-values for the data set to @@ -159,7 +159,7 @@ a number') for all values outside the range of x. remove_bad_data -- bool - indicates whether to remove bad data. + indicates whether to remove bad data points from x and y. bad_data -- list List of values (in x or y) which indicate unacceptable data. All points @@ -168,7 +168,7 @@ numpy.NaN is always considered bad data. - Acceptable Input Strings + Some Acceptable Input Strings ------------------------ "linear" -- linear interpolation : default @@ -192,7 +192,8 @@ """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash a warning (esp if we interpolate missing values), but work anyway. + # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash + # a warning (esp if we interpolate missing values), but work anyway. def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ kindkw={}, lowkw={}, highkw={}, \ @@ -203,8 +204,7 @@ # check acceptable size and dimensions x = np.array(x) y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Interpolate1D does not support\ - arrays of length 0" + assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" assert x.ndim == 1 , "x must be one-dimensional" assert y.ndim == 1 , "y must be one-dimensional" assert len(x) == len(y) , "x and y must be of the same length" @@ -213,13 +213,14 @@ if remove_bad_data: x, y = self._remove_bad_data(x, y, bad_data) + # store data # FIXME : may be good to let x and y be initialized later, or changed after-the-fact self._init_xy(x, y) # store interpolation functions for each range - self.kind = self._init_interp_method(self._x, self._y, kind, kindkw) - self.low = self._init_interp_method(self._x, self._y, low, lowkw) - self.high = self._init_interp_method(self._x, self._y, high, highkw) + self.kind = self._init_interp_method(kind, kindkw) + self.low = self._init_interp_method(low, lowkw) + self.high = self._init_interp_method(high, highkw) def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): """ removes data points whose x or y coordinate is @@ -242,7 +243,7 @@ self._x = make_array_safe(x, self._xdtype).copy() self._y = make_array_safe(y, self._ydtype).copy() - def _init_interp_method(self, x, y, interp_arg, kw): + def _init_interp_method(self, interp_arg, kw): """ User provides interp_arg and dictionary kw. _init_interp_method returns the interpolating function from x and y specified by interp_arg, @@ -295,7 +296,11 @@ result.set_xy(self._x, self._y) # user passes a function to be called - elif isfunction(interp_arg) and interp.func_code.argcount == 3: + # FIXME : I think there is too much flexibility allowed here; it makes + # there be more pathological side cases to consider. Functions + # should perhaps be reqired to be of the form f(x, y, newx, **kw) + elif isfunction(interp_arg) and interp.func_code.argcount >= 3: + # assume x, y and newx are all passed to interp_arg result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) elif isfunction(interp_arg): result = lambda new_x : interp_arg(new_x, **kw) @@ -306,7 +311,7 @@ return result - def __call__(self, x): + def __call__(self, newx): """ Input x must be in sorted order. Breaks x into pieces in-range, below-range, and above range. @@ -314,24 +319,24 @@ """ # FIXME : make_array_safe may also be called within the interpolation technique. # waste of time, but ok for the time being. - x = make_array_safe(x) + newx = make_array_safe(newx) # masks indicate which elements fall into which interpolation region - low_mask = xself._x[-1] + low_mask = newxself._x[-1] interp_mask = (~low_mask) & (~high_mask) # use correct function for x values in each region - if len(x[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. + if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. # if/else is a hack, since vectorize is failing # to work on lists/arrays of length 0 # on the computer where this is being # developed - else: new_low = self.low(x[low_mask]) - if len(x[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(x[interp_mask]) - if len(x[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(x[high_mask]) + else: new_low = self.low(newx[low_mask]) + if len(newx[interp_mask])==0: new_interp=np.array([]) + else: new_interp = self.kind(newx[interp_mask]) + if len(newx[high_mask]) == 0: new_high = np.array([]) + else: new_high = self.high(newx[high_mask]) result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes # Would be nice to say result = zeros(dtype=?) @@ -349,7 +354,7 @@ def test_interpolate_wrapper(self): """ run unit test contained in interpolate_wrapper.py """ - print "\n\nTESTING _interpolate_wrapper MODULE" + #print "\n\nTESTING _interpolate_wrapper MODULE" from interpolate_wrapper import Test T = Test() T.runTest() @@ -357,7 +362,7 @@ def test_fitpack_wrapper(self): """ run unit test contained in fitpack_wrapper.py """ - print "\n\nTESTING _fitpack_wrapper MODULE" + #print "\n\nTESTING _fitpack_wrapper MODULE" from fitpack_wrapper import Test T = Test() T.runTest() @@ -367,8 +372,7 @@ """ # make sure : an instance of a callable class in which - # x and y haven't been initiated works - print 'hello' + # x and y haven't been initiated works N = 7 #must be > 5 x = np.arange(N) y = np.arange(N) @@ -402,9 +406,8 @@ self.assertAllclose(new_x, new_y) def test_intper1d(self): + """ make sure : interp1d works, at least in the linear case """ - make sure : interp1d works, at least in the linear case - """ N = 7 x = arange(N) y = arange(N) @@ -413,11 +416,10 @@ self.assertAllclose(new_x, new_y) def test_spline1_defaultExt(self): - """ - make sure : spline order 1 (linear) interpolation works correctly + """ make sure : spline order 1 (linear) interpolation works correctly make sure : default extrapolation works """ - print "\n\nTESTING LINEAR (1st ORDER) SPLINE" + #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" N = 7 # must be > 5 x = np.arange(N) y = np.arange(N) @@ -430,13 +432,12 @@ self.assert_(new_y[-1] == 599.73) def test_spline2(self): - """ - make sure : order-2 splines work on linear data + """ make sure : order-2 splines work on linear data make sure : order-2 splines work on non-linear data make sure : 'cubic' and 'quad' as arguments yield the desired spline """ - print "\n\nTESTING 2nd ORDER SPLINE" + #print "\n\nTESTING 2nd ORDER SPLINE" N = 7 #must be > 5 x = np.arange(N) y = np.arange(N) @@ -462,11 +463,10 @@ def test_linear(self): - """ - make sure : linear interpolation works + """ make sure : linear interpolation works make sure : linear extrapolation works """ - print "\n\nTESTING LINEAR INTERPOLATION" + #print "\n\nTESTING LINEAR INTERPOLATION" N = 7 x = arange(N) y = arange(N) @@ -482,11 +482,6 @@ self.assertAllclose(new_x, new_y) - - - - - if __name__ == '__main__': unittest.main() \ No newline at end of file From scipy-svn at scipy.org Mon Jul 28 16:48:17 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 15:48:17 -0500 (CDT) Subject: [Scipy-svn] r4565 - branches/Interpolate1D Message-ID: <20080728204817.4049839C559@scipy.org> Author: fcady Date: 2008-07-28 15:48:16 -0500 (Mon, 28 Jul 2008) New Revision: 4565 Added: branches/Interpolate1D/interpolate1d.py Removed: branches/Interpolate1D/interpolate1d.py Modified: branches/Interpolate1D/Interpolate1D.py branches/Interpolate1D/TODO.txt branches/Interpolate1D/example_script.py branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate_wrapper.py branches/Interpolate1D/setup.py Log: trying to fix a problem with file names Modified: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -268,10 +268,10 @@ elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: # specify specific kinds of splines - if interp_arg in ['cubic', 'Cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: + if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: result = Spline(self._x, self._y, k=2) + elif interp_arg in ['cubic', 'Cubic']: + result = Spline(self._x, self._y, k=3) elif interp_arg in ['Quintic', 'quintic']: result = Spline(self._x, self._y, k=4) @@ -296,14 +296,11 @@ result.set_xy(self._x, self._y) # user passes a function to be called - # FIXME : I think there is too much flexibility allowed here; it makes - # there be more pathological side cases to consider. Functions - # should perhaps be reqired to be of the form f(x, y, newx, **kw) - elif isfunction(interp_arg) and interp.func_code.argcount >= 3: + # Assume function has form of f(x, y, newx, **kw) + # FIXME : should other function forms be allowed? + elif isfunction(interp_arg): # assume x, y and newx are all passed to interp_arg result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) - elif isfunction(interp_arg): - result = lambda new_x : interp_arg(new_x, **kw) # default : user has passed a default value to always be returned else: Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/TODO.txt 2008-07-28 20:48:16 UTC (rev 4565) @@ -94,8 +94,11 @@ I believe vectorize is supposed to handle arrays of length 0, but it's not working on my computer. + +**allow newx to be in non-sorted order + This requires rethinking the partition of newx into + low, high and mid - ********* LONGER TERM ************ **update for 2D and ND Modified: branches/Interpolate1D/example_script.py =================================================================== --- branches/Interpolate1D/example_script.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/example_script.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -1,41 +1,97 @@ -# sample operation script +""" sample operation script + Note that in the plot, quadratic, cubic and + quintic lines blur together. You can comment + two out to see one clearly. +""" import numpy as np import interpolate1d as I import matplotlib.pyplot as P +import interpolate_wrapper +import fitpack_wrapper +import time -N = 10.0 -x = np.arange(N) -y = np.sin(x) +## Interpolating in-range data. Basic operation +if True: + + N = 10.0 + x = np.arange(N) + x[1] = 1.2 # make it grid non-regular + y = np.sin(x) + newx = np.arange(.05, N, .05) + # block interpolation + interp = I.Interpolate1d(x, y, 'block') + y_block = interp(newx) -## Interpolating in-range data -newx = np.arange(.05, N, .05) + # linear interpolation + interp = I.Interpolate1d(x, y, 'linear') + y_linear = interp(newx) -# block interpolation -interp = I.Interpolate1d(x, y, 'block') -y_block = interp(newx) + # 2nd order spline + interp = I.Interpolate1d(x, y, 'quad') + y_quad = interp(newx) -# linear interpolation -interp = I.Interpolate1d(x, y, 'linear') -y_linear = interp(newx) + # 3rd order spline + interp = I.Interpolate1d(x, y, 'cubic') + y_cubic = interp(newx) + + # 4th order spline + interp = I.Interpolate1d(x, y, 'quintic') + y_quintic = interp(newx) -# 2nd order spline -interp = I.Interpolate1d(x, y, 'quad') -y_quad = interp(newx) + # plot result + print "plotting results" + P.hold(True) + P.plot(newx, y_block, 'g') + P.plot(newx, y_linear, 'b') + P.plot(newx, y_quad, 'r') + P.plot(newx, y_cubic, 'm') + P.plot(newx, y_quintic, 'y') + P.title( "interpolating in-range data with Interpolate1d class" ) + P.show() + print "plotted results" + + time.sleep(3) -# 3rd order spline -interp = I.Interpolate1d(x, y, 'cubic') -y_cubic = interp(newx) +## demoing some of the other interfac features +if True: + N = 10.0 + x = np.arange(N) + x[1] = 1.2 # make it grid non-regular + y = np.sin(x) + newx = np.arange(.05, N, .05) + # block interpolation with interp1d class + y_block2 = I.interp1d(x, y, newx, 'block') -# plot result -print "plotting results" -P.hold(True) -P.plot(newx, y_block) -P.plot(newx, y_linear) -P.plot(newx, y_quad) -P.plot(newx, y_cubic) -P.show() -print "plotted results" + # linear interpolation with a function passed in + interp = I.Interpolate1d(x, y, interpolate_wrapper.linear) + y_linear2 = interp(newx) + # 2nd order spline, with partially-instantiated class + interp = I.Interpolate1d(x, y, fitpack_wrapper.Spline(k=2)) + y_quad2 = interp(newx) + + # 3rd order spline with additional keyword arguments + interp = I.Interpolate1d(x, y, fitpack_wrapper.Spline, kindkw = {'k':3}) + y_cubic2 = interp(newx) + + # 4th order spline + interp = I.Interpolate1d(x, y, 'quintic') + y_quintic2 = interp(newx) + + # plot result + print "plotting results" + P.hold(True) + P.plot(newx, y_block2, 'g') + P.plot(newx, y_linear2, 'b') + P.plot(newx, y_quad2, 'r') + P.plot(newx, y_cubic2, 'm') + P.plot(newx, y_quintic2, 'y') + P.title( "same data through different interface" ) + P.show() + print "plotted results" + + #time.sleep(20) + Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -1,8 +1,7 @@ """ This module is used for spline interpolation, and functions as a wrapper around the FITPACK Fortran interpolation -package. It is not intended to be directly accessed by -the user, but rather through the class Interpolate1d. +package. The code has been modified from an older version of scipy.interpolate, where it was directly called by the @@ -11,10 +10,15 @@ under the hood. """ +# FIXME : clean up this file! scipy.interpolate contained a lot of +# nice functionality that is only partially in this file. +# The question is whether to copy over the full functionality +# to the point where we may as well include fitting.py form +# scipy.interpolate, or whether we should strip is down some. import numpy as np -import dfitpack # extension module containing FITPACK subroutines +import dfitpack # extension module containing FITPACK subroutines in Fortran class Spline(object): Deleted: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/interpolate1d.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -1,487 +0,0 @@ -""" - Interpolation of 1D data - - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: - - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - -# FIXME: information strings giving mathematical descriptions of the actions -# of the functions. - -from interpolate_wrapper import linear, logarithmic, block, block_average_above -from fitpack_wrapper import Spline -import numpy as np -from numpy import array, arange, empty, float64, NaN - -def make_array_safe(ary, typecode=np.float64): - """Used to make sure that inputs and outputs are - properly formatted. - """ - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary - -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): - """ A function for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - new_x -- list or NumPy array - points whose value is to be interpolated from x and y. - new_x must be in sorted order, lowest to highest. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - return Interpolate1d(x, y, kind=kind, low=low, high=high, \ - kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) - -class Interpolate1d(object): - """ A class for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order. - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - A constant signifies a function which returns that constant - (e.g. val and lambda x : val are equivalent). Defaults to linear - interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data points from x and y. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Some Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - # FIXME: more informative descriptions of sample arguments - # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash - # a warning (esp if we interpolate missing values), but work anyway. - - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): - # FIXME: don't allow copying multiple times. - # FIXME : allow no copying, in case user has huge dataset - - # check acceptable size and dimensions - x = np.array(x) - y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" - assert x.ndim == 1 , "x must be one-dimensional" - assert y.ndim == 1 , "y must be one-dimensional" - assert len(x) == len(y) , "x and y must be of the same length" - - # remove bad data, is there is any - if remove_bad_data: - x, y = self._remove_bad_data(x, y, bad_data) - - # store data - # FIXME : may be good to let x and y be initialized later, or changed after-the-fact - self._init_xy(x, y) - - # store interpolation functions for each range - self.kind = self._init_interp_method(kind, kindkw) - self.low = self._init_interp_method(low, lowkw) - self.high = self._init_interp_method(high, highkw) - - def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): - """ removes data points whose x or y coordinate is - either in bad_data or is a NaN. - """ - # FIXME : In the future, it may be good to just replace the bad points with good guesses. - # Especially in generalizing the higher dimensions - # FIXME : This step is very inefficient because it iterates over the array - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - return x, y - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - - def _init_interp_method(self, interp_arg, kw): - """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. - - """ - # FIXME : error checking specific to interpolation method. x and y long - # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves, but errors at instantiation would be nice. - - from inspect import isclass, isfunction - - # primary usage : user passes a string indicating a known function - if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: - # string used to indicate interpolation method, Select appropriate function - func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ - 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x, **kw) - elif interp_arg in ['Spline', Spline, 'spline']: - # use the Spline class from fitpack_wrapper - result = Spline(self._x, self._y, **kw) - elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: - # specify specific kinds of splines - if interp_arg in ['cubic', 'Cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: - result = Spline(self._x, self._y, k=2) - elif interp_arg in ['Quintic', 'quintic']: - result = Spline(self._x, self._y, k=4) - - # secondary usage : user passes a callable class - elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): - if hasattr(interp_arg, 'init_xy'): - result = interp_arg(**kw) - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy'): - result = interp_arg(**kw) - result.set_xy(self._x, self._y) - else: - result = interp_arg(x, y, **kw) - - # user passes an instance of a callable class which has yet - # to have its x and y initialized. - elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.set_xy(self._x, self._y) - - # user passes a function to be called - # FIXME : I think there is too much flexibility allowed here; it makes - # there be more pathological side cases to consider. Functions - # should perhaps be reqired to be of the form f(x, y, newx, **kw) - elif isfunction(interp_arg) and interp.func_code.argcount >= 3: - # assume x, y and newx are all passed to interp_arg - result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) - elif isfunction(interp_arg): - result = lambda new_x : interp_arg(new_x, **kw) - - # default : user has passed a default value to always be returned - else: - result = np.vectorize(lambda new_x : interp_arg) - - return result - - def __call__(self, newx): - """ - Input x must be in sorted order. - Breaks x into pieces in-range, below-range, and above range. - Performs appropriate operation on each and concatenates results. - """ - # FIXME : make_array_safe may also be called within the interpolation technique. - # waste of time, but ok for the time being. - newx = make_array_safe(newx) - - # masks indicate which elements fall into which interpolation region - low_mask = newxself._x[-1] - interp_mask = (~low_mask) & (~high_mask) - - # use correct function for x values in each region - if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. - # if/else is a hack, since vectorize is failing - # to work on lists/arrays of length 0 - # on the computer where this is being - # developed - else: new_low = self.low(newx[low_mask]) - if len(newx[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(newx[interp_mask]) - if len(newx[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx[high_mask]) - - result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes - # Would be nice to say result = zeros(dtype=?) - # and fill in - - return result - -# unit testing -import unittest, time -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - - def test_interpolate_wrapper(self): - """ run unit test contained in interpolate_wrapper.py - """ - #print "\n\nTESTING _interpolate_wrapper MODULE" - from interpolate_wrapper import Test - T = Test() - T.runTest() - - def test_fitpack_wrapper(self): - """ run unit test contained in fitpack_wrapper.py - """ - #print "\n\nTESTING _fitpack_wrapper MODULE" - from fitpack_wrapper import Test - T = Test() - T.runTest() - - def test_instantiationFormat(self): - """ make sure : all allowed instantiation formats are supported - """ - - # make sure : an instance of a callable class in which - # x and y haven't been initiated works - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_callFormat(self): - """ make sure : all allowed calling formats are supported - """ - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) - - def test_intper1d(self): - """ make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) - - def test_spline1_defaultExt(self): - """ make sure : spline order 1 (linear) interpolation works correctly - make sure : default extrapolation works - """ - #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 # must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) - self.assert_(new_y[-1] == 599.73) - - def test_spline2(self): - """ make sure : order-2 splines work on linear data - make sure : order-2 splines work on non-linear data - make sure : 'cubic' and 'quad' as arguments yield - the desired spline - """ - #print "\n\nTESTING 2nd ORDER SPLINE" - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') - T2 = time.clock() - print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 - new_x = np.arange(N+1)-0.5 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_x, new_y) - - # make sure for non-linear data - N = 7 - x = np.arange(N) - y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x**2, new_y) - - - def test_linear(self): - """ make sure : linear interpolation works - make sure : linear extrapolation works - """ - #print "\n\nTESTING LINEAR INTERPOLATION" - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') - T2 = time.clock() - print "time to create linear interp function with N = %i: " % N, T2 - T1 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to create linear interp function with N = %i: " % N, t2 - t1 - - self.assertAllclose(new_x, new_y) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file Added: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/interpolate1d.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -0,0 +1,484 @@ +""" + Interpolation of 1D data + + This module provides several functions and classes for interpolation + and extrapolation of 1D data (1D in both input and output). The + primary function provided is: + + interp1d(x, y, new_x) : from data points x and y, interpolates + values for points in new_x and + returns them as an array. + + Classes provided include: + + Interpolate1d : an object for interpolation of + various kinds. interp1d is a wrapper + around this class. + + Spline : an object for spline interpolation + + Functions provided include: + + linear : linear interpolation + logarithmic : logarithmic interpolation + block : block interpolation + block_average_above : block average above interpolation + +""" + +# FIXME: information strings giving mathematical descriptions of the actions +# of the functions. + +from interpolate_wrapper import linear, logarithmic, block, block_average_above +from fitpack_wrapper import Spline +import numpy as np +from numpy import array, arange, empty, float64, NaN + +def make_array_safe(ary, typecode=np.float64): + """Used to make sure that inputs and outputs are + properly formatted. + """ + ary = np.atleast_1d(np.asarray(ary, typecode)) + if not ary.flags['CONTIGUOUS']: + ary = ary.copy() + return ary + +def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[], interp_axis = 0): + """ A function for interpolation of 1D data. + + Parameters + ----------- + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. Note that y must be + one-dimensional. + + new_x -- list or NumPy array + points whose value is to be interpolated from x and y. + new_x must be in sorted order, lowest to highest. + + Optional Arguments + ------------------- + + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + If nothing else, assumes the argument is intended as a value + to be returned for all arguments. Defaults to linear interpolation. + + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. + + remove_bad_data -- bool + indicates whether to remove bad data. + + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. + + numpy.NaN is always considered bad data. + + Acceptable Input Strings + ------------------------ + + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN + + Examples + --------- + + >>> import numpy + >>> from Interpolate1D import interp1d + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> new_x = [.2, 2.3, 5.6] + >>> interp1d(x, y, new_x) + array([.2, 2.3, 5.6, NaN]) + """ + return Interpolate1d(x, y, kind=kind, low=low, high=high, \ + kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ + remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) + +class Interpolate1d(object): + """ A class for interpolation of 1D data. + + Parameters + ----------- + + x -- list or NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order. + + y -- list or NumPy array + y includes the y-values for the data set to + interpolate from. Note that y must be + one-dimensional. + + Optional Arguments + ------------------- + + kind -- Usu. function or string. But can be any type. + Specifies the type of extrapolation to use for values within + the range of x. If a string is passed, it will look for an object + or function with that name and call it when evaluating. If + a function or object is passed, it will be called when interpolating. + A constant signifies a function which returns that constant + (e.g. val and lambda x : val are equivalent). Defaults to linear + interpolation. + + kindkw -- dictionary + If kind is a class, function or string, additional keyword arguments + may be needed (example: if you want a 2nd order spline, kind = 'spline' + and kindkw = {'k' : 2}. + + low (high) -- same as for kind + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values outside the range of x. + + remove_bad_data -- bool + indicates whether to remove bad data points from x and y. + + bad_data -- list + List of values (in x or y) which indicate unacceptable data. All points + that have x or y value in missing_data will be removed before + any interpolatin is performed if remove_bad_data is true. + + numpy.NaN is always considered bad data. + + Some Acceptable Input Strings + ------------------------ + + "linear" -- linear interpolation : default + "logarithmic" -- logarithmic interpolation : linear in log space? + "block" -- + "block_average_above' -- block average above + "Spline" -- spline interpolation. keyword k (defaults to 3) + indicates order of spline + numpy.NaN -- return numpy.NaN + + Examples + --------- + + >>> import numpy + >>> from Interpolate1D import interp1d + >>> x = range(5) # note list is permitted + >>> y = numpy.arange(5.) + >>> new_x = [.2, 2.3, 5.6] + >>> interp1d(x, y, new_x) + array([.2, 2.3, 5.6, NaN]) + """ + # FIXME: more informative descriptions of sample arguments + # FIXME: examples in doc string + # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash + # a warning (esp if we interpolate missing values), but work anyway. + + def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[]): + # FIXME: don't allow copying multiple times. + # FIXME : allow no copying, in case user has huge dataset + + # check acceptable size and dimensions + x = np.array(x) + y = np.array(y) + assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" + assert x.ndim == 1 , "x must be one-dimensional" + assert y.ndim == 1 , "y must be one-dimensional" + assert len(x) == len(y) , "x and y must be of the same length" + + # remove bad data, is there is any + if remove_bad_data: + x, y = self._remove_bad_data(x, y, bad_data) + + # store data + # FIXME : may be good to let x and y be initialized later, or changed after-the-fact + self._init_xy(x, y) + + # store interpolation functions for each range + self.kind = self._init_interp_method(kind, kindkw) + self.low = self._init_interp_method(low, lowkw) + self.high = self._init_interp_method(high, highkw) + + def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): + """ removes data points whose x or y coordinate is + either in bad_data or is a NaN. + """ + # FIXME : In the future, it may be good to just replace the bad points with good guesses. + # Especially in generalizing the higher dimensions + # FIXME : This step is very inefficient because it iterates over the array + mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ + (y[i] not in bad_data) and (not np.isnan(y[i])) \ + for i, xi in enumerate(x) ]) + x = x[mask] + y = y[mask] + return x, y + + def _init_xy(self, x, y): + # select proper dataypes and make arrays + self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 + self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._x = make_array_safe(x, self._xdtype).copy() + self._y = make_array_safe(y, self._ydtype).copy() + + def _init_interp_method(self, interp_arg, kw): + """ + User provides interp_arg and dictionary kw. _init_interp_method + returns the interpolating function from x and y specified by interp_arg, + possibly with extra keyword arguments given in kw. + + """ + # FIXME : error checking specific to interpolation method. x and y long + # enough for order-3 spline if that's indicated, etc. Functions should throw + # errors themselves, but errors at instantiation would be nice. + + from inspect import isclass, isfunction + + # primary usage : user passes a string indicating a known function + if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: + # string used to indicate interpolation method, Select appropriate function + func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ + 'block_average_above':block_average_above}[interp_arg] + result = lambda new_x : func(self._x, self._y, new_x, **kw) + elif interp_arg in ['Spline', Spline, 'spline']: + # use the Spline class from fitpack_wrapper + result = Spline(self._x, self._y, **kw) + elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ + 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: + # specify specific kinds of splines + if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: + result = Spline(self._x, self._y, k=2) + elif interp_arg in ['cubic', 'Cubic']: + result = Spline(self._x, self._y, k=3) + elif interp_arg in ['Quintic', 'quintic']: + result = Spline(self._x, self._y, k=4) + + # secondary usage : user passes a callable class + elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): + if hasattr(interp_arg, 'init_xy'): + result = interp_arg(**kw) + result.init_xy(self._x, self._y) + elif hasattr(interp_arg, 'set_xy'): + result = interp_arg(**kw) + result.set_xy(self._x, self._y) + else: + result = interp_arg(x, y, **kw) + + # user passes an instance of a callable class which has yet + # to have its x and y initialized. + elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): + result = interp_arg + result.init_xy(self._x, self._y) + elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): + result = interp_arg + result.set_xy(self._x, self._y) + + # user passes a function to be called + # Assume function has form of f(x, y, newx, **kw) + # FIXME : should other function forms be allowed? + elif isfunction(interp_arg): + # assume x, y and newx are all passed to interp_arg + result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) + + # default : user has passed a default value to always be returned + else: + result = np.vectorize(lambda new_x : interp_arg) + + return result + + def __call__(self, newx): + """ + Input x must be in sorted order. + Breaks x into pieces in-range, below-range, and above range. + Performs appropriate operation on each and concatenates results. + """ + # FIXME : make_array_safe may also be called within the interpolation technique. + # waste of time, but ok for the time being. + newx = make_array_safe(newx) + + # masks indicate which elements fall into which interpolation region + low_mask = newxself._x[-1] + interp_mask = (~low_mask) & (~high_mask) + + # use correct function for x values in each region + if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. + # if/else is a hack, since vectorize is failing + # to work on lists/arrays of length 0 + # on the computer where this is being + # developed + else: new_low = self.low(newx[low_mask]) + if len(newx[interp_mask])==0: new_interp=np.array([]) + else: new_interp = self.kind(newx[interp_mask]) + if len(newx[high_mask]) == 0: new_high = np.array([]) + else: new_high = self.high(newx[high_mask]) + + result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes + # Would be nice to say result = zeros(dtype=?) + # and fill in + + return result + +# unit testing +import unittest, time +class Test(unittest.TestCase): + + def assertAllclose(self, x, y): + self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) + + def test_interpolate_wrapper(self): + """ run unit test contained in interpolate_wrapper.py + """ + #print "\n\nTESTING _interpolate_wrapper MODULE" + from interpolate_wrapper import Test + T = Test() + T.runTest() + + def test_fitpack_wrapper(self): + """ run unit test contained in fitpack_wrapper.py + """ + #print "\n\nTESTING _fitpack_wrapper MODULE" + from fitpack_wrapper import Test + T = Test() + T.runTest() + + def test_instantiationFormat(self): + """ make sure : all allowed instantiation formats are supported + """ + + # make sure : an instance of a callable class in which + # x and y haven't been initiated works + N = 7 #must be > 5 + x = np.arange(N) + y = np.arange(N) + interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_callFormat(self): + """ make sure : all allowed calling formats are supported + """ + # make sure : having no out-of-range elements in new_x is fine + # There was a bug with this earlier. + N = 5 + x = arange(N) + y = arange(N) + new_x = arange(1,N-1)+.2 + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) + new_y = interp_func(new_x) + self.assertAllclose(new_x, new_y) + + def test_removeBad(self): + """make sure : interp1d works with bad data + """ + N = 7.0 # must be >=5 + x = arange(N); x[2] = np.NaN + y = arange(N); y[4] = None; y[0]=np.NaN + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ + remove_bad_data = True, bad_data = [None]) + self.assertAllclose(new_x, new_y) + + def test_intper1d(self): + """ make sure : interp1d works, at least in the linear case + """ + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') + self.assertAllclose(new_x, new_y) + + def test_spline1_defaultExt(self): + """ make sure : spline order 1 (linear) interpolation works correctly + make sure : default extrapolation works + """ + #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" + N = 7 # must be > 5 + x = np.arange(N) + y = np.arange(N) + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + + self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) + self.assert_(new_y[0] == None) + self.assert_(new_y[-1] == 599.73) + + def test_spline2(self): + """ make sure : order-2 splines work on linear data + make sure : order-2 splines work on non-linear data + make sure : 'cubic' and 'quad' as arguments yield + the desired spline + """ + #print "\n\nTESTING 2nd ORDER SPLINE" + N = 7 #must be > 5 + x = np.arange(N) + y = np.arange(N) + T1 = time.clock() + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') + T2 = time.clock() + print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 + new_x = np.arange(N+1)-0.5 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 + self.assertAllclose(new_x, new_y) + + # make sure for non-linear data + N = 7 + x = np.arange(N) + y = x**2 + interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') + new_x = np.arange(N+1)-0.5 + new_y = interp_func(new_x) + self.assertAllclose(new_x**2, new_y) + + + def test_linear(self): + """ make sure : linear interpolation works + make sure : linear extrapolation works + """ + #print "\n\nTESTING LINEAR INTERPOLATION" + N = 7 + x = arange(N) + y = arange(N) + new_x = arange(N+1)-0.5 + T1 = time.clock() + interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') + T2 = time.clock() + print "time to create linear interp function with N = %i: " % N, T2 - T1 + t1 = time.clock() + new_y = interp_func(new_x) + t2 = time.clock() + print "time to create linear interp function with N = %i: " % N, t2 - t1 + + self.assertAllclose(new_x, new_y) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file Modified: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -1,9 +1,10 @@ -""" helper_funcs.py +""" helper_funcs.py. + scavenged from enthought,interpolate """ import numpy as np import sys -import _interpolate +import _interpolate # C extension. Does all the real work. def make_array_safe(ary, typecode = np.float64): ary = np.atleast_1d(np.asarray(ary, typecode)) @@ -104,7 +105,10 @@ return new_y def block(x, y, new_x): - """ Used when only one element is available in the log. + """ Essentially a step function. + + For each new_x[i], finds largest j such that + x[j] < new_x[j], and returns y[j]. """ # find index of values in x that preceed values in x @@ -119,21 +123,6 @@ indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(np.int)) new_y = np.take(y, indices, axis=-1) return new_y -def test_helper(): - """ use numpy.allclose to test - """ - - print "now testing accuracy of interpolation of linear data" - - x = np.arange(10.) - y = 2.0*x - c = np.array([-1.0, 2.3, 10.5]) - - assert np.allclose( linear(x, y, c) , [-2.0, 4.6, 21.0] ), "problem in linear" - assert np.allclose( logarithmic(x, y, c) , [0. , 4.51738774 , 21.47836848] ), \ - "problem with logarithmic" - assert np.allclose( block_average_above(x, y, c) , [0., 2., 4.] ), \ - "problem with block_average_above" # Unit Test Modified: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-28 19:41:44 UTC (rev 4564) +++ branches/Interpolate1D/setup.py 2008-07-28 20:48:16 UTC (rev 4565) @@ -9,19 +9,25 @@ config = Configuration('', parent_package, top_path) + # C++ extension for several basic interpolation types config.add_extension('_interpolate', ['_interpolate.cpp'], include_dirs = ['.'], depends = ['interpolate.h']) + # used by dfitpack extension config.add_library('fitpack', sources=[join('fitpack', '*.f')], ) + # Fortran routines (collectively "FITPACK" for spline interpolation) config.add_extension('dfitpack', sources=['fitpack.pyf'], libraries=['fitpack'], ) + + # FIXME : add documentation files + # config.add_data_dir( return config From scipy-svn at scipy.org Mon Jul 28 16:55:36 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 15:55:36 -0500 (CDT) Subject: [Scipy-svn] r4566 - branches/Interpolate1D Message-ID: <20080728205536.97D1439C559@scipy.org> Author: fcady Date: 2008-07-28 15:55:35 -0500 (Mon, 28 Jul 2008) New Revision: 4566 Removed: branches/Interpolate1D/setup.py Log: testing adding and deleting a file Deleted: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-28 20:48:16 UTC (rev 4565) +++ branches/Interpolate1D/setup.py 2008-07-28 20:55:35 UTC (rev 4566) @@ -1,36 +0,0 @@ -#!/usr/bin/env python - -import os -from os.path import join - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration - - config = Configuration('', parent_package, top_path) - - - # C++ extension for several basic interpolation types - config.add_extension('_interpolate', - ['_interpolate.cpp'], - include_dirs = ['.'], - depends = ['interpolate.h']) - - # used by dfitpack extension - config.add_library('fitpack', - sources=[join('fitpack', '*.f')], - ) - - # Fortran routines (collectively "FITPACK" for spline interpolation) - config.add_extension('dfitpack', - sources=['fitpack.pyf'], - libraries=['fitpack'], - ) - - # FIXME : add documentation files - # config.add_data_dir( - - return config - -if __name__ == '__main__': - from numpy.distutils.core import setup - setup(**configuration().todict()) \ No newline at end of file From scipy-svn at scipy.org Mon Jul 28 17:16:41 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 16:16:41 -0500 (CDT) Subject: [Scipy-svn] r4567 - branches/Interpolate1D Message-ID: <20080728211641.82CC639C70D@scipy.org> Author: fcady Date: 2008-07-28 16:16:39 -0500 (Mon, 28 Jul 2008) New Revision: 4567 Added: branches/Interpolate1D/interp1D.py Removed: branches/Interpolate1D/interpolate1d.py Log: changed file name Copied: branches/Interpolate1D/interp1D.py (from rev 4565, branches/Interpolate1D/interpolate1d.py) Deleted: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-28 20:55:35 UTC (rev 4566) +++ branches/Interpolate1D/interpolate1d.py 2008-07-28 21:16:39 UTC (rev 4567) @@ -1,484 +0,0 @@ -""" - Interpolation of 1D data - - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: - - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - -# FIXME: information strings giving mathematical descriptions of the actions -# of the functions. - -from interpolate_wrapper import linear, logarithmic, block, block_average_above -from fitpack_wrapper import Spline -import numpy as np -from numpy import array, arange, empty, float64, NaN - -def make_array_safe(ary, typecode=np.float64): - """Used to make sure that inputs and outputs are - properly formatted. - """ - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary - -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): - """ A function for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - new_x -- list or NumPy array - points whose value is to be interpolated from x and y. - new_x must be in sorted order, lowest to highest. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - return Interpolate1d(x, y, kind=kind, low=low, high=high, \ - kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) - -class Interpolate1d(object): - """ A class for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order. - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - A constant signifies a function which returns that constant - (e.g. val and lambda x : val are equivalent). Defaults to linear - interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data points from x and y. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Some Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - # FIXME: more informative descriptions of sample arguments - # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash - # a warning (esp if we interpolate missing values), but work anyway. - - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): - # FIXME: don't allow copying multiple times. - # FIXME : allow no copying, in case user has huge dataset - - # check acceptable size and dimensions - x = np.array(x) - y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" - assert x.ndim == 1 , "x must be one-dimensional" - assert y.ndim == 1 , "y must be one-dimensional" - assert len(x) == len(y) , "x and y must be of the same length" - - # remove bad data, is there is any - if remove_bad_data: - x, y = self._remove_bad_data(x, y, bad_data) - - # store data - # FIXME : may be good to let x and y be initialized later, or changed after-the-fact - self._init_xy(x, y) - - # store interpolation functions for each range - self.kind = self._init_interp_method(kind, kindkw) - self.low = self._init_interp_method(low, lowkw) - self.high = self._init_interp_method(high, highkw) - - def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): - """ removes data points whose x or y coordinate is - either in bad_data or is a NaN. - """ - # FIXME : In the future, it may be good to just replace the bad points with good guesses. - # Especially in generalizing the higher dimensions - # FIXME : This step is very inefficient because it iterates over the array - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - return x, y - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - - def _init_interp_method(self, interp_arg, kw): - """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. - - """ - # FIXME : error checking specific to interpolation method. x and y long - # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves, but errors at instantiation would be nice. - - from inspect import isclass, isfunction - - # primary usage : user passes a string indicating a known function - if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: - # string used to indicate interpolation method, Select appropriate function - func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ - 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x, **kw) - elif interp_arg in ['Spline', Spline, 'spline']: - # use the Spline class from fitpack_wrapper - result = Spline(self._x, self._y, **kw) - elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: - # specify specific kinds of splines - if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: - result = Spline(self._x, self._y, k=2) - elif interp_arg in ['cubic', 'Cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quintic', 'quintic']: - result = Spline(self._x, self._y, k=4) - - # secondary usage : user passes a callable class - elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): - if hasattr(interp_arg, 'init_xy'): - result = interp_arg(**kw) - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy'): - result = interp_arg(**kw) - result.set_xy(self._x, self._y) - else: - result = interp_arg(x, y, **kw) - - # user passes an instance of a callable class which has yet - # to have its x and y initialized. - elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.set_xy(self._x, self._y) - - # user passes a function to be called - # Assume function has form of f(x, y, newx, **kw) - # FIXME : should other function forms be allowed? - elif isfunction(interp_arg): - # assume x, y and newx are all passed to interp_arg - result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) - - # default : user has passed a default value to always be returned - else: - result = np.vectorize(lambda new_x : interp_arg) - - return result - - def __call__(self, newx): - """ - Input x must be in sorted order. - Breaks x into pieces in-range, below-range, and above range. - Performs appropriate operation on each and concatenates results. - """ - # FIXME : make_array_safe may also be called within the interpolation technique. - # waste of time, but ok for the time being. - newx = make_array_safe(newx) - - # masks indicate which elements fall into which interpolation region - low_mask = newxself._x[-1] - interp_mask = (~low_mask) & (~high_mask) - - # use correct function for x values in each region - if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. - # if/else is a hack, since vectorize is failing - # to work on lists/arrays of length 0 - # on the computer where this is being - # developed - else: new_low = self.low(newx[low_mask]) - if len(newx[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(newx[interp_mask]) - if len(newx[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx[high_mask]) - - result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes - # Would be nice to say result = zeros(dtype=?) - # and fill in - - return result - -# unit testing -import unittest, time -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - - def test_interpolate_wrapper(self): - """ run unit test contained in interpolate_wrapper.py - """ - #print "\n\nTESTING _interpolate_wrapper MODULE" - from interpolate_wrapper import Test - T = Test() - T.runTest() - - def test_fitpack_wrapper(self): - """ run unit test contained in fitpack_wrapper.py - """ - #print "\n\nTESTING _fitpack_wrapper MODULE" - from fitpack_wrapper import Test - T = Test() - T.runTest() - - def test_instantiationFormat(self): - """ make sure : all allowed instantiation formats are supported - """ - - # make sure : an instance of a callable class in which - # x and y haven't been initiated works - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_callFormat(self): - """ make sure : all allowed calling formats are supported - """ - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) - - def test_intper1d(self): - """ make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) - - def test_spline1_defaultExt(self): - """ make sure : spline order 1 (linear) interpolation works correctly - make sure : default extrapolation works - """ - #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 # must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) - self.assert_(new_y[-1] == 599.73) - - def test_spline2(self): - """ make sure : order-2 splines work on linear data - make sure : order-2 splines work on non-linear data - make sure : 'cubic' and 'quad' as arguments yield - the desired spline - """ - #print "\n\nTESTING 2nd ORDER SPLINE" - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') - T2 = time.clock() - print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 - new_x = np.arange(N+1)-0.5 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_x, new_y) - - # make sure for non-linear data - N = 7 - x = np.arange(N) - y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x**2, new_y) - - - def test_linear(self): - """ make sure : linear interpolation works - make sure : linear extrapolation works - """ - #print "\n\nTESTING LINEAR INTERPOLATION" - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') - T2 = time.clock() - print "time to create linear interp function with N = %i: " % N, T2 - T1 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to create linear interp function with N = %i: " % N, t2 - t1 - - self.assertAllclose(new_x, new_y) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file From scipy-svn at scipy.org Mon Jul 28 17:35:05 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 16:35:05 -0500 (CDT) Subject: [Scipy-svn] r4568 - branches/Interpolate1D Message-ID: <20080728213505.C002239C715@scipy.org> Author: fcady Date: 2008-07-28 16:35:02 -0500 (Mon, 28 Jul 2008) New Revision: 4568 Added: branches/Interpolate1D/_trash.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/setup.py Removed: branches/Interpolate1D/Interpolate1D.py Log: managing file names Deleted: branches/Interpolate1D/Interpolate1D.py =================================================================== --- branches/Interpolate1D/Interpolate1D.py 2008-07-28 21:16:39 UTC (rev 4567) +++ branches/Interpolate1D/Interpolate1D.py 2008-07-28 21:35:02 UTC (rev 4568) @@ -1,484 +0,0 @@ -""" - Interpolation of 1D data - - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: - - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - -# FIXME: information strings giving mathematical descriptions of the actions -# of the functions. - -from interpolate_wrapper import linear, logarithmic, block, block_average_above -from fitpack_wrapper import Spline -import numpy as np -from numpy import array, arange, empty, float64, NaN - -def make_array_safe(ary, typecode=np.float64): - """Used to make sure that inputs and outputs are - properly formatted. - """ - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary - -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): - """ A function for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - new_x -- list or NumPy array - points whose value is to be interpolated from x and y. - new_x must be in sorted order, lowest to highest. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - return Interpolate1d(x, y, kind=kind, low=low, high=high, \ - kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) - -class Interpolate1d(object): - """ A class for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order. - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - A constant signifies a function which returns that constant - (e.g. val and lambda x : val are equivalent). Defaults to linear - interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data points from x and y. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Some Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - # FIXME: more informative descriptions of sample arguments - # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash - # a warning (esp if we interpolate missing values), but work anyway. - - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): - # FIXME: don't allow copying multiple times. - # FIXME : allow no copying, in case user has huge dataset - - # check acceptable size and dimensions - x = np.array(x) - y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" - assert x.ndim == 1 , "x must be one-dimensional" - assert y.ndim == 1 , "y must be one-dimensional" - assert len(x) == len(y) , "x and y must be of the same length" - - # remove bad data, is there is any - if remove_bad_data: - x, y = self._remove_bad_data(x, y, bad_data) - - # store data - # FIXME : may be good to let x and y be initialized later, or changed after-the-fact - self._init_xy(x, y) - - # store interpolation functions for each range - self.kind = self._init_interp_method(kind, kindkw) - self.low = self._init_interp_method(low, lowkw) - self.high = self._init_interp_method(high, highkw) - - def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): - """ removes data points whose x or y coordinate is - either in bad_data or is a NaN. - """ - # FIXME : In the future, it may be good to just replace the bad points with good guesses. - # Especially in generalizing the higher dimensions - # FIXME : This step is very inefficient because it iterates over the array - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - return x, y - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - - def _init_interp_method(self, interp_arg, kw): - """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. - - """ - # FIXME : error checking specific to interpolation method. x and y long - # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves, but errors at instantiation would be nice. - - from inspect import isclass, isfunction - - # primary usage : user passes a string indicating a known function - if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: - # string used to indicate interpolation method, Select appropriate function - func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ - 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x, **kw) - elif interp_arg in ['Spline', Spline, 'spline']: - # use the Spline class from fitpack_wrapper - result = Spline(self._x, self._y, **kw) - elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: - # specify specific kinds of splines - if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: - result = Spline(self._x, self._y, k=2) - elif interp_arg in ['cubic', 'Cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quintic', 'quintic']: - result = Spline(self._x, self._y, k=4) - - # secondary usage : user passes a callable class - elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): - if hasattr(interp_arg, 'init_xy'): - result = interp_arg(**kw) - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy'): - result = interp_arg(**kw) - result.set_xy(self._x, self._y) - else: - result = interp_arg(x, y, **kw) - - # user passes an instance of a callable class which has yet - # to have its x and y initialized. - elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.set_xy(self._x, self._y) - - # user passes a function to be called - # Assume function has form of f(x, y, newx, **kw) - # FIXME : should other function forms be allowed? - elif isfunction(interp_arg): - # assume x, y and newx are all passed to interp_arg - result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) - - # default : user has passed a default value to always be returned - else: - result = np.vectorize(lambda new_x : interp_arg) - - return result - - def __call__(self, newx): - """ - Input x must be in sorted order. - Breaks x into pieces in-range, below-range, and above range. - Performs appropriate operation on each and concatenates results. - """ - # FIXME : make_array_safe may also be called within the interpolation technique. - # waste of time, but ok for the time being. - newx = make_array_safe(newx) - - # masks indicate which elements fall into which interpolation region - low_mask = newxself._x[-1] - interp_mask = (~low_mask) & (~high_mask) - - # use correct function for x values in each region - if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. - # if/else is a hack, since vectorize is failing - # to work on lists/arrays of length 0 - # on the computer where this is being - # developed - else: new_low = self.low(newx[low_mask]) - if len(newx[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(newx[interp_mask]) - if len(newx[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx[high_mask]) - - result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes - # Would be nice to say result = zeros(dtype=?) - # and fill in - - return result - -# unit testing -import unittest, time -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - - def test_interpolate_wrapper(self): - """ run unit test contained in interpolate_wrapper.py - """ - #print "\n\nTESTING _interpolate_wrapper MODULE" - from interpolate_wrapper import Test - T = Test() - T.runTest() - - def test_fitpack_wrapper(self): - """ run unit test contained in fitpack_wrapper.py - """ - #print "\n\nTESTING _fitpack_wrapper MODULE" - from fitpack_wrapper import Test - T = Test() - T.runTest() - - def test_instantiationFormat(self): - """ make sure : all allowed instantiation formats are supported - """ - - # make sure : an instance of a callable class in which - # x and y haven't been initiated works - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_callFormat(self): - """ make sure : all allowed calling formats are supported - """ - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) - - def test_intper1d(self): - """ make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) - - def test_spline1_defaultExt(self): - """ make sure : spline order 1 (linear) interpolation works correctly - make sure : default extrapolation works - """ - #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 # must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) - self.assert_(new_y[-1] == 599.73) - - def test_spline2(self): - """ make sure : order-2 splines work on linear data - make sure : order-2 splines work on non-linear data - make sure : 'cubic' and 'quad' as arguments yield - the desired spline - """ - #print "\n\nTESTING 2nd ORDER SPLINE" - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') - T2 = time.clock() - print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 - new_x = np.arange(N+1)-0.5 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_x, new_y) - - # make sure for non-linear data - N = 7 - x = np.arange(N) - y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x**2, new_y) - - - def test_linear(self): - """ make sure : linear interpolation works - make sure : linear extrapolation works - """ - #print "\n\nTESTING LINEAR INTERPOLATION" - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') - T2 = time.clock() - print "time to create linear interp function with N = %i: " % N, T2 - T1 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to create linear interp function with N = %i: " % N, t2 - t1 - - self.assertAllclose(new_x, new_y) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file Copied: branches/Interpolate1D/_trash.py (from rev 4567, branches/Interpolate1D/Interpolate1D.py) Copied: branches/Interpolate1D/interpolate1d.py (from rev 4567, branches/Interpolate1D/interp1D.py) Added: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-28 21:16:39 UTC (rev 4567) +++ branches/Interpolate1D/setup.py 2008-07-28 21:35:02 UTC (rev 4568) @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import os +from os.path import join + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + + config = Configuration('', parent_package, top_path) + + + # C++ extension for several basic interpolation types + config.add_extension('_interpolate', + ['_interpolate.cpp'], + include_dirs = ['.'], + depends = ['interpolate.h']) + + # used by dfitpack extension + config.add_library('fitpack', + sources=[join('fitpack', '*.f')], + ) + + # Fortran routines (collectively "FITPACK" for spline interpolation) + config.add_extension('dfitpack', + sources=['fitpack.pyf'], + libraries=['fitpack'], + ) + + # FIXME : add documentation files + # config.add_data_dir( + + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(**configuration().todict()) \ No newline at end of file From scipy-svn at scipy.org Mon Jul 28 17:36:54 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 16:36:54 -0500 (CDT) Subject: [Scipy-svn] r4569 - branches/Interpolate1D Message-ID: <20080728213654.CD9D339C9D8@scipy.org> Author: fcady Date: 2008-07-28 16:36:48 -0500 (Mon, 28 Jul 2008) New Revision: 4569 Removed: branches/Interpolate1D/_trash.py branches/Interpolate1D/interp1D.py Log: managing file names Deleted: branches/Interpolate1D/_trash.py =================================================================== --- branches/Interpolate1D/_trash.py 2008-07-28 21:35:02 UTC (rev 4568) +++ branches/Interpolate1D/_trash.py 2008-07-28 21:36:48 UTC (rev 4569) @@ -1,484 +0,0 @@ -""" - Interpolation of 1D data - - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: - - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - -# FIXME: information strings giving mathematical descriptions of the actions -# of the functions. - -from interpolate_wrapper import linear, logarithmic, block, block_average_above -from fitpack_wrapper import Spline -import numpy as np -from numpy import array, arange, empty, float64, NaN - -def make_array_safe(ary, typecode=np.float64): - """Used to make sure that inputs and outputs are - properly formatted. - """ - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary - -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): - """ A function for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - new_x -- list or NumPy array - points whose value is to be interpolated from x and y. - new_x must be in sorted order, lowest to highest. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - return Interpolate1d(x, y, kind=kind, low=low, high=high, \ - kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) - -class Interpolate1d(object): - """ A class for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order. - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - A constant signifies a function which returns that constant - (e.g. val and lambda x : val are equivalent). Defaults to linear - interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data points from x and y. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Some Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - # FIXME: more informative descriptions of sample arguments - # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash - # a warning (esp if we interpolate missing values), but work anyway. - - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): - # FIXME: don't allow copying multiple times. - # FIXME : allow no copying, in case user has huge dataset - - # check acceptable size and dimensions - x = np.array(x) - y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" - assert x.ndim == 1 , "x must be one-dimensional" - assert y.ndim == 1 , "y must be one-dimensional" - assert len(x) == len(y) , "x and y must be of the same length" - - # remove bad data, is there is any - if remove_bad_data: - x, y = self._remove_bad_data(x, y, bad_data) - - # store data - # FIXME : may be good to let x and y be initialized later, or changed after-the-fact - self._init_xy(x, y) - - # store interpolation functions for each range - self.kind = self._init_interp_method(kind, kindkw) - self.low = self._init_interp_method(low, lowkw) - self.high = self._init_interp_method(high, highkw) - - def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): - """ removes data points whose x or y coordinate is - either in bad_data or is a NaN. - """ - # FIXME : In the future, it may be good to just replace the bad points with good guesses. - # Especially in generalizing the higher dimensions - # FIXME : This step is very inefficient because it iterates over the array - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - return x, y - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - - def _init_interp_method(self, interp_arg, kw): - """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. - - """ - # FIXME : error checking specific to interpolation method. x and y long - # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves, but errors at instantiation would be nice. - - from inspect import isclass, isfunction - - # primary usage : user passes a string indicating a known function - if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: - # string used to indicate interpolation method, Select appropriate function - func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ - 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x, **kw) - elif interp_arg in ['Spline', Spline, 'spline']: - # use the Spline class from fitpack_wrapper - result = Spline(self._x, self._y, **kw) - elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: - # specify specific kinds of splines - if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: - result = Spline(self._x, self._y, k=2) - elif interp_arg in ['cubic', 'Cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quintic', 'quintic']: - result = Spline(self._x, self._y, k=4) - - # secondary usage : user passes a callable class - elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): - if hasattr(interp_arg, 'init_xy'): - result = interp_arg(**kw) - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy'): - result = interp_arg(**kw) - result.set_xy(self._x, self._y) - else: - result = interp_arg(x, y, **kw) - - # user passes an instance of a callable class which has yet - # to have its x and y initialized. - elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.set_xy(self._x, self._y) - - # user passes a function to be called - # Assume function has form of f(x, y, newx, **kw) - # FIXME : should other function forms be allowed? - elif isfunction(interp_arg): - # assume x, y and newx are all passed to interp_arg - result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) - - # default : user has passed a default value to always be returned - else: - result = np.vectorize(lambda new_x : interp_arg) - - return result - - def __call__(self, newx): - """ - Input x must be in sorted order. - Breaks x into pieces in-range, below-range, and above range. - Performs appropriate operation on each and concatenates results. - """ - # FIXME : make_array_safe may also be called within the interpolation technique. - # waste of time, but ok for the time being. - newx = make_array_safe(newx) - - # masks indicate which elements fall into which interpolation region - low_mask = newxself._x[-1] - interp_mask = (~low_mask) & (~high_mask) - - # use correct function for x values in each region - if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. - # if/else is a hack, since vectorize is failing - # to work on lists/arrays of length 0 - # on the computer where this is being - # developed - else: new_low = self.low(newx[low_mask]) - if len(newx[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(newx[interp_mask]) - if len(newx[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx[high_mask]) - - result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes - # Would be nice to say result = zeros(dtype=?) - # and fill in - - return result - -# unit testing -import unittest, time -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - - def test_interpolate_wrapper(self): - """ run unit test contained in interpolate_wrapper.py - """ - #print "\n\nTESTING _interpolate_wrapper MODULE" - from interpolate_wrapper import Test - T = Test() - T.runTest() - - def test_fitpack_wrapper(self): - """ run unit test contained in fitpack_wrapper.py - """ - #print "\n\nTESTING _fitpack_wrapper MODULE" - from fitpack_wrapper import Test - T = Test() - T.runTest() - - def test_instantiationFormat(self): - """ make sure : all allowed instantiation formats are supported - """ - - # make sure : an instance of a callable class in which - # x and y haven't been initiated works - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_callFormat(self): - """ make sure : all allowed calling formats are supported - """ - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) - - def test_intper1d(self): - """ make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) - - def test_spline1_defaultExt(self): - """ make sure : spline order 1 (linear) interpolation works correctly - make sure : default extrapolation works - """ - #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 # must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) - self.assert_(new_y[-1] == 599.73) - - def test_spline2(self): - """ make sure : order-2 splines work on linear data - make sure : order-2 splines work on non-linear data - make sure : 'cubic' and 'quad' as arguments yield - the desired spline - """ - #print "\n\nTESTING 2nd ORDER SPLINE" - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') - T2 = time.clock() - print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 - new_x = np.arange(N+1)-0.5 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_x, new_y) - - # make sure for non-linear data - N = 7 - x = np.arange(N) - y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x**2, new_y) - - - def test_linear(self): - """ make sure : linear interpolation works - make sure : linear extrapolation works - """ - #print "\n\nTESTING LINEAR INTERPOLATION" - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') - T2 = time.clock() - print "time to create linear interp function with N = %i: " % N, T2 - T1 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to create linear interp function with N = %i: " % N, t2 - t1 - - self.assertAllclose(new_x, new_y) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file Deleted: branches/Interpolate1D/interp1D.py =================================================================== --- branches/Interpolate1D/interp1D.py 2008-07-28 21:35:02 UTC (rev 4568) +++ branches/Interpolate1D/interp1D.py 2008-07-28 21:36:48 UTC (rev 4569) @@ -1,484 +0,0 @@ -""" - Interpolation of 1D data - - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: - - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - -# FIXME: information strings giving mathematical descriptions of the actions -# of the functions. - -from interpolate_wrapper import linear, logarithmic, block, block_average_above -from fitpack_wrapper import Spline -import numpy as np -from numpy import array, arange, empty, float64, NaN - -def make_array_safe(ary, typecode=np.float64): - """Used to make sure that inputs and outputs are - properly formatted. - """ - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary - -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): - """ A function for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - new_x -- list or NumPy array - points whose value is to be interpolated from x and y. - new_x must be in sorted order, lowest to highest. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - return Interpolate1d(x, y, kind=kind, low=low, high=high, \ - kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) - -class Interpolate1d(object): - """ A class for interpolation of 1D data. - - Parameters - ----------- - - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order. - - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - Optional Arguments - ------------------- - - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - A constant signifies a function which returns that constant - (e.g. val and lambda x : val are equivalent). Defaults to linear - interpolation. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data points from x and y. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - - Some Acceptable Input Strings - ------------------------ - - "linear" -- linear interpolation : default - "logarithmic" -- logarithmic interpolation : linear in log space? - "block" -- - "block_average_above' -- block average above - "Spline" -- spline interpolation. keyword k (defaults to 3) - indicates order of spline - numpy.NaN -- return numpy.NaN - - Examples - --------- - - >>> import numpy - >>> from Interpolate1D import interp1d - >>> x = range(5) # note list is permitted - >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) - array([.2, 2.3, 5.6, NaN]) - """ - # FIXME: more informative descriptions of sample arguments - # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash - # a warning (esp if we interpolate missing values), but work anyway. - - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): - # FIXME: don't allow copying multiple times. - # FIXME : allow no copying, in case user has huge dataset - - # check acceptable size and dimensions - x = np.array(x) - y = np.array(y) - assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" - assert x.ndim == 1 , "x must be one-dimensional" - assert y.ndim == 1 , "y must be one-dimensional" - assert len(x) == len(y) , "x and y must be of the same length" - - # remove bad data, is there is any - if remove_bad_data: - x, y = self._remove_bad_data(x, y, bad_data) - - # store data - # FIXME : may be good to let x and y be initialized later, or changed after-the-fact - self._init_xy(x, y) - - # store interpolation functions for each range - self.kind = self._init_interp_method(kind, kindkw) - self.low = self._init_interp_method(low, lowkw) - self.high = self._init_interp_method(high, highkw) - - def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): - """ removes data points whose x or y coordinate is - either in bad_data or is a NaN. - """ - # FIXME : In the future, it may be good to just replace the bad points with good guesses. - # Especially in generalizing the higher dimensions - # FIXME : This step is very inefficient because it iterates over the array - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] - return x, y - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() - - def _init_interp_method(self, interp_arg, kw): - """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, - possibly with extra keyword arguments given in kw. - - """ - # FIXME : error checking specific to interpolation method. x and y long - # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves, but errors at instantiation would be nice. - - from inspect import isclass, isfunction - - # primary usage : user passes a string indicating a known function - if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: - # string used to indicate interpolation method, Select appropriate function - func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ - 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x, **kw) - elif interp_arg in ['Spline', Spline, 'spline']: - # use the Spline class from fitpack_wrapper - result = Spline(self._x, self._y, **kw) - elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: - # specify specific kinds of splines - if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: - result = Spline(self._x, self._y, k=2) - elif interp_arg in ['cubic', 'Cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quintic', 'quintic']: - result = Spline(self._x, self._y, k=4) - - # secondary usage : user passes a callable class - elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): - if hasattr(interp_arg, 'init_xy'): - result = interp_arg(**kw) - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy'): - result = interp_arg(**kw) - result.set_xy(self._x, self._y) - else: - result = interp_arg(x, y, **kw) - - # user passes an instance of a callable class which has yet - # to have its x and y initialized. - elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.set_xy(self._x, self._y) - - # user passes a function to be called - # Assume function has form of f(x, y, newx, **kw) - # FIXME : should other function forms be allowed? - elif isfunction(interp_arg): - # assume x, y and newx are all passed to interp_arg - result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) - - # default : user has passed a default value to always be returned - else: - result = np.vectorize(lambda new_x : interp_arg) - - return result - - def __call__(self, newx): - """ - Input x must be in sorted order. - Breaks x into pieces in-range, below-range, and above range. - Performs appropriate operation on each and concatenates results. - """ - # FIXME : make_array_safe may also be called within the interpolation technique. - # waste of time, but ok for the time being. - newx = make_array_safe(newx) - - # masks indicate which elements fall into which interpolation region - low_mask = newxself._x[-1] - interp_mask = (~low_mask) & (~high_mask) - - # use correct function for x values in each region - if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. - # if/else is a hack, since vectorize is failing - # to work on lists/arrays of length 0 - # on the computer where this is being - # developed - else: new_low = self.low(newx[low_mask]) - if len(newx[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(newx[interp_mask]) - if len(newx[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx[high_mask]) - - result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes - # Would be nice to say result = zeros(dtype=?) - # and fill in - - return result - -# unit testing -import unittest, time -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - - def test_interpolate_wrapper(self): - """ run unit test contained in interpolate_wrapper.py - """ - #print "\n\nTESTING _interpolate_wrapper MODULE" - from interpolate_wrapper import Test - T = Test() - T.runTest() - - def test_fitpack_wrapper(self): - """ run unit test contained in fitpack_wrapper.py - """ - #print "\n\nTESTING _fitpack_wrapper MODULE" - from fitpack_wrapper import Test - T = Test() - T.runTest() - - def test_instantiationFormat(self): - """ make sure : all allowed instantiation formats are supported - """ - - # make sure : an instance of a callable class in which - # x and y haven't been initiated works - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_callFormat(self): - """ make sure : all allowed calling formats are supported - """ - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) - - def test_intper1d(self): - """ make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) - - def test_spline1_defaultExt(self): - """ make sure : spline order 1 (linear) interpolation works correctly - make sure : default extrapolation works - """ - #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 # must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) - self.assert_(new_y[-1] == 599.73) - - def test_spline2(self): - """ make sure : order-2 splines work on linear data - make sure : order-2 splines work on non-linear data - make sure : 'cubic' and 'quad' as arguments yield - the desired spline - """ - #print "\n\nTESTING 2nd ORDER SPLINE" - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') - T2 = time.clock() - print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 - new_x = np.arange(N+1)-0.5 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_x, new_y) - - # make sure for non-linear data - N = 7 - x = np.arange(N) - y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x**2, new_y) - - - def test_linear(self): - """ make sure : linear interpolation works - make sure : linear extrapolation works - """ - #print "\n\nTESTING LINEAR INTERPOLATION" - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') - T2 = time.clock() - print "time to create linear interp function with N = %i: " % N, T2 - T1 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to create linear interp function with N = %i: " % N, t2 - t1 - - self.assertAllclose(new_x, new_y) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file From scipy-svn at scipy.org Mon Jul 28 20:06:54 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 28 Jul 2008 19:06:54 -0500 (CDT) Subject: [Scipy-svn] r4570 - branches/Interpolate1D Message-ID: <20080729000654.184CF39C09B@scipy.org> Author: fcady Date: 2008-07-28 19:06:51 -0500 (Mon, 28 Jul 2008) New Revision: 4570 Added: branches/Interpolate1D/info.py Modified: branches/Interpolate1D/__init__.py branches/Interpolate1D/example_script.py branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/regression_test.py Log: more updates, esp. to documentation Modified: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-28 21:36:48 UTC (rev 4569) +++ branches/Interpolate1D/__init__.py 2008-07-29 00:06:51 UTC (rev 4570) @@ -5,7 +5,7 @@ # basic interpolation routines from interpolate_wrapper import linear, logarithmic, block, block_average_above -#support for spline interpolation +# support for spline interpolation from fitpack_wrapper import Spline # wrapping for all supported interpolation types. Modified: branches/Interpolate1D/example_script.py =================================================================== --- branches/Interpolate1D/example_script.py 2008-07-28 21:36:48 UTC (rev 4569) +++ branches/Interpolate1D/example_script.py 2008-07-29 00:06:51 UTC (rev 4570) @@ -1,8 +1,15 @@ """ sample operation script + + Creates a sample dataset, performs several + basic interpolations on it, and plots results + for comparison. Pauses, then does the same + thing using different user-input options. + Note that in the plot, quadratic, cubic and quintic lines blur together. You can comment two out to see one clearly. """ + import numpy as np import interpolate1d as I import matplotlib.pyplot as P @@ -11,6 +18,7 @@ import time + ## Interpolating in-range data. Basic operation if True: @@ -37,8 +45,8 @@ y_cubic = interp(newx) # 4th order spline - interp = I.Interpolate1d(x, y, 'quintic') - y_quintic = interp(newx) + interp = I.Interpolate1d(x, y, 'quartic') + y_quartic = interp(newx) # plot result print "plotting results" @@ -47,13 +55,14 @@ P.plot(newx, y_linear, 'b') P.plot(newx, y_quad, 'r') P.plot(newx, y_cubic, 'm') - P.plot(newx, y_quintic, 'y') + P.plot(newx, y_quartic, 'y') P.title( "interpolating in-range data with Interpolate1d class" ) P.show() print "plotted results" - time.sleep(3) + time.sleep(5) + ## demoing some of the other interfac features if True: N = 10.0 @@ -78,7 +87,11 @@ y_cubic2 = interp(newx) # 4th order spline - interp = I.Interpolate1d(x, y, 'quintic') + interp = I.Interpolate1d(x, y, 'Quartic') + y_quartic2 = interp(newx) + + # 5th order spline + interp = I.Interpolate1d(x, y, 'Quintic') y_quintic2 = interp(newx) # plot result @@ -88,10 +101,34 @@ P.plot(newx, y_linear2, 'b') P.plot(newx, y_quad2, 'r') P.plot(newx, y_cubic2, 'm') + P.plot(newx, y_quartic2, 'y') P.plot(newx, y_quintic2, 'y') P.title( "same data through different interface" ) P.show() print "plotted results" + + +# demoing block_average_above and logarithmic +if False: + N = 10.0 + x = np.arange(N) + x[1] = 1.2 # make it grid non-regular + y = np.sin(x) + newx = np.arange(.05, N, .05) + + # block interpolation + # FIXME : I'm not really familiar with logarithmic + # interpolation and thus can't comment on what these + # data should look like, but this looks weird. + interp = I.Interpolate1d(x, y, 'logarithmic') + y_logarithmic = interp(newx) + + # linear interpolation + interp = I.Interpolate1d(x, y, 'block_average_above') + y_blockavgabove = interp(newx) - #time.sleep(20) - + # plotting the results + P.hold(true) + P.plot(newx, y_logarithmic, 'g') + P.plot(newx, y_blockavgabove, 'r') + P.show() \ No newline at end of file Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-28 21:36:48 UTC (rev 4569) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-29 00:06:51 UTC (rev 4570) @@ -10,11 +10,12 @@ under the hood. """ -# FIXME : clean up this file! scipy.interpolate contained a lot of +# FIXME : CLEAN UP THIS FILE! scipy.interpolate contained a lot of # nice functionality that is only partially in this file. # The question is whether to copy over the full functionality -# to the point where we may as well include fitting.py form -# scipy.interpolate, or whether we should strip is down some. +# to the point where we may as well include fitting.py from +# scipy.interpolate, or whether we should strip this down some. +# Until that's decided, cleaning is premature. import numpy as np Added: branches/Interpolate1D/info.py =================================================================== --- branches/Interpolate1D/info.py 2008-07-28 21:36:48 UTC (rev 4569) +++ branches/Interpolate1D/info.py 2008-07-29 00:06:51 UTC (rev 4570) @@ -0,0 +1,45 @@ +# FIXME : better docstring. This needs updating as features change, +# and it also discusses technical points as well as user-interface. + +__doc__ = \ +""" + Interpolation of 1D data + + This module provides several functions and classes for interpolation + and extrapolation of 1D (in both input and output) real-valued. The + primary function provided is: + + interp1d(x, y, new_x) : from data points (x[i], y[i]), interpolates + values for points in new_x and + returns them as an array. x and new_x + must both be in sorted order. + + Classes provided include: + + Interpolate1d : an object for interpolation of + various kinds. interp1d is a wrapper + around this class. + + Spline : an object for spline interpolation. Interpolate1d + wraps this class if spline interpolation + is used. However, not all functionality + of Spline is available through Interpolate1d. + + Functions provided include: + + linear : linear interpolation + logarithmic : logarithmic interpolation + block : block interpolation + block_average_above : block average above interpolation + + The dependency/interface architecture is as follows: + interpolate1d.py is viewed by the user (through interp1d and Interpolate1d) + It depends on fitpack_wrapper.py and interpolate_wrapper.py + fitpack_wrapper is viewed by the user (through Spline) + It depends on dfitpack.pyd, a Fortran extension module + interpolate_wrapper is viewed by he user (through functions linear, etc) + It depends on _interpolate.pyd, a C extension module. + +""" + +postpone_import = 1 \ No newline at end of file Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-28 21:36:48 UTC (rev 4569) +++ branches/Interpolate1D/interpolate1d.py 2008-07-29 00:06:51 UTC (rev 4570) @@ -1,31 +1,4 @@ -""" - Interpolation of 1D data - This module provides several functions and classes for interpolation - and extrapolation of 1D data (1D in both input and output). The - primary function provided is: - - interp1d(x, y, new_x) : from data points x and y, interpolates - values for points in new_x and - returns them as an array. - - Classes provided include: - - Interpolate1d : an object for interpolation of - various kinds. interp1d is a wrapper - around this class. - - Spline : an object for spline interpolation - - Functions provided include: - - linear : linear interpolation - logarithmic : logarithmic interpolation - block : block interpolation - block_average_above : block average above interpolation - -""" - # FIXME: information strings giving mathematical descriptions of the actions # of the functions. @@ -119,44 +92,77 @@ """ return Interpolate1d(x, y, kind=kind, low=low, high=high, \ kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data)(new_x) + remove_bad_data = remove_bad_data, bad_data=bad_data\ + )(new_x) class Interpolate1d(object): - """ A class for interpolation of 1D data. + """ A callable class for interpolation of 1D, real-valued data. Parameters ----------- - x -- list or NumPy array + x -- list or 1D NumPy array x includes the x-values for the data set to interpolate from. It must be sorted in ascending order. - y -- list or NumPy array + y -- list or 1D NumPy array y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. + interpolate from. Note that 2-dimensional + y is not supported. Optional Arguments ------------------- - kind -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - A constant signifies a function which returns that constant - (e.g. val and lambda x : val are equivalent). Defaults to linear - interpolation. + kind -- Usu. string or function. But can be any type. + Specifies the type of interpolation to use for values within + the range of x. + If a string is passed, it will look for an object + or function with that name and call it when evaluating. + This is the primary mode of operation. See below for list + of acceptable strings. + + By default, linear interpolation is used. + + Other options are also available: + + If a callable class is passed, it is assumed to have format + instance = Class(x, y, **kw). + It is instantiated and used for interpolation when the instance + of Interpolate1d is called. + + If a callable object with method "init_xy" or "set_xy" is + passed, that method will be used to set x and y, and the + object will be called during interpolation. + + If a function is passed, it will be called when interpolating. + It is assumed to have the form + newy = kind(x, y, newx), + where x, y, newx, and newy are all numpy arrays. + + A primitive type which is not a string signifies a function + which is identically that value (e.g. val and + lambda x, y, newx : val are equivalent). + + low -- same as for kind + How to extrapolate values for inputs below the range of x. + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values below the range of x. + + high -- same as for kind + How to extrapolate values for inputs above the range of x. + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values above the range of x. + kindkw -- dictionary If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. + may be needed (example: if you want a 2nd order spline, you could + set kind = 'spline' and kindkw = {'k' : 2}.) - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. + lowkw -- like kindkw, but for low extrapolation + + highkw -- like kindkw, except for high extrapolation remove_bad_data -- bool indicates whether to remove bad data points from x and y. @@ -177,7 +183,10 @@ "block_average_above' -- block average above "Spline" -- spline interpolation. keyword k (defaults to 3) indicates order of spline - numpy.NaN -- return numpy.NaN + "quad", "quadratic" -- spline interpolation order 2 + "cubic" -- spline interpolation order 3 + "quartic" -- spline interpolation order 4 + "quintic" -- spline interpolation order 5 Examples --------- @@ -201,6 +210,11 @@ # FIXME: don't allow copying multiple times. # FIXME : allow no copying, in case user has huge dataset + self._remove_bad_data = remove_bad_data + # remove bad data, is there is any + if self._remove_bad_data: + x, y = self._remove_bad_data(x, y, bad_data) + # check acceptable size and dimensions x = np.array(x) y = np.array(y) @@ -209,11 +223,7 @@ assert y.ndim == 1 , "y must be one-dimensional" assert len(x) == len(y) , "x and y must be of the same length" - # remove bad data, is there is any - if remove_bad_data: - x, y = self._remove_bad_data(x, y, bad_data) - - # store data + # store data, and remove bad data points is applicable # FIXME : may be good to let x and y be initialized later, or changed after-the-fact self._init_xy(x, y) @@ -222,6 +232,14 @@ self.low = self._init_interp_method(low, lowkw) self.high = self._init_interp_method(high, highkw) + def _init_xy(self, x, y): + + # select proper dataypes and make arrays + self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 + self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._x = make_array_safe(x, self._xdtype).copy() + self._y = make_array_safe(y, self._ydtype).copy() + def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): """ removes data points whose x or y coordinate is either in bad_data or is a NaN. @@ -235,18 +253,11 @@ x = x[mask] y = y[mask] return x, y - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() def _init_interp_method(self, interp_arg, kw): """ User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function from x and y specified by interp_arg, + returns the interpolating function specified by interp_arg, possibly with extra keyword arguments given in kw. """ @@ -264,17 +275,24 @@ result = lambda new_x : func(self._x, self._y, new_x, **kw) elif interp_arg in ['Spline', Spline, 'spline']: # use the Spline class from fitpack_wrapper + # k = 3 unless otherwise specified result = Spline(self._x, self._y, **kw) - elif interp_arg in ['cubic', 'Cubic', 'Quadratic', \ - 'quadratic', 'Quad', 'quad', 'Quintic', 'quintic']: + elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad', \ + 'Cubic', 'cubic', \ + 'Quartic', 'quartic', 'Quar', 'quar',\ + 'Quintic', 'quintic', 'Quin', 'quin']: # specify specific kinds of splines if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: result = Spline(self._x, self._y, k=2) - elif interp_arg in ['cubic', 'Cubic']: + elif interp_arg in ['Cubic', 'cubic']: result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quintic', 'quintic']: + elif interp_arg in ['Quartic', 'quartic', 'Quar', 'quar']: result = Spline(self._x, self._y, k=4) - + elif interp_arg in ['Quintic', 'quintic', 'Quin', 'quin']: + result = Spline(self._x, self._y, k=5) + elif isinstance(interp_arg, str): + raise TypeError, "input string %s not valid" % interp_arg + # secondary usage : user passes a callable class elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): if hasattr(interp_arg, 'init_xy'): @@ -310,7 +328,8 @@ def __call__(self, newx): """ - Input x must be in sorted order. + Input x must be a list or NumPy array in sorted order. + Breaks x into pieces in-range, below-range, and above range. Performs appropriate operation on each and concatenates results. """ Modified: branches/Interpolate1D/regression_test.py =================================================================== --- branches/Interpolate1D/regression_test.py 2008-07-28 21:36:48 UTC (rev 4569) +++ branches/Interpolate1D/regression_test.py 2008-07-29 00:06:51 UTC (rev 4570) @@ -1,4 +1,5 @@ -""" regression test: +""" + regression test: This script runs a simple regression test on the functionality of the interpolation module. Currently, when run, it times each @@ -15,7 +16,7 @@ filename = 'regression_test.dbm' log_total = shelve.open(filename) -current_time = str(time.localtime()[0:5]) # specified up to minute +current_time = str(time.localtime()[0:5]) # specified up to the minute # run all tests in interpolate1d's test class test_list = [name for name in dir(Test) if name.find('test_') == 0] From scipy-svn at scipy.org Tue Jul 29 01:16:42 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 00:16:42 -0500 (CDT) Subject: [Scipy-svn] r4571 - trunk/scipy/cluster/src Message-ID: <20080729051642.93D3B39C2C6@scipy.org> Author: cdavid Date: 2008-07-29 00:16:38 -0500 (Tue, 29 Jul 2008) New Revision: 4571 Modified: trunk/scipy/cluster/src/hierarchy.c Log: Use memset instead of deprecated bzero in cluster/hiearchical. Modified: trunk/scipy/cluster/src/hierarchy.c =================================================================== --- trunk/scipy/cluster/src/hierarchy.c 2008-07-29 00:06:51 UTC (rev 4570) +++ trunk/scipy/cluster/src/hierarchy.c 2008-07-29 05:16:38 UTC (rev 4571) @@ -949,8 +949,8 @@ curNode[k] = (n * 2) - 2; left[k] = 0; nc2 = NCHOOSE2(n); - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); while (k >= 0) { ndid = curNode[k]; @@ -1041,8 +1041,8 @@ levelSum = 0.0; levelCnt = 0; levelStdSum = 0.0; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); curNode[0] = i; for (k = 0; k >= 0;) { ndid = curNode[k]; @@ -1135,8 +1135,8 @@ rvisited = (unsigned char*)malloc(bff); curNode[k] = (n * 2) - 2; left[k] = 0; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); while (k >= 0) { ndid = curNode[k]; @@ -1234,8 +1234,8 @@ ms = -1; k = 0; curNode[k] = (n * 2) - 2; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); ms = -1; while (k >= 0) { ndid = curNode[k]; @@ -1312,8 +1312,8 @@ lvisited = (unsigned char*)malloc(bff); rvisited = (unsigned char*)malloc(bff); curNode[k] = (n * 2) - 2; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); /** number of clusters formed so far. */ nc = 0; @@ -1332,8 +1332,8 @@ } k = 0; curNode[k] = (n * 2) - 2; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); nc = 0; ms = -1; /** See if the threshold MD[g] works. **/ @@ -1416,8 +1416,8 @@ lvisited = (unsigned char*)malloc(bff); rvisited = (unsigned char*)malloc(bff); curNode[k] = (n * 2) - 2; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); while (k >= 0) { ndid = curNode[k]; Zrow = Z + ((ndid-n) * CPY_LIS); @@ -1468,8 +1468,8 @@ lvisited = (unsigned char*)malloc(bff); rvisited = (unsigned char*)malloc(bff); curNode[k] = (n * 2) - 2; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); while (k >= 0) { ndid = curNode[k]; Zrow = Z + ((ndid-n) * CPY_LIS); @@ -1529,8 +1529,8 @@ nc = 0; k = 0; curNode[k] = (n * 2) - 2; - bzero(lvisited, bff); - bzero(rvisited, bff); + memset(lvisited, 0, bff); + memset(rvisited, 0, bff); while (k >= 0) { ndid = curNode[k]; Zrow = Z + ((ndid-n) * CPY_LIS); From scipy-svn at scipy.org Tue Jul 29 01:38:06 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 00:38:06 -0500 (CDT) Subject: [Scipy-svn] r4572 - in trunk/scipy: . sparse/linalg/eigen/arpack Message-ID: <20080729053806.4B87939C9B9@scipy.org> Author: cdavid Date: 2008-07-29 00:37:59 -0500 (Tue, 29 Jul 2008) New Revision: 4572 Modified: trunk/scipy/setupscons.py trunk/scipy/sparse/linalg/eigen/arpack/SConscript Log: Fix F77PATH in scipy.sparse, which was not updated during the new build_dir migration for numscons. Modified: trunk/scipy/setupscons.py =================================================================== --- trunk/scipy/setupscons.py 2008-07-29 05:16:38 UTC (rev 4571) +++ trunk/scipy/setupscons.py 2008-07-29 05:37:59 UTC (rev 4572) @@ -19,7 +19,7 @@ config.add_subpackage('sparse') config.add_subpackage('special') config.add_subpackage('stats') - config.add_subpackage('ndimage') + #config.add_subpackage('ndimage') config.add_subpackage('stsci') config.add_subpackage('weave') config.make_svn_version_py() # installs __svn_version__.py Modified: trunk/scipy/sparse/linalg/eigen/arpack/SConscript =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-29 05:16:38 UTC (rev 4571) +++ trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-29 05:37:59 UTC (rev 4572) @@ -24,6 +24,7 @@ config.Finish() write_info(env) +print env.Dump() # Build arpack arpack_src = [pjoin("ARPACK", "SRC", s) for s in [ "cgetv0.f", "cnaitr.f", "cnapps.f", "cnaup2.f", "cnaupd.f", "cneigh.f", "cneupd.f", "cngets.f", @@ -48,7 +49,7 @@ src = [str(s) for s in arpack_src] env.AppendUnique(CPPPATH = pjoin('ARPACK', 'SRC')) -env.AppendUnique(F77PATH = pjoin(env['src_dir'], 'ARPACK', 'SRC')) +env.AppendUnique(F77PATH = pjoin('ARPACK', 'SRC')) env.AppendUnique(LIBPATH = '.') arpack_lib = env.DistutilsStaticExtLibrary('arpack', source = src) From scipy-svn at scipy.org Tue Jul 29 01:38:50 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 00:38:50 -0500 (CDT) Subject: [Scipy-svn] r4573 - trunk/scipy Message-ID: <20080729053850.BF64239C9A2@scipy.org> Author: cdavid Date: 2008-07-29 00:38:47 -0500 (Tue, 29 Jul 2008) New Revision: 4573 Modified: trunk/scipy/setupscons.py Log: Revert changed in setupscons.py commited by accident. Modified: trunk/scipy/setupscons.py =================================================================== --- trunk/scipy/setupscons.py 2008-07-29 05:37:59 UTC (rev 4572) +++ trunk/scipy/setupscons.py 2008-07-29 05:38:47 UTC (rev 4573) @@ -19,7 +19,7 @@ config.add_subpackage('sparse') config.add_subpackage('special') config.add_subpackage('stats') - #config.add_subpackage('ndimage') + config.add_subpackage('ndimage') config.add_subpackage('stsci') config.add_subpackage('weave') config.make_svn_version_py() # installs __svn_version__.py From scipy-svn at scipy.org Tue Jul 29 01:40:20 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 00:40:20 -0500 (CDT) Subject: [Scipy-svn] r4574 - trunk/scipy/sparse/linalg/eigen/arpack Message-ID: <20080729054020.646D639C832@scipy.org> Author: cdavid Date: 2008-07-29 00:40:16 -0500 (Tue, 29 Jul 2008) New Revision: 4574 Modified: trunk/scipy/sparse/linalg/eigen/arpack/SConscript Log: Remove debug scons dump. Modified: trunk/scipy/sparse/linalg/eigen/arpack/SConscript =================================================================== --- trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-29 05:38:47 UTC (rev 4573) +++ trunk/scipy/sparse/linalg/eigen/arpack/SConscript 2008-07-29 05:40:16 UTC (rev 4574) @@ -24,7 +24,6 @@ config.Finish() write_info(env) -print env.Dump() # Build arpack arpack_src = [pjoin("ARPACK", "SRC", s) for s in [ "cgetv0.f", "cnaitr.f", "cnapps.f", "cnaup2.f", "cnaupd.f", "cneigh.f", "cneupd.f", "cngets.f", From scipy-svn at scipy.org Tue Jul 29 02:11:11 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 01:11:11 -0500 (CDT) Subject: [Scipy-svn] r4575 - in branches/Interpolate1D: . docs Message-ID: <20080729061111.A0C0D39C192@scipy.org> Author: eric Date: 2008-07-29 01:10:46 -0500 (Tue, 29 Jul 2008) New Revision: 4575 Added: branches/Interpolate1D/docs/ branches/Interpolate1D/docs/.static/ branches/Interpolate1D/docs/.templates/ branches/Interpolate1D/docs/Makefile branches/Interpolate1D/docs/conf.py branches/Interpolate1D/docs/index.rst branches/Interpolate1D/docs/interp1d_linear_simple.png branches/Interpolate1D/docs/tutorial.rst branches/Interpolate1D/erics_notes.txt Log: added some notes and some fledgling docs as an example. Added: branches/Interpolate1D/docs/Makefile =================================================================== --- branches/Interpolate1D/docs/Makefile 2008-07-29 05:40:16 UTC (rev 4574) +++ branches/Interpolate1D/docs/Makefile 2008-07-29 06:10:46 UTC (rev 4575) @@ -0,0 +1,70 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html web pickle htmlhelp latex changes linkcheck + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " pickle to make pickle files (usable by e.g. sphinx-web)" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview over all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + +clean: + -rm -rf build/* + +html: + mkdir -p build/html build/doctrees + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html + @echo + @echo "Build finished. The HTML pages are in build/html." + +pickle: + mkdir -p build/pickle build/doctrees + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle + @echo + @echo "Build finished; now you can process the pickle files or run" + @echo " sphinx-web build/pickle" + @echo "to start the sphinx-web server." + +web: pickle + +htmlhelp: + mkdir -p build/htmlhelp build/doctrees + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in build/htmlhelp." + +latex: + mkdir -p build/latex build/doctrees + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex + @echo + @echo "Build finished; the LaTeX files are in build/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + mkdir -p build/changes build/doctrees + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes + @echo + @echo "The overview file is in build/changes." + +linkcheck: + mkdir -p build/linkcheck build/doctrees + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in build/linkcheck/output.txt." Added: branches/Interpolate1D/docs/conf.py =================================================================== --- branches/Interpolate1D/docs/conf.py 2008-07-29 05:40:16 UTC (rev 4574) +++ branches/Interpolate1D/docs/conf.py 2008-07-29 06:10:46 UTC (rev 4575) @@ -0,0 +1,178 @@ +# -*- coding: utf-8 -*- +# +# interpolate documentation build configuration file, created by +# sphinx-quickstart on Tue Jul 29 00:56:51 2008. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# The contents of this file are pickled, so don't put values in the namespace +# that aren't pickleable (module imports are okay, they're removed automatically). +# +# All configuration values have a default value; values that are commented out +# serve to show the default value. + +import sys, os + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +#sys.path.append(os.path.abspath('some/directory')) + +# General configuration +# --------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['.templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General substitutions. +project = 'interpolate' +copyright = '2008, Field Cady and Eric Jones' + +# The default replacements for |version| and |release|, also used in various +# other places throughout the built documents. +# +# The short X.Y version. +version = '0.7' +# The full version, including alpha/beta/rc tags. +release = '0.7' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directories, that shouldn't be searched +# for source files. +#exclude_dirs = [] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# Options for HTML output +# ----------------------- + +# The style sheet to use for HTML and HTML Help pages. A file of that name +# must exist either in Sphinx' static/ path, or in one of the custom paths +# given in html_static_path. +html_style = 'default.css' + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (within the static path) to place at the top of +# the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['.static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, the reST sources are included in the HTML build as _sources/. +#html_copy_source = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'interpolatedoc' + + +# Options for LaTeX output +# ------------------------ + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, document class [howto/manual]). +latex_documents = [ + ('index', 'interpolate.tex', 'interpolate Documentation', 'Field Cady and Eric Jones', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True Added: branches/Interpolate1D/docs/index.rst =================================================================== --- branches/Interpolate1D/docs/index.rst 2008-07-29 05:40:16 UTC (rev 4574) +++ branches/Interpolate1D/docs/index.rst 2008-07-29 06:10:46 UTC (rev 4575) @@ -0,0 +1,21 @@ +.. interpolate documentation master file, created by sphinx-quickstart on Tue Jul 29 00:56:51 2008. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to interpolate's documentation! +======================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + tutorial + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + Added: branches/Interpolate1D/docs/interp1d_linear_simple.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/interp1d_linear_simple.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-29 05:40:16 UTC (rev 4574) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-29 06:10:46 UTC (rev 4575) @@ -0,0 +1,33 @@ +Overview +-------- + +The interpolate package provides tools for interpolating and extrapolating new data points from a set known set of data points. Intepolate provides both a functional interface that is flexible and easy to use as well as an object oriented interface that can be more efficient and flexible for some cases. It is able to interpolate and extrapolate in 1D, 2D, and even N dimensions.[fixme: 1D only right now] + +For 1D interpolation, it handles linear and spline(cubic, quadratic, and quintic) for both uniformly and non-uniformly spaced data points "out of the box." Users can control the behavior of values that fall outside of the range of interpolation either by When new values fall outside of the range of interpolation data, the tools can be + +For 2D interpolation, + +1D Interpolation with the Functional Interface +---------------------------------------------- + +The following example uses the 'interp1d' function to linearly interpolate a sin curve from a sparse set of values.:: + + # start up ipython for our examples. + $ ipython -pylab + + In [1]: from interpolate import interp1d + + # Create our "known" set of 5 points with the x values in one array and the y values in another. + In [2]: x = linspace(0,2*pi,5) + In [3]: y = sin(x) + + # Now interpolate from these x,y values to create a more dense set of new_x, new_y values. + In [4]: new_x = linspace(0,2*pi, 21) + In [5]: new_y = interp1d(x,y, new_x) + + # Plot the results using matplotlib. [note examples assume you are running in ipython -pylab] + In [6]: plot(x,y,'ro', new_x, new_y, 'b-') + +.. image:: interp1d_linear_simple.png + + \ No newline at end of file Added: branches/Interpolate1D/erics_notes.txt =================================================================== --- branches/Interpolate1D/erics_notes.txt 2008-07-29 05:40:16 UTC (rev 4574) +++ branches/Interpolate1D/erics_notes.txt 2008-07-29 06:10:46 UTC (rev 4575) @@ -0,0 +1,94 @@ +*. I am glad to see your docstrings. + +*. Move tests into a seprate test directory. + +*. Follow scipy/FORMAT_GUIDLINES.txt in the main scipy directory. + +For example: + + test_callFormat -> test_call_format + + Here are the rules: + + Follow the standard Python formatting rules when writing code for SciPy. Guido + describes them "here":http://www.python.org/doc/essays/styleguide.html. A few + reminders follow: + + o Use 4 spaces for indentation levels. Do not use tabs as they can result + in indentation confusion. Most editors have a feature that will insert 4 + spaces when the tab key is hit. Also, many editors will automatically + search/replace leading tabs with 4 spaces. + + o Only 80 characters on a line. + + o use all lowercase function names with underscore separated words: + + def set_some_value() + + instead of: + + def setSomeValue() + + + o use CamelCase class names: + + def BaseClass() + + instead of: + + def base_class() + +*. make_array_safe + I would prefer 'make_array_safe' named atleast_1d_and_contiguous(). This is more specific + and it is immediately clear to other developers what the check does. If you add other checks, + then perhaps come up with a more generic name, but this explicit names, when possible, help + readability. + + Also, numpy has an ascontiguousrarray() function that would simplify the code a line or so. + + Also, this function lives in multiple places, interpolate1d and interpolate_wrapper. + +*. Function signatures: + + def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[], interp_axis = 0): + + o. the trailing \ for new lines are not necessary for functions since line continuation + is implicit with the open/close parentheses. + o. [minor] I would just use NaN instead of np.NaN. + o. It is dangerous to initialize containers as default arguments because they are + effectively a singleton for the function. We can discuss this if you don't know + what I am talking about. + o. kindkw, lowkw, and highkw aren't really necessary I don't think. They should go. + o. Do you need both remove_bad_data and bad_data? If bad_data is None, then you + don't remove bad_data... + o. I think I would change interp_axis to just be axis. This is consistent with many + other functions in numpy. + o. The choice of whether axis=0 or axis=-1 by default is a reasonable question. + fft defaults to axis=-1. This is also the faster axis to operate across in the + standard case. It is, however, the opposite of how some people think about + things (columns vs. rows). Talk to Travis O. for his take. Mine is to use axis=-1. + o. + + I think all of this might simplify the interface to the following: + + def interp1d(x, y, new_x, kind='linear', low=NaN, high=NaN, bad_data=None, axis=-1): + +*. isinstance(value, str) should be isinstance(value, basestring) so that we handle + both strings and unicode correctly. + +*. _remove_bad_data should be left up to the interpolation method if it knows what to do. + otherwise, it is handled by this top level class. + And, we definitely don't want the list comprehension in the remove_bad_data class. + +*. If the input to interp1d is a scalar, the return value should be a scalar. + [add test to handle this.] + This fails in the following: + + In [5]: x = arange(10) + In [6]: y = arange(10)*2. + In [7]: interpolate1d.interp1d(x,y,3.2) + Out[7]: array([ 6.4]) + + \ No newline at end of file From scipy-svn at scipy.org Tue Jul 29 10:11:58 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 09:11:58 -0500 (CDT) Subject: [Scipy-svn] r4576 - branches/Interpolate1D Message-ID: <20080729141158.3FE3A39C661@scipy.org> Author: fcady Date: 2008-07-29 09:11:52 -0500 (Tue, 29 Jul 2008) New Revision: 4576 Modified: branches/Interpolate1D/fitpack.pyf branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/setup.py Log: fixed dta-removal bug Modified: branches/Interpolate1D/fitpack.pyf =================================================================== --- branches/Interpolate1D/fitpack.pyf 2008-07-29 06:10:46 UTC (rev 4575) +++ branches/Interpolate1D/fitpack.pyf 2008-07-29 14:11:52 UTC (rev 4576) @@ -1,7 +1,7 @@ ! -*- f90 -*- ! Author: Pearu Peterson ! -python module dfitpack ! in +python module _dfitpack ! in usercode ''' @@ -475,5 +475,5 @@ real*8 :: dblint end function dblint end interface -end python module dfitpack +end python module _dfitpack Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-29 06:10:46 UTC (rev 4575) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-29 14:11:52 UTC (rev 4576) @@ -19,7 +19,7 @@ import numpy as np -import dfitpack # extension module containing FITPACK subroutines in Fortran +import _dfitpack # extension module containing FITPACK subroutines in Fortran class Spline(object): @@ -69,7 +69,7 @@ def init_xy(self, x, y): #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier - data = dfitpack.fpcurf0(x, y, self._k, w=self._w, + data = _dfitpack.fpcurf0(x, y, self._k, w=self._w, xb=self._bbox[0], xe=self._bbox[1], s=self._s) if data[-1]==1: # nest too small, setting to maximum bound @@ -95,7 +95,7 @@ fpint.resize(nest) nrdata.resize(nest) args = data[:8] + (t,c,n,fpint,nrdata,data[13]) - data = dfitpack.fpcurf1(*args) + data = _dfitpack.fpcurf1(*args) return data def set_smoothing_factor(self, s): @@ -109,7 +109,7 @@ 'LSQ spline with fixed knots') return args = data[:6] + (s,) + data[7:] - data = dfitpack.fpcurf1(*args) + data = _dfitpack.fpcurf1(*args) if data[-1]==1: # nest too small, setting to maximum bound data = self._reset_nest(data) @@ -125,8 +125,8 @@ if self._is_initialized: if len(x) == 0: return np.array([]) #hack to cope with shape (0,) if nu is None: - return dfitpack.splev(*(self._eval_args+(x,))) - return dfitpack.splder(nu=nu,*(self._eval_args+(x,))) + return _dfitpack.splev(*(self._eval_args+(x,))) + return _dfitpack.splder(nu=nu,*(self._eval_args+(x,))) else: raise TypeError, "x and y must be set before interpolation is possible" @@ -155,11 +155,11 @@ """ Return definite integral of the spline between two given points. """ - return dfitpack.splint(*(self._eval_args+(a,b))) + return _dfitpack.splint(*(self._eval_args+(a,b))) def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" - d,ier = dfitpack.spalde(*(self._eval_args+(x,))) + d,ier = _dfitpack.spalde(*(self._eval_args+(x,))) assert ier==0,`ier` return d @@ -170,7 +170,7 @@ """ k = self._data[5] if k==3: - z,m,ier = dfitpack.sproot(*self._eval_args[:2]) + z,m,ier = _dfitpack.sproot(*self._eval_args[:2]) assert ier==0,`ier` return z[:m] raise NotImplementedError,\ Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-29 06:10:46 UTC (rev 4575) +++ branches/Interpolate1D/interpolate1d.py 2008-07-29 14:11:52 UTC (rev 4576) @@ -210,9 +210,8 @@ # FIXME: don't allow copying multiple times. # FIXME : allow no copying, in case user has huge dataset - self._remove_bad_data = remove_bad_data # remove bad data, is there is any - if self._remove_bad_data: + if remove_bad_data: x, y = self._remove_bad_data(x, y, bad_data) # check acceptable size and dimensions Modified: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-29 06:10:46 UTC (rev 4575) +++ branches/Interpolate1D/setup.py 2008-07-29 14:11:52 UTC (rev 4576) @@ -16,14 +16,14 @@ depends = ['interpolate.h']) # used by dfitpack extension - config.add_library('fitpack', + config.add_library('_fitpack', sources=[join('fitpack', '*.f')], ) # Fortran routines (collectively "FITPACK" for spline interpolation) - config.add_extension('dfitpack', + config.add_extension('_dfitpack', sources=['fitpack.pyf'], - libraries=['fitpack'], + libraries=['_fitpack'], ) # FIXME : add documentation files From scipy-svn at scipy.org Tue Jul 29 13:56:53 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 12:56:53 -0500 (CDT) Subject: [Scipy-svn] r4577 - branches/Interpolate1D Message-ID: <20080729175653.8CA8039C522@scipy.org> Author: fcady Date: 2008-07-29 12:56:52 -0500 (Tue, 29 Jul 2008) New Revision: 4577 Modified: branches/Interpolate1D/TODO.txt branches/Interpolate1D/__init__.py branches/Interpolate1D/erics_notes.txt branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/info.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/interpolate_wrapper.py Log: incorporated many of Eric's suggestions Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/TODO.txt 2008-07-29 17:56:52 UTC (rev 4577) @@ -103,7 +103,7 @@ **update for 2D and ND This will probably take the form of two additional - classes both based on interpolate1d. Thus it probably + classes both modelled after interpolate1d. Thus it probably shouldn't be done until interpolate1d is more settled. There is an interesting problem here. Most of the extensions @@ -114,7 +114,7 @@ way to do it at first, just to get it working) We should probably use something other than FITPACK for this. - First off it's at most 2D. But much worse, it doesn't evaluate at + But firstly it's at most 2D. Much worse, it doesn't evaluate at a set of points; it evaluates over a grid, which requires inputs being in sorted order (both in x and y coordinates). This makes input inconvenient and the code runs a lot slower than ndimage. @@ -127,6 +127,13 @@ based on FITPACK (or something else, depending on what happens with the smoothing parameter), and InterpolateNd which is based on ndimage. + + Another option is to have two classes: one for uniformly spaced data and + and one for scattered data. Regularly spaced would use NDImage, and + scattered would start as an inefficient wrapper around FITPACK. But longer + term the scattered data could be done with Delaunay triangulation, + perhaps something that would implicitly calculate the convex hull + of the points and interpolate within it. **high-level road map when the module is more established, there should be a page on Modified: branches/Interpolate1D/__init__.py =================================================================== --- branches/Interpolate1D/__init__.py 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/__init__.py 2008-07-29 17:56:52 UTC (rev 4577) @@ -9,4 +9,4 @@ from fitpack_wrapper import Spline # wrapping for all supported interpolation types. -from interpolate1d import Interpolate1d, interp1d \ No newline at end of file +from interpolate1d import Interpolate1d, interp1 \ No newline at end of file Modified: branches/Interpolate1D/erics_notes.txt =================================================================== --- branches/Interpolate1D/erics_notes.txt 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/erics_notes.txt 2008-07-29 17:56:52 UTC (rev 4577) @@ -1,9 +1,39 @@ -*. I am glad to see your docstrings. +*. Function signatures: + + def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ + kindkw={}, lowkw={}, highkw={}, \ + remove_bad_data = False, bad_data=[], interp_axis = 0): -*. Move tests into a seprate test directory. + o. the trailing \ for new lines are not necessary for functions since line continuation + is implicit with the open/close parentheses. + o. [minor] I would just use NaN instead of np.NaN. + o. It is dangerous to initialize containers as default arguments because they are + effectively a singleton for the function. We can discuss this if you don't know + what I am talking about. + o. kindkw, lowkw, and highkw aren't really necessary I don't think. They should go. + Xo. Do you need both remove_bad_data and bad_data? If bad_data is None, then you + don't remove bad_data... + Xo. I think I would change interp_axis to just be axis. This is consistent with many + other functions in numpy. + Xo. The choice of whether axis=0 or axis=-1 by default is a reasonable question. + fft defaults to axis=-1. This is also the faster axis to operate across in the + standard case. It is, however, the opposite of how some people think about + things (columns vs. rows). Talk to Travis O. for his take. Mine is to use axis=-1. + + I think all of this might simplify the interface to the following: + + def interp1d(x, y, new_x, kind='linear', low=NaN, high=NaN, bad_data=None, axis=-1): -*. Follow scipy/FORMAT_GUIDLINES.txt in the main scipy directory. +*. _remove_bad_data should be left up to the interpolation method if it knows what to do. + otherwise, it is handled by this top level class. + And, we definitely don't want the list comprehension in the remove_bad_data class. +X*. I am glad to see your docstrings. + +X*. Move tests into a seprate test directory. + +X*. Follow scipy/FORMAT_GUIDLINES.txt in the main scipy directory. + For example: test_callFormat -> test_call_format @@ -14,14 +44,14 @@ describes them "here":http://www.python.org/doc/essays/styleguide.html. A few reminders follow: - o Use 4 spaces for indentation levels. Do not use tabs as they can result + Xo Use 4 spaces for indentation levels. Do not use tabs as they can result in indentation confusion. Most editors have a feature that will insert 4 spaces when the tab key is hit. Also, many editors will automatically search/replace leading tabs with 4 spaces. o Only 80 characters on a line. - o use all lowercase function names with underscore separated words: + Xo use all lowercase function names with underscore separated words: def set_some_value() @@ -30,7 +60,7 @@ def setSomeValue() - o use CamelCase class names: + Xo use CamelCase class names: def BaseClass() @@ -38,7 +68,7 @@ def base_class() -*. make_array_safe +X*. make_array_safe I would prefer 'make_array_safe' named atleast_1d_and_contiguous(). This is more specific and it is immediately clear to other developers what the check does. If you add other checks, then perhaps come up with a more generic name, but this explicit names, when possible, help @@ -47,42 +77,11 @@ Also, numpy has an ascontiguousrarray() function that would simplify the code a line or so. Also, this function lives in multiple places, interpolate1d and interpolate_wrapper. - -*. Function signatures: - - def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): - o. the trailing \ for new lines are not necessary for functions since line continuation - is implicit with the open/close parentheses. - o. [minor] I would just use NaN instead of np.NaN. - o. It is dangerous to initialize containers as default arguments because they are - effectively a singleton for the function. We can discuss this if you don't know - what I am talking about. - o. kindkw, lowkw, and highkw aren't really necessary I don't think. They should go. - o. Do you need both remove_bad_data and bad_data? If bad_data is None, then you - don't remove bad_data... - o. I think I would change interp_axis to just be axis. This is consistent with many - other functions in numpy. - o. The choice of whether axis=0 or axis=-1 by default is a reasonable question. - fft defaults to axis=-1. This is also the faster axis to operate across in the - standard case. It is, however, the opposite of how some people think about - things (columns vs. rows). Talk to Travis O. for his take. Mine is to use axis=-1. - o. - - I think all of this might simplify the interface to the following: - - def interp1d(x, y, new_x, kind='linear', low=NaN, high=NaN, bad_data=None, axis=-1): - -*. isinstance(value, str) should be isinstance(value, basestring) so that we handle +X*. isinstance(value, str) should be isinstance(value, basestring) so that we handle both strings and unicode correctly. -*. _remove_bad_data should be left up to the interpolation method if it knows what to do. - otherwise, it is handled by this top level class. - And, we definitely don't want the list comprehension in the remove_bad_data class. - -*. If the input to interp1d is a scalar, the return value should be a scalar. +X*. If the input to interp1d is a scalar, the return value should be a scalar. [add test to handle this.] This fails in the following: Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-29 17:56:52 UTC (rev 4577) @@ -174,74 +174,4 @@ assert ier==0,`ier` return z[:m] raise NotImplementedError,\ - 'finding roots unsupported for non-cubic splines' - - - -# testing -import unittest -import time -from numpy import arange, allclose, ones - -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(x, y)) - - def test_linearInterp(self): - """ make sure : linear interpolation (spline with order = 1, s = 0)works - """ - N = 3000. - x = np.arange(N) - y = np.arange(N) - #T1 = time.clock() - interp_func = Spline(x, y, k=1) - #T2 = time.clock() - #print "time to create order 1 spline interpolation function with N = %i:" % N, T2 - T1 - new_x = np.arange(N)+0.5 - #t1 = time.clock() - new_y = interp_func(new_x) - #t2 = time.clock() - #print "time for order 1 spline interpolation with N = %i:" % N, t2 - t1 - self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) - - def test_quadInterp(self): - """ make sure : quadratic interpolation (spline with order = 2, s = 0)works - """ - N = 3000. - x = np.arange(N) - y = x**2 - interp_func = Spline(x, y, k=2) - #print "time to create order 1 spline interpolation function with N = %i:" % N, T2 - T1 - new_x = np.arange(N)+0.5 - #t1 = time.clock() - new_y = interp_func(x) - #t2 = time.clock() - #print "time for order 1 spline interpolation with N = %i:" % N, t2 - t1 - self.assertAllclose(new_y, y) - - - def test_inputFormat(self): - """ make sure : it's possible to instantiate Spline without x and y - """ - #print "testing input format" - N = 3000. - x = np.arange(N) - y = np.arange(N) - interp_func = Spline(k=1) - interp_func.init_xy(x, y) - new_x = np.arange(N)+0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) - - def runTest(self): - test_list = [name for name in dir(self) if name.find('test_')==0] - for test_name in test_list: - exec("self.%s()" % test_name) - - - -if __name__ == '__main__': - unittest.main() - - \ No newline at end of file + 'finding roots unsupported for non-cubic splines' \ No newline at end of file Modified: branches/Interpolate1D/info.py =================================================================== --- branches/Interpolate1D/info.py 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/info.py 2008-07-29 17:56:52 UTC (rev 4577) @@ -9,7 +9,7 @@ and extrapolation of 1D (in both input and output) real-valued. The primary function provided is: - interp1d(x, y, new_x) : from data points (x[i], y[i]), interpolates + interp1(x, y, new_x) : from data points (x[i], y[i]), interpolates values for points in new_x and returns them as an array. x and new_x must both be in sorted order. Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/interpolate1d.py 2008-07-29 17:56:52 UTC (rev 4577) @@ -1,24 +1,14 @@ - # FIXME: information strings giving mathematical descriptions of the actions # of the functions. -from interpolate_wrapper import linear, logarithmic, block, block_average_above +from interpolate_wrapper import linear, logarithmic, block, block_average_above, atleast_1d_and_contiguous from fitpack_wrapper import Spline import numpy as np from numpy import array, arange, empty, float64, NaN - -def make_array_safe(ary, typecode=np.float64): - """Used to make sure that inputs and outputs are - properly formatted. - """ - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary -def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[], interp_axis = 0): +def interp1d(x, y, new_x, interp = 'linear', low = NaN, high = NaN, + interpkw = {}, lowkw={}, highkw={}, + bad_data = None): """ A function for interpolation of 1D data. Parameters @@ -90,10 +80,15 @@ >>> interp1d(x, y, new_x) array([.2, 2.3, 5.6, NaN]) """ - return Interpolate1d(x, y, kind=kind, low=low, high=high, \ - kindkw=kindkw, lowkw=lowkw, highkw=highkw, \ - remove_bad_data = remove_bad_data, bad_data=bad_data\ - )(new_x) + return Interpolate1d(x, y, + interp = interp, + low = low, + high = high, + interpkw = interpkw, + lowkw = lowkw, + highkw = highkw, + bad_data = bad_data + )(new_x) class Interpolate1d(object): """ A callable class for interpolation of 1D, real-valued data. @@ -192,11 +187,12 @@ --------- >>> import numpy - >>> from Interpolate1D import interp1d + >>> from interpolate1d import Interpolate1d >>> x = range(5) # note list is permitted >>> y = numpy.arange(5.) >>> new_x = [.2, 2.3, 5.6] - >>> interp1d(x, y, new_x) + >>> interp_func = Interpolate1d(x, y) + >>> interp_fuc(new_x) array([.2, 2.3, 5.6, NaN]) """ # FIXME: more informative descriptions of sample arguments @@ -204,19 +200,18 @@ # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash # a warning (esp if we interpolate missing values), but work anyway. - def __init__(self, x, y, kind='linear', low=np.NaN, high=np.NaN, \ - kindkw={}, lowkw={}, highkw={}, \ - remove_bad_data = False, bad_data=[]): + def __init__(self, x, y, interp = 'linear', low = NaN, high = NaN, + interpkw={}, lowkw={}, highkw={}, bad_data = None): # FIXME: don't allow copying multiple times. # FIXME : allow no copying, in case user has huge dataset # remove bad data, is there is any - if remove_bad_data: + if bad_data is not None: x, y = self._remove_bad_data(x, y, bad_data) # check acceptable size and dimensions - x = np.array(x) - y = np.array(y) + x = np.atleast_1d(x) + y = np.atleast_1d(y) assert len(x) > 0 and len(y) > 0 , "Arrays cannot be of zero length" assert x.ndim == 1 , "x must be one-dimensional" assert y.ndim == 1 , "y must be one-dimensional" @@ -227,7 +222,7 @@ self._init_xy(x, y) # store interpolation functions for each range - self.kind = self._init_interp_method(kind, kindkw) + self.interp = self._init_interp_method(interp, interpkw) self.low = self._init_interp_method(low, lowkw) self.high = self._init_interp_method(high, highkw) @@ -236,10 +231,10 @@ # select proper dataypes and make arrays self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) - self._x = make_array_safe(x, self._xdtype).copy() - self._y = make_array_safe(y, self._ydtype).copy() + self._x = atleast_1d_and_contiguous(x, self._xdtype).copy() + self._y = atleast_1d_and_contiguous(y, self._ydtype).copy() - def _remove_bad_data(self, x, y, bad_data = [None, np.NaN]): + def _remove_bad_data(self, x, y, bad_data = [None, NaN]): """ removes data points whose x or y coordinate is either in bad_data or is a NaN. """ @@ -272,7 +267,7 @@ func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] result = lambda new_x : func(self._x, self._y, new_x, **kw) - elif interp_arg in ['Spline', Spline, 'spline']: + elif interp_arg in ['Spline', 'spline']: # use the Spline class from fitpack_wrapper # k = 3 unless otherwise specified result = Spline(self._x, self._y, **kw) @@ -289,7 +284,7 @@ result = Spline(self._x, self._y, k=4) elif interp_arg in ['Quintic', 'quintic', 'Quin', 'quin']: result = Spline(self._x, self._y, k=5) - elif isinstance(interp_arg, str): + elif isinstance(interp_arg, basestring): raise TypeError, "input string %s not valid" % interp_arg # secondary usage : user passes a callable class @@ -314,9 +309,7 @@ # user passes a function to be called # Assume function has form of f(x, y, newx, **kw) - # FIXME : should other function forms be allowed? elif isfunction(interp_arg): - # assume x, y and newx are all passed to interp_arg result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) # default : user has passed a default value to always be returned @@ -332,171 +325,39 @@ Breaks x into pieces in-range, below-range, and above range. Performs appropriate operation on each and concatenates results. """ - # FIXME : make_array_safe may also be called within the interpolation technique. + # FIXME : atleast_1d_and_contiguous may also be called within the interpolation technique. # waste of time, but ok for the time being. - newx = make_array_safe(newx) + # if input is scalar or 0-dimemsional array, output will be scalar + input_is_scalar = np.isscalar(newx) or (isinstance(newx, type(np.array([1.0]))) and np.shape(newx) == ()) + + newx_array = atleast_1d_and_contiguous(newx) + # masks indicate which elements fall into which interpolation region - low_mask = newxself._x[-1] + low_mask = newx_arrayself._x[-1] interp_mask = (~low_mask) & (~high_mask) - + # use correct function for x values in each region - if len(newx[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. + if len(newx_array[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. # if/else is a hack, since vectorize is failing # to work on lists/arrays of length 0 # on the computer where this is being # developed - else: new_low = self.low(newx[low_mask]) - if len(newx[interp_mask])==0: new_interp=np.array([]) - else: new_interp = self.kind(newx[interp_mask]) - if len(newx[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx[high_mask]) + else: new_low = self.low(newx_array[low_mask]) + if len(newx_array[interp_mask])==0: new_interp=np.array([]) + else: new_interp = self.interp(newx_array[interp_mask]) + if len(newx_array[high_mask]) == 0: new_high = np.array([]) + else: new_high = self.high(newx_array[high_mask]) - result = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes + result_array = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes # Would be nice to say result = zeros(dtype=?) # and fill in - return result + if input_is_scalar: + result = float(result_array) + else: + result = result_array -# unit testing -import unittest, time -class Test(unittest.TestCase): - - def assertAllclose(self, x, y): - self.assert_(np.allclose(make_array_safe(x), make_array_safe(y))) - - def test_interpolate_wrapper(self): - """ run unit test contained in interpolate_wrapper.py - """ - #print "\n\nTESTING _interpolate_wrapper MODULE" - from interpolate_wrapper import Test - T = Test() - T.runTest() - - def test_fitpack_wrapper(self): - """ run unit test contained in fitpack_wrapper.py - """ - #print "\n\nTESTING _fitpack_wrapper MODULE" - from fitpack_wrapper import Test - T = Test() - T.runTest() - - def test_instantiationFormat(self): - """ make sure : all allowed instantiation formats are supported - """ - - # make sure : an instance of a callable class in which - # x and y haven't been initiated works - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind=Spline(k=2), low=Spline(k=2), high=Spline(k=2)) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_callFormat(self): - """ make sure : all allowed calling formats are supported - """ - # make sure : having no out-of-range elements in new_x is fine - # There was a bug with this earlier. - N = 5 - x = arange(N) - y = arange(N) - new_x = arange(1,N-1)+.2 - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high=np.NaN) - new_y = interp_func(new_x) - self.assertAllclose(new_x, new_y) - - def test_removeBad(self): - """make sure : interp1d works with bad data - """ - N = 7.0 # must be >=5 - x = arange(N); x[2] = np.NaN - y = arange(N); y[4] = None; y[0]=np.NaN - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear', \ - remove_bad_data = True, bad_data = [None]) - self.assertAllclose(new_x, new_y) - - def test_intper1d(self): - """ make sure : interp1d works, at least in the linear case - """ - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - new_y = interp1d(x, y, new_x, kind='linear', low='linear', high='linear') - self.assertAllclose(new_x, new_y) - - def test_spline1_defaultExt(self): - """ make sure : spline order 1 (linear) interpolation works correctly - make sure : default extrapolation works - """ - #print "\n\nTESTING LINEAR (1st ORDER) SPLINE" - N = 7 # must be > 5 - x = np.arange(N) - y = np.arange(N) - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':1}, low=None, high=599.73) - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - - self.assertAllclose(new_y[1:5], [0.5, 1.5, 2.5, 3.5]) - self.assert_(new_y[0] == None) - self.assert_(new_y[-1] == 599.73) - - def test_spline2(self): - """ make sure : order-2 splines work on linear data - make sure : order-2 splines work on non-linear data - make sure : 'cubic' and 'quad' as arguments yield - the desired spline - """ - #print "\n\nTESTING 2nd ORDER SPLINE" - N = 7 #must be > 5 - x = np.arange(N) - y = np.arange(N) - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='spline', high='spline') - T2 = time.clock() - print "time to create 2nd order spline interp function with N = %i: " % N, T2 - T1 - new_x = np.arange(N+1)-0.5 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to evaluate 2nd order spline interp function with N = %i: " % N, t2 - t1 - self.assertAllclose(new_x, new_y) - - # make sure for non-linear data - N = 7 - x = np.arange(N) - y = x**2 - interp_func = Interpolate1d(x, y, kind='Spline', kindkw={'k':2}, low='quad', high='cubic') - new_x = np.arange(N+1)-0.5 - new_y = interp_func(new_x) - self.assertAllclose(new_x**2, new_y) - - - def test_linear(self): - """ make sure : linear interpolation works - make sure : linear extrapolation works - """ - #print "\n\nTESTING LINEAR INTERPOLATION" - N = 7 - x = arange(N) - y = arange(N) - new_x = arange(N+1)-0.5 - T1 = time.clock() - interp_func = Interpolate1d(x, y, kind='linear', low='linear', high='linear') - T2 = time.clock() - print "time to create linear interp function with N = %i: " % N, T2 - T1 - t1 = time.clock() - new_y = interp_func(new_x) - t2 = time.clock() - print "time to create linear interp function with N = %i: " % N, t2 - t1 - - self.assertAllclose(new_x, new_y) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file + return result + \ No newline at end of file Modified: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-29 14:11:52 UTC (rev 4576) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-29 17:56:52 UTC (rev 4577) @@ -6,13 +6,9 @@ import sys import _interpolate # C extension. Does all the real work. -def make_array_safe(ary, typecode = np.float64): - ary = np.atleast_1d(np.asarray(ary, typecode)) - if not ary.flags['CONTIGUOUS']: - ary = ary.copy() - return ary +def atleast_1d_and_contiguous(ary, typecode = np.float64): + return np.atleast_1d( np.ascontiguousarray(ary, typecode) ) - def linear(x, y, new_x): """ Linearly interpolates values in new_x based on the values in x and y @@ -25,9 +21,9 @@ new_x 1-D array """ - x = make_array_safe(x, np.float64) - y = make_array_safe(y, np.float64) - new_x = make_array_safe(new_x, np.float64) + x = atleast_1d_and_contiguous(x, np.float64) + y = atleast_1d_and_contiguous(y, np.float64) + new_x = atleast_1d_and_contiguous(new_x, np.float64) assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: @@ -52,9 +48,9 @@ new_x 1-D array """ - x = make_array_safe(x, np.float64) - y = make_array_safe(y, np.float64) - new_x = make_array_safe(new_x, np.float64) + x = atleast_1d_and_contiguous(x, np.float64) + y = atleast_1d_and_contiguous(y, np.float64) + new_x = atleast_1d_and_contiguous(new_x, np.float64) assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: @@ -80,9 +76,9 @@ 1-D array """ bad_index = None - x = make_array_safe(x, np.float64) - y = make_array_safe(y, np.float64) - new_x = make_array_safe(new_x, np.float64) + x = atleast_1d_and_contiguous(x, np.float64) + y = atleast_1d_and_contiguous(y, np.float64) + new_x = atleast_1d_and_contiguous(new_x, np.float64) assert len(y.shape) < 3, "function only works with 1D or 2D arrays" if len(y.shape) == 2: @@ -122,77 +118,4 @@ # take requires the index array to be an Int indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(np.int)) new_y = np.take(y, indices, axis=-1) - return new_y - - -# Unit Test -import unittest -import time -from numpy import arange, allclose, ones, NaN, isnan -class Test(unittest.TestCase): - - - def assertAllclose(self, x, y, rtol=1.0e-5): - for i, xi in enumerate(x): - self.assert_(allclose(xi, y[i], rtol) or (isnan(xi) and isnan(y[i]))) - - def test_linear(self): - N = 3000. - x = arange(N) - y = arange(N) - new_x = arange(N)+0.5 - t1 = time.clock() - new_y = linear(x, y, new_x) - t2 = time.clock() - #print "time for linear interpolation with N = %i:" % N, t2 - t1 - - self.assertAllclose(new_y[:5], [0.5, 1.5, 2.5, 3.5, 4.5]) - - def test_block_average_above(self): - N = 3000. - x = arange(N) - y = arange(N) - - new_x = arange(N/2)*2 - t1 = time.clock() - new_y = block_average_above(x, y, new_x) - t2 = time.clock() - #print "time for block_avg_above interpolation with N = %i:" % N, t2 - t1 - self.assertAllclose(new_y[:5], [0.0, 0.5, 2.5, 4.5, 6.5]) - - def test_linear2(self): - N = 3000. - x = arange(N) - y = ones((100,N)) * arange(N) - new_x = arange(N)+0.5 - t1 = time.clock() - new_y = linear(x, y, new_x) - t2 = time.clock() - #print "time for 2D linear interpolation with N = %i:" % N, t2 - t1 - self.assertAllclose(new_y[:5,:5], - [[ 0.5, 1.5, 2.5, 3.5, 4.5], - [ 0.5, 1.5, 2.5, 3.5, 4.5], - [ 0.5, 1.5, 2.5, 3.5, 4.5], - [ 0.5, 1.5, 2.5, 3.5, 4.5], - [ 0.5, 1.5, 2.5, 3.5, 4.5]]) - - def test_logarithmic(self): - N = 4000. - x = arange(N) - y = arange(N) - new_x = arange(N)+0.5 - t1 = time.clock() - new_y = logarithmic(x, y, new_x) - t2 = time.clock() - #print "time for logarithmic interpolation with N = %i:" % N, t2 - t1 - correct_y = [np.NaN, 1.41421356, 2.44948974, 3.46410162, 4.47213595] - self.assertAllclose(new_y[:5], correct_y) - - def runTest(self): - test_list = [name for name in dir(self) if name.find('test_')==0] - for test_name in test_list: - exec("self.%s()" % test_name) - -if __name__ == '__main__': - unittest.main() - \ No newline at end of file + return new_y \ No newline at end of file From scipy-svn at scipy.org Tue Jul 29 13:59:54 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 12:59:54 -0500 (CDT) Subject: [Scipy-svn] r4578 - branches/Interpolate1D Message-ID: <20080729175954.74A5339C24E@scipy.org> Author: fcady Date: 2008-07-29 12:59:53 -0500 (Tue, 29 Jul 2008) New Revision: 4578 Modified: branches/Interpolate1D/erics_notes.txt branches/Interpolate1D/info.py Log: edits to TODO.txt Modified: branches/Interpolate1D/erics_notes.txt =================================================================== --- branches/Interpolate1D/erics_notes.txt 2008-07-29 17:56:52 UTC (rev 4577) +++ branches/Interpolate1D/erics_notes.txt 2008-07-29 17:59:53 UTC (rev 4578) @@ -1,3 +1,7 @@ +*. _remove_bad_data should be left up to the interpolation method if it knows what to do. + otherwise, it is handled by this top level class. + And, we definitely don't want the list comprehension in the remove_bad_data class. + *. Function signatures: def interp1d(x, y, new_x, kind='linear', low=np.NaN, high=np.NaN, \ @@ -3,12 +7,12 @@ kindkw={}, lowkw={}, highkw={}, \ remove_bad_data = False, bad_data=[], interp_axis = 0): - - o. the trailing \ for new lines are not necessary for functions since line continuation - is implicit with the open/close parentheses. - o. [minor] I would just use NaN instead of np.NaN. + o. It is dangerous to initialize containers as default arguments because they are effectively a singleton for the function. We can discuss this if you don't know what I am talking about. o. kindkw, lowkw, and highkw aren't really necessary I don't think. They should go. + Xo. [minor] I would just use NaN instead of np.NaN. + Xo. the trailing \ for new lines are not necessary for functions since line continuation + is implicit with the open/close parentheses. Xo. Do you need both remove_bad_data and bad_data? If bad_data is None, then you don't remove bad_data... @@ -24,14 +28,6 @@ def interp1d(x, y, new_x, kind='linear', low=NaN, high=NaN, bad_data=None, axis=-1): -*. _remove_bad_data should be left up to the interpolation method if it knows what to do. - otherwise, it is handled by this top level class. - And, we definitely don't want the list comprehension in the remove_bad_data class. - -X*. I am glad to see your docstrings. - -X*. Move tests into a seprate test directory. - X*. Follow scipy/FORMAT_GUIDLINES.txt in the main scipy directory. For example: @@ -67,7 +63,10 @@ instead of: def base_class() +X*. I am glad to see your docstrings. +X*. Move tests into a seprate test directory. + X*. make_array_safe I would prefer 'make_array_safe' named atleast_1d_and_contiguous(). This is more specific and it is immediately clear to other developers what the check does. If you add other checks, Modified: branches/Interpolate1D/info.py =================================================================== --- branches/Interpolate1D/info.py 2008-07-29 17:56:52 UTC (rev 4577) +++ branches/Interpolate1D/info.py 2008-07-29 17:59:53 UTC (rev 4578) @@ -9,7 +9,7 @@ and extrapolation of 1D (in both input and output) real-valued. The primary function provided is: - interp1(x, y, new_x) : from data points (x[i], y[i]), interpolates + interp1d(x, y, new_x) : from data points (x[i], y[i]), interpolates values for points in new_x and returns them as an array. x and new_x must both be in sorted order. From scipy-svn at scipy.org Tue Jul 29 14:16:23 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 29 Jul 2008 13:16:23 -0500 (CDT) Subject: [Scipy-svn] r4579 - branches/Interpolate1D Message-ID: <20080729181623.6A02339C414@scipy.org> Author: fcady Date: 2008-07-29 13:16:22 -0500 (Tue, 29 Jul 2008) New Revision: 4579 Modified: branches/Interpolate1D/erics_notes.txt branches/Interpolate1D/interpolate1d.py Log: removed keyword arguments Modified: branches/Interpolate1D/erics_notes.txt =================================================================== --- branches/Interpolate1D/erics_notes.txt 2008-07-29 17:59:53 UTC (rev 4578) +++ branches/Interpolate1D/erics_notes.txt 2008-07-29 18:16:22 UTC (rev 4579) @@ -11,7 +11,7 @@ o. It is dangerous to initialize containers as default arguments because they are effectively a singleton for the function. We can discuss this if you don't know what I am talking about. - o. kindkw, lowkw, and highkw aren't really necessary I don't think. They should go. + Xo. kindkw, lowkw, and highkw aren't really necessary I don't think. They should go. Xo. [minor] I would just use NaN instead of np.NaN. Xo. the trailing \ for new lines are not necessary for functions since line continuation is implicit with the open/close parentheses. Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-29 17:59:53 UTC (rev 4578) +++ branches/Interpolate1D/interpolate1d.py 2008-07-29 18:16:22 UTC (rev 4579) @@ -6,8 +6,7 @@ import numpy as np from numpy import array, arange, empty, float64, NaN -def interp1d(x, y, new_x, interp = 'linear', low = NaN, high = NaN, - interpkw = {}, lowkw={}, highkw={}, +def interp1d(x, y, new_x, interp = 'linear', extrap_low = NaN, extrap_high = NaN, bad_data = None): """ A function for interpolation of 1D data. @@ -39,11 +38,6 @@ If nothing else, assumes the argument is intended as a value to be returned for all arguments. Defaults to linear interpolation. - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, kind = 'spline' - and kindkw = {'k' : 2}. - low (high) -- same as for kind Same options as for 'kind'. Defaults to returning numpy.NaN ('not a number') for all values outside the range of x. @@ -82,11 +76,8 @@ """ return Interpolate1d(x, y, interp = interp, - low = low, - high = high, - interpkw = interpkw, - lowkw = lowkw, - highkw = highkw, + extrap_low = extrap_low, + extrap_high = extrap_high, bad_data = bad_data )(new_x) @@ -123,7 +114,7 @@ Other options are also available: If a callable class is passed, it is assumed to have format - instance = Class(x, y, **kw). + instance = Class(x, y). It is instantiated and used for interpolation when the instance of Interpolate1d is called. @@ -149,15 +140,6 @@ How to extrapolate values for inputs above the range of x. Same options as for 'kind'. Defaults to returning numpy.NaN ('not a number') for all values above the range of x. - - kindkw -- dictionary - If kind is a class, function or string, additional keyword arguments - may be needed (example: if you want a 2nd order spline, you could - set kind = 'spline' and kindkw = {'k' : 2}.) - - lowkw -- like kindkw, but for low extrapolation - - highkw -- like kindkw, except for high extrapolation remove_bad_data -- bool indicates whether to remove bad data points from x and y. @@ -200,8 +182,8 @@ # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash # a warning (esp if we interpolate missing values), but work anyway. - def __init__(self, x, y, interp = 'linear', low = NaN, high = NaN, - interpkw={}, lowkw={}, highkw={}, bad_data = None): + def __init__(self, x, y, interp = 'linear', extrap_low = NaN, extrap_high = NaN, + bad_data = None): # FIXME: don't allow copying multiple times. # FIXME : allow no copying, in case user has huge dataset @@ -222,9 +204,9 @@ self._init_xy(x, y) # store interpolation functions for each range - self.interp = self._init_interp_method(interp, interpkw) - self.low = self._init_interp_method(low, lowkw) - self.high = self._init_interp_method(high, highkw) + self.interp = self._init_interp_method(interp) + self.extrap_low = self._init_interp_method(extrap_low) + self.extrap_high = self._init_interp_method(extrap_high) def _init_xy(self, x, y): @@ -248,12 +230,9 @@ y = y[mask] return x, y - def _init_interp_method(self, interp_arg, kw): + def _init_interp_method(self, interp_arg): """ - User provides interp_arg and dictionary kw. _init_interp_method - returns the interpolating function specified by interp_arg, - possibly with extra keyword arguments given in kw. - + returns the interpolating function specified by interp_arg. """ # FIXME : error checking specific to interpolation method. x and y long # enough for order-3 spline if that's indicated, etc. Functions should throw @@ -266,11 +245,11 @@ # string used to indicate interpolation method, Select appropriate function func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x, **kw) + result = lambda new_x : func(self._x, self._y, new_x) elif interp_arg in ['Spline', 'spline']: # use the Spline class from fitpack_wrapper # k = 3 unless otherwise specified - result = Spline(self._x, self._y, **kw) + result = Spline(self._x, self._y) elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad', \ 'Cubic', 'cubic', \ 'Quartic', 'quartic', 'Quar', 'quar',\ @@ -290,13 +269,13 @@ # secondary usage : user passes a callable class elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): if hasattr(interp_arg, 'init_xy'): - result = interp_arg(**kw) + result = interp_arg() result.init_xy(self._x, self._y) elif hasattr(interp_arg, 'set_xy'): - result = interp_arg(**kw) + result = interp_arg() result.set_xy(self._x, self._y) else: - result = interp_arg(x, y, **kw) + result = interp_arg(x, y) # user passes an instance of a callable class which has yet # to have its x and y initialized. @@ -308,9 +287,9 @@ result.set_xy(self._x, self._y) # user passes a function to be called - # Assume function has form of f(x, y, newx, **kw) + # Assume function has form of f(x, y, newx) elif isfunction(interp_arg): - result = lambda new_x : interp_arg(self._x, self._y, new_x, **kw) + result = lambda new_x : interp_arg(self._x, self._y, new_x) # default : user has passed a default value to always be returned else: @@ -344,11 +323,11 @@ # to work on lists/arrays of length 0 # on the computer where this is being # developed - else: new_low = self.low(newx_array[low_mask]) + else: new_low = self.extrap_low(newx_array[low_mask]) if len(newx_array[interp_mask])==0: new_interp=np.array([]) else: new_interp = self.interp(newx_array[interp_mask]) if len(newx_array[high_mask]) == 0: new_high = np.array([]) - else: new_high = self.high(newx_array[high_mask]) + else: new_high = self.extrap_high(newx_array[high_mask]) result_array = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes # Would be nice to say result = zeros(dtype=?) From scipy-svn at scipy.org Wed Jul 30 10:43:22 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 30 Jul 2008 09:43:22 -0500 (CDT) Subject: [Scipy-svn] r4580 - trunk/scipy/sandbox/pyloess/tests Message-ID: <20080730144322.EC57439C8DD@scipy.org> Author: matthew.brett at gmail.com Date: 2008-07-30 09:43:00 -0500 (Wed, 30 Jul 2008) New Revision: 4580 Modified: trunk/scipy/sandbox/pyloess/tests/test_pyloess.py Log: More canonical data path finding for tests Modified: trunk/scipy/sandbox/pyloess/tests/test_pyloess.py =================================================================== --- trunk/scipy/sandbox/pyloess/tests/test_pyloess.py 2008-07-29 18:16:22 UTC (rev 4579) +++ trunk/scipy/sandbox/pyloess/tests/test_pyloess.py 2008-07-30 14:43:00 UTC (rev 4580) @@ -25,6 +25,8 @@ from scipy.sandbox.pyloess import lowess, stl, loess, loess_anova +data_path, _ = os.path.split(__file__) + #####--------------------------------------------------------------------------- #---- --- LOWESS --- #####--------------------------------------------------------------------------- @@ -80,14 +82,14 @@ def __init__(self, *args, **kwds): TestCase.__init__(self, *args, **kwds) # Get CO2 data ................ - filename = os.path.join('tests','co2_data') + filename = os.path.join(data_path,'co2_data') F = open(filename, 'r') data = [] for line in F.readlines(): data.append([float(x) for x in line.rstrip().split()]) co2_data = numpy.concatenate(data) # Get CO2 results ............. - filename = os.path.join('tests','co2_results_double') + filename = os.path.join(data_path,'co2_results_double') F = open(filename, 'r') co2_results = [] for line in F.readlines(): @@ -125,7 +127,7 @@ # def __init__(self, *args, **kwds): TestCase.__init__(self, *args, **kwds) - dfile = open(os.path.join('tests','madeup_data'), 'r') + dfile = open(os.path.join(data_path,'madeup_data'), 'r') dfile.readline() x = fromiter((float(v) for v in dfile.readline().rstrip().split()), float_).reshape(-1,2) @@ -133,7 +135,7 @@ y = fromiter((float(v) for v in dfile.readline().rstrip().split()), float_) # - rfile = open(os.path.join('tests','madeup_result'), 'r') + rfile = open(os.path.join(data_path,'madeup_result'), 'r') results = [] for i in range(8): rfile.readline() @@ -285,7 +287,7 @@ 1.0376667, 1.1308333, 1.2240000]) coverage = 0.99 - rfile = open(os.path.join('tests','gas_result'), 'r') + rfile = open(os.path.join(data_path,'gas_result'), 'r') results = [] for i in range(8): rfile.readline() From scipy-svn at scipy.org Wed Jul 30 16:11:38 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 30 Jul 2008 15:11:38 -0500 (CDT) Subject: [Scipy-svn] r4581 - in branches/Interpolate1D: . docs Message-ID: <20080730201138.6953A39C100@scipy.org> Author: fcady Date: 2008-07-30 15:11:37 -0500 (Wed, 30 Jul 2008) New Revision: 4581 Modified: branches/Interpolate1D/docs/tutorial.rst branches/Interpolate1D/interpolate1d.py Log: documentation extensively bolstered. Hoping for feedback from the scipy development community Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-30 14:43:00 UTC (rev 4580) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-30 20:11:37 UTC (rev 4581) @@ -1,15 +1,26 @@ +================== Overview --------- +================== -The interpolate package provides tools for interpolating and extrapolating new data points from a set known set of data points. Intepolate provides both a functional interface that is flexible and easy to use as well as an object oriented interface that can be more efficient and flexible for some cases. It is able to interpolate and extrapolate in 1D, 2D, and even N dimensions.[fixme: 1D only right now] +The interpolate package provides tools for interpolating and extrapolating new data points from a known set of data points. +Interpolate provides both a functional interface that is flexible and easy to use as well as an object oriented interface that +can be more efficient and flexible for some cases. It is able to interpolate and extrapolate in 1D, 2D, and even N +dimensions.*[fixme: 1D only right now]* -For 1D interpolation, it handles linear and spline(cubic, quadratic, and quintic) for both uniformly and non-uniformly spaced data points "out of the box." Users can control the behavior of values that fall outside of the range of interpolation either by When new values fall outside of the range of interpolation data, the tools can be +For 1D interpolation, it handles linear and spline(cubic, quadratic, and quintic) for both uniformly and non-uniformly spaced +data points "out of the box." Users can control the behavior of values that fall outside of the range of interpolation either +by When new values fall outside of the range of interpolation data, the tools can be For 2D interpolation, +================================================ 1D Interpolation with the Functional Interface ----------------------------------------------- +================================================ +------------- +Basic Usage +------------- + The following example uses the 'interp1d' function to linearly interpolate a sin curve from a sparse set of values.:: # start up ipython for our examples. @@ -18,16 +29,180 @@ In [1]: from interpolate import interp1d # Create our "known" set of 5 points with the x values in one array and the y values in another. - In [2]: x = linspace(0,2*pi,5) + In [2]: x = linspace(0, 2*pi, 5) In [3]: y = sin(x) - - # Now interpolate from these x,y values to create a more dense set of new_x, new_y values. - In [4]: new_x = linspace(0,2*pi, 21) - In [5]: new_y = interp1d(x,y, new_x) - + + # If we only want a value at a single point, we can pass in a scalar and interp1d + # will return a scalar + In [9]: interp1d(x, y, 1.2) + Out [10]: 0.76394372684109768 + + # 0-dimensional arrays are also treated as scalars + In [9]: interp1d(x, y, array(1.2) ) + Out [10]: 0.76394372684109768 + + # To interpolate from these x,y values at multiple points, possibly to get a more dense set of new_x, new_y values, + # pass a numpy array to interp1d, and the return type will also be a numpy array. + In [4]: new_x = linspace(0, 2*pi, 21) + In [5]: new_y = interp1d(x, y, new_x) + # Plot the results using matplotlib. [note examples assume you are running in ipython -pylab] - In [6]: plot(x,y,'ro', new_x, new_y, 'b-') - + In [6]: plot(x, y, 'ro', new_x, new_y, 'b-') + .. image:: interp1d_linear_simple.png +:: + + # Alternatively, x, y and new_x can also be lists (they are internally converted into arrays + # before processing) + In []: interp1d( [1.0, 2.0], [1.0, 2.0], [1.3] ) + Out []: array([ 1.3 ]) + + + +What happens if we pass in a new_x with values outside the range of x? By default, new_y will be +NaN at all such points: :: + + # If we attempt to extrapolate values outside the interpolation range, interp1d defaults + # to returning NaN + In [7]: interp1d(x, y, array([-2, -1, 1, 2])) + Out [8]: array([ NaN, NaN, 0.63661977, 0.72676046]) + + +If we want a type of interpolation other than linear, there is a range of options which we can specify +with the keyword argument interp, which is usually a string. For example:: + + # If we want quadratic (2nd order) spline interpolation, we can use the string 'quadratic' + In [7]: new_y_quadratic = interp1d(x, y, new_x, interp = 'quadratic') + In [8]: plot(x, y, 'r', new_x, new_y_quadratic, 'g') + +.. image:: interp1d_linear_and_quadratic.png + + +There is a large selection of strings which specify a range of interpolation methods. The list includes: + +#. 'linear' : linear interpolation, same as the default +#. 'block' : "round new_x down" to the nearest values where we know y. +#. 'spline' : spline interpolation of default order (currently 3) +#. 'cubic' : 3rd order spline interpolation +#. 'quartic' : 4th order spline interpolation +#. 'quintic' : 5th order spline interpolation + +The same flexibility is afforded for extrapolation by the keywords extrap_low and extrap_high: :: + + In []: z = array([ 1.0, 2.0 ]) + In []: interp1d(z, z, array([-5.0, 5.0]), extrap_low = 'linear', extrap_high = 'linear') + Out []: array([-5.0, 5.0]) + +If a string is passed which is not recognized, and error will be raised. + +Finally, interp, extrap_low, and extrap_high can be set to default return values (just make sure that +the return values are not callable and are not strings): :: + + In []: interp1d(x, y, array([ -5.0, 1.1, 100 ]), interp = 8.2, extrap_low = 7.2, extrap_high = 9.2) + Out []: array([ 7.2, 8.2, 9.2 ]) + +It is also possible, though slightly trickier, to define your own interpolation methods and pass them +in to interp, extrap_low, and extrap_high. For more information, see "User-defined Interpolation Methods" +below. + + + +----------------------------- +Removal of Bad Datapoints +----------------------------- + +Many datasets have missing or corrupt data which it is desirable to ignore when interpolating, +and to this end, interp1d has the keyword argument bad_data. + +bad_data defaults to being None. But if it is a list, all "bad" points (x[i], y[i]) will be removed +before any interpolation is performed. A point is "bad" if +1) either x[i] or y[i] is in bad_data, or +2) either x[i] or y[i] is NaN + +Note that bad_data must be either None or a list of numbers. Including NaN or None in the list, +for example, is not supported. NaNs are removed anyway, and None must not appear in the +data. :: + + # the bad_data + In []: x = arange(10.); y = arange(10.) + In []: x[1] = NaN # bad data + In []: y[2] = 55 # bad data + In []: new_x = arange(0, 10., .1) + In []: new_y_bad = interp1d(x, y, new_x) + In []: new_y_no_bad = interp1d(x, y, new_x, bad_data=[55]) + In []: plot(new_x, new_y_bad, 'r', new_x, new_y_no_bad, 'g') + +.. image :: with_and_without_bad_data.png + + + +-------------------------------------- +User-defined Interpolation Methods +-------------------------------------- + +If you want more direct control than is afforded by the string interface, this is also possible. +Note, however, that this is not for the faint-hearted. You must be very careful to have correct +format, and failure to do so can cause a range of errors. + +interp can also be set to a function, a callable class, or an instance of a callable class. If you do this, however, you will +have to be careful about formatting. + +If a function is passed, it will be called when interpolating. +It is assumed to have the form :: + + newy = interp(x, y, newx, **kw) + +where x, y, newx, and newy are all numpy arrays. + +If a callable class is passed, it is assumed to have format:: + + instance = Class(x, y, **kw). + +which can then be called by + + new_y = instance(new_x) + +If a callable object with method "init_xy" or "set_xy" is +passed, that method will be used to set x and y as follows: :: + + instance.set_xy(x, y, **kw) + +and the object will be called during interpolation. + + new_y = instance(new_x) + +If the "init_xy" and "set_xy" are not present, it will be called as + + new_y = argument(new_x) + +A primitive type which is not a string signifies a function +which is identically that value (e.g. val and +lambda x, y, newx : val are equivalent). :: + + # However, this behavior can be overwritten in the same way as linear interpolation, + # by setting the keyword extrap_low (for values below the range of interpolation) and + # extrap_high (for values above that range) + In []: def dummy(x, y, newx, default = 5.1): + # Note that dummy has acceptable form + return np.array([ default ]) + In []: class Phony: + def __init__(self, val = 4.0): + self.val = val + def init_xy(self, x, y): + pass + def __call__(self, newx): + return self.val + In []: x = arange(5.0) + In []: y = arange(5.0) + In []: new_x = np.array([ -1, .4, 7 ]) + In []: new_y = interp1d(x, y, interp = Phony, + interpkw = {'val':1.0}, + extrap_low = dummy, + lowkw = {'default':7.1}, + extrap_high = dummy + ) + In []: new_y + Out []: array([ 7.1, 1.0, 4.0 ]) + \ No newline at end of file Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-30 14:43:00 UTC (rev 4580) +++ branches/Interpolate1D/interpolate1d.py 2008-07-30 20:11:37 UTC (rev 4581) @@ -5,9 +5,30 @@ from fitpack_wrapper import Spline import numpy as np from numpy import array, arange, empty, float64, NaN - -def interp1d(x, y, new_x, interp = 'linear', extrap_low = NaN, extrap_high = NaN, + +# dictionary of tuples. First element is a callable (class, instance of a class, or function +# second argument is dictionary of additional keywords, if any +dict_of_interp_types = \ + { 'linear' : (linear, {}), + 'logarithmic' : (logarithmic, {}), + 'block' : (block, {}), + 'block_average_above' : (block_average_above, {}), + 'Spline' : (Spline, {}), 'spline' : (Spline, {}), + 'Quadratic' : (Spline, {'k':2}), 'quadratic' : (Spline, {'k':2}), + 'Quad' : (Spline, {'k':2}), 'quad' : (Spline, {'k':2}), + 'Cubic' : (Spline, {'k':3}), 'cubic' : (Spline, {'k':3}), + 'Quartic' : (Spline, {'k':4}), 'quartic' : (Spline, {'k':4}), + 'Quar' : (Spline, {'k':4}), 'quar' : (Spline, {'k':4}), + 'Quintic' : (Spline, {'k':5}), 'quintic' : (Spline, {'k':5}), + 'Quin' : (Spline, {'k':5}), 'quin' : (Spline, {'k':5}) + } + +def interp1d(x, y, new_x, + interp = 'linear', extrap_low = NaN, extrap_high = NaN, + interpkw = {}, lowkw = {}, highkw ={}, bad_data = None): + # FIXME : all y to be multi-dimensional + # FIXME : update the doc string to match that of Interpolate1d """ A function for interpolation of 1D data. Parameters @@ -30,7 +51,7 @@ Optional Arguments ------------------- - kind -- Usu. function or string. But can be any type. + interp -- Usu. function or string. But can be any type. Specifies the type of extrapolation to use for values within the range of x. If a string is passed, it will look for an object or function with that name and call it when evaluating. If @@ -38,17 +59,17 @@ If nothing else, assumes the argument is intended as a value to be returned for all arguments. Defaults to linear interpolation. - low (high) -- same as for kind - Same options as for 'kind'. Defaults to returning numpy.NaN ('not + low (high) -- same as for interp + Same options as for 'interp'. Defaults to returning numpy.NaN ('not a number') for all values outside the range of x. - remove_bad_data -- bool - indicates whether to remove bad data. + interpkw -- dictionary + If bad_data -- list List of values (in x or y) which indicate unacceptable data. All points that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. + any interpolatin is performed if bad_data is not None. numpy.NaN is always considered bad data. @@ -78,6 +99,9 @@ interp = interp, extrap_low = extrap_low, extrap_high = extrap_high, + interpkw = interpkw, + lowkw = lowkw, + highkw = highkw, bad_data = bad_data )(new_x) @@ -87,70 +111,51 @@ Parameters ----------- - x -- list or 1D NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order. + x -- list or 1D NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order. + + y -- list or 1D NumPy array + y includes the y-values for the data set to + interpolate from. Note that 2-dimensional + y is not supported. - y -- list or 1D NumPy array - y includes the y-values for the data set to - interpolate from. Note that 2-dimensional - y is not supported. - Optional Arguments ------------------- - kind -- Usu. string or function. But can be any type. - Specifies the type of interpolation to use for values within - the range of x. - - If a string is passed, it will look for an object - or function with that name and call it when evaluating. - This is the primary mode of operation. See below for list - of acceptable strings. - - By default, linear interpolation is used. - - Other options are also available: - - If a callable class is passed, it is assumed to have format - instance = Class(x, y). - It is instantiated and used for interpolation when the instance - of Interpolate1d is called. + interp -- Usually a string. But can be any type. + Specifies the type of interpolation to use for values within + the range of x. - If a callable object with method "init_xy" or "set_xy" is - passed, that method will be used to set x and y, and the - object will be called during interpolation. + By default, linear interpolation is used. - If a function is passed, it will be called when interpolating. - It is assumed to have the form - newy = kind(x, y, newx), - where x, y, newx, and newy are all numpy arrays. + See below for details on other options. - A primitive type which is not a string signifies a function - which is identically that value (e.g. val and - lambda x, y, newx : val are equivalent). + extrap_low -- same as for kind + How to extrapolate values for inputs below the range of x. + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values below the range of x. + + extrap_high -- same as for kind + How to extrapolate values for inputs above the range of x. + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values above the range of x. + + bad_data -- list + List of numerical values (in x or y) which indicate unacceptable data. + + If bad_data is not None (its default), all points whose x or y coordinate is in + bad_data, OR ones of whose coordinates is NaN, will be removed. + + interpkw -- dictionary + If interp is set to a function, class or callable object, this contains + additional keywords. + + lowkw (highkw) -- dictionary + like interpkw, but for extrap_low and extrap_high + - low -- same as for kind - How to extrapolate values for inputs below the range of x. - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values below the range of x. - - high -- same as for kind - How to extrapolate values for inputs above the range of x. - Same options as for 'kind'. Defaults to returning numpy.NaN ('not - a number') for all values above the range of x. - - remove_bad_data -- bool - indicates whether to remove bad data points from x and y. - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if remove_bad_data is true. - - numpy.NaN is always considered bad data. - Some Acceptable Input Strings ------------------------ @@ -164,31 +169,72 @@ "cubic" -- spline interpolation order 3 "quartic" -- spline interpolation order 4 "quintic" -- spline interpolation order 5 + + Other options for interp, extrap_low, and extrap_high + --------------------------------------------------- - Examples + If you choose to use a non-string argument, you must + be careful to use correct formatting. + + If a function is passed, it will be called when interpolating. + It is assumed to have the form + newy = interp(x, y, newx, **kw), + where x, y, newx, and newy are all numpy arrays. + + If a callable class is passed, it is assumed to have format + instance = Class(x, y, **kw). + which can then be called by + new_y = instance(new_x) + + If a callable object with method "init_xy" or "set_xy" is + passed, that method will be used to set x and y as follows + instance.set_xy(x, y, **kw) + and the object will be called during interpolation. + new_y = instance(new_x) + If the "init_xy" and "set_xy" are not present, it will be called as + new_y = argument(new_x) + + A primitive type which is not a string signifies a function + which is identically that value (e.g. val and + lambda x, y, newx : val are equivalent). + + Example --------- >>> import numpy >>> from interpolate1d import Interpolate1d >>> x = range(5) # note list is permitted >>> y = numpy.arange(5.) - >>> new_x = [.2, 2.3, 5.6] + >>> new_x = [.2, 2.3, 5.6, 7.0] >>> interp_func = Interpolate1d(x, y) >>> interp_fuc(new_x) array([.2, 2.3, 5.6, NaN]) + """ # FIXME: more informative descriptions of sample arguments # FIXME: examples in doc string # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash # a warning (esp if we interpolate missing values), but work anyway. - def __init__(self, x, y, interp = 'linear', extrap_low = NaN, extrap_high = NaN, + def __init__(self, x, y, + interp = 'linear', + extrap_low = NaN, + extrap_high = NaN, + interpkw = {}, + lowkw = {}, + highkw = {}, bad_data = None): # FIXME: don't allow copying multiple times. # FIXME : allow no copying, in case user has huge dataset # remove bad data, is there is any if bad_data is not None: + try: + sum_of_bad_data = sum(bad_data) + except: + raise TypeError, "bad_data must be either None \ + or a list of numerical types" + x, y = self._remove_bad_data(x, y, bad_data) # check acceptable size and dimensions @@ -204,9 +250,9 @@ self._init_xy(x, y) # store interpolation functions for each range - self.interp = self._init_interp_method(interp) - self.extrap_low = self._init_interp_method(extrap_low) - self.extrap_high = self._init_interp_method(extrap_high) + self.interp = self._init_interp_method(interp, interpkw) + self.extrap_low = self._init_interp_method(extrap_low, lowkw) + self.extrap_high = self._init_interp_method(extrap_high, highkw) def _init_xy(self, x, y): @@ -216,21 +262,23 @@ self._x = atleast_1d_and_contiguous(x, self._xdtype).copy() self._y = atleast_1d_and_contiguous(y, self._ydtype).copy() - def _remove_bad_data(self, x, y, bad_data = [None, NaN]): + def _remove_bad_data(self, x, y, bad_data = []): """ removes data points whose x or y coordinate is either in bad_data or is a NaN. """ # FIXME : In the future, it may be good to just replace the bad points with good guesses. # Especially in generalizing the higher dimensions # FIXME : This step is very inefficient because it iterates over the array - mask = np.array([ (xi not in bad_data) and (not np.isnan(xi)) and \ - (y[i] not in bad_data) and (not np.isnan(y[i])) \ - for i, xi in enumerate(x) ]) - x = x[mask] - y = y[mask] + + bad_data_mask = np.isnan(x) | np.isnan(y) + for bad_num in bad_data: + bad_data_mask = bad_data_mask | (x==bad_num) | (y==bad_num) + + x = x[~bad_data_mask] + y = y[~bad_data_mask] return x, y - def _init_interp_method(self, interp_arg): + def _init_interp_method(self, interp_arg, kw): """ returns the interpolating function specified by interp_arg. """ @@ -241,60 +289,46 @@ from inspect import isclass, isfunction # primary usage : user passes a string indicating a known function - if interp_arg in ['linear', 'logarithmic', 'block', 'block_average_above']: - # string used to indicate interpolation method, Select appropriate function - func = {'linear':linear, 'logarithmic':logarithmic, 'block':block, \ - 'block_average_above':block_average_above}[interp_arg] - result = lambda new_x : func(self._x, self._y, new_x) - elif interp_arg in ['Spline', 'spline']: - # use the Spline class from fitpack_wrapper - # k = 3 unless otherwise specified - result = Spline(self._x, self._y) - elif interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad', \ - 'Cubic', 'cubic', \ - 'Quartic', 'quartic', 'Quar', 'quar',\ - 'Quintic', 'quintic', 'Quin', 'quin']: - # specify specific kinds of splines - if interp_arg in ['Quadratic', 'quadratic', 'Quad', 'quad']: - result = Spline(self._x, self._y, k=2) - elif interp_arg in ['Cubic', 'cubic']: - result = Spline(self._x, self._y, k=3) - elif interp_arg in ['Quartic', 'quartic', 'Quar', 'quar']: - result = Spline(self._x, self._y, k=4) - elif interp_arg in ['Quintic', 'quintic', 'Quin', 'quin']: - result = Spline(self._x, self._y, k=5) - elif isinstance(interp_arg, basestring): - raise TypeError, "input string %s not valid" % interp_arg + if isinstance(interp_arg, basestring): + interpolator, kw = dict_of_interp_types.setdefault(interp_arg, (None, {}) ) + + if interpolator is None: + raise TypeError, "input string %s not valid" % interp_arg + else: + interpolator = interp_arg - # secondary usage : user passes a callable class - elif isclass(interp_arg) and hasattr(interp_arg, '__call__'): - if hasattr(interp_arg, 'init_xy'): - result = interp_arg() - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy'): - result = interp_arg() - result.set_xy(self._x, self._y) - else: - result = interp_arg(x, y) + # interpolator is a callable : function, class, or instance of class + if hasattr(interpolator, '__call__'): + # function + if isfunction(interpolator): + result = lambda newx : interpolator(self._x, self._y, newx, **kw) - # user passes an instance of a callable class which has yet - # to have its x and y initialized. - elif hasattr(interp_arg, 'init_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.init_xy(self._x, self._y) - elif hasattr(interp_arg, 'set_xy') and hasattr(interp_arg, '__call__'): - result = interp_arg - result.set_xy(self._x, self._y) + # callable class + elif isclass(interpolator): + if hasattr(interpolator, 'set_xy'): + result = interpolator(**kw) + result.set_xy(self._x, self._y) + if hasattr(interpolator, 'init_xy'): + result = interpolator(**kw) + result.init_xy(self._x, self._y) + else: + result = interpolator(self._x, self._y, **kw) - # user passes a function to be called - # Assume function has form of f(x, y, newx) - elif isfunction(interp_arg): - result = lambda new_x : interp_arg(self._x, self._y, new_x) - - # default : user has passed a default value to always be returned + # instance of callable class + else: + if hasattr(interpolator, 'init_xy'): + result = interpolator + result.init_xy(self._x, self._y, **kw) + elif hasattr(interpolator, 'set_xy'): + result = interpolator + result.set_xy(self._x, self._y, **kw) + else: + result = interpolator + + # non-callable : user has passed a default value to always be returned else: result = np.vectorize(lambda new_x : interp_arg) - + return result def __call__(self, newx): @@ -308,8 +342,13 @@ # waste of time, but ok for the time being. # if input is scalar or 0-dimemsional array, output will be scalar - input_is_scalar = np.isscalar(newx) or (isinstance(newx, type(np.array([1.0]))) and np.shape(newx) == ()) + input_is_scalar = np.isscalar(newx) or \ + ( + isinstance( newx , np.ndarray ) and + np.shape(newx) == () + ) + # make newx_array = atleast_1d_and_contiguous(newx) # masks indicate which elements fall into which interpolation region @@ -317,6 +356,9 @@ high_mask = newx_array>self._x[-1] interp_mask = (~low_mask) & (~high_mask) + type(newx_array[low_mask]) + + # use correct function for x values in each region if len(newx_array[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. # if/else is a hack, since vectorize is failing @@ -333,6 +375,7 @@ # Would be nice to say result = zeros(dtype=?) # and fill in + # convert to scalar if scalar was passed in if input_is_scalar: result = float(result_array) else: From scipy-svn at scipy.org Wed Jul 30 16:14:56 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 30 Jul 2008 15:14:56 -0500 (CDT) Subject: [Scipy-svn] r4582 - in branches/Interpolate1D/docs: . build build/doctrees build/html build/html/_images build/html/_sources build/html/_static Message-ID: <20080730201456.74CE739C703@scipy.org> Author: fcady Date: 2008-07-30 15:14:30 -0500 (Wed, 30 Jul 2008) New Revision: 4582 Added: branches/Interpolate1D/docs/build/ branches/Interpolate1D/docs/build/doctrees/ branches/Interpolate1D/docs/build/doctrees/environment.pickle branches/Interpolate1D/docs/build/doctrees/index.doctree branches/Interpolate1D/docs/build/doctrees/tutorial.doctree branches/Interpolate1D/docs/build/html/ branches/Interpolate1D/docs/build/html/_images/ branches/Interpolate1D/docs/build/html/_images/interp1d_linear_and_quadratic.png branches/Interpolate1D/docs/build/html/_images/interp1d_linear_simple.png branches/Interpolate1D/docs/build/html/_images/with_and_without_bad_data.png branches/Interpolate1D/docs/build/html/_sources/ branches/Interpolate1D/docs/build/html/_sources/index.txt branches/Interpolate1D/docs/build/html/_sources/tutorial.txt branches/Interpolate1D/docs/build/html/_static/ branches/Interpolate1D/docs/build/html/_static/contents.png branches/Interpolate1D/docs/build/html/_static/default.css branches/Interpolate1D/docs/build/html/_static/doctools.js branches/Interpolate1D/docs/build/html/_static/file.png branches/Interpolate1D/docs/build/html/_static/interface.js branches/Interpolate1D/docs/build/html/_static/jquery.js branches/Interpolate1D/docs/build/html/_static/minus.png branches/Interpolate1D/docs/build/html/_static/navigation.png branches/Interpolate1D/docs/build/html/_static/plus.png branches/Interpolate1D/docs/build/html/_static/pygments.css branches/Interpolate1D/docs/build/html/_static/rightsidebar.css branches/Interpolate1D/docs/build/html/_static/searchtools.js branches/Interpolate1D/docs/build/html/_static/sphinxdoc.css branches/Interpolate1D/docs/build/html/_static/stickysidebar.css branches/Interpolate1D/docs/build/html/_static/traditional.css branches/Interpolate1D/docs/build/html/genindex.html branches/Interpolate1D/docs/build/html/index.html branches/Interpolate1D/docs/build/html/modindex.html branches/Interpolate1D/docs/build/html/search.html branches/Interpolate1D/docs/build/html/searchindex.json branches/Interpolate1D/docs/build/html/tutorial.html Log: compiled html documentation included Added: branches/Interpolate1D/docs/build/doctrees/environment.pickle =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/doctrees/environment.pickle ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/doctrees/index.doctree =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/doctrees/index.doctree ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/doctrees/tutorial.doctree =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/doctrees/tutorial.doctree ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_images/interp1d_linear_and_quadratic.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_images/interp1d_linear_and_quadratic.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_images/interp1d_linear_simple.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_images/interp1d_linear_simple.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_images/with_and_without_bad_data.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_images/with_and_without_bad_data.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_sources/index.txt =================================================================== --- branches/Interpolate1D/docs/build/html/_sources/index.txt 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_sources/index.txt 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,21 @@ +.. interpolate documentation master file, created by sphinx-quickstart on Tue Jul 29 00:56:51 2008. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to interpolate's documentation! +======================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + tutorial + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + Property changes on: branches/Interpolate1D/docs/build/html/_sources/index.txt ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_sources/tutorial.txt =================================================================== --- branches/Interpolate1D/docs/build/html/_sources/tutorial.txt 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_sources/tutorial.txt 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,208 @@ +================== +Overview +================== + +The interpolate package provides tools for interpolating and extrapolating new data points from a known set of data points. +Interpolate provides both a functional interface that is flexible and easy to use as well as an object oriented interface that +can be more efficient and flexible for some cases. It is able to interpolate and extrapolate in 1D, 2D, and even N +dimensions.*[fixme: 1D only right now]* + +For 1D interpolation, it handles linear and spline(cubic, quadratic, and quintic) for both uniformly and non-uniformly spaced +data points "out of the box." Users can control the behavior of values that fall outside of the range of interpolation either +by When new values fall outside of the range of interpolation data, the tools can be + +For 2D interpolation, + +================================================ +1D Interpolation with the Functional Interface +================================================ + +------------- +Basic Usage +------------- + +The following example uses the 'interp1d' function to linearly interpolate a sin curve from a sparse set of values.:: + + # start up ipython for our examples. + $ ipython -pylab + + In [1]: from interpolate import interp1d + + # Create our "known" set of 5 points with the x values in one array and the y values in another. + In [2]: x = linspace(0, 2*pi, 5) + In [3]: y = sin(x) + + # If we only want a value at a single point, we can pass in a scalar and interp1d + # will return a scalar + In [9]: interp1d(x, y, 1.2) + Out [10]: 0.76394372684109768 + + # 0-dimensional arrays are also treated as scalars + In [9]: interp1d(x, y, array(1.2) ) + Out [10]: 0.76394372684109768 + + # To interpolate from these x,y values at multiple points, possibly to get a more dense set of new_x, new_y values, + # pass a numpy array to interp1d, and the return type will also be a numpy array. + In [4]: new_x = linspace(0, 2*pi, 21) + In [5]: new_y = interp1d(x, y, new_x) + + # Plot the results using matplotlib. [note examples assume you are running in ipython -pylab] + In [6]: plot(x, y, 'ro', new_x, new_y, 'b-') + +.. image:: interp1d_linear_simple.png + +:: + + # Alternatively, x, y and new_x can also be lists (they are internally converted into arrays + # before processing) + In []: interp1d( [1.0, 2.0], [1.0, 2.0], [1.3] ) + Out []: array([ 1.3 ]) + + + +What happens if we pass in a new_x with values outside the range of x? By default, new_y will be +NaN at all such points: :: + + # If we attempt to extrapolate values outside the interpolation range, interp1d defaults + # to returning NaN + In [7]: interp1d(x, y, array([-2, -1, 1, 2])) + Out [8]: array([ NaN, NaN, 0.63661977, 0.72676046]) + + +If we want a type of interpolation other than linear, there is a range of options which we can specify +with the keyword argument interp, which is usually a string. For example:: + + # If we want quadratic (2nd order) spline interpolation, we can use the string 'quadratic' + In [7]: new_y_quadratic = interp1d(x, y, new_x, interp = 'quadratic') + In [8]: plot(x, y, 'r', new_x, new_y_quadratic, 'g') + +.. image:: interp1d_linear_and_quadratic.png + + +There is a large selection of strings which specify a range of interpolation methods. The list includes: + +#. 'linear' : linear interpolation, same as the default +#. 'block' : "round new_x down" to the nearest values where we know y. +#. 'spline' : spline interpolation of default order (currently 3) +#. 'cubic' : 3rd order spline interpolation +#. 'quartic' : 4th order spline interpolation +#. 'quintic' : 5th order spline interpolation + +The same flexibility is afforded for extrapolation by the keywords extrap_low and extrap_high: :: + + In []: z = array([ 1.0, 2.0 ]) + In []: interp1d(z, z, array([-5.0, 5.0]), extrap_low = 'linear', extrap_high = 'linear') + Out []: array([-5.0, 5.0]) + +If a string is passed which is not recognized, and error will be raised. + +Finally, interp, extrap_low, and extrap_high can be set to default return values (just make sure that +the return values are not callable and are not strings): :: + + In []: interp1d(x, y, array([ -5.0, 1.1, 100 ]), interp = 8.2, extrap_low = 7.2, extrap_high = 9.2) + Out []: array([ 7.2, 8.2, 9.2 ]) + +It is also possible, though slightly trickier, to define your own interpolation methods and pass them +in to interp, extrap_low, and extrap_high. For more information, see "User-defined Interpolation Methods" +below. + + + +----------------------------- +Removal of Bad Datapoints +----------------------------- + +Many datasets have missing or corrupt data which it is desirable to ignore when interpolating, +and to this end, interp1d has the keyword argument bad_data. + +bad_data defaults to being None. But if it is a list, all "bad" points (x[i], y[i]) will be removed +before any interpolation is performed. A point is "bad" if +1) either x[i] or y[i] is in bad_data, or +2) either x[i] or y[i] is NaN + +Note that bad_data must be either None or a list of numbers. Including NaN or None in the list, +for example, is not supported. NaNs are removed anyway, and None must not appear in the +data. :: + + # the bad_data + In []: x = arange(10.); y = arange(10.) + In []: x[1] = NaN # bad data + In []: y[2] = 55 # bad data + In []: new_x = arange(0, 10., .1) + In []: new_y_bad = interp1d(x, y, new_x) + In []: new_y_no_bad = interp1d(x, y, new_x, bad_data=[55]) + In []: plot(new_x, new_y_bad, 'r', new_x, new_y_no_bad, 'g') + +.. image :: with_and_without_bad_data.png + + + +-------------------------------------- +User-defined Interpolation Methods +-------------------------------------- + +If you want more direct control than is afforded by the string interface, this is also possible. +Note, however, that this is not for the faint-hearted. You must be very careful to have correct +format, and failure to do so can cause a range of errors. + +interp can also be set to a function, a callable class, or an instance of a callable class. If you do this, however, you will +have to be careful about formatting. + +If a function is passed, it will be called when interpolating. +It is assumed to have the form :: + + newy = interp(x, y, newx, **kw) + +where x, y, newx, and newy are all numpy arrays. + +If a callable class is passed, it is assumed to have format:: + + instance = Class(x, y, **kw). + +which can then be called by + + new_y = instance(new_x) + +If a callable object with method "init_xy" or "set_xy" is +passed, that method will be used to set x and y as follows: :: + + instance.set_xy(x, y, **kw) + +and the object will be called during interpolation. + + new_y = instance(new_x) + +If the "init_xy" and "set_xy" are not present, it will be called as + + new_y = argument(new_x) + +A primitive type which is not a string signifies a function +which is identically that value (e.g. val and +lambda x, y, newx : val are equivalent). :: + + # However, this behavior can be overwritten in the same way as linear interpolation, + # by setting the keyword extrap_low (for values below the range of interpolation) and + # extrap_high (for values above that range) + In []: def dummy(x, y, newx, default = 5.1): + # Note that dummy has acceptable form + return np.array([ default ]) + In []: class Phony: + def __init__(self, val = 4.0): + self.val = val + def init_xy(self, x, y): + pass + def __call__(self, newx): + return self.val + In []: x = arange(5.0) + In []: y = arange(5.0) + In []: new_x = np.array([ -1, .4, 7 ]) + In []: new_y = interp1d(x, y, interp = Phony, + interpkw = {'val':1.0}, + extrap_low = dummy, + lowkw = {'default':7.1}, + extrap_high = dummy + ) + In []: new_y + Out []: array([ 7.1, 1.0, 4.0 ]) + + \ No newline at end of file Property changes on: branches/Interpolate1D/docs/build/html/_sources/tutorial.txt ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/contents.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_static/contents.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_static/default.css =================================================================== --- branches/Interpolate1D/docs/build/html/_static/default.css 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/default.css 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,833 @@ +/** + * Sphinx Doc Design + */ + +body { + font-family: sans-serif; + font-size: 100%; + background-color: #11303d; + color: #000; + margin: 0; + padding: 0; +} + +/* :::: LAYOUT :::: */ + +div.document { + background-color: #1c4e63; +} + +div.documentwrapper { + float: left; + width: 100%; +} + +div.bodywrapper { + margin: 0 0 0 230px; +} + +div.body { + background-color: white; + padding: 0 20px 30px 20px; +} + +div.sphinxsidebarwrapper { + padding: 10px 5px 0 10px; +} + +div.sphinxsidebar { + float: left; + width: 230px; + margin-left: -100%; + font-size: 90%; +} + +div.clearer { + clear: both; +} + +div.footer { + color: #fff; + width: 100%; + padding: 9px 0 9px 0; + text-align: center; + font-size: 75%; +} + +div.footer a { + color: #fff; + text-decoration: underline; +} + +div.related { + background-color: #133f52; + color: #fff; + width: 100%; + height: 30px; + line-height: 30px; + font-size: 90%; +} + +div.related h3 { + display: none; +} + +div.related ul { + margin: 0; + padding: 0 0 0 10px; + list-style: none; +} + +div.related li { + display: inline; +} + +div.related li.right { + float: right; + margin-right: 5px; +} + +div.related a { + color: white; +} + +/* ::: TOC :::: */ +div.sphinxsidebar h3 { + font-family: 'Trebuchet MS', sans-serif; + color: white; + font-size: 1.4em; + font-weight: normal; + margin: 0; + padding: 0; +} + +div.sphinxsidebar h4 { + font-family: 'Trebuchet MS', sans-serif; + color: white; + font-size: 1.3em; + font-weight: normal; + margin: 5px 0 0 0; + padding: 0; +} + +div.sphinxsidebar p { + color: white; +} + +div.sphinxsidebar p.topless { + margin: 5px 10px 10px 10px; +} + +div.sphinxsidebar ul { + margin: 10px; + padding: 0; + list-style: none; + color: white; +} + +div.sphinxsidebar ul ul, +div.sphinxsidebar ul.want-points { + margin-left: 20px; + list-style: square; +} + +div.sphinxsidebar ul ul { + margin-top: 0; + margin-bottom: 0; +} + +div.sphinxsidebar a { + color: #98dbcc; +} + +div.sphinxsidebar form { + margin-top: 10px; +} + +div.sphinxsidebar input { + border: 1px solid #98dbcc; + font-family: sans-serif; + font-size: 1em; +} + +/* :::: MODULE CLOUD :::: */ +div.modulecloud { + margin: -5px 10px 5px 10px; + padding: 10px; + line-height: 160%; + border: 1px solid #cbe7e5; + background-color: #f2fbfd; +} + +div.modulecloud a { + padding: 0 5px 0 5px; +} + +/* :::: SEARCH :::: */ +ul.search { + margin: 10px 0 0 20px; + padding: 0; +} + +ul.search li { + padding: 5px 0 5px 20px; + background-image: url(file.png); + background-repeat: no-repeat; + background-position: 0 7px; +} + +ul.search li a { + font-weight: bold; +} + +ul.search li div.context { + color: #888; + margin: 2px 0 0 30px; + text-align: left; +} + +ul.keywordmatches li.goodmatch a { + font-weight: bold; +} + +/* :::: COMMON FORM STYLES :::: */ + +div.actions { + padding: 5px 10px 5px 10px; + border-top: 1px solid #cbe7e5; + border-bottom: 1px solid #cbe7e5; + background-color: #e0f6f4; +} + +form dl { + color: #333; +} + +form dt { + clear: both; + float: left; + min-width: 110px; + margin-right: 10px; + padding-top: 2px; +} + +input#homepage { + display: none; +} + +div.error { + margin: 5px 20px 0 0; + padding: 5px; + border: 1px solid #d00; + font-weight: bold; +} + +/* :::: INLINE COMMENTS :::: */ + +div.inlinecomments { + position: absolute; + right: 20px; +} + +div.inlinecomments a.bubble { + display: block; + float: right; + background-image: url(style/comment.png); + background-repeat: no-repeat; + width: 25px; + height: 25px; + text-align: center; + padding-top: 3px; + font-size: 0.9em; + line-height: 14px; + font-weight: bold; + color: black; +} + +div.inlinecomments a.bubble span { + display: none; +} + +div.inlinecomments a.emptybubble { + background-image: url(style/nocomment.png); +} + +div.inlinecomments a.bubble:hover { + background-image: url(style/hovercomment.png); + text-decoration: none; + color: #3ca0a4; +} + +div.inlinecomments div.comments { + float: right; + margin: 25px 5px 0 0; + max-width: 50em; + min-width: 30em; + border: 1px solid #2eabb0; + background-color: #f2fbfd; + z-index: 150; +} + +div#comments { + border: 1px solid #2eabb0; + margin-top: 20px; +} + +div#comments div.nocomments { + padding: 10px; + font-weight: bold; +} + +div.inlinecomments div.comments h3, +div#comments h3 { + margin: 0; + padding: 0; + background-color: #2eabb0; + color: white; + border: none; + padding: 3px; +} + +div.inlinecomments div.comments div.actions { + padding: 4px; + margin: 0; + border-top: none; +} + +div#comments div.comment { + margin: 10px; + border: 1px solid #2eabb0; +} + +div.inlinecomments div.comment h4, +div.commentwindow div.comment h4, +div#comments div.comment h4 { + margin: 10px 0 0 0; + background-color: #2eabb0; + color: white; + border: none; + padding: 1px 4px 1px 4px; +} + +div#comments div.comment h4 { + margin: 0; +} + +div#comments div.comment h4 a { + color: #d5f4f4; +} + +div.inlinecomments div.comment div.text, +div.commentwindow div.comment div.text, +div#comments div.comment div.text { + margin: -5px 0 -5px 0; + padding: 0 10px 0 10px; +} + +div.inlinecomments div.comment div.meta, +div.commentwindow div.comment div.meta, +div#comments div.comment div.meta { + text-align: right; + padding: 2px 10px 2px 0; + font-size: 95%; + color: #538893; + border-top: 1px solid #cbe7e5; + background-color: #e0f6f4; +} + +div.commentwindow { + position: absolute; + width: 500px; + border: 1px solid #cbe7e5; + background-color: #f2fbfd; + display: none; + z-index: 130; +} + +div.commentwindow h3 { + margin: 0; + background-color: #2eabb0; + color: white; + border: none; + padding: 5px; + font-size: 1.5em; + cursor: pointer; +} + +div.commentwindow div.actions { + margin: 10px -10px 0 -10px; + padding: 4px 10px 4px 10px; + color: #538893; +} + +div.commentwindow div.actions input { + border: 1px solid #2eabb0; + background-color: white; + color: #135355; + cursor: pointer; +} + +div.commentwindow div.form { + padding: 0 10px 0 10px; +} + +div.commentwindow div.form input, +div.commentwindow div.form textarea { + border: 1px solid #3c9ea2; + background-color: white; + color: black; +} + +div.commentwindow div.error { + margin: 10px 5px 10px 5px; + background-color: #fbe5dc; + display: none; +} + +div.commentwindow div.form textarea { + width: 99%; +} + +div.commentwindow div.preview { + margin: 10px 0 10px 0; + background-color: #70d0d4; + padding: 0 1px 1px 25px; +} + +div.commentwindow div.preview h4 { + margin: 0 0 -5px -20px; + padding: 4px 0 0 4px; + color: white; + font-size: 1.3em; +} + +div.commentwindow div.preview div.comment { + background-color: #f2fbfd; +} + +div.commentwindow div.preview div.comment h4 { + margin: 10px 0 0 0!important; + padding: 1px 4px 1px 4px!important; + font-size: 1.2em; +} + +/* :::: SUGGEST CHANGES :::: */ +div#suggest-changes-box input, div#suggest-changes-box textarea { + border: 1px solid #ccc; + background-color: white; + color: black; +} + +div#suggest-changes-box textarea { + width: 99%; + height: 400px; +} + + +/* :::: PREVIEW :::: */ +div.preview { + background-image: url(style/preview.png); + padding: 0 20px 20px 20px; + margin-bottom: 30px; +} + + +/* :::: INDEX PAGE :::: */ + +table.contentstable { + width: 90%; +} + +table.contentstable p.biglink { + line-height: 150%; +} + +a.biglink { + font-size: 1.3em; +} + +span.linkdescr { + font-style: italic; + padding-top: 5px; + font-size: 90%; +} + +/* :::: INDEX STYLES :::: */ + +table.indextable td { + text-align: left; + vertical-align: top; +} + +table.indextable dl, table.indextable dd { + margin-top: 0; + margin-bottom: 0; +} + +table.indextable tr.pcap { + height: 10px; +} + +table.indextable tr.cap { + margin-top: 10px; + background-color: #f2f2f2; +} + +img.toggler { + margin-right: 3px; + margin-top: 3px; + cursor: pointer; +} + +form.pfform { + margin: 10px 0 20px 0; +} + +/* :::: GLOBAL STYLES :::: */ + +.docwarning { + background-color: #ffe4e4; + padding: 10px; + margin: 0 -20px 0 -20px; + border-bottom: 1px solid #f66; +} + +p.subhead { + font-weight: bold; + margin-top: 20px; +} + +a { + color: #355f7c; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +div.body h1, +div.body h2, +div.body h3, +div.body h4, +div.body h5, +div.body h6 { + font-family: 'Trebuchet MS', sans-serif; + background-color: #f2f2f2; + font-weight: normal; + color: #20435c; + border-bottom: 1px solid #ccc; + margin: 20px -20px 10px -20px; + padding: 3px 0 3px 10px; +} + +div.body h1 { margin-top: 0; font-size: 200%; } +div.body h2 { font-size: 160%; } +div.body h3 { font-size: 140%; } +div.body h4 { font-size: 120%; } +div.body h5 { font-size: 110%; } +div.body h6 { font-size: 100%; } + +a.headerlink { + color: #c60f0f; + font-size: 0.8em; + padding: 0 4px 0 4px; + text-decoration: none; + visibility: hidden; +} + +h1:hover > a.headerlink, +h2:hover > a.headerlink, +h3:hover > a.headerlink, +h4:hover > a.headerlink, +h5:hover > a.headerlink, +h6:hover > a.headerlink, +dt:hover > a.headerlink { + visibility: visible; +} + +a.headerlink:hover { + background-color: #c60f0f; + color: white; +} + +div.body p, div.body dd, div.body li { + text-align: justify; + line-height: 130%; +} + +div.body p.caption { + text-align: inherit; +} + +div.body td { + text-align: left; +} + +ul.fakelist { + list-style: none; + margin: 10px 0 10px 20px; + padding: 0; +} + +.field-list ul { + padding-left: 1em; +} + +.first { + margin-top: 0 !important; +} + +/* "Footnotes" heading */ +p.rubric { + margin-top: 30px; + font-weight: bold; +} + +/* "Topics" */ + +div.topic { + background-color: #eee; + border: 1px solid #ccc; + padding: 0 7px 0 7px; + margin: 10px 0 10px 0; +} + +p.topic-title { + font-size: 1.1em; + font-weight: bold; + margin-top: 10px; +} + +/* Admonitions */ + +div.admonition { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; +} + +div.admonition dt { + font-weight: bold; +} + +div.admonition dl { + margin-bottom: 0; +} + +div.admonition p { + display: inline; +} + +div.seealso { + background-color: #ffc; + border: 1px solid #ff6; +} + +div.warning { + background-color: #ffe4e4; + border: 1px solid #f66; +} + +div.note { + background-color: #eee; + border: 1px solid #ccc; +} + +p.admonition-title { + margin: 0px 10px 5px 0px; + font-weight: bold; + display: inline; +} + +p.admonition-title:after { + content: ":"; +} + +div.body p.centered { + text-align: center; + margin-top: 25px; +} + +table.docutils { + border: 0; +} + +table.docutils td, table.docutils th { + padding: 1px 8px 1px 0; + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #aaa; +} + +table.field-list td, table.field-list th { + border: 0 !important; +} + +table.footnote td, table.footnote th { + border: 0 !important; +} + +.field-list ul { + margin: 0; + padding-left: 1em; +} + +.field-list p { + margin: 0; +} + +dl { + margin-bottom: 15px; + clear: both; +} + +dd p { + margin-top: 0px; +} + +dd ul, dd table { + margin-bottom: 10px; +} + +dd { + margin-top: 3px; + margin-bottom: 10px; + margin-left: 30px; +} + +.refcount { + color: #060; +} + +dt:target, +.highlight { + background-color: #fbe54e; +} + +dl.glossary dt { + font-weight: bold; + font-size: 1.1em; +} + +th { + text-align: left; + padding-right: 5px; +} + +pre { + padding: 5px; + background-color: #efc; + color: #333; + border: 1px solid #ac9; + border-left: none; + border-right: none; + overflow: auto; +} + +td.linenos pre { + padding: 5px 0px; + border: 0; + background-color: transparent; + color: #aaa; +} + +table.highlighttable { + margin-left: 0.5em; +} + +table.highlighttable td { + padding: 0 0.5em 0 0.5em; +} + +tt { + background-color: #ecf0f3; + padding: 0 1px 0 1px; + font-size: 0.95em; +} + +tt.descname { + background-color: transparent; + font-weight: bold; + font-size: 1.2em; +} + +tt.descclassname { + background-color: transparent; +} + +tt.xref, a tt { + background-color: transparent; + font-weight: bold; +} + +.footnote:target { background-color: #ffa } + +h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { + background-color: transparent; +} + +.optional { + font-size: 1.3em; +} + +.versionmodified { + font-style: italic; +} + +form.comment { + margin: 0; + padding: 10px 30px 10px 30px; + background-color: #eee; +} + +form.comment h3 { + background-color: #326591; + color: white; + margin: -10px -30px 10px -30px; + padding: 5px; + font-size: 1.4em; +} + +form.comment input, +form.comment textarea { + border: 1px solid #ccc; + padding: 2px; + font-family: sans-serif; + font-size: 100%; +} + +form.comment input[type="text"] { + width: 240px; +} + +form.comment textarea { + width: 100%; + height: 200px; + margin-bottom: 10px; +} + +.system-message { + background-color: #fda; + padding: 5px; + border: 3px solid red; +} + +/* :::: PRINT :::: */ + at media print { + div.document, + div.documentwrapper, + div.bodywrapper { + margin: 0; + width : 100%; + } + + div.sphinxsidebar, + div.related, + div.footer, + div#comments div.new-comment-box, + #top-link { + display: none; + } +} Property changes on: branches/Interpolate1D/docs/build/html/_static/default.css ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/doctools.js =================================================================== --- branches/Interpolate1D/docs/build/html/_static/doctools.js 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/doctools.js 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,352 @@ +/// XXX: make it cross browser + +/** + * make the code below compatible with browsers without + * an installed firebug like debugger + */ +if (!window.console || !console.firebug) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {} +} + +/** + * small helper function to urldecode strings + */ +jQuery.urldecode = function(x) { + return decodeURIComponent(x).replace(/\+/g, ' '); +} + +/** + * small helper function to urlencode strings + */ +jQuery.urlencode = encodeURIComponent; + +/** + * This function returns the parsed url parameters of the + * current request. Multiple values per key are supported, + * it will always return arrays of strings for the value parts. + */ +jQuery.getQueryParameters = function(s) { + if (typeof s == 'undefined') + s = document.location.search; + var parts = s.substr(s.indexOf('?') + 1).split('&'); + var result = {}; + for (var i = 0; i < parts.length; i++) { + var tmp = parts[i].split('=', 2); + var key = jQuery.urldecode(tmp[0]); + var value = jQuery.urldecode(tmp[1]); + if (key in result) + result[key].push(value); + else + result[key] = [value]; + } + return result; +} + +/** + * small function to check if an array contains + * a given item. + */ +jQuery.contains = function(arr, item) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == item) + return true; + } + return false; +} + +/** + * highlight a given string on a jquery object by wrapping it in + * span elements with the given class name. + */ +jQuery.fn.highlightText = function(text, className) { + function highlight(node) { + if (node.nodeType == 3) { + var val = node.nodeValue; + var pos = val.toLowerCase().indexOf(text); + if (pos >= 0 && !jQuery.className.has(node.parentNode, className)) { + var span = document.createElement("span"); + span.className = className; + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + node.parentNode.insertBefore(span, node.parentNode.insertBefore( + document.createTextNode(val.substr(pos + text.length)), + node.nextSibling)); + node.nodeValue = val.substr(0, pos); + } + } + else if (!jQuery(node).is("button, select, textarea")) { + jQuery.each(node.childNodes, function() { + highlight(this) + }); + } + } + return this.each(function() { + highlight(this); + }); +} + +/** + * Small JavaScript module for the documentation. + */ +var Documentation = { + + init : function() { + /* this.addContextElements(); -- now done statically */ + this.fixFirefoxAnchorBug(); + this.highlightSearchWords(); + this.initModIndex(); + this.initComments(); + }, + + /** + * add context elements like header anchor links + */ + addContextElements : function() { + for (var i = 1; i <= 6; i++) { + $('h' + i + '[@id]').each(function() { + $('\u00B6'). + attr('href', '#' + this.id). + attr('title', 'Permalink to this headline'). + appendTo(this); + }); + } + $('dt[@id]').each(function() { + $('\u00B6'). + attr('href', '#' + this.id). + attr('title', 'Permalink to this definition'). + appendTo(this); + }); + }, + + /** + * workaround a firefox stupidity + */ + fixFirefoxAnchorBug : function() { + if (document.location.hash && $.browser.mozilla) + window.setTimeout(function() { + document.location.href += ''; + }, 10); + }, + + /** + * highlight the search words provided in the url in the text + */ + highlightSearchWords : function() { + var params = $.getQueryParameters(); + var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; + if (terms.length) { + var body = $('div.body'); + window.setTimeout(function() { + $.each(terms, function() { + body.highlightText(this.toLowerCase(), 'highlight'); + }); + }, 10); + $('') + .appendTo($('.sidebar .this-page-menu')); + } + }, + + /** + * init the modindex toggle buttons + */ + initModIndex : function() { + var togglers = $('img.toggler').click(function() { + var src = $(this).attr('src'); + var idnum = $(this).attr('id').substr(7); + console.log($('tr.cg-' + idnum).toggle()); + if (src.substr(-9) == 'minus.png') + $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); + else + $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); + }).css('display', ''); + if (DOCUMENTATION_OPTIONS.COLLAPSE_MODINDEX) { + togglers.click(); + } + }, + + /** + * init the inline comments + */ + initComments : function() { + $('.inlinecomments div.actions').each(function() { + this.innerHTML += ' | '; + $(this).append($('hide comments').click(function() { + $(this).parent().parent().toggle(); + return false; + })); + }); + $('.inlinecomments .comments').hide(); + $('.inlinecomments a.bubble').each(function() { + $(this).click($(this).is('.emptybubble') ? function() { + var params = $.getQueryParameters(this.href); + Documentation.newComment(params.target[0]); + return false; + } : function() { + $('.comments', $(this).parent().parent()[0]).toggle(); + return false; + }); + }); + $('#comments div.actions a.newcomment').click(function() { + Documentation.newComment(); + return false; + }); + if (document.location.hash.match(/^#comment-/)) + $('.inlinecomments .comments ' + document.location.hash) + .parent().toggle(); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords : function() { + $('.sidebar .this-page-menu li.highlight-link').fadeOut(300); + $('span.highlight').removeClass('highlight'); + }, + + /** + * show the comment window for a certain id or the whole page. + */ + newComment : function(id) { + Documentation.CommentWindow.openFor(id || ''); + }, + + /** + * write a new comment from within a comment view box + */ + newCommentFromBox : function(link) { + var params = $.getQueryParameters(link.href); + $(link).parent().parent().fadeOut('slow'); + this.newComment(params.target); + }, + + /** + * make the url absolute + */ + makeURL : function(relativeURL) { + return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; + }, + + /** + * get the current relative url + */ + getCurrentURL : function() { + var path = document.location.pathname; + var parts = path.split(/\//); + $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { + if (this == '..') + parts.pop(); + }); + var url = parts.join('/'); + return path.substring(url.lastIndexOf('/') + 1, path.length - 1); + }, + + /** + * class that represents the comment window + */ + CommentWindow : (function() { + var openWindows = {}; + + var Window = function(sectionID) { + this.url = Documentation.makeURL('@comments/' + Documentation.getCurrentURL() + + '/?target=' + $.urlencode(sectionID) + '&mode=ajax'); + this.sectionID = sectionID; + + this.root = $('
'); + this.root.appendTo($('body')); + this.title = $('

New Comment

').appendTo(this.root); + this.body = $('
please wait...
').appendTo(this.root); + this.resizeHandle = $('
').appendTo(this.root); + + this.root.Draggable({ + handle: this.title[0] + }); + + this.root.css({ + left: window.innerWidth / 2 - $(this.root).width() / 2, + top: window.scrollY + (window.innerHeight / 2 - 150) + }); + this.root.fadeIn('slow'); + this.updateView(); + }; + + Window.prototype.updateView = function(data) { + var self = this; + function update(data) { + if (data.posted) { + document.location.hash = '#comment-' + data.commentID; + document.location.reload(); + } + else { + self.body.html(data.body); + $('div.actions', self.body).append($('') + .attr('type', 'button') + .attr('value', 'Close') + .click(function() { self.close(); }) + ); + $('div.actions input[@name="preview"]') + .attr('type', 'button') + .click(function() { self.submitForm($('form', self.body)[0], true); }); + $('form', self.body).bind("submit", function() { + self.submitForm(this); + return false; + }); + + if (data.error) { + self.root.Highlight(1000, '#aadee1'); + $('div.error', self.root).slideDown(500); + } + } + } + + if (typeof data == 'undefined') + $.getJSON(this.url, function(json) { update(json); }); + else + $.ajax({ + url: this.url, + type: 'POST', + dataType: 'json', + data: data, + success: function(json) { update(json); } + }); + } + + Window.prototype.getFormValue = function(name) { + return $('*[@name="' + name + '"]', this.body)[0].value; + } + + Window.prototype.submitForm = function(form, previewMode) { + this.updateView({ + author: form.author.value, + author_mail: form.author_mail.value, + title: form.title.value, + comment_body: form.comment_body.value, + preview: previewMode ? 'yes' : '' + }); + } + + Window.prototype.close = function() { + var self = this; + delete openWindows[this.sectionID]; + this.root.fadeOut('slow', function() { + self.root.remove(); + }); + } + + Window.openFor = function(sectionID) { + if (sectionID in openWindows) + return openWindows[sectionID]; + return new Window(sectionID); + } + + return Window; + })() +}; + + +$(document).ready(function() { + Documentation.init(); +}); Property changes on: branches/Interpolate1D/docs/build/html/_static/doctools.js ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/file.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_static/file.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_static/interface.js =================================================================== --- branches/Interpolate1D/docs/build/html/_static/interface.js 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/interface.js 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,8 @@ +/* + * Interface elements for jQuery - http://interface.eyecon.ro + * + * Copyright (c) 2006 Stefan Petre + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + */ + eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('k.1a={2R:u(e){D x=0;D y=0;D 5H=I;D es=e.18;if(k(e).B(\'19\')==\'1n\'){62=es.3j;9C=es.Y;es.3j=\'2O\';es.19=\'2E\';es.Y=\'1O\';5H=1b}D el=e;7o(el){x+=el.8n+(el.4Y&&!k.3h.7N?T(el.4Y.5a)||0:0);y+=el.8t+(el.4Y&&!k.3h.7N?T(el.4Y.4Z)||0:0);el=el.dr}el=e;7o(el&&el.4S&&el.4S.5Z()!=\'2e\'){x-=el.3g||0;y-=el.2V||0;el=el.3e}if(5H){es.19=\'1n\';es.Y=9C;es.3j=62}E{x:x,y:y}},bN:u(el){D x=0,y=0;7o(el){x+=el.8n||0;y+=el.8t||0;el=el.dr}E{x:x,y:y}},2p:u(e){D w=k.B(e,\'Z\');D h=k.B(e,\'V\');D 1D=0;D hb=0;D es=e.18;if(k(e).B(\'19\')!=\'1n\'){1D=e.4b;hb=e.63}P{62=es.3j;9C=es.Y;es.3j=\'2O\';es.19=\'2E\';es.Y=\'1O\';1D=e.4b;hb=e.63;es.19=\'1n\';es.Y=9C;es.3j=62}E{w:w,h:h,1D:1D,hb:hb}},82:u(el){E{1D:el.4b||0,hb:el.63||0}},bq:u(e){D h,w,de;if(e){w=e.8k;h=e.8z}P{de=1j.4J;w=1V.d0||9B.d0||(de&&de.8k)||1j.2e.8k;h=1V.d1||9B.d1||(de&&de.8z)||1j.2e.8z}E{w:w,h:h}},6W:u(e){D t,l,w,h,iw,ih;if(e&&e.9A.5Z()!=\'2e\'){t=e.2V;l=e.3g;w=e.cY;h=e.cW;iw=0;ih=0}P{if(1j.4J&&1j.4J.2V){t=1j.4J.2V;l=1j.4J.3g;w=1j.4J.cY;h=1j.4J.cW}P if(1j.2e){t=1j.2e.2V;l=1j.2e.3g;w=1j.2e.cY;h=1j.2e.cW}iw=9B.d0||1j.4J.8k||1j.2e.8k||0;ih=9B.d1||1j.4J.8z||1j.2e.8z||0}E{t:t,l:l,w:w,h:h,iw:iw,ih:ih}},c8:u(e,7C){D el=k(e);D t=el.B(\'5o\')||\'\';D r=el.B(\'5p\')||\'\';D b=el.B(\'5m\')||\'\';D l=el.B(\'5k\')||\'\';if(7C)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},aj:u(e,7C){D el=k(e);D t=el.B(\'66\')||\'\';D r=el.B(\'6j\')||\'\';D b=el.B(\'5M\')||\'\';D l=el.B(\'4X\')||\'\';if(7C)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},6h:u(e,7C){D el=k(e);D t=el.B(\'4Z\')||\'\';D r=el.B(\'6k\')||\'\';D b=el.B(\'6g\')||\'\';D l=el.B(\'5a\')||\'\';if(7C)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)||0};P E{t:t,r:r,b:b,l:l}},44:u(2l){D x=2l.hI||(2l.hK+(1j.4J.3g||1j.2e.3g))||0;D y=2l.hL||(2l.hM+(1j.4J.2V||1j.2e.2V))||0;E{x:x,y:y}},cS:u(54,cT){cT(54);54=54.77;7o(54){k.1a.cS(54,cT);54=54.hU}},i1:u(54){k.1a.cS(54,u(el){1Y(D 1p in el){if(2h el[1p]===\'u\'){el[1p]=U}}})},i3:u(el,1N){D 5C=$.1a.6W();D d3=$.1a.2p(el);if(!1N||1N==\'4i\')$(el).B({Q:5C.t+((14.3v(5C.h,5C.ih)-5C.t-d3.hb)/2)+\'S\'});if(!1N||1N==\'4a\')$(el).B({O:5C.l+((14.3v(5C.w,5C.iw)-5C.l-d3.1D)/2)+\'S\'})},i0:u(el,dP){D 1Q=$(\'1U[@2M*="95"]\',el||1j),95;1Q.1B(u(){95=q.2M;q.2M=dP;q.18.69="aw:ax.ay.hZ(2M=\'"+95+"\')"})}};[].3F||(7b.hV.3F=u(v,n){n=(n==U)?0:n;D m=q.1h;1Y(D i=n;i-cd?r:(2m(k.B(2i,2z))||0);49=49==\'3Y\'?(7M==\'1n\'?\'22\':\'2G\'):49;M[49]=1b;2k[2z]=49==\'22\'?[0,2i.6u[2z]]:[2i.6u[2z],0];if(2z!=\'1J\')y[2z]=2k[2z][0]+(2z!=\'3B\'&&2z!=\'8h\'?\'S\':\'\');P k.1p(y,"1J",2k[2z][0])}P{2k[2z]=[2m(k.3M(2i,2z)),2m(49)||0]}}P if(k.fx.d9[2z])2k[2z]=[k.fx.6H(k.3M(2i,2z)),k.fx.6H(49)];P if(/^6X$|92$|2B$|9I$|cD$/i.43(2z)){D m=49.4v(/\\s+/g,\' \').4v(/7K\\s*\\(\\s*/g,\'7K(\').4v(/\\s*,\\s*/g,\',\').4v(/\\s*\\)/g,\')\').bU(/([^\\s]+)/g);3m(2z){1e\'6X\':1e\'92\':1e\'cD\':1e\'9I\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];1Y(D i=0;iM.1m+z.9x){6c(z.2H);z.2H=U;1Y(p in 2k){if(p=="1J")k.1p(y,"1J",2k[p][1]);P if(2h 2k[p][1]==\'8i\')y[p]=\'7K(\'+2k[p][1].r+\',\'+2k[p][1].g+\',\'+2k[p][1].b+\')\';P y[p]=2k[p][1]+(p!=\'3B\'&&p!=\'8h\'?\'S\':\'\')}if(M.2G||M.22)1Y(D p in 2i.6u)if(p=="1J")k.1p(y,p,2i.6u[p]);P y[p]="";y.19=M.2G?\'1n\':(7M!=\'1n\'?7M:\'2E\');y.2Y=eH;2i.5R=U;if(k.eI(M.23))M.23.1F(2i)}P{D n=t-q.9x;D 8x=n/M.1m;1Y(p in 2k){if(2h 2k[p][1]==\'8i\'){y[p]=\'7K(\'+T(k.G[M.G](8x,n,2k[p][0].r,(2k[p][1].r-2k[p][0].r),M.1m))+\',\'+T(k.G[M.G](8x,n,2k[p][0].g,(2k[p][1].g-2k[p][0].g),M.1m))+\',\'+T(k.G[M.G](8x,n,2k[p][0].b,(2k[p][1].b-2k[p][0].b),M.1m))+\')\'}P{D cG=k.G[M.G](8x,n,2k[p][0],(2k[p][1]-2k[p][0]),M.1m);if(p=="1J")k.1p(y,"1J",cG);P y[p]=cG+(p!=\'3B\'&&p!=\'8h\'?\'S\':\'\')}}}};z.2H=6I(u(){z.2D()},13);2i.5R=z},cv:u(2i,2D){if(2D)2i.5R.9x-=kM;P{1V.6c(2i.5R.2H);2i.5R=U;k.2L(2i,"fx")}}});k.cu=u(5S){D 5u={};if(2h 5S==\'5g\'){5S=5S.5Z().7h(\';\');1Y(D i=0;i<5S.1h;i++){7H=5S[i].7h(\':\');if(7H.1h==2){5u[k.eP(7H[0].4v(/\\-(\\w)/g,u(m,c){E c.kn()}))]=k.eP(7H[1])}}}E 5u};k.12={1c:U,F:U,58:u(){E q.1B(u(){if(q.9q){q.A.5e.3p(\'5b\',k.12.cU);q.A=U;q.9q=I;if(k.3h.4I){q.d4="fQ"}P{q.18.kk=\'\';q.18.ej=\'\';q.18.e6=\'\'}}})},cU:u(e){if(k.12.F!=U){k.12.9w(e);E I}D C=q.3Z;k(1j).1H(\'3H\',k.12.d6).1H(\'61\',k.12.9w);C.A.1s=k.1a.44(e);C.A.4t=C.A.1s;C.A.7W=I;C.A.ki=q!=q.3Z;k.12.F=C;if(C.A.5i&&q!=q.3Z){ce=k.1a.2R(C.3e);cf=k.1a.2p(C);cg={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};dx=C.A.4t.x-ce.x-cf.1D/2-cg.x;dy=C.A.4t.y-ce.y-cf.hb/2-cg.y;k.3d.59(C,[dx,dy])}E k.7Z||I},dT:u(e){D C=k.12.F;C.A.7W=1b;D 9p=C.18;C.A.7i=k.B(C,\'19\');C.A.4m=k.B(C,\'Y\');if(!C.A.c4)C.A.c4=C.A.4m;C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.9l=0;C.A.9m=0;if(k.3h.4I){D cl=k.1a.6h(C,1b);C.A.9l=cl.l||0;C.A.9m=cl.t||0}C.A.1C=k.21(k.1a.2R(C),k.1a.2p(C));if(C.A.4m!=\'2y\'&&C.A.4m!=\'1O\'){9p.Y=\'2y\'}k.12.1c.5t();D 5s=C.dn(1b);k(5s).B({19:\'2E\',O:\'3c\',Q:\'3c\'});5s.18.5o=\'0\';5s.18.5p=\'0\';5s.18.5m=\'0\';5s.18.5k=\'0\';k.12.1c.1R(5s);D 3X=k.12.1c.K(0).18;if(C.A.cO){3X.Z=\'ao\';3X.V=\'ao\'}P{3X.V=C.A.1C.hb+\'S\';3X.Z=C.A.1C.1D+\'S\'}3X.19=\'2E\';3X.5o=\'3c\';3X.5p=\'3c\';3X.5m=\'3c\';3X.5k=\'3c\';k.21(C.A.1C,k.1a.2p(5s));if(C.A.2S){if(C.A.2S.O){C.A.2c.x+=C.A.1s.x-C.A.1C.x-C.A.2S.O;C.A.1C.x=C.A.1s.x-C.A.2S.O}if(C.A.2S.Q){C.A.2c.y+=C.A.1s.y-C.A.1C.y-C.A.2S.Q;C.A.1C.y=C.A.1s.y-C.A.2S.Q}if(C.A.2S.2N){C.A.2c.x+=C.A.1s.x-C.A.1C.x-C.A.1C.hb+C.A.2S.2N;C.A.1C.x=C.A.1s.x-C.A.1C.1D+C.A.2S.2N}if(C.A.2S.4l){C.A.2c.y+=C.A.1s.y-C.A.1C.y-C.A.1C.hb+C.A.2S.4l;C.A.1C.y=C.A.1s.y-C.A.1C.hb+C.A.2S.4l}}C.A.2x=C.A.2c.x;C.A.2r=C.A.2c.y;if(C.A.8g||C.A.2o==\'96\'){89=k.1a.6h(C.3e,1b);C.A.1C.x=C.8n+(k.3h.4I?0:k.3h.7N?-89.l:89.l);C.A.1C.y=C.8t+(k.3h.4I?0:k.3h.7N?-89.t:89.t);k(C.3e).1R(k.12.1c.K(0))}if(C.A.2o){k.12.bP(C);C.A.5J.2o=k.12.bH}if(C.A.5i){k.3d.bO(C)}3X.O=C.A.1C.x-C.A.9l+\'S\';3X.Q=C.A.1C.y-C.A.9m+\'S\';3X.Z=C.A.1C.1D+\'S\';3X.V=C.A.1C.hb+\'S\';k.12.F.A.9n=I;if(C.A.gx){C.A.5J.67=k.12.bI}if(C.A.3B!=I){k.12.1c.B(\'3B\',C.A.3B)}if(C.A.1J){k.12.1c.B(\'1J\',C.A.1J);if(1V.7a){k.12.1c.B(\'69\',\'9V(1J=\'+C.A.1J*2b+\')\')}}if(C.A.7w){k.12.1c.2Z(C.A.7w);k.12.1c.K(0).77.18.19=\'1n\'}if(C.A.4A)C.A.4A.1F(C,[5s,C.A.2c.x,C.A.2c.y]);if(k.1x&&k.1x.8W>0){k.1x.ea(C)}if(C.A.4j==I){9p.19=\'1n\'}E I},bP:u(C){if(C.A.2o.1K==b5){if(C.A.2o==\'96\'){C.A.24=k.21({x:0,y:0},k.1a.2p(C.3e));D 84=k.1a.6h(C.3e,1b);C.A.24.w=C.A.24.1D-84.l-84.r;C.A.24.h=C.A.24.hb-84.t-84.b}P if(C.A.2o==\'1j\'){D cM=k.1a.bq();C.A.24={x:0,y:0,w:cM.w,h:cM.h}}}P if(C.A.2o.1K==7b){C.A.24={x:T(C.A.2o[0])||0,y:T(C.A.2o[1])||0,w:T(C.A.2o[2])||0,h:T(C.A.2o[3])||0}}C.A.24.dx=C.A.24.x-C.A.1C.x;C.A.24.dy=C.A.24.y-C.A.1C.y},9o:u(F){if(F.A.8g||F.A.2o==\'96\'){k(\'2e\',1j).1R(k.12.1c.K(0))}k.12.1c.5t().2G().B(\'1J\',1);if(1V.7a){k.12.1c.B(\'69\',\'9V(1J=2b)\')}},9w:u(e){k(1j).3p(\'3H\',k.12.d6).3p(\'61\',k.12.9w);if(k.12.F==U){E}D F=k.12.F;k.12.F=U;if(F.A.7W==I){E I}if(F.A.48==1b){k(F).B(\'Y\',F.A.4m)}D 9p=F.18;if(F.5i){k.12.1c.B(\'94\',\'8C\')}if(F.A.7w){k.12.1c.4p(F.A.7w)}if(F.A.6o==I){if(F.A.fx>0){if(!F.A.1N||F.A.1N==\'4a\'){D x=11 k.fx(F,{1m:F.A.fx},\'O\');x.1L(F.A.2c.x,F.A.8c)}if(!F.A.1N||F.A.1N==\'4i\'){D y=11 k.fx(F,{1m:F.A.fx},\'Q\');y.1L(F.A.2c.y,F.A.8j)}}P{if(!F.A.1N||F.A.1N==\'4a\')F.18.O=F.A.8c+\'S\';if(!F.A.1N||F.A.1N==\'4i\')F.18.Q=F.A.8j+\'S\'}k.12.9o(F);if(F.A.4j==I){k(F).B(\'19\',F.A.7i)}}P if(F.A.fx>0){F.A.9n=1b;D dh=I;if(k.1x&&k.1t&&F.A.48){dh=k.1a.2R(k.1t.1c.K(0))}k.12.1c.5K({O:dh?dh.x:F.A.1C.x,Q:dh?dh.y:F.A.1C.y},F.A.fx,u(){F.A.9n=I;if(F.A.4j==I){F.18.19=F.A.7i}k.12.9o(F)})}P{k.12.9o(F);if(F.A.4j==I){k(F).B(\'19\',F.A.7i)}}if(k.1x&&k.1x.8W>0){k.1x.ed(F)}if(k.1t&&F.A.48){k.1t.dp(F)}if(F.A.2T&&(F.A.8c!=F.A.2c.x||F.A.8j!=F.A.2c.y)){F.A.2T.1F(F,F.A.bQ||[0,0,F.A.8c,F.A.8j])}if(F.A.3S)F.A.3S.1F(F);E I},bI:u(x,y,dx,dy){if(dx!=0)dx=T((dx+(q.A.gx*dx/14.3R(dx))/2)/q.A.gx)*q.A.gx;if(dy!=0)dy=T((dy+(q.A.gy*dy/14.3R(dy))/2)/q.A.gy)*q.A.gy;E{dx:dx,dy:dy,x:0,y:0}},bH:u(x,y,dx,dy){dx=14.3D(14.3v(dx,q.A.24.dx),q.A.24.w+q.A.24.dx-q.A.1C.1D);dy=14.3D(14.3v(dy,q.A.24.dy),q.A.24.h+q.A.24.dy-q.A.1C.hb);E{dx:dx,dy:dy,x:0,y:0}},d6:u(e){if(k.12.F==U||k.12.F.A.9n==1b){E}D F=k.12.F;F.A.4t=k.1a.44(e);if(F.A.7W==I){46=14.dm(14.5Y(F.A.1s.x-F.A.4t.x,2)+14.5Y(F.A.1s.y-F.A.4t.y,2));if(460){k.1x.a3(F)}E I},2s:u(o){if(!k.12.1c){k(\'2e\',1j).1R(\'<26 id="dW">\');k.12.1c=k(\'#dW\');D el=k.12.1c.K(0);D 4P=el.18;4P.Y=\'1O\';4P.19=\'1n\';4P.94=\'8C\';4P.dV=\'1n\';4P.2Y=\'2O\';if(1V.7a){el.d4="en"}P{4P.kh=\'1n\';4P.e6=\'1n\';4P.ej=\'1n\'}}if(!o){o={}}E q.1B(u(){if(q.9q||!k.1a)E;if(1V.7a){q.kf=u(){E I};q.kj=u(){E I}}D el=q;D 5e=o.3y?k(q).kp(o.3y):k(q);if(k.3h.4I){5e.1B(u(){q.d4="en"})}P{5e.B(\'-kE-7l-8Z\',\'1n\');5e.B(\'7l-8Z\',\'1n\');5e.B(\'-ko-7l-8Z\',\'1n\')}q.A={5e:5e,6o:o.6o?1b:I,4j:o.4j?1b:I,48:o.48?o.48:I,5i:o.5i?o.5i:I,8g:o.8g?o.8g:I,3B:o.3B?T(o.3B)||0:I,1J:o.1J?2m(o.1J):I,fx:T(o.fx)||U,6p:o.6p?o.6p:I,5J:{},1s:{},4A:o.4A&&o.4A.1K==2C?o.4A:I,3S:o.3S&&o.3S.1K==2C?o.3S:I,2T:o.2T&&o.2T.1K==2C?o.2T:I,1N:/4i|4a/.43(o.1N)?o.1N:I,6m:o.6m?T(o.6m)||0:0,2S:o.2S?o.2S:I,cO:o.cO?1b:I,7w:o.7w||I};if(o.5J&&o.5J.1K==2C)q.A.5J.7l=o.5J;if(o.4x&&o.4x.1K==2C)q.A.4x=o.4x;if(o.2o&&((o.2o.1K==b5&&(o.2o==\'96\'||o.2o==\'1j\'))||(o.2o.1K==7b&&o.2o.1h==4))){q.A.2o=o.2o}if(o.2K){q.A.2K=o.2K}if(o.67){if(2h o.67==\'kl\'){q.A.gx=T(o.67)||1;q.A.gy=T(o.67)||1}P if(o.67.1h==2){q.A.gx=T(o.67[0])||1;q.A.gy=T(o.67[1])||1}}if(o.3z&&o.3z.1K==2C){q.A.3z=o.3z}q.9q=1b;5e.1B(u(){q.3Z=el});5e.1H(\'5b\',k.12.cU)})}};k.fn.21({a4:k.12.58,6Y:k.12.2s});k.1x={ee:u(5r,5y,7j,7g){E 5r<=k.12.F.A.2x&&(5r+7j)>=(k.12.F.A.2x+k.12.F.A.1C.w)&&5y<=k.12.F.A.2r&&(5y+7g)>=(k.12.F.A.2r+k.12.F.A.1C.h)?1b:I},by:u(5r,5y,7j,7g){E!(5r>(k.12.F.A.2x+k.12.F.A.1C.w)||(5r+7j)(k.12.F.A.2r+k.12.F.A.1C.h)||(5y+7g)k.12.F.A.4t.x&&5yk.12.F.A.4t.y?1b:I},5l:I,3W:{},8W:0,3J:{},ea:u(C){if(k.12.F==U){E}D i;k.1x.3W={};D cZ=I;1Y(i in k.1x.3J){if(k.1x.3J[i]!=U){D 1k=k.1x.3J[i].K(0);if(k(k.12.F).is(\'.\'+1k.1i.a)){if(1k.1i.m==I){1k.1i.p=k.21(k.1a.2R(1k),k.1a.82(1k));1k.1i.m=1b}if(1k.1i.ac){k.1x.3J[i].2Z(1k.1i.ac)}k.1x.3W[i]=k.1x.3J[i];if(k.1t&&1k.1i.s&&k.12.F.A.48){1k.1i.el=k(\'.\'+1k.1i.a,1k);C.18.19=\'1n\';k.1t.c5(1k);1k.1i.9Z=k.1t.8o(k.1p(1k,\'id\')).7U;C.18.19=C.A.7i;cZ=1b}if(1k.1i.9v){1k.1i.9v.1F(k.1x.3J[i].K(0),[k.12.F])}}}}if(cZ){k.1t.28()}},ek:u(){k.1x.3W={};1Y(i in k.1x.3J){if(k.1x.3J[i]!=U){D 1k=k.1x.3J[i].K(0);if(k(k.12.F).is(\'.\'+1k.1i.a)){1k.1i.p=k.21(k.1a.2R(1k),k.1a.82(1k));if(1k.1i.ac){k.1x.3J[i].2Z(1k.1i.ac)}k.1x.3W[i]=k.1x.3J[i];if(k.1t&&1k.1i.s&&k.12.F.A.48){1k.1i.el=k(\'.\'+1k.1i.a,1k);C.18.19=\'1n\';k.1t.c5(1k);C.18.19=C.A.7i}}}}},a3:u(e){if(k.12.F==U){E}k.1x.5l=I;D i;D cb=I;D ec=0;1Y(i in k.1x.3W){D 1k=k.1x.3W[i].K(0);if(k.1x.5l==I&&k.1x[1k.1i.t](1k.1i.p.x,1k.1i.p.y,1k.1i.p.1D,1k.1i.p.hb)){if(1k.1i.hc&&1k.1i.h==I){k.1x.3W[i].2Z(1k.1i.hc)}if(1k.1i.h==I&&1k.1i.7T){cb=1b}1k.1i.h=1b;k.1x.5l=1k;if(k.1t&&1k.1i.s&&k.12.F.A.48){k.1t.1c.K(0).3b=1k.1i.eb;k.1t.a3(1k)}ec++}P if(1k.1i.h==1b){if(1k.1i.7Q){1k.1i.7Q.1F(1k,[e,k.12.1c.K(0).77,1k.1i.fx])}if(1k.1i.hc){k.1x.3W[i].4p(1k.1i.hc)}1k.1i.h=I}}if(k.1t&&!k.1x.5l&&k.12.F.48){k.1t.1c.K(0).18.19=\'1n\'}if(cb){k.1x.5l.1i.7T.1F(k.1x.5l,[e,k.12.1c.K(0).77])}},ed:u(e){D i;1Y(i in k.1x.3W){D 1k=k.1x.3W[i].K(0);if(1k.1i.ac){k.1x.3W[i].4p(1k.1i.ac)}if(1k.1i.hc){k.1x.3W[i].4p(1k.1i.hc)}if(1k.1i.s){k.1t.7V[k.1t.7V.1h]=i}if(1k.1i.9r&&1k.1i.h==1b){1k.1i.h=I;1k.1i.9r.1F(1k,[e,1k.1i.fx])}1k.1i.m=I;1k.1i.h=I}k.1x.3W={}},58:u(){E q.1B(u(){if(q.9u){if(q.1i.s){id=k.1p(q,\'id\');k.1t.5j[id]=U;k(\'.\'+q.1i.a,q).a4()}k.1x.3J[\'d\'+q.bn]=U;q.9u=I;q.f=U}})},2s:u(o){E q.1B(u(){if(q.9u==1b||!o.3P||!k.1a||!k.12){E}q.1i={a:o.3P,ac:o.a8||I,hc:o.a7||I,eb:o.4V||I,9r:o.kO||o.9r||I,7T:o.7T||o.dN||I,7Q:o.7Q||o.dz||I,9v:o.9v||I,t:o.6n&&(o.6n==\'ee\'||o.6n==\'by\')?o.6n:\'1s\',fx:o.fx?o.fx:I,m:I,h:I};if(o.bD==1b&&k.1t){id=k.1p(q,\'id\');k.1t.5j[id]=q.1i.a;q.1i.s=1b;if(o.2T){q.1i.2T=o.2T;q.1i.9Z=k.1t.8o(id).7U}}q.9u=1b;q.bn=T(14.6w()*cd);k.1x.3J[\'d\'+q.bn]=k(q);k.1x.8W++})}};k.fn.21({df:k.1x.58,dO:k.1x.2s});k.kH=k.1x.ek;k.R={1A:U,3Q:U,F:U,1s:U,1q:U,Y:U,7r:u(e){k.R.F=(q.a2)?q.a2:q;k.R.1s=k.1a.44(e);k.R.1q={Z:T(k(k.R.F).B(\'Z\'))||0,V:T(k(k.R.F).B(\'V\'))||0};k.R.Y={Q:T(k(k.R.F).B(\'Q\'))||0,O:T(k(k.R.F).B(\'O\'))||0};k(1j).1H(\'3H\',k.R.bj).1H(\'61\',k.R.bs);if(2h k.R.F.1g.ei===\'u\'){k.R.F.1g.ei.1F(k.R.F)}E I},bs:u(e){k(1j).3p(\'3H\',k.R.bj).3p(\'61\',k.R.bs);if(2h k.R.F.1g.e7===\'u\'){k.R.F.1g.e7.1F(k.R.F)}k.R.F=U},bj:u(e){if(!k.R.F){E}1s=k.1a.44(e);7u=k.R.Y.Q-k.R.1s.y+1s.y;7v=k.R.Y.O-k.R.1s.x+1s.x;7u=14.3v(14.3D(7u,k.R.F.1g.8U-k.R.1q.V),k.R.F.1g.7s);7v=14.3v(14.3D(7v,k.R.F.1g.8T-k.R.1q.Z),k.R.F.1g.7p);if(2h k.R.F.1g.4x===\'u\'){D 8J=k.R.F.1g.4x.1F(k.R.F,[7v,7u]);if(2h 8J==\'kc\'&&8J.1h==2){7v=8J[0];7u=8J[1]}}k.R.F.18.Q=7u+\'S\';k.R.F.18.O=7v+\'S\';E I},28:u(e){k(1j).1H(\'3H\',k.R.8C).1H(\'61\',k.R.8v);k.R.1A=q.1A;k.R.3Q=q.3Q;k.R.1s=k.1a.44(e);if(k.R.1A.1g.4A){k.R.1A.1g.4A.1F(k.R.1A,[q])}k.R.1q={Z:T(k(q.1A).B(\'Z\'))||0,V:T(k(q.1A).B(\'V\'))||0};k.R.Y={Q:T(k(q.1A).B(\'Q\'))||0,O:T(k(q.1A).B(\'O\'))||0};E I},8v:u(){k(1j).3p(\'3H\',k.R.8C).3p(\'61\',k.R.8v);if(k.R.1A.1g.3S){k.R.1A.1g.3S.1F(k.R.1A,[k.R.3Q])}k.R.1A=U;k.R.3Q=U},6V:u(dx,9t){E 14.3D(14.3v(k.R.1q.Z+dx*9t,k.R.1A.1g.9s),k.R.1A.1g.6q)},6Q:u(dy,9t){E 14.3D(14.3v(k.R.1q.V+dy*9t,k.R.1A.1g.8L),k.R.1A.1g.8M)},dX:u(V){E 14.3D(14.3v(V,k.R.1A.1g.8L),k.R.1A.1g.8M)},8C:u(e){if(k.R.1A==U){E}1s=k.1a.44(e);dx=1s.x-k.R.1s.x;dy=1s.y-k.R.1s.y;1E={Z:k.R.1q.Z,V:k.R.1q.V};2n={Q:k.R.Y.Q,O:k.R.Y.O};3m(k.R.3Q){1e\'e\':1E.Z=k.R.6V(dx,1);1r;1e\'eO\':1E.Z=k.R.6V(dx,1);1E.V=k.R.6Q(dy,1);1r;1e\'w\':1E.Z=k.R.6V(dx,-1);2n.O=k.R.Y.O-1E.Z+k.R.1q.Z;1r;1e\'5O\':1E.Z=k.R.6V(dx,-1);2n.O=k.R.Y.O-1E.Z+k.R.1q.Z;1E.V=k.R.6Q(dy,1);1r;1e\'7q\':1E.V=k.R.6Q(dy,-1);2n.Q=k.R.Y.Q-1E.V+k.R.1q.V;1E.Z=k.R.6V(dx,-1);2n.O=k.R.Y.O-1E.Z+k.R.1q.Z;1r;1e\'n\':1E.V=k.R.6Q(dy,-1);2n.Q=k.R.Y.Q-1E.V+k.R.1q.V;1r;1e\'9J\':1E.V=k.R.6Q(dy,-1);2n.Q=k.R.Y.Q-1E.V+k.R.1q.V;1E.Z=k.R.6V(dx,1);1r;1e\'s\':1E.V=k.R.6Q(dy,1);1r}if(k.R.1A.1g.4D){if(k.R.3Q==\'n\'||k.R.3Q==\'s\')4B=1E.V*k.R.1A.1g.4D;P 4B=1E.Z;5c=k.R.dX(4B*k.R.1A.1g.4D);4B=5c/k.R.1A.1g.4D;3m(k.R.3Q){1e\'n\':1e\'7q\':1e\'9J\':2n.Q+=1E.V-5c;1r}3m(k.R.3Q){1e\'7q\':1e\'w\':1e\'5O\':2n.O+=1E.Z-4B;1r}1E.V=5c;1E.Z=4B}if(2n.Qk.R.1A.1g.8U){1E.V=k.R.1A.1g.8U-2n.Q;if(k.R.1A.1g.4D){1E.Z=1E.V/k.R.1A.1g.4D}}if(2n.O+1E.Z>k.R.1A.1g.8T){1E.Z=k.R.1A.1g.8T-2n.O;if(k.R.1A.1g.4D){1E.V=1E.Z*k.R.1A.1g.4D}}D 6O=I;5L=k.R.1A.18;5L.O=2n.O+\'S\';5L.Q=2n.Q+\'S\';5L.Z=1E.Z+\'S\';5L.V=1E.V+\'S\';if(k.R.1A.1g.dY){6O=k.R.1A.1g.dY.1F(k.R.1A,[1E,2n]);if(6O){if(6O.1q){k.21(1E,6O.1q)}if(6O.Y){k.21(2n,6O.Y)}}}5L.O=2n.O+\'S\';5L.Q=2n.Q+\'S\';5L.Z=1E.Z+\'S\';5L.V=1E.V+\'S\';E I},2s:u(M){if(!M||!M.3U||M.3U.1K!=7n){E}E q.1B(u(){D el=q;el.1g=M;el.1g.9s=M.9s||10;el.1g.8L=M.8L||10;el.1g.6q=M.6q||6x;el.1g.8M=M.8M||6x;el.1g.7s=M.7s||-aF;el.1g.7p=M.7p||-aF;el.1g.8T=M.8T||6x;el.1g.8U=M.8U||6x;b3=k(el).B(\'Y\');if(!(b3==\'2y\'||b3==\'1O\')){el.18.Y=\'2y\'}eM=/n|9J|e|eO|s|5O|w|7q/g;1Y(i in el.1g.3U){if(i.5Z().bU(eM)!=U){if(el.1g.3U[i].1K==b5){3y=k(el.1g.3U[i]);if(3y.1P()>0){el.1g.3U[i]=3y.K(0)}}if(el.1g.3U[i].4S){el.1g.3U[i].1A=el;el.1g.3U[i].3Q=i;k(el.1g.3U[i]).1H(\'5b\',k.R.28)}}}if(el.1g.4N){if(2h el.1g.4N===\'5g\'){9K=k(el.1g.4N);if(9K.1P()>0){9K.1B(u(){q.a2=el});9K.1H(\'5b\',k.R.7r)}}P if(el.1g.4N.4S){el.1g.4N.a2=el;k(el.1g.4N).1H(\'5b\',k.R.7r)}P if(el.1g.4N==1b){k(q).1H(\'5b\',k.R.7r)}}})},58:u(){E q.1B(u(){D el=q;1Y(i in el.1g.3U){el.1g.3U[i].1A=U;el.1g.3U[i].3Q=U;k(el.1g.3U[i]).3p(\'5b\',k.R.28)}if(el.1g.4N){if(2h el.1g.4N===\'5g\'){3y=k(el.1g.4N);if(3y.1P()>0){3y.3p(\'5b\',k.R.7r)}}P if(el.1g.4N==1b){k(q).3p(\'5b\',k.R.7r)}}el.1g=U})}};k.fn.21({j5:k.R.2s,j4:k.R.58});k.2u=U;k.7Z=I;k.3n=U;k.81=[];k.a0=u(e){D 3O=e.7F||e.7A||-1;if(3O==17||3O==16){k.7Z=1b}};k.9Y=u(e){k.7Z=I};k.eW=u(e){q.f.1s=k.1a.44(e);q.f.1M=k.21(k.1a.2R(q),k.1a.2p(q));q.f.3a=k.1a.6W(q);q.f.1s.x-=q.f.1M.x;q.f.1s.y-=q.f.1M.y;if(q.f.hc)k.2u.2Z(q.f.hc);k.2u.B({19:\'2E\',Z:\'83\',V:\'83\'});if(q.f.o){k.2u.B(\'1J\',q.f.o)}k.3n=q;k.8K=I;k.81=[];q.f.el.1B(u(){q.1M={x:q.8n+(q.4Y&&!k.3h.7N?T(q.4Y.5a)||0:0)+(k.3n.3g||0),y:q.8t+(q.4Y&&!k.3h.7N?T(q.4Y.4Z)||0:0)+(k.3n.2V||0),1D:q.4b,hb:q.63};if(q.s==1b){if(k.7Z==I){q.s=I;k(q).4p(k.3n.f.7X)}P{k.8K=1b;k.81[k.81.1h]=k.1p(q,\'id\')}}});k(q).1R(k.2u.K(0));q.f.93=k.1a.6h(k.2u[0],1b);k.a1.1F(q,[e]);k(1j).1H(\'3H\',k.a1).1H(\'61\',k.bT);E I};k.a1=u(e){if(!k.3n)E;k.eU.1F(k.3n,[e])};k.eU=u(e){if(!k.3n)E;D 1s=k.1a.44(e);D 3a=k.1a.6W(k.3n);1s.x+=3a.l-q.f.3a.l-q.f.1M.x;1s.y+=3a.t-q.f.3a.t-q.f.1M.y;D 8D=14.3D(1s.x,q.f.1s.x);D 5O=14.3D(14.3R(1s.x-q.f.1s.x),14.3R(q.f.3a.w-8D));D 9f=14.3D(1s.y,q.f.1s.y);D 8R=14.3D(14.3R(1s.y-q.f.1s.y),14.3R(q.f.3a.h-9f));if(q.2V>0&&1s.y-20q.2V+q.f.1M.h){D 3T=14.3D(q.f.3a.h-q.2V,10);q.2V+=3T;if(q.2V!=3a.t)8R+=3T}if(q.3g>0&&1s.x-20q.3g+q.f.1M.w){D 3T=14.3D(q.f.3a.w-q.3g,10);q.3g+=3T;if(q.3g!=3a.l)5O+=3T}k.2u.B({O:8D+\'S\',Q:9f+\'S\',Z:5O-(q.f.93.l+q.f.93.r)+\'S\',V:8R-(q.f.93.t+q.f.93.b)+\'S\'});k.2u.l=8D+q.f.3a.l;k.2u.t=9f+q.f.3a.t;k.2u.r=k.2u.l+5O;k.2u.b=k.2u.t+8R;k.8K=I;q.f.el.1B(u(){9k=k.81.3F(k.1p(q,\'id\'));if(!(q.1M.x>k.2u.r||(q.1M.x+q.1M.1D)k.2u.b||(q.1M.y+q.1M.hb)0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[o.1h]=k.1p(q,\'id\')}})}E{7U:h,o:o}};k.fn.jZ=u(o){if(!k.2u){k(\'2e\',1j).1R(\'<26 id="2u">\').1H(\'7E\',k.a0).1H(\'6S\',k.9Y);k.2u=k(\'#2u\');k.2u.B({Y:\'1O\',19:\'1n\'});if(1V.2l){k(\'2e\',1j).1H(\'7E\',k.a0).1H(\'6S\',k.9Y)}P{k(1j).1H(\'7E\',k.a0).1H(\'6S\',k.9Y)}}if(!o){o={}}E q.1B(u(){if(q.eX)E;q.eX=1b;q.f={a:o.3P,o:o.1J?2m(o.1J):I,7X:o.eE?o.eE:I,hc:o.4V?o.4V:I,8Y:o.8Y?o.8Y:I,8X:o.8X?o.8X:I};q.f.el=k(\'.\'+o.3P);k(q).1H(\'5b\',k.eW)})};k.1t={7V:[],5j:{},1c:I,7Y:U,28:u(){if(k.12.F==U){E}D 4M,3A,c,cs;k.1t.1c.K(0).3b=k.12.F.A.6p;4M=k.1t.1c.K(0).18;4M.19=\'2E\';k.1t.1c.1C=k.21(k.1a.2R(k.1t.1c.K(0)),k.1a.2p(k.1t.1c.K(0)));4M.Z=k.12.F.A.1C.1D+\'S\';4M.V=k.12.F.A.1C.hb+\'S\';3A=k.1a.c8(k.12.F);4M.5o=3A.t;4M.5p=3A.r;4M.5m=3A.b;4M.5k=3A.l;if(k.12.F.A.4j==1b){c=k.12.F.dn(1b);cs=c.18;cs.5o=\'3c\';cs.5p=\'3c\';cs.5m=\'3c\';cs.5k=\'3c\';cs.19=\'2E\';k.1t.1c.5t().1R(c)}k(k.12.F).dj(k.1t.1c.K(0));k.12.F.18.19=\'1n\'},dp:u(e){if(!e.A.48&&k.1x.5l.bD){if(e.A.3S)e.A.3S.1F(F);k(e).B(\'Y\',e.A.c4||e.A.4m);k(e).a4();k(k.1x.5l).dd(e)}k.1t.1c.4p(e.A.6p).3w(\'&7J;\');k.1t.7Y=U;D 4M=k.1t.1c.K(0).18;4M.19=\'1n\';k.1t.1c.dj(e);if(e.A.fx>0){k(e).7m(e.A.fx)}k(\'2e\').1R(k.1t.1c.K(0));D 86=[];D 8d=I;1Y(D i=0;i0){8d(86)}},a3:u(e,o){if(!k.12.F)E;D 6i=I;D i=0;if(e.1i.el.1P()>0){1Y(i=e.1i.el.1P();i>0;i--){if(e.1i.el.K(i-1)!=k.12.F){if(!e.5V.bM){if((e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.12.F.A.2r){6i=e.1i.el.K(i-1)}P{1r}}P{if((e.1i.el.K(i-1).1M.x+e.1i.el.K(i-1).1M.1D/2)>k.12.F.A.2x&&(e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.12.F.A.2r){6i=e.1i.el.K(i-1)}}}}}if(6i&&k.1t.7Y!=6i){k.1t.7Y=6i;k(6i).k6(k.1t.1c.K(0))}P if(!6i&&(k.1t.7Y!=U||k.1t.1c.K(0).3e!=e)){k.1t.7Y=U;k(e).1R(k.1t.1c.K(0))}k.1t.1c.K(0).18.19=\'2E\'},c5:u(e){if(k.12.F==U){E}e.1i.el.1B(u(){q.1M=k.21(k.1a.82(q),k.1a.2R(q))})},8o:u(s){D i;D h=\'\';D o={};if(s){if(k.1t.5j[s]){o[s]=[];k(\'#\'+s+\' .\'+k.1t.5j[s]).1B(u(){if(h.1h>0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[s][o[s].1h]=k.1p(q,\'id\')})}P{1Y(a in s){if(k.1t.5j[s[a]]){o[s[a]]=[];k(\'#\'+s[a]+\' .\'+k.1t.5j[s[a]]).1B(u(){if(h.1h>0){h+=\'&\'}h+=s[a]+\'[]=\'+k.1p(q,\'id\');o[s[a]][o[s[a]].1h]=k.1p(q,\'id\')})}}}}P{1Y(i in k.1t.5j){o[i]=[];k(\'#\'+i+\' .\'+k.1t.5j[i]).1B(u(){if(h.1h>0){h+=\'&\'}h+=i+\'[]=\'+k.1p(q,\'id\');o[i][o[i].1h]=k.1p(q,\'id\')})}}E{7U:h,o:o}},dc:u(e){if(!e.jJ){E}E q.1B(u(){if(!q.5V||!k(e).is(\'.\'+q.5V.3P))k(e).2Z(q.5V.3P);k(e).6Y(q.5V.A)})},58:u(){E q.1B(u(){k(\'.\'+q.5V.3P).a4();k(q).df();q.5V=U;q.dD=U})},2s:u(o){if(o.3P&&k.1a&&k.12&&k.1x){if(!k.1t.1c){k(\'2e\',1j).1R(\'<26 id="dt">&7J;\');k.1t.1c=k(\'#dt\');k.1t.1c.K(0).18.19=\'1n\'}q.dO({3P:o.3P,a8:o.a8?o.a8:I,a7:o.a7?o.a7:I,4V:o.4V?o.4V:I,7T:o.7T||o.dN,7Q:o.7Q||o.dz,bD:1b,2T:o.2T||o.jL,fx:o.fx?o.fx:I,4j:o.4j?1b:I,6n:o.6n?o.6n:\'by\'});E q.1B(u(){D A={6o:o.6o?1b:I,dF:6x,1J:o.1J?2m(o.1J):I,6p:o.4V?o.4V:I,fx:o.fx?o.fx:I,48:1b,4j:o.4j?1b:I,3y:o.3y?o.3y:U,2o:o.2o?o.2o:U,4A:o.4A&&o.4A.1K==2C?o.4A:I,4x:o.4x&&o.4x.1K==2C?o.4x:I,3S:o.3S&&o.3S.1K==2C?o.3S:I,1N:/4i|4a/.43(o.1N)?o.1N:I,6m:o.6m?T(o.6m)||0:I,2S:o.2S?o.2S:I};k(\'.\'+o.3P,q).6Y(A);q.dD=1b;q.5V={3P:o.3P,6o:o.6o?1b:I,dF:6x,1J:o.1J?2m(o.1J):I,6p:o.4V?o.4V:I,fx:o.fx?o.fx:I,48:1b,4j:o.4j?1b:I,3y:o.3y?o.3y:U,2o:o.2o?o.2o:U,bM:o.bM?1b:I,A:A}})}}};k.fn.21({jR:k.1t.2s,dd:k.1t.dc,jQ:k.1t.58});k.jN=k.1t.8o;k.3d={bG:1,f0:u(3u){D 3u=3u;E q.1B(u(){q.4r.6T.1B(u(a6){k.3d.59(q,3u[a6])})})},K:u(){D 3u=[];q.1B(u(bJ){if(q.bF){3u[bJ]=[];D C=q;D 1q=k.1a.2p(q);q.4r.6T.1B(u(a6){D x=q.8n;D y=q.8t;99=T(x*2b/(1q.w-q.4b));8a=T(y*2b/(1q.h-q.63));3u[bJ][a6]=[99||0,8a||0,x||0,y||0]})}});E 3u},bO:u(C){C.A.fK=C.A.24.w-C.A.1C.1D;C.A.fN=C.A.24.h-C.A.1C.hb;if(C.9P.4r.bE){a5=C.9P.4r.6T.K(C.bR+1);if(a5){C.A.24.w=(T(k(a5).B(\'O\'))||0)+C.A.1C.1D;C.A.24.h=(T(k(a5).B(\'Q\'))||0)+C.A.1C.hb}9X=C.9P.4r.6T.K(C.bR-1);if(9X){D bL=T(k(9X).B(\'O\'))||0;D bK=T(k(9X).B(\'O\'))||0;C.A.24.x+=bL;C.A.24.y+=bK;C.A.24.w-=bL;C.A.24.h-=bK}}C.A.fW=C.A.24.w-C.A.1C.1D;C.A.fV=C.A.24.h-C.A.1C.hb;if(C.A.2K){C.A.gx=((C.A.24.w-C.A.1C.1D)/C.A.2K)||1;C.A.gy=((C.A.24.h-C.A.1C.hb)/C.A.2K)||1;C.A.fY=C.A.fW/C.A.2K;C.A.fS=C.A.fV/C.A.2K}C.A.24.dx=C.A.24.x-C.A.2c.x;C.A.24.dy=C.A.24.y-C.A.2c.y;k.12.1c.B(\'94\',\'aG\')},3z:u(C,x,y){if(C.A.2K){fZ=T(x/C.A.fY);99=fZ*2b/C.A.2K;fL=T(y/C.A.fS);8a=fL*2b/C.A.2K}P{99=T(x*2b/C.A.fK);8a=T(y*2b/C.A.fN)}C.A.bQ=[99||0,8a||0,x||0,y||0];if(C.A.3z)C.A.3z.1F(C,C.A.bQ)},g4:u(2l){3O=2l.7F||2l.7A||-1;3m(3O){1e 35:k.3d.59(q.3Z,[9W,9W]);1r;1e 36:k.3d.59(q.3Z,[-9W,-9W]);1r;1e 37:k.3d.59(q.3Z,[-q.3Z.A.gx||-1,0]);1r;1e 38:k.3d.59(q.3Z,[0,-q.3Z.A.gy||-1]);1r;1e 39:k.3d.59(q.3Z,[q.3Z.A.gx||1,0]);1r;1e 40:k.12.59(q.3Z,[0,q.3Z.A.gy||1]);1r}},59:u(C,Y){if(!C.A){E}C.A.1C=k.21(k.1a.2R(C),k.1a.2p(C));C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.4m=k.B(C,\'Y\');if(C.A.4m!=\'2y\'&&C.A.4m!=\'1O\'){C.18.Y=\'2y\'}k.12.bP(C);k.3d.bO(C);dx=T(Y[0])||0;dy=T(Y[1])||0;2x=C.A.2c.x+dx;2r=C.A.2c.y+dy;if(C.A.2K){3q=k.12.bI.1F(C,[2x,2r,dx,dy]);if(3q.1K==7n){dx=3q.dx;dy=3q.dy}2x=C.A.2c.x+dx;2r=C.A.2c.y+dy}3q=k.12.bH.1F(C,[2x,2r,dx,dy]);if(3q&&3q.1K==7n){dx=3q.dx;dy=3q.dy}2x=C.A.2c.x+dx;2r=C.A.2c.y+dy;if(C.A.5i&&(C.A.3z||C.A.2T)){k.3d.3z(C,2x,2r)}2x=!C.A.1N||C.A.1N==\'4a\'?2x:C.A.2c.x||0;2r=!C.A.1N||C.A.1N==\'4i\'?2r:C.A.2c.y||0;C.18.O=2x+\'S\';C.18.Q=2r+\'S\'},2s:u(o){E q.1B(u(){if(q.bF==1b||!o.3P||!k.1a||!k.12||!k.1x){E}5N=k(o.3P,q);if(5N.1P()==0){E}D 4K={2o:\'96\',5i:1b,3z:o.3z&&o.3z.1K==2C?o.3z:U,2T:o.2T&&o.2T.1K==2C?o.2T:U,3y:q,1J:o.1J||I};if(o.2K&&T(o.2K)){4K.2K=T(o.2K)||1;4K.2K=4K.2K>0?4K.2K:1}if(5N.1P()==1)5N.6Y(4K);P{k(5N.K(0)).6Y(4K);4K.3y=U;5N.6Y(4K)}5N.7E(k.3d.g4);5N.1p(\'bG\',k.3d.bG++);q.bF=1b;q.4r={};q.4r.g6=4K.g6;q.4r.2K=4K.2K;q.4r.6T=5N;q.4r.bE=o.bE?1b:I;bS=q;bS.4r.6T.1B(u(2I){q.bR=2I;q.9P=bS});if(o.3u&&o.3u.1K==7b){1Y(i=o.3u.1h-1;i>=0;i--){if(o.3u[i].1K==7b&&o.3u[i].1h==2){el=q.4r.6T.K(i);if(el.4S){k.3d.59(el,o.3u[i])}}}}})}};k.fn.21({jV:k.3d.2s,k9:k.3d.f0,kb:k.3d.K});k.2t={6J:U,7c:I,9O:U,6D:u(e){k.2t.7c=1b;k.2t.22(e,q,1b)},bx:u(e){if(k.2t.6J!=q)E;k.2t.7c=I;k.2t.2G(e,q)},22:u(e,el,7c){if(k.2t.6J!=U)E;if(!el){el=q}k.2t.6J=el;1M=k.21(k.1a.2R(el),k.1a.2p(el));8G=k(el);45=8G.1p(\'45\');3f=8G.1p(\'3f\');if(45){k.2t.9O=45;8G.1p(\'45\',\'\');k(\'#fF\').3w(45);if(3f)k(\'#c9\').3w(3f.4v(\'k4://\',\'\'));P k(\'#c9\').3w(\'\');1c=k(\'#8V\');if(el.4T.3b){1c.K(0).3b=el.4T.3b}P{1c.K(0).3b=\'\'}c7=k.1a.2p(1c.K(0));fj=7c&&el.4T.Y==\'c3\'?\'4l\':el.4T.Y;3m(fj){1e\'Q\':2r=1M.y-c7.hb;2x=1M.x;1r;1e\'O\':2r=1M.y;2x=1M.x-c7.1D;1r;1e\'2N\':2r=1M.y;2x=1M.x+1M.1D;1r;1e\'c3\':k(\'2e\').1H(\'3H\',k.2t.3H);1s=k.1a.44(e);2r=1s.y+15;2x=1s.x+15;1r;aG:2r=1M.y+1M.hb;2x=1M.x;1r}1c.B({Q:2r+\'S\',O:2x+\'S\'});if(el.4T.53==I){1c.22()}P{1c.7m(el.4T.53)}if(el.4T.2U)el.4T.2U.1F(el);8G.1H(\'8q\',k.2t.2G).1H(\'5I\',k.2t.bx)}},3H:u(e){if(k.2t.6J==U){k(\'2e\').3p(\'3H\',k.2t.3H);E}1s=k.1a.44(e);k(\'#8V\').B({Q:1s.y+15+\'S\',O:1s.x+15+\'S\'})},2G:u(e,el){if(!el){el=q}if(k.2t.7c!=1b&&k.2t.6J==el){k.2t.6J=U;k(\'#8V\').7k(1);k(el).1p(\'45\',k.2t.9O).3p(\'8q\',k.2t.2G).3p(\'5I\',k.2t.bx);if(el.4T.3i)el.4T.3i.1F(el);k.2t.9O=U}},2s:u(M){if(!k.2t.1c){k(\'2e\').1R(\'<26 id="8V"><26 id="fF"><26 id="c9">\');k(\'#8V\').B({Y:\'1O\',3B:6x,19:\'1n\'});k.2t.1c=1b}E q.1B(u(){if(k.1p(q,\'45\')){q.4T={Y:/Q|4l|O|2N|c3/.43(M.Y)?M.Y:\'4l\',3b:M.3b?M.3b:I,53:M.53?M.53:I,2U:M.2U&&M.2U.1K==2C?M.2U:I,3i:M.3i&&M.3i.1K==2C?M.3i:I};D el=k(q);el.1H(\'aV\',k.2t.22);el.1H(\'6D\',k.2t.6D)}})}};k.fn.k0=k.2t.2s;k.21({G:{bV:u(p,n,1W,1I,1m){E((-14.5v(p*14.2Q)/2)+0.5)*1I+1W},k2:u(p,n,1W,1I,1m){E 1I*(n/=1m)*n*n+1W},fG:u(p,n,1W,1I,1m){E-1I*((n=n/1m-1)*n*n*n-1)+1W},k1:u(p,n,1W,1I,1m){if((n/=1m/2)<1)E 1I/2*n*n*n*n+1W;E-1I/2*((n-=2)*n*n*n-2)+1W},9c:u(p,n,1W,1I,1m){if((n/=1m)<(1/2.75)){E 1I*(7.9N*n*n)+1W}P if(n<(2/2.75)){E 1I*(7.9N*(n-=(1.5/2.75))*n+.75)+1W}P if(n<(2.5/2.75)){E 1I*(7.9N*(n-=(2.25/2.75))*n+.jC)+1W}P{E 1I*(7.9N*(n-=(2.jB/2.75))*n+.jd)+1W}},bY:u(p,n,1W,1I,1m){if(k.G.9c)E 1I-k.G.9c(p,1m-n,0,1I,1m)+1W;E 1W+1I},jc:u(p,n,1W,1I,1m){if(k.G.bY&&k.G.9c)if(n<1m/2)E k.G.bY(p,n*2,0,1I,1m)*.5+1W;E k.G.9c(p,n*2-1m,0,1I,1m)*.5+1I*.5+1W;E 1W+1I},jb:u(p,n,1W,1I,1m){D a,s;if(n==0)E 1W;if((n/=1m)==1)E 1W+1I;a=1I*0.3;p=1m*.3;if(a<14.3R(1I)){a=1I;s=p/4}P{s=p/(2*14.2Q)*14.c0(1I/a)}E-(a*14.5Y(2,10*(n-=1))*14.98((n*1m-s)*(2*14.2Q)/p))+1W},je:u(p,n,1W,1I,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1I;a=1I*0.3;p=1m*.3;if(a<14.3R(1I)){a=1I;s=p/4}P{s=p/(2*14.2Q)*14.c0(1I/a)}E a*14.5Y(2,-10*n)*14.98((n*1m-s)*(2*14.2Q)/p)+1I+1W},jf:u(p,n,1W,1I,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1I;a=1I*0.3;p=1m*.3;if(a<14.3R(1I)){a=1I;s=p/4}P{s=p/(2*14.2Q)*14.c0(1I/a)}if(n<1){E-.5*(a*14.5Y(2,10*(n-=1))*14.98((n*1m-s)*(2*14.2Q)/p))+1W}E a*14.5Y(2,-10*(n-=1))*14.98((n*1m-s)*(2*14.2Q)/p)*.5+1I+1W}}});k.fn.21({fz:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5W(q,H,J,\'4U\',G)})},fP:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5W(q,H,J,\'4y\',G)})},j9:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5W(q,H,J,\'f8\',G)})},j3:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5W(q,H,J,\'O\',G)})},j2:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5W(q,H,J,\'2N\',G)})},j1:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5W(q,H,J,\'fh\',G)})}});k.fx.5W=u(e,H,J,2P,G){if(!k.4O(e)){k.2L(e,\'1o\');E I}D z=q;z.el=k(e);z.1P=k.1a.2p(e);z.G=2h J==\'5g\'?J:G||U;if(!e.4s)e.4s=z.el.B(\'19\');if(2P==\'f8\'){2P=z.el.B(\'19\')==\'1n\'?\'4y\':\'4U\'}P if(2P==\'fh\'){2P=z.el.B(\'19\')==\'1n\'?\'2N\':\'O\'}z.el.22();z.H=H;z.J=2h J==\'u\'?J:U;z.fx=k.fx.9h(e);z.2P=2P;z.23=u(){if(z.J&&z.J.1K==2C){z.J.1F(z.el.K(0))}if(z.2P==\'4y\'||z.2P==\'2N\'){z.el.B(\'19\',z.el.K(0).4s==\'1n\'?\'2E\':z.el.K(0).4s)}P{z.el.2G()}k.fx.9g(z.fx.3o.K(0),z.fx.W);k.2L(z.el.K(0),\'1o\')};3m(z.2P){1e\'4U\':6d=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,z.23),\'V\');6d.1L(z.fx.W.1q.hb,0);1r;1e\'4y\':z.fx.3o.B(\'V\',\'83\');z.el.22();6d=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,z.23),\'V\');6d.1L(0,z.fx.W.1q.hb);1r;1e\'O\':6d=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,z.23),\'Z\');6d.1L(z.fx.W.1q.1D,0);1r;1e\'2N\':z.fx.3o.B(\'Z\',\'83\');z.el.22();6d=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,z.23),\'Z\');6d.1L(0,z.fx.W.1q.1D);1r}};k.fn.kd=u(5w,J){E q.1w(\'1o\',u(){if(!k.4O(q)){k.2L(q,\'1o\');E I}D e=11 k.fx.fa(q,5w,J);e.bc()})};k.fx.fa=u(e,5w,J){D z=q;z.el=k(e);z.el.22();z.J=J;z.5w=T(5w)||40;z.W={};z.W.Y=z.el.B(\'Y\');z.W.Q=T(z.el.B(\'Q\'))||0;z.W.O=T(z.el.B(\'O\'))||0;if(z.W.Y!=\'2y\'&&z.W.Y!=\'1O\'){z.el.B(\'Y\',\'2y\')}z.41=5;z.5D=1;z.bc=u(){z.5D++;z.e=11 k.fx(z.el.K(0),{1m:j6,23:u(){z.e=11 k.fx(z.el.K(0),{1m:80,23:u(){z.5w=T(z.5w/2);if(z.5D<=z.41)z.bc();P{z.el.B(\'Y\',z.W.Y).B(\'Q\',z.W.Q+\'S\').B(\'O\',z.W.O+\'S\');k.2L(z.el.K(0),\'1o\');if(z.J&&z.J.1K==2C){z.J.1F(z.el.K(0))}}}},\'Q\');z.e.1L(z.W.Q-z.5w,z.W.Q)}},\'Q\');z.e.1L(z.W.Q,z.W.Q-z.5w)}};k.fn.21({ji:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'4y\',\'4d\',G)})},jj:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'4y\',\'in\',G)})},jw:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'4y\',\'3Y\',G)})},jv:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'4U\',\'4d\',G)})},ju:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'4U\',\'in\',G)})},jx:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'4U\',\'3Y\',G)})},jy:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'O\',\'4d\',G)})},jz:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'O\',\'in\',G)})},jt:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'O\',\'3Y\',G)})},js:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'2N\',\'4d\',G)})},jm:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'2N\',\'in\',G)})},jl:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.4k(q,H,J,\'2N\',\'3Y\',G)})}});k.fx.4k=u(e,H,J,2P,1u,G){if(!k.4O(e)){k.2L(e,\'1o\');E I}D z=q;z.el=k(e);z.G=2h J==\'5g\'?J:G||U;z.W={};z.W.Y=z.el.B(\'Y\');z.W.Q=z.el.B(\'Q\');z.W.O=z.el.B(\'O\');if(!e.4s)e.4s=z.el.B(\'19\');if(1u==\'3Y\'){1u=z.el.B(\'19\')==\'1n\'?\'in\':\'4d\'}z.el.22();if(z.W.Y!=\'2y\'&&z.W.Y!=\'1O\'){z.el.B(\'Y\',\'2y\')}z.1u=1u;J=2h J==\'u\'?J:U;8y=1;3m(2P){1e\'4U\':z.e=11 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.68=2m(z.W.Q)||0;z.9L=z.fM;8y=-1;1r;1e\'4y\':z.e=11 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.68=2m(z.W.Q)||0;z.9L=z.fM;1r;1e\'2N\':z.e=11 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.68=2m(z.W.O)||0;z.9L=z.f4;1r;1e\'O\':z.e=11 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.68=2m(z.W.O)||0;z.9L=z.f4;8y=-1;1r}z.e2=11 k.fx(z.el.K(0),k.H(H,z.G,u(){z.el.B(z.W);if(z.1u==\'4d\'){z.el.B(\'19\',\'1n\')}P z.el.B(\'19\',z.el.K(0).4s==\'1n\'?\'2E\':z.el.K(0).4s);k.2L(z.el.K(0),\'1o\')}),\'1J\');if(1u==\'in\'){z.e.1L(z.68+2b*8y,z.68);z.e2.1L(0,1)}P{z.e.1L(z.68,z.68+2b*8y);z.e2.1L(1,0)}};k.fn.21({jn:u(H,V,J,G){E q.1w(\'1o\',u(){11 k.fx.9M(q,H,V,J,\'g7\',G)})},jo:u(H,V,J,G){E q.1w(\'1o\',u(){11 k.fx.9M(q,H,V,J,\'9Q\',G)})},jr:u(H,V,J,G){E q.1w(\'1o\',u(){11 k.fx.9M(q,H,V,J,\'3Y\',G)})}});k.fx.9M=u(e,H,V,J,1u,G){if(!k.4O(e)){k.2L(e,\'1o\');E I}D z=q;z.el=k(e);z.G=2h J==\'5g\'?J:G||U;z.J=2h J==\'u\'?J:U;if(1u==\'3Y\'){1u=z.el.B(\'19\')==\'1n\'?\'9Q\':\'g7\'}z.H=H;z.V=V&&V.1K==cR?V:20;z.fx=k.fx.9h(e);z.1u=1u;z.23=u(){if(z.J&&z.J.1K==2C){z.J.1F(z.el.K(0))}if(z.1u==\'9Q\'){z.el.22()}P{z.el.2G()}k.fx.9g(z.fx.3o.K(0),z.fx.W);k.2L(z.el.K(0),\'1o\')};if(z.1u==\'9Q\'){z.el.22();z.fx.3o.B(\'V\',z.V+\'S\').B(\'Z\',\'83\');z.ef=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,u(){z.ef=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,z.23),\'V\');z.ef.1L(z.V,z.fx.W.1q.hb)}),\'Z\');z.ef.1L(0,z.fx.W.1q.1D)}P{z.ef=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,u(){z.ef=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G,z.23),\'Z\');z.ef.1L(z.fx.W.1q.1D,0)}),\'V\');z.ef.1L(z.fx.W.1q.hb,z.V)}};k.fn.21({jq:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.6z(q,H,1,2b,1b,J,\'f1\',G)})},jp:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.6z(q,H,2b,1,1b,J,\'d2\',G)})},kt:u(H,J,G){E q.1w(\'1o\',u(){D G=G||\'fG\';11 k.fx.6z(q,H,2b,fd,1b,J,\'6l\',G)})},6z:u(H,5d,4L,6E,J,G){E q.1w(\'1o\',u(){11 k.fx.6z(q,H,5d,4L,6E,J,\'6z\',G)})}});k.fx.6z=u(e,H,5d,4L,6E,J,1u,G){if(!k.4O(e)){k.2L(e,\'1o\');E I}D z=q;z.el=k(e);z.5d=T(5d)||2b;z.4L=T(4L)||2b;z.G=2h J==\'5g\'?J:G||U;z.J=2h J==\'u\'?J:U;z.1m=k.H(H).1m;z.6E=6E||U;z.2f=k.1a.2p(e);z.W={Z:z.el.B(\'Z\'),V:z.el.B(\'V\'),4w:z.el.B(\'4w\')||\'2b%\',Y:z.el.B(\'Y\'),19:z.el.B(\'19\'),Q:z.el.B(\'Q\'),O:z.el.B(\'O\'),2Y:z.el.B(\'2Y\'),4Z:z.el.B(\'4Z\'),6k:z.el.B(\'6k\'),6g:z.el.B(\'6g\'),5a:z.el.B(\'5a\'),66:z.el.B(\'66\'),6j:z.el.B(\'6j\'),5M:z.el.B(\'5M\'),4X:z.el.B(\'4X\')};z.Z=T(z.W.Z)||e.4b||0;z.V=T(z.W.V)||e.63||0;z.Q=T(z.W.Q)||0;z.O=T(z.W.O)||0;1q=[\'em\',\'S\',\'kJ\',\'%\'];1Y(i in 1q){if(z.W.4w.3F(1q[i])>0){z.fi=1q[i];z.4w=2m(z.W.4w)}if(z.W.4Z.3F(1q[i])>0){z.fw=1q[i];z.bt=2m(z.W.4Z)||0}if(z.W.6k.3F(1q[i])>0){z.fB=1q[i];z.bg=2m(z.W.6k)||0}if(z.W.6g.3F(1q[i])>0){z.fE=1q[i];z.bf=2m(z.W.6g)||0}if(z.W.5a.3F(1q[i])>0){z.fv=1q[i];z.be=2m(z.W.5a)||0}if(z.W.66.3F(1q[i])>0){z.fk=1q[i];z.bb=2m(z.W.66)||0}if(z.W.6j.3F(1q[i])>0){z.fs=1q[i];z.ba=2m(z.W.6j)||0}if(z.W.5M.3F(1q[i])>0){z.fb=1q[i];z.cJ=2m(z.W.5M)||0}if(z.W.4X.3F(1q[i])>0){z.fq=1q[i];z.cX=2m(z.W.4X)||0}}if(z.W.Y!=\'2y\'&&z.W.Y!=\'1O\'){z.el.B(\'Y\',\'2y\')}z.el.B(\'2Y\',\'2O\');z.1u=1u;3m(z.1u){1e\'f1\':z.4f=z.Q+z.2f.h/2;z.57=z.Q;z.4c=z.O+z.2f.w/2;z.4W=z.O;1r;1e\'d2\':z.57=z.Q+z.2f.h/2;z.4f=z.Q;z.4W=z.O+z.2f.w/2;z.4c=z.O;1r;1e\'6l\':z.57=z.Q-z.2f.h/4;z.4f=z.Q;z.4W=z.O-z.2f.w/4;z.4c=z.O;1r}z.bo=I;z.t=(11 72).71();z.4u=u(){6c(z.2H);z.2H=U};z.2D=u(){if(z.bo==I){z.el.22();z.bo=1b}D t=(11 72).71();D n=t-z.t;D p=n/z.1m;if(t>=z.1m+z.t){b1(u(){o=1;if(z.1u){t=z.57;l=z.4W;if(z.1u==\'6l\')o=0}z.bv(z.4L,l,t,1b,o)},13);z.4u()}P{o=1;if(!k.G||!k.G[z.G]){s=((-14.5v(p*14.2Q)/2)+0.5)*(z.4L-z.5d)+z.5d}P{s=k.G[z.G](p,n,z.5d,(z.4L-z.5d),z.1m)}if(z.1u){if(!k.G||!k.G[z.G]){t=((-14.5v(p*14.2Q)/2)+0.5)*(z.57-z.4f)+z.4f;l=((-14.5v(p*14.2Q)/2)+0.5)*(z.4W-z.4c)+z.4c;if(z.1u==\'6l\')o=((-14.5v(p*14.2Q)/2)+0.5)*(-0.9R)+0.9R}P{t=k.G[z.G](p,n,z.4f,(z.57-z.4f),z.1m);l=k.G[z.G](p,n,z.4c,(z.4W-z.4c),z.1m);if(z.1u==\'6l\')o=k.G[z.G](p,n,0.9R,-0.9R,z.1m)}}z.bv(s,l,t,I,o)}};z.2H=6I(u(){z.2D()},13);z.bv=u(4z,O,Q,fp,1J){z.el.B(\'V\',z.V*4z/2b+\'S\').B(\'Z\',z.Z*4z/2b+\'S\').B(\'O\',O+\'S\').B(\'Q\',Q+\'S\').B(\'4w\',z.4w*4z/2b+z.fi);if(z.bt)z.el.B(\'4Z\',z.bt*4z/2b+z.fw);if(z.bg)z.el.B(\'6k\',z.bg*4z/2b+z.fB);if(z.bf)z.el.B(\'6g\',z.bf*4z/2b+z.fE);if(z.be)z.el.B(\'5a\',z.be*4z/2b+z.fv);if(z.bb)z.el.B(\'66\',z.bb*4z/2b+z.fk);if(z.ba)z.el.B(\'6j\',z.ba*4z/2b+z.fs);if(z.cJ)z.el.B(\'5M\',z.cJ*4z/2b+z.fb);if(z.cX)z.el.B(\'4X\',z.cX*4z/2b+z.fq);if(z.1u==\'6l\'){if(1V.7a)z.el.K(0).18.69="9V(1J="+1J*2b+")";z.el.K(0).18.1J=1J}if(fp){if(z.6E){z.el.B(z.W)}if(z.1u==\'d2\'||z.1u==\'6l\'){z.el.B(\'19\',\'1n\');if(z.1u==\'6l\'){if(1V.7a)z.el.K(0).18.69="9V(1J="+2b+")";z.el.K(0).18.1J=1}}P z.el.B(\'19\',\'2E\');if(z.J)z.J.1F(z.el.K(0));k.2L(z.el.K(0),\'1o\')}}};k.fn.kL=u(H,4C,J,G){E q.1w(\'f6\',u(){q.73=k(q).1p("18")||\'\';G=2h J==\'5g\'?J:G||U;J=2h J==\'u\'?J:U;D 9U=k(q).B(\'7f\');D 87=q.3e;7o(9U==\'b7\'&&87){9U=k(87).B(\'7f\');87=87.3e}k(q).B(\'7f\',4C);if(2h q.73==\'8i\')q.73=q.73["9T"];k(q).5K({\'7f\':9U},H,G,u(){k.2L(q,\'f6\');if(2h k(q).1p("18")==\'8i\'){k(q).1p("18")["9T"]="";k(q).1p("18")["9T"]=q.73}P{k(q).1p("18",q.73)}if(J)J.1F(q)})})};k.fn.21({kg:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5A(q,H,J,\'4i\',\'5P\',G)})},kq:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5A(q,H,J,\'4a\',\'5P\',G)})},kr:u(H,J,G){E q.1w(\'1o\',u(){if(k.B(q,\'19\')==\'1n\'){11 k.fx.5A(q,H,J,\'4a\',\'7e\',G)}P{11 k.fx.5A(q,H,J,\'4a\',\'5P\',G)}})},kz:u(H,J,G){E q.1w(\'1o\',u(){if(k.B(q,\'19\')==\'1n\'){11 k.fx.5A(q,H,J,\'4i\',\'7e\',G)}P{11 k.fx.5A(q,H,J,\'4i\',\'5P\',G)}})},ky:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5A(q,H,J,\'4i\',\'7e\',G)})},kx:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.5A(q,H,J,\'4a\',\'7e\',G)})}});k.fx.5A=u(e,H,J,2P,1u,G){if(!k.4O(e)){k.2L(e,\'1o\');E I}D z=q;D 5H=I;z.el=k(e);z.G=2h J==\'5g\'?J:G||U;z.J=2h J==\'u\'?J:U;z.1u=1u;z.H=H;z.2f=k.1a.2p(e);z.W={};z.W.Y=z.el.B(\'Y\');z.W.19=z.el.B(\'19\');if(z.W.19==\'1n\'){62=z.el.B(\'3j\');z.el.22();5H=1b}z.W.Q=z.el.B(\'Q\');z.W.O=z.el.B(\'O\');if(5H){z.el.2G();z.el.B(\'3j\',62)}z.W.Z=z.2f.w+\'S\';z.W.V=z.2f.h+\'S\';z.W.2Y=z.el.B(\'2Y\');z.2f.Q=T(z.W.Q)||0;z.2f.O=T(z.W.O)||0;if(z.W.Y!=\'2y\'&&z.W.Y!=\'1O\'){z.el.B(\'Y\',\'2y\')}z.el.B(\'2Y\',\'2O\').B(\'V\',1u==\'7e\'&&2P==\'4i\'?1:z.2f.h+\'S\').B(\'Z\',1u==\'7e\'&&2P==\'4a\'?1:z.2f.w+\'S\');z.23=u(){z.el.B(z.W);if(z.1u==\'5P\')z.el.2G();P z.el.22();k.2L(z.el.K(0),\'1o\')};3m(2P){1e\'4i\':z.eh=11 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'V\');z.et=11 k.fx(z.el.K(0),k.H(z.H,z.G,z.23),\'Q\');if(z.1u==\'5P\'){z.eh.1L(z.2f.h,0);z.et.1L(z.2f.Q,z.2f.Q+z.2f.h/2)}P{z.eh.1L(0,z.2f.h);z.et.1L(z.2f.Q+z.2f.h/2,z.2f.Q)}1r;1e\'4a\':z.eh=11 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Z\');z.et=11 k.fx(z.el.K(0),k.H(z.H,z.G,z.23),\'O\');if(z.1u==\'5P\'){z.eh.1L(z.2f.w,0);z.et.1L(z.2f.O,z.2f.O+z.2f.w/2)}P{z.eh.1L(0,z.2f.w);z.et.1L(z.2f.O+z.2f.w/2,z.2f.O)}1r}};k.fn.cr=u(H,41,J){E q.1w(\'1o\',u(){if(!k.4O(q)){k.2L(q,\'1o\');E I}D fx=11 k.fx.cr(q,H,41,J);fx.cm()})};k.fx.cr=u(el,H,41,J){D z=q;z.41=41;z.5D=1;z.el=el;z.H=H;z.J=J;k(z.el).22();z.cm=u(){z.5D++;z.e=11 k.fx(z.el,k.H(z.H,u(){z.ef=11 k.fx(z.el,k.H(z.H,u(){if(z.5D<=z.41)z.cm();P{k.2L(z.el,\'1o\');if(z.J&&z.J.1K==2C){z.J.1F(z.el)}}}),\'1J\');z.ef.1L(0,1)}),\'1J\');z.e.1L(1,0)}};k.fn.21({9S:u(H,1N,G){o=k.H(H);E q.1w(\'1o\',u(){11 k.fx.9S(q,o,1N,G)})},ks:u(H,1N,G){E q.1B(u(){k(\'a[@3f*="#"]\',q).5G(u(e){g8=q.3f.7h(\'#\');k(\'#\'+g8[1]).9S(H,1N,G);E I})})}});k.fx.9S=u(e,o,1N,G){D z=q;z.o=o;z.e=e;z.1N=/g3|g0/.43(1N)?1N:I;z.G=G;p=k.1a.2R(e);s=k.1a.6W();z.4u=u(){6c(z.2H);z.2H=U;k.2L(z.e,\'1o\')};z.t=(11 72).71();s.h=s.h>s.ih?(s.h-s.ih):s.h;s.w=s.w>s.iw?(s.w-s.iw):s.w;z.57=p.y>s.h?s.h:p.y;z.4W=p.x>s.w?s.w:p.x;z.4f=s.t;z.4c=s.l;z.2D=u(){D t=(11 72).71();D n=t-z.t;D p=n/z.o.1m;if(t>=z.o.1m+z.t){z.4u();b1(u(){z.cE(z.57,z.4W)},13)}P{if(!z.1N||z.1N==\'g3\'){if(!k.G||!k.G[z.G]){aa=((-14.5v(p*14.2Q)/2)+0.5)*(z.57-z.4f)+z.4f}P{aa=k.G[z.G](p,n,z.4f,(z.57-z.4f),z.o.1m)}}P{aa=z.4f}if(!z.1N||z.1N==\'g0\'){if(!k.G||!k.G[z.G]){a9=((-14.5v(p*14.2Q)/2)+0.5)*(z.4W-z.4c)+z.4c}P{a9=k.G[z.G](p,n,z.4c,(z.4W-z.4c),z.o.1m)}}P{a9=z.4c}z.cE(aa,a9)}};z.cE=u(t,l){1V.gN(l,t)};z.2H=6I(u(){z.2D()},13)};k.fn.cy=u(41,J){E q.1w(\'1o\',u(){if(!k.4O(q)){k.2L(q,\'1o\');E I}D e=11 k.fx.cy(q,41,J);e.cx()})};k.fx.cy=u(e,41,J){D z=q;z.el=k(e);z.el.22();z.41=T(41)||3;z.J=J;z.5D=1;z.W={};z.W.Y=z.el.B(\'Y\');z.W.Q=T(z.el.B(\'Q\'))||0;z.W.O=T(z.el.B(\'O\'))||0;if(z.W.Y!=\'2y\'&&z.W.Y!=\'1O\'){z.el.B(\'Y\',\'2y\')}z.cx=u(){z.5D++;z.e=11 k.fx(z.el.K(0),{1m:60,23:u(){z.e=11 k.fx(z.el.K(0),{1m:60,23:u(){z.e=11 k.fx(e,{1m:60,23:u(){if(z.5D<=z.41)z.cx();P{z.el.B(\'Y\',z.W.Y).B(\'Q\',z.W.Q+\'S\').B(\'O\',z.W.O+\'S\');k.2L(z.el.K(0),\'1o\');if(z.J&&z.J.1K==2C){z.J.1F(z.el.K(0))}}}},\'O\');z.e.1L(z.W.O-20,z.W.O)}},\'O\');z.e.1L(z.W.O+20,z.W.O-20)}},\'O\');z.e.1L(z.W.O,z.W.O+20)}};k.fn.21({g9:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'4U\',\'in\',G)})},f3:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'4U\',\'4d\',G)})},gM:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'4U\',\'3Y\',G)})},gL:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'4y\',\'in\',G)})},gK:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'4y\',\'4d\',G)})},gS:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'4y\',\'3Y\',G)})},gR:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'O\',\'in\',G)})},gJ:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'O\',\'4d\',G)})},gI:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'O\',\'3Y\',G)})},gC:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'2N\',\'in\',G)})},gB:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'2N\',\'4d\',G)})},gU:u(H,J,G){E q.1w(\'1o\',u(){11 k.fx.1z(q,H,J,\'2N\',\'3Y\',G)})}});k.fx.1z=u(e,H,J,2P,1u,G){if(!k.4O(e)){k.2L(e,\'1o\');E I}D z=q;z.el=k(e);z.G=2h J==\'5g\'?J:G||U;z.J=2h J==\'u\'?J:U;if(1u==\'3Y\'){1u=z.el.B(\'19\')==\'1n\'?\'in\':\'4d\'}if(!e.4s)e.4s=z.el.B(\'19\');z.el.22();z.H=H;z.fx=k.fx.9h(e);z.1u=1u;z.2P=2P;z.23=u(){if(z.1u==\'4d\')z.el.B(\'3j\',\'2O\');k.fx.9g(z.fx.3o.K(0),z.fx.W);if(z.1u==\'in\'){z.el.B(\'19\',z.el.K(0).4s==\'1n\'?\'2E\':z.el.K(0).4s)}P{z.el.B(\'19\',\'1n\');z.el.B(\'3j\',\'dR\')}if(z.J&&z.J.1K==2C){z.J.1F(z.el.K(0))}k.2L(z.el.K(0),\'1o\')};3m(z.2P){1e\'4U\':z.ef=11 k.fx(z.el.K(0),k.H(z.H,z.G,z.23),\'Q\');z.7S=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G),\'V\');if(z.1u==\'in\'){z.ef.1L(-z.fx.W.1q.hb,0);z.7S.1L(0,z.fx.W.1q.hb)}P{z.ef.1L(0,-z.fx.W.1q.hb);z.7S.1L(z.fx.W.1q.hb,0)}1r;1e\'4y\':z.ef=11 k.fx(z.el.K(0),k.H(z.H,z.G,z.23),\'Q\');if(z.1u==\'in\'){z.ef.1L(z.fx.W.1q.hb,0)}P{z.ef.1L(0,z.fx.W.1q.hb)}1r;1e\'O\':z.ef=11 k.fx(z.el.K(0),k.H(z.H,z.G,z.23),\'O\');z.7S=11 k.fx(z.fx.3o.K(0),k.H(z.H,z.G),\'Z\');if(z.1u==\'in\'){z.ef.1L(-z.fx.W.1q.1D,0);z.7S.1L(0,z.fx.W.1q.1D)}P{z.ef.1L(0,-z.fx.W.1q.1D);z.7S.1L(z.fx.W.1q.1D,0)}1r;1e\'2N\':z.ef=11 k.fx(z.el.K(0),k.H(z.H,z.G,z.23),\'O\');if(z.1u==\'in\'){z.ef.1L(z.fx.W.1q.1D,0)}P{z.ef.1L(0,z.fx.W.1q.1D)}1r}};k.h2=U;k.fn.h1=u(o){E q.1B(u(){if(!o||!o.4L){E}D el=q;k(o.4L).1B(u(){11 k.fx.fu(el,q,o)})})};k.fx.fu=u(e,8s,o){D z=q;z.el=k(e);z.8s=8s;z.4e=1j.3t(\'26\');k(z.4e).B({Y:\'1O\'}).2Z(o.3b);if(!o.1m){o.1m=er}z.1m=o.1m;z.23=o.23;z.9i=0;z.9j=0;if(k.f5){z.9i=(T(k.3M(z.4e,\'5a\'))||0)+(T(k.3M(z.4e,\'6k\'))||0)+(T(k.3M(z.4e,\'4X\'))||0)+(T(k.3M(z.4e,\'6j\'))||0);z.9j=(T(k.3M(z.4e,\'4Z\'))||0)+(T(k.3M(z.4e,\'6g\'))||0)+(T(k.3M(z.4e,\'66\'))||0)+(T(k.3M(z.4e,\'5M\'))||0)}z.28=k.21(k.1a.2R(z.el.K(0)),k.1a.2p(z.el.K(0)));z.2X=k.21(k.1a.2R(z.8s),k.1a.2p(z.8s));z.28.1D-=z.9i;z.28.hb-=z.9j;z.2X.1D-=z.9i;z.2X.hb-=z.9j;z.J=o.23;k(\'2e\').1R(z.4e);k(z.4e).B(\'Z\',z.28.1D+\'S\').B(\'V\',z.28.hb+\'S\').B(\'Q\',z.28.y+\'S\').B(\'O\',z.28.x+\'S\').5K({Q:z.2X.y,O:z.2X.x,Z:z.2X.1D,V:z.2X.hb},z.1m,u(){k(z.4e).aB();if(z.23&&z.23.1K==2C){z.23.1F(z.el.K(0),[z.4L])}})};k.ak={2s:u(M){E q.1B(u(){D el=q;D 7x=2*14.2Q/eY;D aZ=2*14.2Q;if(k(el).B(\'Y\')!=\'2y\'&&k(el).B(\'Y\')!=\'1O\'){k(el).B(\'Y\',\'2y\')}el.1l={1S:k(M.1S,q),2F:M.2F,6M:M.6M,an:M.an,aZ:aZ,1P:k.1a.2p(q),Y:k.1a.2R(q),28:14.2Q/2,ct:M.ct,91:M.6R,6R:[],aY:I,7x:2*14.2Q/eY};el.1l.eZ=(el.1l.1P.w-el.1l.2F)/2;el.1l.7O=(el.1l.1P.h-el.1l.6M-el.1l.6M*el.1l.91)/2;el.1l.2D=2*14.2Q/el.1l.1S.1P();el.1l.cI=el.1l.1P.w/2;el.1l.cF=el.1l.1P.h/2-el.1l.6M*el.1l.91;D aS=1j.3t(\'26\');k(aS).B({Y:\'1O\',3B:1,Q:0,O:0});k(el).1R(aS);el.1l.1S.1B(u(2I){ab=k(\'1U\',q).K(0);V=T(el.1l.6M*el.1l.91);if(k.3h.4I){3N=1j.3t(\'1U\');k(3N).B(\'Y\',\'1O\');3N.2M=ab.2M;3N.18.69=\'iW aw:ax.ay.c1(1J=60, 18=1, iJ=0, i6=0, hz=0, hx=0)\'}P{3N=1j.3t(\'3N\');if(3N.ga){4H=3N.ga("2d");3N.18.Y=\'1O\';3N.18.V=V+\'S\';3N.18.Z=el.1l.2F+\'S\';3N.V=V;3N.Z=el.1l.2F;4H.i4();4H.i2(0,V);4H.hT(1,-1);4H.hJ(ab,0,0,el.1l.2F,V);4H.6E();4H.hN="hO-4d";D b0=4H.hQ(0,0,0,V);b0.g1(1,"fU(1X, 1X, 1X, 1)");b0.g1(0,"fU(1X, 1X, 1X, 0.6)");4H.hR=b0;if(iR.iv.3F(\'ix\')!=-1){4H.it()}P{4H.ir(0,0,el.1l.2F,V)}}}el.1l.6R[2I]=3N;k(aS).1R(3N)}).1H(\'aV\',u(e){el.1l.aY=1b;el.1l.H=el.1l.7x*0.1*el.1l.H/14.3R(el.1l.H);E I}).1H(\'8q\',u(e){el.1l.aY=I;E I});k.ak.7P(el);el.1l.H=el.1l.7x*0.2;el.1l.gm=1V.6I(u(){el.1l.28+=el.1l.H;if(el.1l.28>aZ)el.1l.28=0;k.ak.7P(el)},20);k(el).1H(\'8q\',u(){el.1l.H=el.1l.7x*0.2*el.1l.H/14.3R(el.1l.H)}).1H(\'3H\',u(e){if(el.1l.aY==I){1s=k.1a.44(e);fe=el.1l.1P.w-1s.x+el.1l.Y.x;el.1l.H=el.1l.ct*el.1l.7x*(el.1l.1P.w/2-fe)/(el.1l.1P.w/2)}})})},7P:u(el){el.1l.1S.1B(u(2I){ch=el.1l.28+2I*el.1l.2D;x=el.1l.eZ*14.5v(ch);y=el.1l.7O*14.98(ch);fm=T(2b*(el.1l.7O+y)/(2*el.1l.7O));fl=(el.1l.7O+y)/(2*el.1l.7O);Z=T((el.1l.2F-el.1l.an)*fl+el.1l.an);V=T(Z*el.1l.6M/el.1l.2F);q.18.Q=el.1l.cF+y-V/2+"S";q.18.O=el.1l.cI+x-Z/2+"S";q.18.Z=Z+"S";q.18.V=V+"S";q.18.3B=fm;el.1l.6R[2I].18.Q=T(el.1l.cF+y+V-1-V/2)+"S";el.1l.6R[2I].18.O=T(el.1l.cI+x-Z/2)+"S";el.1l.6R[2I].18.Z=Z+"S";el.1l.6R[2I].18.V=T(V*el.1l.91)+"S"})}};k.fn.h9=k.ak.2s;k.ff={2s:u(M){E q.1B(u(){if(!M.ae||!M.ad)E;D el=q;el.2j={ag:M.ag||bw,ae:M.ae,ad:M.ad,8r:M.8r||\'f7\',af:M.af||\'f7\',2U:M.2U&&2h M.2U==\'u\'?M.2U:I,3i:M.2U&&2h M.3i==\'u\'?M.3i:I,74:M.74&&2h M.74==\'u\'?M.74:I,ai:k(M.ae,q),8f:k(M.ad,q),H:M.H||8w,6e:M.6e||0};el.2j.8f.2G().B(\'V\',\'83\').eq(0).B({V:el.2j.ag+\'S\',19:\'2E\'}).2X();el.2j.ai.1B(u(2I){q.7d=2I}).h6(u(){k(q).2Z(el.2j.af)},u(){k(q).4p(el.2j.af)}).1H(\'5G\',u(e){if(el.2j.6e==q.7d)E;el.2j.ai.eq(el.2j.6e).4p(el.2j.8r).2X().eq(q.7d).2Z(el.2j.8r).2X();el.2j.8f.eq(el.2j.6e).5K({V:0},el.2j.H,u(){q.18.19=\'1n\';if(el.2j.3i){el.2j.3i.1F(el,[q])}}).2X().eq(q.7d).22().5K({V:el.2j.ag},el.2j.H,u(){q.18.19=\'2E\';if(el.2j.2U){el.2j.2U.1F(el,[q])}}).2X();if(el.2j.74){el.2j.74.1F(el,[q,el.2j.8f.K(q.7d),el.2j.ai.K(el.2j.6e),el.2j.8f.K(el.2j.6e)])}el.2j.6e=q.7d}).eq(0).2Z(el.2j.8r).2X();k(q).B(\'V\',k(q).B(\'V\')).B(\'2Y\',\'2O\')})}};k.fn.h7=k.ff.2s;k.3L={1c:U,8u:u(){31=q.2v;if(!31)E;18={fg:k(q).B(\'fg\')||\'\',4w:k(q).B(\'4w\')||\'\',8h:k(q).B(\'8h\')||\'\',fI:k(q).B(\'fI\')||\'\',fJ:k(q).B(\'fJ\')||\'\',fT:k(q).B(\'fT\')||\'\',cH:k(q).B(\'cH\')||\'\',fc:k(q).B(\'fc\')||\'\'};k.3L.1c.B(18);3w=k.3L.g2(31);3w=3w.4v(11 cp("\\\\n","g"),"
");k.3L.1c.3w(\'km\');ck=k.3L.1c.K(0).4b;k.3L.1c.3w(3w);Z=k.3L.1c.K(0).4b+ck;if(q.6t.2J&&Z>q.6t.2J[0]){Z=q.6t.2J[0]}q.18.Z=Z+\'S\';if(q.4S==\'cQ\'){V=k.3L.1c.K(0).63+ck;if(q.6t.2J&&V>q.6t.2J[1]){V=q.6t.2J[1]}q.18.V=V+\'S\'}},g2:u(31){co={\'&\':\'&j0;\',\'<\':\'&kB;\',\'>\':\'>\',\'"\':\'&kw;\'};1Y(i in co){31=31.4v(11 cp(i,\'g\'),co[i])}E 31},2s:u(2J){if(k.3L.1c==U){k(\'2e\',1j).1R(\'<26 id="fH" 18="Y: 1O; Q: 0; O: 0; 3j: 2O;">\');k.3L.1c=k(\'#fH\')}E q.1B(u(){if(/cQ|bz/.43(q.4S)){if(q.4S==\'bz\'){f9=q.5n(\'1u\');if(!/31|kv/.43(f9)){E}}if(2J&&(2J.1K==cR||(2J.1K==7b&&2J.1h==2))){if(2J.1K==cR)2J=[2J,2J];P{2J[0]=T(2J[0])||8w;2J[1]=T(2J[1])||8w}q.6t={2J:2J}}k(q).5I(k.3L.8u).6S(k.3L.8u).fX(k.3L.8u);k.3L.8u.1F(q)}})}};k.fn.ke=k.3L.2s;k.N={1c:U,8S:U,3E:U,2H:U,4o:U,bp:U,1d:U,2g:U,1S:U,5t:u(){k.N.8S.5t();if(k.N.3E){k.N.3E.2G()}},4u:u(){k.N.1S=U;k.N.2g=U;k.N.4o=k.N.1d.2v;if(k.N.1c.B(\'19\')==\'2E\'){if(k.N.1d.1f.fx){3m(k.N.1d.1f.fx.1u){1e\'bB\':k.N.1c.7k(k.N.1d.1f.fx.1m,k.N.5t);1r;1e\'1z\':k.N.1c.f3(k.N.1d.1f.fx.1m,k.N.5t);1r;1e\'aT\':k.N.1c.fz(k.N.1d.1f.fx.1m,k.N.5t);1r}}P{k.N.1c.2G()}if(k.N.1d.1f.3i)k.N.1d.1f.3i.1F(k.N.1d,[k.N.1c,k.N.3E])}P{k.N.5t()}1V.c6(k.N.2H)},fy:u(){D 1d=k.N.1d;D 4g=k.N.ap(1d);if(1d&&4g.3k!=k.N.4o&&4g.3k.1h>=1d.1f.aL){k.N.4o=4g.3k;k.N.bp=4g.3k;79={2q:k(1d).1p(\'kP\')||\'2q\',2v:4g.3k};k.kN({1u:\'kG\',79:k.kI(79),kF:u(ft){1d.1f.4h=k(\'3k\',ft);1P=1d.1f.4h.1P();if(1P>0){D 5x=\'\';1d.1f.4h.1B(u(2I){5x+=\'<90 4G="\'+k(\'2v\',q).31()+\'" 8O="\'+2I+\'" 18="94: aG;">\'+k(\'31\',q).31()+\'\'});if(1d.1f.aR){D 3G=k(\'2v\',1d.1f.4h.K(0)).31();1d.2v=4g.3l+3G+1d.1f.3K+4g.5Q;k.N.6G(1d,4g.3k.1h!=3G.1h?(4g.3l.1h+4g.3k.1h):3G.1h,4g.3k.1h!=3G.1h?(4g.3l.1h+3G.1h):3G.1h)}if(1P>0){k.N.b4(1d,5x)}P{k.N.4u()}}P{k.N.4u()}},6b:1d.1f.aM})}},b4:u(1d,5x){k.N.8S.3w(5x);k.N.1S=k(\'90\',k.N.8S.K(0));k.N.1S.aV(k.N.f2).1H(\'5G\',k.N.fO);D Y=k.1a.2R(1d);D 1P=k.1a.2p(1d);k.N.1c.B(\'Q\',Y.y+1P.hb+\'S\').B(\'O\',Y.x+\'S\').2Z(1d.1f.aK);if(k.N.3E){k.N.3E.B(\'19\',\'2E\').B(\'Q\',Y.y+1P.hb+\'S\').B(\'O\',Y.x+\'S\').B(\'Z\',k.N.1c.B(\'Z\')).B(\'V\',k.N.1c.B(\'V\'))}k.N.2g=0;k.N.1S.K(0).3b=1d.1f.70;k.N.8P(1d,1d.1f.4h.K(0),\'6Z\');if(k.N.1c.B(\'19\')==\'1n\'){if(1d.1f.bA){D bm=k.1a.aj(1d,1b);D bl=k.1a.6h(1d,1b);k.N.1c.B(\'Z\',1d.4b-(k.f5?(bm.l+bm.r+bl.l+bl.r):0)+\'S\')}if(1d.1f.fx){3m(1d.1f.fx.1u){1e\'bB\':k.N.1c.7m(1d.1f.fx.1m);1r;1e\'1z\':k.N.1c.g9(1d.1f.fx.1m);1r;1e\'aT\':k.N.1c.fP(1d.1f.fx.1m);1r}}P{k.N.1c.22()}if(k.N.1d.1f.2U)k.N.1d.1f.2U.1F(k.N.1d,[k.N.1c,k.N.3E])}},fC:u(){D 1d=q;if(1d.1f.4h){k.N.4o=1d.2v;k.N.bp=1d.2v;D 5x=\'\';1d.1f.4h.1B(u(2I){2v=k(\'2v\',q).31().5Z();fR=1d.2v.5Z();if(2v.3F(fR)==0){5x+=\'<90 4G="\'+k(\'2v\',q).31()+\'" 8O="\'+2I+\'" 18="94: aG;">\'+k(\'31\',q).31()+\'\'}});if(5x!=\'\'){k.N.b4(1d,5x);q.1f.aW=1b;E}}1d.1f.4h=U;q.1f.aW=I},6G:u(2q,28,2X){if(2q.aI){D 6K=2q.aI();6K.j8(1b);6K.fr("bW",28);6K.ja("bW",-2X+28);6K.8Z()}P if(2q.aU){2q.aU(28,2X)}P{if(2q.5B){2q.5B=28;2q.dq=2X}}2q.6D()},fD:u(2q){if(2q.5B)E 2q.5B;P if(2q.aI){D 6K=1j.6G.du();D fo=6K.jg();E 0-fo.fr(\'bW\',-jX)}},ap:u(2q){D 4F={2v:2q.2v,3l:\'\',5Q:\'\',3k:\'\'};if(2q.1f.aO){D 97=I;D 5B=k.N.fD(2q)||0;D 56=4F.2v.7h(2q.1f.3K);1Y(D i=0;i<56.1h;i++){if((4F.3l.1h+56[i].1h>=5B||5B==0)&&!97){if(4F.3l.1h<=5B)4F.3k=56[i];P 4F.5Q+=56[i]+(56[i]!=\'\'?2q.1f.3K:\'\');97=1b}P if(97){4F.5Q+=56[i]+(56[i]!=\'\'?2q.1f.3K:\'\')}if(!97){4F.3l+=56[i]+(56.1h>1?2q.1f.3K:\'\')}}}P{4F.3k=4F.2v}E 4F},bu:u(e){1V.c6(k.N.2H);D 1d=k.N.ap(q);D 3O=e.7F||e.7A||-1;if(/^13$|27$|35$|36$|38$|40$|^9$/.43(3O)&&k.N.1S){if(1V.2l){1V.2l.cj=1b;1V.2l.ci=I}P{e.al();e.am()}if(k.N.2g!=U)k.N.1S.K(k.N.2g||0).3b=\'\';P k.N.2g=-1;3m(3O){1e 9:1e 13:if(k.N.2g==-1)k.N.2g=0;D 2g=k.N.1S.K(k.N.2g||0);D 3G=2g.5n(\'4G\');q.2v=1d.3l+3G+q.1f.3K+1d.5Q;k.N.4o=1d.3k;k.N.6G(q,1d.3l.1h+3G.1h+q.1f.3K.1h,1d.3l.1h+3G.1h+q.1f.3K.1h);k.N.4u();if(q.1f.6a){4n=T(2g.5n(\'8O\'))||0;k.N.8P(q,q.1f.4h.K(4n),\'6a\')}if(q.76)q.76(I);E 3O!=13;1r;1e 27:q.2v=1d.3l+k.N.4o+q.1f.3K+1d.5Q;q.1f.4h=U;k.N.4u();if(q.76)q.76(I);E I;1r;1e 35:k.N.2g=k.N.1S.1P()-1;1r;1e 36:k.N.2g=0;1r;1e 38:k.N.2g--;if(k.N.2g<0)k.N.2g=k.N.1S.1P()-1;1r;1e 40:k.N.2g++;if(k.N.2g==k.N.1S.1P())k.N.2g=0;1r}k.N.8P(q,q.1f.4h.K(k.N.2g||0),\'6Z\');k.N.1S.K(k.N.2g||0).3b=q.1f.70;if(k.N.1S.K(k.N.2g||0).76)k.N.1S.K(k.N.2g||0).76(I);if(q.1f.aR){D aA=k.N.1S.K(k.N.2g||0).5n(\'4G\');q.2v=1d.3l+aA+q.1f.3K+1d.5Q;if(k.N.4o.1h!=aA.1h)k.N.6G(q,1d.3l.1h+k.N.4o.1h,1d.3l.1h+aA.1h)}E I}k.N.fC.1F(q);if(q.1f.aW==I){if(1d.3k!=k.N.4o&&1d.3k.1h>=q.1f.aL)k.N.2H=1V.b1(k.N.fy,q.1f.53);if(k.N.1S){k.N.4u()}}E 1b},8P:u(2q,3k,1u){if(2q.1f[1u]){D 79={};aE=3k.dU(\'*\');1Y(i=0;i\');k.N.3E=k(\'#g5\')}k(\'2e\',1j).1R(\'<26 id="gc" 18="Y: 1O; Q: 0; O: 0; z-b2: jE; 19: 1n;">&7J;\');k.N.1c=k(\'#gc\');k.N.8S=k(\'aX\',k.N.1c)}E q.1B(u(){if(q.4S!=\'bz\'&&q.5n(\'1u\')!=\'31\')E;q.1f={};q.1f.aM=M.aM;q.1f.aL=14.3R(T(M.aL)||1);q.1f.aK=M.aK?M.aK:\'\';q.1f.70=M.70?M.70:\'\';q.1f.6a=M.6a&&M.6a.1K==2C?M.6a:U;q.1f.2U=M.2U&&M.2U.1K==2C?M.2U:U;q.1f.3i=M.3i&&M.3i.1K==2C?M.3i:U;q.1f.6Z=M.6Z&&M.6Z.1K==2C?M.6Z:U;q.1f.bA=M.bA||I;q.1f.aO=M.aO||I;q.1f.3K=q.1f.aO?(M.3K||\', \'):\'\';q.1f.aR=M.aR?1b:I;q.1f.53=14.3R(T(M.53)||aF);if(M.fx&&M.fx.1K==7n){if(!M.fx.1u||!/bB|1z|aT/.43(M.fx.1u)){M.fx.1u=\'1z\'}if(M.fx.1u==\'1z\'&&!k.fx.1z)E;if(M.fx.1u==\'aT\'&&!k.fx.5W)E;M.fx.1m=14.3R(T(M.fx.1m)||8w);if(M.fx.1m>q.1f.53){M.fx.1m=q.1f.53-2b}q.1f.fx=M.fx}q.1f.4h=U;q.1f.aW=I;k(q).1p(\'bu\',\'fQ\').6D(u(){k.N.1d=q;k.N.4o=q.2v}).fX(k.N.gb).6S(k.N.bu).5I(u(){k.N.2H=1V.b1(k.N.4u,jP)})})}};k.fn.jO=k.N.2s;k.1y={2H:U,4E:U,29:U,2D:10,28:u(el,4P,2D,di){k.1y.4E=el;k.1y.29=4P;k.1y.2D=T(2D)||10;k.1y.2H=1V.6I(k.1y.db,T(di)||40)},db:u(){1Y(i=0;i0&&k.1y.29[i].30.y+k.1y.29[i].30.t>6f.y){k.1y.29[i].2V-=k.1y.2D}P if(k.1y.29[i].30.t<=k.1y.29[i].30.h&&k.1y.29[i].30.t+k.1y.29[i].30.hb<6f.y+6f.hb){k.1y.29[i].2V+=k.1y.2D}if(k.1y.29[i].30.l>0&&k.1y.29[i].30.x+k.1y.29[i].30.l>6f.x){k.1y.29[i].3g-=k.1y.2D}P if(k.1y.29[i].30.l<=k.1y.29[i].30.jT&&k.1y.29[i].30.l+k.1y.29[i].30.1D<6f.x+6f.1D){k.1y.29[i].3g+=k.1y.2D}}},8v:u(){1V.6c(k.1y.2H);k.1y.4E=U;k.1y.29=U;1Y(i in k.1y.29){k.1y.29[i].30=U}}};k.6y={2s:u(M){E q.1B(u(){D el=q;el.1G={1S:k(M.1S,q),1Z:k(M.1Z,q),1M:k.1a.2R(q),2F:M.2F,aN:M.aN,7R:M.7R,dw:M.dw,51:M.51,6q:M.6q};k.6y.aJ(el,0);k(1V).1H(\'jS\',u(){el.1G.1M=k.1a.2R(el);k.6y.aJ(el,0);k.6y.7P(el)});k.6y.7P(el);el.1G.1S.1H(\'aV\',u(){k(el.1G.aN,q).K(0).18.19=\'2E\'}).1H(\'8q\',u(){k(el.1G.aN,q).K(0).18.19=\'1n\'});k(1j).1H(\'3H\',u(e){D 1s=k.1a.44(e);D 5q=0;if(el.1G.51&&el.1G.51==\'b8\')D aQ=1s.x-el.1G.1M.x-(el.4b-el.1G.2F*el.1G.1S.1P())/2-el.1G.2F/2;P if(el.1G.51&&el.1G.51==\'2N\')D aQ=1s.x-el.1G.1M.x-el.4b+el.1G.2F*el.1G.1S.1P();P D aQ=1s.x-el.1G.1M.x;D dB=14.5Y(1s.y-el.1G.1M.y-el.63/2,2);el.1G.1S.1B(u(2I){46=14.dm(14.5Y(aQ-2I*el.1G.2F,2)+dB);46-=el.1G.2F/2;46=46<0?0:46;46=46>el.1G.7R?el.1G.7R:46;46=el.1G.7R-46;bC=el.1G.6q*46/el.1G.7R;q.18.Z=el.1G.2F+bC+\'S\';q.18.O=el.1G.2F*2I+5q+\'S\';5q+=bC});k.6y.aJ(el,5q)})})},aJ:u(el,5q){if(el.1G.51)if(el.1G.51==\'b8\')el.1G.1Z.K(0).18.O=(el.4b-el.1G.2F*el.1G.1S.1P())/2-5q/2+\'S\';P if(el.1G.51==\'O\')el.1G.1Z.K(0).18.O=-5q/el.1G.1S.1P()+\'S\';P if(el.1G.51==\'2N\')el.1G.1Z.K(0).18.O=(el.4b-el.1G.2F*el.1G.1S.1P())-5q/2+\'S\';el.1G.1Z.K(0).18.Z=el.1G.2F*el.1G.1S.1P()+5q+\'S\'},7P:u(el){el.1G.1S.1B(u(2I){q.18.Z=el.1G.2F+\'S\';q.18.O=el.1G.2F*2I+\'S\'})}};k.fn.jD=k.6y.2s;k.1v={M:{2B:10,eV:\'1Q/jG.eF\',eT:\'<1U 2M="1Q/5P.eC" />\',eN:0.8,e3:\'jK ab\',e5:\'5d\',3V:8w},jI:I,jU:I,6r:U,9d:I,9e:I,ca:u(2l){if(!k.1v.9e||k.1v.9d)E;D 3O=2l.7F||2l.7A||-1;3m(3O){1e 35:if(k.1v.6r)k.1v.28(U,k(\'a[@4G=\'+k.1v.6r+\']:k7\').K(0));1r;1e 36:if(k.1v.6r)k.1v.28(U,k(\'a[@4G=\'+k.1v.6r+\']:k5\').K(0));1r;1e 37:1e 8:1e 33:1e 80:1e k8:D ar=k(\'#9a\');if(ar.K(0).52!=U){ar.K(0).52.1F(ar.K(0))}1r;1e 38:1r;1e 39:1e 34:1e 32:1e ka:1e 78:D aD=k(\'#9b\');if(aD.K(0).52!=U){aD.K(0).52.1F(aD.K(0))}1r;1e 40:1r;1e 27:k.1v.ah();1r}},7W:u(M){if(M)k.21(k.1v.M,M);if(1V.2l){k(\'2e\',1j).1H(\'6S\',k.1v.ca)}P{k(1j).1H(\'6S\',k.1v.ca)}k(\'a\').1B(u(){el=k(q);dQ=el.1p(\'4G\')||\'\';eA=el.1p(\'3f\')||\'\';eu=/\\.eC|\\.jY|\\.95|\\.eF|\\.jW/g;if(eA.5Z().bU(eu)!=U&&dQ.5Z().3F(\'eJ\')==0){el.1H(\'5G\',k.1v.28)}});if(k.3h.4I){3E=1j.3t(\'3E\');k(3E).1p({id:\'b6\',2M:\'ew:I;\',ez:\'bX\',ey:\'bX\'}).B({19:\'1n\',Y:\'1O\',Q:\'0\',O:\'0\',69:\'aw:ax.ay.c1(1J=0)\'});k(\'2e\').1R(3E)}8Q=1j.3t(\'26\');k(8Q).1p(\'id\',\'bk\').B({Y:\'1O\',19:\'1n\',Q:\'0\',O:\'0\',1J:0}).1R(1j.8F(\' \')).1H(\'5G\',k.1v.ah);6L=1j.3t(\'26\');k(6L).1p(\'id\',\'dZ\').B({4X:k.1v.M.2B+\'S\'}).1R(1j.8F(\' \'));bZ=1j.3t(\'26\');k(bZ).1p(\'id\',\'e1\').B({4X:k.1v.M.2B+\'S\',5M:k.1v.M.2B+\'S\'}).1R(1j.8F(\' \'));cc=1j.3t(\'a\');k(cc).1p({id:\'jh\',3f:\'#\'}).B({Y:\'1O\',2N:k.1v.M.2B+\'S\',Q:\'0\'}).1R(k.1v.M.eT).1H(\'5G\',k.1v.ah);7t=1j.3t(\'26\');k(7t).1p(\'id\',\'bh\').B({Y:\'2y\',b9:\'O\',6X:\'0 ao\',3B:1}).1R(6L).1R(bZ).1R(cc);2a=1j.3t(\'1U\');2a.2M=k.1v.M.eV;k(2a).1p(\'id\',\'ep\').B({Y:\'1O\'});4R=1j.3t(\'a\');k(4R).1p({id:\'9a\',3f:\'#\'}).B({Y:\'1O\',19:\'1n\',2Y:\'2O\',eQ:\'1n\'}).1R(1j.8F(\' \'));4Q=1j.3t(\'a\');k(4Q).1p({id:\'9b\',3f:\'#\'}).B({Y:\'1O\',2Y:\'2O\',eQ:\'1n\'}).1R(1j.8F(\' \'));1Z=1j.3t(\'26\');k(1Z).1p(\'id\',\'e0\').B({19:\'1n\',Y:\'2y\',2Y:\'2O\',b9:\'O\',6X:\'0 ao\',Q:\'0\',O:\'0\',3B:2}).1R([2a,4R,4Q]);6N=1j.3t(\'26\');k(6N).1p(\'id\',\'aq\').B({19:\'1n\',Y:\'1O\',2Y:\'2O\',Q:\'0\',O:\'0\',b9:\'b8\',7f:\'b7\',j7:\'0\'}).1R([1Z,7t]);k(\'2e\').1R(8Q).1R(6N)},28:u(e,C){el=C?k(C):k(q);at=el.1p(\'4G\');D 6P,4n,4R,4Q;if(at!=\'eJ\'){k.1v.6r=at;8N=k(\'a[@4G=\'+at+\']\');6P=8N.1P();4n=8N.b2(C?C:q);4R=8N.K(4n-1);4Q=8N.K(4n+1)}8H=el.1p(\'3f\');6L=el.1p(\'45\');3I=k.1a.6W();8Q=k(\'#bk\');if(!k.1v.9e){k.1v.9e=1b;if(k.3h.4I){k(\'#b6\').B(\'V\',14.3v(3I.ih,3I.h)+\'S\').B(\'Z\',14.3v(3I.iw,3I.w)+\'S\').22()}8Q.B(\'V\',14.3v(3I.ih,3I.h)+\'S\').B(\'Z\',14.3v(3I.iw,3I.w)+\'S\').22().eo(bw,k.1v.M.eN,u(){k.1v.bd(8H,6L,3I,6P,4n,4R,4Q)});k(\'#aq\').B(\'Z\',14.3v(3I.iw,3I.w)+\'S\')}P{k(\'#9a\').K(0).52=U;k(\'#9b\').K(0).52=U;k.1v.bd(8H,6L,3I,6P,4n,4R,4Q)}E I},bd:u(8H,jA,3I,6P,4n,4R,4Q){k(\'#bi\').aB();aC=k(\'#9a\');aC.2G();as=k(\'#9b\');as.2G();2a=k(\'#ep\');1Z=k(\'#e0\');6N=k(\'#aq\');7t=k(\'#bh\').B(\'3j\',\'2O\');k(\'#dZ\').3w(6L);k.1v.9d=1b;if(6P)k(\'#e1\').3w(k.1v.M.e3+\' \'+(4n+1)+\' \'+k.1v.M.e5+\' \'+6P);if(4R){aC.K(0).52=u(){q.5I();k.1v.28(U,4R);E I}}if(4Q){as.K(0).52=u(){q.5I();k.1v.28(U,4Q);E I}}2a.22();8E=k.1a.2p(1Z.K(0));5f=14.3v(8E.1D,2a.K(0).Z+k.1v.M.2B*2);5T=14.3v(8E.hb,2a.K(0).V+k.1v.M.2B*2);2a.B({O:(5f-2a.K(0).Z)/2+\'S\',Q:(5T-2a.K(0).V)/2+\'S\'});1Z.B({Z:5f+\'S\',V:5T+\'S\'}).22();e4=k.1a.bq();6N.B(\'Q\',3I.t+(e4.h/15)+\'S\');if(6N.B(\'19\')==\'1n\'){6N.22().7m(k.1v.M.3V)}6U=11 aH;k(6U).1p(\'id\',\'bi\').1H(\'jk\',u(){5f=6U.Z+k.1v.M.2B*2;5T=6U.V+k.1v.M.2B*2;2a.2G();1Z.5K({V:5T},8E.hb!=5T?k.1v.M.3V:1,u(){1Z.5K({Z:5f},8E.1D!=5f?k.1v.M.3V:1,u(){1Z.cA(6U);k(6U).B({Y:\'1O\',O:k.1v.M.2B+\'S\',Q:k.1v.M.2B+\'S\'}).7m(k.1v.M.3V,u(){dS=k.1a.2p(7t.K(0));if(4R){aC.B({O:k.1v.M.2B+\'S\',Q:k.1v.M.2B+\'S\',Z:5f/2-k.1v.M.2B*3+\'S\',V:5T-k.1v.M.2B*2+\'S\'}).22()}if(4Q){as.B({O:5f/2+k.1v.M.2B*2+\'S\',Q:k.1v.M.2B+\'S\',Z:5f/2-k.1v.M.2B*3+\'S\',V:5T-k.1v.M.2B*2+\'S\'}).22()}7t.B({Z:5f+\'S\',Q:-dS.hb+\'S\',3j:\'dR\'}).5K({Q:-1},k.1v.M.3V,u(){k.1v.9d=I})})})})});6U.2M=8H},ah:u(){k(\'#bi\').aB();k(\'#aq\').2G();k(\'#bh\').B(\'3j\',\'2O\');k(\'#bk\').eo(bw,0,u(){k(q).2G();if(k.3h.4I){k(\'#b6\').2G()}});k(\'#9a\').K(0).52=U;k(\'#9b\').K(0).52=U;k.1v.6r=U;k.1v.9e=I;k.1v.9d=I;E I}};k.2A={5E:[],eS:u(){q.5I();X=q.3e;id=k.1p(X,\'id\');if(k.2A.5E[id]!=U){1V.6c(k.2A.5E[id])}1z=X.L.3x+1;if(X.L.1Q.1h<1z){1z=1}1Q=k(\'1U\',X.L.5F);X.L.3x=1z;if(1Q.1P()>0){1Q.7k(X.L.3V,k.2A.8B)}},eG:u(){q.5I();X=q.3e;id=k.1p(X,\'id\');if(k.2A.5E[id]!=U){1V.6c(k.2A.5E[id])}1z=X.L.3x-1;1Q=k(\'1U\',X.L.5F);if(1z<1){1z=X.L.1Q.1h}X.L.3x=1z;if(1Q.1P()>0){1Q.7k(X.L.3V,k.2A.8B)}},2H:u(c){X=1j.cP(c);if(X.L.6w){1z=X.L.3x;7o(1z==X.L.3x){1z=1+T(14.6w()*X.L.1Q.1h)}}P{1z=X.L.3x+1;if(X.L.1Q.1h<1z){1z=1}}1Q=k(\'1U\',X.L.5F);X.L.3x=1z;if(1Q.1P()>0){1Q.7k(X.L.3V,k.2A.8B)}},go:u(o){D X;if(o&&o.1K==7n){if(o.2a){X=1j.cP(o.2a.X);6b=1V.kK.3f.7h("#");o.2a.6B=U;if(6b.1h==2){1z=T(6b[1]);22=6b[1].4v(1z,\'\');if(k.1p(X,\'id\')!=22){1z=1}}P{1z=1}}if(o.8A){o.8A.5I();X=o.8A.3e.3e;id=k.1p(X,\'id\');if(k.2A.5E[id]!=U){1V.6c(k.2A.5E[id])}6b=o.8A.3f.7h("#");1z=T(6b[1]);22=6b[1].4v(1z,\'\');if(k.1p(X,\'id\')!=22){1z=1}}if(X.L.1Q.1h<1z||1z<1){1z=1}X.L.3x=1z;5h=k.1a.2p(X);e8=k.1a.aj(X);e9=k.1a.6h(X);if(X.L.3s){X.L.3s.o.B(\'19\',\'1n\')}if(X.L.3r){X.L.3r.o.B(\'19\',\'1n\')}if(X.L.2a){y=T(e8.t)+T(e9.t);if(X.L.1T){if(X.L.1T.5z==\'Q\'){y+=X.L.1T.4q.hb}P{5h.h-=X.L.1T.4q.hb}}if(X.L.2w){if(X.L.2w&&X.L.2w.6s==\'Q\'){y+=X.L.2w.4q.hb}P{5h.h-=X.L.2w.4q.hb}}if(!X.L.cV){X.L.eg=o.2a?o.2a.V:(T(X.L.2a.B(\'V\'))||0);X.L.cV=o.2a?o.2a.Z:(T(X.L.2a.B(\'Z\'))||0)}X.L.2a.B(\'Q\',y+(5h.h-X.L.eg)/2+\'S\');X.L.2a.B(\'O\',(5h.1D-X.L.cV)/2+\'S\');X.L.2a.B(\'19\',\'2E\')}1Q=k(\'1U\',X.L.5F);if(1Q.1P()>0){1Q.7k(X.L.3V,k.2A.8B)}P{aP=k(\'a\',X.L.1T.o).K(1z-1);k(aP).2Z(X.L.1T.64);D 1U=11 aH();1U.X=k.1p(X,\'id\');1U.1z=1z-1;1U.2M=X.L.1Q[X.L.3x-1].2M;if(1U.23){1U.6B=U;k.2A.19.1F(1U)}P{1U.6B=k.2A.19}if(X.L.2w){X.L.2w.o.3w(X.L.1Q[1z-1].6v)}}}},8B:u(){X=q.3e.3e;X.L.5F.B(\'19\',\'1n\');if(X.L.1T.64){aP=k(\'a\',X.L.1T.o).4p(X.L.1T.64).K(X.L.3x-1);k(aP).2Z(X.L.1T.64)}D 1U=11 aH();1U.X=k.1p(X,\'id\');1U.1z=X.L.3x-1;1U.2M=X.L.1Q[X.L.3x-1].2M;if(1U.23){1U.6B=U;k.2A.19.1F(1U)}P{1U.6B=k.2A.19}if(X.L.2w){X.L.2w.o.3w(X.L.1Q[X.L.3x-1].6v)}},19:u(){X=1j.cP(q.X);if(X.L.3s){X.L.3s.o.B(\'19\',\'1n\')}if(X.L.3r){X.L.3r.o.B(\'19\',\'1n\')}5h=k.1a.2p(X);y=0;if(X.L.1T){if(X.L.1T.5z==\'Q\'){y+=X.L.1T.4q.hb}P{5h.h-=X.L.1T.4q.hb}}if(X.L.2w){if(X.L.2w&&X.L.2w.6s==\'Q\'){y+=X.L.2w.4q.hb}P{5h.h-=X.L.2w.4q.hb}}kD=k(\'.cz\',X);y=y+(5h.h-q.V)/2;x=(5h.1D-q.Z)/2;X.L.5F.B(\'Q\',y+\'S\').B(\'O\',x+\'S\').3w(\'<1U 2M="\'+q.2M+\'" />\');X.L.5F.7m(X.L.3V);3r=X.L.3x+1;if(3r>X.L.1Q.1h){3r=1}3s=X.L.3x-1;if(3s<1){3s=X.L.1Q.1h}X.L.3r.o.B(\'19\',\'2E\').B(\'Q\',y+\'S\').B(\'O\',x+2*q.Z/3+\'S\').B(\'Z\',q.Z/3+\'S\').B(\'V\',q.V+\'S\').1p(\'45\',X.L.1Q[3r-1].6v);X.L.3r.o.K(0).3f=\'#\'+3r+k.1p(X,\'id\');X.L.3s.o.B(\'19\',\'2E\').B(\'Q\',y+\'S\').B(\'O\',x+\'S\').B(\'Z\',q.Z/3+\'S\').B(\'V\',q.V+\'S\').1p(\'45\',X.L.1Q[3s-1].6v);X.L.3s.o.K(0).3f=\'#\'+3s+k.1p(X,\'id\')},2s:u(o){if(!o||!o.1Z||k.2A.5E[o.1Z])E;D 1Z=k(\'#\'+o.1Z);D el=1Z.K(0);if(el.18.Y!=\'1O\'&&el.18.Y!=\'2y\'){el.18.Y=\'2y\'}el.18.2Y=\'2O\';if(1Z.1P()==0)E;el.L={};el.L.1Q=o.1Q?o.1Q:[];el.L.6w=o.6w&&o.6w==1b||I;8b=el.dU(\'kA\');1Y(i=0;i<8b.1h;i++){7I=el.L.1Q.1h;el.L.1Q[7I]={2M:8b[i].2M,6v:8b[i].45||8b[i].kC||\'\'}}if(el.L.1Q.1h==0){E}el.L.4m=k.21(k.1a.2R(el),k.1a.2p(el));el.L.d5=k.1a.aj(el);el.L.cL=k.1a.6h(el);t=T(el.L.d5.t)+T(el.L.cL.t);b=T(el.L.d5.b)+T(el.L.cL.b);k(\'1U\',el).aB();el.L.3V=o.3V?o.3V:er;if(o.5z||o.88||o.64){el.L.1T={};1Z.1R(\'<26 6A="eL">\');el.L.1T.o=k(\'.eL\',el);if(o.88){el.L.1T.88=o.88;el.L.1T.o.2Z(o.88)}if(o.64){el.L.1T.64=o.64}el.L.1T.o.B(\'Y\',\'1O\').B(\'Z\',el.L.4m.w+\'S\');if(o.5z&&o.5z==\'Q\'){el.L.1T.5z=\'Q\';el.L.1T.o.B(\'Q\',t+\'S\')}P{el.L.1T.5z=\'4l\';el.L.1T.o.B(\'4l\',b+\'S\')}el.L.1T.au=o.au?o.au:\' \';1Y(D i=0;i\'+7I+\'\'+(7I!=el.L.1Q.1h?el.L.1T.au:\'\'))}k(\'a\',el.L.1T.o).1H(\'5G\',u(){k.2A.go({8A:q})});el.L.1T.4q=k.1a.2p(el.L.1T.o.K(0))}if(o.6s||o.8l){el.L.2w={};1Z.1R(\'<26 6A="eK">&7J;\');el.L.2w.o=k(\'.eK\',el);if(o.8l){el.L.2w.8l=o.8l;el.L.2w.o.2Z(o.8l)}el.L.2w.o.B(\'Y\',\'1O\').B(\'Z\',el.L.4m.w+\'S\');if(o.6s&&o.6s==\'Q\'){el.L.2w.6s=\'Q\';el.L.2w.o.B(\'Q\',(el.L.1T&&el.L.1T.5z==\'Q\'?el.L.1T.4q.hb+t:t)+\'S\')}P{el.L.2w.6s=\'4l\';el.L.2w.o.B(\'4l\',(el.L.1T&&el.L.1T.5z==\'4l\'?el.L.1T.4q.hb+b:b)+\'S\')}el.L.2w.4q=k.1a.2p(el.L.2w.o.K(0))}if(o.az){el.L.3r={az:o.az};1Z.1R(\'&7J;\');el.L.3r.o=k(\'.eR\',el);el.L.3r.o.B(\'Y\',\'1O\').B(\'19\',\'1n\').B(\'2Y\',\'2O\').B(\'4w\',\'eB\').2Z(el.L.3r.az);el.L.3r.o.1H(\'5G\',k.2A.eS)}if(o.av){el.L.3s={av:o.av};1Z.1R(\'&7J;\');el.L.3s.o=k(\'.ev\',el);el.L.3s.o.B(\'Y\',\'1O\').B(\'19\',\'1n\').B(\'2Y\',\'2O\').B(\'4w\',\'eB\').2Z(el.L.3s.av);el.L.3s.o.1H(\'5G\',k.2A.eG)}1Z.cA(\'<26 6A="cz">\');el.L.5F=k(\'.cz\',el);el.L.5F.B(\'Y\',\'1O\').B(\'Q\',\'3c\').B(\'O\',\'3c\').B(\'19\',\'1n\');if(o.2a){1Z.cA(\'<26 6A="eD" 18="19: 1n;"><1U 2M="\'+o.2a+\'" />\');el.L.2a=k(\'.eD\',el);el.L.2a.B(\'Y\',\'1O\');D 1U=11 aH();1U.X=o.1Z;1U.2M=o.2a;if(1U.23){1U.6B=U;k.2A.go({2a:1U})}P{1U.6B=u(){k.2A.go({2a:q})}}}P{k.2A.go({1Z:el})}if(o.cB){do=T(o.cB)*aF}k.2A.5E[o.1Z]=o.cB?1V.6I(\'k.2A.2H(\\\'\'+o.1Z+\'\\\')\',do):U}};k.X=k.2A.2s;k.8e={cN:u(e){3O=e.7F||e.7A||-1;if(3O==9){if(1V.2l){1V.2l.cj=1b;1V.2l.ci=I}P{e.al();e.am()}if(q.aI){1j.6G.du().31="\\t";q.dv=u(){q.6D();q.dv=U}}P if(q.aU){28=q.5B;2X=q.dq;q.2v=q.2v.iL(0,28)+"\\t"+q.2v.hm(2X);q.aU(28+1,28+1);q.6D()}E I}},58:u(){E q.1B(u(){if(q.7D&&q.7D==1b){k(q).3p(\'7E\',k.8e.cN);q.7D=I}})},2s:u(){E q.1B(u(){if(q.4S==\'cQ\'&&(!q.7D||q.7D==I)){k(q).1H(\'7E\',k.8e.cN);q.7D=1b}})}};k.fn.21({hS:k.8e.2s,hP:k.8e.58});',62,1292,'||||||||||||||||||||jQuery||||||this||||function||||||dragCfg|css|elm|var|return|dragged|easing|speed|false|callback|get|ss|options|iAuto|left|else|top|iResize|px|parseInt|null|height|oldStyle|slideshow|position|width||new|iDrag||Math||||style|display|iUtil|true|helper|subject|case|autoCFG|resizeOptions|length|dropCfg|document|iEL|carouselCfg|duration|none|interfaceFX|attr|sizes|break|pointer|iSort|type|ImageBox|queue|iDrop|iAutoscroller|slide|resizeElement|each|oC|wb|newSizes|apply|fisheyeCfg|bind|delta|opacity|constructor|custom|pos|axis|absolute|size|images|append|items|slideslinks|img|window|firstNum|255|for|container||extend|show|complete|cont||div||start|elsToScroll|loader|100|oR||body|oldP|selectedItem|typeof|elem|accordionCfg|props|event|parseFloat|newPosition|containment|getSize|field|ny|build|iTooltip|selectHelper|value|slideCaption|nx|relative|tp|islideshow|border|Function|step|block|itemWidth|hide|timer|nr|limit|fractions|dequeue|src|right|hidden|direction|PI|getPosition|cursorAt|onChange|onShow|scrollTop|result|end|overflow|addClass|parentData|text|||||||||scr|className|0px|iSlider|parentNode|href|scrollLeft|browser|onHide|visibility|item|pre|switch|selectdrug|wrapper|unbind|newCoords|nextslide|prevslide|createElement|values|max|html|currentslide|handle|onSlide|margins|zIndex|wrs|min|iframe|indexOf|valueToAdd|mousemove|pageSize|zones|multipleSeparator|iExpander|curCSS|canvas|pressedKey|accept|resizeDirection|abs|onStop|diff|handlers|fadeDuration|highlighted|dhs|toggle|dragElem||times||test|getPointer|title|distance||so|vp|horizontally|offsetWidth|startLeft|out|transferEl|startTop|subjectValue|lastSuggestion|vertically|ghosting|DropOutDirectiont|bottom|oP|iteration|lastValue|removeClass|dimm|slideCfg|ifxFirstDisplay|currentPointer|clear|replace|fontSize|onDrag|down|percent|onStart|nWidth|color|ratio|elToScroll|fieldData|rel|context|msie|documentElement|params|to|shs|dragHandle|fxCheckTag|els|nextImage|prevImage|tagName|tooltipCFG|up|helperclass|endLeft|paddingLeft|currentStyle|borderTopWidth||halign|onclick|delay|nodeEl||chunks|endTop|destroy|dragmoveBy|borderLeftWidth|mousedown|nHeight|from|dhe|containerW|string|slidePos|si|collected|marginLeft|overzone|marginBottom|getAttribute|marginTop|marginRight|toAdd|zonex|clonedEl|empty|newStyles|cos|hight|toWrite|zoney|linksPosition|OpenClose|selectionStart|clientScroll|cnt|slideshows|holder|click|restoreStyle|blur|onDragModifier|animate|elS|paddingBottom|toDrag|sw|close|post|animationHandler|styles|containerH|prop|sortCfg|BlindDirection|nmp|pow|toLowerCase||mouseup|oldVisibility|offsetHeight|activeLinkClass|old|paddingTop|grid|point|filter|onSelect|url|clearInterval|fxh|currentPanel|elementData|borderBottomWidth|getBorder|cur|paddingRight|borderRightWidth|puff|snapDistance|tolerance|revert|hpc|maxWidth|currentRel|captionPosition|Expander|orig|caption|random|3000|iFisheye|Scale|class|onload|wr|focus|restore|128|selection|parseColor|setInterval|current|selRange|captionText|itemHeight|outerContainer|newDimensions|totalImages|getHeight|reflections|keyup|sliders|imageEl|getWidth|getScroll|margin|Draggable|onHighlight|selectClass|getTime|Date|oldStyleAttr|onClick||scrollIntoView|firstChild||data|ActiveXObject|Array|focused|accordionPos|open|backgroundColor|zoneh|split|oD|zonew|fadeOut|user|fadeIn|Object|while|minLeft|nw|startDrag|minTop|captionEl|newTop|newLeft|frameClass|increment|F0|0x|keyCode|139|toInteger|hasTabsEnabled|keydown|charCode|cssRules|rule|indic|nbsp|rgb|np|oldDisplay|opera|radiusY|positionItems|onOut|proximity|efx|onHover|hash|changed|init|sc|inFrontOf|selectKeyHelper||selectCurrent|getSizeLite|1px|contBorders||ts|parentEl|linksClass|parentBorders|yproc|imgs|nRx|fnc|iTTabs|panels|insideParent|fontWeight|object|nRy|clientWidth|captionClass|namedColors|offsetLeft|serialize|cssSides|mouseout|activeClass|targetEl|offsetTop|expand|stop|400|pr|directionIncrement|clientHeight|link|showImage|move|sx|containerSize|createTextNode|jEl|imageSrc|ser|newPos|selectedone|minHeight|maxHeight|gallery|dir|applyOn|overlay|sh|content|maxRight|maxBottom|tooltipHelper|count|onselectstop|onselect|select|li|reflectionSize|padding|selectBorders|cursor|png|parent|finishedPre|sin|xproc|ImageBoxPrevImage|ImageBoxNextImage|bounceout|animationInProgress|opened|sy|destroyWrapper|buildWrapper|diffWidth|diffHeight|iIndex|diffX|diffY|prot|hidehelper|dEs|isDraggable|onDrop|minWidth|side|isDroppable|onActivate|dragstop|startTime|211|192|nodeName|self|oldPosition|exec|opt|getValues|styleSheets|sideEnd|borderColor|ne|handleEl|unit|DoFold|5625|oldTitle|SliderContainer|unfold|9999|ScrollTo|cssText|oldColor|alpha|2000|prev|selectKeyUp|os|selectKeyDown|selectcheck|dragEl|checkhover|DraggableDestroy|next|key|hoverclass|activeclass|sl|st|image||panelSelector|headerSelector|hoverClass|panelHeight|hideImage|headers|getPadding|iCarousel|preventDefault|stopPropagation|itemMinWidth|auto|getFieldValues|ImageBoxOuterContainer|prevEl|nextImageEl|linkRel|linksSeparator|prevslideClass|progid|DXImageTransform|Microsoft|nextslideClass|valToAdd|remove|prevImageEl|nextEl|childs|1000|default|Image|createTextRange|positionContainer|helperClass|minchars|source|itemsText|multiple|lnk|posx|autofill|reflexions|blind|setSelectionRange|mouseover|inCache|ul|protectRotation|maxRotation|gradient|setTimeout|index|elPosition|writeItems|String|ImageBoxIframe|transparent|center|textAlign|paddingRightSize|paddingTopSize|bounce|loadImage|borderLeftSize|borderBottomSize|borderRightSize|ImageBoxCaption|ImageBoxCurrentImage|moveDrag|ImageBoxOverlay|paddings|borders|idsa|firstStep|currentValue|getClient||stopDrag|borderTopSize|autocomplete|zoom|300|hidefocused|intersect|INPUT|inputWidth|fade|extraWidth|sortable|restricted|isSlider|tabindex|fitToContainer|snapToGrid|slider|prevTop|prevLeft|floats|getPositionLite|modifyContainer|getContainment|lastSi|SliderIteration|sliderEl|selectstop|match|linear|character|no|bouncein|captionImages|asin|Alpha|Selectserialize|mouse|initialPosition|measure|clearTimeout|helperSize|getMargins|tooltipURL|keyPressed|applyOnHover|closeEl|10000|parentPos|sliderSize|sliderPos|angle|returnValue|cancelBubble|spacer|oldBorder|pulse|169|entities|RegExp|Color|Pulsate||rotationSpeed|parseStyle|stopAnim|cssSidesEnd|shake|Shake|slideshowHolder|prepend|autoplay|floatVal|borderWidth|scroll|paddingY|pValue|letterSpacing|paddingX|paddingBottomSize|pause|oBor|clnt|doTab|autoSize|getElementById|TEXTAREA|Number|traverseDOM|func|draginit|loaderWidth|scrollHeight|paddingLeftSize|scrollWidth|oneIsSortable|innerWidth|innerHeight|shrink|windowSize|unselectable|oPad|dragmove|oldFloat|cssProps|colorCssProps|107|doScroll|addItem|SortableAddItem||DroppableDestroy|fxe||interval|after|insertBefore||sqrt|cloneNode|time|check|selectionEnd|offsetParent|Width|sortHelper|createRange|onblur|valign|||onout|224|posy|wid|isSortable|165|zindex|245|notColor|140|240|230|144|styleFloat|onhover|Droppable|emptyGIF|relAttr|visible|captionSize|dragstart|getElementsByTagName|listStyle|dragHelper|getHeightMinMax|onResize|ImageBoxCaptionText|ImageBoxContainer|ImageBoxCaptionImages||textImage|clientSize|textImageFrom|userSelect|onDragStop|slidePad|slideBor|highlight|shc|hlt|checkdrop|fit||loaderHeight||onDragStart|KhtmlUserSelect|remeasure|||on|fadeTo|ImageBoxLoader||500|||imageTypes|slideshowPrevslide|javascript|selectstopApply|scrolling|frameborder|hrefAttr|30px|jpg|slideshowLoader|selectedclass|gif|goprev|oldOverflow|isFunction|imagebox|slideshowCaption|slideshowLinks|directions|overlayOpacity|se|trim|textDecoration|slideshowNextSlide|gonext|closeHTML|selectcheckApply|loaderSRC|selectstart|isSelectable|360|radiusX|set|grow|hoverItem|SlideOutUp|leftUnit|boxModel|interfaceColorFX|fakeAccordionClass|togglever|elType|iBounce|paddingBottomUnit|wordSpacing|150|mousex|iAccordion|fontFamily|togglehor|fontUnit|filteredPosition|paddingTopUnit|parte|itemZIndex||selRange2|finish|paddingLeftUnit|moveStart|paddingRightUnit|xml|itransferTo|borderLeftUnit|borderTopUnit||update|BlindUp||borderRightUnit|checkCache|getSelectionStart|borderBottomUnit|tooltipTitle|easeout|expanderHelper|fontStyle|fontStretch|containerMaxx|yfrac|topUnit|containerMaxy|clickItem|BlindDown|off|inputValue|fracH|fontVariant|rgba|maxy|maxx|keypress|fracW|xfrac|horizontal|addColorStop|htmlEntities|vertical|dragmoveByKey|autocompleteIframe|onslide|fold|parts|SlideInUp|getContext|protect|autocompleteHelper|olive|orange|pink|white|maroon|navy|magenta|203|193|rotationTimer|lightpink||red|lightyellow|182|lime||purple|silver|Top|||inset|outset|SlideOutRight|SlideInRight|ridge|groove|dashed|solid|double|SlideToggleLeft|SlideOutLeft|SlideOutDown|SlideInDown|SlideToggleUp|scrollTo|selectorText|rules|borderStyle|SlideInLeft|SlideToggleDown|dotted|SlideToggleRight|textIndent|borderBottomColor|borderLeftColor|borderRightColor|outlineWidth|outlineOffset|TransferTo|transferHelper|lineHeight|borderTopColor|outlineColor|hover|Accordion|isNaN|Carousel|stopAll|||Right|Bottom|Left|yellow|215|option|frameset|optgroup|meta|substr|frame|script|col|colgroup||th|header|removeChild|float|ol|finishx|fxWrapper|starty|table|form|w_|input|textarea|button|tfoot|thead|pageX|drawImage|clientX|pageY|clientY|globalCompositeOperation|destination|DisableTabs|createLinearGradient|fillStyle|EnableTabs|scale|nextSibling|prototype|tr|td|tbody|AlphaImageLoader|fixPNG|purgeEvents|translate|centerEl|save|cssFloat|startx|fuchsia|148|gold|green|indigo|darkviolet||122||204||darkred|darksalmon|233|130|khaki||lightcyan|lightgreen|238|fillRect||fill|216|appVersion||WebKit|lightblue|173|153|darkorchid|black|220|blue|brown|cyan|beige|azure|finishOpacity|appendChild|substring|aqua|darkblue|darkcyan|darkmagenta|darkolivegreen|navigator|darkorange|183|189|darkgrey|flipv|darkgreen|darkkhaki|lightgrey|amp|BlindToggleHorizontally|BlindRight|BlindLeft|ResizableDestroy|Resizable|120|lineHeigt|collapse|BlindToggleVertically|moveEnd|elasticin|bounceboth|984375|elasticout|elasticboth|duplicate|ImageBoxClose|DropOutDown|DropInDown|load|DropToggleRight|DropInRight|Fold|UnFold|Shrink|Grow|FoldToggle|DropOutRight|DropToggleLeft|DropInUp|DropOutUp|DropToggleDown|DropToggleUp|DropOutLeft|DropInLeft|captiontext|625|9375|Fisheye|30001|list|loading|fix|imageLoaded|childNodes|Showing|onchange|30002|SortSerialize|Autocomplete|200|SortableDestroy|Sortable|resize|wh|firstResize|Slider|bmp|100000|jpeg|Selectable|ToolTip|easeboth|easein|nodeValue|http|first|before|last|112|SliderSetValues|110|SliderGetValues|array|Bounce|Autoexpand|onselectstart|CloseVertically|mozUserSelect|fromHandler|ondragstart|MozUserSelect|number|pW|toUpperCase|khtml|find|CloseHorizontally|SwitchHorizontally|ScrollToAnchors|Puff|slideshowLink|password|quot|OpenHorizontally|OpenVertically|SwitchVertically|IMG|lt|alt|par|moz|success|POST|recallDroppables|param|pt|location|Highlight|100000000|ajax|ondrop|name'.split('|'),0,{})) Property changes on: branches/Interpolate1D/docs/build/html/_static/interface.js ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/jquery.js =================================================================== --- branches/Interpolate1D/docs/build/html/_static/jquery.js 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/jquery.js 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,32 @@ +/* + * jQuery 1.2.3 - New Wave Javascript + * + * Copyright (c) 2008 John Resig (jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * $Date: 2008-02-06 00:21:25 -0500 (Wed, 06 Feb 2008) $ + * $Rev: 4663 $ + */ +(function(){if(window.jQuery)var _jQuery=window.jQuery;var jQuery=window.jQuery=function(selector,context){return new jQuery.prototype.init(selector,context);};if(window.$)var _$=window.$;window.$=jQuery;var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;var isSimple=/^.[^:#\[\.]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}else if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem)if(elem.id!=match[3])return jQuery().find(selector);else{this[0]=elem;this.length=1;return this;}else +selector=[];}}else +return new jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return new jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(selector.constructor==Array&&selector||(selector.jquery||selector.length&&selector!=window&&!selector.nodeType&&selector[0]!=undefined&&selector[0].nodeType)&&jQuery.makeArray(selector)||[selector]);},jquery:"1.2.3",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;this.each(function(i){if(this==elem)ret=i;});return ret;},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value==undefined)return this.length&&jQuery[type||"attr"](this[0],name)||undefined;else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else +return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else +selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return!selector?this:this.pushStack(jQuery.merge(this.get(),selector.constructor==String?jQuery(selector).get():selector.length!=undefined&&(!selector.nodeName||jQuery.nodeName(selector,"form"))?selector:[selector]));},is:function(selector){return selector?jQuery.multiFilter(selector,this).length>0:false;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=value.constructor==Array?value:[value];jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else +this.value=value;});},html:function(value){return value==undefined?(this.length?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value==null){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data==undefined&&this.length)data=jQuery.data(this[0],key);return data==null&&parts[1]?this.data(parts[0]):data;}else +return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script")){scripts=scripts.add(elem);}else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.prototype.init.prototype=jQuery.prototype;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else +jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==1){target=this;i=0;}for(;i-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else +jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret;function color(elem){if(!jQuery.browser.safari)return false;var ret=document.defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(elem.style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=elem.style.outline;elem.style.outline="0 solid black";elem.style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&elem.style&&elem.style[name])ret=elem.style[name];else if(document.defaultView&&document.defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var getComputedStyle=document.defaultView.getComputedStyle(elem,null);if(getComputedStyle&&!color(elem))ret=getComputedStyle.getPropertyValue(name);else{var swap=[],stack=[];for(var a=elem;a&&color(a);a=a.parentNode)stack.unshift(a);for(var i=0;i]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("",""]||!tags.indexOf("",""]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!tags.indexOf("",""]||(!tags.indexOf("",""]||!tags.indexOf("",""]||jQuery.browser.msie&&[1,"div
","
"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf(""&&tags.indexOf("=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else +ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var fix=jQuery.isXMLDoc(elem)?{}:jQuery.props;if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(fix[name]){if(value!=undefined)elem[fix[name]]=value;return elem[fix[name]];}else if(jQuery.browser.msie&&name=="style")return jQuery.attr(elem.style,"cssText",value);else if(value==undefined&&jQuery.browser.msie&&jQuery.nodeName(elem,"form")&&(name=="action"||name=="method"))return elem.getAttributeNode(name).nodeValue;else if(elem.tagName){if(value!=undefined){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem.setAttribute(name,""+value);}if(jQuery.browser.msie&&/href|src/.test(name)&&!jQuery.isXMLDoc(elem))return elem.getAttribute(name,2);return elem.getAttribute(name);}else{if(name=="opacity"&&jQuery.browser.msie){if(value!=undefined){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseFloat(value).toString()=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100).toString():"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(value!=undefined)elem[name]=value;return elem[name];}},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(typeof array!="array")for(var i=0,length=array.length;i*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return im[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false;var re=quickChild;var m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[];var cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&(!elem||n!=elem))r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval!=undefined)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=function(){return fn.apply(this,arguments);};handler.data=data;handler.guid=fn.guid;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){var val;if(typeof jQuery=="undefined"||jQuery.event.triggered)return val;val=jQuery.event.handle.apply(arguments.callee.elem,arguments);return val;});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else +for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data||[]);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event)data.unshift(this.fix({type:type,target:elem}));data[0].type=type;if(exclusive)data[0].exclusive=true;if(jQuery.isFunction(jQuery.data(elem,"handle")))val=jQuery.data(elem,"handle").apply(elem,data);if(!fn&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val;event=jQuery.event.fix(event||window.event||{});var parts=event.type.split(".");event.type=parts[0];var handlers=jQuery.data(this,"events")&&jQuery.data(this,"events")[event.type],args=Array.prototype.slice.call(arguments,1);args.unshift(event);for(var j in handlers){var handler=handlers[j];args[0].handler=handler;args[0].data=handler.data;if(!parts[1]&&!event.exclusive||handler.type==parts[1]){var ret=handler.apply(this,args);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}if(jQuery.browser.msie)event.target=event.preventDefault=event.stopPropagation=event.handler=event.data=null;return val;},fix:function(event){var originalEvent=event;event=jQuery.extend({},originalEvent);event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=originalEvent.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){return this.each(function(){jQuery.event.add(this,type,function(event){jQuery(this).unbind(event);return(fn||data).apply(this,arguments);},fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){if(this[0])return jQuery.event.trigger(type,data,this[0],false,fn);return undefined;},toggle:function(){var args=arguments;return this.click(function(event){this.lastToggle=0==this.lastToggle?1:0;event.preventDefault();return args[this.lastToggle].apply(this,arguments)||false;});},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else +jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.apply(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("
").append(res.responseText.replace(//g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=(new Date).getTime();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){var jsonp,jsre=/=\?(&|$)/g,status,data;s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(s.type.toLowerCase()=="get"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&s.type.toLowerCase()=="get"){var ts=(new Date()).getTime();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&s.type.toLowerCase()=="get"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");if((!s.url.indexOf("http")||!s.url.indexOf("//"))&&s.dataType=="script"&&s.type.toLowerCase()=="get"){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xml=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();xml.open(s.type,s.url,s.async,s.username,s.password);try{if(s.data)xml.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xml.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xml.setRequestHeader("X-Requested-With","XMLHttpRequest");xml.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend)s.beforeSend(xml);if(s.global)jQuery.event.trigger("ajaxSend",[xml,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xml&&(xml.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xml)&&"error"||s.ifModified&&jQuery.httpNotModified(xml,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xml,s.dataType);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xml.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else +jQuery.handleError(s,xml,status);complete();if(s.async)xml=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xml){xml.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xml.send(s.data);}catch(e){jQuery.handleError(s,xml,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xml,s]);}function complete(){if(s.complete)s.complete(xml,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xml,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xml;},handleError:function(s,xml,status,e){if(s.error)s.error(xml,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xml,s,e]);},active:0,httpSuccess:function(r){try{return!r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||r.status==1223||jQuery.browser.safari&&r.status==undefined;}catch(e){}return false;},httpNotModified:function(xml,url){try{var xmlRes=xml.getResponseHeader("Last-Modified");return xml.status==304||xmlRes==jQuery.lastModified[url]||jQuery.browser.safari&&xml.status==undefined;}catch(e){}return false;},httpData:function(r,type){var ct=r.getResponseHeader("content-type");var xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0;var data=xml?r.responseXML:r.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else +for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else +s.push(encodeURIComponent(j)+"="+encodeURIComponent(a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle(fn,fn2):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall);var hidden=jQuery(this).is(":hidden"),self=this;for(var p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return jQuery.isFunction(opt.complete)&&opt.complete.apply(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else +e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.apply(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(!elem)return undefined;type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",array?jQuery.makeArray(array):[]);return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].apply(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:{slow:600,fast:200}[opt.duration])||400;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.apply(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.apply(this.elem,[this.now,this]);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=(new Date()).getTime();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;ithis.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done&&jQuery.isFunction(this.options.complete))this.options.complete.apply(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.fx.step={scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}};jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),fixed=jQuery.css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&jQuery.css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(jQuery.css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&jQuery.css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||jQuery.css(offsetChild,"position")=="absolute"))||(mozilla&&jQuery.css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l)||0;top+=parseInt(t)||0;}return results;};})(); \ No newline at end of file Property changes on: branches/Interpolate1D/docs/build/html/_static/jquery.js ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/minus.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_static/minus.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_static/navigation.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_static/navigation.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_static/plus.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/build/html/_static/plus.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/build/html/_static/pygments.css =================================================================== --- branches/Interpolate1D/docs/build/html/_static/pygments.css 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/pygments.css 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,59 @@ +.c { color: #408090; font-style: italic } /* Comment */ +.err { border: 1px solid #FF0000 } /* Error */ +.k { color: #007020; font-weight: bold } /* Keyword */ +.o { color: #666666 } /* Operator */ +.cm { color: #408090; font-style: italic } /* Comment.Multiline */ +.cp { color: #007020 } /* Comment.Preproc */ +.c1 { color: #408090; font-style: italic } /* Comment.Single */ +.cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ +.gd { color: #A00000 } /* Generic.Deleted */ +.ge { font-style: italic } /* Generic.Emph */ +.gr { color: #FF0000 } /* Generic.Error */ +.gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.gi { color: #00A000 } /* Generic.Inserted */ +.go { color: #303030 } /* Generic.Output */ +.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ +.gs { font-weight: bold } /* Generic.Strong */ +.gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.gt { color: #0040D0 } /* Generic.Traceback */ +.kc { color: #007020; font-weight: bold } /* Keyword.Constant */ +.kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ +.kp { color: #007020 } /* Keyword.Pseudo */ +.kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ +.kt { color: #902000 } /* Keyword.Type */ +.m { color: #208050 } /* Literal.Number */ +.s { color: #4070a0 } /* Literal.String */ +.na { color: #4070a0 } /* Name.Attribute */ +.nb { color: #007020 } /* Name.Builtin */ +.nc { color: #0e84b5; font-weight: bold } /* Name.Class */ +.no { color: #60add5 } /* Name.Constant */ +.nd { color: #555555; font-weight: bold } /* Name.Decorator */ +.ni { color: #d55537; font-weight: bold } /* Name.Entity */ +.ne { color: #007020 } /* Name.Exception */ +.nf { color: #06287e } /* Name.Function */ +.nl { color: #002070; font-weight: bold } /* Name.Label */ +.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ +.nt { color: #062873; font-weight: bold } /* Name.Tag */ +.nv { color: #bb60d5 } /* Name.Variable */ +.ow { color: #007020; font-weight: bold } /* Operator.Word */ +.w { color: #bbbbbb } /* Text.Whitespace */ +.mf { color: #208050 } /* Literal.Number.Float */ +.mh { color: #208050 } /* Literal.Number.Hex */ +.mi { color: #208050 } /* Literal.Number.Integer */ +.mo { color: #208050 } /* Literal.Number.Oct */ +.sb { color: #4070a0 } /* Literal.String.Backtick */ +.sc { color: #4070a0 } /* Literal.String.Char */ +.sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ +.s2 { color: #4070a0 } /* Literal.String.Double */ +.se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ +.sh { color: #4070a0 } /* Literal.String.Heredoc */ +.si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ +.sx { color: #c65d09 } /* Literal.String.Other */ +.sr { color: #235388 } /* Literal.String.Regex */ +.s1 { color: #4070a0 } /* Literal.String.Single */ +.ss { color: #517918 } /* Literal.String.Symbol */ +.bp { color: #007020 } /* Name.Builtin.Pseudo */ +.vc { color: #bb60d5 } /* Name.Variable.Class */ +.vg { color: #bb60d5 } /* Name.Variable.Global */ +.vi { color: #bb60d5 } /* Name.Variable.Instance */ +.il { color: #208050 } /* Literal.Number.Integer.Long */ \ No newline at end of file Property changes on: branches/Interpolate1D/docs/build/html/_static/pygments.css ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/rightsidebar.css =================================================================== --- branches/Interpolate1D/docs/build/html/_static/rightsidebar.css 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/rightsidebar.css 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,16 @@ +/** + * Sphinx Doc Design -- Right Side Bar Overrides + */ + + +div.sphinxsidebar { + float: right; +} + +div.bodywrapper { + margin: 0 230px 0 0; +} + +div.inlinecomments { + right: 250px; +} Property changes on: branches/Interpolate1D/docs/build/html/_static/rightsidebar.css ___________________________________________________________________ Name: svn:executable + * Added: branches/Interpolate1D/docs/build/html/_static/searchtools.js =================================================================== --- branches/Interpolate1D/docs/build/html/_static/searchtools.js 2008-07-30 20:11:37 UTC (rev 4581) +++ branches/Interpolate1D/docs/build/html/_static/searchtools.js 2008-07-30 20:14:30 UTC (rev 4582) @@ -0,0 +1,404 @@ +/** + * helper function to return a node containing the + * search summary for a given text. keywords is a list + * of stemmed words, hlwords is the list of normal, unstemmed + * words. the first one is used to find the occurance, the + * latter for highlighting it. + */ +jQuery.makeSearchSummary = function(text, keywords, hlwords) { + var textLower = text.toLowerCase(); + var start = 0; + $.each(keywords, function() { + var i = textLower.indexOf(this.toLowerCase()); + if (i > -1) { + start = i; + } + }); + start = Math.max(start - 120, 0); + var excerpt = ((start > 0) ? '...' : '') + + $.trim(text.substr(start, 240)) + + ((start + 240 - text.length) ? '...' : ''); + var rv = $('
').text(excerpt); + $.each(hlwords, function() { + rv = rv.highlightText(this, 'highlight'); + }); + return rv; +} + +/** + * Porter Stemmer + */ +var PorterStemmer = function() { + + var step2list = { + ational: 'ate', + tional: 'tion', + enci: 'ence', + anci: 'ance', + izer: 'ize', + bli: 'ble', + alli: 'al', + entli: 'ent', + eli: 'e', + ousli: 'ous', + ization: 'ize', + ation: 'ate', + ator: 'ate', + alism: 'al', + iveness: 'ive', + fulness: 'ful', + ousness: 'ous', + aliti: 'al', + iviti: 'ive', + biliti: 'ble', + logi: 'log' + }; + + var step3list = { + icate: 'ic', + ative: '', + alize: 'al', + iciti: 'ic', + ical: 'ic', + ful: '', + ness: '' + }; + + var c = "[^aeiou]"; // consonant + var v = "[aeiouy]"; // vowel + var C = c + "[^aeiouy]*"; // consonant sequence + var V = v + "[aeiou]*"; // vowel sequence + + var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 + var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 + var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 + var s_v = "^(" + C + ")?" + v; // vowel in stem + + this.stemWord = function (w) { + var stem; + var suffix; + var firstch; + var origword = w; + + if (w.length < 3) { + return w; + } + + var re; + var re2; + var re3; + var re4; + + firstch = w.substr(0,1); + if (firstch == "y") { + w = firstch.toUpperCase() + w.substr(1); + } + + // Step 1a + re = /^(.+?)(ss|i)es$/; + re2 = /^(.+?)([^s])s$/; + + if (re.test(w)) { + w = w.replace(re,"$1$2"); + } + else if (re2.test(w)) { + w = w.replace(re2,"$1$2"); + } + + // Step 1b + re = /^(.+?)eed$/; + re2 = /^(.+?)(ed|ing)$/; + if (re.test(w)) { + var fp = re.exec(w); + re = new RegExp(mgr0); + if (re.test(fp[1])) { + re = /.$/; + w = w.replace(re,""); + } + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = new RegExp(s_v); + if (re2.test(stem)) { + w = stem; + re2 = /(at|bl|iz)$/; + re3 = new RegExp("([^aeiouylsz])\\1$"); + re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re2.test(w)) { + w = w + "e"; + } + else if (re3.test(w)) { + re = /.$/; w = w.replace(re,""); + } + else if (re4.test(w)) { + w = w + "e"; + } + } + } + + // Step 1c + re = /^(.+?)y$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(s_v); + if (re.test(stem)) { w = stem + "i"; } + } + + // Step 2 + re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) { + w = stem + step2list[suffix]; + } + } + + // Step 3 + re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) { + w = stem + step3list[suffix]; + } + } + + // Step 4 + re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + re2 = /^(.+?)(s|t)(ion)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + if (re.test(stem)) { + w = stem; + } + } + else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = new RegExp(mgr1); + if (re2.test(stem)) { + w = stem; + } + } + + // Step 5 + re = /^(.+?)e$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + re2 = new RegExp(meq1); + re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) { + w = stem; + } + } + re = /ll$/; + re2 = new RegExp(mgr1); + if (re.test(w) && re2.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + + // and turn initial Y back to y + if (firstch == "y") { + w = firstch.toLowerCase() + w.substr(1); + } + return w; + } +} + + + +/** + * Search Module + */ +var Search = { + + init : function() { + var params = $.getQueryParameters(); + if (params.q) { + var query = params.q[0]; + $('input[@name="q"]')[0].value = query; + this.performSearch(query); + } + }, + + /** + * perform a search for something + */ + performSearch : function(query) { + // create the required interface elements + var out = $('#search-results'); + var title = $('

Searching

').appendTo(out); + var dots = $('').appendTo(title); + var status = $('

').appendTo(out); + var output = $('
@@ -216,10 +235,13 @@
  • 1D Interpolation with the Functional Interface +
  • +

    Previous topic

    Welcome to interpolate’s documentation!

    Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-30 20:32:32 UTC (rev 4583) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-30 20:44:41 UTC (rev 4584) @@ -139,12 +139,15 @@ User-defined Interpolation Methods -------------------------------------- -If you want more direct control than is afforded by the string interface, this is also possible. -Note, however, that this is not for the faint-hearted. You must be very careful to have correct -format, and failure to do so can cause a range of errors. +The string interface is designed to conveniently take care of most things a user would want +to do in a way that is easy and, when something goes wrong, informative and helpful. +If, however, you want more direct control than is afforded by the string interface, this is also possible. +Note, that this is trickier than using strings. You must be very careful to have correct +format, and failure to do so can cause a range of errors which won't necessarily result in +informative error messages. -interp can also be set to a function, a callable class, or an instance of a callable class. If you do this, however, you will -have to be careful about formatting. +interp (or, equivalently, extrap_low and extrap_high) can also be set to a function, a callable +class, or an instance of a callable class. If a function is passed, it will be called when interpolating. It is assumed to have the form :: @@ -157,7 +160,7 @@ instance = Class(x, y, **kw). -which can then be called by +which can then be called by :: new_y = instance(new_x) @@ -166,7 +169,7 @@ instance.set_xy(x, y, **kw) -and the object will be called during interpolation. +and the object will be called during interpolation. :: new_y = instance(new_x) @@ -203,4 +206,16 @@ In []: new_y Out []: array([ 7.1, 1.0, 4.0 ]) - \ No newline at end of file + ================================================ +1D Interpolation with the Object Interface +================================================ + +interp1d is in fact a wrapper around the class Interpolate1d. If you want to +interpolate multiple times from the same dataset, this can be more efficient than the +functional interface because many interpolation methods (splines, for example) involve +preprocessing steps which need only be performed once by the object. + +The only real difference between the objective and functional interfaces is that new_x +is passed as the third argument to interp1d, whereas in the objective interface it is +passed to an instance of Interpolate1d. All other arguments to interp1d (x, y, interp, +extrap_low/high, interpkw, etc) are passed into Interpolate1d at instantiation. \ No newline at end of file From scipy-svn at scipy.org Thu Jul 31 12:46:11 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:46:11 -0500 (CDT) Subject: [Scipy-svn] r4585 - branches/Interpolate1D/docs Message-ID: <20080731164611.D059539C70F@scipy.org> Author: fcady Date: 2008-07-31 11:46:00 -0500 (Thu, 31 Jul 2008) New Revision: 4585 Modified: branches/Interpolate1D/docs/tutorial.rst Log: sample sessions added to html documentation. Demonstrates how to use the module, but also shows some of the things interpolation could be used for Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-30 20:44:41 UTC (rev 4584) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-31 16:46:00 UTC (rev 4585) @@ -2,14 +2,22 @@ Overview ================== +Often researchers need to infer from a data set the values at points where measurements +were not taken. Perhaps they are running a simulation that will demand data points +never measured. Perhaps to estimate a statistic of a function (say, the integral) they +want to guess its value everywhere based on a few points. Perhaps they know a function +which must be evaluated multiple times, but evaluating it is expensive; they want to evaluate +it several times at first, and make educated guesses in the future. In all these cases, interpolation +it the tool of choice. + The interpolate package provides tools for interpolating and extrapolating new data points from a known set of data points. Interpolate provides both a functional interface that is flexible and easy to use as well as an object oriented interface that can be more efficient and flexible for some cases. It is able to interpolate and extrapolate in 1D, 2D, and even N dimensions.*[fixme: 1D only right now]* For 1D interpolation, it handles linear and spline(cubic, quadratic, and quintic) for both uniformly and non-uniformly spaced -data points "out of the box." Users can control the behavior of values that fall outside of the range of interpolation either -by When new values fall outside of the range of interpolation data, the tools can be +data points "out of the box." Users can choose the behavior when new values fall outside the range of known data, and +with a little more work, they can incorporate interpolation methods that are specially tailored to their needs. For 2D interpolation, @@ -21,9 +29,15 @@ Basic Usage ------------- +For most users, the primary feature of interpolate is the function 'interp1d'. It takes +in known data points and the points at which to interpolate values, and returns +estimates that will suffice for most purposes. Optional keyword arguments put +a variety of other sophisticated methods one string away from the user, and users +can define and pass in their own custom-tailored interpolation methods. + The following example uses the 'interp1d' function to linearly interpolate a sin curve from a sparse set of values. :: - + # start up ipython for our examples. $ ipython -pylab @@ -33,16 +47,20 @@ In [2]: x = linspace(0, 2*pi, 5) In [3]: y = sin(x) +:: + # If we only want a value at a single point, we can pass in a scalar and interp1d # will return a scalar In [9]: interp1d(x, y, 1.2) Out [10]: 0.76394372684109768 +:: + # 0-dimensional arrays are also treated as scalars In [9]: interp1d(x, y, array(1.2) ) Out [10]: 0.76394372684109768 - # To interpolate from these x,y values at multiple points, possibly to get a more dense set + # To interpolate from these x,y values at multiple points, possibly to get a more dense set # of new_x, new_y values to approximate the function, pass a numpy array to interp1d, # and the return type will also be a numpy array. In [4]: new_x = linspace(0, 2*pi, 21) @@ -50,7 +68,7 @@ # Plot the results using matplotlib. [note examples assume you are running in ipython -pylab] In [6]: plot(x, y, 'ro', new_x, new_y, 'b-') - + .. image:: interp1d_linear_simple.png :: @@ -69,10 +87,10 @@ Out [8]: array([ NaN, NaN, 0.63661977, 0.72676046]) If we want a type of interpolation other than linear, there is a range of options which we can specify -with the keyword argument interp, which is usually a string. For example:: +with the keyword argument kind, which is usually a string. For example:: # If we want quadratic (2nd order) spline interpolation, we can use the string 'quadratic' - In [7]: new_y_quadratic = interp1d(x, y, new_x, interp = 'quadratic') + In [7]: new_y_quadratic = interp1d(x, y, new_x, kind = 'quadratic') In [8]: plot(x, y, 'r', new_x, new_y_quadratic, 'g') .. image:: interp1d_linear_and_quadratic.png @@ -86,22 +104,27 @@ #. 'quartic' : 4th order spline interpolation #. 'quintic' : 5th order spline interpolation -The same flexibility is afforded for extrapolation by the keywords extrap_low and extrap_high: :: +The same flexibility is afforded for extrapolation by the keywords low and high, which +specify how to treat values below and above the range of know data: :: In []: z = array([ 1.0, 2.0 ]) - In []: interp1d(z, z, array([-5.0, 5.0]), extrap_low = 'linear', extrap_high = 'linear') + In []: interp1d(z, z, array([-5.0, 5.0]), low = 'linear', high = 'linear') # -5 and 5 both out of range Out []: array([-5.0, 5.0]) -If a string is passed which is not recognized, and error will be raised. +If a string is passed which is not recognized, an error will be raised. -Finally, interp, extrap_low, and extrap_high can be set to default return values (just make sure that +Finally, kind, low, and high can be set to default return values (just make sure that the return values are not callable and are not strings): :: - In []: interp1d(x, y, array([ -5.0, 1.1, 100 ]), interp = 8.2, extrap_low = 7.2, extrap_high = 9.2) + In []: interp1d(x, y, array([ -5.0, 1.1, 100 ]), kind = 8.2, low = 7.2, high = 9.2) Out []: array([ 7.2, 8.2, 9.2 ]) - + +In fact, under-the-hood, interpolation, low extrapolation and high extrapolation +are handled the same way; it's just that kind has a default value of 'linear', whereas +low and high both default to NaN. + It is also possible, though slightly trickier, to define your own interpolation methods and pass them -in to interp, extrap_low, and extrap_high. For more information, see "User-defined Interpolation Methods" +in to kind, low, and high. For more information, see "User-defined Interpolation Methods" below. @@ -119,10 +142,11 @@ 2) either x[i] or y[i] is NaN Note that bad_data must be either None or a list of numbers. Including NaN or None in the list, -for example, is not supported. NaNs are removed anyway, and None must not appear in the -data. :: +for example, is not supported and will cause errors. - # the bad_data +The following example shows how :: + + # data will be linear, except for artificial bad points In []: x = arange(10.); y = arange(10.) In []: x[1] = NaN # bad data In []: y[2] = 55 # bad data @@ -141,24 +165,24 @@ The string interface is designed to conveniently take care of most things a user would want to do in a way that is easy and, when something goes wrong, informative and helpful. -If, however, you want more direct control than is afforded by the string interface, this is also possible. -Note, that this is trickier than using strings. You must be very careful to have correct +If, however, you want more direct control than is afforded by the string interface, that is also possible, +thought it's a little trickier than using strings. You must be very careful to have correct format, and failure to do so can cause a range of errors which won't necessarily result in informative error messages. -interp (or, equivalently, extrap_low and extrap_high) can also be set to a function, a callable +kind (or, equivalently, low and high) can also be set to a function, a callable class, or an instance of a callable class. If a function is passed, it will be called when interpolating. It is assumed to have the form :: - newy = interp(x, y, newx, **kw) + newy = interp(x, y, newx) where x, y, newx, and newy are all numpy arrays. If a callable class is passed, it is assumed to have format:: - instance = Class(x, y, **kw). + instance = Class(x, y). which can then be called by :: @@ -167,15 +191,15 @@ If a callable object with method "init_xy" or "set_xy" is passed, that method will be used to set x and y as follows: :: - instance.set_xy(x, y, **kw) + instance.set_xy(x, y) and the object will be called during interpolation. :: - new_y = instance(new_x) + new_y = instance(new_x) If the "init_xy" and "set_xy" are not present, it will be called as - new_y = argument(new_x) + new_y = argument(new_x) A primitive type which is not a string signifies a function which is identically that value (e.g. val and @@ -184,9 +208,9 @@ # However, this behavior can be overwritten in the same way as linear interpolation, # by setting the keyword extrap_low (for values below the range of interpolation) and # extrap_high (for values above that range) - In []: def dummy(x, y, newx, default = 5.1): + In []: def dummy(x, y, newx): # Note that dummy has acceptable form - return np.array([ default ]) + return 5.7 In []: class Phony: def __init__(self, val = 4.0): self.val = val @@ -196,26 +220,175 @@ return self.val In []: x = arange(5.0) In []: y = arange(5.0) - In []: new_x = np.array([ -1, .4, 7 ]) - In []: new_y = interp1d(x, y, interp = Phony, - interpkw = {'val':1.0}, - extrap_low = dummy, - lowkw = {'default':7.1}, - extrap_high = dummy + In []: new_x = np.array([ -1, 2.4, 7 ]) + In []: new_y = interp1d(x, y, + kind = Phony, + low = dummy, + high = dummy ) In []: new_y - Out []: array([ 7.1, 1.0, 4.0 ]) + Out []: array([ 5.7, 4.0, 5.7 ]) - ================================================ + + + + +================================================ 1D Interpolation with the Object Interface ================================================ -interp1d is in fact a wrapper around the class Interpolate1d. If you want to -interpolate multiple times from the same dataset, this can be more efficient than the -functional interface because many interpolation methods (splines, for example) involve -preprocessing steps which need only be performed once by the object. +interp1d is built as a wrapper around the class Interpolate1d. If you want to +interpolate multiple times from the same dataset, it can be more efficient +to do it directly through Interpolate1d rather calling interp1d multiple times. +This is because many interpolation methods (splines, for example) involve +preprocessing steps which need only be performed once when Interpolate1d +is instantiated, but are performed every time interp1d is called. -The only real difference between the objective and functional interfaces is that new_x -is passed as the third argument to interp1d, whereas in the objective interface it is -passed to an instance of Interpolate1d. All other arguments to interp1d (x, y, interp, -extrap_low/high, interpkw, etc) are passed into Interpolate1d at instantiation. \ No newline at end of file +Interpolate1d has almost the same interface as interp1d. The class is +instantiated using exactly the same arguments as are passed to interp1d, +EXCEPT that new_x is missing. The instance of Interpolate1d is then called +with new_x as the only argument. :: + + # The default behavior is virtually the same + In []: x = linspace(0, 2*pi, 5) + In []: y = sin(x) + In []: new_x = linspace(0, 2*pi, 21) + In []: new_y1 = interp1d(x, y, new_x) + In []: interp_obj1 = Interpolate1d(x, y) + In []: new_Y1 = interp_obj1(new_x) + In []: new_y1 == new_Y1 + Out []: True + + # interp1d's keyword arguments are passed in when Interpolate1d + # is instantiated, not when it is called. + In []: new_y2 = interp1d(x, y, new_x, kind='spline', low=None, high=5.7) + In []: interp_obj2 = Interpolate1d(x, y, kind='spline', low=None, high=5.7) + In []: new_Y2 = interp_obj2(new_x) + In []: new_y2 == new_Y2 + Out []: True + +================================================== +Sample Data Analysis Sessions Using Interpolate +================================================== + +Below are several sample sessions or code pieces from various applications +showing uses for interpolation and how it can be done using the +interpolate module. + +----------------------------------------------------- +Estimating Function Statistics and Displaying Data +----------------------------------------------------- + +In this session, the engineer +has a data set of geological data indicating the temperature at various +depths in the ground. The data set is noisy and large. He wants to 1) +get a feel for the data, and 2) estimate the average temperature. +:: + + # start up ipython for our examples. + $ ipython -pylab + + # load the data from a text file + In []: data_array = loadtxt('dataset1.txt') + In []: shape(data_array) + Out []: (12, 2) + In []: depth = data_array[:,0] + In []: temp = data_array[:,1] + + In []: max(depth) + Out []: 20 + In []: plot(depth, temp) + + # darn, many of the temperatures are 1000, indicating + # a measurement error, which makes it look terrible. + # And what is there doesn't look smooth + + In []: import interpolate as I + In []: plot( I.interp1d(depth, temp, linspace(0,20,100), bad_data = [1000]) + In []: # much better, but he wants to see it smoother too + In []: plot( I.interp1d(depth, temp, linspace(0,20,100), kind='cubic', bad_data = [1000]) + + # To find the average temp he can't average the data because the samples + # are not necessarily uniform, but he can uniformly sample the interpolated function + In []: average_temp = average( I.interp1d(depth, temp, linspace(0,20,100), 'cubic', bad_data=[1000])) + +--------------------------------- +Modelling from a small dataset +--------------------------------- + +This computational biologist wants to model the growth rate of +cancer cells in tissue. He has measurements of the metabolic rate of cancer +cells at several concentrations of blood glucose. He also has measurements +of the growth rate of these cells as a function of their CO2 metabolic output. Each data point represents +a week's work on the part of experimentalists, so though there isn't much +data he'll have to make due. Now, his full simulation takes up hundreds of lines of +code, but we show here the module object estimate_growth_rate which he wrote. +:: + + import numpy as np + import interpolate as I + + metabolism_filename = "metabolism.txt" + growth_filename = "growth.txt" + + class EstimateGrowthRate: + """ This class is instantiated once at the beginning of the simulation, and then + called many times while it is running. Internally, the spline coefficients are + only calculated once, at instantiation, so this is much more time efficient than + using interp1d multiple times. + """ + + def __init__(self, metab_file = metabolism_filename, grow_file = growth_filename): + metab_array = loadtxt(metab_file) + metab_glucose = metab_array[:,0] + metab_CO2 = metab_array[:,1] + self.glucose_to_CO2 = I.interpolate1d(metab_glucose, metab_CO2, 'cubic') + + grow_array = loadtxt(grow_file) + grow_CO2 = grow_array[:,0] + grow_growth = grow_array[:,1] + self.CO2_to_growth = I.interpolate1d(grow_CO2, grow_growth, 'cubic') + + def __call__(self, glucose_level): + return self.CO2_to_growth( self.glucose_to_CO2( glucose_level )) + + +-------------- +Optimization +-------------- + +This engineer is developing a piece of hardware, and needs to find the optimal +thickness for a thin film it contains. Because performance (by some metric) is at a premium, +she needs to pick a very good thickness. But building a separate prototype for every +possible thickness is impractical, so she needs to make educated guesses for each +thickness she implements. + +An ideal approach is to measure performance for several thicknesses, interpolate +a function from them, guess a good thickness based on that function, make that +prototype, and repeat. If she does this, she can "zoom in" on the optimal thickness. +:: + + In []: data_array = loadtxt('data.dat') + In []: thickness = data_array[:,0] + In []: performance = data_array[:,1] + In []: new_thick = linspace( min(thickness), max(thickness), 200 ) + + # she uses a very high-order spline because, though it's + # somewhat expensive, making prototypes is much more so + In []: new_perf = interp1d(thickness, performance, new_thick, kind = 'quintic') + In []: guess_perf = max(new_perf) + In []: guess_thick = new_thick( find( new_perf == best_perf ) ) + In []: len(guess_thick) + Out []: 1 # make sure she only got one answer. + + # At this point she builds the prototype and calculates its performance. + # She wants to re-insert it into the array and interpolate again + In []: measured_perf = 10.7 #the measured performance + In []: where_to_insert = max( find(thickness < guess_thick) ) +1 + In []: thickness = insert(thickness, where_to_insert, guess_thick) + In []: peformance = insert(performance, where_to_insert, measured_perf) + + + + + \ No newline at end of file From scipy-svn at scipy.org Thu Jul 31 12:58:29 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:58:29 -0500 (CDT) Subject: [Scipy-svn] r4586 - trunk/scipy Message-ID: <20080731165829.EA0AA39C02D@scipy.org> Author: cdavid Date: 2008-07-31 11:58:25 -0500 (Thu, 31 Jul 2008) New Revision: 4586 Modified: trunk/scipy/setupscons.py Log: Handle inplace generation of __config__. Modified: trunk/scipy/setupscons.py =================================================================== --- trunk/scipy/setupscons.py 2008-07-31 16:46:00 UTC (rev 4585) +++ trunk/scipy/setupscons.py 2008-07-31 16:58:25 UTC (rev 4586) @@ -1,7 +1,12 @@ +from os.path import join as pjoin -def configuration(parent_package='',top_path=None, setup_name = 'setupscons.py'): +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, setup_name = 'setupscons.py') + from numpy.distutils.misc_util import scons_generate_config_py + + pkgname = 'scipy' + config = Configuration(pkgname, parent_package, top_path, + setup_name = 'setupscons.py') config.add_subpackage('cluster') config.add_subpackage('fftpack') config.add_subpackage('integrate') @@ -23,7 +28,17 @@ config.add_subpackage('stsci') config.add_subpackage('weave') config.make_svn_version_py() # installs __svn_version__.py - config.scons_make_config_py() # installs __config__.py + + def add_config(*args, **kw): + # Generate __config__, handle inplace issues. + if kw['scons_cmd'].inplace: + target = pjoin(kw['pkg_name'], '__config__.py') + else: + target = pjoin(kw['scons_cmd'].build_lib, kw['pkg_name'], + '__config__.py') + scons_generate_config_py(target) + config.add_sconscript(None, post_hook = add_config) + return config if __name__ == '__main__': From scipy-svn at scipy.org Thu Jul 31 15:09:03 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 14:09:03 -0500 (CDT) Subject: [Scipy-svn] r4587 - in branches/Interpolate1D: . docs Message-ID: <20080731190903.02AE339C089@scipy.org> Author: fcady Date: 2008-07-31 14:09:00 -0500 (Thu, 31 Jul 2008) New Revision: 4587 Modified: branches/Interpolate1D/docs/tutorial.rst branches/Interpolate1D/interpolate1d.py Log: documentation improved, tweaked the api in the case of an instance of a callable class being passed Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-31 16:58:25 UTC (rev 4586) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-31 19:09:00 UTC (rev 4587) @@ -2,25 +2,25 @@ Overview ================== -Often researchers need to infer from a data set the values at points where measurements -were not taken. Perhaps they are running a simulation that will demand data points -never measured. Perhaps to estimate a statistic of a function (say, the integral) they -want to guess its value everywhere based on a few points. Perhaps they know a function -which must be evaluated multiple times, but evaluating it is expensive; they want to evaluate -it several times at first, and make educated guesses in the future. In all these cases, interpolation -it the tool of choice. +Interpolation is the process of using known data to guess the value of unknown data. It turns +a sample of a function into an approximation of that function for every value, and is one of +the most basic mathematical tools available to a researcher. The interpolate package provides tools for interpolating and extrapolating new data points from a known set of data points. Interpolate provides both a functional interface that is flexible and easy to use as well as an object oriented interface that can be more efficient and flexible for some cases. It is able to interpolate and extrapolate in 1D, 2D, and even N -dimensions.*[fixme: 1D only right now]* +dimensions. *[FIXME : 1D only right now]* For 1D interpolation, it handles linear and spline(cubic, quadratic, and quintic) for both uniformly and non-uniformly spaced data points "out of the box." Users can choose the behavior when new values fall outside the range of known data, and with a little more work, they can incorporate interpolation methods that are specially tailored to their needs. -For 2D interpolation, +For 2D interpolation, *[FIXME : include this]* +This tutorial covers how to use the interpolate module, provides some basic examples, and shows +them at work in realistic sample sessions. These sessions demonstrate how to use the +interpolate module, but also highlight some of the uses of interpolation techniques. + ================================================ 1D Interpolation with the Functional Interface ================================================ @@ -38,36 +38,32 @@ The following example uses the 'interp1d' function to linearly interpolate a sin curve from a sparse set of values. :: - # start up ipython for our examples. - $ ipython -pylab - - In [1]: from interpolate import interp1d - - # Create our "known" set of 5 points with the x values in one array and the y values in another. - In [2]: x = linspace(0, 2*pi, 5) - In [3]: y = sin(x) + # start up ipython for our examples. + $ ipython -pylab -:: + In [1]: from interpolate import interp1d + # Create our "known" set of 5 points with the x values in one array and the y values in another. + In [2]: x = linspace(0, 2*pi, 5) + In [3]: y = sin(x) + # If we only want a value at a single point, we can pass in a scalar and interp1d # will return a scalar - In [9]: interp1d(x, y, 1.2) - Out [10]: 0.76394372684109768 + In []: interp1d(x, y, 1.2) + Out []: 0.76394372684109768 -:: - # 0-dimensional arrays are also treated as scalars - In [9]: interp1d(x, y, array(1.2) ) - Out [10]: 0.76394372684109768 + In []: interp1d(x, y, array(1.2) ) + Out []: 0.76394372684109768 # To interpolate from these x,y values at multiple points, possibly to get a more dense set # of new_x, new_y values to approximate the function, pass a numpy array to interp1d, # and the return type will also be a numpy array. - In [4]: new_x = linspace(0, 2*pi, 21) - In [5]: new_y = interp1d(x, y, new_x) - - # Plot the results using matplotlib. [note examples assume you are running in ipython -pylab] - In [6]: plot(x, y, 'ro', new_x, new_y, 'b-') + In []: new_x = linspace(0, 2*pi, 21) + In []: new_y = interp1d(x, y, new_x) + + # Plot the results using matplotlib. [note examples assume you are running in ipython -pylab] + In []: plot(x, y, 'ro', new_x, new_y, 'b-') .. image:: interp1d_linear_simple.png @@ -83,15 +79,15 @@ # If we attempt to extrapolate values outside the interpolation range, interp1d defaults # to returning NaN - In [7]: interp1d(x, y, array([-2, -1, 1, 2])) - Out [8]: array([ NaN, NaN, 0.63661977, 0.72676046]) + In []: interp1d(x, y, array([-2, -1, 1, 2])) + Out []: array([ NaN, NaN, 0.63661977, 0.72676046]) If we want a type of interpolation other than linear, there is a range of options which we can specify -with the keyword argument kind, which is usually a string. For example:: +with the keyword argument "kind", which is usually a string. Continuing from the previous example,:: # If we want quadratic (2nd order) spline interpolation, we can use the string 'quadratic' - In [7]: new_y_quadratic = interp1d(x, y, new_x, kind = 'quadratic') - In [8]: plot(x, y, 'r', new_x, new_y_quadratic, 'g') + In []: new_y_quadratic = interp1d(x, y, new_x, kind = 'quadratic') + In []: plot(x, y, 'r', new_x, new_y_quadratic, 'g') .. image:: interp1d_linear_and_quadratic.png @@ -105,7 +101,7 @@ #. 'quintic' : 5th order spline interpolation The same flexibility is afforded for extrapolation by the keywords low and high, which -specify how to treat values below and above the range of know data: :: +specify how to treat values below and above the range of known data: :: In []: z = array([ 1.0, 2.0 ]) In []: interp1d(z, z, array([-5.0, 5.0]), low = 'linear', high = 'linear') # -5 and 5 both out of range @@ -133,7 +129,7 @@ Removal of Bad Datapoints ----------------------------- -Many datasets have missing or corrupt data which it is desirable to ignore when interpolating, +Many datasets have missing or corrupt data which we want to ignore when interpolating, and to this end, interp1d has the keyword argument bad_data. bad_data defaults to being None. But if it is a list, all "bad" points (x[i], y[i]) will be removed @@ -144,7 +140,7 @@ Note that bad_data must be either None or a list of numbers. Including NaN or None in the list, for example, is not supported and will cause errors. -The following example shows how :: +The following example demonstrates using this keyword argument :: # data will be linear, except for artificial bad points In []: x = arange(10.); y = arange(10.) @@ -165,12 +161,12 @@ The string interface is designed to conveniently take care of most things a user would want to do in a way that is easy and, when something goes wrong, informative and helpful. -If, however, you want more direct control than is afforded by the string interface, that is also possible, -thought it's a little trickier than using strings. You must be very careful to have correct -format, and failure to do so can cause a range of errors which won't necessarily result in +If, however, you want more direct control than is afforded by the string interface, that is also possible. +If you define your own types, you must be very careful to have correct +format; failure to do so can cause a range of errors which won't necessarily result in informative error messages. -kind (or, equivalently, low and high) can also be set to a function, a callable +kind (or, equivalently, low or high) can also be set to a function, a callable class, or an instance of a callable class. If a function is passed, it will be called when interpolating. @@ -178,36 +174,45 @@ newy = interp(x, y, newx) -where x, y, newx, and newy are all numpy arrays. +where x, y, newx, and newy are all 1D numpy arrays. -If a callable class is passed, it is assumed to have format:: +If a class is passed, it is assumed to have ones of two formats. +If there is a "init_xy" or "set_xy" method, the class is instantiated +with no argument, then the relevant method is called to initialize +x and y, and the class is later called with a 1D array as an argument.:: - instance = Class(x, y). - -which can then be called by :: + instance = Class(). + instance.set_xy(x, y) + new_y = instance(new_x) +If the class does not have an init_xy or set_xy method, the class +is instantiated with x and y as arguments, and passed a 1D array +during interpolation. :: + + instance = Class(x, y) new_y = instance(new_x) -If a callable object with method "init_xy" or "set_xy" is -passed, that method will be used to set x and y as follows: :: +You can also pass an instance of the callable class, rather than the class +itself. This is useful is the class has other parameters besides x, y, and +new_x (perhaps smoothing coefficients, orders for polynomials, etc). +If the instance has a method "init_xy" or "set_xy", +that method will be used to set x and y, and the instance will be +called later: :: + instance.set_xy(x, y) - -and the object will be called during interpolation. :: - new_y = instance(new_x) -If the "init_xy" and "set_xy" are not present, it will be called as +If the instance has no "init_xy" or "set_xy" method, it will be called as :: - new_y = argument(new_x) - -A primitive type which is not a string signifies a function -which is identically that value (e.g. val and -lambda x, y, newx : val are equivalent). :: + new_y = kind(x, y, new_x) + +Failure to follow these guidelines (say, by having kind require other keyword +arguments, having a method "initialize_xy" rather than "init_xy", etc) can result +in cryptic errors, so be careful. Here is a demo of how to properly use these features: - # However, this behavior can be overwritten in the same way as linear interpolation, - # by setting the keyword extrap_low (for values below the range of interpolation) and - # extrap_high (for values above that range) +:: + In []: def dummy(x, y, newx): # Note that dummy has acceptable form return 5.7 @@ -222,10 +227,10 @@ In []: y = arange(5.0) In []: new_x = np.array([ -1, 2.4, 7 ]) In []: new_y = interp1d(x, y, - kind = Phony, - low = dummy, - high = dummy - ) + kind = Phony, + low = dummy, + high = dummy + ) In []: new_y Out []: array([ 5.7, 4.0, 5.7 ]) @@ -251,7 +256,7 @@ # The default behavior is virtually the same In []: x = linspace(0, 2*pi, 5) - In []: y = sin(x) + In []: y = sin(x) In []: new_x = linspace(0, 2*pi, 21) In []: new_y1 = interp1d(x, y, new_x) In []: interp_obj1 = Interpolate1d(x, y) @@ -279,16 +284,12 @@ Estimating Function Statistics and Displaying Data ----------------------------------------------------- -In this session, the engineer -has a data set of geological data indicating the temperature at various -depths in the ground. The data set is noisy and large. He wants to 1) -get a feel for the data, and 2) estimate the average temperature. +In this session, the geologist +has a data set of data indicating the temperature at various +depths in the ground. He wants to 1) get a visual feel for the data, +and 2) estimate the average temperature. :: - # start up ipython for our examples. - $ ipython -pylab - - # load the data from a text file In []: data_array = loadtxt('dataset1.txt') In []: shape(data_array) Out []: (12, 2) @@ -305,26 +306,29 @@ In []: import interpolate as I In []: plot( I.interp1d(depth, temp, linspace(0,20,100), bad_data = [1000]) - In []: # much better, but he wants to see it smoother too + # much better, but he wants to see it smoother too In []: plot( I.interp1d(depth, temp, linspace(0,20,100), kind='cubic', bad_data = [1000]) - # To find the average temp he can't average the data because the samples - # are not necessarily uniform, but he can uniformly sample the interpolated function - In []: average_temp = average( I.interp1d(depth, temp, linspace(0,20,100), 'cubic', bad_data=[1000])) + # To find the average temp he can't average the data points because the samples + # are not necessarily uniform, but it is easy to uniformly sample the interpolated function + In []: average_temp = average( I.interp1d(depth, temp, linspace(0,20,100), 'cubic', bad_data=[1000]) ) --------------------------------- -Modelling from a small dataset +Modeling from a small dataset --------------------------------- This computational biologist wants to model the growth rate of -cancer cells in tissue. He has measurements of the metabolic rate of cancer -cells at several concentrations of blood glucose. He also has measurements -of the growth rate of these cells as a function of their CO2 metabolic output. Each data point represents +cancer cells in tissue. For several levels of blood glucose, he has measurements +of the CO2 output of the cancer cells. For several different levels of CO2 ouput, +he also has measurements of the growth rate of these cells. Each data point represents a week's work on the part of experimentalists, so though there isn't much data he'll have to make due. Now, his full simulation takes up hundreds of lines of -code, but we show here the module object estimate_growth_rate which he wrote. +code, so we only show the module estimate_growth_rate.py which he wrote. :: + """ Contains callable class EstimateGrowthRate, which accepts blood glucose level as + an argument and returns interpolated growth rate of cells. + """ import numpy as np import interpolate as I @@ -387,8 +391,6 @@ In []: where_to_insert = max( find(thickness < guess_thick) ) +1 In []: thickness = insert(thickness, where_to_insert, guess_thick) In []: peformance = insert(performance, where_to_insert, measured_perf) - - - - - \ No newline at end of file + +More sophisticated optimization tools are also available from the scipy.optimize +module. \ No newline at end of file Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-31 16:58:25 UTC (rev 4586) +++ branches/Interpolate1D/interpolate1d.py 2008-07-31 19:09:00 UTC (rev 4587) @@ -1,79 +1,92 @@ # FIXME: information strings giving mathematical descriptions of the actions # of the functions. -from interpolate_wrapper import linear, logarithmic, block, block_average_above, atleast_1d_and_contiguous +from interpolate_wrapper import linear, logarithmic, block, \ + block_average_above, atleast_1d_and_contiguous from fitpack_wrapper import Spline import numpy as np from numpy import array, arange, empty, float64, NaN -# dictionary of tuples. First element is a callable (class, instance of a class, or function -# second argument is dictionary of additional keywords, if any -dict_of_interp_types = \ - { 'linear' : (linear, {}), - 'logarithmic' : (logarithmic, {}), - 'block' : (block, {}), - 'block_average_above' : (block_average_above, {}), - 'Spline' : (Spline, {}), 'spline' : (Spline, {}), - 'Quadratic' : (Spline, {'k':2}), 'quadratic' : (Spline, {'k':2}), - 'Quad' : (Spline, {'k':2}), 'quad' : (Spline, {'k':2}), - 'Cubic' : (Spline, {'k':3}), 'cubic' : (Spline, {'k':3}), - 'Quartic' : (Spline, {'k':4}), 'quartic' : (Spline, {'k':4}), - 'Quar' : (Spline, {'k':4}), 'quar' : (Spline, {'k':4}), - 'Quintic' : (Spline, {'k':5}), 'quintic' : (Spline, {'k':5}), - 'Quin' : (Spline, {'k':5}), 'quin' : (Spline, {'k':5}) +# dictionary of interpolation functions/classes/objects +method_register = \ + { 'linear' : linear, + 'logarithmic' : logarithmic, + 'block' : block, + 'block_average_above' : block_average_above, + 'Spline' : Spline, 'spline' : Spline, + 'Quadratic' : Spline(k=2), 'quadratic' : Spline(k=2), + 'Quad' : Spline(k=2), 'quad' : Spline(k=2), + 'Cubic' : Spline(k=3), 'cubic' : Spline(k=3), + 'Quartic' : Spline(k=3), 'quartic' : Spline(k=3), + 'Quar' : Spline(k=4), 'quar' : Spline(k=4), + 'Quintic' : Spline(k=5), 'quintic' : Spline(k=5), + 'Quin' : Spline(k=5), 'quin' : Spline(k=5) } + +# dictionary of types for casting. key = possible datatype, value = datatype it is cast to +# BEWARE : if you cast things to integers, you will lose interpolation ability +dtype_register = {np.float32 : np.float32, + np.float64 : np.float64 + } +dtype_default = np.float64 def interp1d(x, y, new_x, - interp = 'linear', extrap_low = NaN, extrap_high = NaN, - interpkw = {}, lowkw = {}, highkw ={}, + kind = 'linear', low = NaN, high = NaN, bad_data = None): # FIXME : all y to be multi-dimensional - # FIXME : update the doc string to match that of Interpolate1d - """ A function for interpolation of 1D data. + # NOTE : This docstring is considered suboordinate to that for Interpolate1d. + # That is, update Interpolate1d and copy-and-paste + """ A callable class for interpolation of 1D, real-valued data. Parameters ----------- - x -- list or NumPy array - x includes the x-values for the data set to - interpolate from. It must be sorted in - ascending order + x -- list or 1D NumPy array + x includes the x-values for the data set to + interpolate from. It must be sorted in + ascending order. + + y -- list or 1D NumPy array + y includes the y-values for the data set to + interpolate from. Note that 2-dimensional + y is not currently supported. - y -- list or NumPy array - y includes the y-values for the data set to - interpolate from. Note that y must be - one-dimensional. - - new_x -- list or NumPy array - points whose value is to be interpolated from x and y. - new_x must be in sorted order, lowest to highest. - Optional Arguments ------------------- - interp -- Usu. function or string. But can be any type. - Specifies the type of extrapolation to use for values within - the range of x. If a string is passed, it will look for an object - or function with that name and call it when evaluating. If - a function or object is passed, it will be called when interpolating. - If nothing else, assumes the argument is intended as a value - to be returned for all arguments. Defaults to linear interpolation. + kind -- Usually a string. But can be any type. + Specifies the type of interpolation to use for values within + the range of x. + + By default, linear interpolation is used. + + See below for details on other options. + + low -- same as for kind + How to extrapolate values for inputs below the range of x. + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values below the range of x. + + high -- same as for kind + How to extrapolate values for inputs above the range of x. + Same options as for 'kind'. Defaults to returning numpy.NaN ('not + a number') for all values above the range of x. + + bad_data -- list + List of numerical values (in x or y) which indicate unacceptable data. + + If bad_data is not None (its default), all points whose x or y coordinate is in + bad_data, OR ones of whose coordinates is NaN, will be removed. + + interpkw -- dictionary + If interp is set to a function, class or callable object, this contains + additional keywords. + + lowkw (highkw) -- dictionary + like interpkw, but for extrap_low and extrap_high + - low (high) -- same as for interp - Same options as for 'interp'. Defaults to returning numpy.NaN ('not - a number') for all values outside the range of x. - - interpkw -- dictionary - If - - bad_data -- list - List of values (in x or y) which indicate unacceptable data. All points - that have x or y value in missing_data will be removed before - any interpolatin is performed if bad_data is not None. - - numpy.NaN is always considered bad data. - - Acceptable Input Strings + Some Acceptable Input Strings ------------------------ "linear" -- linear interpolation : default @@ -82,8 +95,39 @@ "block_average_above' -- block average above "Spline" -- spline interpolation. keyword k (defaults to 3) indicates order of spline - numpy.NaN -- return numpy.NaN + "quad", "quadratic" -- spline interpolation order 2 + "cubic" -- spline interpolation order 3 + "quartic" -- spline interpolation order 4 + "quintic" -- spline interpolation order 5 + + Other options for interp, extrap_low, and extrap_high + --------------------------------------------------- + If you choose to use a non-string argument, you must + be careful to use correct formatting. + + If a function is passed, it will be called when interpolating. + It is assumed to have the form + newy = interp(x, y, newx, **kw), + where x, y, newx, and newy are all numpy arrays. + + If a callable class is passed, it is assumed to have format + instance = Class(x, y, **kw). + which can then be called by + new_y = instance(new_x) + + If a callable object with method "init_xy" or "set_xy" is + passed, that method will be used to set x and y as follows + instance.set_xy(x, y, **kw) + and the object will be called during interpolation. + new_y = instance(new_x) + If the "init_xy" and "set_xy" are not present, it will be called as + new_y = argument(new_x) + + A primitive type which is not a string signifies a function + which is identically that value (e.g. val and + lambda x, y, newx : val are equivalent). + Examples --------- @@ -96,12 +140,9 @@ array([.2, 2.3, 5.6, NaN]) """ return Interpolate1d(x, y, - interp = interp, - extrap_low = extrap_low, - extrap_high = extrap_high, - interpkw = interpkw, - lowkw = lowkw, - highkw = highkw, + kind = kind, + low = low, + high = high, bad_data = bad_data )(new_x) @@ -124,7 +165,7 @@ Optional Arguments ------------------- - interp -- Usually a string. But can be any type. + kind -- Usually a string. But can be any type. Specifies the type of interpolation to use for values within the range of x. @@ -132,12 +173,12 @@ See below for details on other options. - extrap_low -- same as for kind + low -- same as for kind How to extrapolate values for inputs below the range of x. Same options as for 'kind'. Defaults to returning numpy.NaN ('not a number') for all values below the range of x. - extrap_high -- same as for kind + high -- same as for kind How to extrapolate values for inputs above the range of x. Same options as for 'kind'. Defaults to returning numpy.NaN ('not a number') for all values above the range of x. @@ -148,14 +189,6 @@ If bad_data is not None (its default), all points whose x or y coordinate is in bad_data, OR ones of whose coordinates is NaN, will be removed. - interpkw -- dictionary - If interp is set to a function, class or callable object, this contains - additional keywords. - - lowkw (highkw) -- dictionary - like interpkw, but for extrap_low and extrap_high - - Some Acceptable Input Strings ------------------------ @@ -170,7 +203,7 @@ "quartic" -- spline interpolation order 4 "quintic" -- spline interpolation order 5 - Other options for interp, extrap_low, and extrap_high + Other options for kind, low, and high --------------------------------------------------- If you choose to use a non-string argument, you must @@ -178,17 +211,17 @@ If a function is passed, it will be called when interpolating. It is assumed to have the form - newy = interp(x, y, newx, **kw), + newy = interp(x, y, newx), where x, y, newx, and newy are all numpy arrays. If a callable class is passed, it is assumed to have format - instance = Class(x, y, **kw). + instance = Class(x, y). which can then be called by new_y = instance(new_x) If a callable object with method "init_xy" or "set_xy" is passed, that method will be used to set x and y as follows - instance.set_xy(x, y, **kw) + instance.set_xy(x, y) and the object will be called during interpolation. new_y = instance(new_x) If the "init_xy" and "set_xy" are not present, it will be called as @@ -211,30 +244,32 @@ array([.2, 2.3, 5.6, NaN]) """ - # FIXME: more informative descriptions of sample arguments - # FIXME: examples in doc string - # FIXME : Allow copying or not of arrays. non-copy + remove_bad_data should flash - # a warning (esp if we interpolate missing values), but work anyway. def __init__(self, x, y, - interp = 'linear', - extrap_low = NaN, - extrap_high = NaN, - interpkw = {}, - lowkw = {}, - highkw = {}, + kind = 'linear', + low = NaN, + high = NaN, bad_data = None): - # FIXME: don't allow copying multiple times. - # FIXME : allow no copying, in case user has huge dataset - # remove bad data, is there is any + # put data into nice format and store it + self._init_xy(x, y, bad_data) + + # store interpolation functions for each range + self.interp = self._init_interp_method(kind) + self.extrap_low = self._init_interp_method(low) + self.extrap_high = self._init_interp_method(high) + + def _init_xy(self, x, y, bad_data): + # FIXME : no-copying option, in case user has huge dataset. non-copy + remove bad data should + # flash a warning (esp if, in the future, bad values are interpolated). + + # remove bad data if applicable if bad_data is not None: - try: + try: # check that bad_data contains only numerical values sum_of_bad_data = sum(bad_data) except: raise TypeError, "bad_data must be either None \ - or a list of numerical types" - + or a list of numbers" x, y = self._remove_bad_data(x, y, bad_data) # check acceptable size and dimensions @@ -245,20 +280,9 @@ assert y.ndim == 1 , "y must be one-dimensional" assert len(x) == len(y) , "x and y must be of the same length" - # store data, and remove bad data points is applicable - # FIXME : may be good to let x and y be initialized later, or changed after-the-fact - self._init_xy(x, y) - - # store interpolation functions for each range - self.interp = self._init_interp_method(interp, interpkw) - self.extrap_low = self._init_interp_method(extrap_low, lowkw) - self.extrap_high = self._init_interp_method(extrap_high, highkw) - - def _init_xy(self, x, y): - # select proper dataypes and make arrays - self._xdtype = {np.float32 : np.float32}.setdefault(type(x[0]), np.float64) # unless data is float32, cast to float64 - self._ydtype = {np.float32 : np.float32}.setdefault(type(y[0]), np.float64) + self._xdtype = dtype_register.setdefault(type(x[0]), dtype_default) + self._ydtype = dtype_register.setdefault(type(y[0]), dtype_default) self._x = atleast_1d_and_contiguous(x, self._xdtype).copy() self._y = atleast_1d_and_contiguous(y, self._ydtype).copy() @@ -266,9 +290,6 @@ """ removes data points whose x or y coordinate is either in bad_data or is a NaN. """ - # FIXME : In the future, it may be good to just replace the bad points with good guesses. - # Especially in generalizing the higher dimensions - # FIXME : This step is very inefficient because it iterates over the array bad_data_mask = np.isnan(x) | np.isnan(y) for bad_num in bad_data: @@ -278,20 +299,15 @@ y = y[~bad_data_mask] return x, y - def _init_interp_method(self, interp_arg, kw): - """ - returns the interpolating function specified by interp_arg. - """ - # FIXME : error checking specific to interpolation method. x and y long - # enough for order-3 spline if that's indicated, etc. Functions should throw - # errors themselves, but errors at instantiation would be nice. - + def _init_interp_method(self, interp_arg): + """ returns the interpolating function specified by interp_arg. + """ from inspect import isclass, isfunction # primary usage : user passes a string indicating a known function + # pick interpolator accordingly if isinstance(interp_arg, basestring): - interpolator, kw = dict_of_interp_types.setdefault(interp_arg, (None, {}) ) - + interpolator = method_register.setdefault(interp_arg, None ) if interpolator is None: raise TypeError, "input string %s not valid" % interp_arg else: @@ -301,29 +317,29 @@ if hasattr(interpolator, '__call__'): # function if isfunction(interpolator): - result = lambda newx : interpolator(self._x, self._y, newx, **kw) + result = lambda newx : interpolator(self._x, self._y, newx) # callable class elif isclass(interpolator): if hasattr(interpolator, 'set_xy'): - result = interpolator(**kw) + result = interpolator() result.set_xy(self._x, self._y) if hasattr(interpolator, 'init_xy'): - result = interpolator(**kw) + result = interpolator() result.init_xy(self._x, self._y) else: - result = interpolator(self._x, self._y, **kw) + result = interpolator(self._x, self._y) # instance of callable class else: if hasattr(interpolator, 'init_xy'): result = interpolator - result.init_xy(self._x, self._y, **kw) + result.init_xy(self._x, self._y) elif hasattr(interpolator, 'set_xy'): result = interpolator - result.set_xy(self._x, self._y, **kw) + result.set_xy(self._x, self._y) else: - result = interpolator + result = lambda new_x : interpolator(self._x, self._y, new_x) # non-callable : user has passed a default value to always be returned else: @@ -332,49 +348,38 @@ return result def __call__(self, newx): - """ - Input x must be a list or NumPy array in sorted order. + """ Input x must be a list or NumPy array in sorted order. Breaks x into pieces in-range, below-range, and above range. Performs appropriate operation on each and concatenates results. """ - # FIXME : atleast_1d_and_contiguous may also be called within the interpolation technique. - # waste of time, but ok for the time being. - # if input is scalar or 0-dimemsional array, output will be scalar + # record if input is scalar or 0-dimemsional array, in which case output will be scalar input_is_scalar = np.isscalar(newx) or \ ( isinstance( newx , np.ndarray ) and np.shape(newx) == () ) - # make - newx_array = atleast_1d_and_contiguous(newx) + # make input into a nice 1d, contiguous array + newx_array = atleast_1d_and_contiguous(newx, dtype=self._xdtype) + assert newx_array.ndim == 1, "new_x can be at most 1-dimensional" # masks indicate which elements fall into which interpolation region low_mask = newx_arrayself._x[-1] interp_mask = (~low_mask) & (~high_mask) - type(newx_array[low_mask]) - - - # use correct function for x values in each region - if len(newx_array[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else. - # if/else is a hack, since vectorize is failing - # to work on lists/arrays of length 0 - # on the computer where this is being - # developed + # use correct function for x values in each region and create output as an array + if len(newx_array[low_mask]) == 0: new_low=np.array([]) # FIXME : remove need for if/else hack. + # it's there since vectorize is failing on arrays of zero length else: new_low = self.extrap_low(newx_array[low_mask]) if len(newx_array[interp_mask])==0: new_interp=np.array([]) else: new_interp = self.interp(newx_array[interp_mask]) if len(newx_array[high_mask]) == 0: new_high = np.array([]) else: new_high = self.extrap_high(newx_array[high_mask]) + result_array = np.concatenate((new_low, new_interp, new_high)) - result_array = np.concatenate((new_low, new_interp, new_high)) # FIXME : deal with mixed datatypes - # Would be nice to say result = zeros(dtype=?) - # and fill in - # convert to scalar if scalar was passed in if input_is_scalar: result = float(result_array) From scipy-svn at scipy.org Thu Jul 31 15:13:05 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 14:13:05 -0500 (CDT) Subject: [Scipy-svn] r4588 - branches/Interpolate1D/docs Message-ID: <20080731191305.B697539C089@scipy.org> Author: fcady Date: 2008-07-31 14:13:04 -0500 (Thu, 31 Jul 2008) New Revision: 4588 Removed: branches/Interpolate1D/docs/build/ Log: deleted build directory From scipy-svn at scipy.org Thu Jul 31 17:01:51 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 16:01:51 -0500 (CDT) Subject: [Scipy-svn] r4589 - branches/Interpolate1D/docs Message-ID: <20080731210151.3464C39C088@scipy.org> Author: fcady Date: 2008-07-31 16:01:45 -0500 (Thu, 31 Jul 2008) New Revision: 4589 Added: branches/Interpolate1D/docs/with_and_without_bad_data.png Modified: branches/Interpolate1D/docs/tutorial.rst Log: fixed the example code, and replaced some of the graphics Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-31 19:13:04 UTC (rev 4588) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-31 21:01:45 UTC (rev 4589) @@ -41,11 +41,11 @@ # start up ipython for our examples. $ ipython -pylab - In [1]: from interpolate import interp1d + In []: from interpolate import interp1d # Create our "known" set of 5 points with the x values in one array and the y values in another. - In [2]: x = linspace(0, 2*pi, 5) - In [3]: y = sin(x) + In []: x = linspace(0, 2*pi, 5) + In []: y = sin(x) # If we only want a value at a single point, we can pass in a scalar and interp1d # will return a scalar @@ -145,16 +145,20 @@ # data will be linear, except for artificial bad points In []: x = arange(10.); y = arange(10.) In []: x[1] = NaN # bad data - In []: y[2] = 55 # bad data - In []: new_x = arange(0, 10., .1) + In []: y[6] = 55 # bad data + In []: new_x = arange(0, 9., .1) In []: new_y_bad = interp1d(x, y, new_x) In []: new_y_no_bad = interp1d(x, y, new_x, bad_data=[55]) - In []: plot(new_x, new_y_bad, 'r', new_x, new_y_no_bad, 'g') + In []: plot(new_x, new_y_bad, 'ro', new_x, new_y_no_bad, 'b+') .. image :: with_and_without_bad_data.png +The plot with the bad data still in is visually marred by the bad value, +the NaN in x[1] makes all extrapolated values that depend on X[1] +become NaN as well, and NaN does not show up on a graph. In contrast, +using bad_data removed both those points, so the entire range of x is linearly +interpolated. - -------------------------------------- User-defined Interpolation Methods -------------------------------------- @@ -166,22 +170,24 @@ format; failure to do so can cause a range of errors which won't necessarily result in informative error messages. -kind (or, equivalently, low or high) can also be set to a function, a callable -class, or an instance of a callable class. +To specify your own interpolation type, set kind (or low or high) to a function, a callable +class, or an instance of a callable class. The function or class instance will be stored (if you +pass a class, an instance will be stored) by Interpolate1d and used on the appropriate part +of new_x whenever Interpolate1d is called. interp1d creates and calls an instance of Interpolate1d +all in one shot. -If a function is passed, it will be called when interpolating. -It is assumed to have the form :: +If a function is passed, it is assumed to have the form :: - newy = interp(x, y, newx) + newy = kind(x, y, newx) where x, y, newx, and newy are all 1D numpy arrays. -If a class is passed, it is assumed to have ones of two formats. +If a class is passed, it is assumed to have one of two formats. If there is a "init_xy" or "set_xy" method, the class is instantiated with no argument, then the relevant method is called to initialize x and y, and the class is later called with a 1D array as an argument.:: - instance = Class(). + instance = kind(). instance.set_xy(x, y) new_y = instance(new_x) @@ -189,21 +195,21 @@ is instantiated with x and y as arguments, and passed a 1D array during interpolation. :: - instance = Class(x, y) + instance = kind(x, y) new_y = instance(new_x) -You can also pass an instance of the callable class, rather than the class -itself. This is useful is the class has other parameters besides x, y, and +You can also pass an instance of acallable class, rather than the class +itself. This is useful if the class has other parameters besides x, y, and new_x (perhaps smoothing coefficients, orders for polynomials, etc). If the instance has a method "init_xy" or "set_xy", that method will be used to set x and y, and the instance will be called later: :: - instance.set_xy(x, y) - new_y = instance(new_x) + kind.set_xy(x, y) + new_y = kind(new_x) -If the instance has no "init_xy" or "set_xy" method, it will be called as :: +If the instance has no "init_xy" or "set_xy" method, it will be called like :: new_y = kind(x, y, new_x) @@ -215,18 +221,19 @@ In []: def dummy(x, y, newx): # Note that dummy has acceptable form - return 5.7 + return array([ 5.7 ]) In []: class Phony: def __init__(self, val = 4.0): self.val = val def init_xy(self, x, y): pass def __call__(self, newx): - return self.val + # must return an array + return array([ self.val ]) In []: x = arange(5.0) In []: y = arange(5.0) In []: new_x = np.array([ -1, 2.4, 7 ]) - In []: new_y = interp1d(x, y, + In []: new_y = interp1d(x, y, new_x, kind = Phony, low = dummy, high = dummy @@ -300,7 +307,7 @@ Out []: 20 In []: plot(depth, temp) - # darn, many of the temperatures are 1000, indicating + # He realizes that many of the temperatures are 1000, indicating # a measurement error, which makes it look terrible. # And what is there doesn't look smooth @@ -323,7 +330,8 @@ he also has measurements of the growth rate of these cells. Each data point represents a week's work on the part of experimentalists, so though there isn't much data he'll have to make due. Now, his full simulation takes up hundreds of lines of -code, so we only show the module estimate_growth_rate.py which he wrote. +code, so we only show the module estimate_growth_rate.py which is used by +the simulation to estimate the growth rate of the cells at various point in time. :: """ Contains callable class EstimateGrowthRate, which accepts blood glucose level as @@ -336,7 +344,7 @@ growth_filename = "growth.txt" class EstimateGrowthRate: - """ This class is instantiated once at the beginning of the simulation, and then + """ This class should be instantiated once at the beginning of the simulation, and then called many times while it is running. Internally, the spline coefficients are only calculated once, at instantiation, so this is much more time efficient than using interp1d multiple times. @@ -356,7 +364,6 @@ def __call__(self, glucose_level): return self.CO2_to_growth( self.glucose_to_CO2( glucose_level )) - -------------- Optimization -------------- Added: branches/Interpolate1D/docs/with_and_without_bad_data.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/with_and_without_bad_data.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream From scipy-svn at scipy.org Thu Jul 31 19:46:58 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 18:46:58 -0500 (CDT) Subject: [Scipy-svn] r4590 - branches/Interpolate1D/docs Message-ID: <20080731234658.6B02439C226@scipy.org> Author: fcady Date: 2008-07-31 18:46:55 -0500 (Thu, 31 Jul 2008) New Revision: 4590 Added: branches/Interpolate1D/docs/interp1d_linear_and_quadratic.png branches/Interpolate1D/docs/spline_of_sin.png Modified: branches/Interpolate1D/docs/tutorial.rst Log: better graphics, and tutorial discusses splines since Spline is currently a very substantial class with a lot of interesting utility Added: branches/Interpolate1D/docs/interp1d_linear_and_quadratic.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/interp1d_linear_and_quadratic.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: branches/Interpolate1D/docs/spline_of_sin.png =================================================================== (Binary files differ) Property changes on: branches/Interpolate1D/docs/spline_of_sin.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-31 21:01:45 UTC (rev 4589) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-31 23:46:55 UTC (rev 4590) @@ -95,6 +95,8 @@ #. 'linear' : linear interpolation, same as the default #. 'block' : "round new_x down" to the nearest values where we know y. +#. 'nearest' : take the y value of the nearest point +#. 'logarithmic' : logarithmic interpolation (linear in log(y) ) #. 'spline' : spline interpolation of default order (currently 3) #. 'cubic' : 3rd order spline interpolation #. 'quartic' : 4th order spline interpolation @@ -400,4 +402,108 @@ In []: peformance = insert(performance, where_to_insert, measured_perf) More sophisticated optimization tools are also available from the scipy.optimize -module. \ No newline at end of file +module. + +=================== +The Spline Class +=================== + +Interpolate1d, with the string arguments 'spline', 'cubic', 'quad', 'quintic', etc, is +actually a wrapper around the Spline class, which contains fast and powerful Fortran +code for working with splines. However, Interpolate1d only wraps a part of this functionality. +For some tasks, it is good to be able to directly access this power. + +This section describes the operation of the Spline class. + +---------------- +Intro to Splines +---------------- + +Splines are a class of functions which +#) are easy and quick to evaluate, +#) can be fitted to any 1D data, and +#) are quite smooth +#) do not show the pathological Runge's phenomenon which mares polynomial fits +Thus, they are ideal for interpolation if we need something smoother than +a simple linear fit. This is the barest of mathematical primers on splines; +more information is readily available on the internet. + + +Mathematically, a spline function S of order k is defined relative to a sequence of "knots", x1, x2, ..., xn. On +every interval [xi, x_{i-1}], S is a polynomial of order at most k (it is from this that the ease and speed +of splines arises). At a knot, where two of the polynomials meet, they are required to agree in the first +k-1 derivatives (ie all but the last). A spline is specified by the locations of its knots and the coefficients +of its polynomial in each interval. + +For interpolation purposes, the knots are typically chosen to be the known data points. It +is also common for splines to include smoothing of data, so that the curve does not pass +through all the data points but is smoother than it would be if it had to. k=3 is the most +common order of spline used in interpolation, and is often called a cubic spline. + +------------- +Basic Usage +------------- + +At instantiation, the user passes in x, y, and possibly the spline order k (which defaults to 3). +Calls are then made with the new_x array. :: + + In []: from interpolate import Spline + In []: x = linspace(0, 2*pi, 5) + In []: y = sin(x) + In []: interp = Spline(x, y, k=3) + In []: new_x = linspace(0, 2*pi, 40) + In []: plot(x, y, 'r', new_x, interp(new_x), 'g') + +..image :: spline_of_sin.png + +Notice that the resulting curve is extremely smooth. It is this smoothness that makes splines +in general (and cubic splines in particular) so sought after. +:: + + # There is also an init_xy method + In []: interp2 = Spline(k=2) + In []: interp2.init_xy(x, y) + + +--------------------- +Optional Arguments +--------------------- + +At instantiation: + +#) bbox + This is a 2-element list specifying the endpoints of the approximation interval. + It default to [x[0],x[-1]] + +#) w + a 1D sequence of weights which defaults to all ones. + +#) s + If s is zero, the interpolation is exact. If s is not 0, the curve is smoothe subject to + the constraint that sum((w[i]*( y[i]-s(x[i]) ))**2,axis=0) <= s + +At calling: + +#) nu + Spline returns, not the spline function S, but the (nu)th derivative of S. nu defaults + to 0, so Spline usually returns the zeroth derivative of S, ie S. + +----------------- +Special Methods +----------------- + +#) set_smoothing_factor(s) +#) get_knots + returns the positions of the knots of the spline +#) get_coeffs + returns the coefficients of the +#) get_residual + returns the weighted sum of the errors (due to smoothing) at the data points + sum((w[i]*( y[i]-s(x[i]) ))**2,axis=0) +#) integral(a, b) + returns the integral from a to b +#) derivatives(x) + returns all the derivatives of the spline at point x +#) roots + This only works for cubic splines. But it returns the places where the spline + is identically zero. From scipy-svn at scipy.org Thu Jul 31 19:58:47 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 18:58:47 -0500 (CDT) Subject: [Scipy-svn] r4591 - in branches/Interpolate1D: . docs Message-ID: <20080731235847.5DE1D39C226@scipy.org> Author: fcady Date: 2008-07-31 18:58:42 -0500 (Thu, 31 Jul 2008) New Revision: 4591 Added: branches/Interpolate1D/_fitpack.pyf Removed: branches/Interpolate1D/fitpack.pyf Modified: branches/Interpolate1D/TODO.txt branches/Interpolate1D/docs/tutorial.rst branches/Interpolate1D/example_script.py branches/Interpolate1D/fitpack_wrapper.py branches/Interpolate1D/interpolate1d.py branches/Interpolate1D/interpolate_wrapper.py branches/Interpolate1D/setup.py Log: fitpack.pyf to _fitpack.pyf to make it more in the background, added 'nearest' interpolate method for more functionality Modified: branches/Interpolate1D/TODO.txt =================================================================== --- branches/Interpolate1D/TODO.txt 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/TODO.txt 2008-07-31 23:58:42 UTC (rev 4591) @@ -15,11 +15,11 @@ In fitpack_wrapper the smoothing parameter is s. It now defaults to 0.0 (exact interpolation). Zero smoothing and moderate (s ~ 1) are fast, but small non-zero s makes the algorithm VERY slow. + + This appears resolved, in that Spline can do smoothing (but defaults + to not), and user-defined classes are allowed to smooth. - Currently the user does see s in Interpolate1d; no smoothing - is available. The Spline class, however, has it available (default = 0.0). - **pick best spline Under-the-hood machinery currently comes from _interpolate.cpp (used in enthought.interpolate) and FITPACK (Fortran, used in @@ -41,6 +41,21 @@ that stuff needs to be cleaned up, and the rest needs to be either removed or set aside. +**allow y to be 2-dimensional? + It is not decided whether this feature should be supported, but + I don't think it should; I think there should be another class with + that functionality which wraps Interpolate1d. The main reasons + are: + 1) interpolation should probably be along columns, so the user + can enter data as enter the data as y=array([obs1, obs2, ...]). But + the interpolate_wrapper and fitpack_wrapper interpolate along + rows; this means there would be messy transposes in the code. + 2) FITPACK doesn't support 2D y arrays, which means we would + have to store the y columns separately + 3) If we remove bad data, bearing in mind (2), we would also + have to store copies of x, since the bad data in the y cols aren't + at the same locations, meaning that different data points should be + deleted for each column. **better handling of variable types Currently everything is cast to a float64 if it is not already @@ -56,7 +71,7 @@ -*********** DOCUENTATION-TYPE AND NON-URGENT TASKS ******* +*********** DOCUMENTATION-TYPE AND NON-URGENT TASKS ******* **improve regression tests desired for fitpack_wrapper and _interpolate_wrapper @@ -64,10 +79,7 @@ really basic. -**improve unit tests - interpolate1d.py has its own unit tests, which also call - the unit tests of fitpack_wrapper and _interpolate_wrapper. - But they could surely be made better. +**improve unit tests in tests directory **comment all files @@ -102,7 +114,7 @@ ********* LONGER TERM ************ **update for 2D and ND - This will probably take the form of two additional + This will take the form of two additional classes both modelled after interpolate1d. Thus it probably shouldn't be done until interpolate1d is more settled. @@ -147,20 +159,3 @@ differentiation of functionality (one for splines, one for simple operations, etc), rather than being a holdover of where they were stolen from. - - -**allow y to be 2-dimensional? - It is not decided whether this feature should be supported, but - I don't think it should; I think there should be another class with - that functionality which wraps Interpolate1d. The main reasons - are: - 1) interpolation should probably be along columns, so the user - can enter data as enter the data as y=array([obs1, obs2, ...]). But - the interpolate_wrapper and fitpack_wrapper interpolate along - rows; this means there would be messy transposes in the code. - 2) FITPACK doesn't support 2D y arrays, which means we would - have to store the y columns separately - 3) If we remove bad data, bearing in mind (2), we would also - have to store copies of x, since the bad data in the y cols aren't - at the same locations, meaning that different data points should be - deleted for each column. Copied: branches/Interpolate1D/_fitpack.pyf (from rev 4587, branches/Interpolate1D/fitpack.pyf) Modified: branches/Interpolate1D/docs/tutorial.rst =================================================================== --- branches/Interpolate1D/docs/tutorial.rst 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/docs/tutorial.rst 2008-07-31 23:58:42 UTC (rev 4591) @@ -481,6 +481,9 @@ #) s If s is zero, the interpolation is exact. If s is not 0, the curve is smoothe subject to the constraint that sum((w[i]*( y[i]-s(x[i]) ))**2,axis=0) <= s + + BEWARE : in the current implementation of the code, if s is small but not zero, + instantiating Spline can become painfully slow. At calling: Modified: branches/Interpolate1D/example_script.py =================================================================== --- branches/Interpolate1D/example_script.py 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/example_script.py 2008-07-31 23:58:42 UTC (rev 4591) @@ -82,10 +82,6 @@ interp = I.Interpolate1d(x, y, fitpack_wrapper.Spline(k=2)) y_quad2 = interp(newx) - # 3rd order spline with additional keyword arguments - interp = I.Interpolate1d(x, y, fitpack_wrapper.Spline, kindkw = {'k':3}) - y_cubic2 = interp(newx) - # 4th order spline interp = I.Interpolate1d(x, y, 'Quartic') y_quartic2 = interp(newx) @@ -100,7 +96,6 @@ P.plot(newx, y_block2, 'g') P.plot(newx, y_linear2, 'b') P.plot(newx, y_quad2, 'r') - P.plot(newx, y_cubic2, 'm') P.plot(newx, y_quartic2, 'y') P.plot(newx, y_quintic2, 'y') P.title( "same data through different interface" ) Deleted: branches/Interpolate1D/fitpack.pyf =================================================================== --- branches/Interpolate1D/fitpack.pyf 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/fitpack.pyf 2008-07-31 23:58:42 UTC (rev 4591) @@ -1,479 +0,0 @@ -! -*- f90 -*- -! Author: Pearu Peterson -! -python module _dfitpack ! in - - usercode ''' - -static double dmax(double* seq,int len) { - double val; - int i; - if (len<1) - return -1e308; - val = seq[0]; - for(i=1;ival) val = seq[i]; - return val; -} -static double dmin(double* seq,int len) { - double val; - int i; - if (len<1) - return 1e308; - val = seq[0]; - for(i=1;ival1) return val1; - val1 = dmax(tx,nx); - return val2 - (val1-val2)/nx; -} -static double calc_e(double* x,int m,double* tx,int nx) { - double val1 = dmax(x,m); - double val2 = dmax(tx,nx); - if (val2=8) :: n=len(t) - real*8 dimension(n),depend(n),check(len(c)==n) :: c - real*8 dimension(mest),intent(out),depend(mest) :: zero - integer optional,intent(in),depend(n) :: mest=3*(n-7) - integer intent(out) :: m - integer intent(out) :: ier - end subroutine sproot - - subroutine spalde(t,n,c,k,x,d,ier) - ! d,ier = spalde(t,c,k,x) - - callprotoargument double*,int*,double*,int*,double*,double*,int* - callstatement {int k1=k+1; (*f2py_func)(t,&n,c,&k1,&x,d,&ier); } - - real*8 dimension(n) :: t - integer intent(hide),depend(t) :: n=len(t) - real*8 dimension(n),depend(n),check(len(c)==n) :: c - integer intent(in) :: k - real*8 intent(in) :: x - real*8 dimension(k+1),intent(out),depend(k) :: d - integer intent(out) :: ier - end subroutine spalde - - subroutine curfit(iopt,m,x,y,w,xb,xe,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) - ! in curfit.f - integer :: iopt - integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) - real*8 dimension(m) :: x - real*8 dimension(m),depend(m),check(len(y)==m) :: y - real*8 dimension(m),depend(m),check(len(w)==m) :: w - real*8 optional,depend(x),check(xb<=x[0]) :: xb = x[0] - real*8 optional,depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] - integer optional,check(1<=k && k <=5),intent(in) :: k=3 - real*8 optional,check(s>=0.0) :: s = 0.0 - integer intent(hide),depend(t) :: nest=len(t) - integer intent(out), depend(nest) :: n=nest - real*8 dimension(nest),intent(inout) :: t - real*8 dimension(n),intent(out) :: c - real*8 intent(out) :: fp - real*8 dimension(lwrk),intent(inout) :: wrk - integer intent(hide),depend(wrk) :: lwrk=len(wrk) - integer dimension(nest),intent(inout) :: iwrk - integer intent(out) :: ier - end subroutine curfit - - subroutine percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) - ! in percur.f - integer :: iopt - integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) - real*8 dimension(m) :: x - real*8 dimension(m),depend(m),check(len(y)==m) :: y - real*8 dimension(m),depend(m),check(len(w)==m) :: w - integer optional,check(1<=k && k <=5),intent(in) :: k=3 - real*8 optional,check(s>=0.0) :: s = 0.0 - integer intent(hide),depend(t) :: nest=len(t) - integer intent(out), depend(nest) :: n=nest - real*8 dimension(nest),intent(inout) :: t - real*8 dimension(n),intent(out) :: c - real*8 intent(out) :: fp - real*8 dimension(lwrk),intent(inout) :: wrk - integer intent(hide),depend(wrk) :: lwrk=len(wrk) - integer dimension(nest),intent(inout) :: iwrk - integer intent(out) :: ier - end subroutine percur - - - subroutine parcur(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,c,fp,wrk,lwrk,iwrk,ier) - ! in parcur.f - integer check(iopt>=-1 && iopt <= 1):: iopt - integer check(ipar == 1 || ipar == 0) :: ipar - integer check(idim > 0 && idim < 11) :: idim - integer intent(hide),depend(u,k),check(m>k) :: m=len(u) - real*8 dimension(m), intent(inout) :: u - integer intent(hide),depend(x,idim,m),check(mx>=idim*m) :: mx=len(x) - real*8 dimension(mx) :: x - real*8 dimension(m) :: w - real*8 :: ub - real*8 :: ue - integer optional, check(1<=k && k<=5) :: k=3.0 - real*8 optional, check(s>=0.0) :: s = 0.0 - integer intent(hide), depend(t) :: nest=len(t) - integer intent(out), depend(nest) :: n=nest - real*8 dimension(nest), intent(inout) :: t - integer intent(hide), depend(c,nest,idim), check(nc>=idim*nest) :: nc=len(c) - real*8 dimension(nc), intent(out) :: c - real*8 intent(out) :: fp - real*8 dimension(lwrk), intent(inout) :: wrk - integer intent(hide),depend(wrk) :: lwrk=len(wrk) - integer dimension(nest), intent(inout) :: iwrk - integer intent(out) :: ier - end subroutine parcur - - - subroutine fpcurf0(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) - ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ - ! fpcurf0(x,y,k,[w,xb,xe,s,nest]) - - fortranname fpcurf - callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* - callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) - - integer intent(hide) :: iopt = 0 - real*8 dimension(m),intent(in,out) :: x - real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y - real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out) :: w = 1.0 - integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) - real*8 intent(in,out),depend(x),check(xb<=x[0]) :: xb = x[0] - real*8 intent(in,out),depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] - integer check(1<=k && k<=5),intent(in,out) :: k - real*8 check(s>=0.0),depend(m),intent(in,out) :: s = m - integer intent(in),depend(m,s,k,k1),check(nest>=2*k1) :: nest = (s==0.0?m+k+1:MAX(m/2,2*k1)) - real*8 intent(hide) :: tol = 0.001 - integer intent(hide) :: maxit = 20 - integer intent(hide),depend(k) :: k1=k+1 - integer intent(hide),depend(k) :: k2=k+2 - integer intent(out) :: n - real*8 dimension(nest),intent(out),depend(nest) :: t - real*8 dimension(nest),depend(nest),intent(out) :: c - real*8 intent(out) :: fp - real*8 dimension(nest),depend(nest),intent(out,cache) :: fpint - real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk - integer dimension(nest),depend(nest),intent(out,cache) :: nrdata - integer intent(out) :: ier - end subroutine fpcurf0 - - subroutine fpcurf1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) - ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ - ! fpcurf1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier) - - fortranname fpcurf - callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* - callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) - - integer intent(hide) :: iopt = 1 - real*8 dimension(m),intent(in,out,overwrite) :: x - real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out,overwrite) :: y - real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out,overwrite) :: w - integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) - real*8 intent(in,out) :: xb - real*8 intent(in,out) :: xe - integer check(1<=k && k<=5),intent(in,out) :: k - real*8 check(s>=0.0),intent(in,out) :: s - integer intent(hide),depend(t) :: nest = len(t) - real*8 intent(hide) :: tol = 0.001 - integer intent(hide) :: maxit = 20 - integer intent(hide),depend(k) :: k1=k+1 - integer intent(hide),depend(k) :: k2=k+2 - integer intent(in,out) :: n - real*8 dimension(nest),intent(in,out,overwrite) :: t - real*8 dimension(nest),depend(nest),check(len(c)==nest),intent(in,out,overwrite) :: c - real*8 intent(in,out) :: fp - real*8 dimension(nest),depend(nest),check(len(fpint)==nest),intent(in,out,cache,overwrite) :: fpint - real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk - integer dimension(nest),depend(nest),check(len(nrdata)==nest),intent(in,out,cache,overwrite) :: nrdata - integer intent(in,out) :: ier - end subroutine fpcurf1 - - subroutine fpcurfm1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) - ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ - ! fpcurfm1(x,y,k,t,[w,xb,xe]) - - fortranname fpcurf - callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* - callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) - - integer intent(hide) :: iopt = -1 - real*8 dimension(m),intent(in,out) :: x - real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y - real*8 dimension(m),depend(m),check(len(w)==m),intent(in,out) :: w = 1.0 - integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) - real*8 intent(in,out),depend(x),check(xb<=x[0]) :: xb = x[0] - real*8 intent(in,out),depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] - integer check(1<=k && k<=5),intent(in,out) :: k - real*8 intent(out) :: s = -1 - integer intent(hide),depend(n) :: nest = n - real*8 intent(hide) :: tol = 0.001 - integer intent(hide) :: maxit = 20 - integer intent(hide),depend(k) :: k1=k+1 - integer intent(hide),depend(k) :: k2=k+2 - integer intent(out),depend(t) :: n = len(t) - real*8 dimension(n),intent(in,out,overwrite) :: t - real*8 dimension(nest),depend(nest),intent(out) :: c - real*8 intent(out) :: fp - real*8 dimension(nest),depend(nest),intent(out,cache) :: fpint - real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk - integer dimension(nest),depend(nest),intent(out,cache) :: nrdata - integer intent(out) :: ier - end subroutine fpcurfm1 - - !!!!!!!!!! Bivariate spline !!!!!!!!!!! - - subroutine bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk,iwrk,kwrk,ier) - ! z,ier = bispev(tx,ty,c,kx,ky,x,y) - real*8 dimension(nx),intent(in) :: tx - integer intent(hide),depend(tx) :: nx=len(tx) - real*8 dimension(ny),intent(in) :: ty - integer intent(hide),depend(ty) :: ny=len(ty) - real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& - check(len(c)==(nx-kx-1)*(ny-ky-1)):: c - integer :: kx - integer :: ky - real*8 intent(in),dimension(mx) :: x - integer intent(hide),depend(x) :: mx=len(x) - real*8 intent(in),dimension(my) :: y - integer intent(hide),depend(y) :: my=len(y) - real*8 dimension(mx,my),depend(mx,my),intent(out,c) :: z - real*8 dimension(lwrk),depend(lwrk),intent(hide,cache) :: wrk - integer intent(hide),depend(mx,kx,my,ky) :: lwrk=mx*(kx+1)+my*(ky+1) - integer dimension(kwrk),depend(kwrk),intent(hide,cache) :: iwrk - integer intent(hide),depend(mx,my) :: kwrk=mx+my - integer intent(out) :: ier - end subroutine bispev - - subroutine surfit_smth(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest,& - nmax,eps,nx,tx,ny,ty,c,fp,wrk1,lwrk1,wrk2,lwrk2,& - iwrk,kwrk,ier) - ! nx,tx,ny,ty,c,fp,ier = surfit_smth(x,y,z,[w,xb,xe,yb,ye,kx,ky,s,eps,lwrk2]) - - fortranname surfit - - integer intent(hide) :: iopt=0 - integer intent(hide),depend(x,kx,ky),check(m>=(kx+1)*(ky+1)) & - :: m=len(x) - real*8 dimension(m) :: x - real*8 dimension(m),depend(m),check(len(y)==m) :: y - real*8 dimension(m),depend(m),check(len(z)==m) :: z - real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 - real*8 optional,depend(x,m) :: xb=dmin(x,m) - real*8 optional,depend(x,m) :: xe=dmax(x,m) - real*8 optional,depend(y,m) :: yb=dmin(y,m) - real*8 optional,depend(y,m) :: ye=dmax(y,m) - integer check(1<=kx && kx<=5) :: kx = 3 - integer check(1<=ky && ky<=5) :: ky = 3 - real*8 optional,check(0.0<=s) :: s = m - integer optional,depend(kx,m),check(nxest>=2*(kx+1)) & - :: nxest = imax(kx+1+sqrt(m/2),2*(kx+1)) - integer optional,depend(ky,m),check(nyest>=2*(ky+1)) & - :: nyest = imax(ky+1+sqrt(m/2),2*(ky+1)) - integer intent(hide),depend(nxest,nyest) :: nmax=MAX(nxest,nyest) - real*8 optional,check(0.0=(kx+1)*(ky+1)) & - :: m=len(x) - real*8 dimension(m) :: x - real*8 dimension(m),depend(m),check(len(y)==m) :: y - real*8 dimension(m),depend(m),check(len(z)==m) :: z - real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 - real*8 optional,depend(x,tx,m,nx) :: xb=calc_b(x,m,tx,nx) - real*8 optional,depend(x,tx,m,nx) :: xe=calc_e(x,m,tx,nx) - real*8 optional,depend(y,ty,m,ny) :: yb=calc_b(y,m,ty,ny) - real*8 optional,depend(y,ty,m,ny) :: ye=calc_e(y,m,ty,ny) - integer check(1<=kx && kx<=5) :: kx = 3 - integer check(1<=ky && ky<=5) :: ky = 3 - real*8 intent(hide) :: s = 0.0 - integer intent(hide),depend(nx) :: nxest = nx - integer intent(hide),depend(ny) :: nyest = ny - integer intent(hide),depend(nx,ny) :: nmax=MAX(nx,ny) - real*8 optional,check(0.0kx) :: mx=len(x) - real*8 dimension(mx) :: x - integer intent(hide),depend(y,ky),check(my>ky) :: my=len(y) - real*8 dimension(my) :: y - real*8 dimension(mx*my),depend(mx,my),check(len(z)==mx*my) :: z - real*8 optional,depend(x,mx) :: xb=dmin(x,mx) - real*8 optional,depend(x,mx) :: xe=dmax(x,mx) - real*8 optional,depend(y,my) :: yb=dmin(y,my) - real*8 optional,depend(y,my) :: ye=dmax(y,my) - integer optional,check(1<=kx && kx<=5) :: kx = 3 - integer optional,check(1<=ky && ky<=5) :: ky = 3 - real*8 optional,check(0.0<=s) :: s = 0.0 - integer intent(hide),depend(kx,mx),check(nxest>=2*(kx+1)) & - :: nxest = mx+kx+1 - integer intent(hide),depend(ky,my),check(nyest>=2*(ky+1)) & - :: nyest = my+ky+1 - integer intent(out) :: nx - real*8 dimension(nxest),intent(out),depend(nxest) :: tx - integer intent(out) :: ny - real*8 dimension(nyest),intent(out),depend(nyest) :: ty - real*8 dimension((nxest-kx-1)*(nyest-ky-1)), & - depend(kx,ky,nxest,nyest),intent(out) :: c - real*8 intent(out) :: fp - real*8 dimension(lwrk),intent(cache,hide),depend(lwrk) :: wrk - integer intent(hide),depend(mx,my,kx,ky,nxest,nyest) & - :: lwrk=calc_regrid_lwrk(mx,my,kx,ky,nxest,nyest) - integer dimension(kwrk),depend(kwrk),intent(cache,hide) :: iwrk - integer intent(hide),depend(mx,my,nxest,nyest) & - :: kwrk=3+mx+my+nxest+nyest - integer intent(out) :: ier - end subroutine regrid_smth - - function dblint(tx,nx,ty,ny,c,kx,ky,xb,xe,yb,ye,wrk) - ! iy = dblint(tx,ty,c,kx,ky,xb,xe,yb,ye) - real*8 dimension(nx),intent(in) :: tx - integer intent(hide),depend(tx) :: nx=len(tx) - real*8 dimension(ny),intent(in) :: ty - integer intent(hide),depend(ty) :: ny=len(ty) - real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& - check(len(c)==(nx-kx-1)*(ny-ky-1)):: c - integer :: kx - integer :: ky - real*8 intent(in) :: xb - real*8 intent(in) :: xe - real*8 intent(in) :: yb - real*8 intent(in) :: ye - real*8 dimension(nx+ny-kx-ky-2),depend(nx,ny,kx,ky),intent(cache,hide) :: wrk - real*8 :: dblint - end function dblint - end interface -end python module _dfitpack - Modified: branches/Interpolate1D/fitpack_wrapper.py =================================================================== --- branches/Interpolate1D/fitpack_wrapper.py 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/fitpack_wrapper.py 2008-07-31 23:58:42 UTC (rev 4591) @@ -1,8 +1,13 @@ """ This module is used for spline interpolation, and functions as a wrapper around the FITPACK Fortran interpolation -package. +package. Its functionality is contained in the Spline +class. +Spline is primarily meant to be called by Interpolate1d +or inter1d, but is a stand-alone class in its own right. + + The code has been modified from an older version of scipy.interpolate, where it was directly called by the user. As such, it includes functionality not available through @@ -29,10 +34,6 @@ Can include least-squares fitting. - See also: - - splrep, splev, sproot, spint, spalde - an older wrapping of FITPACK - BivariateSpline - a similar class for bivariate spline interpolation """ def __init__(self, x=None, y=None, w=None, bbox = [None]*2, k=3, s=0.0): @@ -43,16 +44,14 @@ Optional input: w - positive 1-d sequence of weights - bbox - 2-sequence specifying the boundary of + bbox - 2-sequence specifying the boundary of the approximation interval. By default, bbox=[x[0],x[-1]] - k=3 - degree of the univariate spline. + k=3 - degree of the univariate spline. s - positive smoothing factor defined for estimation condition: sum((w[i]*( y[i]-s(x[i]) ))**2,axis=0) <= s - Default s=len(w) which should be a good value - if 1/w[i] is an estimate of the standard - deviation of y[i]. + Default s=0 """ self._k = k Modified: branches/Interpolate1D/interpolate1d.py =================================================================== --- branches/Interpolate1D/interpolate1d.py 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/interpolate1d.py 2008-07-31 23:58:42 UTC (rev 4591) @@ -1,18 +1,22 @@ # FIXME: information strings giving mathematical descriptions of the actions # of the functions. -from interpolate_wrapper import linear, logarithmic, block, \ - block_average_above, atleast_1d_and_contiguous +from interpolate_wrapper import atleast_1d_and_contiguous, \ + linear, logarithmic, block, block_average_above, nearest from fitpack_wrapper import Spline import numpy as np from numpy import array, arange, empty, float64, NaN # dictionary of interpolation functions/classes/objects method_register = \ - { 'linear' : linear, + { # functions + 'linear' : linear, 'logarithmic' : logarithmic, 'block' : block, 'block_average_above' : block_average_above, + 'nearest' : nearest, + + # Splines 'Spline' : Spline, 'spline' : Spline, 'Quadratic' : Spline(k=2), 'quadratic' : Spline(k=2), 'Quad' : Spline(k=2), 'quad' : Spline(k=2), Modified: branches/Interpolate1D/interpolate_wrapper.py =================================================================== --- branches/Interpolate1D/interpolate_wrapper.py 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/interpolate_wrapper.py 2008-07-31 23:58:42 UTC (rev 4591) @@ -6,9 +6,27 @@ import sys import _interpolate # C extension. Does all the real work. -def atleast_1d_and_contiguous(ary, typecode = np.float64): - return np.atleast_1d( np.ascontiguousarray(ary, typecode) ) +def atleast_1d_and_contiguous(ary, dtype = np.float64): + return np.atleast_1d( np.ascontiguousarray(ary, dtype) ) +def nearest(x, y, new_x): + """ Rounds each new_x[i] to the closest value in x + and returns corresponding y. + """ + shifted_x = np.concatenate(( np.array([x[0]-1]) , x[0:-1] )) + + midpoints_of_x = atleast_1d_and_contiguous( .5*(x + shifted_x) ) + new_x = atleast_1d_and_contiguous(new_x) + + TINY = 1e-10 + indices = np.searchsorted(midpoints_of_x, new_x+TINY)-1 + indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(np.int)) + new_y = np.take(y, indices, axis=-1) + + return new_y + + + def linear(x, y, new_x): """ Linearly interpolates values in new_x based on the values in x and y @@ -106,7 +124,6 @@ For each new_x[i], finds largest j such that x[j] < new_x[j], and returns y[j]. """ - # find index of values in x that preceed values in x # This code is a little strange -- we really want a routine that # returns the index of values where x[j] < x[index] Modified: branches/Interpolate1D/setup.py =================================================================== --- branches/Interpolate1D/setup.py 2008-07-31 23:46:55 UTC (rev 4590) +++ branches/Interpolate1D/setup.py 2008-07-31 23:58:42 UTC (rev 4591) @@ -22,7 +22,7 @@ # Fortran routines (collectively "FITPACK" for spline interpolation) config.add_extension('_dfitpack', - sources=['fitpack.pyf'], + sources=['_fitpack.pyf'], libraries=['_fitpack'], ) From scipy-svn at scipy.org Thu Jul 31 20:06:21 2008 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 31 Jul 2008 19:06:21 -0500 (CDT) Subject: [Scipy-svn] r4592 - branches/Interpolate1D Message-ID: <20080801000621.36E5839C164@scipy.org> Author: fcady Date: 2008-07-31 19:06:19 -0500 (Thu, 31 Jul 2008) New Revision: 4592 Modified: branches/Interpolate1D/regression_test.py Log: commented out most of regression_test so that nosetests would pass Modified: branches/Interpolate1D/regression_test.py =================================================================== --- branches/Interpolate1D/regression_test.py 2008-07-31 23:58:42 UTC (rev 4591) +++ branches/Interpolate1D/regression_test.py 2008-08-01 00:06:19 UTC (rev 4592) @@ -10,24 +10,24 @@ """ import shelve, time -from interpolate1d import Test +#from tests/test_interpolate1d import Test # name of log file to which all data is stored. filename = 'regression_test.dbm' -log_total = shelve.open(filename) +#log_total = shelve.open(filename) current_time = str(time.localtime()[0:5]) # specified up to the minute # run all tests in interpolate1d's test class -test_list = [name for name in dir(Test) if name.find('test_') == 0] +#test_list = [name for name in dir(Test) if name.find('test_') == 0] log_now = {} # record time taken for each test -for test_name in test_list: - t1 = time.clock() - eval('Test.%s' % test_name) - t2 = time.clock() - log_now[test_name] = t2-t1 +#for test_name in test_list: + # t1 = time.clock() + # eval('Test.%s' % test_name) + #t2 = time.clock() + #log_now[test_name] = t2-t1 -log_total[current_time] = log_now -log_total.close() +#log_total[current_time] = log_now +#log_total.close()