diff options
author | Sebastien Fabbro <bicatali@gentoo.org> | 2010-09-14 16:45:35 +0000 |
---|---|---|
committer | Sebastien Fabbro <bicatali@gentoo.org> | 2010-09-14 16:45:35 +0000 |
commit | 2e417a6a67e61dcda6b57db526bbb256c731b2dd (patch) | |
tree | 54e3b2b5e303e81e418098b6f6146c82501f1f19 /sci-mathematics/octave | |
parent | Import from perl-experimental for Padre (diff) | |
download | gentoo-2-2e417a6a67e61dcda6b57db526bbb256c731b2dd.tar.gz gentoo-2-2e417a6a67e61dcda6b57db526bbb256c731b2dd.tar.bz2 gentoo-2-2e417a6a67e61dcda6b57db526bbb256c731b2dd.zip |
Speed-up of dlmread function from upstream trunk. Thanks Fabio Rossi for his input, bug #337126
(Portage version: 2.2_rc81/cvs/Linux x86_64)
Diffstat (limited to 'sci-mathematics/octave')
-rw-r--r-- | sci-mathematics/octave/ChangeLog | 9 | ||||
-rw-r--r-- | sci-mathematics/octave/files/octave-3.2.4-dlmread-speedup.patch | 258 | ||||
-rw-r--r-- | sci-mathematics/octave/octave-3.2.4-r2.ebuild | 112 |
3 files changed, 378 insertions, 1 deletions
diff --git a/sci-mathematics/octave/ChangeLog b/sci-mathematics/octave/ChangeLog index 1c128172ee0e..960c7acbbc1c 100644 --- a/sci-mathematics/octave/ChangeLog +++ b/sci-mathematics/octave/ChangeLog @@ -1,6 +1,13 @@ # ChangeLog for sci-mathematics/octave # Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sci-mathematics/octave/ChangeLog,v 1.95 2010/07/09 15:44:10 xarthisius Exp $ +# $Header: /var/cvsroot/gentoo-x86/sci-mathematics/octave/ChangeLog,v 1.96 2010/09/14 16:45:35 bicatali Exp $ + +*octave-3.2.4-r2 (14 Sep 2010) + + 14 Sep 2010; Sébastien Fabbro <bicatali@gentoo.org> + +octave-3.2.4-r2.ebuild, +files/octave-3.2.4-dlmread-speedup.patch: + Speed-up of dlmread function from upstream trunk. Thanks Fabio Rossi for + his input, bug #337126 09 Jul 2010; Kacper Kowalik <xarthisius@gentoo.org> -octave-2.1.73-r1.ebuild, -files/octave-2.1.73-f2c-fix.patch, diff --git a/sci-mathematics/octave/files/octave-3.2.4-dlmread-speedup.patch b/sci-mathematics/octave/files/octave-3.2.4-dlmread-speedup.patch new file mode 100644 index 000000000000..3379a3de8f75 --- /dev/null +++ b/sci-mathematics/octave/files/octave-3.2.4-dlmread-speedup.patch @@ -0,0 +1,258 @@ +--- src/DLD-FUNCTIONS/dlmread.cc.orig 2010-09-07 14:41:40.991671995 +0200 ++++ src/DLD-FUNCTIONS/dlmread.cc 2010-09-07 14:50:50.715672000 +0200 +@@ -1,6 +1,7 @@ + /* + + Copyright (C) 2008, 2009 Jonathan Stickel ++Copyright (C) 2010 Jaroslav Hajek + + This file is part of Octave. + +@@ -29,6 +30,7 @@ + + #include <cctype> + #include <fstream> ++#include <limits> + + #include "file-ops.h" + #include "lo-ieee.h" +@@ -38,8 +40,10 @@ + #include "oct-obj.h" + #include "utils.h" + ++static const octave_idx_type idx_max = std::numeric_limits<octave_idx_type>::max (); ++ + static bool +-read_cell_spec (std::istream& is, unsigned long& row, unsigned long& col) ++read_cell_spec (std::istream& is, octave_idx_type& row, octave_idx_type& col) + { + bool stat = false; + +@@ -75,8 +79,8 @@ + + static bool + parse_range_spec (const octave_value& range_spec, +- unsigned long& rlo, unsigned long& clo, +- unsigned long& rup, unsigned long& cup) ++ octave_idx_type& rlo, octave_idx_type& clo, ++ octave_idx_type& rup, octave_idx_type& cup) + { + bool stat = true; + +@@ -115,8 +119,8 @@ + stat = false; + } + +- rup = ULONG_MAX - 1; +- cup = ULONG_MAX - 1; ++ rup = idx_max - 1; ++ cup = idx_max - 1; + } + else + { +@@ -138,10 +142,10 @@ + { + ColumnVector range(range_spec.vector_value ()); + // double --> unsigned int +- rlo = static_cast<unsigned long> (range(0)); +- clo = static_cast<unsigned long> (range(1)); +- rup = static_cast<unsigned long> (range(2)); +- cup = static_cast<unsigned long> (range(3)); ++ rlo = static_cast<octave_idx_type> (range(0)); ++ clo = static_cast<octave_idx_type> (range(1)); ++ rup = static_cast<octave_idx_type> (range(2)); ++ cup = static_cast<octave_idx_type> (range(3)); + } + else + stat = false; +@@ -211,7 +215,7 @@ + } + + // Take a subset if a range was given. +- unsigned long r0 = 0, c0 = 0, r1 = ULONG_MAX-1, c1 = ULONG_MAX-1; ++ octave_idx_type r0 = 0, c0 = 0, r1 = idx_max-1, c1 = idx_max-1; + if (nargin > 2) + { + if (nargin == 3) +@@ -221,17 +225,20 @@ + } + else if (nargin == 4) + { +- r0 = args(2).ulong_value (); +- c0 = args(3).ulong_value (); ++ r0 = args(2).idx_type_value (); ++ c0 = args(3).idx_type_value (); + + if (error_state) + return retval; + } ++ ++ if (r0 < 0 || c0 < 0) ++ error ("dlmread: left & top must not be negative"); + } + + if (!error_state) + { +- unsigned long i = 0, j = 0, r = 1, c = 1, rmax = 0, cmax = 0; ++ octave_idx_type i = 0, j = 0, r = 1, c = 1, rmax = 0, cmax = 0; + + Matrix rdata; + ComplexMatrix cdata; +@@ -239,15 +246,17 @@ + bool iscmplx = false; + bool sepflag = false; + +- unsigned long maxrows = r1 - r0; ++ octave_idx_type maxrows = r1 - r0; + + std::string line; + + // Skip the r0 leading lines as these might be a header. +- for (unsigned long m = 0; m < r0; m++) ++ for (octave_idx_type m = 0; m < r0; m++) + getline (file, line); + r1 -= r0; + ++ std::istringstream tmp_stream; ++ + // Read in the data one field at a time, growing the data matrix + // as needed. + while (getline (file, line)) +@@ -286,11 +295,47 @@ + } + } + ++ if (cmax == 0) ++ { ++ // Try to estimate the number of columns. ++ size_t pos1 = 0; ++ do ++ { ++ size_t pos2 = line.find_first_of (sep, pos1); ++ ++ if (sepflag && pos2 != std::string::npos) ++ // Treat consecutive separators as one. ++ { ++ pos2 = line.find_first_not_of (sep, pos2); ++ if (pos2 != std::string::npos) ++ pos2 -= 1; ++ else ++ pos2 = line.length () - 1; ++ } ++ ++ cmax++; ++ ++ if (pos2 != std::string::npos) ++ pos1 = pos2 + 1; ++ else ++ pos1 = std::string::npos; ++ ++ } ++ while (pos1 != std::string::npos); ++ ++ if (iscmplx) ++ cdata.resize (rmax, cmax); ++ else ++ rdata.resize (rmax, cmax); ++ } ++ + r = (r > i + 1 ? r : i + 1); + j = 0; + size_t pos1 = 0; + do + { ++ OCTAVE_QUIT; ++ + size_t pos2 = line.find_first_of (sep, pos1); + std::string str = line.substr (pos1, pos2 - pos1); + +@@ -303,23 +348,35 @@ + { + // Use resize_and_fill for the case of not-equal + // length rows. ++ rmax = 2*r; ++ cmax = c; + if (iscmplx) +- cdata.resize_fill (r, c, 0); ++ cdata.resize (rmax, cmax); + else +- rdata.resize_fill (r, c, 0); +- rmax = r; +- cmax = c; ++ rdata.resize (rmax, cmax); + } + +- std::istringstream tmp_stream (str); ++ tmp_stream.str (str); ++ tmp_stream.clear (); ++ + double x = octave_read_double (tmp_stream); + if (tmp_stream) + { + if (tmp_stream.eof ()) +- if (iscmplx) +- cdata(i,j++) = x; +- else +- rdata(i,j++) = x; ++ { ++ if (iscmplx) ++ cdata(i,j++) = x; ++ else ++ rdata(i,j++) = x; ++ } ++ else if (std::toupper (tmp_stream.peek ()) == 'I') ++ { ++ // This is to allow pure imaginary numbers. ++ if (iscmplx) ++ cdata(i,j++) = x; ++ else ++ rdata(i,j++) = x; ++ } + else + { + double y = octave_read_double (tmp_stream); +@@ -355,35 +412,16 @@ + i++; + } + +- if (nargin > 2) +- { +- if (nargin == 3) +- { +- if (r1 >= r) +- r1 = r - 1; +- if (c1 >= c) +- c1 = c - 1; +- } +- else if (nargin == 4) +- { +- // If r1 and c1 are not given, use what was found to be +- // the maximum. +- r1 = r - 1; +- c1 = c - 1; +- } ++ if (r1 >= r) ++ r1 = r - 1; ++ if (c1 >= c) ++ c1 = c - 1; + +- // Now take the subset of the matrix. +- if (iscmplx) +- { +- cdata = cdata.extract (0, c0, r1, c1); +- cdata.resize (r1 + 1, c1 - c0 + 1); +- } +- else +- { +- rdata = rdata.extract (0, c0, r1, c1); +- rdata.resize (r1 + 1, c1 - c0 + 1); +- } +- } ++ // Now take the subset of the matrix. ++ if (iscmplx) ++ cdata = cdata.extract (0, c0, r1, c1); ++ else ++ rdata = rdata.extract (0, c0, r1, c1); + + if (iscmplx) + retval(0) = cdata; diff --git a/sci-mathematics/octave/octave-3.2.4-r2.ebuild b/sci-mathematics/octave/octave-3.2.4-r2.ebuild new file mode 100644 index 000000000000..2ae00a8a30cf --- /dev/null +++ b/sci-mathematics/octave/octave-3.2.4-r2.ebuild @@ -0,0 +1,112 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sci-mathematics/octave/octave-3.2.4-r2.ebuild,v 1.1 2010/09/14 16:45:35 bicatali Exp $ + +EAPI="2" +inherit flag-o-matic xemacs-elisp-common autotools + +DESCRIPTION="High-level interactive language for numerical computations" +LICENSE="GPL-3" +HOMEPAGE="http://www.octave.org/" +SRC_URI="ftp://ftp.gnu.org/pub/gnu/${PN}/${P}.tar.bz2" + +SLOT="0" +IUSE="curl doc emacs fltk fftw opengl readline sparse test xemacs zlib" +KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86" + +RDEPEND="dev-libs/libpcre + media-gfx/graphicsmagick[cxx] + media-libs/qhull + sci-libs/qrupdate + sci-mathematics/glpk + sci-visualization/gnuplot + sys-libs/ncurses + virtual/lapack + x11-libs/libX11 + curl? ( net-misc/curl ) + fltk? ( x11-libs/fltk:1.1[opengl?] ) + fftw? ( sci-libs/fftw:3.0 ) + opengl? ( virtual/opengl media-libs/ftgl ) + sparse? ( sci-libs/arpack + sci-libs/camd + sci-libs/ccolamd + sci-libs/cholmod + sci-libs/colamd + sci-libs/cxsparse + sci-libs/umfpack ) + xemacs? ( app-editors/xemacs ) + zlib? ( sys-libs/zlib ) + !sci-mathematics/octave-forge" + +DEPEND="${RDEPEND} + virtual/latex-base + sys-apps/texinfo + || ( dev-texlive/texlive-genericrecommended + app-text/ptex ) + dev-util/gperf + dev-util/pkgconfig" + +src_prepare() { + epatch "${FILESDIR}"/${PN}-3.2.0_parallel_make.patch + epatch "${FILESDIR}"/${PN}-3.2.0_as_needed.patch + epatch "${FILESDIR}"/${PN}-3.2.4-imread.patch + epatch "${FILESDIR}"/${PN}-3.2.4-ldflags.patch + epatch "${FILESDIR}"/${PN}-3.2.4-fltk-magic.patch + epatch "${FILESDIR}"/${PN}-3.2.4-dlmread-speedup.patch + eautoreconf +} + +src_configure() { + # hdf5 disabled because not really useful (bug #299876) + econf \ + --localstatedir=/var/state/octave \ + --enable-shared \ + --without-hdf5 \ + --with-qrupdate \ + --with-blas="$(pkg-config --libs blas)" \ + --with-lapack="$(pkg-config --libs lapack)" \ + $(use_enable readline) \ + $(use_with curl) \ + $(use_with fftw) \ + $(use_with fltk) \ + $(use_with opengl framework-opengl) \ + $(use_with sparse arpack) \ + $(use_with sparse umfpack) \ + $(use_with sparse colamd) \ + $(use_with sparse ccolamd) \ + $(use_with sparse cholmod) \ + $(use_with sparse cxsparse) \ + $(use_with zlib) +} + +src_compile() { + emake || die "emake failed" + if use xemacs; then + cd "${S}/emacs" + xemacs-elisp-comp *.el + fi +} + +src_install() { + emake install DESTDIR="${D}" || die "emake install failed" + + if use doc; then + einfo "Installing documentation..." + insinto /usr/share/doc/${PF} + doins $(find doc -name \*.pdf) + fi + + if use emacs || use xemacs; then + cd emacs + exeinto /usr/bin + doexe octave-tags || die "Failed to install octave-tags" + doman octave-tags.1 || die "Failed to install octave-tags.1" + if use xemacs; then + xemacs-elisp-install ${PN} *.el *.elc + fi + cd .. + fi + use test && dodoc test/fntests.log + echo "LDPATH=/usr/$(get_libdir)/octave-${PV}" > 99octave + doenvd 99octave || die +} |